From 8765d58b02c9afd00186bae4a0045dff32f7d102 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 17:47:54 +0200 Subject: Fixed code formatting * moved braces to new lines * fixed some function/variable names * fixed whitespace issues --- src/CBot/CBot.cpp | 60 +++---- src/CBot/CBot.h | 49 +++--- src/CBot/CBotAddExpr.cpp | 3 +- src/CBot/CBotClass.cpp | 40 ++--- src/CBot/CBotCompExpr.cpp | 2 +- src/CBot/CBotDll.h | 46 +++--- src/CBot/CBotFunction.cpp | 43 ++--- src/CBot/CBotIf.cpp | 4 +- src/CBot/CBotProgram.cpp | 48 +++--- src/CBot/CBotStack.cpp | 56 +++---- src/CBot/CBotString.cpp | 10 +- src/CBot/CBotToken.cpp | 2 +- src/CBot/CBotToken.h | 1 + src/CBot/CBotTwoOpExpr.cpp | 15 +- src/CBot/CBotVar.cpp | 35 ++-- src/CBot/CBotWhile.cpp | 66 ++++---- src/CBot/CMakeLists.txt | 1 + src/CBot/ClassFILE.cpp | 6 +- src/CBot/StringFunctions.cpp | 7 +- src/CBot/idees.txt | 1 + src/CBot/resource.h | 1 + src/CMakeLists.txt | 3 +- src/app/README.txt | 1 + src/app/main.cpp | 1 + src/app/system.cpp | 9 +- src/app/system.h | 5 +- src/app/system_linux.cpp | 31 ++-- src/app/system_linux.h | 5 +- src/app/system_other.cpp | 1 + src/app/system_other.h | 1 + src/app/system_windows.cpp | 27 ++-- src/app/system_windows.h | 5 +- src/common/README.txt | 1 + src/common/config.h.cmake | 1 + src/common/event.h | 1 + src/common/global.h | 1 + src/common/image.cpp | 4 +- src/common/image.h | 1 + src/common/iman.cpp | 1 + src/common/iman.h | 1 - src/common/ioutils.h | 1 + src/common/key.h | 1 + src/common/logger.h | 4 +- src/common/misc.h | 1 + src/common/profile.cpp | 32 ++-- src/common/profile.h | 188 +++++++++++----------- src/common/restext.cpp | 1 + src/common/restext.h | 1 + src/common/singleton.h | 1 + src/common/stringutils.cpp | 1 + src/common/stringutils.h | 1 + src/desktop/.gitignore | 1 + src/desktop/CMakeLists.txt | 111 ++++++------- src/desktop/colobot.desktop.in | 1 + src/desktop/colobot.ini | 1 + src/desktop/colobot.pod | 1 + src/desktop/colobot.svg | 1 + src/desktop/create_desktop_file.sh | 8 +- src/desktop/po/colobot-desktop.pot | 1 + src/desktop/po4a.cfg | 1 + src/graphics/README.txt | 1 + src/graphics/core/README.txt | 3 +- src/graphics/core/color.cpp | 1 + src/graphics/core/color.h | 1 + src/graphics/core/device.h | 1 + src/graphics/core/light.h | 1 + src/graphics/core/material.h | 1 + src/graphics/core/texture.h | 1 + src/graphics/core/vertex.h | 1 + src/graphics/d3d/README.txt | 1 + src/graphics/engine/README.txt | 1 + src/graphics/engine/camera.cpp | 1 + src/graphics/engine/camera.h | 4 +- src/graphics/engine/cloud.cpp | 1 + src/graphics/engine/cloud.h | 1 + src/graphics/engine/engine.cpp | 1 + src/graphics/engine/engine.h | 1 + src/graphics/engine/lightman.cpp | 1 + src/graphics/engine/lightman.h | 1 + src/graphics/engine/lightning.cpp | 1 + src/graphics/engine/lightning.h | 1 + src/graphics/engine/modelfile.cpp | 1 + src/graphics/engine/modelfile.h | 1 + src/graphics/engine/modelmanager.cpp | 1 + src/graphics/engine/modelmanager.h | 1 + src/graphics/engine/particle.cpp | 1 + src/graphics/engine/particle.h | 1 + src/graphics/engine/planet.cpp | 1 + src/graphics/engine/planet.h | 1 + src/graphics/engine/pyro.cpp | 1 + src/graphics/engine/pyro.h | 1 + src/graphics/engine/terrain.cpp | 1 + src/graphics/engine/terrain.h | 1 + src/graphics/engine/test/CMakeLists.txt | 1 + src/graphics/engine/test/modelfile_test.cpp | 1 + src/graphics/engine/text.cpp | 1 + src/graphics/engine/text.h | 1 + src/graphics/engine/water.cpp | 1 + src/graphics/engine/water.h | 1 + src/graphics/opengl/README.txt | 1 + src/graphics/opengl/gldevice.cpp | 1 + src/graphics/opengl/gldevice.h | 1 + src/math/README.txt | 1 + src/math/all.h | 1 + src/math/const.h | 1 + src/math/func.h | 1 + src/math/geometry.h | 1 + src/math/intpoint.h | 1 + src/math/matrix.h | 1 + src/math/point.h | 1 + src/math/vector.h | 1 + src/object/README.txt | 1 + src/object/auto/auto.h | 4 +- src/object/auto/autoderrick.cpp | 1 - src/object/auto/autodestroyer.cpp | 13 +- src/object/auto/autoenergy.cpp | 1 + src/object/auto/autofactory.cpp | 4 +- src/object/auto/autoflag.cpp | 1 - src/object/auto/autoinfo.cpp | 1 - src/object/auto/autojostle.cpp | 1 - src/object/auto/autokid.cpp | 1 - src/object/auto/autolabo.cpp | 5 +- src/object/auto/automush.cpp | 1 - src/object/auto/autonest.cpp | 1 - src/object/auto/autonuclear.cpp | 1 - src/object/auto/autopara.cpp | 1 - src/object/auto/autoradar.cpp | 1 - src/object/auto/autorepair.cpp | 1 - src/object/auto/autorepair.h | 1 - src/object/auto/autoresearch.cpp | 5 +- src/object/auto/autoroot.cpp | 1 - src/object/auto/autosafe.cpp | 2 - src/object/auto/autostation.cpp | 1 - src/object/auto/autotower.cpp | 3 +- src/object/brain.cpp | 3 +- src/object/brain.h | 2 +- src/object/mainmovie.cpp | 1 - src/object/motion/motionant.cpp | 1 - src/object/motion/motionbee.cpp | 1 - src/object/motion/motiondummy.cpp | 3 +- src/object/motion/motiondummy.h | 1 + src/object/motion/motionhuman.cpp | 1 - src/object/motion/motionmother.cpp | 1 - src/object/motion/motionspider.cpp | 1 - src/object/motion/motiontoto.cpp | 1 - src/object/motion/motionvehicle.cpp | 1 - src/object/motion/motionworm.cpp | 3 +- src/object/object.cpp | 9 +- src/object/objman.cpp | 3 +- src/object/objman.h | 1 - src/object/robotmain.cpp | 239 +++++++++++++++++----------- src/object/robotmain.h | 8 +- src/object/task/task.cpp | 1 - src/object/task/task.h | 4 +- src/object/task/taskadvance.cpp | 1 - src/object/task/taskgoto.cpp | 4 +- src/object/task/taskmanager.cpp | 1 - src/object/task/tasksearch.cpp | 6 +- src/object/task/taskshield.cpp | 2 - src/object/task/tasktake.cpp | 1 - src/object/task/taskturn.cpp | 1 - src/object/task/taskwait.cpp | 1 - src/physics/README.txt | 1 + src/physics/physics.h | 1 - src/po/CMakeLists.txt | 1 + src/po/colobot.pot | 1 + src/po/de.po | 1 + src/po/fr.po | 1 + src/po/pl.po | 1 + src/script/cbottoken.cpp | 1 - src/script/cbottoken.h | 1 - src/script/cmdtoken.cpp | 1 - src/script/dd.cpp | 1 + src/script/script.cpp | 202 ++++++++++++----------- src/script/script.h | 5 +- src/sound/oalsound/alsound.cpp | 44 ++--- src/sound/oalsound/buffer.cpp | 2 +- src/sound/oalsound/channel.cpp | 28 ++-- src/sound/oalsound/channel.h | 14 +- src/sound/sound.h | 4 +- src/tools/CMakeLists.txt | 1 + src/tools/README.txt | 1 + src/tools/convert_model.cpp | 1 + src/ui/README.txt | 1 + src/ui/button.cpp | 1 + src/ui/button.h | 1 + src/ui/check.cpp | 1 + src/ui/color.cpp | 1 + src/ui/color.h | 1 + src/ui/compass.cpp | 1 + src/ui/compass.h | 1 + src/ui/control.cpp | 17 +- src/ui/control.h | 1 + src/ui/displayinfo.cpp | 1 + src/ui/displayinfo.h | 1 + src/ui/displaytext.cpp | 1 + src/ui/edit.cpp | 108 ++++++++----- src/ui/edit.h | 3 +- src/ui/editvalue.cpp | 1 + src/ui/editvalue.h | 1 + src/ui/gauge.cpp | 1 + src/ui/gauge.h | 23 ++- src/ui/group.cpp | 1 + src/ui/group.h | 1 + src/ui/image.cpp | 1 + src/ui/image.h | 1 + src/ui/interface.cpp | 30 ++-- src/ui/interface.h | 83 +++++----- src/ui/key.cpp | 1 + src/ui/label.cpp | 4 +- src/ui/label.h | 13 +- src/ui/list.cpp | 164 +++++++++++++------ src/ui/list.h | 1 + src/ui/maindialog.cpp | 221 +++++++++++++++---------- src/ui/maindialog.h | 2 +- src/ui/mainmap.cpp | 17 +- src/ui/mainmap.h | 62 ++++---- src/ui/mainshort.h | 47 +++--- src/ui/map.cpp | 45 ++++-- src/ui/map.h | 143 ++++++++--------- src/ui/scroll.cpp | 1 + src/ui/scroll.h | 65 ++++---- src/ui/shortcut.cpp | 1 + src/ui/shortcut.h | 21 +-- src/ui/slider.cpp | 1 + src/ui/slider.h | 69 ++++---- src/ui/studio.cpp | 28 ++-- src/ui/target.cpp | 1 + src/ui/target.h | 19 +-- src/ui/window.cpp | 1 + src/ui/window.h | 1 + 231 files changed, 1633 insertions(+), 1255 deletions(-) (limited to 'src') diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp index 4a16b6b..513b803 100644 --- a/src/CBot/CBot.cpp +++ b/src/CBot/CBot.cpp @@ -510,7 +510,7 @@ CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack) return inst; } -// creates a variable and assigns the result to the stack +// creates a variable and assigns the result to the stack bool CBotLeftExprVar::Execute(CBotStack* &pj) { CBotVar* var1; @@ -1073,7 +1073,7 @@ bool CBotInt::Execute(CBotStack* &pj) if (pile->IfStep()) return false; - if ( m_next2b && + if ( m_next2b && !m_next2b->Execute(pile)) return false; // other(s) definition(s) return pj->Return(pile); // forward below @@ -1558,8 +1558,8 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) int OpType = p->GetType(); if ( pStack->IsOk() && - IsOfTypeList(p, ID_ASS, ID_ASSADD, ID_ASSSUB, ID_ASSMUL, ID_ASSDIV, ID_ASSMODULO, - ID_ASSAND, ID_ASSXOR, ID_ASSOR, + IsOfTypeList(p, ID_ASS, ID_ASSADD, ID_ASSSUB, ID_ASSMUL, ID_ASSDIV, ID_ASSMODULO, + ID_ASSAND, ID_ASSXOR, ID_ASSOR, ID_ASSSL , ID_ASSSR, ID_ASSASR, 0 )) { if (inst->m_leftop == NULL) @@ -1655,7 +1655,7 @@ bool CBotExpression::Execute(CBotStack* &pj) CBotStack* pile = pj->AddStack(this); // CBotToken* pToken = m_leftop->GetToken(); - + CBotVar* pVar = NULL; CBotStack* pile1 = pile; @@ -1711,13 +1711,13 @@ bool CBotExpression::Execute(CBotStack* &pj) pile2->SetVar(result); break; case ID_ASSDIV: - if (IsInit && + if (IsInit && result->Div(pile1->GetVar(), pile2->GetVar())) pile2->SetError(TX_DIVZERO, &m_token); pile2->SetVar(result); break; case ID_ASSMODULO: - if (IsInit && + if (IsInit && result->Modulo(pile1->GetVar(), pile2->GetVar())) pile2->SetError(TX_DIVZERO, &m_token); pile2->SetVar(result); @@ -1776,7 +1776,7 @@ void CBotExpression::RestoreState(CBotStack* &pj, bool bMain) if ( pile1->GetState()==0) { - m_leftop->RestoreStateVar(pile, true); + m_leftop->RestoreStateVar(pile, true); return; } @@ -1969,7 +1969,7 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack) } // is it a number or DefineNum? - if (p->GetType() == TokenTypNum || + if (p->GetType() == TokenTypNum || p->GetType() == TokenTypDef ) { CBotInstr* inst = CBotExprNum::Compile(p, pStk); @@ -2066,7 +2066,7 @@ bool CBotPostIncExpr::Execute(CBotStack* &pj) pile1->SetState(1); pile1->SetCopyVar(var1); // places the result (before incrementation); - CBotStack* pile3 = pile2->AddStack(this); + CBotStack* pile3 = pile2->AddStack(this); if (pile3->IfStep()) return false; if (var1->GetInit() == IS_NAN) @@ -2321,7 +2321,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev pVar->Maj(pile->GetPUser(), true); - if ( m_next3 != NULL && + if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile, prevToken, bStep, bExtend) ) return false; // does not release the stack @@ -2340,7 +2340,7 @@ void CBotIndexExpr::RestoreStateVar(CBotStack* &pile, bool bMain) return; } - if (m_next3) + if (m_next3) m_next3->RestoreStateVar(pile, bMain); } @@ -2428,7 +2428,7 @@ bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev // request the update of the element, if applicable pVar->Maj(pile->GetPUser(), true); - if ( m_next3 != NULL && + if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, bExtend) ) return false; // does not release the stack @@ -2442,7 +2442,7 @@ void CBotFieldExpr::RestoreStateVar(CBotStack* &pj, bool bMain) pj = pj->RestoreStack(this); if (pj == NULL) return; - if (m_next3 != NULL) + if (m_next3 != NULL) m_next3->RestoreStateVar(pj, bMain); } @@ -2656,7 +2656,7 @@ bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT if (bStep && m_next3 == NULL && pile->IfStep()) return false; - if ( m_next3 != NULL && + if ( m_next3 != NULL && !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, true) ) return false; return true; @@ -2667,7 +2667,7 @@ void CBotLeftExpr::RestoreStateVar(CBotStack* &pile, bool bMain) pile = pile->RestoreStack(this); if (pile == NULL) return; - if (m_next3 != NULL) + if (m_next3 != NULL) m_next3->RestoreStateVar(pile, bMain); } @@ -3095,7 +3095,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat) { if (var->GetType() == CBotTypArrayPointer) { - if (IsOfType( p, ID_OPBRK )) // check if there is an aindex + if (IsOfType( p, ID_OPBRK )) // check if there is an aindex { CBotIndexExpr* i = new CBotIndexExpr(); i->m_expr = CBotExpression::Compile(p, pStk); // compile the formula @@ -3412,7 +3412,7 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* { CBotClass* pClass = var->GetClass(); // pointer to the class inst->m_ClassName = pClass->GetName(); // name of the class - CBotTypResult r = pClass->CompileMethode(inst->m_NomMethod, var, ppVars, + CBotTypResult r = pClass->CompileMethode(inst->m_NomMethod, var, ppVars, pStack, inst->m_MethodeIdent); delete pStack->TokenStack(); // release parameters on the stack inst->m_typRes = r; @@ -3504,8 +3504,8 @@ bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre } CBotVar* pRes = pResult; - if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, - pThis, ppVars, + if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, + pThis, ppVars, pResult, pile2, GetToken())) return false; if (pRes != pResult) delete pRes; @@ -3555,7 +3555,7 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain) // CBotVar* pRes = pResult; - pClass->RestoreMethode(m_MethodeIdent, m_NomMethod, + pClass->RestoreMethode(m_MethodeIdent, m_NomMethod, pThis, ppVars, pile2); } @@ -3609,8 +3609,8 @@ bool CBotInstrMethode::Execute(CBotStack* &pj) } CBotVar* pRes = pResult; - if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, - pThis, ppVars, + if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, + pThis, ppVars, pResult, pile2, GetToken())) return false; // interupted // set the new value of this in place of the old variable @@ -3625,7 +3625,7 @@ bool CBotInstrMethode::Execute(CBotStack* &pj) /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// compile an instruction "new" +// compile an instruction "new" CBotNew::CBotNew() { @@ -3770,8 +3770,8 @@ bool CBotNew::Execute(CBotStack* &pj) // create a variable for the result CBotVar* pResult = NULL; // constructos still void - if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(), - pThis, ppVars, + if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(), + pThis, ppVars, pResult, pile2, GetToken())) return false; // interrupt pThis->ConstructorSet(); // indicates that the constructor has been called @@ -3857,13 +3857,13 @@ bool TypeCompatible(CBotTypResult& type1, CBotTypResult& type2, int op) if (max >= CBotTypBoolean) { - if ( (op == ID_EQ || op == ID_NE) && + if ( (op == ID_EQ || op == ID_NE) && (t1 == CBotTypPointer && t2 == CBotTypNullPointer)) return true; - if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) && + if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) && (t2 == CBotTypPointer && t1 == CBotTypNullPointer)) return true; - if ( (op == ID_EQ || op == ID_NE) && + if ( (op == ID_EQ || op == ID_NE) && (t1 == CBotTypArrayPointer && t2 == CBotTypNullPointer)) return true; - if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) && + if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) && (t2 == CBotTypArrayPointer && t1 == CBotTypNullPointer)) return true; if (t2 != t1) return false; if (t1 == CBotTypArrayPointer) return type1.Compare(type2); diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index f5d78c8..8313252 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -69,7 +69,7 @@ class CBotDefParam; // paramerer list of a function // to use for routine CBotProgram :: Execute (CBotStack) -/**\class CBotStack +/**\class CBotStack * \brief Management of the execution stack. * \brief Actually the only thing it can do is to create an instance of a stack * \brief to use for routine CBotProgram :: Execute(CBotStack)*/ @@ -210,14 +210,14 @@ public: // in case of eventual break bool IfContinue(int state, const char* name); // or "continue" - + bool IsOk(); bool SetState(int n, int lim = -10); // select a state int GetState(); // in what state am I? bool IncState(int lim = -10); // passes to the next state bool IfStep(); // do step by step - bool Execute(); + bool Execute(); void SetVar( CBotVar* var ); void SetCopyVar( CBotVar* var ); @@ -259,7 +259,7 @@ private: CBotStack* m_prev; friend class CBotInstArray; -#ifdef _DEBUG +#ifdef _DEBUG int m_index; #endif int m_state; @@ -360,7 +360,7 @@ public: CBotCStack* TokenStack(CBotToken* pToken = NULL, bool bBlock = false); CBotInstr* Return(CBotInstr* p, CBotCStack* pParent); // transmits the result upper CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent); // transmits the result upper - + void SetVar( CBotVar* var ); void SetCopyVar( CBotVar* var ); CBotVar* GetVar(); @@ -480,7 +480,7 @@ class CBotWhile : public CBotInstr private: CBotInstr* m_Condition; // condition CBotInstr* m_Block; // instructions - CBotString m_label; // a label if there is + CBotString m_label; // a label if there is public: CBotWhile(); @@ -496,7 +496,7 @@ class CBotDo : public CBotInstr private: CBotInstr* m_Block; // instruction CBotInstr* m_Condition; // conditions - CBotString m_label; // a label if there is + CBotString m_label; // a label if there is public: CBotDo(); @@ -514,7 +514,7 @@ private: CBotInstr* m_Test; // test condition CBotInstr* m_Incr; // instruction for increment CBotInstr* m_Block; // instructions - CBotString m_label; // a label if there is + CBotString m_label; // a label if there is public: CBotFor(); @@ -528,7 +528,7 @@ public: class CBotBreak : public CBotInstr { private: - CBotString m_label; // a label if there is + CBotString m_label; // a label if there is public: CBotBreak(); @@ -542,7 +542,7 @@ public: class CBotReturn : public CBotInstr { private: - CBotInstr* m_Instr; // paramter of return + CBotInstr* m_Instr; // paramter of return public: CBotReturn(); @@ -557,7 +557,7 @@ public: class CBotSwitch : public CBotInstr { private: - CBotInstr* m_Value; // value to seek + CBotInstr* m_Value; // value to seek CBotInstr* m_Block; // instructions public: @@ -704,7 +704,7 @@ public: }; -// definition of a assignment list for a table +// definition of a assignment list for a table // int [ ] a [ ] = ( ( 1, 2, 3 ) , ( 3, 2, 1 ) ) ; class CBotListArray : public CBotInstr @@ -1415,12 +1415,12 @@ public: void IncrementUse(); // a reference to incrementation void DecrementUse(); // a reference to decrementation - CBotVarClass* + CBotVarClass* GetPointer(); void SetItemList(CBotVar* pVar); void SetIdent(long n); - + static CBotVarClass* Find(long id); @@ -1489,7 +1489,7 @@ public: void SetPointer(CBotVar* p); CBotVarClass* GetPointer(); - + void Copy(CBotVar* pSrc, bool bName=true); CBotVar* GetItem(int n, bool bGrow=false); // makes an element according to its numeric index // enlarged the table if necessary if bExtend @@ -1544,14 +1544,14 @@ private: CBotCall* m_next; public: - CBotCall(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + CBotCall(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); ~CBotCall(); static - bool AddFunction(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + bool AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); static @@ -1572,7 +1572,7 @@ public: CBotString GetName(); CBotCall* Next(); - + static void SetPUser(void* pUser); static void Free(); }; @@ -1591,13 +1591,13 @@ private: long m_nFuncIdent; public: - CBotCallMethode(const char* name, - bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), + CBotCallMethode(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)); ~CBotCallMethode(); CBotTypResult - CompileCall(const char* name, CBotVar* pThis, + CompileCall(const char* name, CBotVar* pThis, CBotVar** ppVars, CBotCStack* pStack, long& nIdent); @@ -1606,7 +1606,7 @@ public: CBotString GetName(); CBotCallMethode* Next(); void AddNext(CBotCallMethode* p); - + }; // a list of parameters @@ -1703,4 +1703,3 @@ public: bool GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop); }; - diff --git a/src/CBot/CBotAddExpr.cpp b/src/CBot/CBotAddExpr.cpp index 231f008..ec007ae 100644 --- a/src/CBot/CBotAddExpr.cpp +++ b/src/CBot/CBotAddExpr.cpp @@ -84,7 +84,7 @@ CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack) return pStack->Return(NULL, pStk); } - // if we are not dealing with an operation + or - + // if we are not dealing with an operation + or - // goes to that requested, the operand (left) found // place the object "addition" return pStack->Return(left, pStk); @@ -141,4 +141,3 @@ bool CBotAddExpr::Execute(CBotStack* &pStack) return pStack->Return(pStk1); // transmits the result } - diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp index a1c3fd4..12765ba 100644 --- a/src/CBot/CBotClass.cpp +++ b/src/CBot/CBotClass.cpp @@ -54,7 +54,7 @@ CBotClass::CBotClass(const char* name, CBotClass* pPapa, bool bIntrinsic) CBotClass::~CBotClass() { - // removes the list of class + // removes the list of class if ( m_ExPrev ) m_ExPrev->m_ExNext = m_ExNext; else m_ExClass = m_ExNext; @@ -106,7 +106,7 @@ bool CBotClass::Lock(CBotProgram* p) m_ProgInLock[0] = p; return true; } - if ( p == m_ProgInLock[0] ) + if ( p == m_ProgInLock[0] ) { m_cptOne++; m_cptLock--; // has already been counted @@ -156,14 +156,14 @@ void CBotClass::FreeLock(CBotProgram* p) while ( pClass != NULL ) { - if ( p == pClass->m_ProgInLock[0] ) + if ( p == pClass->m_ProgInLock[0] ) { pClass->m_cptLock -= pClass->m_cptOne; pClass->m_cptOne = 0; } for ( int j = 1; j < 5 ; j++ ) - if ( p == pClass->m_ProgInLock[j] ) + if ( p == pClass->m_ProgInLock[j] ) pClass->m_cptLock--; pClass = pClass->m_ExNext; @@ -291,8 +291,8 @@ CBotClass* CBotClass::Find(const char* name) return NULL; } -bool CBotClass::AddFunction(const char* name, - bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), +bool CBotClass::AddFunction(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)) { // stores pointers to the two functions @@ -313,7 +313,7 @@ bool CBotClass::AddFunction(const char* name, } p = new CBotCallMethode(name, rExec, rCompile); - + if (m_pCalls == NULL) m_pCalls = p; else m_pCalls->AddNext(p); // added to the list @@ -329,8 +329,8 @@ bool CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) ) // compiles a method associated with an instance of class // the method can be declared by the user or AddFunction -CBotTypResult CBotClass::CompileMethode(const char* name, - CBotVar* pThis, CBotVar** ppParams, +CBotTypResult CBotClass::CompileMethode(const char* name, + CBotVar* pThis, CBotVar** ppParams, CBotCStack* pStack, long& nIdent) { nIdent = 0; // forget the previous one if necessary @@ -350,8 +350,8 @@ CBotTypResult CBotClass::CompileMethode(const char* name, // executes a method -bool CBotClass::ExecuteMethode(long& nIdent, const char* name, - CBotVar* pThis, CBotVar** ppParams, +bool CBotClass::ExecuteMethode(long& nIdent, const char* name, + CBotVar* pThis, CBotVar** ppParams, CBotVar* &pResult, CBotStack* &pStack, CBotToken* pToken) { @@ -437,7 +437,7 @@ bool CBotClass::RestoreStaticState(FILE* pf) if (!ReadString( pf, VarName )) return false; if ( pClass != NULL ) pVar = pClass->GetItem(VarName); - if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable + if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable if ( pVar != NULL ) pVar->Copy(pv); delete pv; @@ -514,7 +514,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* delete inst; // is not type CBotInt p = vartoken; // returns to the variable name - // compiles declaration an array + // compiles declaration an array inst = static_cast(CBotInstArray::Compile( p, pStk, type )); @@ -595,7 +595,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* goto error; } // if ( !bIntrinsic ) var->SetPointer(pStk->GetVar()->GetPointer()); - if ( !bIntrinsic ) + if ( !bIntrinsic ) { // does not use the result on the stack, to impose the class CBotVar* pvar = CBotVar::Create("", pClass); @@ -608,7 +608,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* { // creates the object on the "job" (\TODO "tas") // with a pointer to the object - if ( !bIntrinsic ) + if ( !bIntrinsic ) { CBotVar* pvar = CBotVar::Create("", pClass); var->SetPointer( pvar ); // variable already declared instance pointer @@ -617,14 +617,14 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* var->SetInit(2); // marks the pointer as init } suite: - if (IsOfType(p, ID_COMMA)) // several chained definitions + if (IsOfType(p, ID_COMMA)) // several chained definitions { if ( NULL != ( inst->m_next = CBotClassInst::Compile(p, pStk, pClass) )) // compiles the following { return pStack->Return(inst, pStk); } } - + if (IsOfType(p, ID_SEP)) // complete instruction { return pStack->Return(inst, pStk); @@ -684,7 +684,7 @@ bool CBotClassInst::Execute(CBotStack* &pj) { // evaluates the expression for the assignment if (!m_expr->Execute(pile)) return false; - + if ( bIntrincic ) { CBotVar* pv = pile->GetVar(); @@ -750,8 +750,8 @@ bool CBotClassInst::Execute(CBotStack* &pj) // creates a variable for the result CBotVar* pResult = NULL; // constructor still void - if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(), - pThis, ppVars, + if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GetName(), + pThis, ppVars, pResult, pile2, GetToken())) return false; // interrupt pThis->SetInit(true); diff --git a/src/CBot/CBotCompExpr.cpp b/src/CBot/CBotCompExpr.cpp index 2daf53f..c9a977c 100644 --- a/src/CBot/CBotCompExpr.cpp +++ b/src/CBot/CBotCompExpr.cpp @@ -83,7 +83,7 @@ CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack) } -// perform the operation +// perform the operation bool CBotCompExpr::Execute(CBotStack* &pStack) { diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h index b401528..8858559 100644 --- a/src/CBot/CBotDll.h +++ b/src/CBot/CBotDll.h @@ -93,22 +93,22 @@ public: CBotTypResult(int type); // for simple types (CBotTypInt à CBotTypString) - + CBotTypResult(int type, const char* name); // for pointer types and intrinsic classes - + CBotTypResult(int type, CBotClass* pClass); // for the instance of a class - + CBotTypResult(int type, CBotTypResult elem); // for arrays of variables - + CBotTypResult(const CBotTypResult& typ); // for assignments - + CBotTypResult(); // for default - + ~CBotTypResult(); int GetType(int mode = 0) const; @@ -147,7 +147,7 @@ private: CBotClass* m_pClass; // for the derivatives of class int m_limite; // limits of tables friend class CBotVarClass; - friend class CBotVarPointer; + friend class CBotVarPointer; }; /* @@ -246,7 +246,7 @@ private: //////////////////////////////////////////////////////////////////////// -// +// // as part of MFC CString not used here. // // ( all functions are not implemented yet ) @@ -451,12 +451,12 @@ public: static void SetTimer(int n); - // defines the number of steps (parts of instructions) to done + // defines the number of steps (parts of instructions) to done // in Run() before rendering hand "false" \TODO avant de rendre la main "false" static - bool AddFunction(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + bool AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); // call this to add externally (**) // a new function used by the program CBoT @@ -472,8 +472,8 @@ public: // restores the state of execution from file // the compiled program must obviously be the same - bool GetPosition(const char* name, int& start, int& stop, - CBotGet modestart = GetPosExtern, + bool GetPosition(const char* name, int& start, int& stop, + CBotGet modestart = GetPosExtern, CBotGet modestop = GetPosBloc); // gives the position of a routine in the original text // the user can select the item to find from the beginning to the end @@ -513,7 +513,7 @@ int cMean(CBotVar* &pVar, CBotString& ClassName) while ( pVar != NULL ) { - if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number + if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number pVar = pVar -> GetNext(); } @@ -623,7 +623,7 @@ virtual ~CBotVar( ); // destructor void SetName(const char* name); // changes the name of the variable int GetType(int mode = 0); // returns the base type (int) of the variable - // TODO check it + // TODO check it //////////////////////////////////////////////////////////////////////////////////////// CBotTypResult GetTypResult(int mode = 0); // returns the complete type of the variable @@ -654,7 +654,7 @@ virtual ~CBotVar( ); // destructor CBotVar* GetItemRef(int nIdent); // idem à partir du n° ref // TODO ditto from ref no. virtual - CBotVar* GetItem(int row, bool bGrow = false); + CBotVar* GetItem(int row, bool bGrow = false); virtual CBotVar* GetItemList(); // lists the elements @@ -802,8 +802,8 @@ public: ~CBotClass( ); // destructor - bool AddFunction(const char* name, - bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), + bool AddFunction(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)); // this call allows to add as external (**) // new method used by the objects of this class @@ -841,7 +841,7 @@ public: CBotVar* GetItem(const char* name); // one of the variables according to its name CBotVar* GetItemRef(int nIdent); - CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams, + CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams, CBotCStack* pStack, long& nIdent); bool ExecuteMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotVar* &pResult, CBotStack* &pStack, CBotToken* pToken); @@ -854,7 +854,7 @@ public: CBotClass* Compile1(CBotToken* &p, CBotCStack* pStack); bool CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond); - + bool IsIntrinsic(); void Purge(); static @@ -917,7 +917,7 @@ private: int m_start; // position in the original text (program) int m_end; // the same for the end of the token - + /** * \brief Check whether given parameter is a keyword */ @@ -979,11 +979,11 @@ public: CBotToken* GetPrev(); /** - * \brief transforms the entire program + * \brief transforms the entire program */ static CBotToken* CompileTokens(const char* p, int& error); - + /** * \brief releases the list */ diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp index 28db24e..862554e 100644 --- a/src/CBot/CBotFunction.cpp +++ b/src/CBot/CBotFunction.cpp @@ -28,7 +28,7 @@ CBotFunction::CBotFunction() m_Param = NULL; // empty parameter list m_Block = NULL; // the instruction block m_next = NULL; // functions can be chained - m_bPublic = false; // function not public + m_bPublic = false; // function not public m_bExtern = false; // function not extern m_nextpublic = NULL; m_prevpublic = NULL; @@ -159,9 +159,9 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile) if ( pClass != NULL) { p = p->GetNext(); - return ArrayType(p, pile, - pClass->IsIntrinsic() ? - CBotTypResult( CBotTypIntrinsic, pClass ) : + return ArrayType(p, pile, + pClass->IsIntrinsic() ? + CBotTypResult( CBotTypIntrinsic, pClass ) : CBotTypResult( CBotTypPointer, pClass ) ); } } @@ -261,7 +261,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct } } - // and compiles the following instruction block + // and compiles the following instruction block func->m_openblk = p; func->m_Block = CBotBlock::Compile(p, pStk, false); func->m_closeblk = p->GetPrev(); @@ -288,7 +288,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas { CBotFunction* func = new CBotFunction(); func->m_nFuncIdent = CBotVar::NextUniqNum(); - + CBotCStack* pStk = pStack->TokenStack(p, true); while (true) @@ -334,7 +334,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas func->m_Param = CBotDefParam::Compile( p, pStk ); if (pStk->IsOk()) { - // looks if the function exists elsewhere + // looks if the function exists elsewhere if (( pClass != NULL || !pStack->CheckCall(pp, func->m_Param)) && ( pClass == NULL || !pClass->CheckCall(pp, func->m_Param)) ) { @@ -350,7 +350,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas if (type == ID_CLBLK) level--; } while (level > 0 && p != NULL); - + return pStack->ReturnFunc(func, pStk); } pStk->SetError(TX_OPENBLK, p); @@ -528,7 +528,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB pv = pv->GetNext(); pw = ppVars[i++]; } - if ( pw != NULL ) + if ( pw != NULL ) { if ( pFunc != NULL ) continue; if ( TypeOrError.Eq(TX_LOWPARAM) ) TypeOrError.SetType(TX_NUMPARAM); @@ -583,7 +583,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CB pv = pv->GetNext(); pw = ppVars[i++]; } - if ( pw != NULL ) + if ( pw != NULL ) { if ( pFunc != NULL ) continue; if ( TypeOrError.Eq(TX_LOWPARAM) ) TypeOrError.SetType(TX_NUMPARAM); @@ -630,7 +630,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS { CBotTypResult type; CBotFunction* pt = NULL; - + pt = FindLocalOrPublic(nIdent, name, ppVars, type); if ( pt != NULL ) @@ -754,7 +754,7 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, -// makes call of a method +// makes call of a method // note: this is already on the stack, the pointer pThis is just to simplify int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass) @@ -951,7 +951,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack) if (IsOfType(p, ID_OPENPAR)) { CBotDefParam* list = NULL; - + while (!IsOfType(p, ID_CLOSEPAR)) { CBotDefParam* param = new CBotDefParam(); @@ -1090,7 +1090,7 @@ CBotDefParam* CBotDefParam::GetNext() CBotString CBotDefParam::GetParamString() { CBotString param; - + param = m_typename; param += ' '; @@ -1136,7 +1136,7 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack) if ( pStack->IsOk() ) { CBotTypResult retType = pStack->GetTypResult(2); - if (TypeCompatible(retType, type, ID_ASS)) + if (TypeCompatible(retType, type, ID_ASS)) { if ( IsOfType( p, ID_SEP ) ) return inst; @@ -1202,7 +1202,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack) int i = 0; - CBotToken* pp = p; + CBotToken* pp = p; p = p->GetNext(); pStack->SetStartError(p->GetStart()); @@ -1367,7 +1367,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack) pStack->SetError(TX_NOPUBLIC, p); return NULL; } - + if ( !IsOfType(p, ID_CLASS) ) return NULL; CBotString name = p->GetString(); @@ -1443,7 +1443,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) return false; } - while (pStack->IsOk()) + while (pStack->IsOk()) { CBotToken* pp = p; IsOfType(p, ID_NOT); // skips ~ eventual (destructor) @@ -1484,7 +1484,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) if ( !bSecond ) { p = pBase; - CBotFunction* f = + CBotFunction* f = CBotFunction::Compile1(p, pStack, this); if ( f == NULL ) return false; @@ -1497,7 +1497,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) // return a method precompiled in pass 1 CBotFunction* pf = m_pMethod; CBotFunction* prev = NULL; - while ( pf != NULL ) + while ( pf != NULL ) { if (pf->GetName() == pp->GetString()) break; prev = pf; @@ -1541,7 +1541,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) // compiles a method p = pBase; - CBotFunction* f = + CBotFunction* f = CBotFunction::Compile(p, pile, NULL/*, false*/); if ( f != NULL ) @@ -1646,3 +1646,4 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack) pStack->SetError(TX_ENDOF, p); return NULL; } + diff --git a/src/CBot/CBotIf.cpp b/src/CBot/CBotIf.cpp index a5d2693..bc58af1 100644 --- a/src/CBot/CBotIf.cpp +++ b/src/CBot/CBotIf.cpp @@ -109,7 +109,7 @@ bool CBotIf :: Execute(CBotStack* &pj) // passes into the second state if (!pile->SetState(1)) return false; // ready for further } - + // second state, evaluates the associated instructions // the result of the condition is on the stack @@ -143,7 +143,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, bool bMain) m_Condition->RestoreState(pile, bMain); // interrupted here! return; } - + // second state, evaluates the associated instructions // the result of the condition is on the stack diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp index f4987a7..1944f92 100644 --- a/src/CBot/CBotProgram.cpp +++ b/src/CBot/CBotProgram.cpp @@ -97,7 +97,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, { if ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking - if ( p->GetType() == ID_CLASS || + if ( p->GetType() == ID_CLASS || ( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS )) { CBotClass* nxt = CBotClass::Compile1(p, pStack); @@ -113,7 +113,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, } if ( !pStack->IsOk() ) { - m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd); + m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd); delete m_Prog; m_Prog = NULL; delete pBaseToken; @@ -129,7 +129,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, { if ( IsOfType(p, ID_SEP) ) continue; // semicolons lurking - if ( p->GetType() == ID_CLASS || + if ( p->GetType() == ID_CLASS || ( p->GetType() == ID_PUBLIC && p->GetNext()->GetType() == ID_CLASS )) { m_bCompileClass = true; @@ -150,7 +150,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, if ( !pStack->IsOk() ) { - m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd); + m_ErrorCode = pStack->GetError(m_ErrorStart, m_ErrorEnd); delete m_Prog; m_Prog = NULL; } @@ -228,7 +228,7 @@ bool CBotProgram::Run(void* pUser, int timer) #if STACKRUN // resumes execution on the top of the stack ok = m_pStack->Execute(); - if ( ok ) + if ( ok ) { #ifdef _DEBUG CBotVar* ppVar[3]; @@ -354,8 +354,8 @@ CBotFunction* CBotProgram::GetFunctions() return m_Prog; } -bool CBotProgram::AddFunction(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), +bool CBotProgram::AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) { // stores pointers to the two functions @@ -369,7 +369,7 @@ bool WriteWord(FILE* pf, unsigned short w) lg = fwrite(&w, sizeof( unsigned short ), 1, pf ); - return (lg == 1); + return (lg == 1); } bool ReadWord(FILE* pf, unsigned short& w) @@ -387,7 +387,7 @@ bool WriteFloat(FILE* pf, float w) lg = fwrite(&w, sizeof( float ), 1, pf ); - return (lg == 1); + return (lg == 1); } bool ReadFloat(FILE* pf, float& w) @@ -405,7 +405,7 @@ bool WriteLong(FILE* pf, long w) lg = fwrite(&w, sizeof( long ), 1, pf ); - return (lg == 1); + return (lg == 1); } bool ReadLong(FILE* pf, long& w) @@ -425,7 +425,7 @@ bool WriteString(FILE* pf, CBotString s) if (!WriteWord(pf, lg1)) return false; lg2 = fwrite(s, 1, lg1, pf ); - return (lg1 == lg2); + return (lg1 == lg2); } bool ReadString(FILE* pf, CBotString& s) @@ -510,7 +510,7 @@ bool CBotProgram::SaveState(FILE* pf) if (!WriteString( pf, m_pRun->GetName() )) return false; if (!m_pStack->SaveState(pf)) return false; } - else + else { if (!WriteWord( pf, 0)) return false; } @@ -560,9 +560,9 @@ int CBotProgram::GetVersion() ////////////////////////////////////////////////////////////////////////////////////////////////////// CBotCall* CBotCall::m_ListCalls = NULL; - -CBotCall::CBotCall(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + +CBotCall::CBotCall(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) { m_name = name; @@ -583,8 +583,8 @@ void CBotCall::Free() delete CBotCall::m_ListCalls; } -bool CBotCall::AddFunction(const char* name, - bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), +bool CBotCall::AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) { CBotCall* p = m_ListCalls; @@ -608,7 +608,7 @@ bool CBotCall::AddFunction(const char* name, } pp = new CBotCall(name, rExec, rCompile); - + if (p) p->m_next = pp; else m_ListCalls = pp; @@ -658,7 +658,7 @@ CBotTypResult CBotCall::CompileCall(CBotToken* &p, CBotVar** ppVar, CBotCStack* CBotVar* pVar2 = pVar; CBotTypResult r = pt->m_rComp(pVar2, m_pUser); int ret = r.GetType(); - + // if a class is returned, it is actually a pointer if ( ret == CBotTypClass ) r.SetType( ret = CBotTypPointer ); @@ -859,8 +859,8 @@ bool CBotCall::Run(CBotStack* pStack) /////////////////////////////////////////////////////////////////////////////////////// -CBotCallMethode::CBotCallMethode(const char* name, - bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), +CBotCallMethode::CBotCallMethode(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)) { m_name = name; @@ -879,7 +879,7 @@ CBotCallMethode::~CBotCallMethode() // is acceptable by a call procedure name // and given parameters -CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis, +CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis, CBotVar** ppVar, CBotCStack* pStack, long& nIdent) { @@ -1008,7 +1008,7 @@ bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) while ( pVar != NULL ) { - i++; + i++; pVar = pVar->GetNext(); } @@ -1107,7 +1107,7 @@ void CBotProgram::Init() void CBotProgram::Free() { - CBotToken::Free() ; + CBotToken::Free() ; CBotCall ::Free() ; CBotClass::Free() ; } diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index 67f2000..086442d 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -63,7 +63,7 @@ CBotStack* CBotStack::FirstStack() pp->m_bOver = true; pp ++; } -#ifdef _DEBUG +#ifdef _DEBUG int n = 1; pp = p; for ( i = 0 ; i< MAXSTACK+10 ; i++ ) @@ -120,7 +120,7 @@ void CBotStack::Delete() m_index = n; #endif - if ( p == NULL ) + if ( p == NULL ) free( this ); } @@ -128,7 +128,7 @@ void CBotStack::Delete() // routine improved CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) { - if (m_next != NULL) + if (m_next != NULL) { return m_next; // included in an existing stack } @@ -160,7 +160,7 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) { - if (m_next != NULL) + if (m_next != NULL) { if ( m_next == EOX ) { @@ -177,7 +177,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) CBotStack* CBotStack::AddStack2(bool bBlock) { - if (m_next2 != NULL) + if (m_next2 != NULL) { m_next2->m_prog = m_prog; // special avoids RestoreStack2 return m_next2; // included in an existing stack @@ -251,8 +251,8 @@ CBotStack::CBotStack(CBotStack* ppapa) if (ppapa == NULL) m_timer = m_initimer; // sets the timer at the beginning m_listVar = NULL; - m_bDontDelete = false; - + m_bDontDelete = false; + m_var = NULL; m_prog = NULL; m_instr = NULL; @@ -275,7 +275,7 @@ CBotStack::~CBotStack() // \TODO routine has/to optimize CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) { - if (m_next != NULL) + if (m_next != NULL) { return m_next; // included in an existing stack } @@ -290,7 +290,7 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) { - if (m_next != NULL) + if (m_next != NULL) { if ( m_next == EOX ) { @@ -311,7 +311,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) CBotStack* CBotStack::AddStack2(bool bBlock) { - if (m_next2 != NULL) + if (m_next2 != NULL) { m_next2->m_prog = m_prog; // special avoids RestoreStack2 return m_next2; // included in an existing stack @@ -362,7 +362,7 @@ void CBotStack::Reset(void* pUser) CBotStack* CBotStack::RestoreStack(CBotInstr* instr) { - if (m_next != NULL) + if (m_next != NULL) { m_next->m_instr = instr; // reset (if recovery after ) m_next->m_prog = m_prog; @@ -480,7 +480,7 @@ CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif) { if (pp->GetName() == name) { - if ( bUpdate ) + if ( bUpdate ) pp->Maj(m_pUser, false); return pp; @@ -521,7 +521,7 @@ CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif) { if (pp->GetUniqNum() == ident) { - if ( bUpdate ) + if ( bUpdate ) pp->Maj(m_pUser, false); return pp; @@ -552,7 +552,7 @@ CBotVar* CBotStack::CopyVar(CBotToken& Token, bool bUpdate) return pCopy; } - + bool CBotStack::SetState(int n, int limite) { m_state = n; @@ -609,7 +609,7 @@ bool CBotStack::Execute() while (p != NULL) { if ( p->m_next2 != NULL ) break; - if ( p->m_call != NULL ) + if ( p->m_call != NULL ) { instr = p->m_call; pile = p->m_prev ; @@ -684,7 +684,7 @@ void CBotStack::AddVar(CBotVar* pVar) while (p != NULL && p->m_bBlock == 0) p = p->m_prev; if ( p == NULL ) return; - + /// p->m_bDontDelete = bDontDelete; CBotVar** pp = &p->m_listVar; @@ -787,7 +787,7 @@ void CBotStack::GetRunPos(const char* &FunctionName, int &start, int &end) { if ( p->m_instr != NULL ) instr = p->m_instr; if ( p->m_bFunc == 1 ) funct = p->m_instr; - if ( p->m_next->m_prog != prog ) break ; + if ( p->m_next->m_prog != prog ) break ; if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ; else p = p->m_next; @@ -818,7 +818,7 @@ CBotVar* CBotStack::GetStackVars(const char* &FunctionName, int level) while (p->m_next != NULL) { - if ( p->m_next->m_prog != prog ) break ; + if ( p->m_next->m_prog != prog ) break ; if (p->m_next2 && p->m_next2->m_state != 0) p = p->m_next2 ; else p = p->m_next; @@ -848,7 +848,7 @@ CBotVar* CBotStack::GetStackVars(const char* &FunctionName, int level) CBotToken* t = pp->m_instr->GetToken(); FunctionName = t->GetString(); - + return p->m_listVar; } @@ -872,8 +872,8 @@ bool CBotStack::SaveState(FILE* pf) if (!WriteWord(pf, m_state)) return false; // in what state? if (!WriteWord(pf, 0)) return false; // by compatibility m_bDontDelete if (!WriteWord(pf, m_step)) return false; // in what state? - - + + if (!SaveVar(pf, m_var)) return false; // current result if (!SaveVar(pf, m_listVar)) return false; // local variables @@ -921,7 +921,7 @@ bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack) bool CBotVar::Save0State(FILE* pf) -{ +{ if (!WriteWord(pf, 100+m_mPrivate))return false; // private variable? if (!WriteWord(pf, m_bStatic))return false; // static variable? if (!WriteWord(pf, m_type.GetType()))return false; // saves the type (always non-zero) @@ -930,11 +930,11 @@ bool CBotVar::Save0State(FILE* pf) } bool CBotVarInt::Save0State(FILE* pf) -{ +{ if ( !m_defnum.IsEmpty() ) { if(!WriteWord(pf, 200 )) return false; // special marker - if(!WriteString(pf, m_defnum)) return false; // name of the value + if(!WriteString(pf, m_defnum)) return false; // name of the value } return CBotVar::Save0State(pf); @@ -1051,7 +1051,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) if ( p != NULL ) { delete pNew; - pNew = p; // resume known element + pNew = p; // resume known element } } } @@ -1167,7 +1167,7 @@ CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock) CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils) -{ +{ if ( pfils == this ) return inst; if (m_var != NULL) delete m_var; // value replaced? @@ -1185,7 +1185,7 @@ CBotInstr* CBotCStack::Return(CBotInstr* inst, CBotCStack* pfils) } CBotFunction* CBotCStack::ReturnFunc(CBotFunction* inst, CBotCStack* pfils) -{ +{ if (m_var != NULL) delete m_var; // value replaced? m_var = pfils->m_var; // result transmitted pfils->m_var = NULL; // not to destroy the variable @@ -1292,7 +1292,7 @@ bool CBotCStack::IsOk() return (m_error == 0); } - + void CBotCStack::SetStartError( int pos ) { if ( m_error != 0) return; // does not change existing error diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index 51cae52..2929977 100644 --- a/src/CBot/CBotString.cpp +++ b/src/CBot/CBotString.cpp @@ -161,7 +161,7 @@ CBotString::CBotString(const CBotString& srcString) int CBotString::GetLength() { if (m_ptr == NULL) return 0; - return strlen( m_ptr ); + return strlen( m_ptr ); } @@ -336,7 +336,7 @@ const CBotString& CBotString::operator=(const CBotString& stringSrc) delete[] m_ptr; m_ptr = nullptr; - m_lg = stringSrc.m_lg; + m_lg = stringSrc.m_lg; if (m_lg > 0) { @@ -373,7 +373,7 @@ const CBotString& CBotString::operator=(const char ch) { delete[] m_ptr; - m_lg = 1; + m_lg = 1; m_ptr = new char[2]; m_ptr[0] = ch; @@ -389,7 +389,7 @@ const CBotString& CBotString::operator=(const char* pString) if (pString != nullptr) { - m_lg = strlen(pString); + m_lg = strlen(pString); if (m_lg != 0) { @@ -520,7 +520,7 @@ int CBotString::Compare(const char * lpsz) const char* p = m_ptr; if (lpsz == NULL) lpsz = emptyString; if (m_ptr == NULL) p = emptyString; - return strcmp(p, lpsz); // wcscmp + return strcmp(p, lpsz); // wcscmp } const char * CBotString::MapIdToString(EID id) diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp index 7c00e87..48033a3 100644 --- a/src/CBot/CBotToken.cpp +++ b/src/CBot/CBotToken.cpp @@ -472,7 +472,7 @@ void CBotToken::LoadKeyWords() { CBotString s; int i, n = 0; - + i = TokenKeyWord; //start with keywords of the language while (s.LoadString(i)) { diff --git a/src/CBot/CBotToken.h b/src/CBot/CBotToken.h index 6f11bb2..a423375 100644 --- a/src/CBot/CBotToken.h +++ b/src/CBot/CBotToken.h @@ -36,3 +36,4 @@ extern bool IsOfType(CBotToken* &p, int type1, int type2 = -1); extern bool IsOfTypeList(CBotToken* &p, int type1, ...); + diff --git a/src/CBot/CBotTwoOpExpr.cpp b/src/CBot/CBotTwoOpExpr.cpp index dfaed9f..6a0d636 100644 --- a/src/CBot/CBotTwoOpExpr.cpp +++ b/src/CBot/CBotTwoOpExpr.cpp @@ -63,10 +63,10 @@ CBotLogicExpr::~CBotLogicExpr() // acceptable type, operand // zero ends level \TODO précéance -static int ListOp[] = +static int ListOp[] = { BOOLEEN, ID_LOGIC, 0, - BOOLEEN, ID_TXT_OR, + BOOLEEN, ID_TXT_OR, BOOLEEN, ID_LOG_OR, 0, BOOLEEN, ID_TXT_AND, BOOLEEN, ID_LOG_AND, 0, @@ -76,7 +76,7 @@ static int ListOp[] = BOOLEEN|ENTIER|FLOTANT |CHAINE |POINTER - |INSTANCE,ID_EQ, + |INSTANCE,ID_EQ, BOOLEEN|ENTIER|FLOTANT |CHAINE |POINTER @@ -90,8 +90,8 @@ static int ListOp[] = ENTIER, ID_ASR, 0, ENTIER|FLOTANT|CHAINE, ID_ADD, ENTIER|FLOTANT, ID_SUB, 0, - ENTIER|FLOTANT, ID_MUL, - ENTIER|FLOTANT, ID_DIV, + ENTIER|FLOTANT, ID_MUL, + ENTIER|FLOTANT, ID_DIV, ENTIER|FLOTANT, ID_MODULO, 0, ENTIER|FLOTANT, ID_POWER, 0, 0, @@ -194,7 +194,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera if ( NULL != (inst->m_rightop = CBotTwoOpExpr::Compile( p, pStk, pOp )) ) // expression (...) right { - // there is an second operand acceptable + // there is an second operand acceptable type2 = pStk->GetTypResult(); // what kind of results? @@ -327,7 +327,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack) } - // requires a little more stack to avoid touching the result + // requires a little more stack to avoid touching the result // of which is left on the stack, precisely CBotStack* pStk2 = pStk1->AddStack(); // adds an item to the stack @@ -566,3 +566,4 @@ void t(bool t) t ? 0 : "test"; } #endif + diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp index 7b0ce7b..ad3708d 100644 --- a/src/CBot/CBotVar.cpp +++ b/src/CBot/CBotVar.cpp @@ -134,8 +134,8 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type m_LimExpr = NULL; m_pVar = NULL; m_type = type; - if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody ); - else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass ); + if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody ); + else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass ); // officel type for this object m_pClass = NULL; @@ -394,7 +394,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type) CBotVarClass* instance = new CBotVarClass(&name, type); CBotVarArray* array = new CBotVarArray(&name, type); array->SetPointer( instance ); - + CBotVar* pv = array; while (type.Eq(CBotTypArrayBody)) { @@ -414,14 +414,14 @@ CBotVar* CBotVar::Create( const char* name, int type, CBotClass* pClass) { CBotToken token( name, "" ); CBotVar* pVar = Create( &token, type ); - + if ( type == CBotTypPointer && pClass == NULL ) // pointer "null" ? return pVar; if ( type == CBotTypClass || type == CBotTypPointer || type == CBotTypIntrinsic ) { - if (pClass == NULL) + if (pClass == NULL) { delete pVar; return NULL; @@ -443,9 +443,9 @@ CBotTypResult CBotVar::GetTypResult(int mode) { CBotTypResult r = m_type; - if ( mode == 1 && m_type.Eq(CBotTypClass) ) + if ( mode == 1 && m_type.Eq(CBotTypClass) ) r.SetType(CBotTypPointer); - if ( mode == 2 && m_type.Eq(CBotTypClass) ) + if ( mode == 2 && m_type.Eq(CBotTypClass) ) r.SetType(CBotTypIntrinsic); return r; @@ -453,9 +453,9 @@ CBotTypResult CBotVar::GetTypResult(int mode) int CBotVar::GetType(int mode) { - if ( mode == 1 && m_type.Eq(CBotTypClass) ) + if ( mode == 1 && m_type.Eq(CBotTypClass) ) return CBotTypPointer; - if ( mode == 2 && m_type.Eq(CBotTypClass) ) + if ( mode == 2 && m_type.Eq(CBotTypClass) ) return CBotTypIntrinsic; return m_type.GetType(); } @@ -620,7 +620,7 @@ void CBotVar::SetVal(CBotVar* var) ASM_TRAP(); } - m_binit = var->m_binit; // copie l'état nan s'il y a + m_binit = var->m_binit; // copie l'état nan s'il y a } void CBotVar::SetStatic(bool bStatic) @@ -1293,7 +1293,7 @@ void CBotVarBoolean::XOr(CBotVar* left, CBotVar* right) void CBotVarBoolean::Not() { - m_val = m_val ? false : true ; + m_val = m_val ? false : true ; } bool CBotVarBoolean::Eq(CBotVar* left, CBotVar* right) @@ -1468,7 +1468,7 @@ void CBotVarClass::SetClass(CBotClass* pClass)//, int &nIdent) CBotInstr* p = pv->m_LimExpr; // the different formulas if ( p != NULL ) { - CBotStack* pile = CBotStack::FirstStack(); // an independent stack + CBotStack* pile = CBotStack::FirstStack(); // an independent stack int n = 0; int max[100]; @@ -1524,7 +1524,7 @@ CBotClass* CBotVarClass::GetClass() void CBotVarClass::Maj(void* pUser, bool bContinu) { -/* if (!bContinu && m_pMyThis != NULL) +/* if (!bContinu && m_pMyThis != NULL) m_pMyThis->Maj(pUser, true);*/ // an update routine exist? @@ -1671,7 +1671,7 @@ void CBotVarClass::IncrementUse() void CBotVarClass::DecrementUse() { m_CptUse--; - if ( m_CptUse == 0 ) + if ( m_CptUse == 0 ) { // if there is one, call the destructor // but only if a constructor had been called. @@ -2025,7 +2025,7 @@ bool CBotVarPointer::Save1State(FILE* pf) if (!WriteLong(pf, GetIdent())) return false; // the unique reference - // also saves the proceedings copies + // also saves the proceedings copies return SaveVar(pf, GetPointer()); } @@ -2082,7 +2082,7 @@ bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right) /////////////////////////////////////////////////////// -// management of results types +// management of results types CBotTypResult::CBotTypResult(int type) @@ -2164,7 +2164,7 @@ int CBotTypResult::GetType(int mode) const if ( m_pClass == NULL ) ASM_TRAP(); - + if ( m_type == CBotTypArrayPointer ) if ( m_pNext == NULL ) ASM_TRAP(); #endif @@ -2245,4 +2245,3 @@ CBotTypResult& return *this; } - diff --git a/src/CBot/CBotWhile.cpp b/src/CBot/CBotWhile.cpp index d24dc4b..73bcab9 100644 --- a/src/CBot/CBotWhile.cpp +++ b/src/CBot/CBotWhile.cpp @@ -112,16 +112,16 @@ bool CBotWhile :: Execute(CBotStack* &pj) // the condition is true, pass in the second mode if (!pile->SetState(1)) return false; // ready for further - + case 1: // evaluates the associated statement block - if ( m_Block != NULL && + if ( m_Block != NULL && !m_Block->Execute(pile) ) { if (pile->IfContinue(0, m_label)) continue; // if continued, will return to test return pj->BreakReturn(pile, m_label); // sends the results and releases the stack } - + // terminates if there is an error if ( !pile->IsOk() ) { @@ -130,7 +130,7 @@ bool CBotWhile :: Execute(CBotStack* &pj) // returns to the test again if (!pile->SetState(0, 0)) return false; - continue; + continue; } } @@ -140,18 +140,18 @@ void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain) CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack if ( pile == NULL ) return; - switch( pile->GetState() ) + switch( pile->GetState() ) { // there are two possible states (depending on recovery) case 0: // evaluates the condition - m_Condition->RestoreState(pile, bMain); + m_Condition->RestoreState(pile, bMain); return; - + case 1: // evaluates the associated statement block if ( m_Block != NULL ) m_Block->RestoreState(pile, bMain); return; - } + } } @@ -231,13 +231,13 @@ bool CBotDo :: Execute(CBotStack* &pj) { // there are two possible states (depending on recovery) case 0: // evaluates the associated statement block - if ( m_Block != NULL && + if ( m_Block != NULL && !m_Block->Execute(pile) ) { if (pile->IfContinue(1, m_label)) continue; // if continued, will return to test return pj->BreakReturn(pile, m_label); // sends the results and releases the stack } - + // terminates if there is an error if ( !pile->IsOk() ) { @@ -245,7 +245,7 @@ bool CBotDo :: Execute(CBotStack* &pj) } if (!pile->SetState(1)) return false; // ready for further - + case 1: // evaluates the condition if ( !m_Condition->Execute(pile) ) return false; // interrupted here ? @@ -260,7 +260,7 @@ bool CBotDo :: Execute(CBotStack* &pj) // returns to instruction block to start if (!pile->SetState(0, 0)) return false; - continue; + continue; } } @@ -277,7 +277,7 @@ void CBotDo :: RestoreState(CBotStack* &pj, bool bMain) // restores the assosiated statement's block if ( m_Block != NULL ) m_Block->RestoreState(pile, bMain); return; - + case 1: // restores the condition m_Condition->RestoreState(pile, bMain); @@ -302,9 +302,9 @@ CBotFor::CBotFor() CBotFor::~CBotFor() { - delete m_Init; - delete m_Test; - delete m_Incr; + delete m_Init; + delete m_Test; + delete m_Incr; delete m_Block; // frees the instruction block } @@ -386,7 +386,7 @@ bool CBotFor :: Execute(CBotStack* &pj) if ( m_Init != NULL && !m_Init->Execute(pile) ) return false; // interrupted here ? if (!pile->SetState(1)) return false; // ready for further - + case 1: // evaluates the condition if ( m_Test != NULL ) // no strings attached? -> True! @@ -404,10 +404,10 @@ bool CBotFor :: Execute(CBotStack* &pj) // la condition est vrai, passe à la suite if (!pile->SetState(2)) return false; // ready for further - + case 2: // evaluates the associated statement block - if ( m_Block != NULL && + if ( m_Block != NULL && !m_Block->Execute(pile) ) { if (pile->IfContinue(3, m_label)) continue; // if continued, going on to incrementation @@ -429,7 +429,7 @@ bool CBotFor :: Execute(CBotStack* &pj) // returns to the test again if (!pile->SetState(1, 0)) return false; // returns to the test - continue; + continue; } } @@ -446,7 +446,7 @@ void CBotFor :: RestoreState(CBotStack* &pj, bool bMain) // initialize if ( m_Init != NULL ) m_Init->RestoreState(pile, true); // interrupted here ! return; - + case 1: if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // variables definitions @@ -543,7 +543,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; int state = 0x7000; - + if ( bMain ) { pile = pj->RestoreStack(); @@ -615,7 +615,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack) CBotInstr* i = CBotCase::Compile( p, pStk2 ); if (i == NULL) { - delete inst; + delete inst; return pStack->Return(NULL, pStk2); } delete pStk2; @@ -623,7 +623,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack) else inst->m_Block->AddNext(i); continue; } - + if ( inst->m_Block == NULL ) { pStk->SetError(TX_NOCASE, p->GetStart()); @@ -647,7 +647,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack) } } DecLvl(); - + if ( inst->m_Block == NULL ) { pStk->SetError(TX_NOCASE, p->GetStart()); @@ -674,7 +674,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack) bool CBotSwitch :: Execute(CBotStack* &pj) { - CBotStack* pile1 = pj->AddStack(this); // adds an item to the stack + CBotStack* pile1 = pj->AddStack(this); // adds an item to the stack // if ( pile1 == EOX ) return true; CBotInstr* p = m_Block; // first expression @@ -723,7 +723,7 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; - CBotStack* pile1 = pj->RestoreStack(this); // adds an item to the stack + CBotStack* pile1 = pj->RestoreStack(this); // adds an item to the stack if ( pile1 == NULL ) return; CBotInstr* p = m_Block; // first expression @@ -912,7 +912,7 @@ CBotTry::~CBotTry() delete m_ListCatch; // frees the list delete m_Block; // frees the instruction block delete m_FinalInst; -} +} CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack) { @@ -926,7 +926,7 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack) inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk ); CBotCatch** pn = &inst->m_ListCatch; - + while (pStk->IsOk() && p->GetType() == ID_CATCH) { CBotCatch* i = CBotCatch::Compile(p, pStk); @@ -1011,7 +1011,7 @@ bool CBotTry :: Execute(CBotStack* &pj) if ( !pc->Execute(pile2) ) return false; // performs the operation if ( m_FinalInst == NULL ) return pj->Return(pile2); // ends the try - + pile1->SetState(-2); // passes final break; } @@ -1019,13 +1019,13 @@ bool CBotTry :: Execute(CBotStack* &pj) } pc = pc->m_next; } - if ( m_FinalInst != NULL && + if ( m_FinalInst != NULL && pile1->GetState() > 0 && val != 0 ) pile1->SetState(-1);// if stop then made the final if (pile1->GetState() <= -1) { // pile0->SetState(1); - + if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false; if (!pile2->IsOk()) return pj->Return(pile2); // keep this exception pile2->SetError(pile1->GetState()==-1 ? val : 0); // gives the initial error @@ -1176,7 +1176,7 @@ bool CBotCatch :: TestCatch(CBotStack* &pile, int val) var->SetValInt( pile->GetVal() == val ); pile->SetVar(var); // calls on the stack } - + return true; } diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt index fecd18e..ecde61f 100644 --- a/src/CBot/CMakeLists.txt +++ b/src/CBot/CMakeLists.txt @@ -21,3 +21,4 @@ else() ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR} RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR}) endif() + diff --git a/src/CBot/ClassFILE.cpp b/src/CBot/ClassFILE.cpp index b0f7977..6906bd4 100644 --- a/src/CBot/ClassFILE.cpp +++ b/src/CBot/ClassFILE.cpp @@ -58,7 +58,7 @@ void PrepareFilename(CBotString &filename) //DD! // gets the filename as a parameter // execution -bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { CBotString mode; @@ -239,7 +239,7 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar) return CBotTypResult(CBotTypBoolean); //DR } - + // FILE :: close method // execution @@ -291,7 +291,7 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; } FILE* pFile= (FILE*)pVar->GetValInt(); - + int res = fputs(param+CBotString("\n"), pFile); // on error throws an exception diff --git a/src/CBot/StringFunctions.cpp b/src/CBot/StringFunctions.cpp index d24c942..abdcc18 100644 --- a/src/CBot/StringFunctions.cpp +++ b/src/CBot/StringFunctions.cpp @@ -184,10 +184,10 @@ bool rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) if ( pVar->GetNext() != NULL ) { pVar = pVar->GetNext(); - + // which must be a number if ( pVar->GetType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; } - + // retrieves this number int l = pVar->GetValInt(); @@ -231,7 +231,7 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser ) // third parameter optional if ( pVar->GetNext() != NULL ) { - + pVar = pVar->GetNext(); // which must be a number if ( pVar->GetType() > CBotTypDouble ) @@ -434,3 +434,4 @@ void InitStringFunctions() CBotProgram::AddFunction("strupper", rStrUpper, cStrStr ); CBotProgram::AddFunction("strlower", rStrLower, cStrStr ); } + diff --git a/src/CBot/idees.txt b/src/CBot/idees.txt index 3966ee1..3f335da 100644 --- a/src/CBot/idees.txt +++ b/src/CBot/idees.txt @@ -39,3 +39,4 @@ the object being created with CBotVar :: Create (name, pClasse) not destroy the object when there imédiatement pointers but marked as virtually destroyed + diff --git a/src/CBot/resource.h b/src/CBot/resource.h index f0449b0..9c7e82e 100644 --- a/src/CBot/resource.h +++ b/src/CBot/resource.h @@ -176,3 +176,4 @@ enum EID #define TX_ERRWRITE 6015 #define TX_MAX 6016 + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4305df..5980d32 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,7 +28,7 @@ endif() # Additional libraries per platform if (${MXE}) # MXE requires special treatment - set(PLATFORM_LIBS ${MXE_LIBS}) + set(PLATFORM_LIBS ${MXE_LIBS}) elseif (${PLATFORM_WINDOWS}) # because it isn't included in standard linking libraries set(PLATFORM_LIBS "-lintl") @@ -229,3 +229,4 @@ target_link_libraries(colobot ${LIBS}) install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR}) set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR}) + diff --git a/src/app/README.txt b/src/app/README.txt index 92be8a6..57a2785 100644 --- a/src/app/README.txt +++ b/src/app/README.txt @@ -2,3 +2,4 @@ * \dir src/app * Main class of the application and system functions */ + diff --git a/src/app/main.cpp b/src/app/main.cpp index edb5828..4bd5daa 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -122,3 +122,4 @@ int SDL_MAIN_FUNC(int argc, char *argv[]) } } // extern "C" + diff --git a/src/app/system.cpp b/src/app/system.cpp index 743ed96..2eb68ba 100644 --- a/src/app/system.cpp +++ b/src/app/system.cpp @@ -188,12 +188,13 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte return result; } -std::string CSystemUtils::profileFileLocation() +std::string CSystemUtils::GetProfileFileLocation() { - return std::string("colobot.ini"); + return std::string("colobot.ini"); } -std::string CSystemUtils::savegameDirectoryLocation() +std::string CSystemUtils::GetSavegameDirectoryLocation() { - return std::string("savegame"); + return std::string("savegame"); } + diff --git a/src/app/system.h b/src/app/system.h index 6ae05d6..d22a519 100644 --- a/src/app/system.h +++ b/src/app/system.h @@ -131,10 +131,10 @@ public: virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0; //! Returns the profile (colobot.ini) file location - virtual std::string profileFileLocation(); + virtual std::string GetProfileFileLocation(); //! Returns the savegame directory location - virtual std::string savegameDirectoryLocation(); + virtual std::string GetSavegameDirectoryLocation(); }; //! Global function to get CSystemUtils instance @@ -142,3 +142,4 @@ inline CSystemUtils* GetSystemUtils() { return CSystemUtils::GetInstancePointer(); } + diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp index 01dd850..492af7d 100644 --- a/src/app/system_linux.cpp +++ b/src/app/system_linux.cpp @@ -95,9 +95,9 @@ long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemT (after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll; } -std::string CSystemUtilsLinux::profileFileLocation() +std::string CSystemUtilsLinux::GetProfileFileLocation() { - std::string m_profileFile; + std::string profileFile; // Determine profileFile according to XDG Base Directory Specification char* envXDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME"); @@ -106,25 +106,25 @@ std::string CSystemUtilsLinux::profileFileLocation() char *envHOME = getenv("HOME"); if (envHOME == NULL) { - m_profileFile = "colobot.ini"; + profileFile = "colobot.ini"; } else { - m_profileFile = std::string(envHOME) + "/.config/colobot.ini"; + profileFile = std::string(envHOME) + "/.config/colobot.ini"; } } else { - m_profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini"; + profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini"; } - GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str()); + GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str()); - return m_profileFile; + return profileFile; } -std::string CSystemUtilsLinux::savegameDirectoryLocation() +std::string CSystemUtilsLinux::GetSavegameDirectoryLocation() { - std::string m_savegameDir; + std::string savegameDir; // Determine savegame dir according to XDG Base Directory Specification char *envXDG_DATA_HOME = getenv("XDG_CONFIG_DATA"); @@ -133,18 +133,19 @@ std::string CSystemUtilsLinux::savegameDirectoryLocation() char *envHOME = getenv("HOME"); if (envHOME == NULL) { - m_savegameDir = "/tmp/colobot-savegame"; + savegameDir = "/tmp/colobot-savegame"; } else - { - m_savegameDir = std::string(envHOME) + "/.local/share/colobot"; + { + savegameDir = std::string(envHOME) + "/.local/share/colobot"; } } else { - m_savegameDir = std::string(envXDG_DATA_HOME) + "/colobot"; + savegameDir = std::string(envXDG_DATA_HOME) + "/colobot"; } - GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str()); + GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str()); - return m_savegameDir; + return savegameDir; } + diff --git a/src/app/system_linux.h b/src/app/system_linux.h index a9a5a52..212d840 100644 --- a/src/app/system_linux.h +++ b/src/app/system_linux.h @@ -46,9 +46,10 @@ public: virtual long long GetTimeStampExactResolution() override; virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override; - virtual std::string profileFileLocation() override; - virtual std::string savegameDirectoryLocation() override; + virtual std::string GetProfileFileLocation() override; + virtual std::string GetSavegameDirectoryLocation() override; private: bool m_zenityAvailable; }; + diff --git a/src/app/system_other.cpp b/src/app/system_other.cpp index 9fc1f95..da81a6d 100644 --- a/src/app/system_other.cpp +++ b/src/app/system_other.cpp @@ -37,3 +37,4 @@ long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, Sys { return (after->sdlTicks - before->sdlTicks) * 1000000ll; } + diff --git a/src/app/system_other.h b/src/app/system_other.h index bf16c80..b10a326 100644 --- a/src/app/system_other.h +++ b/src/app/system_other.h @@ -46,3 +46,4 @@ public: virtual long long GetTimeStampExactResolution() override; virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override; }; + diff --git a/src/app/system_windows.cpp b/src/app/system_windows.cpp index 870683f..f48d4e0 100644 --- a/src/app/system_windows.cpp +++ b/src/app/system_windows.cpp @@ -111,38 +111,39 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str) } -std::string CSystemUtilsWindows::profileFileLocation() +std::string CSystemUtilsWindows::GetProfileFileLocation() { - std::string m_profileFile; + std::string profileFile; char* envUSERPROFILE = getenv("USERPROFILE"); if (envUSERPROFILE == NULL) { - m_profileFile = "colobot.ini"; + profileFile = "colobot.ini"; } else { - m_profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini"; + profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini"; } - GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str()); + GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str()); - return m_profileFile; + return profileFile; } -std::string CSystemUtilsWindows::savegameDirectoryLocation() +std::string CSystemUtilsWindows::GetSavegameDirectoryLocation() { - std::string m_savegameDir; + std::string savegameDir; char* envUSERPROFILE = getenv("USERPROFILE"); if (envUSERPROFILE == NULL) { - m_savegameDir = "savegame"; + savegameDir = "savegame"; } else { - m_savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame"; + savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame"; } - GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str()); + GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str()); + + return savegameDir; +} - return m_savegameDir; -} \ No newline at end of file diff --git a/src/app/system_windows.h b/src/app/system_windows.h index 88e7507..fbc71a1 100644 --- a/src/app/system_windows.h +++ b/src/app/system_windows.h @@ -44,8 +44,8 @@ public: virtual long long GetTimeStampExactResolution() override; virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override; - virtual std::string profileFileLocation() override; - virtual std::string savegameDirectoryLocation() override; + virtual std::string GetProfileFileLocation() override; + virtual std::string GetSavegameDirectoryLocation() override; private: std::string UTF8_Encode(const std::wstring &wstr); @@ -54,3 +54,4 @@ private: protected: long long m_counterFrequency; }; + diff --git a/src/common/README.txt b/src/common/README.txt index 25c9fbf..1fc21f1 100644 --- a/src/common/README.txt +++ b/src/common/README.txt @@ -2,3 +2,4 @@ * \dir src/common * \brief Structs and utils shared throughout the application */ + diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake index d5a03b4..76b37b5 100644 --- a/src/common/config.h.cmake +++ b/src/common/config.h.cmake @@ -23,3 +23,4 @@ #define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@" #define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@" + diff --git a/src/common/event.h b/src/common/event.h index b9c6623..97b798a 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -779,3 +779,4 @@ protected: int m_tail; int m_total; }; + diff --git a/src/common/global.h b/src/common/global.h index 716b711..a322057 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -297,3 +297,4 @@ extern int g_build; // constructible buildings extern int g_researchDone; // research done extern long g_researchEnable; // research available extern float g_unit; // conversion factor + diff --git a/src/common/image.cpp b/src/common/image.cpp index fd55217..a9587ef 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -110,7 +110,8 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf) return false; } - if (setjmp(png_jmpbuf(png_ptr))) { + if (setjmp(png_jmpbuf(png_ptr))) + { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); return false; @@ -396,3 +397,4 @@ bool CImage::SavePNG(const std::string& fileName) return true; } + diff --git a/src/common/image.h b/src/common/image.h index f0b50a3..44aedf1 100644 --- a/src/common/image.h +++ b/src/common/image.h @@ -112,3 +112,4 @@ private: //! Image data ImageData* m_data; }; + diff --git a/src/common/iman.cpp b/src/common/iman.cpp index e1400fd..88fbb9b 100644 --- a/src/common/iman.cpp +++ b/src/common/iman.cpp @@ -111,3 +111,4 @@ void CInstanceManager::Compress(ManagedClassType classType) } m_table[classType].usedCount = j; } + diff --git a/src/common/iman.h b/src/common/iman.h index faabd0c..bfa2204 100644 --- a/src/common/iman.h +++ b/src/common/iman.h @@ -93,4 +93,3 @@ protected: ManagedClassInstances m_table[CLASS_MAX]; }; - diff --git a/src/common/ioutils.h b/src/common/ioutils.h index 9a94617..823b720 100644 --- a/src/common/ioutils.h +++ b/src/common/ioutils.h @@ -146,3 +146,4 @@ std::string ReadBinaryString(std::istream &istr) } }; // namespace IOUtils + diff --git a/src/common/key.h b/src/common/key.h index 84ee618..82b3fbd 100644 --- a/src/common/key.h +++ b/src/common/key.h @@ -61,3 +61,4 @@ enum VirtualKmod //! Special value for invalid key bindings const unsigned int KEY_INVALID = SDLK_LAST + 1000; + diff --git a/src/common/logger.h b/src/common/logger.h index 769f548..83a915c 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -125,6 +125,8 @@ private: //! Global function to get Logger instance -inline CLogger* GetLogger() { +inline CLogger* GetLogger() +{ return CLogger::GetInstancePointer(); } + diff --git a/src/common/misc.h b/src/common/misc.h index e2ddc44..bcebf76 100644 --- a/src/common/misc.h +++ b/src/common/misc.h @@ -31,3 +31,4 @@ extern void TimeToAscii(time_t time, char *buffer); extern bool CopyFileListToTemp(char* filename, int* list, int total); extern void AddExt(char* filename, const char* ext); + diff --git a/src/common/profile.cpp b/src/common/profile.cpp index 0bc40cf..c6af6cc 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -47,8 +47,9 @@ bool CProfile::InitCurrentDirectory() { try { + // TODO: NDEBUG should be replaced with something like BUILD_TYPE == "DEBUG"/"RELEASE" #ifdef NDEBUG - bp::ini_parser::read_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); + bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); #else bp::ini_parser::read_ini("colobot.ini", m_propertyTree); #endif @@ -68,7 +69,7 @@ bool CProfile::SaveCurrentDirectory() try { #ifdef NDEBUG - bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); + bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); #else bp::ini_parser::write_ini("colobot.ini", m_propertyTree); #endif @@ -209,34 +210,39 @@ std::string CProfile::GetUserBasedPath(std::string dir, std::string default_dir) { std::string path = dir; boost::replace_all(path, "\\", "/"); - if (dir.find("/") == std::string::npos) { + if (dir.find("/") == std::string::npos) + { path = default_dir + "/" + dir; } - - if (m_userDirectory.length() > 0) { + + if (m_userDirectory.length() > 0) + { boost::replace_all(path, "%user%", m_userDirectory); - } else { + } + else + { boost::replace_all(path, "%user%", default_dir); } - + return fs::path(path).make_preferred().string(); } - - + + bool CProfile::CopyFileToTemp(std::string filename) { std::string src, dst; std::string tmp_user_dir = m_userDirectory; - + src = GetUserBasedPath(filename, "textures"); SetUserDir("temp"); dst = GetUserBasedPath(filename, "textures"); SetUserDir(tmp_user_dir); - + fs::create_directory(fs::path(dst).parent_path().make_preferred().string()); fs::copy_file(src, dst, fs::copy_option::overwrite_if_exists); - if (fs::exists(dst)) { - return true; + if (fs::exists(dst)) + { + return true; } return false; diff --git a/src/common/profile.h b/src/common/profile.h index ba797e9..8ea2aee 100644 --- a/src/common/profile.h +++ b/src/common/profile.h @@ -41,101 +41,103 @@ namespace fs = boost::filesystem; */ class CProfile : public CSingleton { - public: - CProfile(); - ~CProfile(); - - /** Loads colobot.ini from current directory - * \return return true on success - */ - bool InitCurrentDirectory(); - - /** Saves colobot.ini to current directory - * \return return true on success - */ - bool SaveCurrentDirectory(); - - /** Sets string value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool SetLocalProfileString(std::string section, std::string key, std::string value); - - /** Gets string value in section under specified key - * \param section - * \param key - * \param buffer - * \return return true on success - */ - bool GetLocalProfileString(std::string section, std::string key, std::string& buffer); - - /** Sets int value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool SetLocalProfileInt(std::string section, std::string key, int value); - - /** Gets int value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool GetLocalProfileInt(std::string section, std::string key, int &value); - - /** Sets float value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool SetLocalProfileFloat(std::string section, std::string key, float value); - - /** Gets float value in section under specified key - * \param section - * \param key - * \param value - * \return return true on success - */ - bool GetLocalProfileFloat(std::string section, std::string key, float &value); - - /** Gets all values in section under specified key - * \param section - * \param key - * \return vector of values - */ - std::vector< std::string > GetLocalProfileSection(std::string section, std::string key); - - /** Sets current user directory - * \param dir - */ - void SetUserDir(std::string dir); - - /** Returns path based on current user. Replaces %user% in path with current user dir or - * uses default_dir param if no user dir is specified - * \param dir - * \param default_dir - * \return path - */ - std::string GetUserBasedPath(std::string dir, std::string default_dir); - - /** opy a file into the temporary folder. - * \param filename - * \return true on success - */ - bool CopyFileToTemp(std::string filename); - - private: - boost::property_tree::ptree m_propertyTree; - bool m_profileNeedSave; - std::string m_userDirectory; +public: + CProfile(); + ~CProfile(); + + /** Loads colobot.ini from current directory + * \return return true on success + */ + bool InitCurrentDirectory(); + + /** Saves colobot.ini to current directory + * \return return true on success + */ + bool SaveCurrentDirectory(); + + /** Sets string value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool SetLocalProfileString(std::string section, std::string key, std::string value); + + /** Gets string value in section under specified key + * \param section + * \param key + * \param buffer + * \return return true on success + */ + bool GetLocalProfileString(std::string section, std::string key, std::string& buffer); + + /** Sets int value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool SetLocalProfileInt(std::string section, std::string key, int value); + + /** Gets int value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool GetLocalProfileInt(std::string section, std::string key, int &value); + + /** Sets float value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool SetLocalProfileFloat(std::string section, std::string key, float value); + + /** Gets float value in section under specified key + * \param section + * \param key + * \param value + * \return return true on success + */ + bool GetLocalProfileFloat(std::string section, std::string key, float &value); + + /** Gets all values in section under specified key + * \param section + * \param key + * \return vector of values + */ + std::vector< std::string > GetLocalProfileSection(std::string section, std::string key); + + /** Sets current user directory + * \param dir + */ + void SetUserDir(std::string dir); + + /** Returns path based on current user. Replaces %user% in path with current user dir or + * uses default_dir param if no user dir is specified + * \param dir + * \param default_dir + * \return path + */ + std::string GetUserBasedPath(std::string dir, std::string default_dir); + + /** opy a file into the temporary folder. + * \param filename + * \return true on success + */ + bool CopyFileToTemp(std::string filename); + +private: + boost::property_tree::ptree m_propertyTree; + bool m_profileNeedSave; + std::string m_userDirectory; }; //! Global function to get profile instance -inline CProfile & GetProfile() { +inline CProfile & GetProfile() +{ return *CProfile::GetInstancePointer(); } + diff --git a/src/common/restext.cpp b/src/common/restext.cpp index ac40dad..ead8ef3 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -920,3 +920,4 @@ bool GetResource(ResType type, int num, char* text) PutKeyName(text, tmpl); return true; } + diff --git a/src/common/restext.h b/src/common/restext.h index 1c99473..e4659e2 100644 --- a/src/common/restext.h +++ b/src/common/restext.h @@ -158,3 +158,4 @@ void InitializeRestext(); void SetGlobalGamerName(std::string name); bool SearchKey(const char *cmd, InputSlot& slot); bool GetResource(ResType type, int num, char* text); + diff --git a/src/common/singleton.h b/src/common/singleton.h index 25e1648..841759d 100644 --- a/src/common/singleton.h +++ b/src/common/singleton.h @@ -74,3 +74,4 @@ private: CSingleton& operator=(const CSingleton &); CSingleton(const CSingleton &); }; + diff --git a/src/common/stringutils.cpp b/src/common/stringutils.cpp index db486f0..953abba 100644 --- a/src/common/stringutils.cpp +++ b/src/common/stringutils.cpp @@ -142,3 +142,4 @@ size_t StrUtils::Utf8StringLength(const std::string &str) } return result; } + diff --git a/src/common/stringutils.h b/src/common/stringutils.h index 064351d..c60bfb0 100644 --- a/src/common/stringutils.h +++ b/src/common/stringutils.h @@ -78,3 +78,4 @@ int Utf8CharSizeAt(const std::string &str, unsigned int pos); size_t Utf8StringLength(const std::string &str); }; // namespace StrUtil + diff --git a/src/desktop/.gitignore b/src/desktop/.gitignore index bade6f3..0e770f7 100644 --- a/src/desktop/.gitignore +++ b/src/desktop/.gitignore @@ -1 +1,2 @@ lang/ + diff --git a/src/desktop/CMakeLists.txt b/src/desktop/CMakeLists.txt index 9a00dd4..23f2280 100644 --- a/src/desktop/CMakeLists.txt +++ b/src/desktop/CMakeLists.txt @@ -3,72 +3,72 @@ cmake_minimum_required(VERSION 2.8) # Install Desktop Entry file set(COLOBOT_DESKTOP_FILE colobot.desktop) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE} - COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE} - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "Build ${COLOBOT_DESKTOP_FILE}" - ) + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE} + COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Build ${COLOBOT_DESKTOP_FILE}" + ) add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE} + FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/ - ) + ) # Install Icon set(COLOBOT_ICON_FILE colobot.svg) install( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE} - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/ - ) + FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE} + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/ + ) # Render SVG icon in various sizes find_program(RSVG_CONVERT rsvg-convert) if(RSVG_CONVERT) - foreach(PNGSIZE "48" "32" "16") - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}) - add_custom_target(resize_icon_${PNGSIZE} ALL - COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE} - > ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png - ) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/ - ) - endforeach() + foreach(PNGSIZE "48" "32" "16") + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}) + add_custom_target(resize_icon_${PNGSIZE} ALL + COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE} + > ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png + ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/ + ) + endforeach() endif() # Create manpage from pod-formatted file find_program(POD2MAN pod2man) if(POD2MAN AND (NOT MSYS)) - set(COLOBOT_MANPAGE_SECTION 6) + set(COLOBOT_MANPAGE_SECTION 6) macro(podman) - cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN}) - if(PM_LOCALE) - # This copes with the fact that english has no "/LANG" in the paths and filenames. - set(SLASHLOCALE /${PM_LOCALE}) - endif() - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} + cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN}) + if(PM_LOCALE) + # This copes with the fact that english has no "/LANG" in the paths and filenames. + set(SLASHLOCALE /${PM_LOCALE}) + endif() + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE} COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION} --center="Colobot" --stderr --utf8 --release="${COLOBOT_VERSION_FULL}" ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE} ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} - COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage" + COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage" ) - add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}) + add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ ) - add_dependencies(man man${PM_LOCALE}) - endmacro() + add_dependencies(man man${PM_LOCALE}) + endmacro() - # Create the english manpage - podman(PODFILE colobot.pod) + # Create the english manpage + podman(PODFILE colobot.pod) endif() @@ -76,22 +76,23 @@ endif() find_program(PO4A po4a) if(PO4A) - add_custom_target(desktop_po4a - COMMAND ${PO4A} po4a.cfg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - add_dependencies(desktopfile desktop_po4a) + add_custom_target(desktop_po4a + COMMAND ${PO4A} po4a.cfg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + add_dependencies(desktopfile desktop_po4a) - if(POD2MAN) - add_custom_target(man_po4a - COMMAND ${PO4A} po4a.cfg - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - add_dependencies(man man_po4a) - file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po) - string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO}) - foreach(LOCALE ${LINGUAS}) - podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE}) - endforeach() - endif() + if(POD2MAN) + add_custom_target(man_po4a + COMMAND ${PO4A} po4a.cfg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + add_dependencies(man man_po4a) + file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po) + string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO}) + foreach(LOCALE ${LINGUAS}) + podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE}) + endforeach() + endif() endif() + diff --git a/src/desktop/colobot.desktop.in b/src/desktop/colobot.desktop.in index 9b09803..9b48d87 100644 --- a/src/desktop/colobot.desktop.in +++ b/src/desktop/colobot.desktop.in @@ -4,3 +4,4 @@ Type=Application Exec=colobot Icon=colobot Categories=Education;Robotics;Game;AdventureGame;StrategyGame; + diff --git a/src/desktop/colobot.ini b/src/desktop/colobot.ini index 136e008..27193df 100644 --- a/src/desktop/colobot.ini +++ b/src/desktop/colobot.ini @@ -1,3 +1,4 @@ Name="Colobot" GenericName="Game to learn programming" Comment="Colonize with bots" + diff --git a/src/desktop/colobot.pod b/src/desktop/colobot.pod index ae67e72..6a25f70 100644 --- a/src/desktop/colobot.pod +++ b/src/desktop/colobot.pod @@ -45,3 +45,4 @@ Set language. Note that you can also fill the B environment variable. =head1 AUTHOR This manpage was written by Didier Raboud >. + diff --git a/src/desktop/colobot.svg b/src/desktop/colobot.svg index 85a0545..ef5949f 100644 --- a/src/desktop/colobot.svg +++ b/src/desktop/colobot.svg @@ -236,3 +236,4 @@ + diff --git a/src/desktop/create_desktop_file.sh b/src/desktop/create_desktop_file.sh index e0f120b..8f3d15b 100755 --- a/src/desktop/create_desktop_file.sh +++ b/src/desktop/create_desktop_file.sh @@ -11,8 +11,8 @@ cat colobot.desktop.in linguas=$([ ! -d lang ] || ( cd lang ; ls)); for type in Name GenericName Comment; do - egrep "^$type=" $fname | sed -e "s/^$type=\"\(.*\)\"$/$type=\1/g" - for l in $linguas; do - egrep "^$type=" lang/$l/$fname | sed -e "s/^$type=\"\(.*\)\"$/$type[$l]=\1/g" - done + egrep "^$type=" $fname | sed -e "s/^$type=\"\(.*\)\"$/$type=\1/g" + for l in $linguas; do + egrep "^$type=" lang/$l/$fname | sed -e "s/^$type=\"\(.*\)\"$/$type[$l]=\1/g" + done done diff --git a/src/desktop/po/colobot-desktop.pot b/src/desktop/po/colobot-desktop.pot index 94eb85a..ac6bbd2 100644 --- a/src/desktop/po/colobot-desktop.pot +++ b/src/desktop/po/colobot-desktop.pot @@ -132,3 +132,4 @@ msgstr "" #: colobot.pod:47 msgid "This manpage was written by Didier Raboud >." msgstr "" + diff --git a/src/desktop/po4a.cfg b/src/desktop/po4a.cfg index c251959..881929d 100644 --- a/src/desktop/po4a.cfg +++ b/src/desktop/po4a.cfg @@ -2,3 +2,4 @@ [type:ini] colobot.ini $lang:lang/$lang/colobot.ini [type:pod] colobot.pod $lang:lang/$lang/colobot.pod + diff --git a/src/graphics/README.txt b/src/graphics/README.txt index 1cb91ba..f9ec2ae 100644 --- a/src/graphics/README.txt +++ b/src/graphics/README.txt @@ -10,3 +10,4 @@ * This namespace was created to avoid clashing with old code, but now it still serves, * defining a border between pure graphics engine and other parts of application. */ + diff --git a/src/graphics/core/README.txt b/src/graphics/core/README.txt index ca3768c..056441d 100644 --- a/src/graphics/core/README.txt +++ b/src/graphics/core/README.txt @@ -4,4 +4,5 @@ * * Core types, enums, structs and CDevice abstract class that define * the abstract graphics device used in graphics engine - */ \ No newline at end of file + */ + diff --git a/src/graphics/core/color.cpp b/src/graphics/core/color.cpp index 1f9d7a5..f0b74f8 100644 --- a/src/graphics/core/color.cpp +++ b/src/graphics/core/color.cpp @@ -106,3 +106,4 @@ Color HSV2RGB(ColorHSV color) } // namespace Gfx + diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h index 5d059e5..3546611 100644 --- a/src/graphics/core/color.h +++ b/src/graphics/core/color.h @@ -154,3 +154,4 @@ Color HSV2RGB(ColorHSV color); } // namespace Gfx + diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index b714358..38bc463 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -401,3 +401,4 @@ public: } // namespace Gfx + diff --git a/src/graphics/core/light.h b/src/graphics/core/light.h index 28733c1..923d0e9 100644 --- a/src/graphics/core/light.h +++ b/src/graphics/core/light.h @@ -98,3 +98,4 @@ struct Light } // namespace Gfx + diff --git a/src/graphics/core/material.h b/src/graphics/core/material.h index 07782d5..e0bfaff 100644 --- a/src/graphics/core/material.h +++ b/src/graphics/core/material.h @@ -60,3 +60,4 @@ struct Material } // namespace Gfx + diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h index 31e3774..0702428 100644 --- a/src/graphics/core/texture.h +++ b/src/graphics/core/texture.h @@ -269,3 +269,4 @@ struct Texture } // namespace Gfx + diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h index 66e1503..c3a657a 100644 --- a/src/graphics/core/vertex.h +++ b/src/graphics/core/vertex.h @@ -140,3 +140,4 @@ struct VertexTex2 } // namespace Gfx + diff --git a/src/graphics/d3d/README.txt b/src/graphics/d3d/README.txt index 0fe7db6..4f96f27 100644 --- a/src/graphics/d3d/README.txt +++ b/src/graphics/d3d/README.txt @@ -1 +1,2 @@ Possible future DirectX implementation of graphics engine + diff --git a/src/graphics/engine/README.txt b/src/graphics/engine/README.txt index 05d2d76..fbf45fd 100644 --- a/src/graphics/engine/README.txt +++ b/src/graphics/engine/README.txt @@ -7,3 +7,4 @@ * * Graphics operations are done on abstract interface from src/graphics/core */ + diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp index f65a59a..f0c379c 100644 --- a/src/graphics/engine/camera.cpp +++ b/src/graphics/engine/camera.cpp @@ -1676,3 +1676,4 @@ Math::Vector CCamera::ExcludeObject(Math::Vector eye, Math::Vector lookat, } + diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h index 0ffc2c2..6d94dad 100644 --- a/src/graphics/engine/camera.h +++ b/src/graphics/engine/camera.h @@ -128,8 +128,7 @@ enum CameraOverEffect ... */ class CCamera { - - public: +public: CCamera(); ~CCamera(); @@ -391,3 +390,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/cloud.cpp b/src/graphics/engine/cloud.cpp index d9ebf5a..74083af 100644 --- a/src/graphics/engine/cloud.cpp +++ b/src/graphics/engine/cloud.cpp @@ -270,3 +270,4 @@ bool CCloud::GetEnabled() } // namespace Gfx + diff --git a/src/graphics/engine/cloud.h b/src/graphics/engine/cloud.h index 8f644f0..8e820c7 100644 --- a/src/graphics/engine/cloud.h +++ b/src/graphics/engine/cloud.h @@ -140,3 +140,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 3959c02..0faddbb 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -4332,3 +4332,4 @@ void CEngine::DrawStats() } // namespace Gfx + diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index af8cf6a..8763a4e 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -1431,3 +1431,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index 16c84ea..cbb8509 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -465,3 +465,4 @@ bool CLightManager::LightsComparator::operator()(const DynamicLight& left, const } } // namespace Gfx + diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h index ab66524..171299c 100644 --- a/src/graphics/engine/lightman.h +++ b/src/graphics/engine/lightman.h @@ -216,3 +216,4 @@ protected: }; }; // namespace Gfx + diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp index 5fdae51..4395eec 100644 --- a/src/graphics/engine/lightning.cpp +++ b/src/graphics/engine/lightning.cpp @@ -418,3 +418,4 @@ CObject* CLightning::SearchObject(Math::Vector pos) } // namespace Gfx + diff --git a/src/graphics/engine/lightning.h b/src/graphics/engine/lightning.h index 7809a6c..1b1d339 100644 --- a/src/graphics/engine/lightning.h +++ b/src/graphics/engine/lightning.h @@ -107,3 +107,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/modelfile.cpp b/src/graphics/engine/modelfile.cpp index f6d7a7b..8383b15 100644 --- a/src/graphics/engine/modelfile.cpp +++ b/src/graphics/engine/modelfile.cpp @@ -1199,3 +1199,4 @@ int CModelFile::GetTriangleCount() } // namespace Gfx + diff --git a/src/graphics/engine/modelfile.h b/src/graphics/engine/modelfile.h index 3a702cb..9a01f78 100644 --- a/src/graphics/engine/modelfile.h +++ b/src/graphics/engine/modelfile.h @@ -150,3 +150,4 @@ protected: }; }; // namespace Gfx + diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index 238a7d9..8397e15 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -201,3 +201,4 @@ float CModelManager::GetHeight(std::vector& triangles, Math::Vect } + diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h index a7f9805..26ee130 100644 --- a/src/graphics/engine/modelmanager.h +++ b/src/graphics/engine/modelmanager.h @@ -99,3 +99,4 @@ private: }; } // namespace Gfx + diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index d15ee3b..10b945e 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -3917,3 +3917,4 @@ bool CParticle::WriteWheelTrace(const char *filename, int width, int height, } } // namespace Gfx + diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h index 708a04d..7fb24a1 100644 --- a/src/graphics/engine/particle.h +++ b/src/graphics/engine/particle.h @@ -395,3 +395,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/planet.cpp b/src/graphics/engine/planet.cpp index 49bcb4c..0c96f63 100644 --- a/src/graphics/engine/planet.cpp +++ b/src/graphics/engine/planet.cpp @@ -185,3 +185,4 @@ int CPlanet::GetMode() } // namespace Gfx + diff --git a/src/graphics/engine/planet.h b/src/graphics/engine/planet.h index 3762e1d..58d3aeb 100644 --- a/src/graphics/engine/planet.h +++ b/src/graphics/engine/planet.h @@ -118,3 +118,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index 0a82408..975a211 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -2399,3 +2399,4 @@ void CPyro::LightOperFrame(float rTime) } // namespace Gfx + diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h index 9548a07..98b9a1b 100644 --- a/src/graphics/engine/pyro.h +++ b/src/graphics/engine/pyro.h @@ -219,3 +219,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp index c2a7855..4fe3057 100644 --- a/src/graphics/engine/terrain.cpp +++ b/src/graphics/engine/terrain.cpp @@ -1801,3 +1801,4 @@ float CTerrain::GetFlyingLimit(Math::Vector pos, bool noLimit) } // namespace Gfx + diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h index 1fa8dec..e2317c4 100644 --- a/src/graphics/engine/terrain.h +++ b/src/graphics/engine/terrain.h @@ -418,3 +418,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/test/CMakeLists.txt b/src/graphics/engine/test/CMakeLists.txt index afaa86a..134ed2a 100644 --- a/src/graphics/engine/test/CMakeLists.txt +++ b/src/graphics/engine/test/CMakeLists.txt @@ -25,3 +25,4 @@ add_executable(modelfile_test ${MODELFILE_TEST_SOURCES}) target_link_libraries(modelfile_test gtest) add_test(modelfile_test modelfile_test) + diff --git a/src/graphics/engine/test/modelfile_test.cpp b/src/graphics/engine/test/modelfile_test.cpp index e7078a9..1ca7f0a 100644 --- a/src/graphics/engine/test/modelfile_test.cpp +++ b/src/graphics/engine/test/modelfile_test.cpp @@ -260,3 +260,4 @@ int main(int argc, char **argv) ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } + diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 0f0122d..9bc8bd0 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -913,3 +913,4 @@ CharTexture CText::CreateCharTexture(UTF8Char ch, CachedFont* font) } // namespace Gfx + diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h index b19a224..3abb8b7 100644 --- a/src/graphics/engine/text.h +++ b/src/graphics/engine/text.h @@ -342,3 +342,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/engine/water.cpp b/src/graphics/engine/water.cpp index d90652b..d1f8d29 100644 --- a/src/graphics/engine/water.cpp +++ b/src/graphics/engine/water.cpp @@ -628,3 +628,4 @@ void CWater::AdjustEye(Math::Vector &eye) } // namespace Gfx + diff --git a/src/graphics/engine/water.h b/src/graphics/engine/water.h index bb113e0..5e9f4b2 100644 --- a/src/graphics/engine/water.h +++ b/src/graphics/engine/water.h @@ -204,3 +204,4 @@ protected: } // namespace Gfx + diff --git a/src/graphics/opengl/README.txt b/src/graphics/opengl/README.txt index c62166b..1a6bedd 100644 --- a/src/graphics/opengl/README.txt +++ b/src/graphics/opengl/README.txt @@ -5,3 +5,4 @@ * Contains the concrete implementation using OpenGL of abstract CDevice class * from src/graphics/core */ + diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 9d5abc3..4bfc542 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -1689,3 +1689,4 @@ FillMode CGLDevice::GetFillMode() } // namespace Gfx + diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h index 6f956cf..004a18b 100644 --- a/src/graphics/opengl/gldevice.h +++ b/src/graphics/opengl/gldevice.h @@ -257,3 +257,4 @@ private: } // namespace Gfx + diff --git a/src/math/README.txt b/src/math/README.txt index 26069aa..fcc204f 100644 --- a/src/math/README.txt +++ b/src/math/README.txt @@ -10,3 +10,4 @@ * This namespace was created to avoid clashing with old code, but now it still serves, * defining a border between math and non-math-related code. */ + diff --git a/src/math/all.h b/src/math/all.h index 10c17a9..7d716c8 100644 --- a/src/math/all.h +++ b/src/math/all.h @@ -28,3 +28,4 @@ #include "math/vector.h" #include "math/matrix.h" #include "math/geometry.h" + diff --git a/src/math/const.h b/src/math/const.h index 8318b7a..fee635e 100644 --- a/src/math/const.h +++ b/src/math/const.h @@ -53,3 +53,4 @@ const float LOG_2 = log(2.0f); } // namespace Math + diff --git a/src/math/func.h b/src/math/func.h index 83e8ca4..98111c5 100644 --- a/src/math/func.h +++ b/src/math/func.h @@ -263,3 +263,4 @@ inline float Bounce(float progress, float middle = 0.3f, float bounce = 0.4f) } // namespace Math + diff --git a/src/math/geometry.h b/src/math/geometry.h index 23c149c..9dcb447 100644 --- a/src/math/geometry.h +++ b/src/math/geometry.h @@ -643,3 +643,4 @@ inline Math::Vector RotateView(Math::Vector center, float angleH, float angleV, } // namespace Math + diff --git a/src/math/intpoint.h b/src/math/intpoint.h index 010b0fb..872e614 100644 --- a/src/math/intpoint.h +++ b/src/math/intpoint.h @@ -59,3 +59,4 @@ struct IntPoint } // namespace Math + diff --git a/src/math/matrix.h b/src/math/matrix.h index e0cf492..67ccb48 100644 --- a/src/math/matrix.h +++ b/src/math/matrix.h @@ -462,3 +462,4 @@ inline Math::Vector MatrixVectorMultiply(const Math::Matrix &m, const Math::Vect } // namespace Math + diff --git a/src/math/point.h b/src/math/point.h index 456fe1e..65de94c 100644 --- a/src/math/point.h +++ b/src/math/point.h @@ -191,3 +191,4 @@ inline float Distance(const Point &a, const Point &b) } // namespace Math + diff --git a/src/math/vector.h b/src/math/vector.h index 73e8e44..38886d0 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -281,3 +281,4 @@ inline Vector Clamp(const Vector &vec, const Vector &min, const Vector &max) } // namespace Math + diff --git a/src/object/README.txt b/src/object/README.txt index fe946db..4e21620 100644 --- a/src/object/README.txt +++ b/src/object/README.txt @@ -5,3 +5,4 @@ * Contains the main class of game engine - CRobotMain and the various in-game objects: * CObject and related auto, motion and task subclasses. */ + diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h index e27804c..4a430ce 100644 --- a/src/object/auto/auto.h +++ b/src/object/auto/auto.h @@ -31,7 +31,7 @@ namespace Ui { class CDisplayText; class CInterface; class CWindow; -} /* Ui */ +} /* Ui */ namespace Gfx { @@ -44,7 +44,7 @@ class CCloud; class CCamera; class CPlanet; class CLightning; -} /* Gfx */ +} /* Gfx */ class CAuto diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp index 260edcb..b613406 100644 --- a/src/object/auto/autoderrick.cpp +++ b/src/object/auto/autoderrick.cpp @@ -589,4 +589,3 @@ Error CAutoDerrick::GetError() return ERR_OK; } - diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index 8e3fa98..fdaebc0 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -82,8 +82,10 @@ Error CAutoDestroyer::StartAction(int param) scrap = SearchPlastic(); if ( scrap == nullptr ) return ERR_DESTROY_NOTFOUND; - else { - if ( m_phase == ADEP_WAIT ) { + else + { + if ( m_phase == ADEP_WAIT ) + { scrap->SetLock(true); // usable waste //? scrap->SetTruck(m_object); // usable waste @@ -93,7 +95,8 @@ Error CAutoDestroyer::StartAction(int param) m_progress = 0.0f; m_speed = 1.0f/1.0f; m_bExplo = false; - } else + } + else return ERR_GENERIC; } return ERR_OK; @@ -147,7 +150,8 @@ bool CAutoDestroyer::EventProcess(const Event &event) m_phase = ADEP_WAIT; // still waiting ... m_progress = 0.0f; m_speed = 1.0f/0.5f; - if (m_main->GetSelect() == m_object) { + if (m_main->GetSelect() == m_object) + { scrap = SearchPlastic(); if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); } @@ -403,3 +407,4 @@ void CAutoDestroyer::EnableInterface(Ui::CWindow *pw, EventType event, bool bSta control->SetState(Ui::STATE_ENABLE, bState); } + diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp index a0b4d85..6a8672b 100644 --- a/src/object/auto/autoenergy.cpp +++ b/src/object/auto/autoenergy.cpp @@ -649,3 +649,4 @@ bool CAutoEnergy::Read(char *line) return true; } + diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index fb82497..a648656 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -209,8 +209,8 @@ bool CAutoFactory::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_FACTORYrs ) type = OBJECT_MOBILErs; if ( event.type == EVENT_OBJECT_FACTORYsa ) type = OBJECT_MOBILEsa; - Error err = StartAction(type); - if( err != ERR_OK && err != ERR_GENERIC ) + Error err = StartAction(type); + if( err != ERR_OK && err != ERR_GENERIC ) m_displayText->DisplayError(err, m_object); if( err != ERR_GENERIC ) diff --git a/src/object/auto/autoflag.cpp b/src/object/auto/autoflag.cpp index 936546d..cc00db0 100644 --- a/src/object/auto/autoflag.cpp +++ b/src/object/auto/autoflag.cpp @@ -159,4 +159,3 @@ Error CAutoFlag::GetError() return ERR_OK; } - diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp index e8f31c8..6d4a484 100644 --- a/src/object/auto/autoinfo.cpp +++ b/src/object/auto/autoinfo.cpp @@ -513,4 +513,3 @@ bool CAutoInfo::Read(char *line) return true; } - diff --git a/src/object/auto/autojostle.cpp b/src/object/auto/autojostle.cpp index df82ad5..5ce01c2 100644 --- a/src/object/auto/autojostle.cpp +++ b/src/object/auto/autojostle.cpp @@ -142,4 +142,3 @@ Error CAutoJostle::IsEnded() return m_error; } - diff --git a/src/object/auto/autokid.cpp b/src/object/auto/autokid.cpp index a9f86b0..7d61d64 100644 --- a/src/object/auto/autokid.cpp +++ b/src/object/auto/autokid.cpp @@ -197,4 +197,3 @@ Error CAutoKid::GetError() return ERR_OK; } - diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp index 8424b93..172a618 100644 --- a/src/object/auto/autolabo.cpp +++ b/src/object/auto/autolabo.cpp @@ -177,8 +177,8 @@ bool CAutoLabo::EventProcess(const Event &event) Error err = ERR_GENERIC; if ( event.type == EVENT_OBJECT_RiPAW ) err = StartAction(RESEARCH_iPAW); if ( event.type == EVENT_OBJECT_RiGUN ) err = StartAction(RESEARCH_iGUN); - - if( err != ERR_OK && err != ERR_GENERIC ) + + if( err != ERR_OK && err != ERR_GENERIC ) m_displayText->DisplayError(err, m_object); if( err != ERR_GENERIC ) @@ -632,4 +632,3 @@ bool CAutoLabo::Read(char *line) return true; } - diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp index e97e2a1..1e4796d 100644 --- a/src/object/auto/automush.cpp +++ b/src/object/auto/automush.cpp @@ -342,4 +342,3 @@ bool CAutoMush::Read(char *line) return true; } - diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp index 1cf13d6..8a2d644 100644 --- a/src/object/auto/autonest.cpp +++ b/src/object/auto/autonest.cpp @@ -273,4 +273,3 @@ bool CAutoNest::Read(char *line) return true; } - diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp index 75bfb45..224776d 100644 --- a/src/object/auto/autonuclear.cpp +++ b/src/object/auto/autonuclear.cpp @@ -484,4 +484,3 @@ bool CAutoNuclear::Read(char *line) return true; } - diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp index ad6517b..24bc119 100644 --- a/src/object/auto/autopara.cpp +++ b/src/object/auto/autopara.cpp @@ -327,4 +327,3 @@ bool CAutoPara::Read(char *line) return true; } - diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp index 1a10aa7..4afd3fe 100644 --- a/src/object/auto/autoradar.cpp +++ b/src/object/auto/autoradar.cpp @@ -305,4 +305,3 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos) return true; } - diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp index 67aa9af..2f813f8 100644 --- a/src/object/auto/autorepair.cpp +++ b/src/object/auto/autorepair.cpp @@ -340,4 +340,3 @@ bool CAutoRepair::Read(char *line) return true; } - diff --git a/src/object/auto/autorepair.h b/src/object/auto/autorepair.h index 31a3c65..f522a55 100644 --- a/src/object/auto/autorepair.h +++ b/src/object/auto/autorepair.h @@ -63,4 +63,3 @@ protected: float m_lastParticle; }; - diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp index 7564bb8..8308ebe 100644 --- a/src/object/auto/autoresearch.cpp +++ b/src/object/auto/autoresearch.cpp @@ -176,8 +176,8 @@ bool CAutoResearch::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_RPHAZER ) err = StartAction(RESEARCH_PHAZER); if ( event.type == EVENT_OBJECT_RSHIELD ) err = StartAction(RESEARCH_SHIELD); if ( event.type == EVENT_OBJECT_RATOMIC ) err = StartAction(RESEARCH_ATOMIC); - - if( err != ERR_OK && err != ERR_GENERIC ) + + if( err != ERR_OK && err != ERR_GENERIC ) m_displayText->DisplayError(err, m_object); if( err != ERR_GENERIC ) @@ -607,4 +607,3 @@ bool CAutoResearch::Read(char *line) return true; } - diff --git a/src/object/auto/autoroot.cpp b/src/object/auto/autoroot.cpp index a390e90..7e5c5e7 100644 --- a/src/object/auto/autoroot.cpp +++ b/src/object/auto/autoroot.cpp @@ -115,4 +115,3 @@ Error CAutoRoot::GetError() return ERR_OK; } - diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp index 58c459a..2871a70 100644 --- a/src/object/auto/autosafe.cpp +++ b/src/object/auto/autosafe.cpp @@ -611,5 +611,3 @@ CObject* CAutoSafe::SearchVehicle() return 0; } - - diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp index 4ace2ac..2c0aa02 100644 --- a/src/object/auto/autostation.cpp +++ b/src/object/auto/autostation.cpp @@ -368,4 +368,3 @@ void CAutoStation::UpdateInterface(float rTime) } } - diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp index e3b06cf..17a41f4 100644 --- a/src/object/auto/autotower.cpp +++ b/src/object/auto/autotower.cpp @@ -397,7 +397,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn) pos.y = 18.0f; pos.z = listpos[i*2+1]; pos = Transform(*mat, pos); - + m_partiStop[i] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELR, 1.0f, 0.0f, 0.0f); @@ -544,4 +544,3 @@ bool CAutoTower::Read(char *line) return true; } - diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 4fab449..9e5149e 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -1312,7 +1312,8 @@ bool CBrain::CreateInterface(bool bSelect) type == OBJECT_WORM || type == OBJECT_CONTROLLER) // vehicle? { - if (!(m_main->GetRetroMode())) { + if (!(m_main->GetRetroMode())) + { ddim.x = dim.x*5.1f; ddim.y = dim.y*2.0f; // default => 2 pos.x = ox+sx*0.0f; diff --git a/src/object/brain.h b/src/object/brain.h index 38fb96f..dcf07a4 100644 --- a/src/object/brain.h +++ b/src/object/brain.h @@ -52,7 +52,7 @@ class CTerrain; class CWater; class CCamera; class CParticle; -} /* Gfx */ +} /* Gfx */ const int BRAINMAXSCRIPT = 10; diff --git a/src/object/mainmovie.cpp b/src/object/mainmovie.cpp index 04c0d56..85abee2 100644 --- a/src/object/mainmovie.cpp +++ b/src/object/mainmovie.cpp @@ -228,4 +228,3 @@ MainMovieType CMainMovie::GetStopType() return m_stopType; } - diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp index 3eabc0e..16e53aa 100644 --- a/src/object/motion/motionant.cpp +++ b/src/object/motion/motionant.cpp @@ -831,4 +831,3 @@ bool CMotionAnt::EventFrame(const Event &event) return true; } - diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp index a0f4734..2a052b2 100644 --- a/src/object/motion/motionbee.cpp +++ b/src/object/motion/motionbee.cpp @@ -610,4 +610,3 @@ bool CMotionBee::EventFrame(const Event &event) return true; } - diff --git a/src/object/motion/motiondummy.cpp b/src/object/motion/motiondummy.cpp index f25b81b..86e389e 100644 --- a/src/object/motion/motiondummy.cpp +++ b/src/object/motion/motiondummy.cpp @@ -81,4 +81,5 @@ bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, m_physics->SetCirMotionY(MO_STOACCEL, 2.0f); return true; -} \ No newline at end of file +} + diff --git a/src/object/motion/motiondummy.h b/src/object/motion/motiondummy.h index de29148..2cb3a88 100644 --- a/src/object/motion/motiondummy.h +++ b/src/object/motion/motiondummy.h @@ -31,3 +31,4 @@ public: void DeleteObject(bool bAll=false); bool Create(Math::Vector pos, float angle, ObjectType type, float power); }; + diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index c469a7e..b1de44e 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -1735,4 +1735,3 @@ void CMotionHuman::StopDisplayPerso() m_bDisplayPerso = false; } - diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp index c01dc66..03e7c21 100644 --- a/src/object/motion/motionmother.cpp +++ b/src/object/motion/motionmother.cpp @@ -493,4 +493,3 @@ bool CMotionMother::EventFrame(const Event &event) return true; } - diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp index a9a9b9b..8d339b6 100644 --- a/src/object/motion/motionspider.cpp +++ b/src/object/motion/motionspider.cpp @@ -743,4 +743,3 @@ bool CMotionSpider::EventFrame(const Event &event) return true; } - diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp index de473a1..b4ed89d 100644 --- a/src/object/motion/motiontoto.cpp +++ b/src/object/motion/motiontoto.cpp @@ -853,4 +853,3 @@ void CMotionToto::SetLinkType(ObjectType type) m_type = type; } - diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index 966fe75..a67ae24 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -1944,4 +1944,3 @@ void CMotionVehicle::SetTraceWidth(float width) m_traceWidth = width; } - diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp index d153178..80bf7fc 100644 --- a/src/object/motion/motionworm.cpp +++ b/src/object/motion/motionworm.cpp @@ -91,7 +91,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, rank = m_engine->CreateObject(); m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); - // This is an "empty" object, without triangles + // This is an "empty" object, without triangles m_object->SetPosition(0, pos); m_object->SetAngleY(0, angle); @@ -356,4 +356,3 @@ bool CMotionWorm::EventFrame(const Event &event) return true; } - diff --git a/src/object/object.cpp b/src/object/object.cpp index 5df4393..4cf0688 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -343,7 +343,7 @@ CObject::CObject() m_botVar = CBotVar::Create("", CBotTypResult(CBotTypClass, "object")); m_botVar->SetUserPtr(this); m_botVar->SetIdent(m_id); - + CObjectManager::GetInstancePointer()->AddInstance(this); } @@ -2146,10 +2146,12 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type, { m_motion = new CMotionHuman(this); } - else if ( type == OBJECT_CONTROLLER ) { + else if ( type == OBJECT_CONTROLLER ) + { m_motion = new CMotionDummy(this); //dummy object } - else { + else + { m_motion = new CMotionVehicle(this); } if ( m_motion == 0 ) return false; @@ -7391,4 +7393,3 @@ void CObject::SetTraceWidth(float width) mv->SetTraceWidth(width); } - diff --git a/src/object/objman.cpp b/src/object/objman.cpp index 76ab9b0..e4102b8 100644 --- a/src/object/objman.cpp +++ b/src/object/objman.cpp @@ -385,4 +385,5 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, } return object; -} \ No newline at end of file +} + diff --git a/src/object/objman.h b/src/object/objman.h index c776a86..3087383 100644 --- a/src/object/objman.h +++ b/src/object/objman.h @@ -51,4 +51,3 @@ protected: int usedCount; }; - diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 47c8d7f..3cd8384 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -706,7 +706,8 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) float fValue; int iValue; - if (loadProfile) { + if (loadProfile) + { if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; @@ -719,7 +720,8 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle m_IOPos.y = (1.0f-m_IODim.y)/2.0f; - if (loadProfile) { + if (loadProfile) + { if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; @@ -1281,7 +1283,7 @@ void CRobotMain::ChangePhase(Phase phase) ddim.x = dim.x*2; ddim.y = dim.y*2; m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f); - + StartMusic(); } } @@ -1530,9 +1532,8 @@ bool CRobotMain::EventProcess(Event &event) ChangePhase(PHASE_WIN); else if (m_lostDelay > 0.0f) ChangePhase(PHASE_LOST); - else if (!m_cmdEdit) { + else if (!m_cmdEdit) m_dialog->StartAbort(); // do you want to leave? - } } if (event.key.key == KEY(PAUSE)) { @@ -1842,7 +1843,8 @@ void CRobotMain::ExecuteCmd(char *cmd) if (strcmp(cmd, "controller") == 0) { - if (m_controller != nullptr) { + if (m_controller != nullptr) + { // Don't use SelectObject because it checks if the object is selectable if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT) StopDisplayVisit(); @@ -1925,7 +1927,7 @@ void CRobotMain::ExecuteCmd(char *cmd) object->SetRange(object->GetRange()*10.0f); return; } - + if (strcmp(cmd, "\155\157\157") == 0) { // VGhpcyBpcyBlYXN0ZXItZWdnIGFuZCBzbyBpdCBzaG91bGQgYmUgb2JmdXNjYXRlZCEgRG8gbm90 @@ -2079,20 +2081,23 @@ void CRobotMain::ExecuteCmd(char *cmd) return; } - if (strcmp(cmd, "speed4") == 0) { + if (strcmp(cmd, "speed4") == 0) + { SetSpeed(4.0f); UpdateSpeedLabel(); - return; + return; } - if (strcmp(cmd, "speed8") == 0) { + if (strcmp(cmd, "speed8") == 0) + { SetSpeed(8.0f); UpdateSpeedLabel(); - return; + return; } - if (strcmp(cmd, "crazy") == 0) { + if (strcmp(cmd, "crazy") == 0) + { SetSpeed(1000.0f); UpdateSpeedLabel(); - return; + return; } if (m_phase == PHASE_SIMUL) @@ -2189,7 +2194,7 @@ void CRobotMain::StartDisplayInfo(const char *filename, int index) void CRobotMain::StopDisplayInfo() { if (m_cmdEdit) return; - + if (m_movieInfoIndex != -1) // film to read the SatCom? m_movie->Start(MM_SATCOMclose, 2.0f); @@ -3989,19 +3994,22 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) // TODO: Fallback to an non-localized entry sprintf(op, "Title.%c", m_app->GetLanguageChar()); - if (Cmd(line, op) && !resetObject) { + if (Cmd(line, op) && !resetObject) + { OpString(line, "text", m_title); continue; } sprintf(op, "Resume.%c", m_app->GetLanguageChar()); - if (Cmd(line, op) && !resetObject) { + if (Cmd(line, op) && !resetObject) + { OpString(line, "text", m_resume); continue; } sprintf(op, "ScriptName.%c", m_app->GetLanguageChar()); - if (Cmd(line, op) && !resetObject) { + if (Cmd(line, op) && !resetObject) + { OpString(line, "text", m_scriptName); continue; } @@ -4010,7 +4018,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Resume")) continue; // Ignore if (Cmd(line, "ScriptName")) continue; // Ignore - if (Cmd(line, "ScriptFile") && !resetObject) { + if (Cmd(line, "ScriptFile") && !resetObject) + { OpString(line, "name", m_scriptFile); continue; } @@ -4022,7 +4031,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str()); m_immediatSatCom = OpInt(line, "immediat", 0); - if(m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0); + if (m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0); continue; } @@ -4077,7 +4086,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_sound->CacheMusic(filename); continue; } - + if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2 && m_controller == nullptr) { int i = m_audioChangeTotal; @@ -4101,20 +4110,24 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Audio") && !resetObject && m_controller == nullptr) { - if(m_version < 2) { + if (m_version < 2) + { int trackid = OpInt(line, "track", 0); - if(trackid != 0) { + if (trackid != 0) + { std::stringstream filename; filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; m_audioTrack = filename.str(); } - } else { + } + else + { char trackname[100]; OpString(line, "filename", trackname); m_audioTrack = trackname; } m_audioRepeat = OpInt(line, "repeat", 1); - if(m_audioTrack != "") m_sound->CacheMusic(m_audioTrack); + if (m_audioTrack != "") m_sound->CacheMusic(m_audioTrack); continue; } @@ -4132,17 +4145,20 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "VehicleColor") && !resetObject) { + if (Cmd(line, "VehicleColor") && !resetObject) + { m_colorNewBot = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); continue; } - if (Cmd(line, "InsectColor") && !resetObject) { + if (Cmd(line, "InsectColor") && !resetObject) + { m_colorNewAlien = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); continue; } - if (Cmd(line, "GreeneryColor") && !resetObject) { + if (Cmd(line, "GreeneryColor") && !resetObject) + { m_colorNewGreen = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); continue; } @@ -4161,7 +4177,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "SecondTexture") && !resetObject) { + if (Cmd(line, "SecondTexture") && !resetObject) + { m_engine->SetSecondTexture(OpInt(line, "rank", 1)); continue; } @@ -4211,21 +4228,24 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) g_unit = OpFloat(line, "unitScale", 4.0f); m_engine->SetTracePrecision(OpFloat(line, "traceQuality", 1.0f)); m_shortCut = OpInt(line, "shortcut", 1); - if(m_version >= 2) { + if (m_version >= 2) + { m_retroStyle = OpInt(line, "retro", 0); - if(m_retroStyle) GetLogger()->Info("Retro mode enabled.\n"); + if (m_retroStyle) GetLogger()->Info("Retro mode enabled.\n"); } continue; } if (Cmd(line, "TerrainGenerate") && !resetObject) { - if(m_terrainCreate) { + if (m_terrainCreate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainGenerate after TerrainCreate\n", filename, lineNum); continue; } - if(m_terrainInit) { + if (m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainGenerate after TerrainInit\n", filename, lineNum); continue; } @@ -4241,18 +4261,22 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "TerrainWind") && !resetObject) { - if(m_terrainCreate) { + if (Cmd(line, "TerrainWind") && !resetObject) + { + if (m_terrainCreate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind after TerrainCreate\n", filename, lineNum); continue; } - if(m_terrainInit) { + if (m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind after TerrainInit\n", filename, lineNum); continue; } - if(!m_terrainGenerate) { + if (!m_terrainGenerate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind before TerrainGenerate\n", filename, lineNum); continue; } @@ -4263,17 +4287,20 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "TerrainRelief") && !resetObject) { - if(m_terrainCreate) { + if (m_terrainCreate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief after TerrainCreate\n", filename, lineNum); continue; } - if(m_terrainInit) { + if (m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief after TerrainInit\n", filename, lineNum); continue; } - if(!m_terrainGenerate) { + if (!m_terrainGenerate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief before TerrainGenerate\n", filename, lineNum); continue; } @@ -4285,17 +4312,20 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "TerrainResource") && !resetObject) { - if(m_terrainCreate) { + if (m_terrainCreate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource after TerrainCreate\n", filename, lineNum); continue; } - if(m_terrainInit) { + if (m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource after TerrainInit\n", filename, lineNum); continue; } - if(!m_terrainGenerate) { + if (!m_terrainGenerate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource before TerrainGenerate\n", filename, lineNum); continue; } @@ -4325,7 +4355,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "TerrainLava") && !resetObject) { + if (Cmd(line, "TerrainLava") && !resetObject) + { m_water->SetLava(OpInt(line, "mode", 0)); continue; } @@ -4350,7 +4381,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "TerrainInitTextures") && !resetObject) { - if(m_terrainInit) { + if (m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainInitTextures and TerrainInit at same time\n", filename, lineNum); continue; } @@ -4373,8 +4405,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "TerrainInit") && !resetObject) { - if(m_terrainInitTextures) { + if (Cmd(line, "TerrainInit") && !resetObject) + { + if (m_terrainInitTextures) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainInit and TerrainInitTextures at same time\n", filename, lineNum); continue; } @@ -4386,24 +4420,28 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "TerrainMaterial") && !resetObject) { - if(m_terrainCreate) { + if (m_terrainCreate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial after TerrainCreate\n", filename, lineNum); continue; } - if(m_terrainInit) { + if (m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial after TerrainInit\n", filename, lineNum); continue; } - if(m_terrainInitTextures) { + if (m_terrainInitTextures) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial and TerrainInitTextures at same time\n", filename, lineNum); continue; } OpString(line, "image", name); AddExt(name, ".png"); - if (strstr(name, "%user%") != 0) { + if (strstr(name, "%user%") != 0) + { GetProfile().CopyFileToTemp(std::string(name)); } @@ -4421,22 +4459,26 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "TerrainLevel") && !resetObject) { - if(m_terrainCreate) { + if (m_terrainCreate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel after TerrainCreate\n", filename, lineNum); continue; } - if(!m_terrainInit) { + if (!m_terrainInit) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel before TerrainInit\n", filename, lineNum); continue; } - if(m_terrainInitTextures) { + if (m_terrainInitTextures) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel and TerrainInitTextures at same time\n", filename, lineNum); continue; } - if(!m_terrainGenerate) { + if (!m_terrainGenerate) + { GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel before TerrainGenerate\n", filename, lineNum); continue; } @@ -4460,7 +4502,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "TerrainCreate") && !resetObject) { + if (Cmd(line, "TerrainCreate") && !resetObject) + { m_terrain->CreateObjects(); m_terrainCreate = true; continue; @@ -4480,7 +4523,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "MissionController") && read[0] == 0 && m_version >= 2) { - /*if (!m_beginObject) { + /* TODO: ??? + if (!m_beginObject) + { GetLogger()->Error("Syntax error in file '%s' (line %d): MissionController before BeginObject\n", filename, lineNum); continue; }*/ @@ -4500,7 +4545,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "CreateObject") && read[0] == 0) { - if (!m_beginObject) { + if (!m_beginObject) + { GetLogger()->Error("Syntax error in file '%s' (line %d): CreateObject before BeginObject\n", filename, lineNum); continue; } @@ -4614,11 +4660,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) obj->SetClip(OpInt(line, "clip", 1)); obj->SetCheckToken(m_version >= 2 ? trainer || !selectable : OpInt(line, "checkToken", 1)); // SetManual will affect bot speed - if (type == OBJECT_MOBILEdr) { + if (type == OBJECT_MOBILEdr) + { obj->SetManual(m_version >= 2 ? !trainer : OpInt(line, "manual", 0)); } - if(m_version >= 2) { + if (m_version >= 2) + { Math::Vector zoom = OpDir(line, "zoom"); if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f) obj->SetZoom(0, zoom); @@ -4774,7 +4822,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "WaterColor") && !resetObject) { + if (Cmd(line, "WaterColor") && !resetObject) + { m_engine->SetWaterAddColor(OpColor(line, "color", Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f))); continue; } @@ -4846,12 +4895,15 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_endTake[i].type = OpTypeObject(line, "type", OBJECT_NULL); m_endTake[i].min = OpInt(line, "min", 1); m_endTake[i].max = OpInt(line, "max", 9999); - if (m_version >= 2) { - m_endTake[i].powermin = OpInt(line, "powermin", -1); - m_endTake[i].powermax = OpInt(line, "powermax", 100); - } else { - m_endTake[i].powermin = -1; - m_endTake[i].powermax = 100; + if (m_version >= 2) + { + m_endTake[i].powermin = OpInt(line, "powermin", -1); + m_endTake[i].powermax = OpInt(line, "powermax", 100); + } + else + { + m_endTake[i].powermin = -1; + m_endTake[i].powermax = 100; } m_endTake[i].lost = OpInt(line, "lost", -1); m_endTake[i].immediat = OpInt(line, "immediat", 0); @@ -4899,17 +4951,20 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "EnableBuild") && !resetObject) { + if (Cmd(line, "EnableBuild") && !resetObject) + { g_build |= OpBuild(line, "type"); continue; } - if (Cmd(line, "EnableResearch") && !resetObject) { + if (Cmd(line, "EnableResearch") && !resetObject) + { g_researchEnable |= OpResearch(line, "type"); continue; } - if (Cmd(line, "DoneResearch") && read[0] == 0 && !resetObject) { // not loading file? + if (Cmd(line, "DoneResearch") && read[0] == 0 && !resetObject) // not loading file? + { g_researchDone |= OpResearch(line, "type"); continue; } @@ -4922,7 +4977,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } if (line[0] == '\n') continue; // Ignore empty lines - if (line[0] == '\0') continue; // Ignore empty lines + if (line[0] == '\0') continue; // Ignore empty lines if (read[0] != 0) continue; // Ignore when loading saved game GetLogger()->Error("Syntax error in file '%s' (line %d): Unknown command: %s", filename, lineNum, line); // Don't add \n at the end of log message - it's included in line variable @@ -6207,7 +6262,7 @@ bool CRobotMain::IsBusy() void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd) { if (obj->GetType() == OBJECT_FIX) return; - + SetNumericLocale(); char line[3000]; @@ -6296,7 +6351,7 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd) strcat(line, "\n"); fputs(line, file); - + RestoreNumericLocale(); } @@ -6305,7 +6360,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * { FILE* file = fopen(filename, "w"); if (file == NULL) return false; - + SetNumericLocale(); char line[500]; @@ -6369,7 +6424,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * SaveFileScript(obj, filename, objRank++); } fclose(file); - + RestoreNumericLocale(); #if CBOT_STACK @@ -6417,7 +6472,7 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank) return nullptr; SetNumericLocale(); - + int trainer = OpInt(line, "trainer", 0); int toy = OpInt(line, "toy", 0); int option = OpInt(line, "option", 0); @@ -6484,7 +6539,7 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank) } RestoreNumericLocale(); - + return obj; } @@ -6495,7 +6550,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot) FILE* file = fopen(filename, "r"); if (file == NULL) return 0; - + SetNumericLocale(); CObject* fret = nullptr; @@ -6811,7 +6866,7 @@ void CRobotMain::UpdateAudio(bool frame) for (int t = 0; t < m_audioChangeTotal; t++) { - if(m_audioChange[t].changed) continue; + if (m_audioChange[t].changed) continue; Math::Vector bPos = m_audioChange[t].pos; bPos.y = 0.0f; @@ -6843,7 +6898,8 @@ void CRobotMain::UpdateAudio(bool frame) float energyLevel = -1; CObject* power = obj->GetPower(); - if (power != nullptr) { + if (power != nullptr) + { energyLevel = power->GetEnergy(); if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100; } @@ -6873,7 +6929,8 @@ void CRobotMain::UpdateAudio(bool frame) void CRobotMain::SetEndMission(Error result, float delay) { - if (m_controller != nullptr) { + if (m_controller != nullptr) + { m_endTakeWinDelay = delay; m_endTakeLostDelay = delay; m_missionResult = result; @@ -6883,22 +6940,25 @@ void CRobotMain::SetEndMission(Error result, float delay) //! Checks if the mission is over Error CRobotMain::CheckEndMission(bool frame) { - if (m_controller != nullptr) { - if (m_missionResult == INFO_LOST) { //mission lost? + if (m_controller != nullptr) + { + if (m_missionResult == INFO_LOST) //mission lost? + { m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f)); m_winDelay = 0.0f; - if(m_lostDelay == 0) m_lostDelay = m_endTakeLostDelay; + if (m_lostDelay == 0) m_lostDelay = m_endTakeLostDelay; m_displayText->SetEnable(false); } - if (m_missionResult == INFO_LOSTq) { //mission lost? + if (m_missionResult == INFO_LOSTq) //mission lost? + { m_winDelay = 0.0f; - if(m_lostDelay == 0) m_lostDelay = 0.1f; + if (m_lostDelay == 0) m_lostDelay = 0.1f; m_displayText->SetEnable(false); } if (frame && m_base) return ERR_MISSION_NOTERM; if (m_missionResult == ERR_OK) { //mission win? m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f)); - if(m_winDelay == 0) m_winDelay = m_endTakeWinDelay; + if (m_winDelay == 0) m_winDelay = m_endTakeWinDelay; m_lostDelay = 0.0f; m_displayText->SetEnable(false); } @@ -6942,7 +7002,8 @@ Error CRobotMain::CheckEndMission(bool frame) float energyLevel = -1; CObject* power = obj->GetPower(); - if (power != nullptr) { + if (power != nullptr) + { energyLevel = power->GetEnergy(); if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100; } @@ -7417,7 +7478,7 @@ void CRobotMain::StartMusic() { m_sound->StopMusic(); m_sound->PlayMusic(m_audioTrack, m_audioRepeat); - } + } } //! Removes hilite and tooltip @@ -7440,4 +7501,4 @@ void CRobotMain::RestoreNumericLocale() { setlocale(LC_NUMERIC, m_oldLocale.c_str()); } - + diff --git a/src/object/robotmain.h b/src/object/robotmain.h index a459a59..a75509d 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -370,7 +370,7 @@ public: CObject* IOReadObject(char *line, const char* filename, int objRank); int CreateSpot(Math::Vector pos, Gfx::Color color); - + void SetNumericLocale(); void RestoreNumericLocale(); @@ -412,7 +412,7 @@ protected: void ExecuteCmd(char *cmd); bool TestGadgetQuantity(int rank); void UpdateSpeedLabel(); - + protected: CApplication* m_app; @@ -544,7 +544,7 @@ protected: bool m_endTakeNever; float m_endTakeWinDelay; float m_endTakeLostDelay; - + int m_audioChangeTotal; AudioChange m_audioChange[10]; @@ -571,7 +571,7 @@ protected: Gfx::Color m_colorRefWater; Gfx::Color m_colorNewWater; float m_colorShiftWater; - + std::string m_oldLocale; }; diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp index 39fdccf..5ec6f8a 100644 --- a/src/object/task/task.cpp +++ b/src/object/task/task.cpp @@ -81,4 +81,3 @@ bool CTask::Abort() return true; } - diff --git a/src/object/task/task.h b/src/object/task/task.h index 12961ef..41b3d3b 100644 --- a/src/object/task/task.h +++ b/src/object/task/task.h @@ -34,7 +34,7 @@ class CSoundInterface; namespace Ui { class CDisplayText; -} /* Ui */ +} /* Ui */ namespace Gfx { class CEngine; @@ -43,7 +43,7 @@ class CParticle; class CTerrain; class CWater; class CCamera; -} /* Gfx */ +} /* Gfx */ const float TAKE_DIST = 6.0f; // distance to an object to pick it diff --git a/src/object/task/taskadvance.cpp b/src/object/task/taskadvance.cpp index 58eb939..885e100 100644 --- a/src/object/task/taskadvance.cpp +++ b/src/object/task/taskadvance.cpp @@ -139,4 +139,3 @@ Error CTaskAdvance::IsEnded() return ERR_CONTINUE; } - diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index b3a7221..01ff38b 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -90,7 +90,8 @@ bool CTaskGoto::EventProcess(const Event &event) rot.x = m_leakPos.x-pos.x; rot.y = m_leakPos.z-pos.z; dist = Math::Point(rot.x, rot.y).Length(); - if (dist != 0) { + if (dist != 0) + { rot.x /= dist; rot.y /= dist; } @@ -2231,4 +2232,3 @@ bool CTaskGoto::BitmapTestDot(int rank, int x, int y) return m_bmArray[rank*m_bmLine*m_bmSize + m_bmLine*y + x/8] & (1<Abort(); } - diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp index e2c2524..974a53d 100644 --- a/src/object/task/tasksearch.cpp +++ b/src/object/task/tasksearch.cpp @@ -220,10 +220,11 @@ bool CTaskSearch::Abort() { m_hand = TSH_UP; InitAngle(); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) + { m_object->SetAngleZ(i+1, m_finalAngle[i]); } - + m_camera->StopCentering(m_object, 2.0f); m_physics->SetFreeze(false); // is moving again return true; @@ -325,4 +326,3 @@ void CTaskSearch::DeleteMark(ObjectType type) } } - diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp index 929dd5c..fe6eaeb 100644 --- a/src/object/task/taskshield.cpp +++ b/src/object/task/taskshield.cpp @@ -552,5 +552,3 @@ float CTaskShield::GetRadius() return RADIUS_SHIELD_MIN + (RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)*m_object->GetParam(); } - - diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp index 0037f85..c7f0530 100644 --- a/src/object/task/tasktake.cpp +++ b/src/object/task/tasktake.cpp @@ -598,4 +598,3 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos) return true; // location free } - diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp index 7a924cb..bf9d593 100644 --- a/src/object/task/taskturn.cpp +++ b/src/object/task/taskturn.cpp @@ -126,4 +126,3 @@ Error CTaskTurn::IsEnded() return ERR_CONTINUE; } - diff --git a/src/object/task/taskwait.cpp b/src/object/task/taskwait.cpp index 3e201e0..5b9fdb3 100644 --- a/src/object/task/taskwait.cpp +++ b/src/object/task/taskwait.cpp @@ -64,4 +64,3 @@ Error CTaskWait::IsEnded() return ERR_CONTINUE; } - diff --git a/src/physics/README.txt b/src/physics/README.txt index c068d4d..dd74709 100644 --- a/src/physics/README.txt +++ b/src/physics/README.txt @@ -2,3 +2,4 @@ * \dir src/physics * \brief Physics engine */ + diff --git a/src/physics/physics.h b/src/physics/physics.h index cce57f3..834d7b8 100644 --- a/src/physics/physics.h +++ b/src/physics/physics.h @@ -250,4 +250,3 @@ protected: bool m_bLowLevel; }; - diff --git a/src/po/CMakeLists.txt b/src/po/CMakeLists.txt index df667dd..85b401c 100644 --- a/src/po/CMakeLists.txt +++ b/src/po/CMakeLists.txt @@ -16,3 +16,4 @@ add_custom_target(update-pot DEPENDS ${_potFile}) file(GLOB _poFiles *.po) gettext_create_translations(${_potFile} ALL ${_poFiles}) + diff --git a/src/po/colobot.pot b/src/po/colobot.pot index e1f9dc7..8ce386f 100644 --- a/src/po/colobot.pot +++ b/src/po/colobot.pot @@ -1816,3 +1816,4 @@ msgstr "" msgid "%1" msgstr "" + diff --git a/src/po/de.po b/src/po/de.po index 2992cb1..d0943ab 100644 --- a/src/po/de.po +++ b/src/po/de.po @@ -2053,3 +2053,4 @@ msgstr "www.epsitec.com" #~ msgid "Zoom" #~ msgstr "Zoom" + diff --git a/src/po/fr.po b/src/po/fr.po index 662fb93..343458d 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -2055,3 +2055,4 @@ msgstr "www.epsitec.com" #~ msgid "Zoom" #~ msgstr "Zoom" + diff --git a/src/po/pl.po b/src/po/pl.po index 9bab529..4cbfe60 100644 --- a/src/po/pl.po +++ b/src/po/pl.po @@ -2063,3 +2063,4 @@ msgstr "www.epsitec.com" #~ msgid "Zoom" #~ msgstr "PowiÄ™kszenie" + diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index b5af5c3..505228e 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -535,4 +535,3 @@ const char* GetHelpText(const char *token) return ""; } - diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h index bc53f77..976d856 100644 --- a/src/script/cbottoken.h +++ b/src/script/cbottoken.h @@ -36,4 +36,3 @@ extern bool IsType(const char *token); extern bool IsFunction(const char *token); extern const char* GetHelpText(const char *token); - diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp index 9c97f7d..69df68b 100644 --- a/src/script/cmdtoken.cpp +++ b/src/script/cmdtoken.cpp @@ -947,4 +947,3 @@ Gfx::Color OpColor(char *line, const char *op, Gfx::Color def) return color; } - diff --git a/src/script/dd.cpp b/src/script/dd.cpp index 4110813..a7f5eb9 100644 --- a/src/script/dd.cpp +++ b/src/script/dd.cpp @@ -173,3 +173,4 @@ bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user) } return true; } + diff --git a/src/script/script.cpp b/src/script/script.cpp index 3a88a8e..b03702c 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -632,7 +632,7 @@ CBotTypResult CScript::cFactory(CBotVar* thisclass, CBotVar* &var) if ( var == 0 ) return CBotTypResult(CBotErrLowParam); if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); - if ( var != 0 ) + if ( var != 0 ) { if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); @@ -909,11 +909,13 @@ CBotTypResult CScript::cDelete(CBotVar* &var, void* user) if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { if ( var->GetType() != CBotTypInt ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); } @@ -935,10 +937,12 @@ bool CScript::rDelete(CBotVar* var, CBotVar* result, int& exception, void* user) rank = var->GetValInt(); var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { exploType = var->GetValInt(); var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { force = var->GetValFloat(); } } @@ -950,9 +954,12 @@ bool CScript::rDelete(CBotVar* var, CBotVar* result, int& exception, void* user) } else { - if ( exploType ) { + if ( exploType ) + { pObj->ExploObject(static_cast(exploType), force); - } else { + } + else + { pObj->DeleteObject(false); } } @@ -1710,13 +1717,17 @@ CBotTypResult CScript::cProduce(CBotVar* &var, void* user) if ( var == 0 ) return CBotTypResult(CBotErrLowParam); - if ( var->GetType() <= CBotTypDouble ) { + if ( var->GetType() <= CBotTypDouble ) + { var = var->GetNext(); - if( var != 0 ) { + if( var != 0 ) + { if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); } - } else { + } + else + { ret = cPoint(var, user); if ( ret.GetType() != 0 ) return ret; @@ -1728,11 +1739,13 @@ CBotTypResult CScript::cProduce(CBotVar* &var, void* user) if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString); var = var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); } @@ -1759,7 +1772,8 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user ObjectType type; float power; - if ( var->GetType() <= CBotTypDouble ) { + if ( var->GetType() <= CBotTypDouble ) + { type = static_cast(var->GetValInt()); var = var->GetNext(); @@ -1774,7 +1788,9 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user power = -1.0f; name = ""; - } else { + } + else + { if ( !GetPoint(var, exception, pos) ) return true; angle = var->GetValFloat()*Math::PI/180.0f; @@ -1783,16 +1799,22 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user type = static_cast(var->GetValInt()); var = var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { cbs = var->GetValString(); name = cbs; var = var->GetNext(); - if ( var != 0 ) { + if ( var != 0 ) + { power = var->GetValFloat(); - } else { + } + else + { power = -1.0f; } - } else { + } + else + { name = ""; power = -1.0f; } @@ -1839,12 +1861,11 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user } object->SetActivity(false); } - else - if ( type == OBJECT_MOTHER || - type == OBJECT_ANT || - type == OBJECT_SPIDER || - type == OBJECT_BEE || - type == OBJECT_WORM ) + else if ( type == OBJECT_MOTHER || + type == OBJECT_ANT || + type == OBJECT_SPIDER || + type == OBJECT_BEE || + type == OBJECT_WORM ) { CObject* egg; @@ -1863,30 +1884,29 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user } object->SetActivity(false); } - else - if ( type == OBJECT_PORTICO || - type == OBJECT_BASE || - type == OBJECT_DERRICK || - type == OBJECT_FACTORY || - type == OBJECT_STATION || - type == OBJECT_CONVERT || - type == OBJECT_REPAIR || - type == OBJECT_DESTROYER|| - type == OBJECT_TOWER || - type == OBJECT_NEST || - type == OBJECT_RESEARCH || - type == OBJECT_RADAR || - type == OBJECT_INFO || - type == OBJECT_ENERGY || - type == OBJECT_LABO || - type == OBJECT_NUCLEAR || - type == OBJECT_PARA || - type == OBJECT_SAFE || - type == OBJECT_HUSTON || - type == OBJECT_TARGET1 || - type == OBJECT_TARGET2 || - type == OBJECT_START || - type == OBJECT_END ) + else if ( type == OBJECT_PORTICO || + type == OBJECT_BASE || + type == OBJECT_DERRICK || + type == OBJECT_FACTORY || + type == OBJECT_STATION || + type == OBJECT_CONVERT || + type == OBJECT_REPAIR || + type == OBJECT_DESTROYER|| + type == OBJECT_TOWER || + type == OBJECT_NEST || + type == OBJECT_RESEARCH || + type == OBJECT_RADAR || + type == OBJECT_INFO || + type == OBJECT_ENERGY || + type == OBJECT_LABO || + type == OBJECT_NUCLEAR || + type == OBJECT_PARA || + type == OBJECT_SAFE || + type == OBJECT_HUSTON || + type == OBJECT_TARGET1 || + type == OBJECT_TARGET2 || + type == OBJECT_START || + type == OBJECT_END ) { object = new CObject(); if ( !object->CreateBuilding(pos, angle, 0, type) ) @@ -1898,12 +1918,11 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user object->SetActivity(false); script->m_main->CreateShortcuts(); } - else - if ( type == OBJECT_FLAGb || - type == OBJECT_FLAGr || - type == OBJECT_FLAGg || - type == OBJECT_FLAGy || - type == OBJECT_FLAGv ) + else if ( type == OBJECT_FLAGb || + type == OBJECT_FLAGr || + type == OBJECT_FLAGg || + type == OBJECT_FLAGy || + type == OBJECT_FLAGv ) { object = new CObject(); if ( !object->CreateFlag(pos, angle, type) ) @@ -1914,38 +1933,37 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user } object->SetActivity(false); } - else - if ( type == OBJECT_HUMAN || - type == OBJECT_TECH || - type == OBJECT_TOTO || - type == OBJECT_MOBILEfa || - type == OBJECT_MOBILEta || - type == OBJECT_MOBILEwa || - type == OBJECT_MOBILEia || - type == OBJECT_MOBILEfc || - type == OBJECT_MOBILEtc || - type == OBJECT_MOBILEwc || - type == OBJECT_MOBILEic || - type == OBJECT_MOBILEfi || - type == OBJECT_MOBILEti || - type == OBJECT_MOBILEwi || - type == OBJECT_MOBILEii || - type == OBJECT_MOBILEfs || - type == OBJECT_MOBILEts || - type == OBJECT_MOBILEws || - type == OBJECT_MOBILEis || - type == OBJECT_MOBILErt || - type == OBJECT_MOBILErc || - type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs || - type == OBJECT_MOBILEsa || - type == OBJECT_MOBILEtg || - type == OBJECT_MOBILEft || - type == OBJECT_MOBILEtt || - type == OBJECT_MOBILEwt || - type == OBJECT_MOBILEit || - type == OBJECT_MOBILEdr || - type == OBJECT_APOLLO2 ) + else if ( type == OBJECT_HUMAN || + type == OBJECT_TECH || + type == OBJECT_TOTO || + type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEta || + type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfc || + type == OBJECT_MOBILEtc || + type == OBJECT_MOBILEwc || + type == OBJECT_MOBILEic || + type == OBJECT_MOBILEfi || + type == OBJECT_MOBILEti || + type == OBJECT_MOBILEwi || + type == OBJECT_MOBILEii || + type == OBJECT_MOBILEfs || + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEws || + type == OBJECT_MOBILEis || + type == OBJECT_MOBILErt || + type == OBJECT_MOBILErc || + type == OBJECT_MOBILErr || + type == OBJECT_MOBILErs || + type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEtg || + type == OBJECT_MOBILEft || + type == OBJECT_MOBILEtt || + type == OBJECT_MOBILEwt || + type == OBJECT_MOBILEit || + type == OBJECT_MOBILEdr || + type == OBJECT_APOLLO2 ) { object = new CObject(); if ( !object->CreateVehicle(pos, angle, type, power, false, false) ) @@ -1964,8 +1982,9 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user } object->SetLock(false); // vehicle useable // SetManual will affect bot speed - if (type == OBJECT_MOBILEdr) { - object->SetManual(true); + if (type == OBJECT_MOBILEdr) + { + object->SetManual(true); } object->SetActivity(true); script->m_main->CreateShortcuts(); @@ -1976,7 +1995,8 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user return true; } - if(name[0] != 0) { + if (name[0] != 0) + { object->ReadProgram(0, static_cast(name)); object->RunProgram(0); } @@ -3008,8 +3028,8 @@ bool CScript::rAim(CBotVar* var, CBotVar* result, int& exception, void* user) { script->m_primaryTask = new CTaskManager(script->m_object); x = var->GetValFloat(); - var = var->GetNext(); - var == 0 ? y=0.0f : y=var->GetValFloat(); + var = var->GetNext(); + var == 0 ? y=0.0f : y=var->GetValFloat(); err = script->m_primaryTask->StartTaskGunGoal(x*Math::PI/180.0f, y*Math::PI/180.0f); if ( err != ERR_OK ) { diff --git a/src/script/script.h b/src/script/script.h index 74b81df..7a5d075 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -38,13 +38,13 @@ class CDisplayText; class CEdit; class CInterface; class CList; -} /* Ui */ +} /* Ui */ namespace Gfx { class CEngine; class CTerrain; class CWater; -} /* Gfx */ +} /* Gfx */ @@ -237,4 +237,3 @@ protected: float m_returnValue; }; - diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index dc2b64d..c50f6ec 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -375,7 +375,7 @@ bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float t if (mChannels.find(channel) == mChannels.end()) { return false; } - + SoundOper op; op.finalAmplitude = amplitude; op.finalFrequency = frequency; @@ -401,7 +401,7 @@ bool ALSound::Position(int channel, Math::Vector pos) mChannels[channel]->SetPan(pos); } else { ComputeVolumePan2D(channel, pos); - + if (!mChannels[channel]->HasEnvelope()) { float volume = mChannels[channel]->GetStartAmplitude(); mChannels[channel]->SetVolume(powf(volume * mChannels[channel]->GetVolumeAtrib(), 0.2f) * mAudioVolume); @@ -459,7 +459,7 @@ bool ALSound::MuteAll(bool bMute) { if (!mEnabled) return false; - + for (auto it : mChannels) { if (it.second->IsPlaying()) { it.second->Mute(bMute); @@ -486,7 +486,7 @@ void ALSound::FrameMove(float delta) if (!it.second->IsPlaying()) { continue; } - + if (it.second->IsMuted()) { it.second->SetVolume(0.0f); continue; @@ -499,7 +499,7 @@ void ALSound::FrameMove(float delta) oper.currentTime += delta; progress = oper.currentTime / oper.totalTime; progress = MIN(progress, 1.0f); - + // setting volume volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); volume = volume + it.second->GetStartAmplitude(); @@ -536,20 +536,20 @@ void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) mEye = eye; mLookat = lookat; if (m3D) { - float orientation[] = {lookat.x, lookat.y, lookat.z, 0.f, 1.f, 0.f}; - alListener3f(AL_POSITION, eye.x, eye.y, eye.z); + float orientation[] = {lookat.x, lookat.y, lookat.z, 0.f, 1.f, 0.f}; + alListener3f(AL_POSITION, eye.x, eye.y, eye.z); alListenerfv(AL_ORIENTATION, orientation); } else { - float orientation[] = {0.0f, 0.0f, 0.0f, 0.f, 1.f, 0.f}; - alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); + float orientation[] = {0.0f, 0.0f, 0.0f, 0.f, 1.f, 0.f}; + alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); alListenerfv(AL_ORIENTATION, orientation); - + // recalculate sound position for (auto it : mChannels) { if (it.second->IsPlaying()) { Math::Vector pos = it.second->GetPosition(); ComputeVolumePan2D(it.first, pos); - + if (!it.second->HasEnvelope()) { float volume = it.second->GetStartAmplitude(); it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * mAudioVolume); @@ -586,14 +586,14 @@ bool ALSound::PlayMusic(std::string filename, bool bRepeat) buffer->LoadFromFile(file.str(), static_cast(-1)); mCurrentMusic->SetBuffer(buffer); } else { - GetLogger()->Debug("Music loaded from cache\n"); - mCurrentMusic->SetBuffer(mMusic[filename]); + GetLogger()->Debug("Music loaded from cache\n"); + mCurrentMusic->SetBuffer(mMusic[filename]); } - + mCurrentMusic->SetVolume(mMusicVolume); mCurrentMusic->SetLoop(bRepeat); mCurrentMusic->Play(); - + return true; } @@ -614,7 +614,7 @@ void ALSound::StopMusic() if (!mEnabled || !mCurrentMusic) { return; } - + SuspendMusic(); } @@ -624,7 +624,7 @@ bool ALSound::IsPlayingMusic() if (!mEnabled || !mCurrentMusic) { return false; } - + return mCurrentMusic->IsPlaying(); } @@ -634,7 +634,7 @@ void ALSound::SuspendMusic() if (!mEnabled || !mCurrentMusic) { return; } - + mCurrentMusic->Stop(); } @@ -665,17 +665,17 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) Math::Vector one = Math::Vector(1.0f, 0.0f, 0.0f); float angle_a = Angle(Math::Vector(mLookat.x - mEye.x, mLookat.z - mEye.z, 0.0f), one); float angle_g = Angle(Math::Vector(pos.x - mEye.x, pos.z - mEye.z, 0.0f), one); - + a = fmodf(angle_a, Math::PI * 2.0f); g = fmodf(angle_g, Math::PI * 2.0f); - + if ( a < 0.0f ) { a += Math::PI * 2.0f; } if ( g < 0.0f ) { g += Math::PI * 2.0f; } - + if ( a < g ) { if (a + Math::PI * 2.0f - g < g - a ) { a += Math::PI * 2.0f; @@ -685,6 +685,6 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) g += Math::PI * 2.0f; } } - + mChannels[channel]->SetPan( Math::Vector(0.0f, 0.0f, sinf(g - a)) ); } diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp index edc3d74..4640504 100644 --- a/src/sound/oalsound/buffer.cpp +++ b/src/sound/oalsound/buffer.cpp @@ -67,7 +67,7 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound) { while ((read = sf_read_short(file, buffer.data(), buffer.size())) != 0) { data.insert(data.end(), buffer.begin(), buffer.begin() + read); } - sf_close(file); + sf_close(file); alBufferData(mBuffer, fileInfo.channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, &data.front(), data.size() * sizeof(uint16_t), fileInfo.samplerate); mDuration = static_cast(fileInfo.frames) / fileInfo.samplerate; diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index c5b05fa..d64d6b5 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -27,7 +27,7 @@ Channel::Channel() } else { mReady = true; } - + mPriority = 0; mBuffer = nullptr; mLoop = false; @@ -74,7 +74,7 @@ bool Channel::SetPan(Math::Vector pos) if (!mReady || mBuffer == nullptr) { return false; } - + alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z); if (alCheck()) { GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode()); @@ -117,7 +117,7 @@ float Channel::GetFrequency() if (!mReady || mBuffer == nullptr) { return 0; } - + alGetSourcef(mSource, AL_PITCH, &freq); if (alCheck()) { GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode()); @@ -133,7 +133,7 @@ bool Channel::SetVolume(float vol) if (!mReady || vol < 0 || mBuffer == nullptr) { return false; } - + alSourcef(mSource, AL_GAIN, vol); if (alCheck()) { GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode()); @@ -149,7 +149,7 @@ float Channel::GetVolume() if (!mReady || mBuffer == nullptr) { return 0; } - + alGetSourcef(mSource, AL_GAIN, &vol); if (alCheck()) { GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode()); @@ -243,7 +243,7 @@ Sound Channel::GetSoundType() { if (!mReady || mBuffer == nullptr) { return SOUND_NONE; } - + return mBuffer->GetSoundType(); } @@ -252,13 +252,13 @@ bool Channel::SetBuffer(Buffer *buffer) { if (!mReady) return false; - Stop(); + Stop(); mBuffer = buffer; if (buffer == nullptr) { alSourcei(mSource, AL_BUFFER, 0); return true; - } - + } + alSourcei(mSource, AL_BUFFER, buffer->GetBuffer()); if (alCheck()) { GetLogger()->Warn("Could not set sound buffer. Code: %d\n", alGetCode()); @@ -287,7 +287,7 @@ bool Channel::IsPlaying() { if (!mReady || mBuffer == nullptr) { return false; } - + alGetSourcei(mSource, AL_SOURCE_STATE, &status); if (alCheck()) { GetLogger()->Warn("Could not get sound status. Code: %d\n", alGetCode()); @@ -311,7 +311,7 @@ bool Channel::Stop() { if (!mReady || mBuffer == nullptr) { return false; } - + alSourceStop(mSource); if (alCheck()) { GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode()); @@ -326,7 +326,7 @@ float Channel::GetCurrentTime() if (!mReady || mBuffer == nullptr) { return 0.0f; } - + ALfloat current; alGetSourcef(mSource, AL_SEC_OFFSET, ¤t); if (alCheck()) { @@ -342,7 +342,7 @@ void Channel::SetCurrentTime(float current) if (!mReady || mBuffer == nullptr) { return; } - + alSourcef(mSource, AL_SEC_OFFSET, current); if (alCheck()) { GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode()); @@ -355,7 +355,7 @@ float Channel::GetDuration() if (!mReady || mBuffer == nullptr) { return 0.0f; } - + return mBuffer->GetDuration(); } diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index 6717f03..c0b0436 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -48,7 +48,7 @@ class Channel bool Play(); bool Stop(); - + bool SetPan(Math::Vector); void SetPosition(Math::Vector); Math::Vector GetPosition(); @@ -64,21 +64,21 @@ class Channel float GetVolume(); void SetVolumeAtrib(float); float GetVolumeAtrib(); - + bool IsPlaying(); bool IsReady(); bool IsLoaded(); bool SetBuffer(Buffer *); bool FreeBuffer(); - + bool HasEnvelope(); SoundOper& GetEnvelope(); void PopEnvelope(); - + int GetPriority(); void SetPriority(int); - + void SetStartAmplitude(float); void SetStartFrequency(float); void SetChangeFrequency(float); @@ -87,14 +87,14 @@ class Channel float GetStartFrequency(); float GetChangeFrequency(); float GetInitFrequency(); - + void AddOper(SoundOper); void ResetOper(); Sound GetSoundType(); void SetLoop(bool); void Mute(bool); bool IsMuted(); - + private: Buffer *mBuffer; ALuint mSource; diff --git a/src/sound/sound.h b/src/sound/sound.h index 360f0de..1fd79c3 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -48,7 +48,7 @@ **/ enum Sound { - SOUND_NONE = -1, + SOUND_NONE = -1, SOUND_CLICK = 0, SOUND_BOUM = 1, SOUND_EXPLO = 2, @@ -183,7 +183,7 @@ class CSoundInterface CacheMusic("music010.ogg"); CacheMusic("music011.ogg"); }; - + /** Function called to cache sound effect file. * This function is called by plugin interface for each file. * \param bSound - id of a file, will be used to identify sound files diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 0be2bd5..da590d8 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -12,3 +12,4 @@ include_directories(SYSTEM ${SDL_INCLUDE_DIR}) add_definitions(-DMODELFILE_NO_ENGINE) add_executable(convert_model ${CONVERT_MODEL_SOURCES}) + diff --git a/src/tools/README.txt b/src/tools/README.txt index de2f087..3de9e75 100644 --- a/src/tools/README.txt +++ b/src/tools/README.txt @@ -2,3 +2,4 @@ * \dir tools * \brief Various tools (separate programs) */ + diff --git a/src/tools/convert_model.cpp b/src/tools/convert_model.cpp index 463b83a..57e8789 100644 --- a/src/tools/convert_model.cpp +++ b/src/tools/convert_model.cpp @@ -279,3 +279,4 @@ int main(int argc, char *argv[]) return 0; } + diff --git a/src/ui/README.txt b/src/ui/README.txt index a159ed5..05f72a1 100644 --- a/src/ui/README.txt +++ b/src/ui/README.txt @@ -2,3 +2,4 @@ * \dir src/ui * \brief 2D user interface controls */ + diff --git a/src/ui/button.cpp b/src/ui/button.cpp index a68b34d..348382d 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -245,3 +245,4 @@ bool CButton::GetRepeat() } } + diff --git a/src/ui/button.h b/src/ui/button.h index a9aa020..b71ef4a 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -51,3 +51,4 @@ protected: }; } + diff --git a/src/ui/check.cpp b/src/ui/check.cpp index 761264d..362c930 100644 --- a/src/ui/check.cpp +++ b/src/ui/check.cpp @@ -163,3 +163,4 @@ void CCheck::Draw() } } + diff --git a/src/ui/color.cpp b/src/ui/color.cpp index fd05bd9..623ff89 100644 --- a/src/ui/color.cpp +++ b/src/ui/color.cpp @@ -223,3 +223,4 @@ Gfx::Color CColor::GetColor() } + diff --git a/src/ui/color.h b/src/ui/color.h index ec2c537..fe96b87 100644 --- a/src/ui/color.h +++ b/src/ui/color.h @@ -54,3 +54,4 @@ protected: }; } + diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp index ac97cb8..d0fe96f 100644 --- a/src/ui/compass.cpp +++ b/src/ui/compass.cpp @@ -171,3 +171,4 @@ float CCompass::GetDirection() } + diff --git a/src/ui/compass.h b/src/ui/compass.h index 18546e5..956631a 100644 --- a/src/ui/compass.h +++ b/src/ui/compass.h @@ -49,3 +49,4 @@ protected: } + diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 6dc92cd..7c77c95 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -75,10 +75,13 @@ bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType even GetResource(RES_EVENT, m_eventType, text); str_text = std::string(text); auto p = str_text.find("\\"); - if ( p == std::string::npos ) { + if ( p == std::string::npos ) + { if ( icon != -1 ) m_tooltip = str_text; - } else { + } + else + { m_tooltip = str_text.substr(p + 1); } @@ -174,15 +177,18 @@ int CControl::GetIcon() void CControl::SetName(std::string name, bool bTooltip) { - if ( bTooltip ) { + if ( bTooltip ) + { auto p = name.find("\\"); if ( p == std::string::npos ) m_name = name; - else { + else + { m_tooltip = name.substr(p + 1); m_name = name.substr(0, p); } - } else + } + else m_name = name; } @@ -832,3 +838,4 @@ bool CControl::Detect(Math::Point pos) } } + diff --git a/src/ui/control.h b/src/ui/control.h index 7f5077d..aee7d1c 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -141,3 +141,4 @@ protected: }; } // namespace Ui + diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index f83ff5a..3aa3d73 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -1214,3 +1214,4 @@ void CDisplayInfo::CreateObjectsFile() } + diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h index ab42d62..eea50b7 100644 --- a/src/ui/displayinfo.h +++ b/src/ui/displayinfo.h @@ -95,3 +95,4 @@ protected: } // namespace Ui + diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp index 630b385..d88674a 100644 --- a/src/ui/displaytext.cpp +++ b/src/ui/displaytext.cpp @@ -606,3 +606,4 @@ CObject* CDisplayText::SearchToto() } } + diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index c9831dd..6fd1735 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -263,7 +263,7 @@ bool CEdit::EventProcess(const Event &event) if ( event.type == EVENT_MOUSE_MOVE ) { - if ( Detect(event.mousePos) && + if ( Detect(event.mousePos) && event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) ) { if ( m_bEdit ) @@ -782,13 +782,16 @@ void CEdit::HyperJump(std::string name, std::string marker) sMarker = marker; //? sprintf(filename, "help\\%s.txt", name); - - if ( name[0] == '%' ) { + + if ( name[0] == '%' ) + { filename = GetProfile().GetUserBasedPath(name, "") + ".txt"; - } else { + } + else + { filename = std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + "/" + name + std::string(".txt"); } - + if ( ReadText(filename) ) { Justif(); @@ -1249,7 +1252,7 @@ void CEdit::SetText(const char *text, bool bNew) { int i, j, font; bool bBOL; - + if ( !bNew ) UndoMemorize(OPERUNDO_SPEC); m_len = strlen(text); @@ -1387,10 +1390,11 @@ int CEdit::GetTextLength() std::string GetNameParam(std::string cmd, int rank) { - std::vector results; + std::vector results; boost::split(results, cmd, boost::is_any_of(" ;")); - - if (results.size() > static_cast(rank)) { + + if (results.size() > static_cast(rank)) + { return results.at(rank); } @@ -1402,11 +1406,12 @@ std::string GetNameParam(std::string cmd, int rank) int GetValueParam(std::string cmd, int rank) { - std::vector results; + std::vector results; boost::split(results, cmd, boost::is_any_of(" ;")); int return_value = 0; - - if (results.size() > static_cast(rank)) { + + if (results.size() > static_cast(rank)) + { return_value = atoi(results.at(rank).c_str()); } @@ -1419,7 +1424,8 @@ void CEdit::FreeImage() { std::string filename; - for (int i = 0 ; i < m_imageTotal; i++ ) { + for (int i = 0 ; i < m_imageTotal; i++ ) + { filename = GetProfile().GetUserBasedPath(m_image[i].name, "diagram") + ".png"; m_engine->DeleteTexture(filename); } @@ -1448,12 +1454,14 @@ bool CEdit::ReadText(std::string filename, int addSize) bool bInSoluce, bBOL; if ( filename[0] == 0 ) return false; + boost::replace_all(filename, "\\", "/"); - + /* This is ugly but doesn't require many changes in code. If file doesn't exists it's posible filename is absolute not full path */ std::string path = filename; - if (!fs::exists(path)) { + if (!fs::exists(path)) + { path = CApplication::GetInstancePointer()->GetDataDirPath() + "/" + filename; } @@ -1484,10 +1492,11 @@ bool CEdit::ReadText(std::string filename, int addSize) m_format.clear(); m_format.reserve(m_maxChar+1); - for (i = 0; i <= m_maxChar+1; i++) { + for (i = 0; i <= m_maxChar+1; i++) + { m_format.push_back(0); } - + fclose(file); bInSoluce = false; @@ -1951,7 +1960,8 @@ void CEdit::SetMaxChar(int max) m_format.clear(); m_format.reserve(m_maxChar+1); - for (int i = 0; i <= m_maxChar+1; i++) { + for (int i = 0; i <= m_maxChar+1; i++) + { m_format.push_back(0); } @@ -2142,10 +2152,12 @@ bool CEdit::GetDisplaySpec() void CEdit::SetMultiFont(bool bMulti) { m_format.clear(); - - if (bMulti) { + + if (bMulti) + { m_format.reserve(m_maxChar+1); - for (int i = 0; i <= m_maxChar+1; i++) { + for (int i = 0; i <= m_maxChar+1; i++) + { m_format.push_back(0); } } @@ -2522,26 +2534,33 @@ bool CEdit::Copy(bool memorize_cursor) c1 = m_cursor1; c2 = m_cursor2; - if ( c1 > c2 ) { + if ( c1 > c2 ) + { Math::Swap(c1, c2); // always c1 <= c2 } - if ( c1 == c2 ) { - while ( c1 > 0 ) { - if ( m_text[c1 - 1] == '\n' ) { + if ( c1 == c2 ) + { + while ( c1 > 0 ) + { + if ( m_text[c1 - 1] == '\n' ) + { break; } c1--; } - while ( c2 < m_len ) { + while ( c2 < m_len ) + { c2++; - if ( m_text[c2 - 1] == '\n' ) { + if ( m_text[c2 - 1] == '\n' ) + { break; } } } - if ( c1 == c2 ) { + if ( c1 == c2 ) + { return false; } @@ -2553,8 +2572,9 @@ bool CEdit::Copy(bool memorize_cursor) text[len] = 0; widgetSetClipboardText(text); delete []text; - - if (memorize_cursor) { + + if (memorize_cursor) + { m_cursor1 = c1; m_cursor2 = c2; } @@ -2569,28 +2589,33 @@ bool CEdit::Paste() char c; char* text; - if ( !m_bEdit ) { + if ( !m_bEdit ) + { return false; } text = widgetGetClipboardText(); - - if ( text == nullptr ) { + + if ( text == nullptr ) + { return false; } UndoMemorize(OPERUNDO_SPEC); - for ( unsigned int i = 0; i < strlen(text); i++ ) { + for ( unsigned int i = 0; i < strlen(text); i++ ) + { c = text[i]; - if ( c == '\r' ) { + if ( c == '\r' ) + { continue; } - if ( c == '\t' && m_bAutoIndent ) { + if ( c == '\t' && m_bAutoIndent ) + { continue; } InsertOne(c); } - + free(text); Justif(); ColumnFix(); @@ -2603,7 +2628,8 @@ bool CEdit::Paste() bool CEdit::Undo() { - if ( !m_bEdit ) { + if ( !m_bEdit ) + { return false; } @@ -2617,7 +2643,8 @@ void CEdit::Insert(char character) { int i, level, tab; - if ( !m_bEdit ) { + if ( !m_bEdit ) + { return; } @@ -3219,7 +3246,7 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format) void CEdit::UpdateScroll() { float value; - + if ( m_scroll != nullptr ) { if ( m_lineTotal <= m_lineVisible ) @@ -3243,3 +3270,4 @@ void CEdit::UpdateScroll() } } + diff --git a/src/ui/edit.h b/src/ui/edit.h index df4f143..acdf72c 100644 --- a/src/ui/edit.h +++ b/src/ui/edit.h @@ -239,7 +239,7 @@ protected: void UndoFlush(); void UndoMemorize(OperUndo oper); bool UndoRecall(); - + void UpdateScroll(); protected: @@ -294,3 +294,4 @@ protected: } + diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 6397a73..3fb9b79 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -369,3 +369,4 @@ float CEditValue::GetMaxValue() } } + diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h index 5d6e643..2734847 100644 --- a/src/ui/editvalue.h +++ b/src/ui/editvalue.h @@ -85,3 +85,4 @@ protected: } + diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp index c98e3b6..a8ee41c 100644 --- a/src/ui/gauge.cpp +++ b/src/ui/gauge.cpp @@ -144,3 +144,4 @@ float CGauge::GetLevel() } + diff --git a/src/ui/gauge.h b/src/ui/gauge.h index a2b689a..3dbeef8 100644 --- a/src/ui/gauge.h +++ b/src/ui/gauge.h @@ -31,24 +31,23 @@ namespace Ui { class CGauge : public CControl { - public: - CGauge(); - virtual ~CGauge(); +public: + CGauge(); + virtual ~CGauge(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); - void SetLevel(float level); - float GetLevel(); + void SetLevel(float level); + float GetLevel(); - protected: - - protected: - float m_level; +protected: + float m_level; }; } + diff --git a/src/ui/group.cpp b/src/ui/group.cpp index c3c7028..908ac19 100644 --- a/src/ui/group.cpp +++ b/src/ui/group.cpp @@ -639,3 +639,4 @@ void CGroup::Draw() } + diff --git a/src/ui/group.h b/src/ui/group.h index fd31716..89996cc 100644 --- a/src/ui/group.h +++ b/src/ui/group.h @@ -46,3 +46,4 @@ protected: } + diff --git a/src/ui/image.cpp b/src/ui/image.cpp index 94b9586..9a14789 100644 --- a/src/ui/image.cpp +++ b/src/ui/image.cpp @@ -151,3 +151,4 @@ void CImage::Draw() } + diff --git a/src/ui/image.h b/src/ui/image.h index c40828c..fd71e33 100644 --- a/src/ui/image.h +++ b/src/ui/image.h @@ -52,3 +52,4 @@ protected: } + diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 893cd05..845579e 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -47,8 +47,10 @@ CInterface::~CInterface() void CInterface::Flush() { - for (int i = 0; i < MAXCONTROL; i++ ) { - if ( m_table[i] != nullptr ) { + for (int i = 0; i < MAXCONTROL; i++ ) + { + if ( m_table[i] != nullptr ) + { delete m_table[i]; m_table[i] = nullptr; } @@ -58,7 +60,8 @@ void CInterface::Flush() int CInterface::GetNextFreeControl() { - for (int i = 10; i < MAXCONTROL-1; i++) { + for (int i = 10; i < MAXCONTROL-1; i++) + { if (m_table[i] == nullptr) return i; } @@ -92,7 +95,8 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E if (eventMsg == EVENT_NULL) eventMsg = GetUniqueEventType(); - switch (eventMsg) { + switch (eventMsg) + { case EVENT_WINDOW0: index = 0; break; case EVENT_WINDOW1: index = 1; break; case EVENT_WINDOW2: index = 2; break; @@ -249,9 +253,12 @@ CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventTyp bool CInterface::DeleteControl(EventType eventMsg) { - for (int i = 0; i < MAXCONTROL; i++) { - if ( m_table[i] != nullptr ) { - if (eventMsg == m_table[i]->GetEventType()) { + for (int i = 0; i < MAXCONTROL; i++) + { + if ( m_table[i] != nullptr ) + { + if (eventMsg == m_table[i]->GetEventType()) + { delete m_table[i]; m_table[i] = nullptr; return true; @@ -265,8 +272,10 @@ bool CInterface::DeleteControl(EventType eventMsg) CControl* CInterface::SearchControl(EventType eventMsg) { - for (int i = 0; i < MAXCONTROL; i++) { - if (m_table[i] != nullptr) { + for (int i = 0; i < MAXCONTROL; i++) + { + if (m_table[i] != nullptr) + { if (eventMsg == m_table[i]->GetEventType()) return m_table[i]; } @@ -326,4 +335,5 @@ void CInterface::Draw() } } -} +} // namespace Ui + diff --git a/src/ui/interface.h b/src/ui/interface.h index ebc80e7..d5734f0 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -55,48 +55,49 @@ const int MAXCONTROL = 100; class CInterface { - public: - CInterface(); - ~CInterface(); - - bool EventProcess(const Event &event); - bool GetTooltip(Math::Point pos, std::string &name); - - void Flush(); - CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - - CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); - CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name); - - bool DeleteControl(EventType eventMsg); - CControl* SearchControl(EventType eventMsg); - - void Draw(); - - protected: - int GetNextFreeControl(); - template inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - - CEventQueue* m_event; - Gfx::CEngine* m_engine; - Gfx::CCamera* m_camera; - - CControl* m_table[MAXCONTROL]; +public: + CInterface(); + ~CInterface(); + + bool EventProcess(const Event &event); + bool GetTooltip(Math::Point pos, std::string &name); + + void Flush(); + CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + + CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f); + CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name); + + bool DeleteControl(EventType eventMsg); + CControl* SearchControl(EventType eventMsg); + + void Draw(); + +protected: + int GetNextFreeControl(); + template inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + + CEventQueue* m_event; + Gfx::CEngine* m_engine; + Gfx::CCamera* m_camera; + + CControl* m_table[MAXCONTROL]; }; } + diff --git a/src/ui/key.cpp b/src/ui/key.cpp index b181f70..1f8cff5 100644 --- a/src/ui/key.cpp +++ b/src/ui/key.cpp @@ -214,3 +214,4 @@ InputBinding CKey::GetBinding() } // namespace Ui + diff --git a/src/ui/label.cpp b/src/ui/label.cpp index b5195b5..76a95f2 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -66,7 +66,8 @@ void CLabel::Draw() pos.y = m_pos.y + m_dim.y / 2.0f; - switch (m_textAlign) { + switch (m_textAlign) + { case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x; break; case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break; case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x + m_dim.x; break; @@ -76,3 +77,4 @@ void CLabel::Draw() } } + diff --git a/src/ui/label.h b/src/ui/label.h index c9e1050..305aca2 100644 --- a/src/ui/label.h +++ b/src/ui/label.h @@ -29,15 +29,16 @@ namespace Ui { class CLabel : public CControl { - public: - CLabel(); - virtual ~CLabel(); +public: + CLabel(); + virtual ~CLabel(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); }; } + diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 7593582..f6c3ed9 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -33,13 +33,15 @@ CList::CList() : CControl() m_button[i] = nullptr; m_scroll = nullptr; - for (int i = 0; i < LISTMAXTOTAL; i++) { + for (int i = 0; i < LISTMAXTOTAL; i++) + { m_text[i][0] = 0; m_check[i] = false; m_enable[i] = true; } - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) + { m_tabs[i] = 0.0f; m_justifs[i] = Gfx::TEXT_ALIGN_LEFT; } @@ -57,7 +59,8 @@ CList::CList() : CControl() CList::~CList() { - for (int i = 0; i < LISTMAXDISPLAY; i++) { + for (int i = 0; i < LISTMAXDISPLAY; i++) + { if (m_button[i] != nullptr) delete m_button[i]; } @@ -103,8 +106,10 @@ bool CList::MoveAdjust() Math::Point ipos, idim, ppos, ddim; float marging, h; - for (int i = 0; i < LISTMAXDISPLAY; i++) { - if (m_button[i] != nullptr) { + for (int i = 0; i < LISTMAXDISPLAY; i++) + { + if (m_button[i] != nullptr) + { delete m_button[i]; m_button[i] = nullptr; } @@ -142,7 +147,8 @@ bool CList::MoveAdjust() ppos.y = ipos.y + idim.y - h; ddim.x = idim.x - SCROLL_WIDTH; ddim.y = h; - for (int i = 0; i < m_displayLine; i++) { + for (int i = 0; i < m_displayLine; i++) + { m_button[i] = new CButton(); m_button[i]->Create(ppos, ddim, -1, EVENT_NULL); m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); @@ -154,7 +160,8 @@ bool CList::MoveAdjust() m_eventButton[i] = m_button[i]->GetEventType(); } - if ( m_scroll != nullptr ) { + if ( m_scroll != nullptr ) + { ppos.x = ipos.x + idim.x - SCROLL_WIDTH; ppos.y = ipos.y; ddim.x = SCROLL_WIDTH; @@ -206,8 +213,10 @@ void CList::SetDim(Math::Point dim) bool CList::SetState(int state, bool bState) { - if (state & STATE_ENABLE) { - for (int i = 0; i < m_displayLine; i++) { + if (state & STATE_ENABLE) + { + for (int i = 0; i < m_displayLine; i++) + { if (m_button[i] != nullptr) m_button[i]->SetState(state, bState); } @@ -221,8 +230,10 @@ bool CList::SetState(int state, bool bState) bool CList::SetState(int state) { - if (state & STATE_ENABLE) { - for (int i = 0; i < m_displayLine; i++) { + if (state & STATE_ENABLE) + { + for (int i = 0; i < m_displayLine; i++) + { if (m_button[i] != nullptr) m_button[i]->SetState(state); } @@ -236,8 +247,10 @@ bool CList::SetState(int state) bool CList::ClearState(int state) { - if (state & STATE_ENABLE) { - for (int i = 0; i < m_displayLine; i++) { + if (state & STATE_ENABLE) + { + for (int i = 0; i < m_displayLine; i++) + { if (m_button[i] != nullptr) m_button[i]->ClearState(state); } @@ -254,15 +267,20 @@ bool CList::ClearState(int state) bool CList::EventProcess(const Event &event) { int i; - if (m_bBlink && event.type == EVENT_FRAME) { + if (m_bBlink && event.type == EVENT_FRAME) + { i = m_selectLine-m_firstLine; - if (i >= 0 && i < 4 && m_button[i] != nullptr) { + if (i >= 0 && i < 4 && m_button[i] != nullptr) + { m_blinkTime += event.rTime; - if (Math::Mod(m_blinkTime, 0.7f) < 0.3f) { + if (Math::Mod(m_blinkTime, 0.7f) < 0.3f) + { m_button[i]->ClearState(STATE_ENABLE); m_button[i]->ClearState(STATE_CHECK); - } else { + } + else + { m_button[i]->SetState(STATE_ENABLE); m_button[i]->SetState(STATE_CHECK); } @@ -274,7 +292,8 @@ bool CList::EventProcess(const Event &event) if ((m_state & STATE_ENABLE) == 0) return true; - if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mousePos)) { + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mousePos)) + { if (m_firstLine > 0) m_firstLine--; UpdateScroll(); @@ -282,7 +301,8 @@ bool CList::EventProcess(const Event &event) return true; } - if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos)) { + if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos)) + { if (m_firstLine < m_totalLine - m_displayLine) m_firstLine++; UpdateScroll(); @@ -292,9 +312,11 @@ bool CList::EventProcess(const Event &event) CControl::EventProcess(event); - if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos)) { + if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos)) + { m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); - for (i = 0; i < m_displayLine; i++) { + for (i = 0; i < m_displayLine; i++) + { if (i + m_firstLine >= m_totalLine) break; if (m_button[i] != nullptr) @@ -302,16 +324,20 @@ bool CList::EventProcess(const Event &event) } } - if (m_bSelectCap) { - for (i = 0; i < m_displayLine; i++) { + if (m_bSelectCap) + { + for (i = 0; i < m_displayLine; i++) + { if (i + m_firstLine >= m_totalLine) break; - if (m_button[i] != nullptr) { + if (m_button[i] != nullptr) + { if (!m_button[i]->EventProcess(event)) return false; - if (event.type == m_eventButton[i]) { + if (event.type == m_eventButton[i]) + { SetSelect(m_firstLine + i); Event newEvent = event; @@ -322,11 +348,13 @@ bool CList::EventProcess(const Event &event) } } - if (m_scroll != nullptr) { + if (m_scroll != nullptr) + { if (!m_scroll->EventProcess(event)) return false; - if (event.type == m_eventScroll) { + if (event.type == m_eventScroll) + { MoveScroll(); UpdateButton(); } @@ -354,10 +382,12 @@ void CList::Draw() dp = 0.5f / 256.0f; - if (m_icon != -1) { + if (m_icon != -1) + { dim = m_dim; - if (m_icon == 0) { + if (m_icon == 0) + { m_engine->SetTexture("button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -365,7 +395,9 @@ void CList::Draw() uv1.y = 64.0f / 256.0f; // u-v texture uv2.x = 160.0f / 256.0f; uv2.y = 96.0f / 256.0f; - } else { + } + else + { m_engine->SetTexture("button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); @@ -374,7 +406,8 @@ void CList::Draw() uv2.x = 156.0f / 256.0f; uv2.y = 92.0f / 256.0f; - if (m_button[0] != nullptr) { + if (m_button[0] != nullptr) + { dim = m_button[0]->GetDim(); dim.y *= m_displayLine; // background sounds spot behind } @@ -390,9 +423,11 @@ void CList::Draw() DrawIcon(m_pos, dim, uv1, uv2, corner, 8.0f / 256.0f); } - if ( m_totalLine < m_displayLine ) { // no buttons to the bottom? + if ( m_totalLine < m_displayLine ) // no buttons to the bottom? + { i = m_totalLine; - if ( m_button[i] != 0 ) { + if ( m_button[i] != 0 ) + { pos = m_button[i]->GetPos(); dim = m_button[i]->GetDim(); pos.y += dim.y * 1.1f; @@ -413,11 +448,13 @@ void CList::Draw() } } - for (i = 0; i < m_displayLine; i++) { + for (i = 0; i < m_displayLine; i++) + { if ( i + m_firstLine >= m_totalLine ) break; - if ( m_button[i] != nullptr ) { + if ( m_button[i] != nullptr ) + { if ( !m_bBlink && i + m_firstLine < m_totalLine ) m_button[i]->SetState(STATE_ENABLE, m_enable[i+m_firstLine] && (m_state & STATE_ENABLE) ); @@ -426,22 +463,27 @@ void CList::Draw() // draws text in the box pos = m_button[i]->GetPos(); dim = m_button[i]->GetDim(); - if ( m_tabs[0] == 0.0f ) { + if ( m_tabs[0] == 0.0f ) + { ppos.x = pos.x + dim.y * 0.5f; ppos.y = pos.y + dim.y * 0.5f; ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; ddim.x = dim.x-dim.y; DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_LEFT); - } else { + } + else + { ppos.x = pos.x + dim.y * 0.5f; ppos.y = pos.y + dim.y * 0.5f; ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; pb = m_text[i + m_firstLine]; - for (int j = 0; j < 10; j++) { + for (int j = 0; j < 10; j++) + { pe = strchr(pb, '\t'); if ( pe == 0 ) strcpy(text, pb); - else { + else + { strncpy(text, pb, pe - pb); text[pe - pb] = 0; } @@ -454,7 +496,8 @@ void CList::Draw() } } - if ( (m_state & STATE_EXTEND) && i < m_totalLine) { + if ( (m_state & STATE_EXTEND) && i < m_totalLine) + { pos = m_button[i]->GetPos(); dim = m_button[i]->GetDim(); pos.x += dim.x - dim.y * 0.75f; @@ -464,7 +507,8 @@ void CList::Draw() dim.x -= 4.0f / 640.0f; dim.y -= 4.0f / 480.0f; - if ( m_check[i + m_firstLine] ) { + if ( m_check[i + m_firstLine] ) + { m_engine->SetTexture("button1.png"); m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); uv1.x = 64.0f / 256.0f; @@ -487,15 +531,20 @@ void CList::Draw() uv2.x -= dp; uv2.y -= dp; DrawIcon(pos, dim, uv1, uv2); // draws v - } else { + } + else + { m_engine->SetTexture("button1.png"); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw - if ( i + m_firstLine == m_selectLine ) { + if ( i + m_firstLine == m_selectLine ) + { uv1.x =224.0f / 256.0f; // < uv1.y =192.0f / 256.0f; uv2.x =256.0f / 256.0f; uv2.y =224.0f / 256.0f; - } else { + } + else + { uv1.x = 96.0f / 256.0f; // x uv1.y = 32.0f / 256.0f; uv2.x =128.0f / 256.0f; @@ -560,7 +609,8 @@ void CList::SetSelect(int i) { if ( m_bSelectCap ) m_selectLine = i; - else { + else + { m_firstLine = i; UpdateScroll(); } @@ -603,8 +653,10 @@ void CList::SetBlink(bool bEnable) i = m_selectLine-m_firstLine; - if (i >= 0 && i < 4 && m_button[i] != nullptr) { - if ( !bEnable ) { + if (i >= 0 && i < 4 && m_button[i] != nullptr) + { + if ( !bEnable ) + { m_button[i]->SetState(STATE_CHECK); m_button[i]->ClearState(STATE_ENABLE); } @@ -744,17 +796,21 @@ void CList::UpdateButton() state = CControl::GetState(); j = m_firstLine; - for (i = 0; i < m_displayLine; i++) { + for (i = 0; i < m_displayLine; i++) + { if (m_button[i] == nullptr) continue; m_button[i]->SetState(STATE_CHECK, (j == m_selectLine)); - if ( j < m_totalLine ) { + if ( j < m_totalLine ) + { //? m_button[i]->SetName(m_text[j]); m_button[i]->SetName(" "); // blank button m_button[i]->SetState(STATE_ENABLE, (state & STATE_ENABLE)); - } else { + } + else + { m_button[i]->SetName(" "); // blank button m_button[i]->ClearState(STATE_ENABLE); } @@ -771,11 +827,14 @@ void CList::UpdateScroll() if (m_scroll == nullptr) return; - if (m_totalLine <= m_displayLine) { + if (m_totalLine <= m_displayLine) + { ratio = 1.0f; value = 0.0f; step = 0.0f; - } else { + } + else + { ratio = static_cast(m_displayLine) / m_totalLine; if ( ratio > 1.0f ) ratio = 1.0f; @@ -817,3 +876,4 @@ void CList::MoveScroll() } // namespace Ui + diff --git a/src/ui/list.h b/src/ui/list.h index 3d2e517..a2e033f 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -122,3 +122,4 @@ class CList : public CControl } // namespace Ui + diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 696c156..dfc2d52 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -174,8 +174,10 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; + + // TODO: replace NDEBUG with something like BUILD_TYPE == "DEBUG"/"RELEASE" #ifdef NDEBUG - m_savegameDir = GetSystemUtils()->savegameDirectoryLocation(); + m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); #else m_savegameDir = "savegame"; #endif @@ -756,7 +758,8 @@ pb->SetState(STATE_SHADOW); m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPss ) { - if (!m_sound->IsPlayingMusic()) { + if (!m_sound->IsPlayingMusic()) + { m_sound->PlayMusic("Intro1.ogg", false); } } @@ -1623,7 +1626,7 @@ pos.y -= 0.048f; } if ( m_phase == PHASE_READ || - m_phase == PHASE_READs ) + m_phase == PHASE_READs ) { pos.x = 0.10f; pos.y = 0.10f; @@ -2029,14 +2032,15 @@ bool CMainDialog::EventProcess(const Event &event) m_phase != PHASE_SETUPcs && m_phase != PHASE_SETUPss ) { - if (!m_sound->IsPlayingMusic()) { + if (!m_sound->IsPlayingMusic()) + { m_sound->PlayMusic("Intro2.ogg", true); } } if ( m_phase == PHASE_WELCOME1 || - m_phase == PHASE_WELCOME2 || - m_phase == PHASE_WELCOME3 ) + m_phase == PHASE_WELCOME2 || + m_phase == PHASE_WELCOME3 ) { float intensity; int mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; @@ -2627,15 +2631,18 @@ bool CMainDialog::EventProcess(const Event &event) pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) break; pc = static_cast(pw->SearchControl(EVENT_INTERFACE_FULL)); - if ( pc == 0 ) break; - - if ( pc->TestState(STATE_CHECK) ) { - m_setupFull = false; - pc->ClearState(STATE_CHECK); - } else { - m_setupFull = true; - pc->SetState(STATE_CHECK); - } + if ( pc == 0 ) break; + + if ( pc->TestState(STATE_CHECK) ) + { + m_setupFull = false; + pc->ClearState(STATE_CHECK); + } + else + { + m_setupFull = true; + pc->SetState(STATE_CHECK); + } UpdateApply(); break; @@ -2647,7 +2654,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( pb == 0 ) break; pb->ClearState(STATE_PRESS); pb->ClearState(STATE_HILIGHT); - // TODO: uncomment when changing display is implemented + // TODO: uncomment when changing display is implemented //ChangeDisplay(); UpdateApply(); break; @@ -4297,16 +4304,19 @@ void CMainDialog::DefPerso() bool CMainDialog::IsIOReadScene() { fs::directory_iterator end_iter; - + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); - if (fs::exists(saveDir) && fs::is_directory(saveDir)) { - for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { - if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { + if (fs::exists(saveDir) && fs::is_directory(saveDir)) + { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) + { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) + { return true; } } } - + return false; } @@ -4390,27 +4400,34 @@ void CMainDialog::IOReadList() if ( pl == 0 ) return; pl->Flush(); - + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); m_saveList.clear(); - - if (fs::exists(saveDir) && fs::is_directory(saveDir)) { - for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { - if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { - + + if (fs::exists(saveDir) && fs::is_directory(saveDir)) + { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) + { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) + { + file = fopen((dir_iter->path() / "data.sav").make_preferred().string().c_str(), "r"); if ( file == NULL ) continue; - while ( fgets(line, 500, file) != NULL ) { - for ( i=0 ; i<500 ; i++ ) { + while ( fgets(line, 500, file) != NULL ) + { + for ( i=0 ; i<500 ; i++ ) + { if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) { + if ( line[i] == '/' && line[i+1] == '/' ) + { line[i] = 0; break; } } - if ( Cmd(line, "Title") ) { + if ( Cmd(line, "Title") ) + { OpString(line, "text", name); break; } @@ -4422,9 +4439,10 @@ void CMainDialog::IOReadList() } } } - - // zly indeks - if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { + + // invalid index + if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) + { GetResource(RES_TEXT, RT_IO_NEW, name); pl->SetItemName(m_saveList.size(), name); } @@ -4453,22 +4471,24 @@ void CMainDialog::IOUpdateList() sel = pl->GetSelect(); max = pl->GetTotal(); - if (m_saveList.size() <= static_cast(sel)) { + if (m_saveList.size() <= static_cast(sel)) return; - } - + std::string filename = (m_saveList.at(sel) / "screen.png").make_preferred().string(); if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { - if ( sel < max-1 ) { + if ( sel < max-1 ) + { pi->SetFilenameImage(filename.c_str()); } - else { + else + { pi->SetFilenameImage(""); } pb = static_cast(pw->SearchControl(EVENT_INTERFACE_IODELETE)); - if ( pb != nullptr ) { + if ( pb != nullptr ) + { pb->SetState(STATE_ENABLE, sel < max-1); } } @@ -4500,11 +4520,13 @@ void CMainDialog::IODeleteScene() try { - if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) { + if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) + { fs::remove_all(m_saveList.at(sel)); } } - catch (std::exception & e) { + catch (std::exception & e) + { GetLogger()->Error("Error removing save %s : %s\n", pl->GetItemName(sel), e.what()); } @@ -4516,8 +4538,10 @@ std::string clearName(char *name) { std::string ret; int len = strlen(name); - for (int i = 0; i < len; i++) { - if (isalnum(name[i])) { + for (int i = 0; i < len; i++) + { + if (isalnum(name[i])) + { ret += name[i]; } } @@ -4542,19 +4566,24 @@ bool CMainDialog::IOWriteScene() if ( pe == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 ) { + if ( sel == -1 ) + { return false; } - + fs::path dir; pe->GetText(info, 100); - if (static_cast(sel) >= m_saveList.size()) { + if (static_cast(sel) >= m_saveList.size()) + { dir = fs::path(m_savegameDir) / m_main->GetGamerName() / ("save" + clearName(info)); - } else { + } + else + { dir = m_saveList.at(sel); - } - - if (!fs::exists(dir)) { + } + + if (!fs::exists(dir)) + { fs::create_directories(dir); } @@ -4585,7 +4614,8 @@ bool CMainDialog::IOReadScene() if ( pl == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 || m_saveList.size() <= static_cast(sel) ) { + if ( sel == -1 || m_saveList.size() <= static_cast(sel) ) + { return false; } @@ -4593,33 +4623,42 @@ bool CMainDialog::IOReadScene() std::string fileCbot = (m_saveList.at(sel) / "cbot.run").make_preferred().string(); file = fopen(fileName.c_str(), "r"); - if ( file == NULL ) { + if ( file == NULL ) + { return false; } - while ( fgets(line, 500, file) != NULL ) { - for ( i=0 ; i<500 ; i++ ) { + while ( fgets(line, 500, file) != NULL ) + { + for ( i=0 ; i<500 ; i++ ) + { if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) { + if ( line[i] == '/' && line[i+1] == '/' ) + { line[i] = 0; break; } } - if ( Cmd(line, "Mission") ) { + if ( Cmd(line, "Mission") ) + { OpString(line, "base", m_sceneName); m_sceneRank = OpInt(line, "rank", 0); - if ( strcmp(m_sceneName, "user") == 0 ) { + if ( strcmp(m_sceneName, "user") == 0 ) + { m_sceneRank = m_sceneRank%100; OpString(line, "dir", dir); - for ( i=0 ; iGetVideoResolutionList(modes, true, true); int i = 0; std::stringstream mode_text; - for (Math::IntPoint mode : modes) { - mode_text.str(""); - mode_text << mode.x << "x" << mode.y; - pl->SetItemName(i++, mode_text.str().c_str()); + for (Math::IntPoint mode : modes) + { + mode_text.str(""); + mode_text << mode.x << "x" << mode.y; + pl->SetItemName(i++, mode_text.str().c_str()); } pl->SetSelect(m_setupSelMode); @@ -5535,25 +5575,29 @@ void CMainDialog::SetupMemorize() GetProfile().SetLocalProfileInt("Setup", "Sound3D", m_sound->GetSound3D()); GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode()); GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue()); - + /* screen setup */ if (m_setupFull) - GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1); + GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1); else - GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0); - + GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0); + CList *pl; CWindow *pw; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw != 0 ) { - pl = static_cast(pw->SearchControl(EVENT_LIST2)); - if ( pl != 0 ) { - GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); - } - } else { + if ( pw != 0 ) + { + pl = static_cast(pw->SearchControl(EVENT_LIST2)); + if ( pl != 0 ) + { + GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); + } + } + else + { // TODO: Default value } - + std::stringstream key; for (int i = 0; i < INPUT_SLOT_MAX; i++) { @@ -5765,7 +5809,7 @@ void CMainDialog::SetupRecall() { m_sound->SetMusicVolume(iValue); } - + if ( GetProfile().GetLocalProfileInt("Setup", "Sound3D", iValue) ) { m_sound->SetSound3D(iValue == 1); @@ -5813,13 +5857,15 @@ void CMainDialog::SetupRecall() { m_bDeleteGamer = iValue; } - - if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) { - m_setupSelMode = iValue; + + if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) + { + m_setupSelMode = iValue; } - - if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) { - m_setupFull = (iValue == 1); + + if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) + { + m_setupFull = (iValue == 1); } } @@ -6584,7 +6630,7 @@ void CMainDialog::WriteGamerPerso(char *gamer) if ( file == NULL ) return; m_main->SetNumericLocale(); - + sprintf(line, "Head face=%d glasses=%d hair=%.2f;%.2f;%.2f;%.2f\n", m_perso.face, m_perso.glasses, m_perso.colorHair.r, m_perso.colorHair.g, m_perso.colorHair.b, m_perso.colorHair.a); @@ -6596,7 +6642,7 @@ void CMainDialog::WriteGamerPerso(char *gamer) fputs(line, file); fclose(file); - + m_main->RestoreNumericLocale(); } @@ -6615,7 +6661,7 @@ void CMainDialog::ReadGamerPerso(char *gamer) sprintf(filename, "%s/%s/face.gam", m_savegameDir.c_str(), gamer); file = fopen(filename, "r"); if ( file == NULL ) return; - + m_main->SetNumericLocale(); while ( fgets(line, 100, file) != NULL ) @@ -6649,7 +6695,7 @@ void CMainDialog::ReadGamerPerso(char *gamer) } fclose(file); - + m_main->RestoreNumericLocale(); } @@ -6836,3 +6882,4 @@ bool CMainDialog::NextMission() } // namespace Ui + diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index afdf94f..96aff2a 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -262,7 +262,7 @@ protected: Math::Point m_partiPos[10]; SceneInfo m_sceneInfo[MAXSCENE]; - + std::vector m_saveList; }; diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp index 1143a77..8c81160 100644 --- a/src/ui/mainmap.cpp +++ b/src/ui/mainmap.cpp @@ -55,7 +55,8 @@ void CMainMap::CreateMap() Math::Point pos, dim; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW1)); - if (pw == nullptr) { + if (pw == nullptr) + { pos.x = 0.0f; pos.y = 0.0f; dim.x = 0.0f; @@ -106,7 +107,8 @@ void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water) return; pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); - if (pm != nullptr) { + if (pm != nullptr) + { pm->SetFloorColor(floor); pm->SetWaterColor(water); } @@ -124,9 +126,12 @@ void CMainMap::ShowMap(bool bShow) if (pw == nullptr) return; - if (bShow) { + if (bShow) + { DimMap(); - } else { + } + else + { pm = static_cast(pw->SearchControl(EVENT_OBJECT_MAP)); if (pm != nullptr) pm->ClearState(STATE_VISIBLE); @@ -164,7 +169,8 @@ void CMainMap::DimMap() pm->SetDim(dim); ps = static_cast(pw->SearchControl(EVENT_OBJECT_MAPZOOM)); - if (ps != nullptr) { + if (ps != nullptr) + { ps->SetState(STATE_VISIBLE, (m_mapMode != 0)); dim.x = SCROLL_WIDTH; @@ -392,3 +398,4 @@ void CMainMap::SetHighlight(CObject* pObj) } + diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h index 9d0d72f..9b20548 100644 --- a/src/ui/mainmap.h +++ b/src/ui/mainmap.h @@ -34,37 +34,37 @@ namespace Ui { class CMainMap { - public: - CMainMap(); - ~CMainMap(); - - void UpdateMap(); - void CreateMap(); - void SetFixImage(const char *filename); - void FloorColorMap(Gfx::Color floor, Gfx::Color water); - void ShowMap(bool bShow); - void DimMap(); - float GetZoomMap(); - void ZoomMap(float zoom); - void ZoomMap(); - void MapEnable(bool bEnable); - bool GetShowMap(); - bool GetFixImage(); - CObject* DetectMap(Math::Point pos, bool &bInMap); - void SetHighlight(CObject* pObj); - void SetToy(bool bToy); - void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); - - protected: - void CenterMap(); - - protected: - CEventQueue* m_event; - Gfx::CEngine* m_engine; - CInterface* m_interface; - - int m_mapMode; - bool m_bFixImage; +public: + CMainMap(); + ~CMainMap(); + + void UpdateMap(); + void CreateMap(); + void SetFixImage(const char *filename); + void FloorColorMap(Gfx::Color floor, Gfx::Color water); + void ShowMap(bool bShow); + void DimMap(); + float GetZoomMap(); + void ZoomMap(float zoom); + void ZoomMap(); + void MapEnable(bool bEnable); + bool GetShowMap(); + bool GetFixImage(); + CObject* DetectMap(Math::Point pos, bool &bInMap); + void SetHighlight(CObject* pObj); + void SetToy(bool bToy); + void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); + +protected: + void CenterMap(); + +protected: + CEventQueue* m_event; + Gfx::CEngine* m_engine; + CInterface* m_interface; + + int m_mapMode; + bool m_bFixImage; }; } diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h index d679eb0..b185aed 100644 --- a/src/ui/mainshort.h +++ b/src/ui/mainshort.h @@ -34,29 +34,30 @@ namespace Ui { class CMainShort { - public: - CMainShort(); - ~CMainShort(); - - void SetMode(bool bBuilding); - void FlushShortcuts(); - bool CreateShortcuts(); - bool UpdateShortcuts(); - void SelectShortcut(EventType event); - void SelectNext(); - CObject* DetectShort(Math::Point pos); - void SetHighlight(CObject* pObj); - - protected: - - protected: - CEventQueue* m_event; - Gfx::CEngine* m_engine; - CInterface* m_interface; - CRobotMain* m_main; - - CObject* m_shortcuts[20]; - bool m_bBuilding; +public: + CMainShort(); + ~CMainShort(); + + void SetMode(bool bBuilding); + void FlushShortcuts(); + bool CreateShortcuts(); + bool UpdateShortcuts(); + void SelectShortcut(EventType event); + void SelectNext(); + CObject* DetectShort(Math::Point pos); + void SetHighlight(CObject* pObj); + +protected: + +protected: + CEventQueue* m_event; + Gfx::CEngine* m_engine; + CInterface* m_interface; + CRobotMain* m_main; + + CObject* m_shortcuts[20]; + bool m_bBuilding; }; } + diff --git a/src/ui/map.cpp b/src/ui/map.cpp index 33d0fb1..c5f0062 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.cpp @@ -187,14 +187,17 @@ bool CMap::EventProcess(const Event &event) if ( event.type == EVENT_FRAME ) m_time += event.rTime; - if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) ) { + if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) ) + { m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM); if ( DetectObject(event.mousePos, bInMap) != 0 ) m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND); } - if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT ) { - if ( CControl::Detect(event.mousePos) ) { + if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT ) + { + if ( CControl::Detect(event.mousePos) ) + { SelectObject(event.mousePos); return false; } @@ -228,11 +231,13 @@ void CMap::SetHighlight(CObject* pObj) if ( pObj == nullptr ) return; - for (int i = 0; i < MAPMAXOBJECT; i++) { + for (int i = 0; i < MAPMAXOBJECT; i++) + { if ( !m_map[i].bUsed ) continue; - if ( m_map[i].object == pObj ) { + if ( m_map[i].object == pObj ) + { m_highlightRank = i; break; } @@ -262,7 +267,8 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap) min = 10000.0f; best = -1; - for (int i = MAPMAXOBJECT - 1; i >= 0; i--) { + for (int i = MAPMAXOBJECT - 1; i >= 0; i--) + { if ( !m_map[i].bUsed ) continue; if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) @@ -273,7 +279,8 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap) dist = Math::Point(m_map[i].pos.x - pos.x, m_map[i].pos.y - pos.y).Length(); if ( dist > m_half / m_zoom * 8.0f / 100.0f ) continue; // too far? - if ( dist < min ) { + if ( dist < min ) + { min = dist; best = i; } @@ -337,13 +344,15 @@ void CMap::Draw() if ( m_map[i].bUsed ) // selection: DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color); - for ( i=0 ; im_totalMove ; i-- ) { // moving objects: + for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) // moving objects: + { if ( i == m_highlightRank ) continue; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false); @@ -353,7 +362,8 @@ void CMap::Draw() if ( m_map[i].bUsed && i != m_highlightRank ) // selection: DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false); - if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) { + if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) + { i = m_highlightRank; DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true); DrawHighlight(m_map[i].pos); @@ -375,23 +385,27 @@ Math::Point CMap::MapInter(Math::Point pos, float dir) p1.y -= pos.y; limit = m_mapPos.x + m_mapDim.x - pos.x; - if ( p1.x > limit ) { // exceeds the right? + if ( p1.x > limit ) // exceeds the right? + { p1.y = limit*p1.y/p1.x; p1.x = limit; } limit = m_mapPos.y * 0.75f + m_mapDim.y * 0.75f - pos.y; - if ( p1.y > limit ) { // exceeds the top? + if ( p1.y > limit ) // exceeds the top? + { p1.x = limit * p1.x / p1.y; p1.y = limit; } limit = m_mapPos.x - pos.x; - if ( p1.x < limit ) { // exceeds the left? + if ( p1.x < limit ) // exceeds the left? + { p1.y = limit * p1.y / p1.x; p1.x = limit; } limit = m_mapPos.y * 0.75f - pos.y; - if ( p1.y < limit ) { // exceeds the bottom? + if ( p1.y < limit ) // exceeds the bottom? + { p1.x = limit * p1.x / p1.y; p1.y = limit; } @@ -1152,7 +1166,7 @@ void CMap::UpdateObject(CObject* pObj) pos.z = ppos.y; dir += m_angle; } - + color = MAPCOLOR_NULL; if ( type == OBJECT_BASE ) { @@ -1303,3 +1317,4 @@ void CMap::UpdateObject(CObject* pObj) } } + diff --git a/src/ui/map.h b/src/ui/map.h index 258dcdf..4ebe688 100644 --- a/src/ui/map.h +++ b/src/ui/map.h @@ -69,78 +69,79 @@ struct MapObject class CMap : public CControl { - public: - CMap(); - ~CMap(); - - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); - void Draw(); - - void UpdateTerrain(); - void UpdateTerrain(int bx, int by, int ex, int ey); - - void SetFixImage(const char *filename); - bool GetFixImage(); - - void SetOffset(float ox, float oy); - void SetAngle(float angle); - void SetMode(int mode); - void SetToy(bool bToy); - void SetDebug(bool bDebug); - - void SetZoom(float value); - float GetZoom(); - - void SetEnable(bool bEnable); - bool GetEnable(); - - void SetFloorColor(Gfx::Color color); - void SetWaterColor(Gfx::Color color); - - void FlushObject(); - void UpdateObject(CObject* pObj); - - CObject* DetectObject(Math::Point pos, bool &bInMap); - void SetHighlight(CObject* pObj); - - protected: - Math::Point AdjustOffset(Math::Point offset); - void SelectObject(Math::Point pos); - Math::Point MapInter(Math::Point pos, float dir); - void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); - void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite); - void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite); - void DrawHighlight(Math::Point pos); - void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2); - void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2); - void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom); - - protected: - Gfx::CTerrain* m_terrain; - Gfx::CWater* m_water; - CRobotMain* m_main; - - bool m_bEnable; - float m_time; - float m_half; - float m_zoom; - Math::Point m_offset; - float m_angle; - Gfx::Color m_floorColor; - Gfx::Color m_waterColor; - MapObject m_map[MAPMAXOBJECT]; - int m_totalFix; - int m_totalMove; - int m_highlightRank; - Math::Point m_mapPos; - Math::Point m_mapDim; - bool m_bRadar; - char m_fixImage[100]; - int m_mode; - bool m_bToy; - bool m_bDebug; +public: + CMap(); + ~CMap(); + + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool EventProcess(const Event &event); + void Draw(); + + void UpdateTerrain(); + void UpdateTerrain(int bx, int by, int ex, int ey); + + void SetFixImage(const char *filename); + bool GetFixImage(); + + void SetOffset(float ox, float oy); + void SetAngle(float angle); + void SetMode(int mode); + void SetToy(bool bToy); + void SetDebug(bool bDebug); + + void SetZoom(float value); + float GetZoom(); + + void SetEnable(bool bEnable); + bool GetEnable(); + + void SetFloorColor(Gfx::Color color); + void SetWaterColor(Gfx::Color color); + + void FlushObject(); + void UpdateObject(CObject* pObj); + + CObject* DetectObject(Math::Point pos, bool &bInMap); + void SetHighlight(CObject* pObj); + +protected: + Math::Point AdjustOffset(Math::Point offset); + void SelectObject(Math::Point pos); + Math::Point MapInter(Math::Point pos, float dir); + void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color); + void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite); + void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite); + void DrawHighlight(Math::Point pos); + void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2); + void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2); + void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom); + +protected: + Gfx::CTerrain* m_terrain; + Gfx::CWater* m_water; + CRobotMain* m_main; + + bool m_bEnable; + float m_time; + float m_half; + float m_zoom; + Math::Point m_offset; + float m_angle; + Gfx::Color m_floorColor; + Gfx::Color m_waterColor; + MapObject m_map[MAPMAXOBJECT]; + int m_totalFix; + int m_totalMove; + int m_highlightRank; + Math::Point m_mapPos; + Math::Point m_mapDim; + bool m_bRadar; + char m_fixImage[100]; + int m_mode; + bool m_bToy; + bool m_bDebug; }; } + diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index ff7451d..b3422ec 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -467,3 +467,4 @@ float CScroll::GetArrowStep() } } + diff --git a/src/ui/scroll.h b/src/ui/scroll.h index 57d6f8f..c115aa4 100644 --- a/src/ui/scroll.h +++ b/src/ui/scroll.h @@ -34,51 +34,52 @@ const float SCROLL_WIDTH = (15.0f/640.0f); class CScroll : public CControl { - public: - CScroll(); - ~CScroll(); +public: + CScroll(); + ~CScroll(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void SetVisibleValue(float value); - float GetVisibleValue(); + void SetVisibleValue(float value); + float GetVisibleValue(); - void SetVisibleRatio(float value); - float GetVisibleRatio(); + void SetVisibleRatio(float value); + float GetVisibleRatio(); - void SetArrowStep(float step); - float GetArrowStep(); + void SetArrowStep(float step); + float GetArrowStep(); - protected: - void MoveAdjust(); - void AdjustGlint(); - void DrawVertex(Math::Point pos, Math::Point dim, int icon); +protected: + void MoveAdjust(); + void AdjustGlint(); + void DrawVertex(Math::Point pos, Math::Point dim, int icon); - protected: - CButton* m_buttonUp; - CButton* m_buttonDown; +protected: + CButton* m_buttonUp; + CButton* m_buttonDown; - float m_visibleValue; - float m_visibleRatio; - float m_step; + float m_visibleValue; + float m_visibleRatio; + float m_step; - bool m_bCapture; - Math::Point m_pressPos; - float m_pressValue; + bool m_bCapture; + Math::Point m_pressPos; + float m_pressValue; - EventType m_eventUp; - EventType m_eventDown; + EventType m_eventUp; + EventType m_eventDown; }; } + diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index 4462140..7231d5d 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -237,3 +237,4 @@ void CShortcut::DrawVertex(int icon, float zoom) } } + diff --git a/src/ui/shortcut.h b/src/ui/shortcut.h index 7e7899e..6495ba0 100644 --- a/src/ui/shortcut.h +++ b/src/ui/shortcut.h @@ -27,22 +27,23 @@ namespace Ui { class CShortcut : public CControl { - public: - CShortcut(); - ~CShortcut(); +public: + CShortcut(); + ~CShortcut(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType); - bool EventProcess(const Event &event); + bool EventProcess(const Event &event); - void Draw(); + void Draw(); - protected: - void DrawVertex(int icon, float zoom); +protected: + void DrawVertex(int icon, float zoom); - protected: - float m_time; +protected: + float m_time; }; } + diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index f516e70..33293d1 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -581,3 +581,4 @@ float CSlider::GetArrowStep() } + diff --git a/src/ui/slider.h b/src/ui/slider.h index 4912453..bc38aec 100644 --- a/src/ui/slider.h +++ b/src/ui/slider.h @@ -29,54 +29,55 @@ class CButton; class CSlider : public CControl { - public: - CSlider(); - ~CSlider(); +public: + CSlider(); + ~CSlider(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - void SetPos(Math::Point pos); - void SetDim(Math::Point dim); + void SetPos(Math::Point pos); + void SetDim(Math::Point dim); - bool SetState(int state, bool bState); - bool SetState(int state); - bool ClearState(int state); + bool SetState(int state, bool bState); + bool SetState(int state); + bool ClearState(int state); - bool EventProcess(const Event &event); - void Draw(); + bool EventProcess(const Event &event); + void Draw(); - void SetLimit(float min, float max); + void SetLimit(float min, float max); - void SetVisibleValue(float value); - float GetVisibleValue(); + void SetVisibleValue(float value); + float GetVisibleValue(); - void SetArrowStep(float step); - float GetArrowStep(); + void SetArrowStep(float step); + float GetArrowStep(); - protected: - void MoveAdjust(); - void AdjustGlint(); - void DrawVertex(Math::Point pos, Math::Point dim, int icon); +protected: + void MoveAdjust(); + void AdjustGlint(); + void DrawVertex(Math::Point pos, Math::Point dim, int icon); - protected: - CButton* m_buttonLeft; - CButton* m_buttonRight; +protected: + CButton* m_buttonLeft; + CButton* m_buttonRight; - float m_min; - float m_max; - float m_visibleValue; - float m_step; + float m_min; + float m_max; + float m_visibleValue; + float m_step; - bool m_bHoriz; - float m_marginButton; + bool m_bHoriz; + float m_marginButton; - bool m_bCapture; - Math::Point m_pressPos; - float m_pressValue; + bool m_bCapture; + Math::Point m_pressPos; + float m_pressValue; - EventType m_eventUp; - EventType m_eventDown; + EventType m_eventUp; + EventType m_eventDown; }; } + diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 5027924..24a64c4 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1511,7 +1511,7 @@ void CStudio::UpdateDialogList() fs::path path; int i = 0; char time[100]; - + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); @@ -1520,12 +1520,15 @@ void CStudio::UpdateDialogList() path = fs::path(SearchDirectory(false)); fs::directory_iterator end_iter; - if ( fs::exists(path) && fs::is_directory(path) ) { - for( fs::directory_iterator file(path); file != end_iter; file++) { - if (fs::is_regular_file(file->status()) ) { + if ( fs::exists(path) && fs::is_directory(path) ) + { + for( fs::directory_iterator file(path); file != end_iter; file++) + { + if (fs::is_regular_file(file->status()) ) + { std::ostringstream temp; TimeToAscii(fs::last_write_time(file->path()), time); - temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; + temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; pl->SetItemName(i++, temp.str().c_str()); } } @@ -1538,15 +1541,19 @@ void CStudio::UpdateDialogList() std::string CStudio::SearchDirectory(bool bCreate) { char dir[MAX_FNAME]; - if ( m_main->GetIOPublic() ) { + if ( m_main->GetIOPublic() ) + { sprintf(dir, "%s/", m_main->GetPublicDir()); - } else { + } + else + { sprintf(dir, "%s/%s/Program/", m_main->GetSavegameDir(), m_main->GetGamerName()); } - + fs::path path = fs::path(dir); - - if ( bCreate ) { + + if ( bCreate ) + { fs::create_directory(path); } @@ -1629,3 +1636,4 @@ bool CStudio::WriteProgram() } } + diff --git a/src/ui/target.cpp b/src/ui/target.cpp index cc74750..455c530 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -272,3 +272,4 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) } } + diff --git a/src/ui/target.h b/src/ui/target.h index 054524b..2344e59 100644 --- a/src/ui/target.h +++ b/src/ui/target.h @@ -36,19 +36,20 @@ namespace Ui { class CTarget : public CControl { - public: - CTarget(); - ~CTarget(); +public: + CTarget(); + ~CTarget(); - bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); + bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); - bool EventProcess(const Event &event); - void Draw(); - bool GetTooltip(Math::Point pos, std::string &name); + bool EventProcess(const Event &event); + void Draw(); + bool GetTooltip(Math::Point pos, std::string &name); - protected: - CObject* DetectFriendObject(Math::Point pos); +protected: + CObject* DetectFriendObject(Math::Point pos); }; } + diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 1820642..8005939 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -1579,3 +1579,4 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim) } } + diff --git a/src/ui/window.h b/src/ui/window.h index 6cb6e5d..87805e2 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -151,3 +151,4 @@ protected: } + -- cgit v1.2.3-1-g7c22