From efe4f0baddf10124581e4fcb88d55a52838b06a1 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 9 Sep 2012 17:51:10 +0200 Subject: Refactoring in src/common - refactored CInstanceManager and some headers - removed old headers --- src/common/error_ids.h | 3 ++ src/common/event.cpp | 10 ++++ src/common/event.h | 52 ++++-------------- src/common/event_ids.h | 3 ++ src/common/global.h | 123 ++++++++++++++++++++++++++++++------------ src/common/image.h | 5 +- src/common/iman.cpp | 136 +++++++++++++++-------------------------------- src/common/iman.h | 108 +++++++++++++++++++++++++++++++++---- src/common/ioutils.h | 5 +- src/common/language.h | 54 ------------------- src/common/logger.h | 14 +++-- src/common/metafile.cpp | 24 ++++----- src/common/misc.cpp | 55 ++----------------- src/common/misc.h | 59 +------------------- src/common/profile.cpp | 5 +- src/common/profile.h | 19 +++---- src/common/restext.cpp | 22 +++----- src/common/restext.h | 28 +++++----- src/common/restext_ids.h | 3 ++ src/common/singleton.h | 5 +- src/common/stringutils.h | 5 +- src/common/struct.h | 54 ------------------- 22 files changed, 331 insertions(+), 461 deletions(-) delete mode 100644 src/common/language.h delete mode 100644 src/common/struct.h (limited to 'src/common') 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 -#include -#include - -#include - +#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 - -#include "common/struct.h" #include "common/iman.h" +#include + template<> CInstanceManager* CSingleton::mInstance = nullptr; @@ -39,139 +37,91 @@ CInstanceManager* CInstanceManager::GetInstancePointer() return mInstance; } - -// Object's constructor. - CInstanceManager::CInstanceManager() { - int i; - - for ( i=0 ; i= 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( 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= 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 +/** + * \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 { 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 #include #include -#include - -/** - * @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 -#include - -#include "common/language.h" #include "common/metafile.h" +#include +#include +#include -#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 #include #include +#include #include -#include #include -#include - -#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 -#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 +#include "common/profile.h" + +#include +#include template<> CProfile* CSingleton::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 -#include -#include - -#include +#include "lib/simpleini/SimpleIni.h" -#include +#include "common/singleton.h" -/** - * @file common/profile.h - * @brief Class for loading profile (currently for loading ini config file) - */ +#include +#include /** 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 -#include -#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 +#include -// 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 - - -#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 -- cgit v1.2.3-1-g7c22