summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2013-04-03 09:41:20 +0200
committerDidier Raboud <odyx@debian.org>2013-04-03 09:41:20 +0200
commit26d9e7beb9e1d5f1b0cc6b265ac751f203002882 (patch)
tree782a22135b03c3a4f01514f0498df58b23e48f96
parent4561d764ff2157cc39ccd16ff64f5206c6e814ed (diff)
parent926126d5adf457dbc5c92fd83c7231415ea22d04 (diff)
downloadcolobot-26d9e7beb9e1d5f1b0cc6b265ac751f203002882.tar.gz
colobot-26d9e7beb9e1d5f1b0cc6b265ac751f203002882.tar.bz2
colobot-26d9e7beb9e1d5f1b0cc6b265ac751f203002882.zip
New snapshot of dev branch (254-g926126d)
-rw-r--r--CMakeLists.txt7
m---------data0
-rw-r--r--debian/changelog4
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/app/app.cpp19
-rw-r--r--src/app/app.h7
-rw-r--r--src/app/system_windows.cpp36
-rw-r--r--src/app/system_windows.h3
-rw-r--r--src/common/profile.h3
-rw-r--r--src/graphics/engine/engine.cpp21
-rw-r--r--src/graphics/engine/modelmanager.cpp14
-rw-r--r--src/graphics/engine/modelmanager.h4
-rw-r--r--src/object/brain.cpp19
-rw-r--r--src/object/object.cpp23
-rw-r--r--src/object/objman.cpp388
-rw-r--r--src/object/objman.h54
-rw-r--r--src/object/robotmain.cpp85
-rw-r--r--src/object/robotmain.h7
-rw-r--r--src/script/cbottoken.cpp395
-rw-r--r--src/script/cbottoken.h4
-rw-r--r--src/script/script.cpp70
-rw-r--r--src/script/script.h2
-rw-r--r--src/sound/oalsound/alsound.cpp49
-rw-r--r--src/sound/oalsound/channel.cpp13
-rw-r--r--src/sound/oalsound/channel.h1
-rw-r--r--src/ui/displayinfo.cpp6
-rw-r--r--src/ui/edit.cpp2
-rw-r--r--src/ui/maindialog.cpp258
-rw-r--r--src/ui/maindialog.h4
-rw-r--r--src/ui/studio.cpp2
-rw-r--r--test/unit/CMakeLists.txt1
-rw-r--r--test/unit/ui/CMakeLists.txt54
-rw-r--r--test/unit/ui/edit_test.cpp13
-rw-r--r--test/unit/ui/mocks/text_mock.h3
-rw-r--r--test/unit/ui/stubs/app_stub.cpp5
-rw-r--r--test/unit/ui/stubs/robotmain_stub.cpp8
36 files changed, 1137 insertions, 448 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f58b654..38458bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,10 +67,15 @@ else()
"Supported compilers at this time are GCC 4.6+ and clang.")
endif()
+
# Global compile flags
# These are specific to GCC/MinGW/clang; for other compilers, change as necessary
# The flags are used throughout src/ and test/ subdirs
-set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast ${CXX11_FLAGS}")
+
+# Special flags for boost
+set(Boost_FLAGS "-DBOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS")
+
+set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast ${CXX11_FLAGS} ${Boost_FLAGS}")
set(COLOBOT_CXX_FLAGS_RELEASE "-O2")
set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
diff --git a/data b/data
-Subproject e853f88d5a2bfac363ddf5b227784ad3caae64a
+Subproject 01900b30c0bdb51e800971e67e6e863fe4ac2a3
diff --git a/debian/changelog b/debian/changelog
index da44720..2165f96 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,5 @@
-colobot (0.1.0~pre-alpha-git-dev~r221-gcef858b-1~OdyX0) UNRELEASED; urgency=low
+colobot (0.1.0~pre-alpha-git-dev~r254-g926126d-1~OdyX0) UNRELEASED; urgency=low
* Initial release. (Closes: #695829)
- -- Didier Raboud <odyx@debian.org> Wed, 27 Mar 2013 13:11:24 +0100
+ -- Didier Raboud <odyx@debian.org> Wed, 03 Apr 2013 09:41:20 +0200
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index de60ef3..72fcee6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -128,6 +128,7 @@ object/motion/motionvehicle.cpp
object/motion/motionworm.cpp
object/object.cpp
object/robotmain.cpp
+object/objman.cpp
object/task/task.cpp
object/task/taskadvance.cpp
object/task/taskbuild.cpp
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 9349cbf..3801f95 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -95,6 +95,7 @@ CApplication::CApplication()
{
m_private = new ApplicationPrivate();
m_iMan = new CInstanceManager();
+ m_objMan = new CObjectManager();
m_eventQueue = new CEventQueue();
m_profile = new CProfile();
@@ -144,6 +145,7 @@ CApplication::CApplication()
m_trackedKeys = 0;
m_dataPath = COLOBOT_DEFAULT_DATADIR;
+ m_langPath = COLOBOT_I18N_DIR;
m_language = LANGUAGE_ENV;
@@ -213,6 +215,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
OPT_DATADIR,
OPT_LOGLEVEL,
OPT_LANGUAGE,
+ OPT_LANGDIR,
OPT_VBO
};
@@ -223,6 +226,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
{ "datadir", required_argument, nullptr, OPT_DATADIR },
{ "loglevel", required_argument, nullptr, OPT_LOGLEVEL },
{ "language", required_argument, nullptr, OPT_LANGUAGE },
+ { "langdir", required_argument, nullptr, OPT_LANGDIR },
{ "vbo", required_argument, nullptr, OPT_VBO }
};
@@ -258,6 +262,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
GetLogger()->Message(" -datadir path set custom data directory path\n");
GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
+ GetLogger()->Message(" -langdir path set custom language directory path\n");
GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n");
return PARSE_ARGS_HELP;
}
@@ -298,6 +303,12 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
m_language = language;
break;
}
+ case OPT_LANGDIR:
+ {
+ m_langPath = optarg;
+ GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str());
+ break;
+ }
case OPT_VBO:
{
std::string vbo;
@@ -1400,7 +1411,7 @@ bool CApplication::GetMouseButtonState(int index)
void CApplication::ResetKeyStates()
{
- GetLogger()->Info("Reset key states\n");
+ GetLogger()->Trace("Reset key states\n");
m_trackedKeys = 0;
m_kmodState = 0;
m_robotMain->ResetKeyStates();
@@ -1512,6 +1523,10 @@ std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& sub
str << m_dataPath;
str << "/";
str << m_dataDirs[index];
+ if (stdDir == DIR_HELP) {
+ str << "/";
+ str << GetLanguageChar();
+ }
str << "/";
str << subpath;
return str.str();
@@ -1645,7 +1660,7 @@ void CApplication::SetLanguage(Language language)
}
setlocale(LC_ALL, "");
- bindtextdomain("colobot", COLOBOT_I18N_DIR);
+ bindtextdomain("colobot", m_langPath.c_str());
bind_textdomain_codeset("colobot", "UTF-8");
textdomain("colobot");
diff --git a/src/app/app.h b/src/app/app.h
index d2561e7..07f1b90 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -31,6 +31,8 @@
#include "graphics/engine/engine.h"
#include "graphics/opengl/gldevice.h"
+#include "object/objman.h"
+
#include <string>
#include <vector>
@@ -374,6 +376,8 @@ protected:
//! Instance manager
// TODO: to be removed
CInstanceManager* m_iMan;
+ //! Object manager
+ CObjectManager* m_objMan;
//! Global event queue
CEventQueue* m_eventQueue;
//! Graphics engine
@@ -455,6 +459,9 @@ protected:
//! Path to directory with data files
std::string m_dataPath;
+ //! Path to directory with language files
+ std::string m_langPath;
+
const char* m_dataDirs[DIR_MAX];
//! Application language
diff --git a/src/app/system_windows.cpp b/src/app/system_windows.cpp
index 780afef..870683f 100644
--- a/src/app/system_windows.cpp
+++ b/src/app/system_windows.cpp
@@ -110,3 +110,39 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
return wstrTo;
}
+
+std::string CSystemUtilsWindows::profileFileLocation()
+{
+ std::string m_profileFile;
+
+ char* envUSERPROFILE = getenv("USERPROFILE");
+ if (envUSERPROFILE == NULL)
+ {
+ m_profileFile = "colobot.ini";
+ }
+ else
+ {
+ m_profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini";
+ }
+ GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str());
+
+ return m_profileFile;
+}
+
+std::string CSystemUtilsWindows::savegameDirectoryLocation()
+{
+ std::string m_savegameDir;
+
+ char* envUSERPROFILE = getenv("USERPROFILE");
+ if (envUSERPROFILE == NULL)
+ {
+ m_savegameDir = "savegame";
+ }
+ else
+ {
+ m_savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame";
+ }
+ GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str());
+
+ return m_savegameDir;
+} \ No newline at end of file
diff --git a/src/app/system_windows.h b/src/app/system_windows.h
index e367b92..88e7507 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -44,6 +44,9 @@ public:
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
+ virtual std::string profileFileLocation() override;
+ virtual std::string savegameDirectoryLocation() override;
+
private:
std::string UTF8_Encode(const std::wstring &wstr);
std::wstring UTF8_Decode(const std::string &str);
diff --git a/src/common/profile.h b/src/common/profile.h
index bcd76c3..7f99d81 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -23,9 +23,6 @@
#include "common/singleton.h"
-// this is just to fix problem with undefined reference when compiling with c++11 support
-#define BOOST_NO_SCOPED_ENUMS
-
#include <boost/property_tree/ptree.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string/replace.hpp>
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index e2ef569..274e179 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -591,6 +591,27 @@ void CEngine::CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank)
assert(destBaseObjRank >= 0 && destBaseObjRank < static_cast<int>( m_baseObjects.size() ));
m_baseObjects[destBaseObjRank] = m_baseObjects[sourceBaseObjRank];
+
+ EngineBaseObject& p1 = m_baseObjects[destBaseObjRank];
+
+ if (! p1.used)
+ return;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ EngineBaseObjLODTier& p3 = p2.next[l3];
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ EngineBaseObjDataTier& p4 = p3.next[l4];
+ p4.staticBufferId = 0;
+ }
+ }
+ }
}
void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<VertexTex2>& vertices,
diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp
index c23b79d..238a7d9 100644
--- a/src/graphics/engine/modelmanager.cpp
+++ b/src/graphics/engine/modelmanager.cpp
@@ -23,7 +23,7 @@ CModelManager::~CModelManager()
bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
{
- GetLogger()->Info("Loading model '%s'\n", fileName.c_str());
+ GetLogger()->Debug("Loading model '%s'\n", fileName.c_str());
CModelFile modelFile;
@@ -111,6 +111,8 @@ bool CModelManager::AddModelCopy(const std::string& fileName, bool mirrored, int
m_engine->CopyBaseObject((*it).second.baseObjRank, copyBaseObjRank);
m_engine->SetObjectBaseRank(objRank, copyBaseObjRank);
+ m_copiesBaseRanks.push_back(copyBaseObjRank);
+
return true;
}
@@ -128,6 +130,16 @@ int CModelManager::GetModelBaseObjRank(const std::string& fileName, bool mirrore
return (*it).second.baseObjRank;
}
+void CModelManager::DeleteAllModelCopies()
+{
+ for (int baseObjRank : m_copiesBaseRanks)
+ {
+ m_engine->DeleteBaseObject(baseObjRank);
+ }
+
+ m_copiesBaseRanks.clear();
+}
+
void CModelManager::UnloadModel(const std::string& fileName, bool mirrored)
{
auto it = m_models.find(FileInfo(fileName, mirrored));
diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h
index 601d636..a7f9805 100644
--- a/src/graphics/engine/modelmanager.h
+++ b/src/graphics/engine/modelmanager.h
@@ -53,6 +53,9 @@ public:
//! Returns the rank of base engine object of given loaded model
int GetModelBaseObjRank(const std::string& fileName, bool mirrored);
+ //! Deletes all copied objects
+ void DeleteAllModelCopies();
+
//! Unloads the given model
void UnloadModel(const std::string& fileName, bool mirrored);
//! Unloads all models
@@ -91,6 +94,7 @@ private:
}
};
std::map<FileInfo, ModelInfo> m_models;
+ std::vector<int> m_copiesBaseRanks;
CEngine* m_engine;
};
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 2cd7170..951a763 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -1389,8 +1389,9 @@ bool CBrain::CreateInterface(bool bSelect)
pw->CreateButton(pos, dim, 33, EVENT_OBJECT_MFRONT);
}
- if ( type == OBJECT_MOBILEsa && // underwater?
- !m_object->GetTrainer() )
+ if ( ( type == OBJECT_MOBILEsa && // underwater?
+ !m_object->GetTrainer() ) ||
+ type == OBJECT_BEE )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1943,9 +1944,7 @@ bool CBrain::CreateInterface(bool bSelect)
void CBrain::UpdateInterface(float rTime)
{
Ui::CWindow* pw;
-/* TODO: #if _TEEN
Ui::CButton* pb;
-#endif*/
Ui::CGauge* pg;
Ui::CCompass* pc;
Ui::CGroup* pgr;
@@ -2057,8 +2056,7 @@ void CBrain::UpdateInterface(float rTime)
pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap());
}
-#if _TEEN
- pb = (CButton*)pw->SearchControl(EVENT_OBJECT_REC);
+ pb = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_OBJECT_REC));
if ( pb != 0 )
{
if ( m_bTraceRecord && Math::Mod(m_time, 0.4f) >= 0.2f )
@@ -2070,7 +2068,6 @@ void CBrain::UpdateInterface(float rTime)
pb->ClearState(Ui::STATE_CHECK);
}
}
-#endif
bOnBoard = m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD;
@@ -2150,10 +2147,8 @@ void CBrain::UpdateInterface()
Ui::CWindow* pw;
Ui::CButton* pb;
Ui::CSlider* ps;
-#if _TEEN
- CColor* pc;
+ Ui::CColor* pc;
int color;
-#endif
bool bEnable, bFly, bRun;
char title[100];
@@ -2188,7 +2183,6 @@ void CBrain::UpdateInterface()
EnableInterface(pw, EVENT_OBJECT_FIRE, bEnable);
EnableInterface(pw, EVENT_OBJECT_SPIDEREXPLO, bEnable);
EnableInterface(pw, EVENT_OBJECT_RESET, bEnable);
-#if _TEEN
EnableInterface(pw, EVENT_OBJECT_PEN0, bEnable);
EnableInterface(pw, EVENT_OBJECT_PEN1, bEnable);
EnableInterface(pw, EVENT_OBJECT_PEN2, bEnable);
@@ -2200,7 +2194,6 @@ void CBrain::UpdateInterface()
EnableInterface(pw, EVENT_OBJECT_PEN8, bEnable);
EnableInterface(pw, EVENT_OBJECT_REC, bEnable);
EnableInterface(pw, EVENT_OBJECT_STOP, bEnable);
-#endif
if ( type == OBJECT_HUMAN ) // builder?
{
@@ -2351,7 +2344,6 @@ void CBrain::UpdateInterface()
CheckInterface(pw, EVENT_OBJECT_MFRONT, m_manipStyle==EVENT_OBJECT_MFRONT);
}
-#if _TEEN
if ( m_object->GetTraceDown() )
{
pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PEN0));
@@ -2451,7 +2443,6 @@ void CBrain::UpdateInterface()
pc->ClearState(Ui::STATE_CHECK);
}
}
-#endif
}
// Updates the list of programs.
diff --git a/src/object/object.cpp b/src/object/object.cpp
index a0a3f09..b621ef2 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -71,6 +71,7 @@
#include "object/motion/motionvehicle.h"
#include "object/motion/motionworm.h"
#include "object/robotmain.h"
+#include "object/objman.h"
#include "physics/physics.h"
@@ -202,6 +203,10 @@ void uObject(CBotVar* botThis, void* user)
fret = object->GetFret();
if ( fret == 0 ) pVar->SetPointer(0);
else pVar->SetPointer(fret->GetBotVar());
+
+ pVar = pVar->GetNext(); // "id"
+ value = object->GetID();
+ pVar->SetValInt(value);
}
@@ -337,6 +342,8 @@ CObject::CObject()
m_botVar = CBotVar::Create("", CBotTypResult(CBotTypClass, "object"));
m_botVar->SetUserPtr(this);
m_botVar->SetIdent(m_id);
+
+ CObjectManager::GetInstancePointer()->AddInstance(this);
}
// Object's destructor.
@@ -360,6 +367,7 @@ CObject::~CObject()
m_auto = nullptr;
CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_OBJECT, this);
+ CObjectManager::GetInstancePointer()->DeleteInstance(this);
m_app = nullptr;
}
@@ -592,7 +600,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
}
}
- if ( EXPLO_BOUM )
+ if ( type == EXPLO_BOUM )
{
if ( m_shotTime < 0.5f ) return false;
m_shotTime = 0.0f;
@@ -2658,7 +2666,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_ENERGY )
{
- modelManager->AddModelReference("energy.mod", false, rank);
+ modelManager->AddModelCopy("energy.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2841,7 +2849,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_STATION )
{
- modelManager->AddModelReference("station.mod", false, rank);
+ modelManager->AddModelCopy("station.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3207,7 +3215,14 @@ bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_MARKKEYd ) name = "crossd.mod";
if ( type == OBJECT_EGG ) name = "egg.mod";
- modelManager->AddModelReference(name, false, rank);
+ if (type == OBJECT_POWER || type == OBJECT_ATOMIC)
+ {
+ modelManager->AddModelCopy(name, false, rank);
+ }
+ else
+ {
+ modelManager->AddModelReference(name, false, rank);
+ }
SetPosition(0, pos);
SetAngleY(0, angle);
diff --git a/src/object/objman.cpp b/src/object/objman.cpp
new file mode 100644
index 0000000..76ab9b0
--- /dev/null
+++ b/src/object/objman.cpp
@@ -0,0 +1,388 @@
+// * 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/.
+
+
+#include "object/object.h"
+#include "object/auto/auto.h"
+
+#include "object/objman.h"
+
+
+template<> CObjectManager* CSingleton<CObjectManager>::m_instance = nullptr;
+
+
+CObjectManager::CObjectManager()
+{
+ for (int i = 0; i < MAX_OBJECTS; i++)
+ {
+ m_table[i] = nullptr;
+ }
+ usedCount = 0;
+}
+
+CObjectManager::~CObjectManager()
+{
+}
+
+bool CObjectManager::AddInstance(CObject* instance)
+{
+ if (usedCount >= MAX_OBJECTS) return false;
+
+ m_table[instance->GetID()] = instance;
+ usedCount++;
+ return true;
+}
+
+bool CObjectManager::DeleteInstance(CObject* instance)
+{
+ for (int i = 0; i < usedCount; i++)
+ {
+ if (m_table[i] == instance)
+ m_table[i] = nullptr;
+ }
+
+ return true;
+}
+
+CObject* CObjectManager::SearchInstance(int id)
+{
+ if (id >= MAX_OBJECTS) return nullptr;
+ return m_table[id];
+}
+
+CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, float height,
+ ObjectType type, float power,
+ bool trainer, bool toy,
+ int option)
+{
+ CObject* object = nullptr;
+
+ if ( type == OBJECT_NULL ) return nullptr;
+
+ if ( type == OBJECT_HUMAN ||
+ type == OBJECT_TECH )
+ {
+ trainer = false; // necessarily
+ }
+
+ if ( type == OBJECT_PORTICO ||
+ type == OBJECT_BASE ||
+ type == OBJECT_DERRICK ||
+ type == OBJECT_FACTORY ||
+ type == OBJECT_STATION ||
+ type == OBJECT_CONVERT ||
+ type == OBJECT_REPAIR ||
+ type == OBJECT_DESTROYER||
+ type == OBJECT_TOWER ||
+ type == OBJECT_NEST ||
+ type == OBJECT_RESEARCH ||
+ type == OBJECT_RADAR ||
+ type == OBJECT_INFO ||
+ type == OBJECT_ENERGY ||
+ type == OBJECT_LABO ||
+ type == OBJECT_NUCLEAR ||
+ type == OBJECT_PARA ||
+ type == OBJECT_SAFE ||
+ type == OBJECT_HUSTON ||
+ type == OBJECT_TARGET1 ||
+ type == OBJECT_TARGET2 ||
+ type == OBJECT_START ||
+ type == OBJECT_END )
+ {
+ object = new CObject();
+ object->CreateBuilding(pos, angle, height, type, power);
+
+ CAuto* automat = object->GetAuto();
+ if (automat != nullptr)
+ {
+ automat->Init();
+ }
+ }
+ else
+ if ( type == OBJECT_FRET ||
+ type == OBJECT_STONE ||
+ type == OBJECT_URANIUM ||
+ type == OBJECT_METAL ||
+ type == OBJECT_POWER ||
+ type == OBJECT_ATOMIC ||
+ type == OBJECT_BULLET ||
+ type == OBJECT_BBOX ||
+ type == OBJECT_KEYa ||
+ type == OBJECT_KEYb ||
+ type == OBJECT_KEYc ||
+ type == OBJECT_KEYd ||
+ type == OBJECT_TNT ||
+ type == OBJECT_SCRAP1 ||
+ type == OBJECT_SCRAP2 ||
+ type == OBJECT_SCRAP3 ||
+ type == OBJECT_SCRAP4 ||
+ type == OBJECT_SCRAP5 ||
+ type == OBJECT_BOMB ||
+ type == OBJECT_WAYPOINT ||
+ type == OBJECT_SHOW ||
+ type == OBJECT_WINFIRE ||
+ type == OBJECT_BAG ||
+ type == OBJECT_MARKPOWER ||
+ type == OBJECT_MARKSTONE ||
+ type == OBJECT_MARKURANIUM ||
+ type == OBJECT_MARKKEYa ||
+ type == OBJECT_MARKKEYb ||
+ type == OBJECT_MARKKEYc ||
+ type == OBJECT_MARKKEYd ||
+ type == OBJECT_EGG )
+ {
+ object = new CObject();
+ object->CreateResource(pos, angle, type, power);
+ }
+ else
+ if ( type == OBJECT_FLAGb ||
+ type == OBJECT_FLAGr ||
+ type == OBJECT_FLAGg ||
+ type == OBJECT_FLAGy ||
+ type == OBJECT_FLAGv )
+ {
+ object = new CObject();
+ object->CreateFlag(pos, angle, type);
+ }
+ else
+ if ( type == OBJECT_BARRIER0 ||
+ type == OBJECT_BARRIER1 ||
+ type == OBJECT_BARRIER2 ||
+ type == OBJECT_BARRIER3 ||
+ type == OBJECT_BARRIER4 )
+ {
+ object = new CObject();
+ object->CreateBarrier(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_PLANT0 ||
+ type == OBJECT_PLANT1 ||
+ type == OBJECT_PLANT2 ||
+ type == OBJECT_PLANT3 ||
+ type == OBJECT_PLANT4 ||
+ type == OBJECT_PLANT5 ||
+ type == OBJECT_PLANT6 ||
+ type == OBJECT_PLANT7 ||
+ type == OBJECT_PLANT8 ||
+ type == OBJECT_PLANT9 ||
+ type == OBJECT_PLANT10 ||
+ type == OBJECT_PLANT11 ||
+ type == OBJECT_PLANT12 ||
+ type == OBJECT_PLANT13 ||
+ type == OBJECT_PLANT14 ||
+ type == OBJECT_PLANT15 ||
+ type == OBJECT_PLANT16 ||
+ type == OBJECT_PLANT17 ||
+ type == OBJECT_PLANT18 ||
+ type == OBJECT_PLANT19 ||
+ type == OBJECT_TREE0 ||
+ type == OBJECT_TREE1 ||
+ type == OBJECT_TREE2 ||
+ type == OBJECT_TREE3 ||
+ type == OBJECT_TREE4 ||
+ type == OBJECT_TREE5 ||
+ type == OBJECT_TREE6 ||
+ type == OBJECT_TREE7 ||
+ type == OBJECT_TREE8 ||
+ type == OBJECT_TREE9 )
+ {
+ object = new CObject();
+ object->CreatePlant(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_MUSHROOM0 ||
+ type == OBJECT_MUSHROOM1 ||
+ type == OBJECT_MUSHROOM2 ||
+ type == OBJECT_MUSHROOM3 ||
+ type == OBJECT_MUSHROOM4 ||
+ type == OBJECT_MUSHROOM5 ||
+ type == OBJECT_MUSHROOM6 ||
+ type == OBJECT_MUSHROOM7 ||
+ type == OBJECT_MUSHROOM8 ||
+ type == OBJECT_MUSHROOM9 )
+ {
+ object = new CObject();
+ object->CreateMushroom(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_TEEN0 ||
+ type == OBJECT_TEEN1 ||
+ type == OBJECT_TEEN2 ||
+ type == OBJECT_TEEN3 ||
+ type == OBJECT_TEEN4 ||
+ type == OBJECT_TEEN5 ||
+ type == OBJECT_TEEN6 ||
+ type == OBJECT_TEEN7 ||
+ type == OBJECT_TEEN8 ||
+ type == OBJECT_TEEN9 ||
+ type == OBJECT_TEEN10 ||
+ type == OBJECT_TEEN11 ||
+ type == OBJECT_TEEN12 ||
+ type == OBJECT_TEEN13 ||
+ type == OBJECT_TEEN14 ||
+ type == OBJECT_TEEN15 ||
+ type == OBJECT_TEEN16 ||
+ type == OBJECT_TEEN17 ||
+ type == OBJECT_TEEN18 ||
+ type == OBJECT_TEEN19 ||
+ type == OBJECT_TEEN20 ||
+ type == OBJECT_TEEN21 ||
+ type == OBJECT_TEEN22 ||
+ type == OBJECT_TEEN23 ||
+ type == OBJECT_TEEN24 ||
+ type == OBJECT_TEEN25 ||
+ type == OBJECT_TEEN26 ||
+ type == OBJECT_TEEN27 ||
+ type == OBJECT_TEEN28 ||
+ type == OBJECT_TEEN29 ||
+ type == OBJECT_TEEN30 ||
+ type == OBJECT_TEEN31 ||
+ type == OBJECT_TEEN32 ||
+ type == OBJECT_TEEN33 ||
+ type == OBJECT_TEEN34 ||
+ type == OBJECT_TEEN35 ||
+ type == OBJECT_TEEN36 ||
+ type == OBJECT_TEEN37 ||
+ type == OBJECT_TEEN38 ||
+ type == OBJECT_TEEN39 ||
+ type == OBJECT_TEEN40 ||
+ type == OBJECT_TEEN41 ||
+ type == OBJECT_TEEN42 ||
+ type == OBJECT_TEEN43 ||
+ type == OBJECT_TEEN44 ||
+ type == OBJECT_TEEN45 ||
+ type == OBJECT_TEEN46 ||
+ type == OBJECT_TEEN47 ||
+ type == OBJECT_TEEN48 ||
+ type == OBJECT_TEEN49 )
+ {
+ object = new CObject();
+ object->SetOption(option);
+ object->CreateTeen(pos, angle, zoom, height, type);
+ }
+ else
+ if ( type == OBJECT_QUARTZ0 ||
+ type == OBJECT_QUARTZ1 ||
+ type == OBJECT_QUARTZ2 ||
+ type == OBJECT_QUARTZ3 ||
+ type == OBJECT_QUARTZ4 ||
+ type == OBJECT_QUARTZ5 ||
+ type == OBJECT_QUARTZ6 ||
+ type == OBJECT_QUARTZ7 ||
+ type == OBJECT_QUARTZ8 ||
+ type == OBJECT_QUARTZ9 )
+ {
+ object = new CObject();
+ object->CreateQuartz(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_ROOT0 ||
+ type == OBJECT_ROOT1 ||
+ type == OBJECT_ROOT2 ||
+ type == OBJECT_ROOT3 ||
+ type == OBJECT_ROOT4 ||
+ type == OBJECT_ROOT5 ||
+ type == OBJECT_ROOT6 ||
+ type == OBJECT_ROOT7 ||
+ type == OBJECT_ROOT8 ||
+ type == OBJECT_ROOT9 )
+ {
+ object = new CObject();
+ object->CreateRoot(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_HOME1 )
+ {
+ object = new CObject();
+ object->CreateHome(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_RUINmobilew1 ||
+ type == OBJECT_RUINmobilew2 ||
+ type == OBJECT_RUINmobilet1 ||
+ type == OBJECT_RUINmobilet2 ||
+ type == OBJECT_RUINmobiler1 ||
+ type == OBJECT_RUINmobiler2 ||
+ type == OBJECT_RUINfactory ||
+ type == OBJECT_RUINdoor ||
+ type == OBJECT_RUINsupport ||
+ type == OBJECT_RUINradar ||
+ type == OBJECT_RUINconvert ||
+ type == OBJECT_RUINbase ||
+ type == OBJECT_RUINhead )
+ {
+ object = new CObject();
+ object->CreateRuin(pos, angle, height, type);
+ }
+ else
+ if ( type == OBJECT_APOLLO1 ||
+ type == OBJECT_APOLLO3 ||
+ type == OBJECT_APOLLO4 ||
+ type == OBJECT_APOLLO5 )
+ {
+ object = new CObject();
+ object->CreateApollo(pos, angle, type);
+ }
+ else
+ if ( type == OBJECT_MOTHER ||
+ type == OBJECT_ANT ||
+ type == OBJECT_SPIDER ||
+ type == OBJECT_BEE ||
+ type == OBJECT_WORM )
+ {
+ object = new CObject();
+ object->CreateInsect(pos, angle, type); // no eggs
+ }
+ else
+ if ( type == OBJECT_HUMAN ||
+ type == OBJECT_TECH ||
+ type == OBJECT_TOTO ||
+ type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEia ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEic ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEii ||
+ type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEts ||
+ type == OBJECT_MOBILEws ||
+ type == OBJECT_MOBILEis ||
+ type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs ||
+ type == OBJECT_MOBILEsa ||
+ type == OBJECT_MOBILEtg ||
+ type == OBJECT_MOBILEft ||
+ type == OBJECT_MOBILEtt ||
+ type == OBJECT_MOBILEwt ||
+ type == OBJECT_MOBILEit ||
+ type == OBJECT_MOBILEdr ||
+ type == OBJECT_APOLLO2 )
+ {
+ object = new CObject();
+ object->SetOption(option);
+ object->CreateVehicle(pos, angle, type, power, trainer, toy);
+ }
+
+ return object;
+} \ No newline at end of file
diff --git a/src/object/objman.h b/src/object/objman.h
new file mode 100644
index 0000000..3bdf1a2
--- /dev/null
+++ b/src/object/objman.h
@@ -0,0 +1,54 @@
+// * 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/.
+
+/**
+ * \file common/objman.h
+ * \brief Instance manager for objects
+ */
+
+#pragma once
+
+#include "object/object.h"
+
+#include "common/singleton.h"
+
+const int MAX_OBJECTS = 500;
+
+/**
+ * \class ObjectManager
+ * \brief Manager for objects
+ */
+class CObjectManager : public CSingleton<CObjectManager>
+{
+public:
+ CObjectManager();
+ virtual ~CObjectManager();
+
+ //! Registers new object
+ bool AddInstance(CObject* instance);
+ //! Deletes the registered object
+ bool DeleteInstance(CObject* instance);
+ //! Seeks for an object
+ CObject* SearchInstance(int id);
+ //! Creates an object
+ CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power, bool trainer, bool toy, int option);
+
+protected:
+ CObject* m_table[MAX_OBJECTS];
+ int usedCount;
+};
+
+
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index f27438f..2c890a4 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -34,7 +34,7 @@
#include "graphics/engine/engine.h"
#include "graphics/engine/lightman.h"
#include "graphics/engine/lightning.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/planet.h"
#include "graphics/engine/pyro.h"
@@ -659,6 +659,7 @@ CRobotMain::CRobotMain(CApplication* app)
m_retroStyle = false;
m_immediatSatCom = false;
m_beginSatCom = false;
+ m_lockedSatCom = false;
m_movieLock = false;
m_satComLock = false;
m_editLock = false;
@@ -804,6 +805,11 @@ CRobotMain::CRobotMain(CApplication* app)
CBotProgram::DefineNum("FilterOnlyLanding", FILTER_ONLYLANDING);
CBotProgram::DefineNum("FilterOnlyFliying", FILTER_ONLYFLYING);
+ CBotProgram::DefineNum("ExploNone", 0);
+ CBotProgram::DefineNum("ExploBoum", EXPLO_BOUM);
+ CBotProgram::DefineNum("ExploBurn", EXPLO_BURN);
+ CBotProgram::DefineNum("ExploWater", EXPLO_WATER);
+
CBotProgram::DefineNum("PolskiPortalColobota", 1337);
CBotClass* bc;
@@ -830,6 +836,7 @@ CRobotMain::CRobotMain(CApplication* app)
bc->AddItem("material", CBotTypResult(CBotTypInt), PR_READ);
bc->AddItem("energyCell", CBotTypResult(CBotTypPointer, "object"), PR_READ);
bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ);
+ bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ);
// Initializes the class FILE.
InitClassFILE();
@@ -1040,6 +1047,7 @@ void CRobotMain::ChangePhase(Phase phase)
FlushDisplayInfo();
m_engine->SetRankView(0);
m_engine->DeleteAllObjects();
+ Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies();
m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
m_engine->SetBackground("");
m_engine->SetBackForce(false);
@@ -1136,13 +1144,13 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_mapImage)
m_map->SetFixImage(m_mapFilename);
- Math::Point ddim;
+ /*Math::Point ddim;
pos.x = 620.0f/640.0f;
pos.y = 460.0f/480.0f;
ddim.x = 20.0f/640.0f;
ddim.y = 20.0f/480.0f;
- m_interface->CreateButton(pos, ddim, 11, EVENT_BUTTON_QUIT);
+ m_interface->CreateButton(pos, ddim, 11, EVENT_BUTTON_QUIT);*/
if (m_immediatSatCom && !loading &&
m_infoFilename[SATCOM_HUSTON][0] != 0)
@@ -1195,7 +1203,7 @@ void CRobotMain::ChangePhase(Phase phase)
pe->SetFontType(Gfx::FONT_COLOBOT);
pe->SetEditCap(false);
pe->SetHighlightCap(false);
- pe->ReadText(std::string("help/win.txt"));
+ pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt"));
}
else
{
@@ -1331,7 +1339,7 @@ bool CRobotMain::EventProcess(Event &event)
// Management of the console.
if (m_phase != PHASE_NAME &&
!m_movie->IsExist() &&
- !m_movieLock && !m_editLock &&
+ !m_movieLock && !m_editLock && !m_engine->GetPause() &&
event.type == EVENT_KEY_DOWN &&
event.key.key == KEY(PAUSE)) // Pause ?
{
@@ -1473,8 +1481,9 @@ bool CRobotMain::EventProcess(Event &event)
ChangePhase(PHASE_WIN);
else if (m_lostDelay > 0.0f)
ChangePhase(PHASE_LOST);
- else
+ else if (!m_cmdEdit) {
m_dialog->StartAbort(); // do you want to leave?
+ }
}
if (event.key.key == KEY(PAUSE))
{
@@ -2019,7 +2028,7 @@ void CRobotMain::FlushDisplayInfo()
m_infoFilename[i][0] = 0;
m_infoPos[i] = 0;
}
- strcpy(m_infoFilename[SATCOM_OBJECT], "help/objects.txt");
+ strcpy(m_infoFilename[SATCOM_OBJECT], "help/") + m_app->GetLanguageChar() + std::string("/objects.txt");
m_infoIndex = 0;
}
@@ -2027,7 +2036,7 @@ void CRobotMain::FlushDisplayInfo()
//! index: SATCOM_*
void CRobotMain::StartDisplayInfo(int index, bool movie)
{
- if (m_cmdEdit || m_satComLock) return;
+ if (m_cmdEdit || m_satComLock || m_lockedSatCom) return;
CObject* obj = GetSelect();
bool human = obj != nullptr && obj->GetType() == OBJECT_HUMAN;
@@ -3071,7 +3080,7 @@ void CRobotMain::HelpObject()
CObject* obj = GetSelect();
if (obj == nullptr) return;
- const char* filename = GetHelpFilename(obj->GetType());
+ const char* filename = GetHelpFilename(obj->GetType()).c_str();
if (filename[0] == 0) return;
StartDisplayInfo(filename, -1);
@@ -3728,6 +3737,7 @@ void CRobotMain::ScenePerso()
{
DeleteAllObjects(); // removes all the current 3D Scene
m_engine->DeleteAllObjects();
+ Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies();
m_terrain->FlushRelief(); // all flat
m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit();
@@ -3789,6 +3799,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_displayText->SetDelay(1.0f);
m_displayText->SetEnable(true);
m_immediatSatCom = false;
+ m_lockedSatCom = false;
m_endingWinRank = 0;
m_endingLostRank = 0;
m_endTakeTotal = 0;
@@ -3862,12 +3873,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
int rankGadget = 0;
CObject* sel = 0;
- std::string oldLocale;
- char *locale = setlocale(LC_NUMERIC, nullptr);
- if (locale != nullptr)
- oldLocale = locale;
-
- setlocale(LC_NUMERIC, "C");
+ SetNumericLocale();
while (fgets(line, 500, file) != NULL)
{
@@ -3908,6 +3914,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str());
m_immediatSatCom = OpInt(line, "immediat", 0);
+ if(m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0);
}
if (Cmd(line, "Satellite") && !resetObject)
@@ -4328,12 +4335,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
Math::Vector pos = OpPos(line, "pos")*g_unit;
float dir = OpFloat(line, "dir", 0.0f)*Math::PI;
+ bool trainer = OpInt(line, "trainer", 0);
CObject* obj = CreateObject(pos, dir,
OpFloat(line, "z", 1.0f),
OpFloat(line, "h", 0.0f),
type,
OpFloat(line, "power", 1.0f),
- OpInt(line, "trainer", 0),
+ trainer,
OpInt(line, "toy", 0),
OpInt(line, "option", 0));
@@ -4395,12 +4403,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
obj->SetShield(OpFloat(line, "shield", 1.0f));
obj->SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f));
obj->SetClip(OpInt(line, "clip", 1));
- obj->SetCheckToken(OpInt(line, "checkToken", 1));
- obj->SetManual(OpInt(line, "manual", 0));
+ obj->SetCheckToken(m_version >= 2 ? trainer : OpInt(line, "manual", 1));
+ obj->SetManual(m_version >= 2 ? !trainer : OpInt(line, "manual", 0));
- Math::Vector zoom = OpDir(line, "zoom");
- if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
- obj->SetZoom(0, zoom);
+ if(m_version >= 2) {
+ Math::Vector zoom = OpDir(line, "zoom");
+ if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
+ obj->SetZoom(0, zoom);
+ }
CMotion* motion = obj->GetMotion();
if (motion != nullptr)
@@ -4731,7 +4741,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_dialog->SetSceneRead("");
m_dialog->SetStackRead("");
- setlocale(LC_NUMERIC, oldLocale.c_str());
+ RestoreNumericLocale();
}
//! Creates an object of decoration mobile or stationary
@@ -5938,6 +5948,8 @@ bool CRobotMain::IsBusy()
void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
{
if (obj->GetType() == OBJECT_FIX) return;
+
+ SetNumericLocale();
char line[3000];
char name[100];
@@ -6025,6 +6037,8 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
strcat(line, "\n");
fputs(line, file);
+
+ RestoreNumericLocale();
}
//! Saves the current game
@@ -6032,6 +6046,8 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
{
FILE* file = fopen(filename, "w");
if (file == NULL) return false;
+
+ SetNumericLocale();
char line[500];
@@ -6094,6 +6110,8 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
SaveFileScript(obj, filename, objRank++);
}
fclose(file);
+
+ RestoreNumericLocale();
#if CBOT_STACK
// Writes the file of stacks of execution.
@@ -6139,6 +6157,8 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
if (type == OBJECT_NULL)
return nullptr;
+ SetNumericLocale();
+
int trainer = OpInt(line, "trainer", 0);
int toy = OpInt(line, "toy", 0);
int option = OpInt(line, "option", 0);
@@ -6204,6 +6224,8 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
automat->Start(run); // starts the film
}
+ RestoreNumericLocale();
+
return obj;
}
@@ -6214,6 +6236,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
FILE* file = fopen(filename, "r");
if (file == NULL) return 0;
+
+ SetNumericLocale();
CObject* fret = nullptr;
CObject* power = nullptr;
@@ -6336,6 +6360,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
}
#endif
+ RestoreNumericLocale();
+
return sel;
}
@@ -7032,3 +7058,18 @@ void CRobotMain::ClearInterface()
HiliteClear(); // removes setting evidence
m_tooltipName[0] = 0; // really removes the tooltip
}
+
+void CRobotMain::SetNumericLocale()
+{
+ char *locale = setlocale(LC_NUMERIC, nullptr);
+ if (locale != nullptr)
+ m_oldLocale = locale;
+
+ setlocale(LC_NUMERIC, "C");
+}
+
+void CRobotMain::RestoreNumericLocale()
+{
+ setlocale(LC_NUMERIC, m_oldLocale.c_str());
+}
+ \ No newline at end of file
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 0bcd2dc..fc62072 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -352,6 +352,9 @@ public:
CObject* IOReadObject(char *line, const char* filename, int objRank);
int CreateSpot(Math::Vector pos, Gfx::Color color);
+
+ void SetNumericLocale();
+ void RestoreNumericLocale();
protected:
bool EventFrame(const Event &event);
@@ -390,6 +393,7 @@ protected:
void ExecuteCmd(char *cmd);
bool TestGadgetQuantity(int rank);
void UpdateSpeedLabel();
+
protected:
CApplication* m_app;
@@ -459,6 +463,7 @@ protected:
bool m_retroStyle; // Retro
bool m_immediatSatCom; // SatCom immediately?
bool m_beginSatCom; // messages SatCom poster?
+ bool m_lockedSatCom; // SatCom locked?
bool m_movieLock; // movie in progress?
bool m_satComLock; // call of SatCom is possible?
bool m_editLock; // edition in progress?
@@ -539,5 +544,7 @@ protected:
Gfx::Color m_colorRefWater;
Gfx::Color m_colorNewWater;
float m_colorShiftWater;
+
+ std::string m_oldLocale;
};
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 06d36e1..95b259b 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -18,6 +18,7 @@
#include "script/cbottoken.h"
#include "object/object.h"
+#include "app/app.h"
#include <string.h>
@@ -130,208 +131,208 @@ const char* GetObjectAlias(ObjectType type)
// Returns the help file to use for the object.
-const char* GetHelpFilename(ObjectType type)
+std::string GetHelpFilename(ObjectType type)
{
- if ( type == OBJECT_BASE ) return "help\\object\\base.txt";
- if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt";
- if ( type == OBJECT_FACTORY ) return "help\\object\\factory.txt";
- if ( type == OBJECT_STATION ) return "help\\object\\station.txt";
- if ( type == OBJECT_CONVERT ) return "help\\object\\convert.txt";
- if ( type == OBJECT_REPAIR ) return "help\\object\\repair.txt";
- if ( type == OBJECT_DESTROYER ) return "help\\object\\destroy.txt";
- if ( type == OBJECT_TOWER ) return "help\\object\\tower.txt";
- if ( type == OBJECT_NEST ) return "help\\object\\nest.txt";
- if ( type == OBJECT_RESEARCH ) return "help\\object\\research.txt";
- if ( type == OBJECT_RADAR ) return "help\\object\\radar.txt";
- if ( type == OBJECT_INFO ) return "help\\object\\exchange.txt";
- if ( type == OBJECT_ENERGY ) return "help\\object\\energy.txt";
- if ( type == OBJECT_LABO ) return "help\\object\\labo.txt";
- if ( type == OBJECT_NUCLEAR ) return "help\\object\\nuclear.txt";
- if ( type == OBJECT_PARA ) return "help\\object\\captor.txt";
- if ( type == OBJECT_SAFE ) return "help\\object\\safe.txt";
- if ( type == OBJECT_HUSTON ) return "help\\object\\huston.txt";
- if ( type == OBJECT_START ) return "help\\object\\start.txt";
- if ( type == OBJECT_END ) return "help\\object\\goal.txt";
- if ( type == OBJECT_STONE ) return "help\\object\\titanore.txt";
- if ( type == OBJECT_URANIUM ) return "help\\object\\uranore.txt";
- if ( type == OBJECT_METAL ) return "help\\object\\titan.txt";
- if ( type == OBJECT_POWER ) return "help\\object\\power.txt";
- if ( type == OBJECT_ATOMIC ) return "help\\object\\atomic.txt";
- if ( type == OBJECT_BULLET ) return "help\\object\\bullet.txt";
- if ( type == OBJECT_BBOX ) return "help\\object\\bbox.txt";
- if ( type == OBJECT_KEYa ) return "help\\object\\key.txt";
- if ( type == OBJECT_KEYb ) return "help\\object\\key.txt";
- if ( type == OBJECT_KEYc ) return "help\\object\\key.txt";
- if ( type == OBJECT_KEYd ) return "help\\object\\key.txt";
- if ( type == OBJECT_TNT ) return "help\\object\\tnt.txt";
- if ( type == OBJECT_SCRAP1 ) return "help\\object\\scrap.txt";
- if ( type == OBJECT_BOMB ) return "help\\object\\mine.txt";
- if ( type == OBJECT_BARRIER1 ) return "help\\object\\barrier.txt";
- if ( type == OBJECT_WAYPOINT ) return "help\\object\\waypoint.txt";
- if ( type == OBJECT_FLAGb ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGr ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGg ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGy ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGv ) return "help\\object\\flag.txt";
- if ( type == OBJECT_MARKPOWER ) return "help\\object\\enerspot.txt";
- if ( type == OBJECT_MARKSTONE ) return "help\\object\\stonspot.txt";
- if ( type == OBJECT_MARKURANIUM ) return "help\\object\\uranspot.txt";
- if ( type == OBJECT_MOBILEwa ) return "help\\object\\botgr.txt";
- if ( type == OBJECT_MOBILEta ) return "help\\object\\botgc.txt";
- if ( type == OBJECT_MOBILEfa ) return "help\\object\\botgj.txt";
- if ( type == OBJECT_MOBILEia ) return "help\\object\\botgs.txt";
- if ( type == OBJECT_MOBILEws ) return "help\\object\\botsr.txt";
- if ( type == OBJECT_MOBILEts ) return "help\\object\\botsc.txt";
- if ( type == OBJECT_MOBILEfs ) return "help\\object\\botsj.txt";
- if ( type == OBJECT_MOBILEis ) return "help\\object\\botss.txt";
- if ( type == OBJECT_MOBILEwi ) return "help\\object\\botor.txt";
- if ( type == OBJECT_MOBILEti ) return "help\\object\\botoc.txt";
- if ( type == OBJECT_MOBILEfi ) return "help\\object\\botoj.txt";
- if ( type == OBJECT_MOBILEii ) return "help\\object\\botos.txt";
- if ( type == OBJECT_MOBILEwc ) return "help\\object\\botfr.txt";
- if ( type == OBJECT_MOBILEtc ) return "help\\object\\botfc.txt";
- if ( type == OBJECT_MOBILEfc ) return "help\\object\\botfj.txt";
- if ( type == OBJECT_MOBILEic ) return "help\\object\\botfs.txt";
- if ( type == OBJECT_MOBILErt ) return "help\\object\\bottump.txt";
- if ( type == OBJECT_MOBILErc ) return "help\\object\\botphaz.txt";
- if ( type == OBJECT_MOBILErr ) return "help\\object\\botrecy.txt";
- if ( type == OBJECT_MOBILErs ) return "help\\object\\botshld.txt";
- if ( type == OBJECT_MOBILEsa ) return "help\\object\\botsub.txt";
- if ( type == OBJECT_MOBILEwt ) return "help\\object\\bottr.txt";
- if ( type == OBJECT_MOBILEtg ) return "help\\object\\bottarg.txt";
- if ( type == OBJECT_MOBILEdr ) return "help\\object\\botdraw.txt";
- if ( type == OBJECT_APOLLO2 ) return "help\\object\\lrv.txt";
- if ( type == OBJECT_HUMAN ) return "help\\object\\human.txt";
- if ( type == OBJECT_MOTHER ) return "help\\object\\mother.txt";
- if ( type == OBJECT_EGG ) return "help\\object\\egg.txt";
- if ( type == OBJECT_ANT ) return "help\\object\\ant.txt";
- if ( type == OBJECT_SPIDER ) return "help\\object\\spider.txt";
- if ( type == OBJECT_BEE ) return "help\\object\\wasp.txt";
- if ( type == OBJECT_WORM ) return "help\\object\\worm.txt";
- if ( type == OBJECT_RUINmobilew1) return "help\\object\\wreck.txt";
+ if ( type == OBJECT_BASE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/base.txt");
+ if ( type == OBJECT_DERRICK ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/derrick.txt");
+ if ( type == OBJECT_FACTORY ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/factory.txt");
+ if ( type == OBJECT_STATION ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/station.txt");
+ if ( type == OBJECT_CONVERT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/convert.txt");
+ if ( type == OBJECT_REPAIR ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/repair.txt");
+ if ( type == OBJECT_DESTROYER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/destroy.txt");
+ if ( type == OBJECT_TOWER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/tower.txt");
+ if ( type == OBJECT_NEST ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/nest.txt");
+ if ( type == OBJECT_RESEARCH ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/research.txt");
+ if ( type == OBJECT_RADAR ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/radar.txt");
+ if ( type == OBJECT_INFO ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/exchange.txt");
+ if ( type == OBJECT_ENERGY ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/energy.txt");
+ if ( type == OBJECT_LABO ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/labo.txt");
+ if ( type == OBJECT_NUCLEAR ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/nuclear.txt");
+ if ( type == OBJECT_PARA ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/captor.txt");
+ if ( type == OBJECT_SAFE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/safe.txt");
+ if ( type == OBJECT_HUSTON ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/huston.txt");
+ if ( type == OBJECT_START ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/start.txt");
+ if ( type == OBJECT_END ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/goal.txt");
+ if ( type == OBJECT_STONE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/titanore.txt");
+ if ( type == OBJECT_URANIUM ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/uranore.txt");
+ if ( type == OBJECT_METAL ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/titan.txt");
+ if ( type == OBJECT_POWER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/power.txt");
+ if ( type == OBJECT_ATOMIC ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/atomic.txt");
+ if ( type == OBJECT_BULLET ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bullet.txt");
+ if ( type == OBJECT_BBOX ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bbox.txt");
+ if ( type == OBJECT_KEYa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_KEYb ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_KEYc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_KEYd ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_TNT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/tnt.txt");
+ if ( type == OBJECT_SCRAP1 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/scrap.txt");
+ if ( type == OBJECT_BOMB ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/mine.txt");
+ if ( type == OBJECT_BARRIER1 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/barrier.txt");
+ if ( type == OBJECT_WAYPOINT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/waypoint.txt");
+ if ( type == OBJECT_FLAGb ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGr ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGg ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGy ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGv ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_MARKPOWER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/enerspot.txt");
+ if ( type == OBJECT_MARKSTONE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/stonspot.txt");
+ if ( type == OBJECT_MARKURANIUM ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/uranspot.txt");
+ if ( type == OBJECT_MOBILEwa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgr.txt");
+ if ( type == OBJECT_MOBILEta ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgc.txt");
+ if ( type == OBJECT_MOBILEfa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgj.txt");
+ if ( type == OBJECT_MOBILEia ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgs.txt");
+ if ( type == OBJECT_MOBILEws ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsr.txt");
+ if ( type == OBJECT_MOBILEts ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsc.txt");
+ if ( type == OBJECT_MOBILEfs ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsj.txt");
+ if ( type == OBJECT_MOBILEis ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botss.txt");
+ if ( type == OBJECT_MOBILEwi ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botor.txt");
+ if ( type == OBJECT_MOBILEti ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botoc.txt");
+ if ( type == OBJECT_MOBILEfi ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botoj.txt");
+ if ( type == OBJECT_MOBILEii ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botos.txt");
+ if ( type == OBJECT_MOBILEwc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfr.txt");
+ if ( type == OBJECT_MOBILEtc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfc.txt");
+ if ( type == OBJECT_MOBILEfc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfj.txt");
+ if ( type == OBJECT_MOBILEic ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfs.txt");
+ if ( type == OBJECT_MOBILErt ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bottump.txt");
+ if ( type == OBJECT_MOBILErc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botphaz.txt");
+ if ( type == OBJECT_MOBILErr ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botrecy.txt");
+ if ( type == OBJECT_MOBILErs ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botshld.txt");
+ if ( type == OBJECT_MOBILEsa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsub.txt");
+ if ( type == OBJECT_MOBILEwt ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bottr.txt");
+ if ( type == OBJECT_MOBILEtg ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bottarg.txt");
+ if ( type == OBJECT_MOBILEdr ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botdraw.txt");
+ if ( type == OBJECT_APOLLO2 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/lrv.txt");
+ if ( type == OBJECT_HUMAN ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/human.txt");
+ if ( type == OBJECT_MOTHER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/mother.txt");
+ if ( type == OBJECT_EGG ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/egg.txt");
+ if ( type == OBJECT_ANT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/ant.txt");
+ if ( type == OBJECT_SPIDER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/spider.txt");
+ if ( type == OBJECT_BEE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/wasp.txt");
+ if ( type == OBJECT_WORM ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/worm.txt");
+ if ( type == OBJECT_RUINmobilew1) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/wreck.txt");
return "";
}
// Returns the help file to use for instruction.
-const char* GetHelpFilename(const char *token)
+std::string GetHelpFilename(const char *token)
{
- if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt";
- if ( strcmp(token, "else" ) == 0 ) return "help\\cbot\\if.txt";
- if ( strcmp(token, "repeat" ) == 0 ) return "help\\cbot\\repeat.txt";
- if ( strcmp(token, "for" ) == 0 ) return "help\\cbot\\for.txt";
- if ( strcmp(token, "while" ) == 0 ) return "help\\cbot\\while.txt";
- if ( strcmp(token, "do" ) == 0 ) return "help\\cbot\\do.txt";
- if ( strcmp(token, "break" ) == 0 ) return "help\\cbot\\break.txt";
- if ( strcmp(token, "continue" ) == 0 ) return "help\\cbot\\continue.txt";
- if ( strcmp(token, "return" ) == 0 ) return "help\\cbot\\return.txt";
- if ( strcmp(token, "sizeof" ) == 0 ) return "help\\cbot\\sizeof.txt";
- if ( strcmp(token, "int" ) == 0 ) return "help\\cbot\\int.txt";
- if ( strcmp(token, "float" ) == 0 ) return "help\\cbot\\float.txt";
- if ( strcmp(token, "bool" ) == 0 ) return "help\\cbot\\bool.txt";
- if ( strcmp(token, "string" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "point" ) == 0 ) return "help\\cbot\\point.txt";
- if ( strcmp(token, "object" ) == 0 ) return "help\\cbot\\object.txt";
- if ( strcmp(token, "file" ) == 0 ) return "help\\cbot\\file.txt";
- if ( strcmp(token, "void" ) == 0 ) return "help\\cbot\\void.txt";
- if ( strcmp(token, "null" ) == 0 ) return "help\\cbot\\null.txt";
- if ( strcmp(token, "nan" ) == 0 ) return "help\\cbot\\nan.txt";
- if ( strcmp(token, "true" ) == 0 ) return "help\\cbot\\true.txt";
- if ( strcmp(token, "false" ) == 0 ) return "help\\cbot\\false.txt";
- if ( strcmp(token, "sin" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "cos" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "tan" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "asin" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "acos" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "atan" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "sqrt" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "pow" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "rand" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "abs" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "retobject" ) == 0 ) return "help\\cbot\\retobj.txt";
- if ( strcmp(token, "search" ) == 0 ) return "help\\cbot\\search.txt";
- if ( strcmp(token, "radar" ) == 0 ) return "help\\cbot\\radar.txt";
- if ( strcmp(token, "direction" ) == 0 ) return "help\\cbot\\direct.txt";
- if ( strcmp(token, "distance" ) == 0 ) return "help\\cbot\\dist.txt";
- if ( strcmp(token, "distance2d" ) == 0 ) return "help\\cbot\\dist2d.txt";
- if ( strcmp(token, "space" ) == 0 ) return "help\\cbot\\space.txt";
- if ( strcmp(token, "flatground" ) == 0 ) return "help\\cbot\\flatgrnd.txt";
- if ( strcmp(token, "wait" ) == 0 ) return "help\\cbot\\wait.txt";
- if ( strcmp(token, "move" ) == 0 ) return "help\\cbot\\move.txt";
- if ( strcmp(token, "turn" ) == 0 ) return "help\\cbot\\turn.txt";
- if ( strcmp(token, "goto" ) == 0 ) return "help\\cbot\\goto.txt";
- if ( strcmp(token, "find" ) == 0 ) return "help\\cbot\\find.txt";
- if ( strcmp(token, "grab" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "drop" ) == 0 ) return "help\\cbot\\drop.txt";
- if ( strcmp(token, "sniff" ) == 0 ) return "help\\cbot\\sniff.txt";
- if ( strcmp(token, "receive" ) == 0 ) return "help\\cbot\\receive.txt";
- if ( strcmp(token, "send" ) == 0 ) return "help\\cbot\\send.txt";
- if ( strcmp(token, "deleteinfo" ) == 0 ) return "help\\cbot\\delinfo.txt";
- if ( strcmp(token, "testinfo" ) == 0 ) return "help\\cbot\\testinfo.txt";
- if ( strcmp(token, "thump" ) == 0 ) return "help\\cbot\\thump.txt";
- if ( strcmp(token, "recycle" ) == 0 ) return "help\\cbot\\recycle.txt";
- if ( strcmp(token, "shield" ) == 0 ) return "help\\cbot\\shield.txt";
- if ( strcmp(token, "fire" ) == 0 ) return "help\\cbot\\fire.txt";
- if ( strcmp(token, "antfire" ) == 0 ) return "help\\cbot\\antfire.txt";
- if ( strcmp(token, "aim" ) == 0 ) return "help\\cbot\\aim.txt";
- if ( strcmp(token, "motor" ) == 0 ) return "help\\cbot\\motor.txt";
- if ( strcmp(token, "jet" ) == 0 ) return "help\\cbot\\jet.txt";
- if ( strcmp(token, "topo" ) == 0 ) return "help\\cbot\\topo.txt";
- if ( strcmp(token, "message" ) == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "abstime" ) == 0 ) return "help\\cbot\\abstime.txt";
- if ( strcmp(token, "BlackArrow" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "RedArrow" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "White" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Black" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Gray" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "LightGray" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Red" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Pink" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Purple" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Orange" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Yellow" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Beige" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Brown" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Skin" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Green" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "LightGreen" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Blue" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "LightBlue" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "InFront" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "Behind" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "EnergyCell" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "DisplayError" ) == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "DisplayWarning") == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "DisplayInfo" ) == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "DisplayMessage") == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "strlen" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strleft" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strright" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strmid" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strval" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strfind" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strlower" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strupper" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "open" ) == 0 ) return "help\\cbot\\open.txt";
- if ( strcmp(token, "close" ) == 0 ) return "help\\cbot\\close.txt";
- if ( strcmp(token, "writeln" ) == 0 ) return "help\\cbot\\writeln.txt";
- if ( strcmp(token, "readln " ) == 0 ) return "help\\cbot\\readln.txt";
- if ( strcmp(token, "eof" ) == 0 ) return "help\\cbot\\eof.txt";
- if ( strcmp(token, "deletefile" ) == 0 ) return "help\\cbot\\deletef.txt";
- if ( strcmp(token, "openfile" ) == 0 ) return "help\\cbot\\openfile.txt";
- if ( strcmp(token, "pendown" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "penup" ) == 0 ) return "help\\cbot\\penup.txt";
- if ( strcmp(token, "pencolor" ) == 0 ) return "help\\cbot\\pencolor.txt";
- if ( strcmp(token, "penwidth" ) == 0 ) return "help\\cbot\\penwidth.txt";
- if ( strcmp(token, "extern" ) == 0 ) return "help\\cbot\\extern.txt";
- if ( strcmp(token, "class" ) == 0 ) return "help\\cbot\\class.txt";
- if ( strcmp(token, "static" ) == 0 ) return "help\\cbot\\static.txt";
- if ( strcmp(token, "public" ) == 0 ) return "help\\cbot\\public.txt";
- if ( strcmp(token, "private" ) == 0 ) return "help\\cbot\\private.txt";
- if ( strcmp(token, "synchronized" ) == 0 ) return "help\\cbot\\synchro.txt";
- if ( strcmp(token, "new" ) == 0 ) return "help\\cbot\\new.txt";
- if ( strcmp(token, "this" ) == 0 ) return "help\\cbot\\this.txt";
+ if ( strcmp(token, "if" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt");
+ if ( strcmp(token, "else" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt");
+ if ( strcmp(token, "repeat" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/repeat.txt");
+ if ( strcmp(token, "for" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/for.txt");
+ if ( strcmp(token, "while" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/while.txt");
+ if ( strcmp(token, "do" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/do.txt");
+ if ( strcmp(token, "break" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/break.txt");
+ if ( strcmp(token, "continue" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/continue.txt");
+ if ( strcmp(token, "return" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/return.txt");
+ if ( strcmp(token, "sizeof" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sizeof.txt");
+ if ( strcmp(token, "int" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/int.txt");
+ if ( strcmp(token, "float" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/float.txt");
+ if ( strcmp(token, "bool" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/bool.txt");
+ if ( strcmp(token, "string" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "point" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/point.txt");
+ if ( strcmp(token, "object" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/object.txt");
+ if ( strcmp(token, "file" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/file.txt");
+ if ( strcmp(token, "void" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/void.txt");
+ if ( strcmp(token, "null" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/null.txt");
+ if ( strcmp(token, "nan" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/nan.txt");
+ if ( strcmp(token, "true" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/true.txt");
+ if ( strcmp(token, "false" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/false.txt");
+ if ( strcmp(token, "sin" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "cos" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "tan" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "asin" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "acos" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "atan" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "sqrt" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "pow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "rand" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "abs" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt");
+ if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt");
+ if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt");
+ if ( strcmp(token, "direction" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/direct.txt");
+ if ( strcmp(token, "distance" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/dist.txt");
+ if ( strcmp(token, "distance2d" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/dist2d.txt");
+ if ( strcmp(token, "space" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/space.txt");
+ if ( strcmp(token, "flatground" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/flatgrnd.txt");
+ if ( strcmp(token, "wait" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/wait.txt");
+ if ( strcmp(token, "move" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/move.txt");
+ if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt");
+ if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt");
+ if ( strcmp(token, "find" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/find.txt");
+ if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt");
+ if ( strcmp(token, "sniff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sniff.txt");
+ if ( strcmp(token, "receive" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/receive.txt");
+ if ( strcmp(token, "send" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/send.txt");
+ if ( strcmp(token, "deleteinfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/delinfo.txt");
+ if ( strcmp(token, "testinfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/testinfo.txt");
+ if ( strcmp(token, "thump" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/thump.txt");
+ if ( strcmp(token, "recycle" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/recycle.txt");
+ if ( strcmp(token, "shield" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/shield.txt");
+ if ( strcmp(token, "fire" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/fire.txt");
+ if ( strcmp(token, "antfire" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/antfire.txt");
+ if ( strcmp(token, "aim" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/aim.txt");
+ if ( strcmp(token, "motor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/motor.txt");
+ if ( strcmp(token, "jet" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/jet.txt");
+ if ( strcmp(token, "topo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/topo.txt");
+ if ( strcmp(token, "message" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "abstime" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/abstime.txt");
+ if ( strcmp(token, "BlackArrow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "RedArrow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "White" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Black" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Gray" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "LightGray" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Red" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Pink" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Purple" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Orange" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Yellow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Beige" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Brown" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Skin" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Green" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "LightGreen" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Blue" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "LightBlue" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "InFront" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "Behind" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "EnergyCell" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "DisplayError" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "DisplayWarning") == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "DisplayInfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "DisplayMessage") == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "strlen" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strleft" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strright" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strmid" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strval" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strfind" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strlower" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strupper" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "open" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/open.txt");
+ if ( strcmp(token, "close" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/close.txt");
+ if ( strcmp(token, "writeln" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/writeln.txt");
+ if ( strcmp(token, "readln " ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/readln.txt");
+ if ( strcmp(token, "eof" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/eof.txt");
+ if ( strcmp(token, "deletefile" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/deletef.txt");
+ if ( strcmp(token, "openfile" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/openfile.txt");
+ if ( strcmp(token, "pendown" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "penup" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penup.txt");
+ if ( strcmp(token, "pencolor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pencolor.txt");
+ if ( strcmp(token, "penwidth" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penwidth.txt");
+ if ( strcmp(token, "extern" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/extern.txt");
+ if ( strcmp(token, "class" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/class.txt");
+ if ( strcmp(token, "static" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/static.txt");
+ if ( strcmp(token, "public" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/public.txt");
+ if ( strcmp(token, "private" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/private.txt");
+ if ( strcmp(token, "synchronized" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/synchro.txt");
+ if ( strcmp(token, "new" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/new.txt");
+ if ( strcmp(token, "this" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/this.txt");
return "";
}
@@ -450,7 +451,7 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "pow" ) == 0 ) return "pow ( x, y );";
if ( strcmp(token, "rand" ) == 0 ) return "rand ( );";
if ( strcmp(token, "abs" ) == 0 ) return "abs ( value );";
- if ( strcmp(token, "retobject" ) == 0 ) return "retobjet ( );";
+ if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( );";
if ( strcmp(token, "search" ) == 0 ) return "search ( );";
if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );";
if ( strcmp(token, "detect" ) == 0 ) return "detect ( cat );";
@@ -475,8 +476,8 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "recycle" ) == 0 ) return "recycle ( );";
if ( strcmp(token, "shield" ) == 0 ) return "shield ( oper, radius );";
if ( strcmp(token, "fire" ) == 0 ) return "fire ( time );";
- if ( strcmp(token, "antfire" ) == 0 ) return "antfire ( );";
- if ( strcmp(token, "aim" ) == 0 ) return "aim ( angle, angle );";
+ //if ( strcmp(token, "antfire" ) == 0 ) return "antfire ( );";
+ if ( strcmp(token, "aim" ) == 0 ) return "aim ( x, y );";
if ( strcmp(token, "motor" ) == 0 ) return "motor ( left, right );";
if ( strcmp(token, "jet" ) == 0 ) return "jet ( power );";
if ( strcmp(token, "topo" ) == 0 ) return "topo ( position );";
diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h
index f5b7b70..bc53f77 100644
--- a/src/script/cbottoken.h
+++ b/src/script/cbottoken.h
@@ -30,8 +30,8 @@
extern const char* GetObjectName(ObjectType type);
extern const char* GetObjectAlias(ObjectType type);
-extern const char* GetHelpFilename(ObjectType type);
-extern const char* GetHelpFilename(const char *token);
+extern std::string GetHelpFilename(ObjectType type);
+extern std::string GetHelpFilename(const char *token);
extern bool IsType(const char *token);
extern bool IsFunction(const char *token);
extern const char* GetHelpText(const char *token);
diff --git a/src/script/script.cpp b/src/script/script.cpp
index a62866d..6095e05 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -33,6 +33,7 @@
#include "object/object.h"
#include "object/robotmain.h"
#include "object/task/taskmanager.h"
+#include "object/objman.h"
#include "physics/physics.h"
@@ -329,15 +330,12 @@ CBotTypResult CScript::cGetObject(CBotVar* &var, void* user)
bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = (static_cast<CObject*>(user))->GetRunScript();
CObject* pObj;
int rank;
rank = var->GetValInt();
- CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
-
- pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, rank));
+ pObj = static_cast<CObject*>(CObjectManager::GetInstancePointer()->SearchInstance(rank));
if ( pObj == 0 )
{
result->SetPointer(0);
@@ -349,6 +347,66 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us
return true;
}
+// Compilation of the instruction "destroy(rank[, exploType[, force]])".
+
+CBotTypResult CScript::cDestroy(CBotVar* &var, void* user)
+{
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+
+ if ( var != 0 ) {
+ if ( var->GetType() != CBotTypInt ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+
+ if ( var != 0 ) {
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+ }
+ }
+
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
+
+ return CBotTypResult(CBotTypFloat);
+}
+
+// Instruction "destroy(rank[, exploType[, force]])".
+
+bool CScript::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user)
+{
+ CObject* pObj;
+ int rank;
+ int exploType = 0;
+ float force = 1.0f;
+
+ rank = var->GetValInt();
+ var->GetNext();
+ if ( var != 0 ) {
+ exploType = var->GetValInt();
+ var->GetNext();
+ if ( var != 0 ) {
+ force = var->GetValFloat();
+ }
+ }
+
+ pObj = static_cast<CObject*>(CObjectManager::GetInstancePointer()->SearchInstance(rank));
+ if ( pObj == 0 )
+ {
+ return true;
+ }
+ else
+ {
+ if ( exploType ) {
+ pObj->ExploObject(static_cast<ExploType>(exploType), force);
+ } else {
+ pObj->DeleteObject(false);
+ }
+ }
+ return true;
+}
+
+
// Compilation of the instruction "search(type, pos)".
@@ -380,7 +438,6 @@ CBotTypResult CScript::cSearch(CBotVar* &var, void* user)
bool CScript::rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CObject *pObj, *pBest;
CBotVar* array;
Math::Vector pos, oPos;
@@ -523,7 +580,6 @@ CBotTypResult CScript::cRadar(CBotVar* &var, void* user)
bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CObject* pThis = static_cast<CObject *>(user);
CObject *pObj, *pBest;
CPhysics* physics;
@@ -1210,6 +1266,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
physics->SetFreeze(false); // can move
}
object->SetLock(false); // vehicle useable
+ object->SetManual(true);
object->SetActivity(true);
script->m_main->CreateShortcuts();
}
@@ -2897,6 +2954,7 @@ void CScript::InitFonctions()
CBotProgram::AddFunction("abs", rAbs, CScript::cOneFloat);
CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject);
+ CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy);
CBotProgram::AddFunction("search", rSearch, CScript::cSearch);
CBotProgram::AddFunction("radar", rRadar, CScript::cRadar);
CBotProgram::AddFunction("detect", rDetect, CScript::cDetect);
diff --git a/src/script/script.h b/src/script/script.h
index 982d12b..0d2726a 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -100,6 +100,7 @@ private:
static CBotTypResult cTwoFloat(CBotVar* &var, void* user);
static CBotTypResult cString(CBotVar* &var, void* user);
static CBotTypResult cGetObject(CBotVar* &var, void* user);
+ static CBotTypResult cDestroy(CBotVar* &var, void* user);
static CBotTypResult cSearch(CBotVar* &var, void* user);
static CBotTypResult cRadar(CBotVar* &var, void* user);
static CBotTypResult cDetect(CBotVar* &var, void* user);
@@ -133,6 +134,7 @@ private:
static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user);
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 8c1cb81..e3a3f4b 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -81,6 +81,7 @@ bool ALSound::Create(bool b3D)
return false;
}
alcMakeContextCurrent(mContext);
+ alListenerf(AL_GAIN, mAudioVolume);
mCurrentMusic = new Channel();
GetLogger()->Info("Done.\n");
@@ -118,8 +119,7 @@ bool ALSound::GetEnable()
void ALSound::SetAudioVolume(int volume)
{
- mAudioVolume = MIN(static_cast<float>(volume) / MAXVOLUME, 1.0f);
- alListenerf(AL_GAIN, mAudioVolume);
+ mAudioVolume = static_cast<float>(volume) / MAXVOLUME;
}
@@ -134,9 +134,9 @@ int ALSound::GetAudioVolume()
void ALSound::SetMusicVolume(int volume)
{
- mMusicVolume = MIN(static_cast<float>(volume) / MAXVOLUME, 1.0f);
+ mMusicVolume = static_cast<float>(volume) / MAXVOLUME;
if (mCurrentMusic) {
- mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume);
+ mCurrentMusic->SetVolume(mMusicVolume);
}
}
@@ -298,7 +298,6 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
if (!mEnabled) {
return -1;
}
-
if (mSounds.find(sound) == mSounds.end()) {
GetLogger()->Warn("Sound %d was not loaded!\n", sound);
return -1;
@@ -323,7 +322,7 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
mChannels[channel]->SetChangeFrequency(1.0f);
mChannels[channel]->ResetOper();
mChannels[channel]->SetFrequency(frequency);
- mChannels[channel]->SetVolume(amplitude * mAudioVolume);
+ mChannels[channel]->SetVolume(powf(amplitude, 0.2f) * mAudioVolume);
mChannels[channel]->SetLoop(bLoop);
mChannels[channel]->Play();
@@ -426,17 +425,12 @@ bool ALSound::MuteAll(bool bMute)
if (!mEnabled)
return false;
- float volume;
mMute = bMute;
- if (mMute)
- volume = 0;
- else
- volume = mAudioVolume;
-
- for (auto channel : mChannels) {
- channel.second->SetVolume(volume * mAudioVolume);
+ if (mMute) {
+ mCurrentMusic->SetVolume(0.0f);
+ } else {
+ mCurrentMusic->SetVolume(mMusicVolume);
}
-
return true;
}
@@ -451,6 +445,11 @@ void ALSound::FrameMove(float delta)
if (!it.second->IsPlaying()) {
continue;
}
+
+ if (mMute) {
+ it.second->SetVolume(0.0f);
+ continue;
+ }
if (!it.second->HasEnvelope())
continue;
@@ -461,13 +460,19 @@ void ALSound::FrameMove(float delta)
progress = MIN(progress, 1.0f);
// setting volume
- volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude());
- volume = (volume + it.second->GetStartAmplitude()) * mAudioVolume;
- it.second->SetVolume(volume);
+ if (!mMute) {
+ volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude());
+ volume = (volume + it.second->GetStartAmplitude());
+ it.second->SetVolume(powf(volume, 0.2f) * mAudioVolume);
+ }
// setting frequency
- frequency = progress * (oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency() * it.second->GetInitFrequency();
- it.second->AdjustFrequency(frequency);
+ frequency = progress;
+ frequency *= oper.finalFrequency - it.second->GetStartFrequency();
+ frequency += it.second->GetStartFrequency();
+ frequency *= it.second->GetChangeFrequency();
+ frequency = (frequency * it.second->GetInitFrequency());
+ it.second->SetFrequency(frequency);
if (oper.totalTime <= oper.currentTime) {
if (oper.nextOper == SOPER_LOOP) {
@@ -508,7 +513,7 @@ bool ALSound::PlayMusic(int rank, bool bRepeat)
GetLogger()->Debug("Music loaded from cache\n");
mCurrentMusic->SetBuffer(music);
- mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume);
+ mCurrentMusic->SetVolume(mMusicVolume);
mCurrentMusic->SetLoop(bRepeat);
mCurrentMusic->Play();
return true;
@@ -533,7 +538,7 @@ bool ALSound::PlayMusic(int rank, bool bRepeat)
mMusicCache[rank] = buffer;
}
- mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume);
+ mCurrentMusic->SetVolume(mMusicVolume);
mCurrentMusic->SetLoop(bRepeat);
mCurrentMusic->Play();
diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp
index 19394c6..f5967ab 100644
--- a/src/sound/oalsound/channel.cpp
+++ b/src/sound/oalsound/channel.cpp
@@ -17,8 +17,6 @@
#include "channel.h"
-#define MIN(a, b) (a > b ? b : a)
-
Channel::Channel() {
alGenSources(1, &mSource);
@@ -89,15 +87,6 @@ bool Channel::SetFrequency(float freq)
}
-bool Channel::AdjustFrequency(float freq)
-{
- if (!mReady || mBuffer == nullptr)
- return false;
-
- return SetFrequency(mInitFrequency + fabs(freq));
-}
-
-
float Channel::GetFrequency()
{
ALfloat freq;
@@ -119,7 +108,7 @@ bool Channel::SetVolume(float vol)
if (!mReady || vol < 0 || mBuffer == nullptr)
return false;
- alSourcef(mSource, AL_GAIN, MIN(powf(vol, 0.2f), 1.0f));
+ alSourcef(mSource, AL_GAIN, vol);
if (alCheck()) {
GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
return false;
diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h
index 8965306..883ddf2 100644
--- a/src/sound/oalsound/channel.h
+++ b/src/sound/oalsound/channel.h
@@ -52,7 +52,6 @@ class Channel
bool SetFrequency(float);
float GetFrequency();
- bool AdjustFrequency(float);
float GetCurrentTime();
void SetCurrentTime(float);
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 974cd60..fcc77db 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -989,9 +989,9 @@ void ObjectWrite(FILE* file, ObjectList list[], int i)
strcat(line, res);
strcat(line, "\\u ");
- p = const_cast<char*>(GetHelpFilename(list[i].type));
+ p = const_cast<char*>(GetHelpFilename(list[i].type).c_str());
if ( p[0] == 0 ) return;
- strcat(line, p+5); // skip "help\"
+ strcat(line, p+7); // skip "help\?\"
p = strstr(line, ".txt");
if ( p != 0 ) *p = 0;
strcat(line, ";\n");
@@ -1012,7 +1012,7 @@ void CDisplayInfo::CreateObjectsFile()
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
- file = fopen("help\\objects.txt", "w");
+ file = fopen((std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("objects.txt")).c_str(), "w");
if ( file == 0 ) return;
list[0].total = 0; // empty list
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index e4bb3a3..e60a040 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -786,7 +786,7 @@ void CEdit::HyperJump(std::string name, std::string marker)
if ( name[0] == '%' ) {
filename = GetProfile().GetUserBasedPath(name, "") + ".txt";
} else {
- filename = "/help/" + name + ".txt";
+ filename = std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + "/" + name + std::string(".txt");
}
if ( ReadText(filename) )
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index ced4324..75db2a6 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -1819,7 +1819,7 @@ pos.y -= 0.048f;
pe->SetHighlightCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
- pe->ReadText("help/authors.txt");
+ pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));
pos.x = 80.0f/640.0f;
pos.y = 140.0f/480.0f;
@@ -1831,7 +1831,7 @@ pos.y -= 0.048f;
pe->SetHighlightCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
- pe->ReadText("help/licences.txt");
+ pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/licences.txt"));
// #endif
/* TODO: #if _SCHOOL
#if _CEEBOTDEMO
@@ -4256,14 +4256,18 @@ void CMainDialog::DefPerso()
bool CMainDialog::IsIOReadScene()
{
- FILE* file;
- std::string filename;
-
- filename = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + "000/data.sav";
- file = fopen(filename.c_str(), "r");
- if ( file == NULL ) return false;
- fclose(file);
- return true;
+ fs::directory_iterator end_iter;
+
+ fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName());
+ if (fs::exists(saveDir) && fs::is_directory(saveDir)) {
+ for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) {
+ if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
// Builds the file name by default.
@@ -4283,9 +4287,9 @@ void CMainDialog::IOReadName()
int i;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
- if ( pw == 0 ) return;
+ if ( pw == nullptr ) return;
pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME));
- if ( pe == 0 ) return;
+ if ( pe == nullptr ) return;
sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1);
BuildSceneName(filename, m_sceneName, (m_chap[m_index]+1)*100);
@@ -4337,7 +4341,8 @@ void CMainDialog::IOReadList()
CList* pl;
char line[500];
char name[100];
- int i, j;
+ int i;
+ fs::directory_iterator end_iter;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
@@ -4345,50 +4350,46 @@ void CMainDialog::IOReadList()
if ( pl == 0 ) return;
pl->Flush();
+
+ fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName());
+ m_saveList.clear();
+
+ if (fs::exists(saveDir) && fs::is_directory(saveDir)) {
+ for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) {
+ if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) {
+
+ file = fopen((dir_iter->path() / "data.sav").make_preferred().string().c_str(), "r");
+ if ( file == NULL ) continue;
+
+ while ( fgets(line, 500, file) != NULL ) {
+ for ( i=0 ; i<500 ; i++ ) {
+ if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space
+ if ( line[i] == '/' && line[i+1] == '/' ) {
+ line[i] = 0;
+ break;
+ }
+ }
- for ( j=0 ; j<999 ; j++ )
- {
- std::string filename;
- std::ostringstream rankStream;
- rankStream << std::setfill('0') << std::setw(3) << j;
- filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav";
-
- // sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j);
- file = fopen(fs::path(filename).make_preferred().string().c_str(), "r");
- if ( file == NULL ) break;
-
- while ( fgets(line, 500, file) != NULL )
- {
- for ( i=0 ; i<500 ; i++ )
- {
- if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space
- if ( line[i] == '/' && line[i+1] == '/' )
- {
- line[i] = 0;
- break;
+ if ( Cmd(line, "Title") ) {
+ OpString(line, "text", name);
+ break;
+ }
}
- }
+ fclose(file);
- if ( Cmd(line, "Title") )
- {
- OpString(line, "text", name);
- break;
+ pl->SetName(m_saveList.size(), name);
+ m_saveList.push_back(dir_iter->path());
}
}
- fclose(file);
-
- pl->SetName(j, name);
}
-
- if ( m_phase == PHASE_WRITE ||
- m_phase == PHASE_WRITEs )
- {
+
+ // zly indeks
+ if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) {
GetResource(RES_TEXT, RT_IO_NEW, name);
- pl->SetName(j, name);
- j ++;
+ pl->SetName(m_saveList.size(), name);
}
- pl->SetSelect(j-1);
+ pl->SetSelect(m_saveList.size());
pl->ShowSelect(false); // shows the selected columns
}
@@ -4403,35 +4404,31 @@ void CMainDialog::IOUpdateList()
int sel, max;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
- if ( pw == 0 ) return;
+ if ( pw == nullptr ) return;
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
- if ( pl == 0 ) return;
+ if ( pl == nullptr ) return;
pi = static_cast<CImage*>(pw->SearchControl(EVENT_INTERFACE_IOIMAGE));
- if ( pi == 0 ) return;
+ if ( pi == nullptr ) return;
sel = pl->GetSelect();
max = pl->GetTotal();
- std::string filename;
- std::ostringstream rankStream;
- rankStream << std::setfill('0') << std::setw(3) << sel;
- filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/screen.png";
-
- if ( m_phase == PHASE_WRITE ||
- m_phase == PHASE_WRITEs )
+ if (m_saveList.size() <= static_cast<unsigned int>(sel)) {
+ return;
+ }
+
+ std::string filename = (m_saveList.at(sel) / "screen.png").make_preferred().string();
+ if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs )
{
- if ( sel < max-1 )
- {
+ if ( sel < max-1 ) {
pi->SetFilenameImage(filename.c_str());
}
- else
- {
+ else {
pi->SetFilenameImage("");
}
pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_IODELETE));
- if ( pb != 0 )
- {
+ if ( pb != nullptr ) {
pb->SetState(STATE_ENABLE, sel < max-1);
}
}
@@ -4455,34 +4452,40 @@ void CMainDialog::IODeleteScene()
if ( pl == 0 ) return;
sel = pl->GetSelect();
- if ( sel == -1 )
+ if ( sel == -1 || m_saveList.size() <= static_cast<unsigned int>(sel))
{
m_sound->Play(SOUND_TZOING);
return;
}
-
- std::ostringstream rankStream;
- std::string fileName;
- rankStream << std::setfill('0') << std::setw(3) << sel;
- fileName = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str();
try
{
- if (fs::exists(fileName) && fs::is_directory(fileName))
- {
- fs::remove_all(fileName);
+ if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) {
+ fs::remove_all(m_saveList.at(sel));
}
}
- catch (std::exception & e)
- {
- GetLogger()->Error("Error on removing directory %s : %s\n", e.what());
+ catch (std::exception & e) {
+ GetLogger()->Error("Error removing save %s : %s\n", pl->GetName(sel), e.what());
}
IOReadList();
}
-// Writes the scene.
+// clears filename only to leave letter or numbers
+std::string clearName(char *name)
+{
+ std::string ret;
+ int len = strlen(name);
+ for (int i = 0; i < len; i++) {
+ if (isalnum(name[i])) {
+ ret += name[i];
+ }
+ }
+ return ret;
+}
+
+// Writes the scene.
bool CMainDialog::IOWriteScene()
{
CWindow* pw;
@@ -4492,36 +4495,35 @@ bool CMainDialog::IOWriteScene()
int sel;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
- if ( pw == 0 ) return false;
+ if ( pw == nullptr ) return false;
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
- if ( pl == 0 ) return false;
+ if ( pl == nullptr ) return false;
pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME));
- if ( pe == 0 ) return false;
+ if ( pe == nullptr ) return false;
sel = pl->GetSelect();
- if ( sel == -1 ) return false;
-
- std::string directoryName;
- std::string fileName;
- std::string fileCBot;
- std::ostringstream selectStream;
-
- //TODO: Change this to point user dir according to operating system
- GetLogger()->Debug("Creating save directory\n");
- selectStream << std::setfill('0') << std::setw(3) << sel;
- directoryName = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + selectStream.str();
- if (!fs::exists(directoryName))
- {
- fs::create_directories(directoryName);
+ if ( sel == -1 ) {
+ return false;
}
-
- fileName = directoryName + "/data.sav";
- fileCBot = directoryName + "/cbot.run";
+
+ fs::path dir;
pe->GetText(info, 100);
+ if (static_cast<unsigned int>(sel) >= m_saveList.size()) {
+ dir = fs::path(m_savegameDir) / m_main->GetGamerName() / ("save" + clearName(info));
+ } else {
+ dir = m_saveList.at(sel);
+ }
+
+ if (!fs::exists(dir)) {
+ fs::create_directories(dir);
+ }
+
+ std::string fileName = (dir / "data.sav").make_preferred().string();
+ std::string fileCBot = (dir / "cbot.run").make_preferred().string();
m_main->IOWriteScene(fileName.c_str(), fileCBot.c_str(), info);
m_shotDelay = 3;
- m_shotName = directoryName + "/screen.png";
+ m_shotName = (dir / "screen.png").make_preferred().string();
return true;
}
@@ -4538,58 +4540,46 @@ bool CMainDialog::IOReadScene()
int sel, i;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
- if ( pw == 0 ) return false;
+ if ( pw == nullptr ) return false;
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
- if ( pl == 0 ) return false;
+ if ( pl == nullptr ) return false;
sel = pl->GetSelect();
- if ( sel == -1 ) return false;
-
- //TODO: Change this to point user dir according to operating system
- std::string fileName;
- std::string fileCbot;
- std::string directoryName;
- std::ostringstream selectStream;
- selectStream << std::setfill('0') << std::setw(3) << sel;
- directoryName = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + selectStream.str();
+ if ( sel == -1 || m_saveList.size() <= static_cast<unsigned int>(sel) ) {
+ return false;
+ }
- fileName = directoryName + "/data.sav";
- fileCbot = directoryName + "/cbot.run";
+ std::string fileName = (m_saveList.at(sel) / "data.sav").make_preferred().string();
+ std::string fileCbot = (m_saveList.at(sel) / "cbot.run").make_preferred().string();
file = fopen(fileName.c_str(), "r");
- if ( file == NULL ) return false;
+ if ( file == NULL ) {
+ return false;
+ }
- while ( fgets(line, 500, file) != NULL )
- {
- for ( i=0 ; i<500 ; i++ )
- {
+ while ( fgets(line, 500, file) != NULL ) {
+ for ( i=0 ; i<500 ; i++ ) {
if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space
- if ( line[i] == '/' && line[i+1] == '/' )
- {
+ if ( line[i] == '/' && line[i+1] == '/' ) {
line[i] = 0;
break;
}
}
- if ( Cmd(line, "Mission") )
- {
+ if ( Cmd(line, "Mission") ) {
OpString(line, "base", m_sceneName);
m_sceneRank = OpInt(line, "rank", 0);
- if ( strcmp(m_sceneName, "user") == 0 )
- {
+ if ( strcmp(m_sceneName, "user") == 0 ) {
m_sceneRank = m_sceneRank%100;
OpString(line, "dir", dir);
- for ( i=0 ; i<m_userTotal ; i++ )
- {
- if ( strcmp(m_userList[i].c_str(), dir) == 0 )
- {
+ for ( i=0 ; i<m_userTotal ; i++ ) {
+ if ( strcmp(m_userList[i].c_str(), dir) == 0 ) {
m_sceneRank += (i+1)*100;
break;
}
}
- if ( m_sceneRank/100 == 0 )
- {
+ if ( m_sceneRank/100 == 0 ) {
fclose(file);
return false;
}
@@ -4598,8 +4588,8 @@ bool CMainDialog::IOReadScene()
}
fclose(file);
- m_chap[m_index] = (m_sceneRank/100)-1;
- m_sel[m_index] = (m_sceneRank%100)-1;
+ m_chap[m_index] = (m_sceneRank / 100)-1;
+ m_sel[m_index] = (m_sceneRank % 100)-1;
m_sceneRead = fileName;
m_stackRead = fileCbot;
@@ -6542,6 +6532,8 @@ void CMainDialog::WriteGamerPerso(char *gamer)
file = fopen(filename, "w");
if ( file == NULL ) return;
+ m_main->SetNumericLocale();
+
sprintf(line, "Head face=%d glasses=%d hair=%.2f;%.2f;%.2f;%.2f\n",
m_perso.face, m_perso.glasses,
m_perso.colorHair.r, m_perso.colorHair.g, m_perso.colorHair.b, m_perso.colorHair.a);
@@ -6553,6 +6545,8 @@ void CMainDialog::WriteGamerPerso(char *gamer)
fputs(line, file);
fclose(file);
+
+ m_main->RestoreNumericLocale();
}
// Reads the personalized player.
@@ -6570,6 +6564,8 @@ void CMainDialog::ReadGamerPerso(char *gamer)
sprintf(filename, "%s/%s/face.gam", m_savegameDir.c_str(), gamer);
file = fopen(filename, "r");
if ( file == NULL ) return;
+
+ m_main->SetNumericLocale();
while ( fgets(line, 100, file) != NULL )
{
@@ -6602,6 +6598,8 @@ void CMainDialog::ReadGamerPerso(char *gamer)
}
fclose(file);
+
+ m_main->RestoreNumericLocale();
}
// Specifies the face of the player.
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index a79b95e..afdf94f 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -26,6 +26,8 @@
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+#include <vector>
+
namespace fs = boost::filesystem;
@@ -260,6 +262,8 @@ protected:
Math::Point m_partiPos[10];
SceneInfo m_sceneInfo[MAXSCENE];
+
+ std::vector<fs::path> m_saveList;
};
} // namespace Ui
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index da18d83..29dfebf 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -500,7 +500,7 @@ void CStudio::SearchToken(CEdit* edit)
}
token[i] = 0;
- m_helpFilename = std::string(GetHelpFilename(token));
+ m_helpFilename = GetHelpFilename(token);
if ( m_helpFilename.length() == 0 )
{
for ( i=0 ; i<OBJECT_MAX ; i++ )
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 3d8a38c..7f78a35 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -90,6 +90,7 @@ ${SRC_DIR}/object/motion/motiontoto.cpp
${SRC_DIR}/object/motion/motionvehicle.cpp
${SRC_DIR}/object/motion/motionworm.cpp
${SRC_DIR}/object/object.cpp
+${SRC_DIR}/object/objman.cpp
${SRC_DIR}/object/robotmain.cpp
${SRC_DIR}/object/task/task.cpp
${SRC_DIR}/object/task/taskadvance.cpp
diff --git a/test/unit/ui/CMakeLists.txt b/test/unit/ui/CMakeLists.txt
index b0d9ce2..c899834 100644
--- a/test/unit/ui/CMakeLists.txt
+++ b/test/unit/ui/CMakeLists.txt
@@ -7,25 +7,35 @@ ${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR}
)
-# add_executable(edit_test
-# ${SRC_DIR}/common/event.cpp
-# ${SRC_DIR}/common/logger.cpp
-# ${SRC_DIR}/common/misc.cpp
-# ${SRC_DIR}/common/profile.cpp
-# ${SRC_DIR}/common/iman.cpp
-# ${SRC_DIR}/common/stringutils.cpp
-# ${SRC_DIR}/graphics/engine/text.cpp
-# ${SRC_DIR}/ui/button.cpp
-# ${SRC_DIR}/ui/control.cpp
-# ${SRC_DIR}/ui/edit.cpp
-# ${SRC_DIR}/ui/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})
-#
-# TODO: Edit test doesn't work, comment it away for now
-# add_test(edit_test ./edit_test)
+# Platform-dependent implementation of CSystemUtils
+if (${PLATFORM_WINDOWS})
+ set(SYSTEM_CPP_MODULE "system_windows.cpp")
+elseif(${PLATFORM_LINUX})
+ set(SYSTEM_CPP_MODULE "system_linux.cpp")
+else()
+ set(SYSTEM_CPP_MODULE "system_other.cpp")
+endif()
+
+add_executable(edit_test
+${SRC_DIR}/app/system.cpp
+${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
+${SRC_DIR}/common/event.cpp
+${SRC_DIR}/common/logger.cpp
+${SRC_DIR}/common/misc.cpp
+${SRC_DIR}/common/profile.cpp
+${SRC_DIR}/common/iman.cpp
+${SRC_DIR}/common/stringutils.cpp
+${SRC_DIR}/graphics/engine/text.cpp
+${SRC_DIR}/ui/button.cpp
+${SRC_DIR}/ui/control.cpp
+${SRC_DIR}/ui/edit.cpp
+${SRC_DIR}/ui/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/test/unit/ui/edit_test.cpp b/test/unit/ui/edit_test.cpp
index 2f31a89..428b66a 100644
--- a/test/unit/ui/edit_test.cpp
+++ b/test/unit/ui/edit_test.cpp
@@ -9,10 +9,16 @@
class CEditTest : public testing::Test
{
public:
- CEditTest(){};
+ CEditTest()
+ : m_robotMain(nullptr)
+ , m_engine(nullptr)
+ , m_edit(nullptr)
+ {}
virtual void SetUp()
{
+ m_robotMain = new CRobotMain(&m_app);
+
m_engine = new Gfx::CEngine(nullptr);
m_edit = new Ui::CEdit;
@@ -20,6 +26,8 @@ public:
virtual void TearDown()
{
+ delete m_robotMain;
+ m_robotMain = nullptr;
delete m_engine;
m_engine = nullptr;
delete m_edit;
@@ -33,6 +41,7 @@ public:
protected:
CApplication m_app;
+ CRobotMain* m_robotMain;
Gfx::CEngine * m_engine;
Ui::CEdit * m_edit;
CLogger m_logger;
@@ -46,7 +55,7 @@ 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));
+ EXPECT_CALL(*text, GetStringWidth(_, _, _, _)).WillOnce(Return(1.0f));
std::string filename = "test.file";
m_edit->SetMaxChar(Ui::EDITSTUDIOMAX);
m_edit->SetAutoIndent(true);
diff --git a/test/unit/ui/mocks/text_mock.h b/test/unit/ui/mocks/text_mock.h
index 9289481..f38b977 100644
--- a/test/unit/ui/mocks/text_mock.h
+++ b/test/unit/ui/mocks/text_mock.h
@@ -16,6 +16,9 @@ public:
};
MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float));
+ MOCK_METHOD4(GetStringWidth, float(const std::string &text,
+ std::vector<Gfx::FontMetaChar>::iterator format,
+ std::vector<Gfx::FontMetaChar>::iterator end, float size));
MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float));
};
diff --git a/test/unit/ui/stubs/app_stub.cpp b/test/unit/ui/stubs/app_stub.cpp
index c8e7bc6..9b33e5e 100644
--- a/test/unit/ui/stubs/app_stub.cpp
+++ b/test/unit/ui/stubs/app_stub.cpp
@@ -45,3 +45,8 @@ Event CApplication::CreateUpdateEvent()
{
return Event(EVENT_NULL);
}
+
+char CApplication::GetLanguageChar()
+{
+ return 'E';
+}
diff --git a/test/unit/ui/stubs/robotmain_stub.cpp b/test/unit/ui/stubs/robotmain_stub.cpp
index c332d5a..7988e9d 100644
--- a/test/unit/ui/stubs/robotmain_stub.cpp
+++ b/test/unit/ui/stubs/robotmain_stub.cpp
@@ -3,6 +3,14 @@
template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
+CRobotMain::CRobotMain(CApplication* app)
+{
+}
+
+CRobotMain::~CRobotMain()
+{
+}
+
bool CRobotMain::GetGlint()
{
return false;