summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-09 17:51:10 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-09 17:51:10 +0200
commitefe4f0baddf10124581e4fcb88d55a52838b06a1 (patch)
treec07882eb005e486abe1dbb03d008f6cca2898fe6
parentb3d5491af4f953e8d63800897c40d602de9e9305 (diff)
downloadcolobot-efe4f0baddf10124581e4fcb88d55a52838b06a1.tar.gz
colobot-efe4f0baddf10124581e4fcb88d55a52838b06a1.tar.bz2
colobot-efe4f0baddf10124581e4fcb88d55a52838b06a1.zip
Refactoring in src/common
- refactored CInstanceManager and some headers - removed old headers
-rw-r--r--src/CMakeLists.txt14
-rw-r--r--src/app/app.cpp80
-rw-r--r--src/app/app.h12
-rw-r--r--src/common/error_ids.h3
-rw-r--r--src/common/event.cpp10
-rw-r--r--src/common/event.h52
-rw-r--r--src/common/event_ids.h3
-rw-r--r--src/common/global.h123
-rw-r--r--src/common/image.h5
-rw-r--r--src/common/iman.cpp136
-rw-r--r--src/common/iman.h108
-rw-r--r--src/common/ioutils.h5
-rw-r--r--src/common/language.h54
-rw-r--r--src/common/logger.h14
-rw-r--r--src/common/metafile.cpp24
-rw-r--r--src/common/misc.cpp55
-rw-r--r--src/common/misc.h59
-rw-r--r--src/common/profile.cpp5
-rw-r--r--src/common/profile.h19
-rw-r--r--src/common/restext.cpp22
-rw-r--r--src/common/restext.h28
-rw-r--r--src/common/restext_ids.h3
-rw-r--r--src/common/singleton.h5
-rw-r--r--src/common/stringutils.h5
-rw-r--r--src/common/struct.h54
-rw-r--r--src/graphics/engine/lightning.h2
-rw-r--r--src/graphics/engine/pyro.h3
-rw-r--r--src/physics/physics.h2
28 files changed, 399 insertions, 506 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dc003b9..c41ebb0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -64,12 +64,11 @@ app/main.cpp
app/system.cpp
common/event.cpp
common/image.cpp
-common/logger.cpp
common/iman.cpp
-# common/metafile.cpp
-# common/misc.cpp
-# common/modfile.cpp
-# common/profile.cpp
+common/logger.cpp
+common/metafile.cpp
+common/misc.cpp
+common/profile.cpp
common/restext.cpp
common/restext_strings.c
common/stringutils.cpp
@@ -191,7 +190,10 @@ ${PLATFORM_LIBS}
CBot
)
-include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
+include_directories(
+.
+..
+${CMAKE_CURRENT_BINARY_DIR}
${SDL_INCLUDE_DIR}
${SDL_IMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 00cd13d..981146d 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -32,7 +32,7 @@
#include <stdio.h>
-template<> CApplication* CSingleton<CApplication>::mInstance = NULL;
+template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
//! Interval of timer called to update joystick state
@@ -62,8 +62,8 @@ struct ApplicationPrivate
ApplicationPrivate()
{
memset(&currentEvent, 0, sizeof(SDL_Event));
- surface = NULL;
- joystick = NULL;
+ surface = nullptr;
+ joystick = nullptr;
joystickTimer = 0;
}
};
@@ -76,10 +76,10 @@ CApplication::CApplication()
m_iMan = new CInstanceManager();
m_eventQueue = new CEventQueue(m_iMan);
- m_engine = NULL;
- m_device = NULL;
- m_robotMain = NULL;
- m_sound = NULL;
+ m_engine = nullptr;
+ m_device = nullptr;
+ m_robotMain = nullptr;
+ m_sound = nullptr;
m_keyState = 0;
m_axeKey = Math::Vector(0.0f, 0.0f, 0.0f);
@@ -95,19 +95,21 @@ CApplication::CApplication()
m_dataPath = "./data";
+ m_language = LANG_ENGLISH;
+
ResetKey();
}
CApplication::~CApplication()
{
delete m_private;
- m_private = NULL;
+ m_private = nullptr;
delete m_eventQueue;
- m_eventQueue = NULL;
+ m_eventQueue = nullptr;
delete m_iMan;
- m_iMan = NULL;
+ m_iMan = nullptr;
}
bool CApplication::ParseArguments(int argc, char *argv[])
@@ -218,7 +220,7 @@ bool CApplication::Create()
if (! CreateVideoSurface())
return false; // dialog is in function
- if (m_private->surface == NULL)
+ if (m_private->surface == nullptr)
{
m_errorMessage = std::string("SDL error while setting video mode:\n") +
std::string(SDL_GetError());
@@ -269,7 +271,7 @@ bool CApplication::Create()
bool CApplication::CreateVideoSurface()
{
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
- if (videoInfo == NULL)
+ if (videoInfo == nullptr)
{
m_errorMessage = std::string("SDL error while getting video info:\n ") +
std::string(SDL_GetError());
@@ -321,44 +323,44 @@ bool CApplication::CreateVideoSurface()
void CApplication::Destroy()
{
- /*if (m_robotMain != NULL)
+ /*if (m_robotMain != nullptr)
{
delete m_robotMain;
- m_robotMain = NULL;
+ m_robotMain = nullptr;
}
- if (m_sound != NULL)
+ if (m_sound != nullptr)
{
delete m_sound;
- m_sound = NULL;
+ m_sound = nullptr;
}*/
- if (m_engine != NULL)
+ if (m_engine != nullptr)
{
m_engine->Destroy();
delete m_engine;
- m_engine = NULL;
+ m_engine = nullptr;
}
- if (m_device != NULL)
+ if (m_device != nullptr)
{
m_device->Destroy();
delete m_device;
- m_device = NULL;
+ m_device = nullptr;
}
- if (m_private->joystick != NULL)
+ if (m_private->joystick != nullptr)
{
SDL_JoystickClose(m_private->joystick);
- m_private->joystick = NULL;
+ m_private->joystick = nullptr;
}
- if (m_private->surface != NULL)
+ if (m_private->surface != nullptr)
{
SDL_FreeSurface(m_private->surface);
- m_private->surface = NULL;
+ m_private->surface = nullptr;
}
IMG_Quit();
@@ -383,7 +385,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
return false;
}
- if (m_private->surface == NULL)
+ if (m_private->surface == nullptr)
{
if (! restore)
{
@@ -426,7 +428,7 @@ bool CApplication::OpenJoystick()
return false;
m_private->joystick = SDL_JoystickOpen(m_joystick.index);
- if (m_private->joystick == NULL)
+ if (m_private->joystick == nullptr)
return false;
m_joystick.axisCount = SDL_JoystickNumAxes(m_private->joystick);
@@ -437,7 +439,7 @@ bool CApplication::OpenJoystick()
m_joyButtonState = std::vector<bool>(m_joystick.buttonCount, false);
// Create a timer for polling joystick state
- m_private->joystickTimer = SDL_AddTimer(JOYSTICK_TIMER_INTERVAL, JoystickTimerCallback, NULL);
+ m_private->joystickTimer = SDL_AddTimer(JOYSTICK_TIMER_INTERVAL, JoystickTimerCallback, nullptr);
return true;
}
@@ -447,7 +449,7 @@ void CApplication::CloseJoystick()
// Timer will remove itself automatically
SDL_JoystickClose(m_private->joystick);
- m_private->joystick = NULL;
+ m_private->joystick = nullptr;
}
bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
@@ -455,7 +457,7 @@ bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
if ( (newJoystick.index < 0) || (newJoystick.index >= SDL_NumJoysticks()) )
return false;
- if (m_private->joystick != NULL)
+ if (m_private->joystick != nullptr)
CloseJoystick();
return OpenJoystick();
@@ -464,7 +466,7 @@ bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
Uint32 JoystickTimerCallback(Uint32 interval, void *)
{
CApplication *app = CApplication::GetInstancePointer();
- if ((app == NULL) || (! app->GetJoystickEnabled()))
+ if ((app == nullptr) || (! app->GetJoystickEnabled()))
return 0; // don't run the timer again
app->UpdateJoystick();
@@ -577,7 +579,7 @@ int CApplication::Run()
{
bool passOn = ProcessEvent(event);
- if (m_engine != NULL && passOn)
+ if (m_engine != nullptr && passOn)
passOn = m_engine->ProcessEvent(event);
if (passOn)
@@ -602,11 +604,11 @@ int CApplication::Run()
{
passOn = ProcessEvent(event);
- if (passOn && m_engine != NULL)
+ if (passOn && m_engine != nullptr)
passOn = m_engine->ProcessEvent(event);
}
- /*if (passOn && m_robotMain != NULL)
+ /*if (passOn && m_robotMain != nullptr)
m_robotMain->ProcessEvent(event); */
}
@@ -814,7 +816,7 @@ VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntPoint
resolutions.clear();
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
- if (videoInfo == NULL)
+ if (videoInfo == nullptr)
return VIDEO_QUERY_ERROR;
Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
@@ -964,3 +966,13 @@ std::string CApplication::GetDataFilePath(const std::string& dirName, const std:
{
return m_dataPath + "/" + dirName + "/" + fileName;
}
+
+Language CApplication::GetLanguage()
+{
+ return m_language;
+}
+
+void CApplication::SetLanguage(Language language)
+{
+ m_language = language;
+}
diff --git a/src/app/app.h b/src/app/app.h
index 7991177..b92c6b6 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -22,8 +22,7 @@
#pragma once
-
-#include "common/misc.h"
+#include "common/global.h"
#include "common/singleton.h"
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
@@ -198,6 +197,12 @@ public:
//! Returns the full path to a file in data directory
std::string GetDataFilePath(const std::string &dirName, const std::string &fileName);
+ //! Management of language
+ //@{
+ Language GetLanguage();
+ void SetLanguage(Language language);
+ //@}
+
protected:
//! Creates the window's SDL_Surface
bool CreateVideoSurface();
@@ -267,5 +272,8 @@ protected:
//! Path to directory with data files
std::string m_dataPath;
+
+ //! Application language
+ Language m_language;
};
diff --git a/src/common/error_ids.h b/src/common/error_ids.h
index b17a018..3c0e0a1 100644
--- a/src/common/error_ids.h
+++ b/src/common/error_ids.h
@@ -14,6 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// TODO: move to global.h after restext rewrite
+
#pragma once
enum Error
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 6a5f4d3..d082ba9 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -19,6 +19,16 @@
#include "common/event.h"
#include "common/iman.h"
+static EventType g_uniqueEventType = EVENT_USER;
+
+
+EventType GetUniqueEventType()
+{
+ int i = (int)g_uniqueEventType+1;
+ g_uniqueEventType = (EventType)i;
+ return g_uniqueEventType;
+}
+
CEventQueue::CEventQueue(CInstanceManager* iMan)
diff --git a/src/common/event.h b/src/common/event.h
index 3192931..e57bd08 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -14,17 +14,17 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// event.h
+/**
+ * \file common/event.h
+ * \brief Event types, structs and event queue
+ */
#pragma once
-#include <common/key.h>
-#include <common/event_ids.h>
-#include <math/point.h>
-
-#include <string.h>
-
+#include "common/key.h"
+#include "common/event_ids.h"
+#include "math/point.h"
class CInstanceManager;
@@ -193,40 +193,8 @@ struct Event
};
-/**
- \enum KeyRank
- \brief Slots for key assignment of user controls
- */
-
-// TODO: move to global.h ?
-
-enum KeyRank
-{
- KEYRANK_LEFT = 0,
- KEYRANK_RIGHT = 1,
- KEYRANK_UP = 2,
- KEYRANK_DOWN = 3,
- KEYRANK_GUP = 4,
- KEYRANK_GDOWN = 5,
- KEYRANK_CAMERA = 6,
- KEYRANK_DESEL = 7,
- KEYRANK_ACTION = 8,
- KEYRANK_NEAR = 9,
- KEYRANK_AWAY = 10,
- KEYRANK_NEXT = 11,
- KEYRANK_HUMAN = 12,
- KEYRANK_QUIT = 13,
- KEYRANK_HELP = 14,
- KEYRANK_PROG = 15,
- KEYRANK_VISIT = 16,
- KEYRANK_SPEED10 = 17,
- KEYRANK_SPEED15 = 18,
- KEYRANK_SPEED20 = 19,
- KEYRANK_SPEED30 = 20,
- KEYRANK_AIMUP = 21,
- KEYRANK_AIMDOWN = 22,
- KEYRANK_CBOT = 23,
-};
+//! Returns an unique event type (above the standard IDs)
+EventType GetUniqueEventType();
/**
@@ -261,5 +229,3 @@ protected:
int m_tail;
int m_total;
};
-
-
diff --git a/src/common/event_ids.h b/src/common/event_ids.h
index ab235d5..1bbc9be 100644
--- a/src/common/event_ids.h
+++ b/src/common/event_ids.h
@@ -14,6 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// TODO: move to event.h after restext rewrite
+
#pragma once
/**
diff --git a/src/common/global.h b/src/common/global.h
index 670c578..acc5b8f 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -14,53 +14,110 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// global.h
+/**
+ * \file common/global.h
+ * \brief Some common, global definitions
+ */
#pragma once
+#include "error_ids.h"
-enum BuildType
+/**
+ * \enum Language
+ * \brief Application language
+ */
+enum Language
{
- BUILD_FACTORY = (1<<0), // factory
- BUILD_DERRICK = (1<<1), // derrick
- BUILD_CONVERT = (1<<2), // converter
- BUILD_RADAR = (1<<3), // radar
- BUILD_ENERGY = (1<<4), // factory of cells
- BUILD_NUCLEAR = (1<<5), // nuclear power plant
- BUILD_STATION = (1<<6), // base station
- BUILD_REPAIR = (1<<7), // repair center
- BUILD_TOWER = (1<<8), // defense tower
- BUILD_RESEARCH = (1<<9), // research center
- BUILD_LABO = (1<<10), // laboratory
- BUILD_PARA = (1<<11), // lightning protection
- BUILD_INFO = (1<<12), // information terminal
- BUILD_GFLAT = (1<<16), // flat floor
- BUILD_FLAG = (1<<17) // puts / removes colored flag
+ LANG_ENGLISH = 0,
+ LANG_FRENCH = 1,
+ LANG_GERMAN = 2,
+ LANG_POLISH = 3
};
+/**
+ * \enum BuildType
+ * \brief Construction actions (buildings, etc.) available to user
+ *
+ * TODO: refactor
+ */
+enum BuildType
+{
+ BUILD_FACTORY = (1<<0), //! < factory
+ BUILD_DERRICK = (1<<1), //! < derrick
+ BUILD_CONVERT = (1<<2), //! < converter
+ BUILD_RADAR = (1<<3), //! < radar
+ BUILD_ENERGY = (1<<4), //! < factory of cells
+ BUILD_NUCLEAR = (1<<5), //! < nuclear power plant
+ BUILD_STATION = (1<<6), //! < base station
+ BUILD_REPAIR = (1<<7), //! < repair center
+ BUILD_TOWER = (1<<8), //! < defense tower
+ BUILD_RESEARCH = (1<<9), //! < research center
+ BUILD_LABO = (1<<10), //! < laboratory
+ BUILD_PARA = (1<<11), //! < lightning protection
+ BUILD_INFO = (1<<12), //! < information terminal
+ BUILD_GFLAT = (1<<16), //! < flat floor
+ BUILD_FLAG = (1<<17) //! < puts / removes colored flag
+};
-// Do not change values ​​was because of backups (bits = ...).
+/**
+ * \enum ResearchType
+ * \brief Research actions available to user
+ */
enum ResearchType
{
- RESEARCH_TANK = (1<<0), // caterpillars
- RESEARCH_FLY = (1<<1), // wings
- RESEARCH_CANON = (1<<2), // cannon
- RESEARCH_TOWER = (1<<3), // defense tower
- RESEARCH_ATOMIC = (1<<4), // nuclear
- RESEARCH_THUMP = (1<<5), // thumper
- RESEARCH_SHIELD = (1<<6), // shield
- RESEARCH_PHAZER = (1<<7), // phazer gun
- RESEARCH_iPAW = (1<<8), // legs of insects
- RESEARCH_iGUN = (1<<9), // cannon of insects
- RESEARCH_RECYCLER = (1<<10), // recycler
- RESEARCH_SUBM = (1<<11), // submarine
- RESEARCH_SNIFFER = (1<<12) // sniffer
+ RESEARCH_TANK = (1<<0), //! < caterpillars
+ RESEARCH_FLY = (1<<1), //! < wings
+ RESEARCH_CANON = (1<<2), //! < cannon
+ RESEARCH_TOWER = (1<<3), //! < defense tower
+ RESEARCH_ATOMIC = (1<<4), //! < nuclear
+ RESEARCH_THUMP = (1<<5), //! < thumper
+ RESEARCH_SHIELD = (1<<6), //! < shield
+ RESEARCH_PHAZER = (1<<7), //! < phazer gun
+ RESEARCH_iPAW = (1<<8), //! < legs of insects
+ RESEARCH_iGUN = (1<<9), //! < cannon of insects
+ RESEARCH_RECYCLER = (1<<10), //! < recycler
+ RESEARCH_SUBM = (1<<11), //! < submarine
+ RESEARCH_SNIFFER = (1<<12) //! < sniffer
};
+/**
+ * \enum KeyRank
+ * \brief Slots for key assignment of user controls
+ *
+ * TODO: refactor
+ */
+enum KeyRank
+{
+ KEYRANK_LEFT = 0,
+ KEYRANK_RIGHT = 1,
+ KEYRANK_UP = 2,
+ KEYRANK_DOWN = 3,
+ KEYRANK_GUP = 4,
+ KEYRANK_GDOWN = 5,
+ KEYRANK_CAMERA = 6,
+ KEYRANK_DESEL = 7,
+ KEYRANK_ACTION = 8,
+ KEYRANK_NEAR = 9,
+ KEYRANK_AWAY = 10,
+ KEYRANK_NEXT = 11,
+ KEYRANK_HUMAN = 12,
+ KEYRANK_QUIT = 13,
+ KEYRANK_HELP = 14,
+ KEYRANK_PROG = 15,
+ KEYRANK_VISIT = 16,
+ KEYRANK_SPEED10 = 17,
+ KEYRANK_SPEED15 = 18,
+ KEYRANK_SPEED20 = 19,
+ KEYRANK_SPEED30 = 20,
+ KEYRANK_AIMUP = 21,
+ KEYRANK_AIMDOWN = 22,
+ KEYRANK_CBOT = 23,
+};
+
+// TODO: move to CRobotMain
extern long g_id; // unique identifier
extern long g_build; // constructible buildings
extern long g_researchDone; // research done
extern long g_researchEnable; // research available
extern float g_unit; // conversion factor
-
-
diff --git a/src/common/image.h b/src/common/image.h
index 4d86d31..7588ea9 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// image.h
+/**
+ * \file common/image.h
+ * \brief Class for loading and saving images
+ */
#pragma once
diff --git a/src/common/iman.cpp b/src/common/iman.cpp
index 4b89ecf..e59afb1 100644
--- a/src/common/iman.cpp
+++ b/src/common/iman.cpp
@@ -16,12 +16,10 @@
// iman.cpp
-
-#include <stdio.h>
-
-#include "common/struct.h"
#include "common/iman.h"
+#include <cassert>
+
template<> CInstanceManager* CSingleton<CInstanceManager>::mInstance = nullptr;
@@ -39,139 +37,91 @@ CInstanceManager* CInstanceManager::GetInstancePointer()
return mInstance;
}
-
-// Object's constructor.
-
CInstanceManager::CInstanceManager()
{
- int i;
-
- for ( i=0 ; i<CLASS_MAX ; i++ )
+ for (int i = 0; i < CLASS_MAX; i++)
{
- m_table[i].totalPossible = 0;
- m_table[i].totalUsed = 0;
- m_table[i].classPointer = 0;
+ m_table[i].maxCount = 0;
+ m_table[i].usedCount = 0;
+ m_table[i].instances = nullptr;
}
}
-// Object's destructor.
-
CInstanceManager::~CInstanceManager()
{
- int i;
-
- for ( i=0 ; i<CLASS_MAX ; i++ )
- {
- if ( m_table[i].classPointer != 0 )
- {
- free(m_table[i].classPointer);
- }
- }
+ Flush();
}
-
-// Empty the list of all classes.
-
void CInstanceManager::Flush()
{
- int i;
-
- for ( i=0 ; i<CLASS_MAX ; i++ )
+ for (int i = 0; i < CLASS_MAX; i++)
{
- if ( m_table[i].classPointer != 0 )
- {
- free(m_table[i].classPointer);
- }
- m_table[i].classPointer = 0;
+ if (m_table[i].instances != nullptr)
+ delete[] m_table[i].instances;
+
+ m_table[i].instances = nullptr;
}
}
-// Empty all instances of a given class.
-
-void CInstanceManager::Flush(ClassType classType)
+void CInstanceManager::Flush(ManagedClassType classType)
{
- if ( classType < 0 || classType >= CLASS_MAX ) return;
- if ( m_table[classType].classPointer == 0 ) return;
+ if (classType < 0 || classType >= CLASS_MAX) return;
+ if (m_table[classType].instances == nullptr) return;
- free(m_table[classType].classPointer);
- m_table[classType].classPointer = 0;
+ delete[] m_table[classType].instances;
+ m_table[classType].instances = nullptr;
}
-
-// Adds a new instance of a class.
-
-bool CInstanceManager::AddInstance(ClassType classType, void* pointer, int max)
+bool CInstanceManager::AddInstance(ManagedClassType classType, void* instance, int max)
{
- int i;
+ if (classType < 0 || classType >= CLASS_MAX) return false;
- if ( classType < 0 || classType >= CLASS_MAX ) return false;
-
- if ( m_table[classType].classPointer == 0 )
+ if (m_table[classType].instances == nullptr)
{
- m_table[classType].classPointer = static_cast<void**>( malloc(max*sizeof(void*)) );
- m_table[classType].totalPossible = max;
- m_table[classType].totalUsed = 0;
+ m_table[classType].instances = new void*[max];
+ m_table[classType].maxCount = max;
+ m_table[classType].usedCount = 0;
}
- if ( m_table[classType].totalUsed >= m_table[classType].totalPossible ) return false;
+ if (m_table[classType].usedCount >= m_table[classType].maxCount) return false;
- i = m_table[classType].totalUsed++;
- m_table[classType].classPointer[i] = pointer;
+ int i = m_table[classType].usedCount++;
+ m_table[classType].instances[i] = instance;
return true;
}
-// Deletes an instance of a class.
-
-bool CInstanceManager::DeleteInstance(ClassType classType, void* pointer)
+bool CInstanceManager::DeleteInstance(ManagedClassType classType, void* instance)
{
- int i;
-
- if ( classType < 0 || classType >= CLASS_MAX ) return false;
+ if (classType < 0 || classType >= CLASS_MAX) return false;
- for ( i=0 ; i<m_table[classType].totalUsed ; i++ )
+ for (int i = 0; i < m_table[classType].usedCount; i++)
{
- if ( m_table[classType].classPointer[i] == pointer )
- {
- m_table[classType].classPointer[i] = 0;
- }
+ if (m_table[classType].instances[i] == instance)
+ m_table[classType].instances[i] = nullptr;
}
Compress(classType);
return true;
}
-// Seeking an existing instance. Returns 0 if it does not exist.
-// Must be super fast!
-
-void* CInstanceManager::SearchInstance(ClassType classType, int rank)
+void* CInstanceManager::SearchInstance(ManagedClassType classType, int rank)
{
-#if _DEBUG
- if ( classType < 0 || classType >= CLASS_MAX ) return 0;
- if ( m_table[classType].classPointer == 0 ) return 0;
-#endif
- if ( rank >= m_table[classType].totalUsed ) return 0;
+ if (classType < 0 || classType >= CLASS_MAX) return nullptr;
+ if (m_table[classType].instances == nullptr) return nullptr;
+ if (rank >= m_table[classType].usedCount) return nullptr;
- return m_table[classType].classPointer[rank];
+ return m_table[classType].instances[rank];
}
-
-// Fills holes in a table.
-
-void CInstanceManager::Compress(ClassType classType)
+void CInstanceManager::Compress(ManagedClassType classType)
{
- int i, j;
+ if (classType < 0 || classType >= CLASS_MAX) return;
- if ( classType < 0 || classType >= CLASS_MAX ) return;
-
- j = 0;
- for ( i=0 ; i<m_table[classType].totalUsed ; i++ )
+ int j = 0;
+ for (int i = 0; i < m_table[classType].usedCount; i++)
{
- if ( m_table[classType].classPointer[i] != 0 )
- {
- m_table[classType].classPointer[j++] = m_table[classType].classPointer[i];
- }
+ if (m_table[classType].instances[i] != nullptr)
+ m_table[classType].instances[j++] = m_table[classType].instances[i];
}
- m_table[classType].totalUsed = j;
+ m_table[classType].usedCount = j;
}
-
-
diff --git a/src/common/iman.h b/src/common/iman.h
index 89b5206..44f143a 100644
--- a/src/common/iman.h
+++ b/src/common/iman.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// iman.h
+/**
+ * \file iman.h
+ * \brief Instance manager for managed classes
+ */
#pragma once
@@ -22,36 +25,119 @@
#include <common/misc.h>
+/**
+ * \enum ManagedClassType
+ * \brief Type of class managed by CInstanceManager
+ */
-struct BaseClass
+// TODO: remove unnecessary, refactor to singletons, move to CRobotMain, keep others?
+
+enum ManagedClassType
{
- int totalPossible;
- int totalUsed;
- void** classPointer;
+ //! CEventQueue
+ CLASS_EVENT = 1,
+ //! Ui::CInterface
+ CLASS_INTERFACE = 2,
+ //! CRobotMain
+ CLASS_MAIN = 3,
+ //! Gfx::CEngine
+ CLASS_ENGINE = 4,
+ //! Gfx::CTerrain
+ CLASS_TERRAIN = 5,
+ //! CObject
+ CLASS_OBJECT = 6,
+ //! CPhysics
+ CLASS_PHYSICS = 7,
+ //! CBrain
+ CLASS_BRAIN = 8,
+ //! Gfx::CCamera
+ CLASS_CAMERA = 9,
+ //! Gfx::CLightManager
+ CLASS_LIGHT = 10,
+ //! Gfx::CParticle
+ CLASS_PARTICULE = 11,
+ //! CAuto; TODO: remove (unused)
+ CLASS_AUTO = 12,
+ //! Ui::CDisplayText
+ CLASS_DISPLAYTEXT = 13,
+ //! Gfx::CPyro
+ CLASS_PYRO = 14,
+ //! Ui::CScript; TODO: remove (unused)
+ CLASS_SCRIPT = 15,
+ //! Gfx::CText
+ CLASS_TEXT = 16,
+ //! Ui::CStudio, Ui::CDisplayText; TODO: remove (unused)
+ CLASS_STUDIO = 17,
+ //! Gfx::CWater
+ CLASS_WATER = 18,
+ //! Gfx::CCloud; TODO: remove (unused)
+ CLASS_CLOUD = 19,
+ //! CMotion; TODO: remove (unused)
+ CLASS_MOTION = 20,
+ //! CSoundInterface
+ CLASS_SOUND = 21,
+ //! Gfx::CPlanet
+ CLASS_PLANET = 22,
+ //! CTaskManager; TODO: remove (unused)
+ CLASS_TASKMANAGER = 23,
+ //! Ui::CMainDialog; TODO: remove (unused)
+ CLASS_DIALOG = 24,
+ //! Ui::CMainMap; TODO: remove (unused)
+ CLASS_MAP = 25,
+ //! Ui::CMainShort, CMainMovie; TODO: remove (unused)
+ CLASS_SHORT = 26,
+ //! Gfx::CLightning; TODO: remove (unused)
+ CLASS_BLITZ = 27,
+
+ //! Maximum (number of managed classes)
+ CLASS_MAX = 30
};
+/**
+ * \enum ManagedClassInstances
+ * \brief Instances of class managed by CInstanceManager
+ */
+struct ManagedClassInstances
+{
+ int maxCount;
+ int usedCount;
+ void** instances;
+};
+/**
+ * \class CInstanceManager
+ * \brief Manager for instances of certain classes
+ *
+ * Instance manager (often shortened to iMan) allows to register instances of
+ * classes and search them.
+ */
class CInstanceManager : public CSingleton<CInstanceManager>
{
public:
CInstanceManager();
~CInstanceManager();
+ //! Remove all managed instances
void Flush();
- void Flush(ClassType classType);
- bool AddInstance(ClassType classType, void* pointer, int max=1);
- bool DeleteInstance(ClassType classType, void* pointer);
- void* SearchInstance(ClassType classType, int rank=0);
+ //! Removes instances of one type of class
+ void Flush(ManagedClassType classType);
+ //! Registers new instance of class type
+ bool AddInstance(ManagedClassType classType, void* instance, int max=1);
+ //! Deletes the registered instance of class type
+ bool DeleteInstance(ManagedClassType classType, void* instance);
+ //! Seeks a class instance of given type
+ void* SearchInstance(ManagedClassType classType, int rank=0);
static CInstanceManager& GetInstance();
static CInstanceManager* GetInstancePointer();
protected:
- void Compress(ClassType classType);
+ //! Fills holes in instance table
+ void Compress(ManagedClassType classType);
protected:
- BaseClass m_table[CLASS_MAX];
+ ManagedClassInstances m_table[CLASS_MAX];
};
diff --git a/src/common/ioutils.h b/src/common/ioutils.h
index 2a542c6..e7668eb 100644
--- a/src/common/ioutils.h
+++ b/src/common/ioutils.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// ioutils.h
+/**
+ * \file ioutils.h
+ * \brief Functions for binary I/O
+ */
#pragma once
diff --git a/src/common/language.h b/src/common/language.h
deleted file mode 100644
index 82a7235..0000000
--- a/src/common/language.h
+++ /dev/null
@@ -1,54 +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/.
-
-// language.h
-
-#pragma once
-
-
-#define _FULL true // CoLoBoT
-#define _SCHOOL false // CeeBot-A or Teen
- #define _TEEN false // false for CeeBot-A, true for CeeBot-Teen
- #define _EDU false
- #define _PERSO false
- #define _CEEBOTDEMO false
-#define _NET false
-#define _DEMO false // DEMO only CoLoBoT (with _Full = false)!
-
-#define _FRENCH false
-#define _ENGLISH true
-#define _GERMAN false
-#define _WG false
-#define _POLISH false
-
-#define _NEWLOOK false // false for CoLoBoT, true for all CeeBot
-#define _SOUNDTRACKS false // always false since InitAudioTrackVolume crop in Vista
-
-
-// Verifications
-
-#if !_FULL & !_SCHOOL & !_NET & !_DEMO
--> no version chosen!
-#endif
-
-#if _SCHOOL
-#if !_EDU & !_PERSO & !_CEEBOTDEMO
--> EDU or PERSO or CEEBOTDEMO?
-#endif
-#if _EDU & _PERSO & _CEEBOTDEMO
--> EDU and PERSO and CEEBOTDEMO not at the same time!!!
-#endif
-#endif
diff --git a/src/common/logger.h b/src/common/logger.h
index fc43735..dfeeb98 100644
--- a/src/common/logger.h
+++ b/src/common/logger.h
@@ -14,22 +14,20 @@
// * 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
+/**
+ * \file common/logger.h
+ * \brief Class for logging information to file or console
+ */
#pragma once
+#include "common/singleton.h"
+
#include <string>
#include <cstdarg>
#include <cstdio>
-#include <common/singleton.h>
-
-/**
- * @file common/logger.h
- * @brief Class for loggin information to file or console
- */
-
/**
* \public
diff --git a/src/common/metafile.cpp b/src/common/metafile.cpp
index 9d54f78..d1692ce 100644
--- a/src/common/metafile.cpp
+++ b/src/common/metafile.cpp
@@ -16,17 +16,15 @@
// metafile.cpp
-
-#include <windows.h>
-#include <stdio.h>
-
-#include "common/language.h"
#include "common/metafile.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
-#if _FULL | _NET
+//#if _FULL | _NET
static unsigned char table_codec[23] =
{
0x85, 0x91, 0x73, 0xcf, 0xa2, 0xbb, 0xf4, 0x77,
@@ -44,9 +42,9 @@ void Codec(void* buffer, int len, int start)
b[i] ^= table_codec[(start++)%23];
}
}
-#endif
+//#endif
-#if _SCHOOL
+/*#if _SCHOOL
#if _CEEBOTDEMO
static unsigned char table_codec[136] =
{
@@ -99,9 +97,9 @@ void Codec(void* buffer, int len, int start)
}
}
#endif
-#endif
+#endif*/
-#if _DEMO
+/*#if _DEMO
static unsigned char table_codec[27] =
{
0x85, 0x91, 0x77, 0xcf, 0xa3, 0xbb, 0xf4, 0x77,
@@ -120,7 +118,7 @@ void Codec(void* buffer, int len, int start)
b[i] ^= table_codec[(start++)%27];
}
}
-#endif
+#endif*/
@@ -286,7 +284,7 @@ int CMetaFile::Read(void *buffer, int size)
int CMetaFile::GetByte()
{
- BYTE b;
+ int b;
if ( !m_bOpen ) return 1;
@@ -303,7 +301,7 @@ int CMetaFile::GetByte()
int CMetaFile::GetWord()
{
- WORD w;
+ int w;
if ( !m_bOpen ) return 1;
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 2427356..3da8f24 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -17,45 +17,20 @@
// misc.cpp
+#include "common/misc.h"
+
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <ctype.h>
-#include <direct.h>
#include <time.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "old/d3dutil.h"
-#include "common/language.h"
-#include "common/event.h"
-#include "common/misc.h"
-
-CMetaFile g_metafile;
-
-static EventMsg g_uniqueEventMsg = EVENT_USER;
static bool g_bUserDir = false;
static char g_userDir[100] = "";
-
-// Gives a single user event.
-
-EventMsg GetUniqueEventMsg()
-{
- int i;
-
- i = (int)g_uniqueEventMsg+1;
- g_uniqueEventMsg = (EventMsg)i;
- return g_uniqueEventMsg;
-}
-
-
-
// Returns a non-accented letter.
char RetNoAccent(char letter)
@@ -311,7 +286,8 @@ bool CopyFileToTemp(char* filename)
UserDir(dst, filename, "textures");
strcpy(g_userDir, save);
- _mkdir("temp");
+ //_mkdir("temp");
+ system("mkdir temp");
if ( !Xfer(src, dst) ) return false;
strcpy(filename, dst);
@@ -418,24 +394,3 @@ void UserDir(char* buffer, char* dir, char* def)
}
*buffer = 0;
}
-
-
-// Returns the letter corresponding to the language.
-
-char RetLanguageLetter()
-{
-#if _FRENCH
- return 'F';
-#endif
-#if _ENGLISH
- return 'E';
-#endif
-#if _GERMAN | _WG
- return 'D';
-#endif
-#if _POLISH
- return 'P';
-#endif
- return 'X';
-}
-
diff --git a/src/common/misc.h b/src/common/misc.h
index dca801f..66da478 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -22,55 +22,7 @@
#include <time.h>
-#include "common/metafile.h"
-#include "common/event.h"
-#include "common/error_ids.h"
-
-
-extern CMetaFile g_metafile;
-
-
-
-// Existing classes.
-
-enum ClassType
-{
- CLASS_EVENT = 1,
- CLASS_INTERFACE = 2,
- CLASS_MAIN = 3,
- CLASS_ENGINE = 4,
- CLASS_TERRAIN = 5,
- CLASS_OBJECT = 6,
- CLASS_PHYSICS = 7,
- CLASS_BRAIN = 8,
- CLASS_CAMERA = 9,
- CLASS_LIGHT = 10,
- CLASS_PARTICULE = 11,
- CLASS_AUTO = 12,
- CLASS_DISPLAYTEXT = 13,
- CLASS_PYRO = 14,
- CLASS_SCRIPT = 15,
- CLASS_TEXT = 16,
- CLASS_STUDIO = 17,
- CLASS_WATER = 18,
- CLASS_CLOUD = 19,
- CLASS_MOTION = 20,
- CLASS_SOUND = 21,
- CLASS_PLANET = 22,
- CLASS_TASKMANAGER = 23,
- CLASS_DIALOG = 24,
- CLASS_MAP = 25,
- CLASS_SHORT = 26,
- CLASS_BLITZ = 27,
-};
-
-const int CLASS_MAX = 30;
-
-
-
-
-// Keyboard state.
-
+// TODO: to be removed
const int KS_PAGEUP = (1<<4);
const int KS_PAGEDOWN = (1<<5);
const int KS_SHIFT = (1<<6);
@@ -84,10 +36,7 @@ const int KS_NUMRIGHT = (1<<13);
const int KS_NUMPLUS = (1<<14);
const int KS_NUMMINUS = (1<<15);
-
-// Procedures.
-
-extern EventType GetUniqueEventType();
+// TODO: rewrite/refactor or remove
extern char RetNoAccent(char letter);
extern char RetToUpper(char letter);
@@ -100,7 +49,3 @@ extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, char* ext);
extern void UserDir(bool bUser, char* dir);
extern void UserDir(char* buffer, char* dir, char* def);
-
-extern char RetLanguageLetter();
-
-
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 29a68e1..efcfa66 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -17,7 +17,10 @@
// profile.cpp
-#include <common/profile.h>
+#include "common/profile.h"
+
+#include <utility>
+#include <cstring>
template<> CProfile* CSingleton<CProfile>::mInstance = nullptr;
diff --git a/src/common/profile.h b/src/common/profile.h
index 0886522..7a23d94 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -14,22 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// profile.h
+/**
+ * \file common/profile.h
+ * \brief Class for loading profile (currently for loading ini config file)
+ */
#pragma once
-#include <cstdlib>
-#include <vector>
-#include <utility>
-
-#include <lib/simpleini/SimpleIni.h>
+#include "lib/simpleini/SimpleIni.h"
-#include <common/singleton.h>
+#include "common/singleton.h"
-/**
- * @file common/profile.h
- * @brief Class for loading profile (currently for loading ini config file)
- */
+#include <string>
+#include <vector>
/**
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 487d1a6..e66c70e 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -14,29 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.// restext.cpp
-#include <libintl.h>
-#include <SDL/SDL_keyboard.h>
-#include "common/struct.h"
-#include "common/language.h"
-#include "common/misc.h"
+#include "common/restext.h"
+
+#include "common/global.h"
#include "common/event.h"
-#include "object/object.h"
#include "CBot/resource.h"
-#include "common/restext.h"
+#include "object/object.h"
+#include <libintl.h>
+#include <SDL/SDL_keyboard.h>
-// Gives the pointer to the engine.
-static CD3DEngine* g_engine;
static char g_gamerName[100];
-void SetEngine(CD3DEngine *engine)
-{
- g_engine = engine;
-}
-
-// Give the player's name.
-
void SetGlobalGamerName(char *name)
{
strcpy(g_gamerName, name);
diff --git a/src/common/restext.h b/src/common/restext.h
index 624803b..0dba89a 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -14,30 +14,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// restext.h
+/**
+ * \file common/restext.h
+ * \brief Translation and string resource utilities
+ */
#pragma once
+#include "common/global.h"
#include "common/restext_ids.h"
-
-class CD3DEngine;
-
-// Possible types of the text resources.
-
+/**
+ * \enum ResType
+ * \brief Types of text resources
+ */
enum ResType
{
- RES_TEXT = 0, // RT_*
- RES_EVENT = 1, // EVENT_* (EventMsg)
- RES_OBJECT = 2, // OBJECT_* (ObjectType)
- RES_ERR = 3, // ERR_* (Error)
- RES_KEY = 4, // VK_* (keys)
- RES_CBOT = 5, // TX_* (cbot.dll)
+ RES_TEXT = 0, //! < RT_*
+ RES_EVENT = 1, //! < EVENT_* (EventMsg)
+ RES_OBJECT = 2, //! < OBJECT_* (ObjectType)
+ RES_ERR = 3, //! < ERR_* (Error)
+ RES_KEY = 4, //! < KEY() (keys)
+ RES_CBOT = 5, //! < TX_* (CBot)
};
-extern void SetEngine(CD3DEngine *engine);
extern void SetGlobalGamerName(char *name);
extern bool SearchKey(char *cmd, KeyRank &key);
extern bool GetResource(ResType type, int num, char* text);
diff --git a/src/common/restext_ids.h b/src/common/restext_ids.h
index bee8620..4223a1c 100644
--- a/src/common/restext_ids.h
+++ b/src/common/restext_ids.h
@@ -14,6 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// TODO: move to restext.h after restext rewrite
+
#pragma once
enum ResTextType
diff --git a/src/common/singleton.h b/src/common/singleton.h
index f631ed4..7407504 100644
--- a/src/common/singleton.h
+++ b/src/common/singleton.h
@@ -14,7 +14,10 @@
// * 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
+/**
+ * \file common/singleton.h
+ * \brief CSingleton base class for singletons
+ */
#pragma once
diff --git a/src/common/stringutils.h b/src/common/stringutils.h
index a0cae70..064351d 100644
--- a/src/common/stringutils.h
+++ b/src/common/stringutils.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// stringutils.h
+/**
+ * \file common/stringutils.h
+ * \brief Some useful string operations
+ */
#pragma once
diff --git a/src/common/struct.h b/src/common/struct.h
deleted file mode 100644
index 45ac314..0000000
--- a/src/common/struct.h
+++ /dev/null
@@ -1,54 +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/.
-
-// struct.h
-
-#pragma once
-
-
-#include <math/vector.h>
-
-
-#define D3DFVF_VERTEX2 (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
-
-struct D3DVERTEX2
-{
- float x,y,z;
- float nx,ny,nz;
- float tu, tv;
- float tu2, tv2;
-
- D3DVERTEX2() { }
- D3DVERTEX2(const Math::Vector& _v, const Math::Vector& _n, float _tu=0.0f, float _tv=0.0f, float _tu2=0.0f, float _tv2=0.0f)
- {
- x = _v.x;
- y = _v.y;
- z = _v.z;
- nx = _n.x;
- ny = _n.y;
- nz = _n.z;
- tu = _tu;
- tv = _tv;
- tu2 = _tu2;
- tv2 = _tv2;
- }
-};
-
-
-struct ColorHSV
-{
- float h,s,v;
-}; \ No newline at end of file
diff --git a/src/graphics/engine/lightning.h b/src/graphics/engine/lightning.h
index e34eb3b..af389f2 100644
--- a/src/graphics/engine/lightning.h
+++ b/src/graphics/engine/lightning.h
@@ -22,7 +22,7 @@
#pragma once
-#include "common/misc.h"
+#include "common/event.h"
#include "math/vector.h"
diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h
index 5d2ca63..c0c0144 100644
--- a/src/graphics/engine/pyro.h
+++ b/src/graphics/engine/pyro.h
@@ -22,7 +22,8 @@
#pragma once
-#include "common/misc.h"
+#include "common/event.h"
+#include "common/global.h"
#include "graphics/engine/engine.h"
#include "object/object.h"
diff --git a/src/physics/physics.h b/src/physics/physics.h
index 2e1f5eb..17cfd44 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "common/global.h"
#include "object/object.h"
#include "math/vector.h"