summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-07-04 19:56:22 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-07-04 19:56:22 +0200
commitaf3057df7eb41973349b407539846f17d9094c21 (patch)
tree0940a188a0cfc43a99505f55513516866a57d145 /src
parentf95df35dc58e01b99ffddfc4ad394feaa4460b09 (diff)
downloadcolobot-af3057df7eb41973349b407539846f17d9094c21.tar.gz
colobot-af3057df7eb41973349b407539846f17d9094c21.tar.bz2
colobot-af3057df7eb41973349b407539846f17d9094c21.zip
Merged changes from dev
Resolved conflicts & added fixes.
Diffstat (limited to 'src')
-rw-r--r--src/CBot/CBotString.cpp2
-rw-r--r--src/CBot/CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/app/app.cpp66
-rw-r--r--src/app/app.h9
-rw-r--r--src/app/main.cpp17
-rw-r--r--src/common/logger.cpp136
-rw-r--r--src/common/logger.h111
-rw-r--r--src/common/profile.cpp12
-rw-r--r--src/common/profile.h12
-rw-r--r--src/common/singleton.h57
-rw-r--r--src/graphics/common/particle.h5
-rw-r--r--src/object/robotmain.cpp453
-rw-r--r--src/plugins/plugin.h33
-rw-r--r--src/script/ClassFILE.cpp425
-rw-r--r--src/sound/sound.cpp0
-rw-r--r--src/sound/sound.h483
-rw-r--r--src/ui/maindialog.cpp162
18 files changed, 1246 insertions, 741 deletions
diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp
index 2a1e3bd..53b0f27 100644
--- a/src/CBot/CBotString.cpp
+++ b/src/CBot/CBotString.cpp
@@ -21,7 +21,7 @@
#include <string.h>
-HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("Cbot.dll"); // comment le récupérer autrement ??
+HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // comment le récupérer autrement ??
CBotString::CBotString()
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 409ef3b..9933e9c 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -10,6 +10,7 @@ CBotToken.cpp
CBotTwoOpExpr.cpp
CBotVar.cpp
CBotWhile.cpp
+CBot.rc
)
add_library(CBot SHARED ${SOURCES})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a02e7b9..c72bcd9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,6 +31,7 @@ app/main.cpp
app/system.cpp
common/event.cpp
common/image.cpp
+common/logger.cpp
common/iman.cpp
# common/metafile.cpp
# common/misc.cpp
@@ -118,7 +119,7 @@ graphics/opengl/glengine.cpp
# script/cbottoken.cpp
# script/cmdtoken.cpp
# script/script.cpp
-sound/sound.cpp
+# sound/sound.cpp
# ui/button.cpp
# ui/check.cpp
# ui/color.cpp
diff --git a/src/app/app.cpp b/src/app/app.cpp
index b73adee..6a71f64 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -20,6 +20,7 @@
#include "app/app.h"
#include "app/system.h"
+#include "common/logger.h"
#include "common/iman.h"
#include "graphics/opengl/gldevice.h"
@@ -153,6 +154,7 @@ bool CApplication::Create()
{
SystemDialog(SDT_ERROR, "COLOBOT - Error", std::string("Error in CEngine::BeforeCreateInit() :\n") +
std::string(m_engine->GetError()) );
+ m_exitCode = 1;
return false;
}
@@ -173,6 +175,15 @@ bool CApplication::Create()
{
SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL initialization error:\n" +
std::string(SDL_GetError()) );
+ m_exitCode = 2;
+ return false;
+ }
+
+ if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0)
+ {
+ SystemDialog( SDT_ERROR, "COLOBOT - Error", std::string("SDL_Image initialization error:\n") +
+ std::string(IMG_GetError()) );
+ m_exitCode = 3;
return false;
}
@@ -181,6 +192,7 @@ bool CApplication::Create()
{
SystemDialog( SDT_ERROR, "COLOBOT - Error", "SDL error while getting video info:\n " +
std::string(SDL_GetError()) );
+ m_exitCode = 2;
return false;
}
@@ -219,13 +231,6 @@ bool CApplication::Create()
if (m_private->deviceConfig.hardwareAccel)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
- if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) == 0)
- {
- SystemDialog( SDT_ERROR, "COLOBOT - Error", std::string("SDL_Image initialization error:\n") +
- std::string(IMG_GetError()) );
- return false;
- }
-
m_private->surface = SDL_SetVideoMode(m_private->deviceConfig.width, m_private->deviceConfig.height,
m_private->deviceConfig.bpp, videoFlags);
@@ -233,6 +238,7 @@ bool CApplication::Create()
{
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("SDL error while setting video mode:\n") +
std::string(SDL_GetError()) );
+ m_exitCode = 2;
return false;
}
@@ -255,6 +261,7 @@ bool CApplication::Create()
{
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CDevice::Create() :\n") +
std::string(m_device->GetError()) );
+ m_exitCode = 1;
return false;
}
@@ -263,6 +270,7 @@ bool CApplication::Create()
{
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CEngine::Create() :\n") +
std::string(m_engine->GetError()) );
+ m_exitCode = 1;
return false;
}
@@ -270,6 +278,7 @@ bool CApplication::Create()
{
SystemDialog( SDT_ERROR, "COLOBT - Error", std::string("Error in CEngine::AfterDeviceSetInit() :\n") +
std::string(m_engine->GetError()) );
+ m_exitCode = 1;
return false;
}
@@ -478,6 +487,11 @@ end:
return m_exitCode;
}
+int CApplication::GetExitCode()
+{
+ return m_exitCode;
+}
+
//! Translates SDL press state to PressState
PressState TranslatePressState(unsigned char state)
{
@@ -499,7 +513,6 @@ Math::Point CApplication::WindowToInterfaceCoords(int x, int y)
1.0f - (float)y / (float)m_private->deviceConfig.height);
}
-
void CApplication::ParseEvent()
{
Event event;
@@ -567,6 +580,7 @@ void CApplication::ParseEvent()
void CApplication::ProcessEvent(Event event)
{
+ CLogger *l = GetLogger();
// Print the events in debug mode to test the code
if (m_debugMode)
{
@@ -574,34 +588,34 @@ void CApplication::ProcessEvent(Event event)
{
case EVENT_KEY_DOWN:
case EVENT_KEY_UP:
- printf("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
- printf(" key = %4x\n", event.key.key);
- printf(" state = %s\n", (event.key.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
- printf(" mod = %4x\n", event.key.mod);
- printf(" unicode = %4x\n", event.key.unicode);
+ l->Info("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
+ l->Info(" key = %4x\n", event.key.key);
+ l->Info(" state = %s\n", (event.key.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
+ l->Info(" mod = %4x\n", event.key.mod);
+ l->Info(" unicode = %4x\n", event.key.unicode);
break;
case EVENT_MOUSE_MOVE:
- printf("EVENT_MOUSE_MOVE:\n");
- printf(" state = %s\n", (event.mouseMove.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
- printf(" pos = (%f, %f)\n", event.mouseMove.pos.x, event.mouseMove.pos.y);
+ l->Info("EVENT_MOUSE_MOVE:\n");
+ l->Info(" state = %s\n", (event.mouseMove.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
+ l->Info(" pos = (%f, %f)\n", event.mouseMove.pos.x, event.mouseMove.pos.y);
break;
case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP:
- printf("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP");
- printf(" button = %d\n", event.mouseButton.button);
- printf(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
- printf(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y);
+ l->Info("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP");
+ l->Info(" button = %d\n", event.mouseButton.button);
+ l->Info(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
+ l->Info(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y);
break;
case EVENT_JOY_AXIS:
- printf("EVENT_JOY_AXIS:\n");
- printf(" axis = %d\n", event.joyAxis.axis);
- printf(" value = %d\n", event.joyAxis.value);
+ l->Info("EVENT_JOY_AXIS:\n");
+ l->Info(" axis = %d\n", event.joyAxis.axis);
+ l->Info(" value = %d\n", event.joyAxis.value);
break;
case EVENT_JOY_BUTTON_DOWN:
case EVENT_JOY_BUTTON_UP:
- printf("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP");
- printf(" button = %d\n", event.joyButton.button);
- printf(" state = %s\n", (event.joyButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
+ l->Info("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP");
+ l->Info(" button = %d\n", event.joyButton.button);
+ l->Info(" state = %s\n", (event.joyButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
break;
default:
break;
diff --git a/src/app/app.h b/src/app/app.h
index 098f0ad..ed2bd9a 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -84,10 +84,13 @@ public:
Error ParseArguments(int argc, char *argv[]);
//! Initializes the application
bool Create();
- //! Cleans up before exit
- void Destroy();
//! Main event loop
int Run();
+ //! Returns the code to be returned at main() exit
+ int GetExitCode();
+
+ //! Cleans up before exit
+ void Destroy();
//! Enters the pause mode
void Pause(bool pause);
@@ -96,7 +99,7 @@ public:
void StepSimulation(float rTime);
//! Polls the state of joystick axes and buttons
- void UpdateJoystick();
+ void UpdateJoystick();
void SetShowStat(bool show);
bool GetShowStat();
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 1e102d7..ece18d3 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -19,6 +19,7 @@
#include "app/app.h"
#include "app/system.h"
+#include "common/logger.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -26,6 +27,10 @@
//! Entry point to the program
int main(int argc, char *argv[])
{
+ CLogger logger; // Create the logger
+
+ logger.Info("Colobot starting\n");
+
CApplication app; // single instance of the application
Error err = app.ParseArguments(argc, argv);
@@ -34,11 +39,19 @@ int main(int argc, char *argv[])
SystemDialog(SDT_ERROR, "COLOBOT", "Invalid commandline arguments!\n");
}
+ int code = 0;
+
if (! app.Create())
{
app.Destroy(); // ensure a clean exit
- return 1;
+ code = app.GetExitCode();
+ logger.Info("Didn't run main loop. Exiting with code %d\n", code);
+ return code;
}
- return app.Run();
+ code = app.Run();
+
+ logger.Info("Exiting with code %d\n", code);
+ return code;
}
+
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
new file mode 100644
index 0000000..41d60eb
--- /dev/null
+++ b/src/common/logger.cpp
@@ -0,0 +1,136 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// logger.cpp
+
+#include <common/logger.h>
+
+#include <stdio.h>
+
+
+template<> CLogger* CSingleton<CLogger>::mInstance = 0;
+
+
+CLogger& CLogger::GetInstance()
+{
+ assert(mInstance);
+ return *mInstance;
+}
+
+
+CLogger* CLogger::GetInstancePointer()
+{
+ assert(mInstance);
+ return mInstance;
+}
+
+
+CLogger::CLogger()
+{
+ mFile = NULL;
+ mLogLevel = LOG_INFO;
+}
+
+
+CLogger::~CLogger()
+{
+ Close();
+}
+
+
+void CLogger::Log(LogType type, const char *str, va_list args)
+{
+ if (type < mLogLevel)
+ return;
+
+ switch (type) {
+ case LOG_WARN: fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); break;
+ case LOG_INFO: fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); break;
+ case LOG_ERROR: fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); break;
+ default: break;
+ }
+
+ vfprintf(IsOpened() ? mFile : stderr, str, args);
+}
+
+
+void CLogger::Info(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ Log(LOG_INFO, str, args);
+ va_end(args);
+}
+
+
+void CLogger::Warn(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ Log(LOG_WARN, str, args);
+ va_end(args);
+}
+
+
+void CLogger::Error(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ Log(LOG_ERROR, str, args);
+ va_end(args);
+}
+
+
+void CLogger::Message(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ Log(LOG_NONE, str, args);
+ va_end(args);
+}
+
+
+void CLogger::SetOutputFile(std::string filename)
+{
+ mFilename = filename;
+ Open();
+}
+
+
+void CLogger::Open()
+{
+ mFile = fopen(mFilename.c_str(), "w");
+ if (mFile == NULL)
+ fprintf(stderr, "Could not create file %s\n", mFilename.c_str());
+}
+
+
+void CLogger::Close()
+{
+ if (IsOpened())
+ fclose(mFile);
+}
+
+
+bool CLogger::IsOpened()
+{
+ return mFile != NULL;
+}
+
+
+void CLogger::SetLogLevel(LogType type) {
+ mLogLevel = type;
+}
diff --git a/src/common/logger.h b/src/common/logger.h
new file mode 100644
index 0000000..1b3829c
--- /dev/null
+++ b/src/common/logger.h
@@ -0,0 +1,111 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// logger.h
+
+
+#pragma once
+
+#include <string>
+#include <cstdarg>
+
+#include <common/singleton.h>
+
+/**
+ * @file common/logger.h
+ * @brief Class for loggin information to file or console
+ */
+
+
+/**
+ * \public
+ * \enum LogType common/logger.h
+ * \brief Enum representing log level
+**/
+enum LogType
+{
+ LOG_INFO = 1, /*!< lowest level, information */
+ LOG_WARN = 2, /*!< warning */
+ LOG_ERROR = 3, /*!< error */
+ LOG_NONE = 4 /*!< none level, used for custom messages */
+};
+
+
+/**
+* @class CLogger
+*
+* @brief Class for loggin information to file or console
+*
+*/
+class CLogger : public CSingleton<CLogger>
+{
+ public:
+ CLogger();
+ ~CLogger();
+
+ /** Write message to console or file
+ * @param const char str - message to write
+ * @param ... - additional arguments
+ */
+ void Message(const char *str, ...);
+
+ /** Write message to console or file with LOG_INFO level
+ * @param const char str - message to write
+ * @param ... - additional arguments
+ */
+ void Info(const char *str, ...);
+
+ /** Write message to console or file with LOG_WARN level
+ * @param const char str - message to write
+ * @param ... - additional arguments
+ */
+ void Warn(const char *str, ...);
+
+ /** Write message to console or file with LOG_ERROR level
+ * @param const char str - message to write
+ * @param ... - additional arguments
+ */
+ void Error(const char *str, ...);
+
+ /** Set output file to write logs to
+ * @param std::string filename - output file to write to
+ */
+ void SetOutputFile(std::string filename);
+
+ /** Set log level. Logs with level below will not be shown
+ * @param LogType level - minimum log level to write
+ */
+ void SetLogLevel(LogType level);
+
+ static CLogger& GetInstance();
+ static CLogger* GetInstancePointer();
+
+ private:
+ std::string mFilename;
+ FILE *mFile;
+ LogType mLogLevel;
+
+ void Open();
+ void Close();
+ bool IsOpened();
+ void Log(LogType type, const char* str, va_list args);
+};
+
+
+//! Global function to get Logger instance
+inline CLogger* GetLogger() {
+ return CLogger::GetInstancePointer();
+}
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 07dafae..d921d34 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -42,13 +42,13 @@ bool InitCurrentDirectory()
}
-bool SetProfileString(char* section, char* key, char* string)
+bool SetLocalProfileString(char* section, char* key, char* string)
{
WritePrivateProfileString(section, key, string, g_filename);
return true;
}
-bool GetProfileString(char* section, char* key, char* buffer, int max)
+bool GetLocalProfileString(char* section, char* key, char* buffer, int max)
{
int nb;
@@ -62,7 +62,7 @@ bool GetProfileString(char* section, char* key, char* buffer, int max)
}
-bool SetProfileInt(char* section, char* key, int value)
+bool SetLocalProfileInt(char* section, char* key, int value)
{
char s[20];
@@ -71,7 +71,7 @@ bool SetProfileInt(char* section, char* key, int value)
return true;
}
-bool GetProfileInt(char* section, char* key, int &value)
+bool GetLocalProfileInt(char* section, char* key, int &value)
{
char s[20];
int nb;
@@ -87,7 +87,7 @@ bool GetProfileInt(char* section, char* key, int &value)
}
-bool SetProfileFloat(char* section, char* key, float value)
+bool SetLocalProfileFloat(char* section, char* key, float value)
{
char s[20];
@@ -96,7 +96,7 @@ bool SetProfileFloat(char* section, char* key, float value)
return true;
}
-bool GetProfileFloat(char* section, char* key, float &value)
+bool GetLocalProfileFloat(char* section, char* key, float &value)
{
char s[20];
int nb;
diff --git a/src/common/profile.h b/src/common/profile.h
index 1a36050..2c76a0b 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -20,11 +20,11 @@
extern bool InitCurrentDirectory();
-extern bool SetProfileString(char* section, char* key, char* string);
-extern bool GetProfileString(char* section, char* key, char* buffer, int max);
-extern bool SetProfileInt(char* section, char* key, int value);
-extern bool GetProfileInt(char* section, char* key, int &value);
-extern bool SetProfileFloat(char* section, char* key, float value);
-extern bool GetProfileFloat(char* section, char* key, float &value);
+extern bool SetLocalProfileString(char* section, char* key, char* string);
+extern bool GetLocalProfileString(char* section, char* key, char* buffer, int max);
+extern bool SetLocalProfileInt(char* section, char* key, int value);
+extern bool GetLocalProfileInt(char* section, char* key, int &value);
+extern bool SetLocalProfileFloat(char* section, char* key, float value);
+extern bool GetLocalProfileFloat(char* section, char* key, float &value);
diff --git a/src/common/singleton.h b/src/common/singleton.h
new file mode 100644
index 0000000..dc09645
--- /dev/null
+++ b/src/common/singleton.h
@@ -0,0 +1,57 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// singleton.h
+
+
+#pragma once
+
+#include <cassert>
+
+
+template<typename T> class CSingleton
+{
+ protected:
+ static T* mInstance;
+
+ public:
+ static T& GetInstance() {
+ aserrt(mInstance);
+ return *mInstance;
+ }
+
+ static T& GetInstancePointer() {
+ aserrt(mInstance);
+ return mInstance;
+ }
+
+ static bool IsCreated() {
+ return mInstance != NULL;
+ }
+
+ CSingleton() {
+ assert(!mInstance);
+ mInstance = static_cast<T *>(this);
+ }
+
+ ~CSingleton() {
+ mInstance = NULL;
+ }
+
+ private:
+ CSingleton& operator=(const CSingleton<T> &);
+ CSingleton(const CSingleton<T> &);
+};
diff --git a/src/graphics/common/particle.h b/src/graphics/common/particle.h
index 62d001d..ec87648 100644
--- a/src/graphics/common/particle.h
+++ b/src/graphics/common/particle.h
@@ -26,6 +26,7 @@
class CInstanceManager;
class CRobotMain;
class CObject;
+class CSound;
@@ -303,7 +304,7 @@ protected:
void DrawParticleWheel(int i);
CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father);
CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father);
- void Play(Snd::Sound sound, Math::Vector pos, float amplitude);
+ void Play(Sound sound, Math::Vector pos, float amplitude);
bool TrackMove(int i, Math::Vector pos, float progress);
void TrackDraw(int i, ParticleType type);
@@ -314,7 +315,7 @@ protected:
CRobotMain* m_main;
CTerrain* m_terrain;
CWater* m_water;
- Snd::CSound* m_sound;
+ CSound* m_sound;
Gfx::Particle m_particule[MAXPARTICULE*MAXPARTITYPE];
Gfx::Triangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 1929f6d..fb68152 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -96,7 +96,414 @@ float g_unit; // conversion factor
-#include "script/ClassFILE.cpp"
+// Static variables
+
+static CBotClass* m_pClassFILE;
+static CBotProgram* m_pFuncFile;
+static int m_CompteurFileOpen = 0;
+static char* m_filesDir;
+
+
+
+// Prepares a file name.
+
+void PrepareFilename(CBotString &filename)
+{
+ int pos;
+
+ pos = filename.ReverseFind('\\');
+ if ( pos > 0 )
+ {
+ filename = filename.Mid(pos+1); // Remove files with
+ }
+
+ pos = filename.ReverseFind('/');
+ if ( pos > 0 )
+ {
+ filename = filename.Mid(pos+1); // also with /
+ }
+
+ pos = filename.ReverseFind(':');
+ if ( pos > 0 )
+ {
+ filename = filename.Mid(pos+1); // also removes the drive letter C:
+ }
+
+ filename = CBotString(m_filesDir) + CBotString("\\") + filename;
+}
+
+
+// constructor of the class
+// get the filename as a parameter
+
+// execution
+bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ CBotString mode;
+
+ // accepts no parameters
+ if ( pVar == NULL ) return true;
+
+ // must be a character string
+ if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
+
+ CBotString filename = pVar->GivValString();
+ PrepareFilename(filename);
+
+ // there may be a second parameter
+ pVar = pVar->GivNext();
+ if ( pVar != NULL )
+ {
+ // recover mode
+ mode = pVar->GivValString();
+ if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
+
+ // no third parameter
+ if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
+ }
+
+ // saves the file name
+ pVar = pThis->GivItem("filename");
+ pVar->SetValString(filename);
+
+ if ( ! mode.IsEmpty() )
+ {
+ // opens the requested file
+ FILE* pFile = fopen( filename, mode );
+ if ( pFile == NULL ) { Exception = CBotErrFileOpen; return false; }
+
+ m_CompteurFileOpen ++;
+
+ // save the channel file
+ pVar = pThis->GivItem("handle");
+ pVar->SetValInt((long)pFile);
+ }
+
+ return true;
+}
+
+// compilation
+CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
+{
+ // accepts no parameters
+ if ( pVar == NULL ) return CBotTypResult( 0 );
+
+ // must be a character string
+ if ( pVar->GivType() != CBotTypString )
+ return CBotTypResult( CBotErrBadString );
+
+ // there may be a second parameter
+ pVar = pVar->GivNext();
+ if ( pVar != NULL )
+ {
+ // which must be a string
+ if ( pVar->GivType() != CBotTypString )
+ return CBotTypResult( CBotErrBadString );
+ // no third parameter
+ if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
+ }
+
+ // the result is void (constructor)
+ return CBotTypResult( 0 );
+}
+
+
+// destructor of the class
+
+// execution
+bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ // retrieve the item "handle"
+ pVar = pThis->GivItem("handle");
+
+ // don't open? no problem :)
+ if ( pVar->GivInit() != IS_DEF) return true;
+
+ FILE* pFile= (FILE*)pVar->GivValInt();
+ fclose(pFile);
+ m_CompteurFileOpen --;
+
+ pVar->SetInit(IS_NAN);
+
+ return true;
+}
+
+
+// process FILE :: open
+// get the r/w mode as a parameter
+
+// execution
+bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ // there must be a parameter
+ if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
+
+ // which must be a character string
+ if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
+
+ // There may be a second parameter
+ if ( pVar->GivNext() != NULL )
+ {
+ // if the first parameter is the file name
+ CBotString filename = pVar->GivValString();
+ PrepareFilename(filename);
+
+ // saves the file name
+ CBotVar* pVar2 = pThis->GivItem("filename");
+ pVar2->SetValString(filename);
+
+ // next parameter is the mode
+ pVar = pVar -> GivNext();
+ }
+
+ CBotString mode = pVar->GivValString();
+ if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
+
+ // no third parameter
+ if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
+
+ // retrieve the item "handle"
+ pVar = pThis->GivItem("handle");
+
+ // which must not be initialized
+ if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
+
+ // file contains the name
+ pVar = pThis->GivItem("filename");
+ CBotString filename = pVar->GivValString();
+
+ PrepareFilename(filename); // if the name was h.filename attribute = "...";
+
+ // opens the requested file
+ FILE* pFile = fopen( filename, mode );
+ if ( pFile == NULL )
+ {
+ pResult->SetValInt(false);
+ return true;
+ }
+
+ m_CompteurFileOpen ++;
+
+ // Registered the channel file
+ pVar = pThis->GivItem("handle");
+ pVar->SetValInt((long)pFile);
+
+ pResult->SetValInt(true);
+ return true;
+}
+
+// compilation
+CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
+{
+ // there must be a parameter
+ if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
+
+ // which must be a string
+ if ( pVar->GivType() != CBotTypString )
+ return CBotTypResult( CBotErrBadString );
+
+ // there may be a second parameter
+ pVar = pVar->GivNext();
+ if ( pVar != NULL )
+ {
+ // which must be a string
+ if ( pVar->GivType() != CBotTypString )
+ return CBotTypResult( CBotErrBadString );
+
+ // no third parameter
+ if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
+ }
+
+ // the result is bool
+ return CBotTypResult(CBotTypBoolean);
+}
+
+
+// process FILE :: close
+
+// execeution
+bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ // it shouldn't be any parameters
+ if ( pVar != NULL ) return CBotErrOverParam;
+
+ // retrieve the item "handle"
+ pVar = pThis->GivItem("handle");
+
+ if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
+
+ FILE* pFile= (FILE*)pVar->GivValInt();
+ fclose(pFile);
+ m_CompteurFileOpen --;
+
+ pVar->SetInit(IS_NAN);
+
+ return true;
+}
+
+// compilation
+CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
+{
+ // it shouldn't be any parameters
+ if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
+
+ // function returns a result "void"
+ return CBotTypResult( 0 );
+}
+
+// process FILE :: writeln
+
+// execution
+bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ // there must be a parameter
+ if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
+
+ // which must be a character string
+ if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
+
+ CBotString param = pVar->GivValString();
+
+ // retrieve the item "handle"
+ pVar = pThis->GivItem("handle");
+
+ if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
+
+ FILE* pFile= (FILE*)pVar->GivValInt();
+
+ int res = fputs(param+CBotString("\n"), pFile);
+
+ // if an error occurs generate an exception
+ if ( res < 0 ) { Exception = CBotErrWrite; return false; }
+
+ return true;
+}
+
+// compilation
+CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
+{
+ // there must be a parameter
+ if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
+
+ // which must be a character string
+ if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
+
+ // no other parameter
+ if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
+
+ // the function returns a void result
+ return CBotTypResult( 0 );
+}
+
+// process FILE :: readln
+
+// execution
+bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ // it shouldn't be any parameters
+ if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
+
+ // retrieve the item "handle"
+ pVar = pThis->GivItem("handle");
+
+ if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
+
+ FILE* pFile= (FILE*)pVar->GivValInt();
+
+ char chaine[2000];
+ int i;
+ for ( i = 0 ; i < 2000 ; i++ ) chaine[i] = 0;
+
+ fgets(chaine, 1999, pFile);
+
+ for ( i = 0 ; i < 2000 ; i++ ) if (chaine[i] == '\n') chaine[i] = 0;
+
+ // if an error occurs generate an exception
+ if ( ferror(pFile) ) { Exception = CBotErrRead; return false; }
+
+ pResult->SetValString( chaine );
+
+ return true;
+}
+
+// compilation
+CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
+{
+ // it should not be any parameter
+ if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
+
+ // function returns a result "string"
+ return CBotTypResult( CBotTypString );
+}
+// process FILE :: readln
+
+
+// execution
+bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
+{
+ // it should not be any parameter
+ if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
+
+ // retrieve the item "handle"
+ pVar = pThis->GivItem("handle");
+
+ if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
+
+ FILE* pFile= (FILE*)pVar->GivValInt();
+
+ pResult->SetValInt( feof( pFile ) );
+
+ return true;
+}
+
+// compilation
+CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
+{
+ // it shouldn't be any parameter
+ if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
+
+ // the function returns a boolean result
+ return CBotTypResult( CBotTypBoolean );
+}
+
+
+
+
+
+void InitClassFILE()
+{
+// create a class for file management
+// the use is as follows:
+// file canal( "NomFichier.txt" )
+// canal.open( "r" ); // open for read
+// s = canal.readln( ); // reads a line
+// canal.close(); // close the file
+
+ // create the class FILE
+ m_pClassFILE = new CBotClass("file", NULL);
+ // adds the component ".filename"
+ m_pClassFILE->AddItem("filename", CBotTypString);
+ // adds the component ".handle"
+ m_pClassFILE->AddItem("handle", CBotTypInt, PR_PRIVATE);
+
+ // define a constructor and a destructor
+ m_pClassFILE->AddFunction("file", rfconstruct, cfconstruct );
+ m_pClassFILE->AddFunction("~file", rfdestruct, NULL );
+
+ // end of the methods associated
+ m_pClassFILE->AddFunction("open", rfopen, cfopen );
+ m_pClassFILE->AddFunction("close", rfclose, cfclose );
+ m_pClassFILE->AddFunction("writeln", rfwrite, cfwrite );
+ m_pClassFILE->AddFunction("readln", rfread, cfread );
+ m_pClassFILE->AddFunction("eof", rfeof, cfeof );
+
+ m_pFuncFile = new CBotProgram( );
+ CBotStringArray ListFonctions;
+ m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
+ m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
+}
+
+
@@ -283,22 +690,22 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_windowPos = Math::Point(0.15f, 0.17f);
m_windowDim = Math::Point(0.70f, 0.66f);
- if ( GetProfileFloat("Edit", "FontSize", fValue) ) m_fontSize = fValue;
- if ( GetProfileFloat("Edit", "WindowPos.x", fValue) ) m_windowPos.x = fValue;
- if ( GetProfileFloat("Edit", "WindowPos.y", fValue) ) m_windowPos.y = fValue;
- if ( GetProfileFloat("Edit", "WindowDim.x", fValue) ) m_windowDim.x = fValue;
- if ( GetProfileFloat("Edit", "WindowDim.y", fValue) ) m_windowDim.y = fValue;
+ if ( GetLocalProfileFloat("Edit", "FontSize", fValue) ) m_fontSize = fValue;
+ if ( GetLocalProfileFloat("Edit", "WindowPos.x", fValue) ) m_windowPos.x = fValue;
+ if ( GetLocalProfileFloat("Edit", "WindowPos.y", fValue) ) m_windowPos.y = fValue;
+ if ( GetLocalProfileFloat("Edit", "WindowDim.x", fValue) ) m_windowDim.x = fValue;
+ if ( GetLocalProfileFloat("Edit", "WindowDim.y", fValue) ) m_windowDim.y = fValue;
m_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle
m_IOPos.y = (1.0f-m_IODim.y)/2.0f;
- if ( GetProfileInt ("Edit", "IOPublic", iValue) ) m_IOPublic = iValue;
- if ( GetProfileFloat("Edit", "IOPos.x", fValue) ) m_IOPos.x = fValue;
- if ( GetProfileFloat("Edit", "IOPos.y", fValue) ) m_IOPos.y = fValue;
- if ( GetProfileFloat("Edit", "IODim.x", fValue) ) m_IODim.x = fValue;
- if ( GetProfileFloat("Edit", "IODim.y", fValue) ) m_IODim.y = fValue;
+ if ( GetLocalProfileInt ("Edit", "IOPublic", iValue) ) m_IOPublic = iValue;
+ if ( GetLocalProfileFloat("Edit", "IOPos.x", fValue) ) m_IOPos.x = fValue;
+ if ( GetLocalProfileFloat("Edit", "IOPos.y", fValue) ) m_IOPos.y = fValue;
+ if ( GetLocalProfileFloat("Edit", "IODim.x", fValue) ) m_IODim.x = fValue;
+ if ( GetLocalProfileFloat("Edit", "IODim.y", fValue) ) m_IODim.y = fValue;
m_short->FlushShortcuts();
InitEye();
@@ -315,7 +722,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
g_unit = 4.0f;
m_gamerName[0] = 0;
- GetProfileString("Gamer", "LastName", m_gamerName, 100);
+ GetLocalProfileString("Gamer", "LastName", m_gamerName, 100);
SetGlobalGamerName(m_gamerName);
ReadFreeParam();
m_dialog->SetupRecall();
@@ -430,7 +837,7 @@ void CRobotMain::CreateIni()
int iValue;
// colobot.ini don't exist?
- if ( !GetProfileInt("Setup", "TotoMode", iValue) )
+ if ( !GetLocalProfileInt("Setup", "TotoMode", iValue) )
{
m_dialog->SetupMemorize();
}
@@ -1801,7 +2208,7 @@ float CRobotMain::RetGameTime()
void CRobotMain::SetFontSize(float size)
{
m_fontSize = size;
- SetProfileFloat("Edit", "FontSize", m_fontSize);
+ SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
}
float CRobotMain::RetFontSize()
@@ -1814,8 +2221,8 @@ float CRobotMain::RetFontSize()
void CRobotMain::SetWindowPos(Math::Point pos)
{
m_windowPos = pos;
- SetProfileFloat("Edit", "WindowPos.x", m_windowPos.x);
- SetProfileFloat("Edit", "WindowPos.y", m_windowPos.y);
+ SetLocalProfileFloat("Edit", "WindowPos.x", m_windowPos.x);
+ SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y);
}
Math::Point CRobotMain::RetWindowPos()
@@ -1826,8 +2233,8 @@ Math::Point CRobotMain::RetWindowPos()
void CRobotMain::SetWindowDim(Math::Point dim)
{
m_windowDim = dim;
- SetProfileFloat("Edit", "WindowDim.x", m_windowDim.x);
- SetProfileFloat("Edit", "WindowDim.y", m_windowDim.y);
+ SetLocalProfileFloat("Edit", "WindowDim.x", m_windowDim.x);
+ SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y);
}
Math::Point CRobotMain::RetWindowDim()
@@ -1841,7 +2248,7 @@ Math::Point CRobotMain::RetWindowDim()
void CRobotMain::SetIOPublic(bool bMode)
{
m_IOPublic = bMode;
- SetProfileInt("Edit", "IOPublic", m_IOPublic);
+ SetLocalProfileInt("Edit", "IOPublic", m_IOPublic);
}
bool CRobotMain::RetIOPublic()
@@ -1852,8 +2259,8 @@ bool CRobotMain::RetIOPublic()
void CRobotMain::SetIOPos(Math::Point pos)
{
m_IOPos = pos;
- SetProfileFloat("Edit", "IOPos.x", m_IOPos.x);
- SetProfileFloat("Edit", "IOPos.y", m_IOPos.y);
+ SetLocalProfileFloat("Edit", "IOPos.x", m_IOPos.x);
+ SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y);
}
Math::Point CRobotMain::RetIOPos()
@@ -1864,8 +2271,8 @@ Math::Point CRobotMain::RetIOPos()
void CRobotMain::SetIODim(Math::Point dim)
{
m_IODim = dim;
- SetProfileFloat("Edit", "IODim.x", m_IODim.x);
- SetProfileFloat("Edit", "IODim.y", m_IODim.y);
+ SetLocalProfileFloat("Edit", "IODim.x", m_IODim.x);
+ SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y);
}
Math::Point CRobotMain::RetIODim()
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
new file mode 100644
index 0000000..f238122
--- /dev/null
+++ b/src/plugins/plugin.h
@@ -0,0 +1,33 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// plugin.h
+
+
+#pragma once
+
+
+#define PLUGIN_INTERFACE(class_type, interface_type) \
+ extern "C" interface_type* installPlugin() { return (interface_type *)new class_type(); } \
+ extern "C" void uninstallPlugin(class_type *_class) { delete _class; }
+
+
+class CPlugin {
+ public:
+ virtual char* PluginName() = 0;
+ virtual int PluginVersion() = 0;
+};
+
diff --git a/src/script/ClassFILE.cpp b/src/script/ClassFILE.cpp
deleted file mode 100644
index d5f2c6b..0000000
--- a/src/script/ClassFILE.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-
-
-// Static variables
-
-static CBotClass* m_pClassFILE;
-static CBotProgram* m_pFuncFile;
-static int m_CompteurFileOpen = 0;
-static char* m_filesDir;
-
-
-
-// Prepares a file name.
-
-void PrepareFilename(CBotString &filename)
-{
- int pos;
-
- pos = filename.ReverseFind('\\');
- if ( pos > 0 )
- {
- filename = filename.Mid(pos+1); // Remove files with
- }
-
- pos = filename.ReverseFind('/');
- if ( pos > 0 )
- {
- filename = filename.Mid(pos+1); // also with /
- }
-
- pos = filename.ReverseFind(':');
- if ( pos > 0 )
- {
- filename = filename.Mid(pos+1); // also removes the drive letter C:
- }
-
- filename = CBotString(m_filesDir) + CBotString("\\") + filename;
-}
-
-
-// constructor of the class
-// get the filename as a parameter
-
-// execution
-bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- CBotString mode;
-
- // accepts no parameters
- if ( pVar == NULL ) return true;
-
- // must be a character string
- if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
-
- CBotString filename = pVar->GivValString();
- PrepareFilename(filename);
-
- // there may be a second parameter
- pVar = pVar->GivNext();
- if ( pVar != NULL )
- {
- // recover mode
- mode = pVar->GivValString();
- if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
-
- // no third parameter
- if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
- }
-
- // saves the file name
- pVar = pThis->GivItem("filename");
- pVar->SetValString(filename);
-
- if ( ! mode.IsEmpty() )
- {
- // opens the requested file
- FILE* pFile = fopen( filename, mode );
- if ( pFile == NULL ) { Exception = CBotErrFileOpen; return false; }
-
- m_CompteurFileOpen ++;
-
- // save the channel file
- pVar = pThis->GivItem("handle");
- pVar->SetValInt((long)pFile);
- }
-
- return true;
-}
-
-// compilation
-CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
-{
- // accepts no parameters
- if ( pVar == NULL ) return CBotTypResult( 0 );
-
- // must be a character string
- if ( pVar->GivType() != CBotTypString )
- return CBotTypResult( CBotErrBadString );
-
- // there may be a second parameter
- pVar = pVar->GivNext();
- if ( pVar != NULL )
- {
- // which must be a string
- if ( pVar->GivType() != CBotTypString )
- return CBotTypResult( CBotErrBadString );
- // no third parameter
- if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
- }
-
- // the result is void (constructor)
- return CBotTypResult( 0 );
-}
-
-
-// destructor of the class
-
-// execution
-bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- // retrieve the item "handle"
- pVar = pThis->GivItem("handle");
-
- // don't open? no problem :)
- if ( pVar->GivInit() != IS_DEF) return true;
-
- FILE* pFile= (FILE*)pVar->GivValInt();
- fclose(pFile);
- m_CompteurFileOpen --;
-
- pVar->SetInit(IS_NAN);
-
- return true;
-}
-
-
-// process FILE :: open
-// get the r/w mode as a parameter
-
-// execution
-bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- // there must be a parameter
- if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
-
- // which must be a character string
- if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
-
- // There may be a second parameter
- if ( pVar->GivNext() != NULL )
- {
- // if the first parameter is the file name
- CBotString filename = pVar->GivValString();
- PrepareFilename(filename);
-
- // saves the file name
- CBotVar* pVar2 = pThis->GivItem("filename");
- pVar2->SetValString(filename);
-
- // next parameter is the mode
- pVar = pVar -> GivNext();
- }
-
- CBotString mode = pVar->GivValString();
- if ( mode != "r" && mode != "w" ) { Exception = CBotErrBadParam; return false; }
-
- // no third parameter
- if ( pVar->GivNext() != NULL ) { Exception = CBotErrOverParam; return false; }
-
- // retrieve the item "handle"
- pVar = pThis->GivItem("handle");
-
- // which must not be initialized
- if ( pVar->GivInit() == IS_DEF) { Exception = CBotErrFileOpen; return false; }
-
- // file contains the name
- pVar = pThis->GivItem("filename");
- CBotString filename = pVar->GivValString();
-
- PrepareFilename(filename); // if the name was h.filename attribute = "...";
-
- // opens the requested file
- FILE* pFile = fopen( filename, mode );
- if ( pFile == NULL )
- {
- pResult->SetValInt(false);
- return true;
- }
-
- m_CompteurFileOpen ++;
-
- // Registered the channel file
- pVar = pThis->GivItem("handle");
- pVar->SetValInt((long)pFile);
-
- pResult->SetValInt(true);
- return true;
-}
-
-// compilation
-CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
-{
- // there must be a parameter
- if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
-
- // which must be a string
- if ( pVar->GivType() != CBotTypString )
- return CBotTypResult( CBotErrBadString );
-
- // there may be a second parameter
- pVar = pVar->GivNext();
- if ( pVar != NULL )
- {
- // which must be a string
- if ( pVar->GivType() != CBotTypString )
- return CBotTypResult( CBotErrBadString );
-
- // no third parameter
- if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
- }
-
- // the result is bool
- return CBotTypResult(CBotTypBoolean);
-}
-
-
-// process FILE :: close
-
-// execeution
-bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- // it shouldn't be any parameters
- if ( pVar != NULL ) return CBotErrOverParam;
-
- // retrieve the item "handle"
- pVar = pThis->GivItem("handle");
-
- if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
-
- FILE* pFile= (FILE*)pVar->GivValInt();
- fclose(pFile);
- m_CompteurFileOpen --;
-
- pVar->SetInit(IS_NAN);
-
- return true;
-}
-
-// compilation
-CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
-{
- // it shouldn't be any parameters
- if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
-
- // function returns a result "void"
- return CBotTypResult( 0 );
-}
-
-// process FILE :: writeln
-
-// execution
-bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- // there must be a parameter
- if ( pVar == NULL ) { Exception = CBotErrLowParam; return false; }
-
- // which must be a character string
- if ( pVar->GivType() != CBotTypString ) { Exception = CBotErrBadString; return false; }
-
- CBotString param = pVar->GivValString();
-
- // retrieve the item "handle"
- pVar = pThis->GivItem("handle");
-
- if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
-
- FILE* pFile= (FILE*)pVar->GivValInt();
-
- int res = fputs(param+CBotString("\n"), pFile);
-
- // if an error occurs generate an exception
- if ( res < 0 ) { Exception = CBotErrWrite; return false; }
-
- return true;
-}
-
-// compilation
-CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
-{
- // there must be a parameter
- if ( pVar == NULL ) return CBotTypResult( CBotErrLowParam );
-
- // which must be a character string
- if ( pVar->GivType() != CBotTypString ) return CBotTypResult( CBotErrBadString );
-
- // no other parameter
- if ( pVar->GivNext() != NULL ) return CBotTypResult( CBotErrOverParam );
-
- // the function returns a void result
- return CBotTypResult( 0 );
-}
-
-// process FILE :: readln
-
-// execution
-bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- // it shouldn't be any parameters
- if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
-
- // retrieve the item "handle"
- pVar = pThis->GivItem("handle");
-
- if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
-
- FILE* pFile= (FILE*)pVar->GivValInt();
-
- char chaine[2000];
- int i;
- for ( i = 0 ; i < 2000 ; i++ ) chaine[i] = 0;
-
- fgets(chaine, 1999, pFile);
-
- for ( i = 0 ; i < 2000 ; i++ ) if (chaine[i] == '\n') chaine[i] = 0;
-
- // if an error occurs generate an exception
- if ( ferror(pFile) ) { Exception = CBotErrRead; return false; }
-
- pResult->SetValString( chaine );
-
- return true;
-}
-
-// compilation
-CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
-{
- // it should not be any parameter
- if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
-
- // function returns a result "string"
- return CBotTypResult( CBotTypString );
-}
-// process FILE :: readln
-
-
-// execution
-bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
-{
- // it should not be any parameter
- if ( pVar != NULL ) { Exception = CBotErrOverParam; return false; }
-
- // retrieve the item "handle"
- pVar = pThis->GivItem("handle");
-
- if ( pVar->GivInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
-
- FILE* pFile= (FILE*)pVar->GivValInt();
-
- pResult->SetValInt( feof( pFile ) );
-
- return true;
-}
-
-// compilation
-CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar)
-{
- // it shouldn't be any parameter
- if ( pVar != NULL ) return CBotTypResult( CBotErrOverParam );
-
- // the function returns a boolean result
- return CBotTypResult( CBotTypBoolean );
-}
-
-
-
-
-
-void InitClassFILE()
-{
-// create a class for file management
-// the use is as follows:
-// file canal( "NomFichier.txt" )
-// canal.open( "r" ); // open for read
-// s = canal.readln( ); // reads a line
-// canal.close(); // close the file
-
- // create the class FILE
- m_pClassFILE = new CBotClass("file", NULL);
- // adds the component ".filename"
- m_pClassFILE->AddItem("filename", CBotTypString);
- // adds the component ".handle"
- m_pClassFILE->AddItem("handle", CBotTypInt, PR_PRIVATE);
-
- // define a constructor and a destructor
- m_pClassFILE->AddFunction("file", rfconstruct, cfconstruct );
- m_pClassFILE->AddFunction("~file", rfdestruct, NULL );
-
- // end of the methods associated
- m_pClassFILE->AddFunction("open", rfopen, cfopen );
- m_pClassFILE->AddFunction("close", rfclose, cfclose );
- m_pClassFILE->AddFunction("writeln", rfwrite, cfwrite );
- m_pClassFILE->AddFunction("readln", rfread, cfread );
- m_pClassFILE->AddFunction("eof", rfeof, cfeof );
-
- m_pFuncFile = new CBotProgram( );
- CBotStringArray ListFonctions;
- m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
- m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
-}
-
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/sound/sound.cpp
+++ /dev/null
diff --git a/src/sound/sound.h b/src/sound/sound.h
index a2bfc76..598ffe3 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -1,165 +1,318 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-// sound.h
-
-#pragma once
-
-
-#include "math/vector.h"
-
-
-class CInstanceManager;
-
-namespace Snd {
-
-const int MAXFILES = 200;
-const int MAXSOUND = 32;
-const int MAXVOLUME = 20;
-const int MAXOPER = 4;
-
-
-enum Sound
-{
- SOUND_CLICK = 0,
- SOUND_BOUM = 1,
- SOUND_EXPLO = 2,
- SOUND_FLYh = 3, // human
- SOUND_FLY = 4,
- SOUND_STEPs = 5, // smooth
- SOUND_MOTORw = 6, // wheel
- SOUND_MOTORt = 7, // tank
- SOUND_MOTORr = 8, // roller
- SOUND_ERROR = 9,
- SOUND_CONVERT = 10,
- SOUND_ENERGY = 11,
- SOUND_PLOUF = 12,
- SOUND_BLUP = 13,
- SOUND_WARNING = 14,
- SOUND_DERRICK = 15,
- SOUND_LABO = 16,
- SOUND_STATION = 17,
- SOUND_REPAIR = 18,
- SOUND_RESEARCH = 19,
- SOUND_INSECTs = 20, // spider
- SOUND_BURN = 21,
- SOUND_TZOING = 22,
- SOUND_GGG = 23,
- SOUND_MANIP = 24,
- SOUND_FIRE = 25, // shooting with fireball
- SOUND_HUMAN1 = 26, // breathing
- SOUND_STEPw = 27, // water
- SOUND_SWIM = 28,
- SOUND_RADAR = 29,
- SOUND_BUILD = 30,
- SOUND_ALARM = 31, // energy alarm
- SOUND_SLIDE = 32,
- SOUND_EXPLOi = 33, // insect
- SOUND_INSECTa = 34, // ant
- SOUND_INSECTb = 35, // bee
- SOUND_INSECTw = 36, // worm
- SOUND_INSECTm = 37, // mother
- SOUND_TREMBLE = 38,
- SOUND_PSHHH = 39,
- SOUND_NUCLEAR = 40,
- SOUND_INFO = 41,
- SOUND_OPEN = 42,
- SOUND_CLOSE = 43,
- SOUND_FACTORY = 44,
- SOUND_EGG = 45,
- SOUND_MOTORs = 46, // submarine
- SOUND_MOTORi = 47, // insect (legs)
- SOUND_SHIELD = 48,
- SOUND_FIREi = 49, // shooting with orgaball (insect)
- SOUND_GUNDEL = 50,
- SOUND_PSHHH2 = 51, // shield
- SOUND_MESSAGE = 52,
- SOUND_BOUMm = 53, // metal
- SOUND_BOUMv = 54, // plant
- SOUND_BOUMs = 55, // smooth
- SOUND_EXPLOl = 56, // little
- SOUND_EXPLOlp = 57, // little power
- SOUND_EXPLOp = 58, // power
- SOUND_STEPh = 59, // hard
- SOUND_STEPm = 60, // metal
- SOUND_POWERON = 61,
- SOUND_POWEROFF = 62,
- SOUND_AIE = 63,
- SOUND_WAYPOINT = 64,
- SOUND_RECOVER = 65,
- SOUND_DEADi = 66,
- SOUND_JOSTLE = 67,
- SOUND_GFLAT = 68,
- SOUND_DEADg = 69, // shooting death
- SOUND_DEADw = 70, // drowning
- SOUND_FLYf = 71, // reactor fail
- SOUND_ALARMt = 72, // temperature alarm
- SOUND_FINDING = 73, // finds a cache object
- SOUND_THUMP = 74,
- SOUND_TOUCH = 75,
- SOUND_BLITZ = 76,
- SOUND_MUSHROOM = 77,
- SOUND_FIREp = 78, // shooting with phazer
- SOUND_EXPLOg1 = 79, // impact gun 1
- SOUND_EXPLOg2 = 80, // impact gun 2
- SOUND_MOTORd = 81, // engine friction
-};
-
-enum SoundNext
-{
- SOPER_CONTINUE = 1,
- SOPER_STOP = 2,
- SOPER_LOOP = 3,
-};
-
-struct SoundOper
-{
- char bUsed;
- float finalAmplitude;
- float finalFrequency;
- float totalTime;
- float currentTime;
- Snd::SoundNext nextOper;
-};
-
-struct SoundChannel
-{
- char bUsed; // buffer used?
- char bMute; // silence?
- Snd::Sound type; // SOUND_*
- int priority; // so great -> important
- Math::Vector pos; // position in space
- unsigned short uniqueStamp; // unique marker
-// LPDIRECTSOUNDBUFFER soundBuffer;
-// LPDIRECTSOUND3DBUFFER soundBuffer3D;
- float startAmplitude;
- float startFrequency;
- float changeFrequency;
- int initFrequency;
- float volume; // 2D: volume 1..0 depending on position
- float pan; // 2D: pan -1..+1 depending on position
- Snd::SoundOper oper[MAXOPER];
-};
-
-
-
-class CSound
-{
- // TODO
-};
-
-}; // namespace Sound
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// soundinterface.h
+
+/**
+ * @file sound/soundinterface.h
+ * @brief Sound plugin interface
+ */
+
+#pragma once
+
+#include <math/vector.h>
+
+#include <plugins/plugin.h>
+
+/*!
+ * Maximum possible audio volume
+ */
+#define MAXVOLUME 100
+
+
+/**
+ * \public
+ * \enum Sound sound/soundinterface.h
+ * \brief Sound enum representing sound file
+**/
+enum Sound
+{
+ SOUND_CLICK = 0,
+ SOUND_BOUM = 1,
+ SOUND_EXPLO = 2,
+ SOUND_FLYh = 3, /*!< human */
+ SOUND_FLY = 4,
+ SOUND_STEPs = 5, /*!< smooth */
+ SOUND_MOTORw = 6, /*!< wheel */
+ SOUND_MOTORt = 7, /*!< tank */
+ SOUND_MOTORr = 8, /*!< roller */
+ SOUND_ERROR = 9,
+ SOUND_CONVERT = 10,
+ SOUND_ENERGY = 11,
+ SOUND_PLOUF = 12,
+ SOUND_BLUP = 13,
+ SOUND_WARNING = 14,
+ SOUND_DERRICK = 15,
+ SOUND_LABO = 16,
+ SOUND_STATION = 17,
+ SOUND_REPAIR = 18,
+ SOUND_RESEARCH = 19,
+ SOUND_INSECTs = 20, /*!< spider */
+ SOUND_BURN = 21,
+ SOUND_TZOING = 22,
+ SOUND_GGG = 23,
+ SOUND_MANIP = 24,
+ SOUND_FIRE = 25, /*!< shooting with fireball */
+ SOUND_HUMAN1 = 26, /*!< breathing */
+ SOUND_STEPw = 27, /*!< water */
+ SOUND_SWIM = 28,
+ SOUND_RADAR = 29,
+ SOUND_BUILD = 30,
+ SOUND_ALARM = 31, /*!< energy alarm */
+ SOUND_SLIDE = 32,
+ SOUND_EXPLOi = 33, /*!< insect */
+ SOUND_INSECTa = 34, /*!< ant */
+ SOUND_INSECTb = 35, /*!< bee */
+ SOUND_INSECTw = 36, /*!< worm */
+ SOUND_INSECTm = 37, /*!< mother */
+ SOUND_TREMBLE = 38,
+ SOUND_PSHHH = 39,
+ SOUND_NUCLEAR = 40,
+ SOUND_INFO = 41,
+ SOUND_OPEN = 42,
+ SOUND_CLOSE = 43,
+ SOUND_FACTORY = 44,
+ SOUND_EGG = 45,
+ SOUND_MOTORs = 46, /*!< submarine */
+ SOUND_MOTORi = 47, /*!< insect (legs) */
+ SOUND_SHIELD = 48,
+ SOUND_FIREi = 49, /*!< shooting with orgaball (insect) */
+ SOUND_GUNDEL = 50,
+ SOUND_PSHHH2 = 51, /*!< shield */
+ SOUND_MESSAGE = 52,
+ SOUND_BOUMm = 53, /*!< metal */
+ SOUND_BOUMv = 54, /*!< plant */
+ SOUND_BOUMs = 55, /*!< smooth */
+ SOUND_EXPLOl = 56, /*!< little */
+ SOUND_EXPLOlp = 57, /*!< little power */
+ SOUND_EXPLOp = 58, /*!< power */
+ SOUND_STEPh = 59, /*!< hard */
+ SOUND_STEPm = 60, /*!< metal */
+ SOUND_POWERON = 61,
+ SOUND_POWEROFF = 62,
+ SOUND_AIE = 63,
+ SOUND_WAYPOINT = 64,
+ SOUND_RECOVER = 65,
+ SOUND_DEADi = 66,
+ SOUND_JOSTLE = 67,
+ SOUND_GFLAT = 68,
+ SOUND_DEADg = 69, /*!< shooting death */
+ SOUND_DEADw = 70, /*!< drowning */
+ SOUND_FLYf = 71, /*!< reactor fail */
+ SOUND_ALARMt = 72, /*!< temperature alarm */
+ SOUND_FINDING = 73, /*!< finds a cache object */
+ SOUND_THUMP = 74,
+ SOUND_TOUCH = 75,
+ SOUND_BLITZ = 76,
+ SOUND_MUSHROOM = 77,
+ SOUND_FIREp = 78, /*!< shooting with phazer */
+ SOUND_EXPLOg1 = 79, /*!< impact gun 1 */
+ SOUND_EXPLOg2 = 80, /*!< impact gun 2 */
+ SOUND_MOTORd = 81, /*!< engine friction */
+};
+
+
+/**
+ * \public
+ * \enum SoundNext sound/soundinterface.h
+ * \brief Enum representing operation that will be performend on a sound at given time
+**/
+enum SoundNext
+{
+ SOPER_CONTINUE = 1, /*!< continue playing */
+ SOPER_STOP = 2, /*!< stop playing */
+ SOPER_LOOP = 3, /*!< start over */
+};
+
+
+/**
+* @class CSoundInterface
+*
+* @brief Sound plugin interface
+*
+*/
+class CSoundInterface : public CPlugin
+{
+ public:
+ CSoundInterface() {
+ //CInstanceManager::getInstance().AddInstance(CLASS_SOUND, this);
+ //m_iMan->AddInstance(CLASS_SOUND, this);
+ };
+ virtual ~CSoundInterface() = 0;
+
+ /** Function to initialize sound device
+ * @param bool b3D - enable support for 3D sound
+ */
+ virtual bool Create(bool b3D) = 0;
+
+ /** Function called to cache all sound effect files.
+ * Function calls \link CSoundInterface::Cache() \endlink for each file
+ */
+ virtual void CacheAll() = 0;
+
+ /** Function called to cache sound effect file.
+ * This function is called by plugin interface for each file.
+ * @param Sound bSound - id of a file, will be used to identify sound files
+ * @param std::string bFile - file to load
+ * @return return true on success
+ */
+ virtual bool Cache(Sound bSound, std::string bFile) = 0;
+
+ /** Return if plugin is enabled
+ * @return return true if plugin is enabled
+ */
+ virtual bool RetEnable() = 0;
+
+ /** Change sound mode to 2D/3D
+ * @param bool bMode - true to enable 3D sound
+ */
+ virtual void SetSound3D(bool bMode) = 0;
+
+ /** Return if we use 3D sound
+ * @return true if we have 3D sound enabled
+ */
+ virtual bool RetSound3D() = 0;
+
+ /** Return if we have 3D sound capable card
+ * @return true for 3D sound support
+ */
+ virtual bool RetSound3DCap() = 0;
+
+ /** Change global sound volume
+ * @param int volume - range from 0 to MAXVOLUME
+ */
+ virtual void SetAudioVolume(int volume) = 0;
+
+ /** Return global sound volume
+ * @return global volume as int in range from 0 to MAXVOLUME
+ */
+ virtual int RetAudioVolume() = 0;
+
+ /** Set music volume
+ * @param int volume - range from 0 to MAXVOLUME
+ */
+ virtual void SetMusicVolume(int volume) = 0;
+
+ /** Return music volume
+ * @return music volume as int in range from 0 to MAXVOLUME
+ */
+ virtual int RetMusicVolume() = 0;
+
+ /** Set listener position
+ * @param Math::Vector eye - position of listener
+ * @param Math::Vector lookat - direction listener is looking at
+ */
+ virtual void SetListener(Math::Vector eye, Math::Vector lookat) = 0;
+
+ /** Update data each frame
+ * @param float rTime - time since last update
+ */
+ virtual void FrameMove(float rTime) = 0;
+
+ /** Play specific sound
+ * @param Sound sound - sound to play
+ * @param float amplitude - change amplitude of sound before playing
+ * @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
+ * @param bool bLoop - loop sound
+ * @return identifier of channel that sound will be played on
+ */
+ virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
+
+ /** Play specific sound
+ * @param Sound sound - sound to play
+ * @param Math:Vector pos - position of sound in space
+ * @param float amplitude - change amplitude of sound before playing
+ * @param float frequency - change sound frequency before playing (0.5 octave down, 2.0 octave up)
+ * @param bool bLoop - loop sound
+ * @return identifier of channel that sound will be played on
+ */
+ virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
+
+ /** Remove all operations that would be made on sound in channel.
+ * @param int channel - channel to work on
+ * @return return true on success
+ */
+ virtual bool FlushEnvelope(int channel) = 0;
+
+ /** Add envelope to sound. Envelope is a operatino that will be performend on sound in future like changing frequency
+ * @param int channel - channel to work on
+ * @param float amplitude - change amplitude
+ * @param float frequency - change frequency
+ * @param float time - when to change (sample time)
+ * @param SoundNext oper - operation to perform
+ * @return return true on success
+ */
+ virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) = 0;
+
+ /** Set sound position in space
+ * @param int channel - channel to work on
+ * @param Math::Vector pos - new positino of a sound
+ * @return return true on success
+ */
+ virtual bool Position(int channel, Math::Vector pos) = 0;
+
+ /** Set sound frequency
+ * @param int channel - channel to work on
+ * @param float frequency - change sound frequency
+ * @return return true on success
+ */
+ virtual bool Frequency(int channel, float frequency) = 0;
+
+ /** Stop playing sound
+ * @param int channel - channel to work on
+ * @return return true on success
+ */
+ virtual bool Stop(int channel) = 0;
+
+ /** Stop playing all sounds
+ * @return return true on success
+ */
+ virtual bool StopAll() = 0;
+
+ /** Mute/unmute all sounds
+ * @param bool bMute
+ * @return return true on success
+ */
+ virtual bool MuteAll(bool bMute) = 0;
+
+ /** Start playing music
+ * @param int rank - track number
+ * @param bool bRepeat - repeat playing
+ * @return return true on success
+ */
+ virtual bool PlayMusic(int rank, bool bRepeat) = 0;
+
+ /** Restart music
+ * @return return true on success
+ */
+ virtual bool RestartMusic() = 0;
+
+ /** Susspend paying music
+ * @return return true on success
+ */
+ virtual void SuspendMusic() = 0;
+
+ /** Stop playing music
+ * @return return true on success
+ */
+ virtual void StopMusic() = 0;
+
+ /** Check if music if playing
+ * @return return true if music is playing
+ */
+ virtual bool IsPlayingMusic() = 0;
+};
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 5d96043..c8759e0 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -3884,7 +3884,7 @@ void CMainDialog::NameSelect()
RetGamerFace(m_main->RetGamerName());
- SetProfileString("Gamer", "LastName", m_main->RetGamerName());
+ SetLocalProfileString("Gamer", "LastName", m_main->RetGamerName());
}
// Creates a new player.
@@ -5522,104 +5522,104 @@ void CMainDialog::SetupMemorize()
char key[500];
char num[10];
- SetProfileString("Directory", "scene", m_sceneDir);
- SetProfileString("Directory", "savegame", m_savegameDir);
- SetProfileString("Directory", "public", m_publicDir);
- SetProfileString("Directory", "user", m_userDir);
- SetProfileString("Directory", "files", m_filesDir);
+ SetLocalProfileString("Directory", "scene", m_sceneDir);
+ SetLocalProfileString("Directory", "savegame", m_savegameDir);
+ SetLocalProfileString("Directory", "public", m_publicDir);
+ SetLocalProfileString("Directory", "user", m_userDir);
+ SetLocalProfileString("Directory", "files", m_filesDir);
iValue = m_engine->RetTotoMode();
- SetProfileInt("Setup", "TotoMode", iValue);
+ SetLocalProfileInt("Setup", "TotoMode", iValue);
iValue = m_bTooltip;
- SetProfileInt("Setup", "Tooltips", iValue);
+ SetLocalProfileInt("Setup", "Tooltips", iValue);
iValue = m_bGlint;
- SetProfileInt("Setup", "InterfaceGlint", iValue);
+ SetLocalProfileInt("Setup", "InterfaceGlint", iValue);
iValue = m_bRain;
- SetProfileInt("Setup", "InterfaceGlint", iValue);
+ SetLocalProfileInt("Setup", "InterfaceGlint", iValue);
iValue = m_engine->RetNiceMouse();
- SetProfileInt("Setup", "NiceMouse", iValue);
+ SetLocalProfileInt("Setup", "NiceMouse", iValue);
iValue = m_bSoluce4;
- SetProfileInt("Setup", "Soluce4", iValue);
+ SetLocalProfileInt("Setup", "Soluce4", iValue);
iValue = m_bMovies;
- SetProfileInt("Setup", "Movies", iValue);
+ SetLocalProfileInt("Setup", "Movies", iValue);
iValue = m_bNiceReset;
- SetProfileInt("Setup", "NiceReset", iValue);
+ SetLocalProfileInt("Setup", "NiceReset", iValue);
iValue = m_bHimselfDamage;
- SetProfileInt("Setup", "HimselfDamage", iValue);
+ SetLocalProfileInt("Setup", "HimselfDamage", iValue);
iValue = m_bCameraScroll;
- SetProfileInt("Setup", "CameraScroll", iValue);
+ SetLocalProfileInt("Setup", "CameraScroll", iValue);
iValue = m_bCameraInvertX;
- SetProfileInt("Setup", "CameraInvertX", iValue);
+ SetLocalProfileInt("Setup", "CameraInvertX", iValue);
iValue = m_bEffect;
- SetProfileInt("Setup", "InterfaceEffect", iValue);
+ SetLocalProfileInt("Setup", "InterfaceEffect", iValue);
iValue = m_engine->RetShadow();
- SetProfileInt("Setup", "GroundShadow", iValue);
+ SetLocalProfileInt("Setup", "GroundShadow", iValue);
iValue = m_engine->RetGroundSpot();
- SetProfileInt("Setup", "GroundSpot", iValue);
+ SetLocalProfileInt("Setup", "GroundSpot", iValue);
iValue = m_engine->RetDirty();
- SetProfileInt("Setup", "ObjectDirty", iValue);
+ SetLocalProfileInt("Setup", "ObjectDirty", iValue);
iValue = m_engine->RetFog();
- SetProfileInt("Setup", "FogMode", iValue);
+ SetLocalProfileInt("Setup", "FogMode", iValue);
iValue = m_engine->RetLensMode();
- SetProfileInt("Setup", "LensMode", iValue);
+ SetLocalProfileInt("Setup", "LensMode", iValue);
iValue = m_engine->RetSkyMode();
- SetProfileInt("Setup", "SkyMode", iValue);
+ SetLocalProfileInt("Setup", "SkyMode", iValue);
iValue = m_engine->RetPlanetMode();
- SetProfileInt("Setup", "PlanetMode", iValue);
+ SetLocalProfileInt("Setup", "PlanetMode", iValue);
iValue = m_engine->RetLightMode();
- SetProfileInt("Setup", "LightMode", iValue);
+ SetLocalProfileInt("Setup", "LightMode", iValue);
iValue = m_engine->RetJoystick();
- SetProfileInt("Setup", "UseJoystick", iValue);
+ SetLocalProfileInt("Setup", "UseJoystick", iValue);
fValue = m_engine->RetParticuleDensity();
- SetProfileFloat("Setup", "ParticuleDensity", fValue);
+ SetLocalProfileFloat("Setup", "ParticuleDensity", fValue);
fValue = m_engine->RetClippingDistance();
- SetProfileFloat("Setup", "ClippingDistance", fValue);
+ SetLocalProfileFloat("Setup", "ClippingDistance", fValue);
fValue = m_engine->RetObjectDetail();
- SetProfileFloat("Setup", "ObjectDetail", fValue);
+ SetLocalProfileFloat("Setup", "ObjectDetail", fValue);
fValue = m_engine->RetGadgetQuantity();
- SetProfileFloat("Setup", "GadgetQuantity", fValue);
+ SetLocalProfileFloat("Setup", "GadgetQuantity", fValue);
iValue = m_engine->RetTextureQuality();
- SetProfileInt("Setup", "TextureQuality", iValue);
+ SetLocalProfileInt("Setup", "TextureQuality", iValue);
iValue = m_sound->RetAudioVolume();
- SetProfileInt("Setup", "AudioVolume", iValue);
+ SetLocalProfileInt("Setup", "AudioVolume", iValue);
iValue = m_sound->RetMidiVolume();
- SetProfileInt("Setup", "MidiVolume", iValue);
+ SetLocalProfileInt("Setup", "MidiVolume", iValue);
iValue = m_sound->RetSound3D();
- SetProfileInt("Setup", "Sound3D", iValue);
+ SetLocalProfileInt("Setup", "Sound3D", iValue);
iValue = m_engine->RetEditIndentMode();
- SetProfileInt("Setup", "EditIndentMode", iValue);
+ SetLocalProfileInt("Setup", "EditIndentMode", iValue);
iValue = m_engine->RetEditIndentValue();
- SetProfileInt("Setup", "EditIndentValue", iValue);
+ SetLocalProfileInt("Setup", "EditIndentValue", iValue);
key[0] = 0;
for ( i=0 ; i<100 ; i++ )
@@ -5633,21 +5633,21 @@ void CMainDialog::SetupMemorize()
strcat(key, num);
}
}
- SetProfileString("Setup", "KeyMap", key);
+ SetLocalProfileString("Setup", "KeyMap", key);
#if _NET
if ( m_accessEnable )
{
iValue = m_accessMission;
- SetProfileInt("Setup", "AccessMission", iValue);
+ SetLocalProfileInt("Setup", "AccessMission", iValue);
iValue = m_accessUser;
- SetProfileInt("Setup", "AccessUser", iValue);
+ SetLocalProfileInt("Setup", "AccessUser", iValue);
}
#endif
iValue = m_bDeleteGamer;
- SetProfileInt("Setup", "DeleteGamer", iValue);
+ SetLocalProfileInt("Setup", "DeleteGamer", iValue);
m_engine->WriteProfile();
}
@@ -5661,192 +5661,192 @@ void CMainDialog::SetupRecall()
char key[500];
char* p;
- if ( GetProfileString("Directory", "scene", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "scene", key, _MAX_FNAME) )
{
strcpy(m_sceneDir, key);
}
- if ( GetProfileString("Directory", "savegame", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "savegame", key, _MAX_FNAME) )
{
strcpy(m_savegameDir, key);
}
- if ( GetProfileString("Directory", "public", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "public", key, _MAX_FNAME) )
{
strcpy(m_publicDir, key);
}
- if ( GetProfileString("Directory", "user", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "user", key, _MAX_FNAME) )
{
strcpy(m_userDir, key);
}
- if ( GetProfileString("Directory", "files", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "files", key, _MAX_FNAME) )
{
strcpy(m_filesDir, key);
}
- if ( GetProfileInt("Setup", "TotoMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "TotoMode", iValue) )
{
m_engine->SetTotoMode(iValue);
}
- if ( GetProfileInt("Setup", "Tooltips", iValue) )
+ if ( GetLocalProfileInt("Setup", "Tooltips", iValue) )
{
m_bTooltip = iValue;
}
- if ( GetProfileInt("Setup", "InterfaceGlint", iValue) )
+ if ( GetLocalProfileInt("Setup", "InterfaceGlint", iValue) )
{
m_bGlint = iValue;
}
- if ( GetProfileInt("Setup", "InterfaceGlint", iValue) )
+ if ( GetLocalProfileInt("Setup", "InterfaceGlint", iValue) )
{
m_bRain = iValue;
}
- if ( GetProfileInt("Setup", "NiceMouse", iValue) )
+ if ( GetLocalProfileInt("Setup", "NiceMouse", iValue) )
{
m_engine->SetNiceMouse(iValue);
}
- if ( GetProfileInt("Setup", "Soluce4", iValue) )
+ if ( GetLocalProfileInt("Setup", "Soluce4", iValue) )
{
m_bSoluce4 = iValue;
}
- if ( GetProfileInt("Setup", "Movies", iValue) )
+ if ( GetLocalProfileInt("Setup", "Movies", iValue) )
{
m_bMovies = iValue;
}
- if ( GetProfileInt("Setup", "NiceReset", iValue) )
+ if ( GetLocalProfileInt("Setup", "NiceReset", iValue) )
{
m_bNiceReset = iValue;
}
- if ( GetProfileInt("Setup", "HimselfDamage", iValue) )
+ if ( GetLocalProfileInt("Setup", "HimselfDamage", iValue) )
{
m_bHimselfDamage = iValue;
}
- if ( GetProfileInt("Setup", "CameraScroll", iValue) )
+ if ( GetLocalProfileInt("Setup", "CameraScroll", iValue) )
{
m_bCameraScroll = iValue;
m_camera->SetCameraScroll(m_bCameraScroll);
}
- if ( GetProfileInt("Setup", "CameraInvertX", iValue) )
+ if ( GetLocalProfileInt("Setup", "CameraInvertX", iValue) )
{
m_bCameraInvertX = iValue;
m_camera->SetCameraInvertX(m_bCameraInvertX);
}
- if ( GetProfileInt("Setup", "CameraInvertY", iValue) )
+ if ( GetLocalProfileInt("Setup", "CameraInvertY", iValue) )
{
m_bCameraInvertY = iValue;
m_camera->SetCameraInvertY(m_bCameraInvertY);
}
- if ( GetProfileInt("Setup", "InterfaceEffect", iValue) )
+ if ( GetLocalProfileInt("Setup", "InterfaceEffect", iValue) )
{
m_bEffect = iValue;
}
- if ( GetProfileInt("Setup", "GroundShadow", iValue) )
+ if ( GetLocalProfileInt("Setup", "GroundShadow", iValue) )
{
m_engine->SetShadow(iValue);
}
- if ( GetProfileInt("Setup", "GroundSpot", iValue) )
+ if ( GetLocalProfileInt("Setup", "GroundSpot", iValue) )
{
m_engine->SetGroundSpot(iValue);
}
- if ( GetProfileInt("Setup", "ObjectDirty", iValue) )
+ if ( GetLocalProfileInt("Setup", "ObjectDirty", iValue) )
{
m_engine->SetDirty(iValue);
}
- if ( GetProfileInt("Setup", "FogMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "FogMode", iValue) )
{
m_engine->SetFog(iValue);
m_camera->SetOverBaseColor(RetColor(RetColor(0.0f)));
}
- if ( GetProfileInt("Setup", "LensMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "LensMode", iValue) )
{
m_engine->SetLensMode(iValue);
}
- if ( GetProfileInt("Setup", "SkyMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "SkyMode", iValue) )
{
m_engine->SetSkyMode(iValue);
}
- if ( GetProfileInt("Setup", "PlanetMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "PlanetMode", iValue) )
{
m_engine->SetPlanetMode(iValue);
}
- if ( GetProfileInt("Setup", "LightMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "LightMode", iValue) )
{
m_engine->SetLightMode(iValue);
}
- if ( GetProfileInt("Setup", "UseJoystick", iValue) )
+ if ( GetLocalProfileInt("Setup", "UseJoystick", iValue) )
{
m_engine->SetJoystick(iValue);
}
- if ( GetProfileFloat("Setup", "ParticuleDensity", fValue) )
+ if ( GetLocalProfileFloat("Setup", "ParticuleDensity", fValue) )
{
m_engine->SetParticuleDensity(fValue);
}
- if ( GetProfileFloat("Setup", "ClippingDistance", fValue) )
+ if ( GetLocalProfileFloat("Setup", "ClippingDistance", fValue) )
{
m_engine->SetClippingDistance(fValue);
}
- if ( GetProfileFloat("Setup", "ObjectDetail", fValue) )
+ if ( GetLocalProfileFloat("Setup", "ObjectDetail", fValue) )
{
m_engine->SetObjectDetail(fValue);
}
- if ( GetProfileFloat("Setup", "GadgetQuantity", fValue) )
+ if ( GetLocalProfileFloat("Setup", "GadgetQuantity", fValue) )
{
m_engine->SetGadgetQuantity(fValue);
}
- if ( GetProfileInt("Setup", "TextureQuality", iValue) )
+ if ( GetLocalProfileInt("Setup", "TextureQuality", iValue) )
{
m_engine->SetTextureQuality(iValue);
}
- if ( GetProfileInt("Setup", "AudioVolume", iValue) )
+ if ( GetLocalProfileInt("Setup", "AudioVolume", iValue) )
{
m_sound->SetAudioVolume(iValue);
}
- if ( GetProfileInt("Setup", "MidiVolume", iValue) )
+ if ( GetLocalProfileInt("Setup", "MidiVolume", iValue) )
{
m_sound->SetMidiVolume(iValue);
}
- if ( GetProfileInt("Setup", "EditIndentMode", iValue) )
+ if ( GetLocalProfileInt("Setup", "EditIndentMode", iValue) )
{
m_engine->SetEditIndentMode(iValue);
}
- if ( GetProfileInt("Setup", "EditIndentValue", iValue) )
+ if ( GetLocalProfileInt("Setup", "EditIndentValue", iValue) )
{
m_engine->SetEditIndentValue(iValue);
}
- if ( GetProfileString("Setup", "KeyMap", key, 500) )
+ if ( GetLocalProfileString("Setup", "KeyMap", key, 500) )
{
p = key;
for ( i=0 ; i<100 ; i++ )
@@ -5866,19 +5866,19 @@ void CMainDialog::SetupRecall()
#if _NET
if ( m_accessEnable )
{
- if ( GetProfileInt("Setup", "AccessMission", iValue) )
+ if ( GetLocalProfileInt("Setup", "AccessMission", iValue) )
{
m_accessMission = iValue;
}
- if ( GetProfileInt("Setup", "AccessUser", iValue) )
+ if ( GetLocalProfileInt("Setup", "AccessUser", iValue) )
{
m_accessUser = iValue;
}
}
#endif
- if ( GetProfileInt("Setup", "DeleteGamer", iValue) )
+ if ( GetLocalProfileInt("Setup", "DeleteGamer", iValue) )
{
m_bDeleteGamer = iValue;
}