From 040a7e8f249a190b0d66b10ccec075ad33772d7c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 30 Mar 2013 15:43:09 +0100 Subject: Added function destroy(rank) --- src/script/script.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/script/script.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index d5fe2ce..f09b53a 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -349,6 +349,43 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us return true; } +// Compilation of the instruction "destroy(rank)". + +CBotTypResult CScript::cDestroy(CBotVar* &var, void* user) +{ + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + + return CBotTypResult(CBotTypFloat); +} + +// Instruction "destroy(rank)". + +bool CScript::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + CScript* script = (static_cast(user))->GetRunScript(); + CObject* pObj; + int rank; + + rank = var->GetValInt(); + + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + + pObj = static_cast(iMan->SearchInstance(CLASS_OBJECT, rank)); + if ( pObj == 0 ) + { + return true; + } + else + { + pObj->ExploObject(EXPLO_BOUM, 1.0f); + } + return true; +} + + // Compilation of the instruction "search(type, pos)". @@ -2898,6 +2935,7 @@ void CScript::InitFonctions() CBotProgram::AddFunction("abs", rAbs, CScript::cOneFloat); CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); + CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy); CBotProgram::AddFunction("search", rSearch, CScript::cSearch); CBotProgram::AddFunction("radar", rRadar, CScript::cRadar); CBotProgram::AddFunction("detect", rDetect, CScript::cDetect); diff --git a/src/script/script.h b/src/script/script.h index 982d12b..0d2726a 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -100,6 +100,7 @@ private: static CBotTypResult cTwoFloat(CBotVar* &var, void* user); static CBotTypResult cString(CBotVar* &var, void* user); static CBotTypResult cGetObject(CBotVar* &var, void* user); + static CBotTypResult cDestroy(CBotVar* &var, void* user); static CBotTypResult cSearch(CBotVar* &var, void* user); static CBotTypResult cRadar(CBotVar* &var, void* user); static CBotTypResult cDetect(CBotVar* &var, void* user); @@ -133,6 +134,7 @@ private: static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From b7b5f002a636154033166a2c828765386c14e5a5 Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 30 Mar 2013 16:03:25 +0100 Subject: * Removed warning while compiling brain.cpp * Fix for issue #130 * Fix for issue #128 with wrong sound pitch --- src/object/brain.cpp | 2 +- src/object/robotmain.cpp | 5 +++-- src/sound/oalsound/alsound.cpp | 49 +++++++++++++++++++++++------------------- src/sound/oalsound/channel.cpp | 13 +---------- src/sound/oalsound/channel.h | 1 - 5 files changed, 32 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/object/brain.cpp b/src/object/brain.cpp index fa3e425..951a763 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -2056,7 +2056,7 @@ void CBrain::UpdateInterface(float rTime) pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap()); } - pb = (Ui::CButton*)pw->SearchControl(EVENT_OBJECT_REC); + pb = static_cast(pw->SearchControl(EVENT_OBJECT_REC)); if ( pb != 0 ) { if ( m_bTraceRecord && Math::Mod(m_time, 0.4f) >= 0.2f ) diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index c1e4140..4cea7ed 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1332,7 +1332,7 @@ bool CRobotMain::EventProcess(Event &event) // Management of the console. if (m_phase != PHASE_NAME && !m_movie->IsExist() && - !m_movieLock && !m_editLock && + !m_movieLock && !m_editLock && !m_engine->GetPause() && event.type == EVENT_KEY_DOWN && event.key.key == KEY(PAUSE)) // Pause ? { @@ -1474,8 +1474,9 @@ bool CRobotMain::EventProcess(Event &event) ChangePhase(PHASE_WIN); else if (m_lostDelay > 0.0f) ChangePhase(PHASE_LOST); - else + else if (!m_cmdEdit) { m_dialog->StartAbort(); // do you want to leave? + } } if (event.key.key == KEY(PAUSE)) { diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 8c1cb81..e3a3f4b 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -81,6 +81,7 @@ bool ALSound::Create(bool b3D) return false; } alcMakeContextCurrent(mContext); + alListenerf(AL_GAIN, mAudioVolume); mCurrentMusic = new Channel(); GetLogger()->Info("Done.\n"); @@ -118,8 +119,7 @@ bool ALSound::GetEnable() void ALSound::SetAudioVolume(int volume) { - mAudioVolume = MIN(static_cast(volume) / MAXVOLUME, 1.0f); - alListenerf(AL_GAIN, mAudioVolume); + mAudioVolume = static_cast(volume) / MAXVOLUME; } @@ -134,9 +134,9 @@ int ALSound::GetAudioVolume() void ALSound::SetMusicVolume(int volume) { - mMusicVolume = MIN(static_cast(volume) / MAXVOLUME, 1.0f); + mMusicVolume = static_cast(volume) / MAXVOLUME; if (mCurrentMusic) { - mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume); + mCurrentMusic->SetVolume(mMusicVolume); } } @@ -298,7 +298,6 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc if (!mEnabled) { return -1; } - if (mSounds.find(sound) == mSounds.end()) { GetLogger()->Warn("Sound %d was not loaded!\n", sound); return -1; @@ -323,7 +322,7 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc mChannels[channel]->SetChangeFrequency(1.0f); mChannels[channel]->ResetOper(); mChannels[channel]->SetFrequency(frequency); - mChannels[channel]->SetVolume(amplitude * mAudioVolume); + mChannels[channel]->SetVolume(powf(amplitude, 0.2f) * mAudioVolume); mChannels[channel]->SetLoop(bLoop); mChannels[channel]->Play(); @@ -426,17 +425,12 @@ bool ALSound::MuteAll(bool bMute) if (!mEnabled) return false; - float volume; mMute = bMute; - if (mMute) - volume = 0; - else - volume = mAudioVolume; - - for (auto channel : mChannels) { - channel.second->SetVolume(volume * mAudioVolume); + if (mMute) { + mCurrentMusic->SetVolume(0.0f); + } else { + mCurrentMusic->SetVolume(mMusicVolume); } - return true; } @@ -451,6 +445,11 @@ void ALSound::FrameMove(float delta) if (!it.second->IsPlaying()) { continue; } + + if (mMute) { + it.second->SetVolume(0.0f); + continue; + } if (!it.second->HasEnvelope()) continue; @@ -461,13 +460,19 @@ void ALSound::FrameMove(float delta) progress = MIN(progress, 1.0f); // setting volume - volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); - volume = (volume + it.second->GetStartAmplitude()) * mAudioVolume; - it.second->SetVolume(volume); + if (!mMute) { + volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); + volume = (volume + it.second->GetStartAmplitude()); + it.second->SetVolume(powf(volume, 0.2f) * mAudioVolume); + } // setting frequency - frequency = progress * (oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency() * it.second->GetInitFrequency(); - it.second->AdjustFrequency(frequency); + frequency = progress; + frequency *= oper.finalFrequency - it.second->GetStartFrequency(); + frequency += it.second->GetStartFrequency(); + frequency *= it.second->GetChangeFrequency(); + frequency = (frequency * it.second->GetInitFrequency()); + it.second->SetFrequency(frequency); if (oper.totalTime <= oper.currentTime) { if (oper.nextOper == SOPER_LOOP) { @@ -508,7 +513,7 @@ bool ALSound::PlayMusic(int rank, bool bRepeat) GetLogger()->Debug("Music loaded from cache\n"); mCurrentMusic->SetBuffer(music); - mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume); + mCurrentMusic->SetVolume(mMusicVolume); mCurrentMusic->SetLoop(bRepeat); mCurrentMusic->Play(); return true; @@ -533,7 +538,7 @@ bool ALSound::PlayMusic(int rank, bool bRepeat) mMusicCache[rank] = buffer; } - mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume); + mCurrentMusic->SetVolume(mMusicVolume); mCurrentMusic->SetLoop(bRepeat); mCurrentMusic->Play(); diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 19394c6..f5967ab 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -17,8 +17,6 @@ #include "channel.h" -#define MIN(a, b) (a > b ? b : a) - Channel::Channel() { alGenSources(1, &mSource); @@ -89,15 +87,6 @@ bool Channel::SetFrequency(float freq) } -bool Channel::AdjustFrequency(float freq) -{ - if (!mReady || mBuffer == nullptr) - return false; - - return SetFrequency(mInitFrequency + fabs(freq)); -} - - float Channel::GetFrequency() { ALfloat freq; @@ -119,7 +108,7 @@ bool Channel::SetVolume(float vol) if (!mReady || vol < 0 || mBuffer == nullptr) return false; - alSourcef(mSource, AL_GAIN, MIN(powf(vol, 0.2f), 1.0f)); + alSourcef(mSource, AL_GAIN, vol); if (alCheck()) { GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode()); return false; diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index 8965306..883ddf2 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -52,7 +52,6 @@ class Channel bool SetFrequency(float); float GetFrequency(); - bool AdjustFrequency(float); float GetCurrentTime(); void SetCurrentTime(float); -- cgit v1.2.3-1-g7c22 From 90301e24c0fc5fcd6bffb0399e203e5adea6aa2c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 31 Mar 2013 10:21:22 +0200 Subject: Added field "item" to class "object" in CBot --- src/CMakeLists.txt | 1 + src/app/app.cpp | 1 + src/app/app.h | 4 + src/object/object.cpp | 8 + src/object/objman.cpp | 388 +++++++++++++++++++++++++++++++++++++++++++++++ src/object/objman.h | 54 +++++++ src/object/robotmain.cpp | 1 + src/script/script.cpp | 9 +- 8 files changed, 460 insertions(+), 6 deletions(-) create mode 100644 src/object/objman.cpp create mode 100644 src/object/objman.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de60ef3..72fcee6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -128,6 +128,7 @@ object/motion/motionvehicle.cpp object/motion/motionworm.cpp object/object.cpp object/robotmain.cpp +object/objman.cpp object/task/task.cpp object/task/taskadvance.cpp object/task/taskbuild.cpp diff --git a/src/app/app.cpp b/src/app/app.cpp index 59a04f4..c42c8b0 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -95,6 +95,7 @@ CApplication::CApplication() { m_private = new ApplicationPrivate(); m_iMan = new CInstanceManager(); + m_objMan = new CObjectManager; m_eventQueue = new CEventQueue(); m_profile = new CProfile(); diff --git a/src/app/app.h b/src/app/app.h index dcc90e0..07f1b90 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -31,6 +31,8 @@ #include "graphics/engine/engine.h" #include "graphics/opengl/gldevice.h" +#include "object/objman.h" + #include #include @@ -374,6 +376,8 @@ protected: //! Instance manager // TODO: to be removed CInstanceManager* m_iMan; + //! Object manager + CObjectManager* m_objMan; //! Global event queue CEventQueue* m_eventQueue; //! Graphics engine diff --git a/src/object/object.cpp b/src/object/object.cpp index 23a757a..f14cf80 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -71,6 +71,7 @@ #include "object/motion/motionvehicle.h" #include "object/motion/motionworm.h" #include "object/robotmain.h" +#include "object/objman.h" #include "physics/physics.h" @@ -202,6 +203,10 @@ void uObject(CBotVar* botThis, void* user) fret = object->GetFret(); if ( fret == 0 ) pVar->SetPointer(0); else pVar->SetPointer(fret->GetBotVar()); + + pVar = pVar->GetNext(); // "id" + value = object->GetID(); + pVar->SetValInt(value); } @@ -337,6 +342,8 @@ CObject::CObject() m_botVar = CBotVar::Create("", CBotTypResult(CBotTypClass, "object")); m_botVar->SetUserPtr(this); m_botVar->SetIdent(m_id); + + CObjectManager::GetInstancePointer()->AddInstance(this); } // Object's destructor. @@ -360,6 +367,7 @@ CObject::~CObject() m_auto = nullptr; CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_OBJECT, this); + CObjectManager::GetInstancePointer()->DeleteInstance(this); m_app = nullptr; } diff --git a/src/object/objman.cpp b/src/object/objman.cpp new file mode 100644 index 0000000..76ab9b0 --- /dev/null +++ b/src/object/objman.cpp @@ -0,0 +1,388 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + + +#include "object/object.h" +#include "object/auto/auto.h" + +#include "object/objman.h" + + +template<> CObjectManager* CSingleton::m_instance = nullptr; + + +CObjectManager::CObjectManager() +{ + for (int i = 0; i < MAX_OBJECTS; i++) + { + m_table[i] = nullptr; + } + usedCount = 0; +} + +CObjectManager::~CObjectManager() +{ +} + +bool CObjectManager::AddInstance(CObject* instance) +{ + if (usedCount >= MAX_OBJECTS) return false; + + m_table[instance->GetID()] = instance; + usedCount++; + return true; +} + +bool CObjectManager::DeleteInstance(CObject* instance) +{ + for (int i = 0; i < usedCount; i++) + { + if (m_table[i] == instance) + m_table[i] = nullptr; + } + + return true; +} + +CObject* CObjectManager::SearchInstance(int id) +{ + if (id >= MAX_OBJECTS) return nullptr; + return m_table[id]; +} + +CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, float height, + ObjectType type, float power, + bool trainer, bool toy, + int option) +{ + CObject* object = nullptr; + + if ( type == OBJECT_NULL ) return nullptr; + + if ( type == OBJECT_HUMAN || + type == OBJECT_TECH ) + { + trainer = false; // necessarily + } + + if ( type == OBJECT_PORTICO || + type == OBJECT_BASE || + type == OBJECT_DERRICK || + type == OBJECT_FACTORY || + type == OBJECT_STATION || + type == OBJECT_CONVERT || + type == OBJECT_REPAIR || + type == OBJECT_DESTROYER|| + type == OBJECT_TOWER || + type == OBJECT_NEST || + type == OBJECT_RESEARCH || + type == OBJECT_RADAR || + type == OBJECT_INFO || + type == OBJECT_ENERGY || + type == OBJECT_LABO || + type == OBJECT_NUCLEAR || + type == OBJECT_PARA || + type == OBJECT_SAFE || + type == OBJECT_HUSTON || + type == OBJECT_TARGET1 || + type == OBJECT_TARGET2 || + type == OBJECT_START || + type == OBJECT_END ) + { + object = new CObject(); + object->CreateBuilding(pos, angle, height, type, power); + + CAuto* automat = object->GetAuto(); + if (automat != nullptr) + { + automat->Init(); + } + } + else + if ( type == OBJECT_FRET || + type == OBJECT_STONE || + type == OBJECT_URANIUM || + type == OBJECT_METAL || + type == OBJECT_POWER || + type == OBJECT_ATOMIC || + type == OBJECT_BULLET || + type == OBJECT_BBOX || + type == OBJECT_KEYa || + type == OBJECT_KEYb || + type == OBJECT_KEYc || + type == OBJECT_KEYd || + type == OBJECT_TNT || + type == OBJECT_SCRAP1 || + type == OBJECT_SCRAP2 || + type == OBJECT_SCRAP3 || + type == OBJECT_SCRAP4 || + type == OBJECT_SCRAP5 || + type == OBJECT_BOMB || + type == OBJECT_WAYPOINT || + type == OBJECT_SHOW || + type == OBJECT_WINFIRE || + type == OBJECT_BAG || + type == OBJECT_MARKPOWER || + type == OBJECT_MARKSTONE || + type == OBJECT_MARKURANIUM || + type == OBJECT_MARKKEYa || + type == OBJECT_MARKKEYb || + type == OBJECT_MARKKEYc || + type == OBJECT_MARKKEYd || + type == OBJECT_EGG ) + { + object = new CObject(); + object->CreateResource(pos, angle, type, power); + } + else + if ( type == OBJECT_FLAGb || + type == OBJECT_FLAGr || + type == OBJECT_FLAGg || + type == OBJECT_FLAGy || + type == OBJECT_FLAGv ) + { + object = new CObject(); + object->CreateFlag(pos, angle, type); + } + else + if ( type == OBJECT_BARRIER0 || + type == OBJECT_BARRIER1 || + type == OBJECT_BARRIER2 || + type == OBJECT_BARRIER3 || + type == OBJECT_BARRIER4 ) + { + object = new CObject(); + object->CreateBarrier(pos, angle, height, type); + } + else + if ( type == OBJECT_PLANT0 || + type == OBJECT_PLANT1 || + type == OBJECT_PLANT2 || + type == OBJECT_PLANT3 || + type == OBJECT_PLANT4 || + type == OBJECT_PLANT5 || + type == OBJECT_PLANT6 || + type == OBJECT_PLANT7 || + type == OBJECT_PLANT8 || + type == OBJECT_PLANT9 || + type == OBJECT_PLANT10 || + type == OBJECT_PLANT11 || + type == OBJECT_PLANT12 || + type == OBJECT_PLANT13 || + type == OBJECT_PLANT14 || + type == OBJECT_PLANT15 || + type == OBJECT_PLANT16 || + type == OBJECT_PLANT17 || + type == OBJECT_PLANT18 || + type == OBJECT_PLANT19 || + type == OBJECT_TREE0 || + type == OBJECT_TREE1 || + type == OBJECT_TREE2 || + type == OBJECT_TREE3 || + type == OBJECT_TREE4 || + type == OBJECT_TREE5 || + type == OBJECT_TREE6 || + type == OBJECT_TREE7 || + type == OBJECT_TREE8 || + type == OBJECT_TREE9 ) + { + object = new CObject(); + object->CreatePlant(pos, angle, height, type); + } + else + if ( type == OBJECT_MUSHROOM0 || + type == OBJECT_MUSHROOM1 || + type == OBJECT_MUSHROOM2 || + type == OBJECT_MUSHROOM3 || + type == OBJECT_MUSHROOM4 || + type == OBJECT_MUSHROOM5 || + type == OBJECT_MUSHROOM6 || + type == OBJECT_MUSHROOM7 || + type == OBJECT_MUSHROOM8 || + type == OBJECT_MUSHROOM9 ) + { + object = new CObject(); + object->CreateMushroom(pos, angle, height, type); + } + else + if ( type == OBJECT_TEEN0 || + type == OBJECT_TEEN1 || + type == OBJECT_TEEN2 || + type == OBJECT_TEEN3 || + type == OBJECT_TEEN4 || + type == OBJECT_TEEN5 || + type == OBJECT_TEEN6 || + type == OBJECT_TEEN7 || + type == OBJECT_TEEN8 || + type == OBJECT_TEEN9 || + type == OBJECT_TEEN10 || + type == OBJECT_TEEN11 || + type == OBJECT_TEEN12 || + type == OBJECT_TEEN13 || + type == OBJECT_TEEN14 || + type == OBJECT_TEEN15 || + type == OBJECT_TEEN16 || + type == OBJECT_TEEN17 || + type == OBJECT_TEEN18 || + type == OBJECT_TEEN19 || + type == OBJECT_TEEN20 || + type == OBJECT_TEEN21 || + type == OBJECT_TEEN22 || + type == OBJECT_TEEN23 || + type == OBJECT_TEEN24 || + type == OBJECT_TEEN25 || + type == OBJECT_TEEN26 || + type == OBJECT_TEEN27 || + type == OBJECT_TEEN28 || + type == OBJECT_TEEN29 || + type == OBJECT_TEEN30 || + type == OBJECT_TEEN31 || + type == OBJECT_TEEN32 || + type == OBJECT_TEEN33 || + type == OBJECT_TEEN34 || + type == OBJECT_TEEN35 || + type == OBJECT_TEEN36 || + type == OBJECT_TEEN37 || + type == OBJECT_TEEN38 || + type == OBJECT_TEEN39 || + type == OBJECT_TEEN40 || + type == OBJECT_TEEN41 || + type == OBJECT_TEEN42 || + type == OBJECT_TEEN43 || + type == OBJECT_TEEN44 || + type == OBJECT_TEEN45 || + type == OBJECT_TEEN46 || + type == OBJECT_TEEN47 || + type == OBJECT_TEEN48 || + type == OBJECT_TEEN49 ) + { + object = new CObject(); + object->SetOption(option); + object->CreateTeen(pos, angle, zoom, height, type); + } + else + if ( type == OBJECT_QUARTZ0 || + type == OBJECT_QUARTZ1 || + type == OBJECT_QUARTZ2 || + type == OBJECT_QUARTZ3 || + type == OBJECT_QUARTZ4 || + type == OBJECT_QUARTZ5 || + type == OBJECT_QUARTZ6 || + type == OBJECT_QUARTZ7 || + type == OBJECT_QUARTZ8 || + type == OBJECT_QUARTZ9 ) + { + object = new CObject(); + object->CreateQuartz(pos, angle, height, type); + } + else + if ( type == OBJECT_ROOT0 || + type == OBJECT_ROOT1 || + type == OBJECT_ROOT2 || + type == OBJECT_ROOT3 || + type == OBJECT_ROOT4 || + type == OBJECT_ROOT5 || + type == OBJECT_ROOT6 || + type == OBJECT_ROOT7 || + type == OBJECT_ROOT8 || + type == OBJECT_ROOT9 ) + { + object = new CObject(); + object->CreateRoot(pos, angle, height, type); + } + else + if ( type == OBJECT_HOME1 ) + { + object = new CObject(); + object->CreateHome(pos, angle, height, type); + } + else + if ( type == OBJECT_RUINmobilew1 || + type == OBJECT_RUINmobilew2 || + type == OBJECT_RUINmobilet1 || + type == OBJECT_RUINmobilet2 || + type == OBJECT_RUINmobiler1 || + type == OBJECT_RUINmobiler2 || + type == OBJECT_RUINfactory || + type == OBJECT_RUINdoor || + type == OBJECT_RUINsupport || + type == OBJECT_RUINradar || + type == OBJECT_RUINconvert || + type == OBJECT_RUINbase || + type == OBJECT_RUINhead ) + { + object = new CObject(); + object->CreateRuin(pos, angle, height, type); + } + else + if ( type == OBJECT_APOLLO1 || + type == OBJECT_APOLLO3 || + type == OBJECT_APOLLO4 || + type == OBJECT_APOLLO5 ) + { + object = new CObject(); + object->CreateApollo(pos, angle, type); + } + else + if ( type == OBJECT_MOTHER || + type == OBJECT_ANT || + type == OBJECT_SPIDER || + type == OBJECT_BEE || + type == OBJECT_WORM ) + { + object = new CObject(); + object->CreateInsect(pos, angle, type); // no eggs + } + else + if ( type == OBJECT_HUMAN || + type == OBJECT_TECH || + type == OBJECT_TOTO || + type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEta || + type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfc || + type == OBJECT_MOBILEtc || + type == OBJECT_MOBILEwc || + type == OBJECT_MOBILEic || + type == OBJECT_MOBILEfi || + type == OBJECT_MOBILEti || + type == OBJECT_MOBILEwi || + type == OBJECT_MOBILEii || + type == OBJECT_MOBILEfs || + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEws || + type == OBJECT_MOBILEis || + type == OBJECT_MOBILErt || + type == OBJECT_MOBILErc || + type == OBJECT_MOBILErr || + type == OBJECT_MOBILErs || + type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEtg || + type == OBJECT_MOBILEft || + type == OBJECT_MOBILEtt || + type == OBJECT_MOBILEwt || + type == OBJECT_MOBILEit || + type == OBJECT_MOBILEdr || + type == OBJECT_APOLLO2 ) + { + object = new CObject(); + object->SetOption(option); + object->CreateVehicle(pos, angle, type, power, trainer, toy); + } + + return object; +} \ No newline at end of file diff --git a/src/object/objman.h b/src/object/objman.h new file mode 100644 index 0000000..3bdf1a2 --- /dev/null +++ b/src/object/objman.h @@ -0,0 +1,54 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +/** + * \file common/objman.h + * \brief Instance manager for objects + */ + +#pragma once + +#include "object/object.h" + +#include "common/singleton.h" + +const int MAX_OBJECTS = 500; + +/** + * \class ObjectManager + * \brief Manager for objects + */ +class CObjectManager : public CSingleton +{ +public: + CObjectManager(); + virtual ~CObjectManager(); + + //! Registers new object + bool AddInstance(CObject* instance); + //! Deletes the registered object + bool DeleteInstance(CObject* instance); + //! Seeks for an object + CObject* SearchInstance(int id); + //! Creates an object + CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power, bool trainer, bool toy, int option); + +protected: + CObject* m_table[MAX_OBJECTS]; + int usedCount; +}; + + diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index c1e4140..3a880a6 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -831,6 +831,7 @@ CRobotMain::CRobotMain(CApplication* app) bc->AddItem("material", CBotTypResult(CBotTypInt), PR_READ); bc->AddItem("energyCell", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ); + bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ); // Initializes the class FILE. InitClassFILE(); diff --git a/src/script/script.cpp b/src/script/script.cpp index f09b53a..2bfe632 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -33,6 +33,7 @@ #include "object/object.h" #include "object/robotmain.h" #include "object/task/taskmanager.h" +#include "object/objman.h" #include "physics/physics.h" @@ -335,9 +336,7 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us rank = var->GetValInt(); - CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); - - pObj = static_cast(iMan->SearchInstance(CLASS_OBJECT, rank)); + pObj = static_cast(CObjectManager::GetInstancePointer()->SearchInstance(rank)); if ( pObj == 0 ) { result->SetPointer(0); @@ -371,9 +370,7 @@ bool CScript::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user rank = var->GetValInt(); - CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); - - pObj = static_cast(iMan->SearchInstance(CLASS_OBJECT, rank)); + pObj = static_cast(CObjectManager::GetInstancePointer()->SearchInstance(rank)); if ( pObj == 0 ) { return true; -- cgit v1.2.3-1-g7c22 From a6d68d58e57f300fb4a1e87b1263460639f09322 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 31 Mar 2013 10:26:37 +0200 Subject: And it compiled and worked? o.O --- src/app/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index c42c8b0..0d7a8a1 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -95,7 +95,7 @@ CApplication::CApplication() { m_private = new ApplicationPrivate(); m_iMan = new CInstanceManager(); - m_objMan = new CObjectManager; + m_objMan = new CObjectManager(); m_eventQueue = new CEventQueue(); m_profile = new CProfile(); -- cgit v1.2.3-1-g7c22 From 2f7ff844d3b754948e2cecc0b8573b8d45b465ec Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 31 Mar 2013 11:15:45 +0200 Subject: Small fix to CObject::ExploObject --- src/object/object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/object/object.cpp b/src/object/object.cpp index f14cf80..b621ef2 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -600,7 +600,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay) } } - if ( EXPLO_BOUM ) + if ( type == EXPLO_BOUM ) { if ( m_shotTime < 0.5f ) return false; m_shotTime = 0.0f; -- cgit v1.2.3-1-g7c22 From 0d70b6e2f874d9adeb6528df355d3271c3943845 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 31 Mar 2013 12:04:12 +0200 Subject: More parameters to destroy() Also, removed some warnings in script.cpp --- src/object/robotmain.cpp | 5 +++++ src/script/script.cpp | 36 +++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 1e9e207..e14af78 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -805,6 +805,11 @@ CRobotMain::CRobotMain(CApplication* app) CBotProgram::DefineNum("FilterOnlyLanding", FILTER_ONLYLANDING); CBotProgram::DefineNum("FilterOnlyFliying", FILTER_ONLYFLYING); + CBotProgram::DefineNum("ExploNone", 0); + CBotProgram::DefineNum("ExploBoum", EXPLO_BOUM); + CBotProgram::DefineNum("ExploBurn", EXPLO_BURN); + CBotProgram::DefineNum("ExploWater", EXPLO_WATER); + CBotProgram::DefineNum("PolskiPortalColobota", 1337); CBotClass* bc; diff --git a/src/script/script.cpp b/src/script/script.cpp index 2bfe632..6095e05 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -330,7 +330,6 @@ CBotTypResult CScript::cGetObject(CBotVar* &var, void* user) bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user) { - CScript* script = (static_cast(user))->GetRunScript(); CObject* pObj; int rank; @@ -348,27 +347,48 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us return true; } -// Compilation of the instruction "destroy(rank)". +// Compilation of the instruction "destroy(rank[, exploType[, force]])". CBotTypResult CScript::cDestroy(CBotVar* &var, void* user) { if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); + + if ( var != 0 ) { + if ( var->GetType() != CBotTypInt ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + + if ( var != 0 ) { + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + } + } + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); return CBotTypResult(CBotTypFloat); } -// Instruction "destroy(rank)". +// Instruction "destroy(rank[, exploType[, force]])". bool CScript::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user) { - CScript* script = (static_cast(user))->GetRunScript(); CObject* pObj; int rank; + int exploType = 0; + float force = 1.0f; rank = var->GetValInt(); + var->GetNext(); + if ( var != 0 ) { + exploType = var->GetValInt(); + var->GetNext(); + if ( var != 0 ) { + force = var->GetValFloat(); + } + } pObj = static_cast(CObjectManager::GetInstancePointer()->SearchInstance(rank)); if ( pObj == 0 ) @@ -377,7 +397,11 @@ bool CScript::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user } else { - pObj->ExploObject(EXPLO_BOUM, 1.0f); + if ( exploType ) { + pObj->ExploObject(static_cast(exploType), force); + } else { + pObj->DeleteObject(false); + } } return true; } @@ -414,7 +438,6 @@ CBotTypResult CScript::cSearch(CBotVar* &var, void* user) bool CScript::rSearch(CBotVar* var, CBotVar* result, int& exception, void* user) { - CScript* script = (static_cast(user))->GetRunScript(); CObject *pObj, *pBest; CBotVar* array; Math::Vector pos, oPos; @@ -557,7 +580,6 @@ CBotTypResult CScript::cRadar(CBotVar* &var, void* user) bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user) { - CScript* script = (static_cast(user))->GetRunScript(); CObject* pThis = static_cast(user); CObject *pObj, *pBest; CPhysics* physics; -- cgit v1.2.3-1-g7c22 From ff97de547799a60a2121008e9da5793d2ab1581f Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 31 Mar 2013 13:06:38 +0200 Subject: Fixed graphics objects after reset Should fix #120 and perhaps some other bugs as well --- src/graphics/engine/engine.cpp | 21 +++++++++++++++++++++ src/graphics/engine/modelmanager.cpp | 12 ++++++++++++ src/graphics/engine/modelmanager.h | 4 ++++ src/object/robotmain.cpp | 4 +++- 4 files changed, 40 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index e2ef569..274e179 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -591,6 +591,27 @@ void CEngine::CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank) assert(destBaseObjRank >= 0 && destBaseObjRank < static_cast( m_baseObjects.size() )); m_baseObjects[destBaseObjRank] = m_baseObjects[sourceBaseObjRank]; + + EngineBaseObject& p1 = m_baseObjects[destBaseObjRank]; + + if (! p1.used) + return; + + for (int l2 = 0; l2 < static_cast( p1.next.size() ); l2++) + { + EngineBaseObjTexTier& p2 = p1.next[l2]; + + for (int l3 = 0; l3 < static_cast( p2.next.size() ); l3++) + { + EngineBaseObjLODTier& p3 = p2.next[l3]; + + for (int l4 = 0; l4 < static_cast( p3.next.size() ); l4++) + { + EngineBaseObjDataTier& p4 = p3.next[l4]; + p4.staticBufferId = 0; + } + } + } } void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector& vertices, diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index c23b79d..35b7e7a 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -111,6 +111,8 @@ bool CModelManager::AddModelCopy(const std::string& fileName, bool mirrored, int m_engine->CopyBaseObject((*it).second.baseObjRank, copyBaseObjRank); m_engine->SetObjectBaseRank(objRank, copyBaseObjRank); + m_copiesBaseRanks.push_back(copyBaseObjRank); + return true; } @@ -128,6 +130,16 @@ int CModelManager::GetModelBaseObjRank(const std::string& fileName, bool mirrore return (*it).second.baseObjRank; } +void CModelManager::DeleteAllModelCopies() +{ + for (int baseObjRank : m_copiesBaseRanks) + { + m_engine->DeleteBaseObject(baseObjRank); + } + + m_copiesBaseRanks.clear(); +} + void CModelManager::UnloadModel(const std::string& fileName, bool mirrored) { auto it = m_models.find(FileInfo(fileName, mirrored)); diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h index 601d636..a7f9805 100644 --- a/src/graphics/engine/modelmanager.h +++ b/src/graphics/engine/modelmanager.h @@ -53,6 +53,9 @@ public: //! Returns the rank of base engine object of given loaded model int GetModelBaseObjRank(const std::string& fileName, bool mirrored); + //! Deletes all copied objects + void DeleteAllModelCopies(); + //! Unloads the given model void UnloadModel(const std::string& fileName, bool mirrored); //! Unloads all models @@ -91,6 +94,7 @@ private: } }; std::map m_models; + std::vector m_copiesBaseRanks; CEngine* m_engine; }; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index e14af78..733bf6b 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -34,7 +34,7 @@ #include "graphics/engine/engine.h" #include "graphics/engine/lightman.h" #include "graphics/engine/lightning.h" -#include "graphics/engine/modelfile.h" +#include "graphics/engine/modelmanager.h" #include "graphics/engine/particle.h" #include "graphics/engine/planet.h" #include "graphics/engine/pyro.h" @@ -1047,6 +1047,7 @@ void CRobotMain::ChangePhase(Phase phase) FlushDisplayInfo(); m_engine->SetRankView(0); m_engine->DeleteAllObjects(); + Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies(); m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); m_engine->SetBackground(""); m_engine->SetBackForce(false); @@ -3736,6 +3737,7 @@ void CRobotMain::ScenePerso() { DeleteAllObjects(); // removes all the current 3D Scene m_engine->DeleteAllObjects(); + Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies(); m_terrain->FlushRelief(); // all flat m_terrain->FlushBuildingLevel(); m_terrain->FlushFlyingLimit(); -- cgit v1.2.3-1-g7c22 From 9485e1a95fc264beb121bc2fc92dd3303b80ce5e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 1 Apr 2013 12:57:31 +0200 Subject: Improved log levels --- src/app/app.cpp | 2 +- src/graphics/engine/modelmanager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 0d7a8a1..3801f95 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1411,7 +1411,7 @@ bool CApplication::GetMouseButtonState(int index) void CApplication::ResetKeyStates() { - GetLogger()->Info("Reset key states\n"); + GetLogger()->Trace("Reset key states\n"); m_trackedKeys = 0; m_kmodState = 0; m_robotMain->ResetKeyStates(); diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index 35b7e7a..238a7d9 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -23,7 +23,7 @@ CModelManager::~CModelManager() bool CModelManager::LoadModel(const std::string& fileName, bool mirrored) { - GetLogger()->Info("Loading model '%s'\n", fileName.c_str()); + GetLogger()->Debug("Loading model '%s'\n", fileName.c_str()); CModelFile modelFile; -- cgit v1.2.3-1-g7c22 From 926126d5adf457dbc5c92fd83c7231415ea22d04 Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 1 Apr 2013 18:24:12 +0200 Subject: * Changed loading of scene and player info (there's problem with locales using , as comma separator). Issue #137 * Changed way of saving files. Now it's not based on slot (from 000 to 999) but it uses save name as a base. * Changed way of displaying saved games. Listing directory instead of checking from 000 to 999. Issue #138 --- src/object/robotmain.cpp | 40 ++++++-- src/object/robotmain.h | 6 ++ src/ui/maindialog.cpp | 254 +++++++++++++++++++++++------------------------ src/ui/maindialog.h | 4 + 4 files changed, 169 insertions(+), 135 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 733bf6b..2c890a4 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3873,12 +3873,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) int rankGadget = 0; CObject* sel = 0; - std::string oldLocale; - char *locale = setlocale(LC_NUMERIC, nullptr); - if (locale != nullptr) - oldLocale = locale; - - setlocale(LC_NUMERIC, "C"); + SetNumericLocale(); while (fgets(line, 500, file) != NULL) { @@ -4746,7 +4741,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_dialog->SetSceneRead(""); m_dialog->SetStackRead(""); - setlocale(LC_NUMERIC, oldLocale.c_str()); + RestoreNumericLocale(); } //! Creates an object of decoration mobile or stationary @@ -5953,6 +5948,8 @@ bool CRobotMain::IsBusy() void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd) { if (obj->GetType() == OBJECT_FIX) return; + + SetNumericLocale(); char line[3000]; char name[100]; @@ -6040,6 +6037,8 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd) strcat(line, "\n"); fputs(line, file); + + RestoreNumericLocale(); } //! Saves the current game @@ -6047,6 +6046,8 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * { FILE* file = fopen(filename, "w"); if (file == NULL) return false; + + SetNumericLocale(); char line[500]; @@ -6109,6 +6110,8 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * SaveFileScript(obj, filename, objRank++); } fclose(file); + + RestoreNumericLocale(); #if CBOT_STACK // Writes the file of stacks of execution. @@ -6154,6 +6157,8 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank) if (type == OBJECT_NULL) return nullptr; + SetNumericLocale(); + int trainer = OpInt(line, "trainer", 0); int toy = OpInt(line, "toy", 0); int option = OpInt(line, "option", 0); @@ -6219,6 +6224,8 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank) automat->Start(run); // starts the film } + RestoreNumericLocale(); + return obj; } @@ -6229,6 +6236,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot) FILE* file = fopen(filename, "r"); if (file == NULL) return 0; + + SetNumericLocale(); CObject* fret = nullptr; CObject* power = nullptr; @@ -6351,6 +6360,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot) } #endif + RestoreNumericLocale(); + return sel; } @@ -7047,3 +7058,18 @@ void CRobotMain::ClearInterface() HiliteClear(); // removes setting evidence m_tooltipName[0] = 0; // really removes the tooltip } + +void CRobotMain::SetNumericLocale() +{ + char *locale = setlocale(LC_NUMERIC, nullptr); + if (locale != nullptr) + m_oldLocale = locale; + + setlocale(LC_NUMERIC, "C"); +} + +void CRobotMain::RestoreNumericLocale() +{ + setlocale(LC_NUMERIC, m_oldLocale.c_str()); +} + \ No newline at end of file diff --git a/src/object/robotmain.h b/src/object/robotmain.h index fe5fbd5..fc62072 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -352,6 +352,9 @@ public: CObject* IOReadObject(char *line, const char* filename, int objRank); int CreateSpot(Math::Vector pos, Gfx::Color color); + + void SetNumericLocale(); + void RestoreNumericLocale(); protected: bool EventFrame(const Event &event); @@ -390,6 +393,7 @@ protected: void ExecuteCmd(char *cmd); bool TestGadgetQuantity(int rank); void UpdateSpeedLabel(); + protected: CApplication* m_app; @@ -540,5 +544,7 @@ protected: Gfx::Color m_colorRefWater; Gfx::Color m_colorNewWater; float m_colorShiftWater; + + std::string m_oldLocale; }; diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 9060e8b..75db2a6 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -4256,14 +4256,18 @@ void CMainDialog::DefPerso() bool CMainDialog::IsIOReadScene() { - FILE* file; - std::string filename; - - filename = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + "000/data.sav"; - file = fopen(filename.c_str(), "r"); - if ( file == NULL ) return false; - fclose(file); - return true; + fs::directory_iterator end_iter; + + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); + if (fs::exists(saveDir) && fs::is_directory(saveDir)) { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { + return true; + } + } + } + + return false; } // Builds the file name by default. @@ -4283,9 +4287,9 @@ void CMainDialog::IOReadName() int i; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return; + if ( pw == nullptr ) return; pe = static_cast(pw->SearchControl(EVENT_INTERFACE_IONAME)); - if ( pe == 0 ) return; + if ( pe == nullptr ) return; sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1); BuildSceneName(filename, m_sceneName, (m_chap[m_index]+1)*100); @@ -4337,7 +4341,8 @@ void CMainDialog::IOReadList() CList* pl; char line[500]; char name[100]; - int i, j; + int i; + fs::directory_iterator end_iter; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == 0 ) return; @@ -4345,50 +4350,46 @@ void CMainDialog::IOReadList() if ( pl == 0 ) return; pl->Flush(); + + fs::path saveDir(m_savegameDir + "/" + m_main->GetGamerName()); + m_saveList.clear(); + + if (fs::exists(saveDir) && fs::is_directory(saveDir)) { + for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter) { + if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") ) { + + file = fopen((dir_iter->path() / "data.sav").make_preferred().string().c_str(), "r"); + if ( file == NULL ) continue; + + while ( fgets(line, 500, file) != NULL ) { + for ( i=0 ; i<500 ; i++ ) { + if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space + if ( line[i] == '/' && line[i+1] == '/' ) { + line[i] = 0; + break; + } + } - for ( j=0 ; j<999 ; j++ ) - { - std::string filename; - std::ostringstream rankStream; - rankStream << std::setfill('0') << std::setw(3) << j; - filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav"; - - // sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j); - file = fopen(fs::path(filename).make_preferred().string().c_str(), "r"); - if ( file == NULL ) break; - - while ( fgets(line, 500, file) != NULL ) - { - for ( i=0 ; i<500 ; i++ ) - { - if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) - { - line[i] = 0; - break; + if ( Cmd(line, "Title") ) { + OpString(line, "text", name); + break; + } } - } + fclose(file); - if ( Cmd(line, "Title") ) - { - OpString(line, "text", name); - break; + pl->SetName(m_saveList.size(), name); + m_saveList.push_back(dir_iter->path()); } } - fclose(file); - - pl->SetName(j, name); } - - if ( m_phase == PHASE_WRITE || - m_phase == PHASE_WRITEs ) - { + + // zly indeks + if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { GetResource(RES_TEXT, RT_IO_NEW, name); - pl->SetName(j, name); - j ++; + pl->SetName(m_saveList.size(), name); } - pl->SetSelect(j-1); + pl->SetSelect(m_saveList.size()); pl->ShowSelect(false); // shows the selected columns } @@ -4403,35 +4404,31 @@ void CMainDialog::IOUpdateList() int sel, max; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return; + if ( pw == nullptr ) return; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_IOLIST)); - if ( pl == 0 ) return; + if ( pl == nullptr ) return; pi = static_cast(pw->SearchControl(EVENT_INTERFACE_IOIMAGE)); - if ( pi == 0 ) return; + if ( pi == nullptr ) return; sel = pl->GetSelect(); max = pl->GetTotal(); - std::string filename; - std::ostringstream rankStream; - rankStream << std::setfill('0') << std::setw(3) << sel; - filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/screen.png"; - - if ( m_phase == PHASE_WRITE || - m_phase == PHASE_WRITEs ) + if (m_saveList.size() <= static_cast(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 != 0 ) - { + if ( pb != nullptr ) { pb->SetState(STATE_ENABLE, sel < max-1); } } @@ -4455,34 +4452,40 @@ void CMainDialog::IODeleteScene() if ( pl == 0 ) return; sel = pl->GetSelect(); - if ( sel == -1 ) + if ( sel == -1 || m_saveList.size() <= static_cast(sel)) { m_sound->Play(SOUND_TZOING); return; } - - std::ostringstream rankStream; - std::string fileName; - rankStream << std::setfill('0') << std::setw(3) << sel; - fileName = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str(); try { - if (fs::exists(fileName) && fs::is_directory(fileName)) - { - fs::remove_all(fileName); + if (fs::exists(m_saveList.at(sel)) && fs::is_directory(m_saveList.at(sel))) { + fs::remove_all(m_saveList.at(sel)); } } - catch (std::exception & e) - { - GetLogger()->Error("Error on removing directory %s : %s\n", e.what()); + catch (std::exception & e) { + GetLogger()->Error("Error removing save %s : %s\n", pl->GetName(sel), e.what()); } IOReadList(); } -// Writes the scene. +// clears filename only to leave letter or numbers +std::string clearName(char *name) +{ + std::string ret; + int len = strlen(name); + for (int i = 0; i < len; i++) { + if (isalnum(name[i])) { + ret += name[i]; + } + } + return ret; +} + +// Writes the scene. bool CMainDialog::IOWriteScene() { CWindow* pw; @@ -4492,36 +4495,35 @@ bool CMainDialog::IOWriteScene() int sel; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return false; + if ( pw == nullptr ) return false; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_IOLIST)); - if ( pl == 0 ) return false; + if ( pl == nullptr ) return false; pe = static_cast(pw->SearchControl(EVENT_INTERFACE_IONAME)); - if ( pe == 0 ) return false; + if ( pe == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 ) return false; - - std::string directoryName; - std::string fileName; - std::string fileCBot; - std::ostringstream selectStream; - - //TODO: Change this to point user dir according to operating system - GetLogger()->Debug("Creating save directory\n"); - selectStream << std::setfill('0') << std::setw(3) << sel; - directoryName = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + selectStream.str(); - if (!fs::exists(directoryName)) - { - fs::create_directories(directoryName); + if ( sel == -1 ) { + return false; } - - fileName = directoryName + "/data.sav"; - fileCBot = directoryName + "/cbot.run"; + + fs::path dir; pe->GetText(info, 100); + if (static_cast(sel) >= m_saveList.size()) { + dir = fs::path(m_savegameDir) / m_main->GetGamerName() / ("save" + clearName(info)); + } else { + dir = m_saveList.at(sel); + } + + if (!fs::exists(dir)) { + fs::create_directories(dir); + } + + std::string fileName = (dir / "data.sav").make_preferred().string(); + std::string fileCBot = (dir / "cbot.run").make_preferred().string(); m_main->IOWriteScene(fileName.c_str(), fileCBot.c_str(), info); m_shotDelay = 3; - m_shotName = directoryName + "/screen.png"; + m_shotName = (dir / "screen.png").make_preferred().string(); return true; } @@ -4538,58 +4540,46 @@ bool CMainDialog::IOReadScene() int sel, i; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); - if ( pw == 0 ) return false; + if ( pw == nullptr ) return false; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_IOLIST)); - if ( pl == 0 ) return false; + if ( pl == nullptr ) return false; sel = pl->GetSelect(); - if ( sel == -1 ) return false; - - //TODO: Change this to point user dir according to operating system - std::string fileName; - std::string fileCbot; - std::string directoryName; - std::ostringstream selectStream; - selectStream << std::setfill('0') << std::setw(3) << sel; - directoryName = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + selectStream.str(); + if ( sel == -1 || m_saveList.size() <= static_cast(sel) ) { + return false; + } - fileName = directoryName + "/data.sav"; - fileCbot = directoryName + "/cbot.run"; + std::string fileName = (m_saveList.at(sel) / "data.sav").make_preferred().string(); + std::string fileCbot = (m_saveList.at(sel) / "cbot.run").make_preferred().string(); file = fopen(fileName.c_str(), "r"); - if ( file == NULL ) return false; + if ( file == NULL ) { + return false; + } - while ( fgets(line, 500, file) != NULL ) - { - for ( i=0 ; i<500 ; i++ ) - { + while ( fgets(line, 500, file) != NULL ) { + for ( i=0 ; i<500 ; i++ ) { if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space - if ( line[i] == '/' && line[i+1] == '/' ) - { + if ( line[i] == '/' && line[i+1] == '/' ) { line[i] = 0; break; } } - if ( Cmd(line, "Mission") ) - { + if ( Cmd(line, "Mission") ) { OpString(line, "base", m_sceneName); m_sceneRank = OpInt(line, "rank", 0); - if ( strcmp(m_sceneName, "user") == 0 ) - { + if ( strcmp(m_sceneName, "user") == 0 ) { m_sceneRank = m_sceneRank%100; OpString(line, "dir", dir); - for ( i=0 ; iSetNumericLocale(); + sprintf(line, "Head face=%d glasses=%d hair=%.2f;%.2f;%.2f;%.2f\n", m_perso.face, m_perso.glasses, m_perso.colorHair.r, m_perso.colorHair.g, m_perso.colorHair.b, m_perso.colorHair.a); @@ -6553,6 +6545,8 @@ void CMainDialog::WriteGamerPerso(char *gamer) fputs(line, file); fclose(file); + + m_main->RestoreNumericLocale(); } // Reads the personalized player. @@ -6570,6 +6564,8 @@ void CMainDialog::ReadGamerPerso(char *gamer) sprintf(filename, "%s/%s/face.gam", m_savegameDir.c_str(), gamer); file = fopen(filename, "r"); if ( file == NULL ) return; + + m_main->SetNumericLocale(); while ( fgets(line, 100, file) != NULL ) { @@ -6602,6 +6598,8 @@ void CMainDialog::ReadGamerPerso(char *gamer) } fclose(file); + + m_main->RestoreNumericLocale(); } // Specifies the face of the player. diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index a79b95e..afdf94f 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -26,6 +26,8 @@ #include #include +#include + namespace fs = boost::filesystem; @@ -260,6 +262,8 @@ protected: Math::Point m_partiPos[10]; SceneInfo m_sceneInfo[MAXSCENE]; + + std::vector m_saveList; }; } // namespace Ui -- cgit v1.2.3-1-g7c22 From f4b1cabbde0187c7429e31ff344814adf35c4bc1 Mon Sep 17 00:00:00 2001 From: erihel Date: Sun, 7 Apr 2013 13:35:39 +0200 Subject: * Sound are too quiet in 3D mode, for now added support for 2D sound option in menu. In 2D mode sounds are normal (Issue #123) --- src/sound/oalsound/alsound.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index e3a3f4b..660363e 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -92,15 +92,25 @@ bool ALSound::Create(bool b3D) void ALSound::SetSound3D(bool bMode) { - // TODO stub! need to be implemented m3D = bMode; + + if (!m3D) { + 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); + + for (auto c : mChannels) { + if (c.second->IsPlaying()) { + c.second->SetPosition(Math::Vector(0.0f, 0.0f, 0.0f)); + } + } + } } bool ALSound::GetSound3D() { - // TODO stub! need to be implemented - return true; + return m3D; } @@ -371,7 +381,9 @@ bool ALSound::Position(int channel, Math::Vector pos) return false; } - mChannels[channel]->SetPosition(pos); + if (m3D) { + mChannels[channel]->SetPosition(pos); + } return true; } @@ -494,9 +506,11 @@ void ALSound::FrameMove(float delta) void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) { - 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); + 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); + alListenerfv(AL_ORIENTATION, orientation); + } } -- cgit v1.2.3-1-g7c22 From 7513bc5864efce2d6366f8836f1cb178adff6965 Mon Sep 17 00:00:00 2001 From: erihel Date: Sun, 7 Apr 2013 16:26:15 +0200 Subject: * Set distance model to fix issue #123 --- src/sound/oalsound/alsound.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 660363e..21f11b7 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -82,6 +82,7 @@ bool ALSound::Create(bool b3D) } alcMakeContextCurrent(mContext); alListenerf(AL_GAIN, mAudioVolume); + alDistanceModel(AL_LINEAR_DISTANCE); mCurrentMusic = new Channel(); GetLogger()->Info("Done.\n"); -- cgit v1.2.3-1-g7c22 From 846e7b6578058cf6d52bf2bf0b2133f84220d670 Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 8 Apr 2013 01:42:12 +0200 Subject: * Adjusted pan computing function from original game (2D sound should work correctly) * Set max sound distance to 110.0f to match original colobot (for issue #123) --- src/sound/oalsound/alsound.cpp | 70 ++++++++++++++++++++++++++++++++++-------- src/sound/oalsound/alsound.h | 3 ++ src/sound/oalsound/channel.cpp | 49 ++++++++++++++++++----------- 3 files changed, 91 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 21f11b7..a5a6989 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -28,6 +28,8 @@ ALSound::ALSound() mMusicVolume = 1.0f; mMute = false; mCurrentMusic = nullptr; + mEye.LoadZero(); + mLookat.LoadZero(); } @@ -82,7 +84,7 @@ bool ALSound::Create(bool b3D) } alcMakeContextCurrent(mContext); alListenerf(AL_GAIN, mAudioVolume); - alDistanceModel(AL_LINEAR_DISTANCE); + alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); mCurrentMusic = new Channel(); GetLogger()->Info("Done.\n"); @@ -94,18 +96,6 @@ bool ALSound::Create(bool b3D) void ALSound::SetSound3D(bool bMode) { m3D = bMode; - - if (!m3D) { - 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); - - for (auto c : mChannels) { - if (c.second->IsPlaying()) { - c.second->SetPosition(Math::Vector(0.0f, 0.0f, 0.0f)); - } - } - } } @@ -326,6 +316,9 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc } } Position(channel, pos); + if (!m3D) { + ComputeVolumePan2D(channel, pos); + } // setting initial values mChannels[channel]->SetStartAmplitude(amplitude); @@ -384,6 +377,8 @@ bool ALSound::Position(int channel, Math::Vector pos) if (m3D) { mChannels[channel]->SetPosition(pos); + } else { + ComputeVolumePan2D(channel, pos); } return true; } @@ -447,6 +442,7 @@ bool ALSound::MuteAll(bool bMute) return true; } + void ALSound::FrameMove(float delta) { if (!mEnabled) @@ -507,6 +503,8 @@ void ALSound::FrameMove(float delta) 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); @@ -600,3 +598,49 @@ void ALSound::SuspendMusic() mCurrentMusic->Stop(); } + + +void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) +{ + float dist, a, g; + + if (VectorsEqual(pos, mEye)) { + mChannels[channel]->SetVolume(1.0f); // maximum volume + mChannels[channel]->SetPosition(Math::Vector()); // at the center + return; + } + + dist = Distance(pos, mEye); + if ( dist >= 110.0f ) { // very far? + mChannels[channel]->SetVolume(0.0f); // silence + mChannels[channel]->SetPosition(Math::Vector()); // at the center + return; + } else if ( dist <= 10.0f ) { // very close? + mChannels[channel]->SetVolume(1.0f); // maximum volume + mChannels[channel]->SetPosition(Math::Vector()); // at the center + return; + } + mChannels[channel]->SetVolume(1.0f - ((dist - 10.0f) / 100.0f)); + + a = fmodf(Angle(mLookat, mEye), Math::PI * 2.0f); + g = fmodf(Angle(pos, mEye), 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; + } + } else { + if ( g + Math::PI * 2.0f - a < a - g ) { + g += Math::PI * 2.0f; + } + } + + mChannels[channel]->SetPosition( Math::Vector(sinf(g - a), 0.0f, 0.0f) ); +} diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index bdf06b1..725aa2a 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -81,6 +81,7 @@ class ALSound : public CSoundInterface void CleanUp(); int GetPriority(Sound); bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded); + void ComputeVolumePan2D(int channel, Math::Vector &pos); bool mEnabled; bool m3D; @@ -93,4 +94,6 @@ class ALSound : public CSoundInterface std::map mChannels; std::deque mMusicCache; Channel *mCurrentMusic; + Math::Vector mEye; + Math::Vector mLookat; }; diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index f5967ab..746282e 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -49,20 +49,25 @@ Channel::~Channel() { bool Channel::Play() { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return false; + } alSourcei(mSource, AL_LOOPING, static_cast(mLoop)); + alSourcei(mSource, AL_REFERENCE_DISTANCE, 10.0f); + alSourcei(mSource, AL_MAX_DISTANCE, 110.0f); alSourcePlay(mSource); - if (alCheck()) + if (alCheck()) { GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode()); + } return true; } bool Channel::SetPosition(Math::Vector pos) { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return false; + } alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z); if (alCheck()) { @@ -75,8 +80,9 @@ bool Channel::SetPosition(Math::Vector pos) { bool Channel::SetFrequency(float freq) { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return false; + } alSourcef(mSource, AL_PITCH, freq); if (alCheck()) { @@ -90,8 +96,9 @@ bool Channel::SetFrequency(float freq) float Channel::GetFrequency() { ALfloat freq; - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return 0; + } alGetSourcef(mSource, AL_PITCH, &freq); if (alCheck()) { @@ -105,8 +112,9 @@ float Channel::GetFrequency() bool Channel::SetVolume(float vol) { - if (!mReady || vol < 0 || mBuffer == nullptr) + if (!mReady || vol < 0 || mBuffer == nullptr) { return false; + } alSourcef(mSource, AL_GAIN, vol); if (alCheck()) { @@ -120,8 +128,9 @@ bool Channel::SetVolume(float vol) float Channel::GetVolume() { ALfloat vol; - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return 0; + } alGetSourcef(mSource, AL_GAIN, &vol); if (alCheck()) { @@ -201,8 +210,9 @@ void Channel::ResetOper() Sound Channel::GetSoundType() { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return SOUND_NONE; + } return mBuffer->GetSoundType(); } @@ -230,10 +240,7 @@ bool Channel::SetBuffer(Buffer *buffer) { bool Channel::FreeBuffer() { - if (!mReady) - return false; - - if (!mBuffer) { + if (!mReady || !mBuffer) { return false; } @@ -247,8 +254,9 @@ bool Channel::FreeBuffer() { bool Channel::IsPlaying() { ALint status; - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return false; + } alGetSourcei(mSource, AL_SOURCE_STATE, &status); if (alCheck()) { @@ -270,8 +278,9 @@ bool Channel::IsLoaded() { bool Channel::Stop() { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return false; + } alSourceStop(mSource); if (alCheck()) { @@ -284,8 +293,9 @@ bool Channel::Stop() { float Channel::GetCurrentTime() { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return 0.0f; + } ALfloat current; alGetSourcef(mSource, AL_SEC_OFFSET, ¤t); @@ -299,19 +309,22 @@ float Channel::GetCurrentTime() void Channel::SetCurrentTime(float current) { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return; + } alSourcef(mSource, AL_SEC_OFFSET, current); - if (alCheck()) + if (alCheck()) { GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode()); + } } float Channel::GetDuration() { - if (!mReady || mBuffer == nullptr) + if (!mReady || mBuffer == nullptr) { return 0.0f; + } return mBuffer->GetDuration(); } -- cgit v1.2.3-1-g7c22 From 7146cf8ee65d35dcc8b1bfa55bc7b25b3ca73d2d Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 8 Apr 2013 12:58:00 +0200 Subject: * Issue #60: Fix for "(null)" instead of time on windows platform --- src/ui/studio.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 29dfebf..3010d5a 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1511,8 +1511,8 @@ void CStudio::UpdateDialogList() fs::path path; int i = 0; char time[100]; - char temp[100]; - + std::ostringstream temp; + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); @@ -1525,9 +1525,8 @@ void CStudio::UpdateDialogList() for( fs::directory_iterator file(path); file != end_iter; file++) { if (fs::is_regular_file(file->status()) ) { TimeToAscii(fs::last_write_time(file->path()), time); - sprintf(temp, "%s\t%lu \t%s", file->path().filename().string().c_str(), fs::file_size(file->path()), time); - - pl->SetName(i++, temp); + temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; + pl->SetName(i++, temp.str().c_str()); } } } -- cgit v1.2.3-1-g7c22 From a66abd4990c6c415bafe3ce879bc67d7539a2901 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 9 Apr 2013 12:20:40 +0200 Subject: * Loading 3D sound settings from profile --- src/ui/maindialog.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 75db2a6..b75fab6 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5719,6 +5719,11 @@ void CMainDialog::SetupRecall() { m_sound->SetMusicVolume(iValue); } + + if ( GetProfile().GetLocalProfileInt("Setup", "Sound3D", iValue) ) + { + m_sound->SetSound3D(iValue == 1); + } if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) ) { -- cgit v1.2.3-1-g7c22 From 99d386b61a29e6f8cadf2f91019017736c681f00 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 9 Apr 2013 13:20:31 +0200 Subject: * Fixed problem with MuteAll and some sounds not playing after muting other sounds (like game menu sound) --- src/sound/oalsound/alsound.cpp | 31 ++++++++++++++++++++----------- src/sound/oalsound/alsound.h | 1 - src/sound/oalsound/channel.cpp | 13 +++++++++++++ src/sound/oalsound/channel.h | 3 +++ 4 files changed, 36 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index a5a6989..68bf515 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -26,7 +26,6 @@ ALSound::ALSound() m3D = false; mAudioVolume = 1.0f; mMusicVolume = 1.0f; - mMute = false; mCurrentMusic = nullptr; mEye.LoadZero(); mLookat.LoadZero(); @@ -290,7 +289,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) int ALSound::Play(Sound sound, float amplitude, float frequency, bool bLoop) { - return Play(sound, Math::Vector(), amplitude, frequency, bLoop); + return Play(sound, mEye, amplitude, frequency, bLoop); } @@ -315,9 +314,12 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc return -1; } } + Position(channel, pos); if (!m3D) { ComputeVolumePan2D(channel, pos); + } else { + mChannels[channel]->SetVolume(1.0f); } // setting initial values @@ -326,7 +328,7 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc mChannels[channel]->SetChangeFrequency(1.0f); mChannels[channel]->ResetOper(); mChannels[channel]->SetFrequency(frequency); - mChannels[channel]->SetVolume(powf(amplitude, 0.2f) * mAudioVolume); + mChannels[channel]->SetVolume(powf(amplitude * mChannels[channel]->GetVolume(), 0.2f) * mAudioVolume); mChannels[channel]->SetLoop(bLoop); mChannels[channel]->Play(); @@ -432,9 +434,14 @@ bool ALSound::MuteAll(bool bMute) { if (!mEnabled) return false; + + for (auto it : mChannels) { + if (it.second->IsPlaying()) { + it.second->Mute(bMute); + } + } - mMute = bMute; - if (mMute) { + if (bMute) { mCurrentMusic->SetVolume(0.0f); } else { mCurrentMusic->SetVolume(mMusicVolume); @@ -455,7 +462,7 @@ void ALSound::FrameMove(float delta) continue; } - if (mMute) { + if (it.second->IsMuted()) { it.second->SetVolume(0.0f); continue; } @@ -469,11 +476,9 @@ void ALSound::FrameMove(float delta) progress = MIN(progress, 1.0f); // setting volume - if (!mMute) { - volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); - volume = (volume + it.second->GetStartAmplitude()); - it.second->SetVolume(powf(volume, 0.2f) * mAudioVolume); - } + volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); + volume = (volume + it.second->GetStartAmplitude()); + it.second->SetVolume(powf(volume, 0.2f) * mAudioVolume); // setting frequency frequency = progress; @@ -509,6 +514,10 @@ void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) 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); + alListenerfv(AL_ORIENTATION, orientation); } } diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index 725aa2a..5701997 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -85,7 +85,6 @@ class ALSound : public CSoundInterface bool mEnabled; bool m3D; - bool mMute; float mAudioVolume; float mMusicVolume; ALCdevice* mDevice; diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 746282e..686e909 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -30,6 +30,7 @@ Channel::Channel() { mPriority = 0; mBuffer = nullptr; mLoop = false; + mMute = false; mInitFrequency = 0.0f; mStartAmplitude = 0.0f; mStartFrequency = 0.0f; @@ -351,3 +352,15 @@ void Channel::PopEnvelope() void Channel::SetLoop(bool loop) { mLoop = loop; } + + +void Channel::Mute(bool mute) +{ + mMute = mute; +} + + +bool Channel::IsMuted() +{ + return mMute; +} diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index 883ddf2..f5f3bb9 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -86,6 +86,8 @@ class Channel void ResetOper(); Sound GetSoundType(); void SetLoop(bool); + void Mute(bool); + bool IsMuted(); private: Buffer *mBuffer; @@ -99,4 +101,5 @@ class Channel std::deque mOper; bool mReady; bool mLoop; + bool mMute; }; -- cgit v1.2.3-1-g7c22 From 01309c8bd0a9ac4476952ec5063499ec980a7b12 Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 11 Apr 2013 13:37:15 +0200 Subject: * Added clipboard support (issue #60) * Fixed keyboard shortcuts while code editing in game --- src/CMakeLists.txt | 2 + src/ui/edit.cpp | 238 ++++++++++++++++------------------------------------- src/ui/edit.h | 2 +- 3 files changed, 74 insertions(+), 168 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72fcee6..c873d89 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -196,6 +196,7 @@ ${Boost_LIBRARIES} ${LIBSNDFILE_LIBRARY} ${OPTIONAL_LIBS} ${PLATFORM_LIBS} +clipboard ) # Local @@ -216,6 +217,7 @@ ${GLEW_INCLUDE_PATH} ${Boost_INCLUDE_DIRS} ${LIBSNDFILE_INCLUDE_DIR} ${OPTIONAL_INCLUDE_DIRS} +${CLIPBOARD_DIR} ) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot) diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index e60a040..7e657c8 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -20,6 +20,8 @@ #include "app/app.h" +#include "clipboard/clipboard.h" + #include namespace Ui { @@ -298,55 +300,53 @@ bool CEdit::EventProcess(const Event &event) bShift = ( (event.kmodState & KEY_MOD(SHIFT) ) != 0 ); bControl = ( (event.kmodState & KEY_MOD(CTRL) ) != 0); - if ( (event.key.unicode == 'X' && !bShift && bControl) || - ((event.kmodState & KEY_MOD(CTRL)) != 0 && bShift && !bControl) ) + if ( (event.key.key == KEY(x) && !bShift && bControl) || + (event.key.key == KEY(DELETE) && bShift && !bControl) ) { Cut(); return true; } - if ( (event.key.unicode == 'C' && !bShift && bControl) || - ((event.kmodState & KEY_MOD(CTRL)) != 0 && !bShift && bControl) ) + if ( (event.key.key == KEY(c) && !bShift && bControl) || + (event.key.key == KEY(INSERT) && !bShift && bControl) ) { Copy(); return true; } - if ( (event.key.unicode == 'V' && !bShift && bControl) || - ((event.kmodState & KEY_MOD(CTRL)) != 0 && bShift && !bControl) ) + if ( (event.key.key == KEY(v) && !bShift && bControl) || + (event.key.key == KEY(INSERT) && bShift && !bControl) ) { Paste(); return true; } - if ( event.key.unicode == 'A' && !bShift && bControl ) + if ( event.key.key == KEY(a) && !bShift && bControl ) { SetCursor(999999, 0); return true; } - if ( event.key.unicode == 'O' && !bShift && bControl ) + if ( event.key.key == KEY(o) && !bShift && bControl ) { Event newEvent(EVENT_STUDIO_OPEN); -// m_event->NewEvent(newEvent, EVENT_STUDIO_OPEN); m_event->AddEvent(newEvent); } - if ( event.key.unicode == 'S' && !bShift && bControl ) + if ( event.key.key == KEY(s) && !bShift && bControl ) { Event newEvent( EVENT_STUDIO_SAVE ); -// m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE); m_event->AddEvent(newEvent); } - if ( event.key.unicode == 'Z' && !bShift && bControl ) + if ( event.key.key == KEY(z) && !bShift && bControl ) { Undo(); return true; } - if ( event.key.unicode == 'U' && !bShift && bControl ) + if ( event.key.key == KEY(u) && !bShift && bControl ) { if ( MinMaj(false) ) return true; } - if ( event.key.unicode == 'U' && bShift && bControl ) + if ( event.key.key == KEY(u) && bShift && bControl ) { if ( MinMaj(true) ) return true; } @@ -2501,200 +2501,100 @@ void CEdit::ColumnFix() // Cut the selected characters or entire line. -bool CEdit::Cut() // TODO MS Windows allocations +bool CEdit::Cut() { - /* HGLOBAL hg; - char* text; - char c; - int c1, c2, start, len, i, j; - - if ( !m_bEdit ) return false; - - c1 = m_cursor1; - c2 = m_cursor2; - if ( c1 > c2 ) Math::Swap(c1, c2); // always c1 <= c2 - - if ( c1 == c2 ) - { - while ( c1 > 0 ) - { - if ( m_text[c1-1] == '\n' ) break; - c1 --; - } - while ( c2 < m_len ) - { - c2 ++; - if ( m_text[c2-1] == '\n' ) break; - } - } - - if ( c1 == c2 ) return false; - - start = c1; - len = c2-c1; - - if ( !(hg = GlobalAlloc(GMEM_DDESHARE, len*2+1)) ) - { - return false; - } - if ( !(text = (char*)GlobalLock(hg)) ) - { - GlobalFree(hg); - return false; - } - - j = 0; - for ( i=start ; i c2 ) Math::Swap(c1, c2); // always c1 <= c2 + if ( c1 > c2 ) { + Math::Swap(c1, c2); // always c1 <= c2 + } - if ( c1 == c2 ) - { - while ( c1 > 0 ) - { - if ( m_text[c1-1] == '\n' ) break; - c1 --; + if ( c1 == c2 ) { + while ( c1 > 0 ) { + if ( m_text[c1 - 1] == '\n' ) { + break; + } + c1--; } - while ( c2 < m_len ) - { - c2 ++; - if ( m_text[c2-1] == '\n' ) break; + while ( c2 < m_len ) { + c2++; + if ( m_text[c2 - 1] == '\n' ) { + break; + } } } - if ( c1 == c2 ) return false; - - start = c1; - len = c2-c1; - - if ( !(hg = GlobalAlloc(GMEM_DDESHARE, len*2+1)) ) - { - return false; - } - if ( !(text = (char*)GlobalLock(hg)) ) - { - GlobalFree(hg); + if ( c1 == c2 ) { return false; } - j = 0; - for ( i=start ; i Date: Thu, 11 Apr 2013 15:34:03 +0200 Subject: * Fix for issue #161: function checking for radar didn't check if it's finished --- src/object/robotmain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 2c890a4..9f95e10 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -6801,10 +6801,10 @@ bool CRobotMain::GetRadar() for (int i = 0; i < 1000000; i++) { CObject* obj = static_cast(iMan->SearchInstance(CLASS_OBJECT, i)); - if (obj == 0) break; + if (obj == nullptr) break; ObjectType type = obj->GetType(); - if (type == OBJECT_RADAR) + if (type == OBJECT_RADAR && !obj->GetLock()) return true; } return false; -- cgit v1.2.3-1-g7c22 From 593be3b776adf6d028eb5008678b3b235998e2b0 Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 11 Apr 2013 21:37:19 +0200 Subject: * Fix for bad file listing (issue #60) --- src/ui/studio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 3010d5a..1cedabb 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1511,7 +1511,6 @@ void CStudio::UpdateDialogList() fs::path path; int i = 0; char time[100]; - std::ostringstream temp; pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; @@ -1524,6 +1523,7 @@ void CStudio::UpdateDialogList() 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; pl->SetName(i++, temp.str().c_str()); -- cgit v1.2.3-1-g7c22 From bc760e35138579743f687661f1104777f5ba727f Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 11 Apr 2013 21:55:49 +0200 Subject: * Added X11 to libs in CMakefiles for linux build --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c873d89..d9c3d57 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,7 @@ elseif (${PLATFORM_WINDOWS}) set(PLATFORM_LIBS "-lintl") elseif(${PLATFORM_LINUX}) # for clock_gettime - set(PLATFORM_LIBS "-lrt") + set(PLATFORM_LIBS "-lrt -lX11") endif() -- cgit v1.2.3-1-g7c22 From 82fdc2ba238a9cb0f60e82681f0dac26d2db7bc9 Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 11 Apr 2013 23:16:32 +0200 Subject: * Fixed problem with 2D sound mode --- src/sound/oalsound/alsound.cpp | 4 ++-- src/sound/oalsound/channel.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 68bf515..02e2403 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -478,7 +478,7 @@ void ALSound::FrameMove(float delta) // setting volume volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); volume = (volume + it.second->GetStartAmplitude()); - it.second->SetVolume(powf(volume, 0.2f) * mAudioVolume); + it.second->SetVolume(powf(volume * it.second->GetVolume(), 0.2f) * mAudioVolume); // setting frequency frequency = progress; @@ -515,7 +515,7 @@ void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) 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}; + float orientation[] = {0.0f, 0.0f, -1.0f, 0.f, 1.f, 0.f}; alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); alListenerfv(AL_ORIENTATION, orientation); } diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 686e909..01ec3de 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -158,7 +158,6 @@ void Channel::SetPriority(int pri) void Channel::SetStartAmplitude(float gain) { mStartAmplitude = gain; - SetVolume(mStartAmplitude); } -- cgit v1.2.3-1-g7c22 From 8a0383c9f088f47e0c70dfbf86f36f95fd191b8c Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 12 Apr 2013 01:46:30 +0200 Subject: * More work on sound --- src/sound/oalsound/alsound.cpp | 49 +++++++++++++++++++++++++++++------------- src/sound/oalsound/channel.cpp | 38 ++++++++++++++++++++++++++++---- src/sound/oalsound/channel.h | 10 ++++++++- 3 files changed, 77 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 02e2403..3ce975b 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -314,12 +314,12 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc return -1; } } - + Position(channel, pos); if (!m3D) { ComputeVolumePan2D(channel, pos); } else { - mChannels[channel]->SetVolume(1.0f); + mChannels[channel]->SetVolumeAtrib(1.0f); } // setting initial values @@ -328,7 +328,7 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc mChannels[channel]->SetChangeFrequency(1.0f); mChannels[channel]->ResetOper(); mChannels[channel]->SetFrequency(frequency); - mChannels[channel]->SetVolume(powf(amplitude * mChannels[channel]->GetVolume(), 0.2f) * mAudioVolume); + mChannels[channel]->SetVolume(powf(amplitude * mChannels[channel]->GetVolumeAtrib(), 0.2f) * mAudioVolume); mChannels[channel]->SetLoop(bLoop); mChannels[channel]->Play(); @@ -378,9 +378,14 @@ bool ALSound::Position(int channel, Math::Vector pos) } if (m3D) { - mChannels[channel]->SetPosition(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); + } } return true; } @@ -477,8 +482,8 @@ void ALSound::FrameMove(float delta) // setting volume volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); - volume = (volume + it.second->GetStartAmplitude()); - it.second->SetVolume(powf(volume * it.second->GetVolume(), 0.2f) * mAudioVolume); + volume = volume + it.second->GetStartAmplitude(); + it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * mAudioVolume); // setting frequency frequency = progress; @@ -515,9 +520,22 @@ void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) alListener3f(AL_POSITION, eye.x, eye.y, eye.z); alListenerfv(AL_ORIENTATION, orientation); } else { - float orientation[] = {0.0f, 0.0f, -1.0f, 0.f, 1.f, 0.f}; + 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); + } + } + } } } @@ -612,24 +630,25 @@ void ALSound::SuspendMusic() void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) { float dist, a, g; + mChannels[channel]->SetPosition(pos); if (VectorsEqual(pos, mEye)) { - mChannels[channel]->SetVolume(1.0f); // maximum volume - mChannels[channel]->SetPosition(Math::Vector()); // at the center + mChannels[channel]->SetVolumeAtrib(1.0f); // maximum volume + mChannels[channel]->SetPan(Math::Vector()); // at the center return; } dist = Distance(pos, mEye); if ( dist >= 110.0f ) { // very far? - mChannels[channel]->SetVolume(0.0f); // silence - mChannels[channel]->SetPosition(Math::Vector()); // at the center + mChannels[channel]->SetVolumeAtrib(0.0f); // silence + mChannels[channel]->SetPan(Math::Vector()); // at the center return; } else if ( dist <= 10.0f ) { // very close? - mChannels[channel]->SetVolume(1.0f); // maximum volume - mChannels[channel]->SetPosition(Math::Vector()); // at the center + mChannels[channel]->SetVolumeAtrib(1.0f); // maximum volume + mChannels[channel]->SetPan(Math::Vector()); // at the center return; } - mChannels[channel]->SetVolume(1.0f - ((dist - 10.0f) / 100.0f)); + mChannels[channel]->SetVolumeAtrib(1.0f - ((dist - 10.0f) / 100.0f)); a = fmodf(Angle(mLookat, mEye), Math::PI * 2.0f); g = fmodf(Angle(pos, mEye), Math::PI * 2.0f); @@ -651,5 +670,5 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) } } - mChannels[channel]->SetPosition( Math::Vector(sinf(g - a), 0.0f, 0.0f) ); + mChannels[channel]->SetPan( Math::Vector(sinf(g - a), 0.0f, 0.0f) ); } diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index 01ec3de..c5b05fa 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -17,7 +17,8 @@ #include "channel.h" -Channel::Channel() { +Channel::Channel() +{ alGenSources(1, &mSource); if (alCheck()) { @@ -35,10 +36,12 @@ Channel::Channel() { mStartAmplitude = 0.0f; mStartFrequency = 0.0f; mChangeFrequency = 0.0f; + mVolume = 0.0f; } -Channel::~Channel() { +Channel::~Channel() +{ if (mReady) { alSourceStop(mSource); alSourcei(mSource, AL_BUFFER, 0); @@ -49,7 +52,8 @@ Channel::~Channel() { } -bool Channel::Play() { +bool Channel::Play() +{ if (!mReady || mBuffer == nullptr) { return false; } @@ -65,7 +69,8 @@ bool Channel::Play() { } -bool Channel::SetPosition(Math::Vector pos) { +bool Channel::SetPan(Math::Vector pos) +{ if (!mReady || mBuffer == nullptr) { return false; } @@ -79,6 +84,18 @@ bool Channel::SetPosition(Math::Vector pos) { } +void Channel::SetPosition(Math::Vector pos) +{ + mPosition = pos; +} + + +Math::Vector Channel::GetPosition() +{ + return mPosition; +} + + bool Channel::SetFrequency(float freq) { if (!mReady || mBuffer == nullptr) { @@ -143,6 +160,19 @@ float Channel::GetVolume() } +void Channel::SetVolumeAtrib(float volume) +{ + mVolume = volume; +} + + +float Channel::GetVolumeAtrib() +{ + return mVolume; +} + + + int Channel::GetPriority() { return mPriority; diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index f5f3bb9..6717f03 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -48,7 +48,10 @@ class Channel bool Play(); bool Stop(); - bool SetPosition(Math::Vector); + + bool SetPan(Math::Vector); + void SetPosition(Math::Vector); + Math::Vector GetPosition(); bool SetFrequency(float); float GetFrequency(); @@ -59,6 +62,9 @@ class Channel bool SetVolume(float); float GetVolume(); + void SetVolumeAtrib(float); + float GetVolumeAtrib(); + bool IsPlaying(); bool IsReady(); bool IsLoaded(); @@ -98,8 +104,10 @@ class Channel float mStartFrequency; float mChangeFrequency; float mInitFrequency; + float mVolume; std::deque mOper; bool mReady; bool mLoop; bool mMute; + Math::Vector mPosition; }; -- cgit v1.2.3-1-g7c22 From 7b2e0e6519525f872fb58df7f287eaefd3c15782 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 12 Apr 2013 22:52:32 +0200 Subject: Added cheats "all" & "allbuildings" (#163) --- src/object/robotmain.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 9f95e10..90d5d03 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1768,6 +1768,23 @@ void CRobotMain::ExecuteCmd(char *cmd) return; } + if (strcmp(cmd, "allbuildings") == 0) + { + g_build = -1; // all buildings are available + + m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE)); + return; + } + + if (strcmp(cmd, "all") == 0) + { + g_researchDone = -1; // all research are done + g_build = -1; // all buildings are available + + m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE)); + return; + } + if (strcmp(cmd, "nolimit") == 0) { m_terrain->SetFlyingMaxHeight(280.0f); @@ -2006,6 +2023,11 @@ void CRobotMain::ExecuteCmd(char *cmd) UpdateSpeedLabel(); return; } + if (strcmp(cmd, "crazy") == 0) { + SetSpeed(1000.0f); + UpdateSpeedLabel(); + return; + } if (m_phase == PHASE_SIMUL) m_displayText->DisplayError(ERR_CMD, Math::Vector(0.0f,0.0f,0.0f)); -- cgit v1.2.3-1-g7c22 From 69e52e5f24d3e02dde20bda5ee322697bafc92c8 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 12 Apr 2013 23:28:44 +0200 Subject: Removed find() & repeat() functions Issue #168 --- src/CBot/CBot.cpp | 5 +- src/CBot/CBot.h | 27 --------- src/CBot/CBotString.cpp | 1 - src/CBot/CBotWhile.cpp | 143 ----------------------------------------------- src/CBot/resource.h | 1 - src/script/cbottoken.cpp | 5 -- src/script/script.cpp | 142 ---------------------------------------------- 7 files changed, 1 insertion(+), 323 deletions(-) (limited to 'src') diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp index ed6831d..4a16b6b 100644 --- a/src/CBot/CBot.cpp +++ b/src/CBot/CBot.cpp @@ -186,7 +186,7 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) { type = pp->GetType(); // these instructions accept only lable - if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, ID_REPEAT, 0)) + if (!IsOfTypeList(pp, ID_WHILE, ID_FOR, ID_DO, 0)) { pStack->SetError(TX_LABEL, pp->GetStart()); return NULL; @@ -205,9 +205,6 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) case ID_DO: return CBotDo::Compile(p, pStack); - case ID_REPEAT: - return CBotRepeat::Compile(p, pStack); - case ID_BREAK: case ID_CONTINUE: return CBotBreak::Compile(p, pStack); diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index 8886308..f5d78c8 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -57,7 +57,6 @@ class CBotExprVar; // a variable name as class CBotWhile; // while (...) {...}; class CBotIf; // if (...) {...} else {...} class CBotDefParam; // paramerer list of a function -class CBotRepeat; // repeat (nb) {...} @@ -492,32 +491,6 @@ public: void RestoreState(CBotStack* &pj, bool bMain); }; -class CBotRepeat : public CBotInstr -{ -private: - /// Number of iterations - CBotInstr* m_NbIter; - - /// Instructions - CBotInstr* m_Block; - - /// Label - CBotString m_label; // a label if there is - -public: - CBotRepeat(); - ~CBotRepeat(); - - /// Static method used for compilation - static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - - /// Execute - bool Execute(CBotStack* &pj); - - /// Restore state - void RestoreState(CBotStack* &pj, bool bMain); -}; - class CBotDo : public CBotInstr { private: diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index b1b5fc4..51cae52 100644 --- a/src/CBot/CBotString.cpp +++ b/src/CBot/CBotString.cpp @@ -54,7 +54,6 @@ const std::map CBotString::s_keywordString = {ID_STATIC, "static"}, {ID_PROTECTED, "protected"}, {ID_PRIVATE, "private"}, - {ID_REPEAT, "repeat"}, {ID_DEBUGDD, "STARTDEBUGDD"}, {ID_INT, "int"}, {ID_FLOAT, "float"}, diff --git a/src/CBot/CBotWhile.cpp b/src/CBot/CBotWhile.cpp index dfd69bf..d24dc4b 100644 --- a/src/CBot/CBotWhile.cpp +++ b/src/CBot/CBotWhile.cpp @@ -155,149 +155,6 @@ void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain) } -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////// -// compiles instruction "repeat" - -CBotRepeat::CBotRepeat() -{ - m_NbIter = - m_Block = NULL; // NULL so that delete is not possible further - name = "CBotRepeat"; // debug -} - -CBotRepeat::~CBotRepeat() -{ - delete m_NbIter; // frees the condition - delete m_Block; // frees the instruction block -} - -CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack) -{ - CBotRepeat* inst = new CBotRepeat(); // creates the object - CBotToken* pp = p; // preserves at the ^ token (starting position) - - if ( IsOfType( p, TokenTypVar ) && - IsOfType( p, ID_DOTS ) ) - { - inst->m_label = pp->GetString(); // register the name of label - } - - inst->SetToken(p); - if (!IsOfType(p, ID_REPEAT)) return NULL; // should never happen - - CBotCStack* pStk = pStack->TokenStack(pp); // un petit bout de pile svp - - if ( IsOfType(p, ID_OPENPAR ) ) - { - CBotToken* ppp = p; // preserves the ^ token (starting position) - if ( NULL != (inst->m_NbIter = CBotExpression::Compile( p, pStk )) ) - { - if ( pStk->GetType() < CBotTypLong ) - { - if ( IsOfType(p, ID_CLOSEPAR ) ) - { - - IncLvl(inst->m_label); - inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true ); - DecLvl(); - - if ( pStk->IsOk() ) - { - // the statement block is ok (it may be empty! - - return pStack->Return(inst, pStk); // return an object to the application - } - } - pStack->SetError(TX_CLOSEPAR, p->GetStart()); - } - pStk->SetStartError(ppp->GetStart()); - pStk->SetError( TX_BADTYPE, p->GetStart() ); - } - pStack->SetError(TX_ENDOF, p); - } - pStack->SetError(TX_OPENPAR, p->GetStart()); // missing parenthesis - - delete inst; // error, frees up - return pStack->Return(NULL, pStk); // no object, the error is on the stack -} - -// execution of intruction "repeat" - -bool CBotRepeat :: Execute(CBotStack* &pj) -{ - CBotStack* pile = pj->AddStack(this); // adds an item to the stack - // or find in case of recovery -// if ( pile == EOX ) return true; - - if ( pile->IfStep() ) return false; - - while( true ) switch( pile->GetState() ) // executes the loop - { // there are two possible states (depending on recovery) - case 0: - // evaluates the number of iterations - if ( !m_NbIter->Execute(pile) ) return false; // interrupted here ? - - // the result of the condition is on the stack - - // terminates if an error or if the condition is false - int n; - if ( !pile->IsOk() || ( n = pile->GetVal() ) < 1 ) - { - return pj->Return(pile); // sends the results and releases the stack - } - - // puts the number of iterations +1 to the "state" - - if (!pile->SetState(n+1)) return false; // ready for further - continue; // continue as a result - - case 1: - // normal end of the loop - return pj->Return(pile); // sends the results and releases the stack - - default: - // evaluates the associated statement block - if ( m_Block != NULL && - !m_Block->Execute(pile) ) - { - if (pile->IfContinue(pile->GetState()-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() ) - { - return pj->Return(pile); // sends the results and releases the stack - } - - // returns to the test again - if (!pile->SetState(pile->GetState()-1, 0)) return false; - continue; - } -} - -void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain) -{ - if ( !bMain ) return; - CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack - if ( pile == NULL ) return; - - switch( pile->GetState() ) - { // there are two possible states (depending on recovery) - case 0: - // evaluates the condition - m_NbIter->RestoreState(pile, bMain); - return; - - case 1: - // evaluates the associated statement block - if ( m_Block != NULL ) m_Block->RestoreState(pile, bMain); - return; - } -} - /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// diff --git a/src/CBot/resource.h b/src/CBot/resource.h index ed14240..f0449b0 100644 --- a/src/CBot/resource.h +++ b/src/CBot/resource.h @@ -47,7 +47,6 @@ enum EID ID_STATIC, ID_PROTECTED, ID_PRIVATE, - ID_REPEAT, ID_DEBUGDD, ID_INT, ID_FLOAT, diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 95b259b..19b0f78 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -220,7 +220,6 @@ std::string GetHelpFilename(const char *token) { if ( strcmp(token, "if" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt"); if ( strcmp(token, "else" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt"); - if ( strcmp(token, "repeat" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/repeat.txt"); if ( strcmp(token, "for" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/for.txt"); if ( strcmp(token, "while" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/while.txt"); if ( strcmp(token, "do" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/do.txt"); @@ -262,7 +261,6 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "move" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/move.txt"); if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt"); if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt"); - if ( strcmp(token, "find" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/find.txt"); if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt"); if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt"); if ( strcmp(token, "sniff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sniff.txt"); @@ -380,7 +378,6 @@ bool IsFunction(const char *token) if ( strcmp(token, "move" ) == 0 ) return true; if ( strcmp(token, "turn" ) == 0 ) return true; if ( strcmp(token, "goto" ) == 0 ) return true; - if ( strcmp(token, "find" ) == 0 ) return true; if ( strcmp(token, "grab" ) == 0 ) return true; if ( strcmp(token, "drop" ) == 0 ) return true; if ( strcmp(token, "sniff" ) == 0 ) return true; @@ -432,7 +429,6 @@ const char* GetHelpText(const char *token) { if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }"; if ( strcmp(token, "else" ) == 0 ) return "else { bloc }"; - if ( strcmp(token, "repeat" ) == 0 ) return "repeat ( number )"; if ( strcmp(token, "for" ) == 0 ) return "for ( before ; condition ; end )"; if ( strcmp(token, "while" ) == 0 ) return "while ( condition ) { bloc }"; if ( strcmp(token, "do" ) == 0 ) return "do { bloc } while ( condition );"; @@ -464,7 +460,6 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "move" ) == 0 ) return "move ( distance );"; if ( strcmp(token, "turn" ) == 0 ) return "turn ( angle );"; if ( strcmp(token, "goto" ) == 0 ) return "goto ( position, altitude );"; - if ( strcmp(token, "find" ) == 0 ) return "find ( cat );"; if ( strcmp(token, "grab" ) == 0 ) return "grab ( order );"; if ( strcmp(token, "drop" ) == 0 ) return "drop ( order );"; if ( strcmp(token, "sniff" ) == 0 ) return "sniff ( );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 6095e05..b3fd6ce 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1632,147 +1632,6 @@ bool CScript::rGoto(CBotVar* var, CBotVar* result, int& exception, void* user) return Process(script, result, exception); } -// Instruction "find(type)". - -bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user) -{ - CScript* script = (static_cast(user))->GetRunScript(); - Math::Vector pos; - TaskGotoGoal goal; - TaskGotoCrash crash; - float altitude; - Error err; - CObject* pThis = static_cast(user); - CObject *pObj, *pBest; - CBotVar* array; - Math::Vector iPos, oPos; - float best, minDist, maxDist, iAngle, focus, d, a; - int type, oType, i; - bool bArray; - - exception = 0; - - if ( script->m_primaryTask == 0 ) // no task in progress? - { - type = OBJECT_NULL; - focus = Math::PI*2.0f; - minDist = 0.0f*g_unit; - maxDist = 1000.0f*g_unit; - - if ( var->GetType() == CBotTypArrayPointer ) - { - array = var->GetItemList(); - bArray = true; - } - else - { - type = var->GetValInt(); - bArray = false; - } - - CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); - - best = 100000.0f; - pBest = 0; - for ( i=0 ; i<1000000 ; i++ ) - { - pObj = static_cast(iMan->SearchInstance(CLASS_OBJECT, i)); - if ( pObj == 0 ) break; - if ( pObj == pThis ) continue; - - if ( pObj->GetTruck() != 0 ) continue; // object transported? - if ( !pObj->GetActif() ) continue; - if ( pObj->GetProxyActivate() ) continue; - - oType = pObj->GetType(); - if ( oType == OBJECT_TOTO ) continue; - - if ( oType == OBJECT_RUINmobilew2 || - oType == OBJECT_RUINmobilet1 || - oType == OBJECT_RUINmobilet2 || - oType == OBJECT_RUINmobiler1 || - oType == OBJECT_RUINmobiler2 ) - { - oType = OBJECT_RUINmobilew1; // any ruin - } - - if ( oType == OBJECT_SCRAP2 || - oType == OBJECT_SCRAP3 || - oType == OBJECT_SCRAP4 || - oType == OBJECT_SCRAP5 ) // wastes? - { - oType = OBJECT_SCRAP1; // any waste - } - - if ( oType == OBJECT_BARRIER2 || - oType == OBJECT_BARRIER3 ) // barriers? - { - oType = OBJECT_BARRIER1; // any barrier - } - - if ( bArray ) - { - if ( !FindList(array, oType) ) continue; - } - else - { - if ( type != oType && type != OBJECT_NULL ) continue; - } - - oPos = pObj->GetPosition(0); - d = Math::DistanceProjected(iPos, oPos); - if ( d < minDist || d > maxDist ) continue; // too close or too far? - - if ( focus >= Math::PI*2.0f ) - { - if ( d < best ) - { - best = d; - pBest = pObj; - } - continue; - } - - a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW ! - if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) ) - { - if ( d < best ) - { - best = d; - pBest = pObj; - } - } - } - - if ( pBest == 0 ) - { - exception = ERR_FIND_IMPOSSIBLE; - return false; - } - - pos = pBest->GetPosition(0); - goal = TGG_DEFAULT; - crash = TGC_DEFAULT; - altitude = 0.0f*g_unit; - - script->m_primaryTask = new CTaskManager(script->m_object); - err = script->m_primaryTask->StartTaskGoto(pos, altitude, goal, crash); - if ( err != ERR_OK ) - { - delete script->m_primaryTask; - script->m_primaryTask = 0; - result->SetValInt(err); // shows the error - if ( script->m_errMode == ERM_STOP ) - { - exception = err; - return false; - } - return true; - } - } - return Process(script, result, exception); -} - // Compilation "grab/drop(oper)". CBotTypResult CScript::cGrabDrop(CBotVar* &var, void* user) @@ -2968,7 +2827,6 @@ void CScript::InitFonctions() CBotProgram::AddFunction("move", rMove, CScript::cOneFloat); CBotProgram::AddFunction("turn", rTurn, CScript::cOneFloat); CBotProgram::AddFunction("goto", rGoto, CScript::cGoto); - CBotProgram::AddFunction("find", rFind, CScript::cOneFloat); CBotProgram::AddFunction("grab", rGrab, CScript::cGrabDrop); CBotProgram::AddFunction("drop", rDrop, CScript::cGrabDrop); CBotProgram::AddFunction("sniff", rSniff, CScript::cNull); -- cgit v1.2.3-1-g7c22 From ebffda717b1b633baba7a313267505614f89f26e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 13 Apr 2013 11:44:16 +0200 Subject: Implemented AudioChange (partially) There is some issues due to #173 Issue #172 --- src/object/robotmain.cpp | 82 +++++++++++++++++++++++++++++++++++++++++- src/object/robotmain.h | 18 +++++++++- src/sound/oalsound/alsound.cpp | 48 ++++++++++--------------- src/sound/oalsound/alsound.h | 2 +- src/sound/sound.h | 16 +++++---- 5 files changed, 126 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 90d5d03..ca18f54 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3478,6 +3478,8 @@ bool CRobotMain::EventFrame(const Event &event) CheckEndMission(true); } + UpdateAudio(true); + if (m_winDelay > 0.0f && !m_editLock) { m_winDelay -= event.rTime; @@ -3824,6 +3826,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_lockedSatCom = false; m_endingWinRank = 0; m_endingLostRank = 0; + m_audioChangeTotal = 0; m_endTakeTotal = 0; m_endTakeResearch = 0; m_endTakeWinDelay = 2.0f; @@ -3983,6 +3986,24 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_audioRepeat = OpInt(line, "repeat", 1); } + if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2) + { + int i = m_audioChangeTotal; + if (i < 10) + { + m_audioChange[i].pos = OpPos(line, "pos")*g_unit; + m_audioChange[i].dist = OpFloat(line, "dist", 8.0f)*g_unit; + m_audioChange[i].type = OpTypeObject(line, "type", OBJECT_NULL); + m_audioChange[i].min = OpInt(line, "min", 1); + m_audioChange[i].max = OpInt(line, "max", 9999); + OpString(line, "filename", m_audioChange[i].music); + m_audioChange[i].repeat = OpInt(line, "repeat", 1); + m_audioChange[i].changed = false; + m_audioChangeTotal ++; + } + } + + if (Cmd(line, "AmbientColor") && !resetObject) { m_engine->SetAmbientColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); @@ -6567,6 +6588,64 @@ void CRobotMain::ResetCreate() } } +//! Updates the audiotracks +void CRobotMain::UpdateAudio(bool frame) +{ + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); + + for (int t = 0; t < m_audioChangeTotal; t++) + { + Math::Vector bPos = m_audioChange[t].pos; + bPos.y = 0.0f; + + Math::Vector oPos; + + int nb = 0; + for (int i = 0; i < 1000000; i++) + { + CObject* obj = static_cast(iMan->SearchInstance(CLASS_OBJECT, i)); + if (obj == nullptr) break; + + // Do not use GetActif () because an invisible worm (underground) + // should be regarded as existing here! + if (obj->GetLock()) continue; + if (obj->GetRuin()) continue; + if (!obj->GetEnable()) continue; + + ObjectType type = obj->GetType(); + if (type == OBJECT_SCRAP2 || + type == OBJECT_SCRAP3 || + type == OBJECT_SCRAP4 || + type == OBJECT_SCRAP5) // wastes? + { + type = OBJECT_SCRAP1; + } + + if (type != m_audioChange[t].type) continue; + + if (obj->GetTruck() == 0) + oPos = obj->GetPosition(0); + else + oPos = obj->GetTruck()->GetPosition(0); + + oPos.y = 0.0f; + + if (Math::DistanceProjected(oPos, bPos) <= m_audioChange[t].dist) + nb ++; + } + + if (nb >= m_audioChange[t].min && + nb <= m_audioChange[t].max && + !m_audioChange[t].changed) + { + CLogger::GetInstancePointer()->Debug("Changing music...\n"); + m_sound->StopMusic(); + m_sound->PlayMusic(std::string(m_audioChange[t].music), m_audioChange[t].repeat); + m_audioChange[t].changed = true; + } + } +} + //! Checks if the mission is over Error CRobotMain::CheckEndMission(bool frame) { @@ -7067,11 +7146,12 @@ float CRobotMain::GetTracePrecision() //! Starts music with a mission void CRobotMain::StartMusic() { + CLogger::GetInstancePointer()->Debug("Starting music...\n"); if (m_audioTrack != 0) { m_sound->StopMusic(); m_sound->PlayMusic(m_audioTrack, m_audioRepeat); - } + } } //! Removes hilite and tooltip diff --git a/src/object/robotmain.h b/src/object/robotmain.h index fc62072..d3b18bc 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -99,13 +99,25 @@ struct EndTake Math::Vector pos; float dist; ObjectType type; - int min; // wins if> + int min; // wins if > int max; // wins if < int lost; // lost if <= bool immediat; char message[100]; }; +struct AudioChange +{ + Math::Vector pos; + float dist; + ObjectType type; + int min; // change if > + int max; // change if < + char music[100]; + bool repeat; + bool changed; +}; + const int MAXNEWSCRIPTNAME = 20; @@ -248,6 +260,7 @@ public: void ResetObject(); void ResetCreate(); + void UpdateAudio(bool frame); Error CheckEndMission(bool frame); void CheckEndMessage(const char* message); int GetObligatoryToken(); @@ -522,6 +535,9 @@ protected: long m_endTakeResearch; float m_endTakeWinDelay; float m_endTakeLostDelay; + + int m_audioChangeTotal; + AudioChange m_audioChange[10]; int m_obligatoryTotal; char m_obligatoryToken[100][20]; diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 3ce975b..48fcc15 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -539,44 +539,32 @@ void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) } } - bool ALSound::PlayMusic(int rank, bool bRepeat) +{ + std::stringstream filename; + filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg"; + return PlayMusic(filename.str(), bRepeat); +} + +bool ALSound::PlayMusic(std::string filename, bool bRepeat) { if (!mEnabled) { return false; } - - if (static_cast(mCurrentMusic->GetSoundType()) != rank) { - // check if we have music in cache - for (auto music : mMusicCache) { - if (static_cast(music->GetSoundType()) == rank) { - GetLogger()->Debug("Music loaded from cache\n"); - mCurrentMusic->SetBuffer(music); - - mCurrentMusic->SetVolume(mMusicVolume); - mCurrentMusic->SetLoop(bRepeat); - mCurrentMusic->Play(); - return true; - } - } - - // we cache only 3 music files - if (mMusicCache.size() == 3) { - mCurrentMusic->FreeBuffer(); - mMusicCache.pop_back(); - } - if (mMusic.find(rank) == mMusic.end()) { - GetLogger()->Info("Requested music %d was not found.\n", rank); - return false; - } + std::stringstream file; + file << m_soundPath << "/" << filename; - Buffer *buffer = new Buffer(); - mMusicCache.push_front(buffer); - buffer->LoadFromFile(mMusic.at(rank), static_cast(rank)); - mCurrentMusic->SetBuffer(buffer); - mMusicCache[rank] = buffer; + if (!boost::filesystem::exists(file.str())) { + GetLogger()->Warn("Requested music %s was not found.\n", filename.c_str()); + return false; } + + // TODO: Cache + + Buffer *buffer = new Buffer(); + buffer->LoadFromFile(file.str(), static_cast(-1)); + mCurrentMusic->SetBuffer(buffer); mCurrentMusic->SetVolume(mMusicVolume); mCurrentMusic->SetLoop(bRepeat); diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index 5701997..7e0503a 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -66,6 +66,7 @@ class ALSound : public CSoundInterface bool MuteAll(bool bMute); bool PlayMusic(int rank, bool bRepeat); + bool PlayMusic(std::string filename, bool bRepeat); bool RestartMusic(); void SuspendMusic(); void StopMusic(); @@ -91,7 +92,6 @@ class ALSound : public CSoundInterface ALCcontext* mContext; std::map mSounds; std::map mChannels; - std::deque mMusicCache; Channel *mCurrentMusic; Math::Vector mEye; Math::Vector mLookat; diff --git a/src/sound/sound.h b/src/sound/sound.h index 70139ea..f101518 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -177,12 +177,7 @@ class CSoundInterface /** Function called to add all music files to list */ inline void AddMusicFiles(std::string path) { - for ( int i = 1; i <= 12; i++ ) { - std::stringstream filename; - filename << path << "/music" << std::setfill('0') << std::setw(3) << i << ".ogg"; - if (boost::filesystem::exists(filename.str())) - mMusic[i] = filename.str(); - } + m_soundPath = path; }; /** Function called to cache sound effect file. @@ -317,6 +312,13 @@ class CSoundInterface */ inline virtual bool PlayMusic(int rank, bool bRepeat) {return true;}; + /** Start playing music + * \param filename - name of file to play + * \param bRepeat - repeat playing + * \return return true on success + */ + inline virtual bool PlayMusic(std::string filename, bool bRepeat) {return true;}; + /** Restart music * @return return true on success */ @@ -338,6 +340,6 @@ class CSoundInterface inline virtual bool IsPlayingMusic() {return true;}; protected: - std::map mMusic; + std::string m_soundPath; }; -- cgit v1.2.3-1-g7c22 From e3b92fb9d842af19f40777dc6764204100c926da Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 13 Apr 2013 15:07:08 +0200 Subject: Some optimalizations to AudioChange --- src/object/robotmain.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ca18f54..f5cdcd8 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3476,10 +3476,9 @@ bool CRobotMain::EventFrame(const Event &event) { m_checkEndTime = m_time; CheckEndMission(true); + UpdateAudio(true); } - UpdateAudio(true); - if (m_winDelay > 0.0f && !m_editLock) { m_winDelay -= event.rTime; @@ -3667,7 +3666,7 @@ void CRobotMain::Convert() } } - if (Cmd(line, "EndMissionTake")) + if (Cmd(line, "EndMissionTake") || Cmd(line, "AudioChange")) { char* p = strstr(line, "pos="); if (p != 0) @@ -6595,6 +6594,8 @@ void CRobotMain::UpdateAudio(bool frame) for (int t = 0; t < m_audioChangeTotal; t++) { + if(m_audioChange[t].changed) continue; + Math::Vector bPos = m_audioChange[t].pos; bPos.y = 0.0f; @@ -6635,8 +6636,7 @@ void CRobotMain::UpdateAudio(bool frame) } if (nb >= m_audioChange[t].min && - nb <= m_audioChange[t].max && - !m_audioChange[t].changed) + nb <= m_audioChange[t].max) { CLogger::GetInstancePointer()->Debug("Changing music...\n"); m_sound->StopMusic(); -- cgit v1.2.3-1-g7c22 From cdba398d29b78256ca12d665ccc4c31c00ec2007 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 13 Apr 2013 16:06:35 +0200 Subject: Added music files cache --- src/object/robotmain.cpp | 6 ++++++ src/sound/oalsound/alsound.cpp | 38 +++++++++++++++++++++++++++++--------- src/sound/oalsound/alsound.h | 2 ++ src/sound/sound.h | 9 +++++++++ 4 files changed, 46 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f5cdcd8..2673d6e 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3983,6 +3983,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { m_audioTrack = OpInt(line, "track", 0); m_audioRepeat = OpInt(line, "repeat", 1); + if(m_audioTrack != 0) { + std::stringstream filename; + filename << "music" << std::setfill('0') << std::setw(3) << m_audioTrack << ".ogg"; + m_sound->CacheMusic(filename.str()); + } } if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2) @@ -3998,6 +4003,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "filename", m_audioChange[i].music); m_audioChange[i].repeat = OpInt(line, "repeat", 1); m_audioChange[i].changed = false; + m_sound->CacheMusic(m_audioChange[i].music); m_audioChangeTotal ++; } } diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 48fcc15..50564e9 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -52,6 +52,10 @@ void ALSound::CleanUp() delete item.second; } + for (auto item : mMusic) { + delete item.second; + } + mEnabled = false; mCurrentMusic->FreeBuffer(); @@ -160,6 +164,18 @@ bool ALSound::Cache(Sound sound, std::string filename) return false; } +bool ALSound::CacheMusic(std::string filename) +{ + Buffer *buffer = new Buffer(); + std::stringstream file; + file << m_soundPath << "/" << filename; + if (buffer->LoadFromFile(file.str(), static_cast(-1))) { + mMusic[filename] = buffer; + return true; + } + return false; +} + int ALSound::GetPriority(Sound sound) { @@ -555,16 +571,20 @@ bool ALSound::PlayMusic(std::string filename, bool bRepeat) std::stringstream file; file << m_soundPath << "/" << filename; - if (!boost::filesystem::exists(file.str())) { - GetLogger()->Warn("Requested music %s was not found.\n", filename.c_str()); - return false; + // check if we have music in cache + if (mMusic.find(filename) == mMusic.end()) { + GetLogger()->Warn("Music %s was not cached!\n", filename.c_str()); + if (!boost::filesystem::exists(file.str())) { + GetLogger()->Warn("Requested music %s was not found.\n", filename.c_str()); + return false; + } + Buffer *buffer = new Buffer(); + buffer->LoadFromFile(file.str(), static_cast(-1)); + mCurrentMusic->SetBuffer(buffer); + } else { + GetLogger()->Debug("Music loaded from cache\n"); + mCurrentMusic->SetBuffer(mMusic[filename]); } - - // TODO: Cache - - Buffer *buffer = new Buffer(); - buffer->LoadFromFile(file.str(), static_cast(-1)); - mCurrentMusic->SetBuffer(buffer); mCurrentMusic->SetVolume(mMusicVolume); mCurrentMusic->SetLoop(bRepeat); diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index 7e0503a..b8afd4d 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -40,6 +40,7 @@ class ALSound : public CSoundInterface bool Create(bool b3D); bool Cache(Sound, std::string); + bool CacheMusic(std::string); bool GetEnable(); @@ -91,6 +92,7 @@ class ALSound : public CSoundInterface ALCdevice* mDevice; ALCcontext* mContext; std::map mSounds; + std::map mMusic; std::map mChannels; Channel *mCurrentMusic; Math::Vector mEye; diff --git a/src/sound/sound.h b/src/sound/sound.h index f101518..9d0e9a0 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -178,6 +178,8 @@ class CSoundInterface /** Function called to add all music files to list */ inline void AddMusicFiles(std::string path) { m_soundPath = path; + CacheMusic("sound010.ogg"); + CacheMusic("sound011.ogg"); }; /** Function called to cache sound effect file. @@ -188,6 +190,13 @@ class CSoundInterface */ inline virtual bool Cache(Sound bSound, std::string bFile) { return true; }; + /** Function called to cache music file. + * This function is called by CRobotMain for each file used in the mission. + * \param bFile - file to load + * \return return true on success + */ + inline virtual bool CacheMusic(std::string bFile) { return true; }; + /** Return if plugin is enabled * \return return true if plugin is enabled */ -- cgit v1.2.3-1-g7c22 From 6ea0031d83db660946084a28dcf7d48eb3644a6d Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 13 Apr 2013 16:35:35 +0200 Subject: Added loading from custom files for Audio --- src/object/robotmain.cpp | 25 ++++++++++++++++--------- src/object/robotmain.h | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 2673d6e..f319d92 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -643,7 +643,7 @@ CRobotMain::CRobotMain(CApplication* app) m_visitLast = EVENT_NULL; m_visitObject = 0; m_visitArrow = 0; - m_audioTrack = 0; + m_audioTrack = ""; m_audioRepeat = true; m_delayWriteMessage = 0; m_selectObject = 0; @@ -3817,7 +3817,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) FlushDisplayInfo(); m_terrain->FlushMaterials(); - m_audioTrack = 0; + m_audioTrack = ""; m_audioRepeat = true; m_displayText->SetDelay(1.0f); m_displayText->SetEnable(true); @@ -3981,13 +3981,20 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Audio") && !resetObject) { - m_audioTrack = OpInt(line, "track", 0); - m_audioRepeat = OpInt(line, "repeat", 1); - if(m_audioTrack != 0) { - std::stringstream filename; - filename << "music" << std::setfill('0') << std::setw(3) << m_audioTrack << ".ogg"; - m_sound->CacheMusic(filename.str()); + if(m_version < 2) { + int trackid = OpInt(line, "track", 0); + if(trackid != 0) { + std::stringstream filename; + filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; + m_audioTrack = filename.str(); + } + } 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 (Cmd(line, "AudioChange") && !resetObject && m_version >= 2) @@ -7153,7 +7160,7 @@ float CRobotMain::GetTracePrecision() void CRobotMain::StartMusic() { CLogger::GetInstancePointer()->Debug("Starting music...\n"); - if (m_audioTrack != 0) + if (m_audioTrack != "") { m_sound->StopMusic(); m_sound->PlayMusic(m_audioTrack, m_audioRepeat); diff --git a/src/object/robotmain.h b/src/object/robotmain.h index d3b18bc..6ff53f1 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -461,7 +461,7 @@ protected: bool m_cheatRadar; bool m_audioRepeat; bool m_shortCut; - int m_audioTrack; + std::string m_audioTrack; int m_delayWriteMessage; int m_movieInfoIndex; -- cgit v1.2.3-1-g7c22 From af24aba899551cce7c4b4d3f3dfe0f31ecf0918d Mon Sep 17 00:00:00 2001 From: erihel Date: Thu, 18 Apr 2013 21:02:25 +0200 Subject: * Key repeating in edit fields --- src/app/app.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 3801f95..6231eb6 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -449,6 +449,7 @@ bool CApplication::Create() // Enable translating key codes of key press events to unicode chars SDL_EnableUNICODE(1); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // Don't generate joystick events SDL_JoystickEventState(SDL_IGNORE); -- cgit v1.2.3-1-g7c22 From 90c691ab0f39f1abedec97804ee2254adffa4d96 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 20 Apr 2013 09:33:54 +0200 Subject: Small fix to music cache --- src/sound/sound.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sound/sound.h b/src/sound/sound.h index 9d0e9a0..a2302c4 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -178,8 +178,8 @@ class CSoundInterface /** Function called to add all music files to list */ inline void AddMusicFiles(std::string path) { m_soundPath = path; - CacheMusic("sound010.ogg"); - CacheMusic("sound011.ogg"); + CacheMusic("music010.ogg"); + CacheMusic("music011.ogg"); }; /** Function called to cache sound effect file. -- cgit v1.2.3-1-g7c22 From ec688021362f1cc470815b3f1483e19e0c754e23 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 20 Apr 2013 10:57:42 +0200 Subject: Fix for not saving robot programs It was Windows-only bug. issue #137 --- src/object/robotmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f319d92..df4deae 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -5702,7 +5702,7 @@ char* SearchLastDir(char *filename) while (p != filename) { - if (*(--p) == '/') return p; + if (*(--p) == '/' || *p == '\\') return p; } return 0; } -- cgit v1.2.3-1-g7c22 From 81fcde4d6740c9c463a20715f92d3a4ad5ab88c4 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 20 Apr 2013 11:17:21 +0200 Subject: Fix for "Ability to select the object in Vault" Issue #170 --- src/object/robotmain.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index df4deae..f64c30f 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -2710,6 +2710,8 @@ CObject* CRobotMain::DetectObject(Math::Point pos) if (obj == nullptr) break; if (!obj->GetActif()) continue; + CObject* truck = obj->GetTruck(); + if (truck != nullptr) if (!truck->GetActif()) continue; if (obj->GetProxyActivate()) continue; CObject* target = nullptr; -- cgit v1.2.3-1-g7c22 From dd180dd88739eb7dd71a6431b2651a18a36599d3 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 20 Apr 2013 12:08:48 +0200 Subject: Added powermin= and powermax= parameters Issue #174 --- src/object/robotmain.cpp | 48 +++++++++++++++++++++++++++++++++++------------- src/object/robotmain.h | 4 ++++ 2 files changed, 39 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f64c30f..79fc1ab 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4004,14 +4004,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) int i = m_audioChangeTotal; if (i < 10) { - m_audioChange[i].pos = OpPos(line, "pos")*g_unit; - m_audioChange[i].dist = OpFloat(line, "dist", 8.0f)*g_unit; - m_audioChange[i].type = OpTypeObject(line, "type", OBJECT_NULL); - m_audioChange[i].min = OpInt(line, "min", 1); - m_audioChange[i].max = OpInt(line, "max", 9999); + m_audioChange[i].pos = OpPos(line, "pos")*g_unit; + m_audioChange[i].dist = OpFloat(line, "dist", 8.0f)*g_unit; + m_audioChange[i].type = OpTypeObject(line, "type", OBJECT_NULL); + m_audioChange[i].min = OpInt(line, "min", 1); + m_audioChange[i].max = OpInt(line, "max", 9999); + m_audioChange[i].powermin = OpInt(line, "powermin", -1); + m_audioChange[i].powermax = OpInt(line, "powermax", 100); OpString(line, "filename", m_audioChange[i].music); - m_audioChange[i].repeat = OpInt(line, "repeat", 1); - m_audioChange[i].changed = false; + m_audioChange[i].repeat = OpInt(line, "repeat", 1); + m_audioChange[i].changed = false; m_sound->CacheMusic(m_audioChange[i].music); m_audioChangeTotal ++; } @@ -4670,12 +4672,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) int i = m_endTakeTotal; if (i < 10) { - m_endTake[i].pos = OpPos(line, "pos")*g_unit; - m_endTake[i].dist = OpFloat(line, "dist", 8.0f)*g_unit; - 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); - m_endTake[i].lost = OpInt(line, "lost", -1); + m_endTake[i].pos = OpPos(line, "pos")*g_unit; + m_endTake[i].dist = OpFloat(line, "dist", 8.0f)*g_unit; + 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); + } + m_endTake[i].lost = OpInt(line, "lost", -1); m_endTake[i].immediat = OpInt(line, "immediat", 0); OpString(line, "message", m_endTake[i].message); m_endTakeTotal ++; @@ -6639,6 +6645,14 @@ void CRobotMain::UpdateAudio(bool frame) if (type != m_audioChange[t].type) continue; + float energyLevel = -1; + CObject* power = obj->GetPower(); + if (power != nullptr) { + energyLevel = power->GetEnergy(); + if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100; + } + if (energyLevel < m_audioChange[t].powermin || energyLevel > m_audioChange[t].powermax) continue; + if (obj->GetTruck() == 0) oPos = obj->GetPosition(0); else @@ -6698,6 +6712,14 @@ Error CRobotMain::CheckEndMission(bool frame) if (type != m_endTake[t].type) continue; + float energyLevel = -1; + CObject* power = obj->GetPower(); + if (power != nullptr) { + energyLevel = power->GetEnergy(); + if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100; + } + if (energyLevel < m_endTake[t].powermin || energyLevel > m_endTake[t].powermax) continue; + if (obj->GetTruck() == 0) oPos = obj->GetPosition(0); else diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 6ff53f1..7ed84c5 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -102,6 +102,8 @@ struct EndTake int min; // wins if > int max; // wins if < int lost; // lost if <= + float powermin; // wins if energy cell >= + float powermax; // wins if energy cell <= bool immediat; char message[100]; }; @@ -113,6 +115,8 @@ struct AudioChange ObjectType type; int min; // change if > int max; // change if < + float powermin; // change if energy cell >= + float powermax; // change if energy cell <= char music[100]; bool repeat; bool changed; -- cgit v1.2.3-1-g7c22 From 364482f022369c219ef1453709732690d18e72f8 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 20 Apr 2013 15:17:40 +0200 Subject: Fix for #180 (bug in commit dd180dd88739eb7dd71a6431b2651a18a36599d3) --- src/object/robotmain.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 79fc1ab..2729e91 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4680,6 +4680,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) 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); -- cgit v1.2.3-1-g7c22 From 32fdf993ea278c3e5a0ffc62f8144dfd9922ba6c Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 20 Apr 2013 19:41:39 +0200 Subject: * Changed order of libs in cmake for clipboard --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9c3d57..26c02bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,6 +186,7 @@ ${OPENAL_SRC} set(LIBS CBot +clipboard ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} @@ -196,7 +197,6 @@ ${Boost_LIBRARIES} ${LIBSNDFILE_LIBRARY} ${OPTIONAL_LIBS} ${PLATFORM_LIBS} -clipboard ) # Local -- cgit v1.2.3-1-g7c22 From 6a1dba0f153adbe99333f8205ba06404351b7aa7 Mon Sep 17 00:00:00 2001 From: erihel Date: Tue, 23 Apr 2013 12:05:04 +0200 Subject: * Resetting arm position on abort for sniffer (issue #162) --- src/object/task/tasksearch.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp index b219185..e2c2524 100644 --- a/src/object/task/tasksearch.cpp +++ b/src/object/task/tasksearch.cpp @@ -218,6 +218,12 @@ Error CTaskSearch::IsEnded() bool CTaskSearch::Abort() { + m_hand = TSH_UP; + InitAngle(); + 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; -- cgit v1.2.3-1-g7c22 From b8d2ce2e4ef355fa82a3dded6d4b7dd9732f4358 Mon Sep 17 00:00:00 2001 From: XienDev Date: Thu, 25 Apr 2013 22:05:27 +0300 Subject: Welcome screen blinking fix --- src/ui/maindialog.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index b75fab6..092903d 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -63,7 +63,7 @@ const int KEY_VISIBLE = 6; // number of visible keys redefinable const int KEY_TOTAL = 21; // total number of keys redefinable -const float WELCOME_LENGTH = 2.0f; +const float WELCOME_LENGTH = 3.0f; const int MAX_FNAME = 255; // TODO: remove after rewrite to std::string @@ -1769,7 +1769,7 @@ pos.y -= 0.048f; ddim.y = 0.0f; pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5); - m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok? + m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_WHITE); // TODO: color ok? m_engine->SetOverFront(true); m_engine->SetBackground("colobot.png", @@ -2006,28 +2006,35 @@ bool CMainDialog::EventProcess(const Event &event) m_phase == PHASE_WELCOME3 ) { float intensity; - int mode = Gfx::ENG_RSTATE_TCOLOR_BLACK; + int mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; - if ( m_phaseTime < 1.5f ) + // 1/4 of display time is animating + float animatingTime = welcomeLength / 4.0f; + + if ( m_phaseTime < animatingTime ) { - intensity = 1.0f-(m_phaseTime-0.5f); + //appearing + intensity = m_phaseTime / animatingTime; } - else if ( m_phaseTime < welcomeLength-1.0f ) + else if ( m_phaseTime < welcomeLength - animatingTime ) { - intensity = 0.0f; + //showing + intensity = 1.0f; } else { - intensity = m_phaseTime-(welcomeLength-1.0f); + //hiding + intensity = (welcomeLength - m_phaseTime) / animatingTime; } + if ( intensity < 0.0f ) intensity = 0.0f; if ( intensity > 1.0f ) intensity = 1.0f; - if ( (m_phase == PHASE_WELCOME2 && m_phaseTime > welcomeLength/2.0f) || - m_phase == PHASE_WELCOME3 ) + //white first, others -> black fadding + if ( (m_phase == PHASE_WELCOME1) && ( m_phaseTime < welcomeLength/2.0f)) { - intensity = 1.0f-intensity; - mode = Gfx::ENG_RSTATE_TCOLOR_WHITE; + intensity = 1.0f - intensity; + mode = Gfx::ENG_RSTATE_TCOLOR_BLACK; } m_engine->SetOverColor(Gfx::Color(intensity, intensity, intensity, intensity), mode); // TODO: color ok? -- cgit v1.2.3-1-g7c22 From 02cb9a699352d4cc4cbb0e396d40c0571301fd64 Mon Sep 17 00:00:00 2001 From: XienDev Date: Thu, 25 Apr 2013 22:11:36 +0300 Subject: Fixes programs list size --- src/object/brain.cpp | 5 +++-- src/ui/interface.cpp | 3 +++ src/ui/list.cpp | 17 ++++++++++++++--- src/ui/window.cpp | 3 +++ 4 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 951a763..f42ea7e 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -1313,10 +1313,11 @@ bool CBrain::CreateInterface(bool bSelect) { if (!(m_main->GetRetroMode())) { ddim.x = dim.x*5.1f; - ddim.y = dim.y*2.0f; + ddim.y = dim.y*2.0f; // default => 2 pos.x = ox+sx*0.0f; pos.y = oy+sy*0.0f; - pw->CreateList(pos, ddim, -1, EVENT_OBJECT_PROGLIST, 1.10f); + + pw->CreateList(pos, ddim, -1, EVENT_OBJECT_PROGLIST, -1.10f); UpdateScript(pw); pos.x = ox+sx*5.2f; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 24d2626..893cd05 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -197,6 +197,9 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev } // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 84aa8ca..fae7af9 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -68,6 +68,9 @@ CList::~CList() // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { @@ -109,14 +112,22 @@ bool CList::MoveAdjust() idim.x = m_dim.x - marging * 2.0f / 640.f; idim.y = m_dim.y - marging * 2.0f / 480.f; - h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * m_expand; - + //If m_expand is less then zero, then try to apply it's absolute value + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * ((m_expand < 0) ? -m_expand : m_expand); m_displayLine = static_cast(idim.y / h); + if (m_displayLine == 0) return false; if (m_displayLine > LISTMAXDISPLAY) m_displayLine = LISTMAXDISPLAY; - idim.y = h * m_displayLine; + + // Stretch lines to fill whole area of a list, if needed + if (m_expand < 0 && (idim.y - (h * m_displayLine) < h)) + { + h = idim.y / m_displayLine; + } + + idim.y = h * m_displayLine; //Here cuts list size if height of shown elements is less then designed height m_dim.y = idim.y + marging * 2.0f / 480.f; ppos.x = ipos.x; diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 6013d37..69ef857 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -355,6 +355,9 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event } // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) -- cgit v1.2.3-1-g7c22 From 88478990b97c9c8d86a5a5edb8e293863266b640 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 26 Apr 2013 14:15:11 +0200 Subject: * Fix a problem with CleanUp function trying to clean up music cache twice --- src/sound/oalsound/alsound.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index 50564e9..cfb0c70 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -43,11 +43,16 @@ void ALSound::CleanUp() if (mEnabled) { GetLogger()->Info("Unloading files and closing device...\n"); StopAll(); + StopMusic(); for (auto channel : mChannels) { delete channel.second; } + if (mCurrentMusic) { + delete mCurrentMusic; + } + for (auto item : mSounds) { delete item.second; } @@ -58,8 +63,6 @@ void ALSound::CleanUp() mEnabled = false; - mCurrentMusic->FreeBuffer(); - delete mCurrentMusic; alcDestroyContext(mContext); alcCloseDevice(mDevice); } -- cgit v1.2.3-1-g7c22 From 1828e60c92aad4a285fb6949bef5a33c113506e1 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 26 Apr 2013 15:34:02 +0200 Subject: * Changed order of reading Audio and AudioChange (issue #173) --- src/object/robotmain.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 2729e91..f2ec838 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3980,25 +3980,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { m_displayText->SetDelay(OpFloat(line, "factor", 1.0f)); } - - if (Cmd(line, "Audio") && !resetObject) - { - if(m_version < 2) { - int trackid = OpInt(line, "track", 0); - if(trackid != 0) { - std::stringstream filename; - filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; - m_audioTrack = filename.str(); - } - } 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 (Cmd(line, "AudioChange") && !resetObject && m_version >= 2) { int i = m_audioChangeTotal; @@ -4019,6 +4001,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } } + if (Cmd(line, "Audio") && !resetObject) + { + if(m_version < 2) { + int trackid = OpInt(line, "track", 0); + if(trackid != 0) { + std::stringstream filename; + filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; + m_audioTrack = filename.str(); + } + } 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 (Cmd(line, "AmbientColor") && !resetObject) { -- cgit v1.2.3-1-g7c22 From adb4b06550b133eefa54548e6c388435e0d6f4d6 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 26 Apr 2013 15:55:06 +0200 Subject: * Issue #173 --- src/object/robotmain.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f2ec838..9599cee 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3999,6 +3999,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_sound->CacheMusic(m_audioChange[i].music); m_audioChangeTotal ++; } + continue; } if (Cmd(line, "Audio") && !resetObject) -- cgit v1.2.3-1-g7c22 From 45f06cec51f2c3d7260c62c1b9a2cc837e8cb02c Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 26 Apr 2013 16:51:17 +0200 Subject: * Fix for issue #71: division by zero on init resulted in bad value after --- src/object/task/taskgoto.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index c4a2939..19d129d 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -90,8 +90,10 @@ 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(); - rot.x /= dist; - rot.y /= dist; + if (dist != 0) { + rot.x /= dist; + rot.y /= dist; + } a = m_object->GetAngleY(0); g = Math::RotateAngle(rot.x, -rot.y); // CW ! -- cgit v1.2.3-1-g7c22 From a693e87293e9daf8ab380d6d7e52d5233f676323 Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 27 Apr 2013 13:03:20 +0200 Subject: * Patch for issue #167 --- src/script/script.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index b3fd6ce..9174971 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1266,7 +1266,10 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user physics->SetFreeze(false); // can move } object->SetLock(false); // vehicle useable - object->SetManual(true); + // SetManual will affect bot speed + if (type == OBJECT_MOBILEdr) { + object->SetManual(true); + } object->SetActivity(true); script->m_main->CreateShortcuts(); } -- cgit v1.2.3-1-g7c22 From 4f1e000ceae2a85f8b5e9fce1534e23f0cb82d38 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 27 Apr 2013 13:43:01 +0200 Subject: Fix for #167 when starting mission + various fixes --- src/object/robotmain.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 9599cee..6ba09a5 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4247,6 +4247,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_terrain->InitTextures(name, tt, dx, dy); m_terrainInitTextures = true; + continue; } if (Cmd(line, "TerrainInit") && !resetObject) { @@ -4462,8 +4463,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) obj->SetShield(OpFloat(line, "shield", 1.0f)); obj->SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f)); obj->SetClip(OpInt(line, "clip", 1)); - obj->SetCheckToken(m_version >= 2 ? trainer : OpInt(line, "manual", 1)); - obj->SetManual(m_version >= 2 ? !trainer : OpInt(line, "manual", 0)); + obj->SetCheckToken(m_version >= 2 ? trainer : OpInt(line, "checkToken", 1)); + // SetManual will affect bot speed + if (type == OBJECT_MOBILEdr) { + obj->SetManual(m_version >= 2 ? !trainer : OpInt(line, "manual", 0)); + } if(m_version >= 2) { Math::Vector zoom = OpDir(line, "zoom"); -- cgit v1.2.3-1-g7c22 From 41fb814e99adb1bbb6b62aeb821574713c8c799b Mon Sep 17 00:00:00 2001 From: XienDev Date: Sat, 27 Apr 2013 18:11:26 +0300 Subject: Added build Third patch --- src/common/global.h | 2 ++ src/common/restext.cpp | 2 ++ src/script/cbottoken.cpp | 3 ++ src/script/script.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ src/script/script.h | 3 +- 5 files changed, 94 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/global.h b/src/common/global.h index 7a5fdfd..db601df 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -55,6 +55,8 @@ enum Error ERR_BUILD_BASE = 129, //! < too close to the rocket ERR_BUILD_NARROW = 130, //! < buildings too close ERR_BUILD_MOTOR = 131, //! < built: not possible in movement + ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission + ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object ERR_SEARCH_FLY = 140, //! < not possible in flight ERR_SEARCH_VEH = 141, //! < inappropriate vehicle ERR_SEARCH_MOTOR = 142, //! < impossible in movement diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 729a883..9af73e4 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -563,6 +563,8 @@ void InitializeRestext() stringsErr[ERR_BUILD_NARROW] = "Too close to a building"; stringsErr[ERR_BUILD_MOTOR] = "Impossible when moving"; stringsErr[ERR_SEARCH_FLY] = "Impossible when flying"; + stringsErr[ERR_BUILD_DISABLED] = "Can not produce this object in this mission"; + stringsErr[ERR_BUILD_RESEARCH] = "Can not produce not researched object"; stringsErr[ERR_SEARCH_VEH] = "Inappropriate bot"; stringsErr[ERR_SEARCH_MOTOR] = "Impossible when moving"; stringsErr[ERR_TERRA_VEH] = "Inappropriate bot"; diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 19b0f78..0bd52da 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -262,6 +262,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt"); if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt"); if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt"); + if ( strcmp(token, "build" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/build.txt"); if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt"); if ( strcmp(token, "sniff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sniff.txt"); if ( strcmp(token, "receive" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/receive.txt"); @@ -379,6 +380,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "turn" ) == 0 ) return true; if ( strcmp(token, "goto" ) == 0 ) return true; if ( strcmp(token, "grab" ) == 0 ) return true; + if ( strcmp(token, "build" ) == 0 ) return true; if ( strcmp(token, "drop" ) == 0 ) return true; if ( strcmp(token, "sniff" ) == 0 ) return true; if ( strcmp(token, "receive" ) == 0 ) return true; @@ -461,6 +463,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "turn" ) == 0 ) return "turn ( angle );"; if ( strcmp(token, "goto" ) == 0 ) return "goto ( position, altitude );"; if ( strcmp(token, "grab" ) == 0 ) return "grab ( order );"; + if ( strcmp(token, "build" ) == 0 ) return "build ( category );"; if ( strcmp(token, "drop" ) == 0 ) return "drop ( order );"; if ( strcmp(token, "sniff" ) == 0 ) return "sniff ( );"; if ( strcmp(token, "receive" ) == 0 ) return "receive ( name, power );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 9174971..c95cd4b 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1003,6 +1003,88 @@ bool CScript::rDirection(CBotVar* var, CBotVar* result, int& exception, void* us return true; } +// Instruction "build(type)" +// draws error if can not build (wher errormode stop), otherwise 0 <- 1 + +bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + CScript* script = (static_cast(user))->GetRunScript(); + CObject* pThis = static_cast(user); + ObjectType oType; + ObjectType category; + Error err; + + exception = 0; + + oType = pThis->GetType(); + + if ( oType != OBJECT_MOBILEfa && // allowed only for grabber bots + oType != OBJECT_MOBILEta && + oType != OBJECT_MOBILEwa && + oType != OBJECT_MOBILEia) + { + err = ERR_MANIP_VEH; //Wrong vehicle; + } + else + { + category = static_cast(var->GetValInt()); //get category parameter + + //if we want to produce one of these buildings + if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) || + (category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) || + (category == OBJECT_STATION && (g_build & BUILD_STATION)) || + (category == OBJECT_CONVERT && (g_build & BUILD_CONVERT)) || + (category == OBJECT_REPAIR && (g_build & BUILD_REPAIR)) || + (category == OBJECT_TOWER && (g_build & BUILD_TOWER)) || + (category == OBJECT_RESEARCH && (g_build & BUILD_RESEARCH)) || + (category == OBJECT_RADAR && (g_build & BUILD_RADAR)) || + (category == OBJECT_ENERGY && (g_build & BUILD_ENERGY)) || + (category == OBJECT_LABO && (g_build & BUILD_LABO)) || + (category == OBJECT_NUCLEAR && (g_build & BUILD_NUCLEAR)) || + (category == OBJECT_INFO && (g_build & BUILD_INFO )) || + (category == OBJECT_PARA && (g_build & BUILD_PARA ))) + { + + //if we want to build not researched one + if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || + (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) + ) + { + err = ERR_BUILD_RESEARCH; + } + else if (script->m_primaryTask == 0) //if we have no other tasks + { + script->m_primaryTask = new CTaskManager(script->m_object); + err = script->m_primaryTask->StartTaskBuild(category); + + if (err != ERR_OK) + { + delete script->m_primaryTask; + script->m_primaryTask = 0; + } + } + + } + else //if we can't build this object + { + err = ERR_BUILD_DISABLED; + } + } + + if ( err != ERR_OK ) + { + result->SetValInt(err); // return error + if ( script->m_errMode == ERM_STOP ) + { + exception = err; + return false; + } + return true; + } + + return Process(script, result, exception); + +} // Compilation of the instruction "produce(pos, angle, type[, scriptName[, power]])" // or "produce(type[, power])". @@ -2856,6 +2938,9 @@ void CScript::InitFonctions() CBotProgram::AddFunction("penup", rPenUp, CScript::cNull); CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat); CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat); + + CBotProgram::AddFunction("build", rBuild, CScript::cOneFloat); + } // Object's destructor. diff --git a/src/script/script.h b/src/script/script.h index 0d2726a..597486b 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -104,7 +104,7 @@ private: static CBotTypResult cSearch(CBotVar* &var, void* user); static CBotTypResult cRadar(CBotVar* &var, void* user); static CBotTypResult cDetect(CBotVar* &var, void* user); - static CBotTypResult cDirection(CBotVar* &var, void* user); + static CBotTypResult cDirection(CBotVar* &var, void* user); static CBotTypResult cProduce(CBotVar* &var, void* user); static CBotTypResult cDistance(CBotVar* &var, void* user); static CBotTypResult cSpace(CBotVar* &var, void* user); @@ -139,6 +139,7 @@ private: static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rBuild(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From 5669053de08bac9726902e96f89aa85b99909399 Mon Sep 17 00:00:00 2001 From: erihel Date: Sat, 27 Apr 2013 17:50:30 +0200 Subject: Some code refactoring Changed vehicule (french) to vehicle (english) in enums and variables --- src/graphics/engine/engine.h | 2 +- src/object/auto/autorepair.cpp | 12 ++++++------ src/object/auto/autostation.cpp | 10 +++++----- src/object/motion/motionant.cpp | 2 +- src/object/motion/motionbee.cpp | 2 +- src/object/motion/motionhuman.cpp | 4 ++-- src/object/motion/motionmother.cpp | 2 +- src/object/motion/motionspider.cpp | 2 +- src/object/motion/motiontoto.cpp | 2 +- src/object/motion/motionvehicle.cpp | 2 +- src/object/motion/motionworm.cpp | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index f9dfd45..671924f 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -171,7 +171,7 @@ enum EngineObjectType //! Fixed object ENG_OBJTYPE_FIX = 2, //! Moving object - ENG_OBJTYPE_VEHICULE = 3, + ENG_OBJTYPE_VEHICLE = 3, //! Part of a moving object ENG_OBJTYPE_DESCENDANT = 4, //! Fixed object type quartz diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp index 95b6cc8..67aa9af 100644 --- a/src/object/auto/autorepair.cpp +++ b/src/object/auto/autorepair.cpp @@ -74,7 +74,7 @@ void CAutoRepair::Init() bool CAutoRepair::EventProcess(const Event &event) { - CObject* vehicule; + CObject* vehicle; Math::Vector pos, speed; Math::Point dim; float angle, shield; @@ -137,16 +137,16 @@ bool CAutoRepair::EventProcess(const Event &event) if ( m_phase == ARP_REPAIR ) { - vehicule = SearchVehicle(); + vehicle = SearchVehicle(); if ( m_progress < 1.0f || - (vehicule != 0 && vehicule->GetShield() < 1.0f) ) + (vehicle != 0 && vehicle->GetShield() < 1.0f) ) { - if ( vehicule != 0 ) + if ( vehicle != 0 ) { - shield = vehicule->GetShield(); + shield = vehicle->GetShield(); shield += event.rTime*0.2f; if ( shield > 1.0f ) shield = 1.0f; - vehicule->SetShield(shield); + vehicle->SetShield(shield); } if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp index a2f5b6b..4ace2ac 100644 --- a/src/object/auto/autostation.cpp +++ b/src/object/auto/autostation.cpp @@ -82,7 +82,7 @@ bool CAutoStation::EventProcess(const Event &event) Math::Matrix* mat; Math::Vector pos, ppos, speed; Math::Point dim; - CObject* vehicule; + CObject* vehicle; CObject* power; Gfx::TerrainRes res; float big, energy, used, add, freq; @@ -133,10 +133,10 @@ bool CAutoStation::EventProcess(const Event &event) freq = 1.0f; if ( big > 0.0f ) { - vehicule = SearchVehicle(); - if ( vehicule != 0 ) + vehicle = SearchVehicle(); + if ( vehicle != 0 ) { - power = vehicule->GetPower(); + power = vehicle->GetPower(); if ( power != 0 && power->GetCapacity() == 1.0f ) { energy = power->GetEnergy(); @@ -149,7 +149,7 @@ bool CAutoStation::EventProcess(const Event &event) big -= add/4.0f; // discharge the large battery } - power = vehicule->GetFret(); + power = vehicle->GetFret(); if ( power != 0 && power->GetType() == OBJECT_POWER ) { energy = power->GetEnergy(); diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp index 384d683..07e743f 100644 --- a/src/object/motion/motionant.cpp +++ b/src/object/motion/motionant.cpp @@ -75,7 +75,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type, // Creates the main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); modelManager->AddModelReference("ant1.mod", false, rank); m_object->SetPosition(0, pos); diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp index 8f69945..e4fdd49 100644 --- a/src/object/motion/motionbee.cpp +++ b/src/object/motion/motionbee.cpp @@ -73,7 +73,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type, // Creates main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); modelManager->AddModelReference("bee1.mod", false, rank); m_object->SetPosition(0, pos); diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index dc5ff34..76ff353 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -107,7 +107,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type, if ( m_main->GetGamerOnlyHead() ) { rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); face = m_main->GetGamerFace(); sprintf(filename, "human2h%d.mod", face+1); @@ -134,7 +134,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type, // Creates the main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); if (option == 0) // head in helmet? diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp index 573a2e4..c01dc66 100644 --- a/src/object/motion/motionmother.cpp +++ b/src/object/motion/motionmother.cpp @@ -74,7 +74,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type, // Creates main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); modelManager->AddModelReference("mother1.mod", false, rank); m_object->SetPosition(0, pos); diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp index 59bc6e0..f76b65b 100644 --- a/src/object/motion/motionspider.cpp +++ b/src/object/motion/motionspider.cpp @@ -101,7 +101,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type, // Creates the main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + 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 m_object->SetPosition(0, pos); diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp index ddb1867..de473a1 100644 --- a/src/object/motion/motiontoto.cpp +++ b/src/object/motion/motiontoto.cpp @@ -88,7 +88,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type, // Creates the head. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); modelManager->AddModelReference("toto1.mod", false, rank); m_object->SetPosition(0, pos); diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index 44b8fdd..88f7b99 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -102,7 +102,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, // Creates the main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); if (type == OBJECT_MOBILEfa || diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp index ee555a8..d153178 100644 --- a/src/object/motion/motionworm.cpp +++ b/src/object/motion/motionworm.cpp @@ -89,7 +89,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type, // Creates the main base. rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + 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 m_object->SetPosition(0, pos); -- cgit v1.2.3-1-g7c22 From 6a4ac9ce1614052b25fea0a0c0572d0ee1afbdff Mon Sep 17 00:00:00 2001 From: XienDev Date: Sun, 28 Apr 2013 16:49:48 +0300 Subject: Added functions "canbuild(category)" and "buildinfo(category)" Also fixed issue with undefined behaviour of build(category) function --- src/script/cbottoken.cpp | 10 +++- src/script/script.cpp | 135 +++++++++++++++++++++++++++++++++-------------- src/script/script.h | 5 +- 3 files changed, 107 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 0bd52da..6eb6592 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -262,6 +262,8 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt"); if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt"); if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt"); + if ( strcmp(token, "buildinfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/buildinfo.txt"); + if ( strcmp(token, "canbuild" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/canbuild.txt"); if ( strcmp(token, "build" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/build.txt"); if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt"); if ( strcmp(token, "sniff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sniff.txt"); @@ -380,7 +382,9 @@ bool IsFunction(const char *token) if ( strcmp(token, "turn" ) == 0 ) return true; if ( strcmp(token, "goto" ) == 0 ) return true; if ( strcmp(token, "grab" ) == 0 ) return true; - if ( strcmp(token, "build" ) == 0 ) return true; + if ( strcmp(token, "buildinfo" ) == 0 ) return true; + if ( strcmp(token, "canbuild" ) == 0 ) return true; + if ( strcmp(token, "build" ) == 0 ) return true; if ( strcmp(token, "drop" ) == 0 ) return true; if ( strcmp(token, "sniff" ) == 0 ) return true; if ( strcmp(token, "receive" ) == 0 ) return true; @@ -463,7 +467,9 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "turn" ) == 0 ) return "turn ( angle );"; if ( strcmp(token, "goto" ) == 0 ) return "goto ( position, altitude );"; if ( strcmp(token, "grab" ) == 0 ) return "grab ( order );"; - if ( strcmp(token, "build" ) == 0 ) return "build ( category );"; + if ( strcmp(token, "buildinfo" ) == 0 ) return "buildinfo ( category );"; + if ( strcmp(token, "canbuild" ) == 0 ) return "canbuild ( category );"; + if ( strcmp(token, "build" ) == 0 ) return "build ( category );"; if ( strcmp(token, "drop" ) == 0 ) return "drop ( order );"; if ( strcmp(token, "sniff" ) == 0 ) return "sniff ( );"; if ( strcmp(token, "receive" ) == 0 ) return "receive ( name, power );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index c95cd4b..c9e3c66 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1003,8 +1003,83 @@ bool CScript::rDirection(CBotVar* var, CBotVar* result, int& exception, void* us return true; } +// compilation of instruction "canbuild ( category );" + +CBotTypResult CScript::cCanBuild(CBotVar* &var, void* user) +{ + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + return CBotTypResult(CBotTypBoolean); +} + +// Instruction "canbuid ( category );" +// returns true if this building can be built + +bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + exception = 0; + + CScript::rBuildInfo(var, result, exception, user); + Error err = static_cast(result->GetValInt()); + + if (err == ERR_OK) + result->SetValInt(true); + else + result->SetValInt(false); + + return true; +} + +// Instruction "buildinfo ( category );" +// This function indicates if this building can be built, and returns a specific value +// +// returns 0(ERR_OK) if this building can be built +// returns 132(ERR_BUILD_DISABLED) if can not build in a current mission +// returns 133(ERR_BUILD_RESEARCH) if this building needs to be researched + +bool CScript::rBuildInfo(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + ObjectType category = static_cast(var->GetValInt()); //get category parameter + exception = 0; + int value = ERR_BUILD_DISABLED; + + if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) || + (category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) || + (category == OBJECT_STATION && (g_build & BUILD_STATION)) || + (category == OBJECT_CONVERT && (g_build & BUILD_CONVERT)) || + (category == OBJECT_REPAIR && (g_build & BUILD_REPAIR)) || + (category == OBJECT_TOWER && (g_build & BUILD_TOWER)) || + (category == OBJECT_RESEARCH && (g_build & BUILD_RESEARCH)) || + (category == OBJECT_RADAR && (g_build & BUILD_RADAR)) || + (category == OBJECT_ENERGY && (g_build & BUILD_ENERGY)) || + (category == OBJECT_LABO && (g_build & BUILD_LABO)) || + (category == OBJECT_NUCLEAR && (g_build & BUILD_NUCLEAR)) || + (category == OBJECT_INFO && (g_build & BUILD_INFO )) || + (category == OBJECT_PARA && (g_build & BUILD_PARA ))) + { + + //if we want to build not researched one + if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || + (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) + ) + { + value = ERR_BUILD_RESEARCH; + } + else + { + value = ERR_OK; + } + + } + + result->SetValInt(value); + return true; +} + // Instruction "build(type)" -// draws error if can not build (wher errormode stop), otherwise 0 <- 1 +// draws error if can not build (wher errormode stop), otherwise 0 <- error bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user) { @@ -1027,48 +1102,26 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user) } else { - category = static_cast(var->GetValInt()); //get category parameter - - //if we want to produce one of these buildings - if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) || - (category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) || - (category == OBJECT_STATION && (g_build & BUILD_STATION)) || - (category == OBJECT_CONVERT && (g_build & BUILD_CONVERT)) || - (category == OBJECT_REPAIR && (g_build & BUILD_REPAIR)) || - (category == OBJECT_TOWER && (g_build & BUILD_TOWER)) || - (category == OBJECT_RESEARCH && (g_build & BUILD_RESEARCH)) || - (category == OBJECT_RADAR && (g_build & BUILD_RADAR)) || - (category == OBJECT_ENERGY && (g_build & BUILD_ENERGY)) || - (category == OBJECT_LABO && (g_build & BUILD_LABO)) || - (category == OBJECT_NUCLEAR && (g_build & BUILD_NUCLEAR)) || - (category == OBJECT_INFO && (g_build & BUILD_INFO )) || - (category == OBJECT_PARA && (g_build & BUILD_PARA ))) - { - - //if we want to build not researched one - if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || - (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) - ) - { - err = ERR_BUILD_RESEARCH; - } - else if (script->m_primaryTask == 0) //if we have no other tasks - { - script->m_primaryTask = new CTaskManager(script->m_object); - err = script->m_primaryTask->StartTaskBuild(category); + //Let's check is building this object is possible + CScript::rBuildInfo(var, result, exception, user); + err = static_cast(result->GetValInt()); - if (err != ERR_OK) - { - delete script->m_primaryTask; - script->m_primaryTask = 0; - } - } - - } - else //if we can't build this object + if (err == ERR_OK && script->m_primaryTask == 0) //if we can build and no task is present { - err = ERR_BUILD_DISABLED; + category = static_cast(var->GetValInt()); //get category parameter + + script->m_primaryTask = new CTaskManager(script->m_object); + err = script->m_primaryTask->StartTaskBuild(category); + + if (err != ERR_OK) + { + delete script->m_primaryTask; + script->m_primaryTask = 0; + } } + //When script is waiting for finishing this task, it sets ERR_OK, and continues executing Process + //without creating new task. I think, there was a problem with previous version in release configuration + //It did not init error variable in this situation, and code tried to use variable with trash inside } if ( err != ERR_OK ) @@ -2939,6 +2992,8 @@ void CScript::InitFonctions() CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat); CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat); + CBotProgram::AddFunction("buildinfo", rBuildInfo, CScript::cOneFloat); + CBotProgram::AddFunction("canbuild", rCanBuild, CScript::cCanBuild); CBotProgram::AddFunction("build", rBuild, CScript::cOneFloat); } diff --git a/src/script/script.h b/src/script/script.h index 597486b..702138b 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -104,7 +104,8 @@ private: static CBotTypResult cSearch(CBotVar* &var, void* user); static CBotTypResult cRadar(CBotVar* &var, void* user); static CBotTypResult cDetect(CBotVar* &var, void* user); - static CBotTypResult cDirection(CBotVar* &var, void* user); + static CBotTypResult cDirection(CBotVar* &var, void* user); + static CBotTypResult cCanBuild(CBotVar* &var, void* user); static CBotTypResult cProduce(CBotVar* &var, void* user); static CBotTypResult cDistance(CBotVar* &var, void* user); static CBotTypResult cSpace(CBotVar* &var, void* user); @@ -139,6 +140,8 @@ private: static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rBuildInfo(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rBuild(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From fc28a8e8406e4b5fd810a09ed3b9524af8d69482 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 28 Apr 2013 18:33:59 +0200 Subject: Implemented EndMissionNever (#181) --- src/object/robotmain.cpp | 8 +++++++- src/object/robotmain.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 6ba09a5..7be1177 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3830,6 +3830,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_audioChangeTotal = 0; m_endTakeTotal = 0; m_endTakeResearch = 0; + m_endTakeNever = false; m_endTakeWinDelay = 2.0f; m_endTakeLostDelay = 2.0f; m_obligatoryTotal = 0; @@ -4703,6 +4704,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { m_endTakeResearch |= OpResearch(line, "type"); } + if (Cmd(line, "EndMissionNever") && !resetObject && m_version >= 2) + { + m_endTakeNever = true; + } if (Cmd(line, "ObligatoryToken") && !resetObject) { @@ -6763,7 +6768,8 @@ Error CRobotMain::CheckEndMission(bool frame) } } if (nb < m_endTake[t].min || - nb > m_endTake[t].max) + nb > m_endTake[t].max || + m_endTakeNever) { m_displayText->SetEnable(true); return ERR_MISSION_NOTERM; diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 7ed84c5..73315af 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -537,6 +537,7 @@ protected: int m_endTakeTotal; EndTake m_endTake[10]; long m_endTakeResearch; + bool m_endTakeNever; float m_endTakeWinDelay; float m_endTakeLostDelay; -- cgit v1.2.3-1-g7c22 From c7d289c00bc60d366f8c5c1016fb30717a228495 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 28 Apr 2013 20:05:19 +0200 Subject: Beggining of MissionController Controling mission using CBot --- src/object/object.cpp | 6 ++++-- src/object/object.h | 1 + src/object/robotmain.cpp | 33 +++++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/object/object.cpp b/src/object/object.cpp index b621ef2..ce79e34 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -2145,8 +2145,10 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type, { m_motion = new CMotionHuman(this); } - else - { + else if ( type == OBJECT_CONTROLLER ) { + m_motion = new CMotion(this); //dummy object + } + else { m_motion = new CMotionVehicle(this); } if ( m_motion == 0 ) return false; diff --git a/src/object/object.h b/src/object/object.h index 4d8cc02..25ea708 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -156,6 +156,7 @@ enum ObjectType OBJECT_MOBILEsa = 210, //! < submarine OBJECT_MOBILEtg = 211, //! < training target OBJECT_MOBILEdr = 212, //! < robot drawing + OBJECT_CONTROLLER = 213, //! < mission controller OBJECT_WAYPOINT = 250, //! < waypoint OBJECT_FLAGb = 260, //! < blue flag OBJECT_FLAGr = 261, //! < red flag diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 7be1177..ddd6545 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4351,6 +4351,24 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_beginObject = true; } + if (Cmd(line, "MissionController") && read[0] == 0 && m_version == 3) + { + if (!m_beginObject) { + GetLogger()->Error("Syntax error in file '%s' (line %d): MissionController before BeginObject\n", filename, lineNum); + continue; + } + + CObject* obj = CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, 1.0f, 0.0f, OBJECT_CONTROLLER, 100.0f, false, false, 0); + CBrain* brain = obj->GetBrain(); + if (brain != nullptr) + { + OpString(line, "script", name); + if (name[0] != 0) + brain->SetScriptName(1, name); + brain->SetScriptRun(1); + } + } + if (Cmd(line, "CreateObject") && read[0] == 0) { if (!m_beginObject) { @@ -4672,7 +4690,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*Math::PI); } - if (Cmd(line, "EndMissionTake") && !resetObject) + if (Cmd(line, "EndMissionTake") && !resetObject && m_version<3) { int i = m_endTakeTotal; if (i < 10) @@ -4695,16 +4713,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_endTakeTotal ++; } } - if (Cmd(line, "EndMissionDelay") && !resetObject) + if (Cmd(line, "EndMissionDelay") && !resetObject && m_version<3) { m_endTakeWinDelay = OpFloat(line, "win", 2.0f); m_endTakeLostDelay = OpFloat(line, "lost", 2.0f); } - if (Cmd(line, "EndMissionResearch") && !resetObject) + if (Cmd(line, "EndMissionResearch") && !resetObject && m_version<3) { m_endTakeResearch |= OpResearch(line, "type"); } - if (Cmd(line, "EndMissionNever") && !resetObject && m_version >= 2) + if (Cmd(line, "EndMissionNever") && !resetObject && m_version == 2) { m_endTakeNever = true; } @@ -5134,7 +5152,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || type == OBJECT_MOBILEdr || - type == OBJECT_APOLLO2 ) + type == OBJECT_APOLLO2 || + type == OBJECT_CONTROLLER ) { object = new CObject(); object->SetOption(option); @@ -6690,6 +6709,8 @@ void CRobotMain::UpdateAudio(bool frame) //! Checks if the mission is over Error CRobotMain::CheckEndMission(bool frame) { + if (m_version >= 3) return ERR_MISSION_NOTERM; //disabled. TODO: Control from program + CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); for (int t = 0; t < m_endTakeTotal; t++) @@ -6769,7 +6790,7 @@ Error CRobotMain::CheckEndMission(bool frame) } if (nb < m_endTake[t].min || nb > m_endTake[t].max || - m_endTakeNever) + m_endTakeNever ) { m_displayText->SetEnable(true); return ERR_MISSION_NOTERM; -- cgit v1.2.3-1-g7c22 From 5fd64624d34e9332b726ecaffecbcbd6686a7d2e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 28 Apr 2013 20:24:46 +0200 Subject: Fix for game crashing sometimes when using MissionController --- src/CMakeLists.txt | 1 + src/object/motion/motiondummy.cpp | 62 +++++++++++++++++++++++++++++++++++++++ src/object/motion/motiondummy.h | 32 ++++++++++++++++++++ src/object/object.cpp | 3 +- 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/object/motion/motiondummy.cpp create mode 100644 src/object/motion/motiondummy.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 26c02bc..f4305df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,6 +120,7 @@ object/mainmovie.cpp object/motion/motion.cpp object/motion/motionant.cpp object/motion/motionbee.cpp +object/motion/motiondummy.cpp object/motion/motionhuman.cpp object/motion/motionmother.cpp object/motion/motionspider.cpp diff --git a/src/object/motion/motiondummy.cpp b/src/object/motion/motiondummy.cpp new file mode 100644 index 0000000..68827ff --- /dev/null +++ b/src/object/motion/motiondummy.cpp @@ -0,0 +1,62 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + + +#include "object/motion/motiondummy.h" + +#include "graphics/engine/modelmanager.h" + +#include +#include + + + + + +// Object's constructor. + +CMotionDummy::CMotionDummy(CObject* object) : CMotion(object) +{ +} + +// Object's destructor. + +CMotionDummy::~CMotionDummy() +{ +} + + +// Removes an object. + +void CMotionDummy::DeleteObject(bool bAll) +{ +} + + +// Creates a Dummy traveling any lands on the ground. + +bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, + float power) +{ + m_object->SetType(type); + + // Creates the main base. + int rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_object->SetObjectRank(0, rank); + + return true; +} \ No newline at end of file diff --git a/src/object/motion/motiondummy.h b/src/object/motion/motiondummy.h new file mode 100644 index 0000000..744df2f --- /dev/null +++ b/src/object/motion/motiondummy.h @@ -0,0 +1,32 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +// motiondummy.h + +#pragma once + + +#include "object/motion/motion.h" + +class CMotionDummy : public CMotion +{ +public: + CMotionDummy(CObject* object); + ~CMotionDummy(); + + void DeleteObject(bool bAll=false); + bool Create(Math::Vector pos, float angle, ObjectType type, float power); +}; \ No newline at end of file diff --git a/src/object/object.cpp b/src/object/object.cpp index ce79e34..3459644 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -64,6 +64,7 @@ #include "object/motion/motion.h" #include "object/motion/motionant.h" #include "object/motion/motionbee.h" +#include "object/motion/motiondummy.h" #include "object/motion/motionhuman.h" #include "object/motion/motionmother.h" #include "object/motion/motionspider.h" @@ -2146,7 +2147,7 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type, m_motion = new CMotionHuman(this); } else if ( type == OBJECT_CONTROLLER ) { - m_motion = new CMotion(this); //dummy object + m_motion = new CMotionDummy(this); //dummy object } else { m_motion = new CMotionVehicle(this); -- cgit v1.2.3-1-g7c22 From 658ebe015f98b8f11f8d46110b5e089323f7d8cb Mon Sep 17 00:00:00 2001 From: XienDev Date: Mon, 29 Apr 2013 13:51:37 +0300 Subject: Fix for shadows (bugs #176 and #132) --- src/graphics/engine/engine.cpp | 2 +- src/object/motion/motionvehicle.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 274e179..5d77e29 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -3651,7 +3651,7 @@ void CEngine::DrawShadow() float lastIntensity = -1.0f; for (int i = 0; i < static_cast( m_shadows.size() ); i++) { - if (m_shadows[i].hide) + if (m_shadows[i].hide || !m_shadows[i].used) continue; Math::Vector pos = m_shadows[i].pos; // pos = center of the shadow on the ground diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index 44b8fdd..2eed83e 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -931,6 +931,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, rank = m_engine->CreateObject(); m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); pPower->SetObjectRank(0, rank); + pPower->CreateShadowCircle(1.5f, 1.0f); //create a shadow for battary if ( power <= 1.0f ) modelManager->AddModelCopy("power.mod", false, rank); else modelManager->AddModelCopy("atomic.mod", false, rank); -- cgit v1.2.3-1-g7c22 From 2ba146cd63cefd58f5ff464b5b94e43740cf0700 Mon Sep 17 00:00:00 2001 From: erihel Date: Mon, 29 Apr 2013 14:29:12 +0200 Subject: Fixed problem with test compilation Altered test cmake files to fix linker problem. Changed tga to png in pyro. Changed enum in CMotionDummy. --- src/graphics/engine/pyro.cpp | 2 +- src/object/motion/motiondummy.cpp | 5 +++-- src/object/motion/motiondummy.h | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index cab28b6..0a82408 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -1555,7 +1555,7 @@ void CPyro::ExploStart() { int objRank = m_object->GetObjectRank(i); if ( objRank == -1 ) continue; - m_engine->ChangeSecondTexture(objRank, "dirty04.tga"); + m_engine->ChangeSecondTexture(objRank, "dirty04.png"); Math::Vector pos = m_object->GetPosition(i); diff --git a/src/object/motion/motiondummy.cpp b/src/object/motion/motiondummy.cpp index 68827ff..577ff47 100644 --- a/src/object/motion/motiondummy.cpp +++ b/src/object/motion/motiondummy.cpp @@ -1,5 +1,6 @@ // * This file is part of the COLOBOT source code // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * Copyright (C) 2013 Polish Portal of Colobot (PPC) // * // * This program is free software: you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by @@ -55,8 +56,8 @@ bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, // Creates the main base. int rank = m_engine->CreateObject(); - m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); return true; -} \ No newline at end of file +} diff --git a/src/object/motion/motiondummy.h b/src/object/motion/motiondummy.h index 744df2f..de29148 100644 --- a/src/object/motion/motiondummy.h +++ b/src/object/motion/motiondummy.h @@ -1,5 +1,6 @@ // * This file is part of the COLOBOT source code // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * Copyright (C) 2013 Polish Portal of Colobot (PPC) // * // * This program is free software: you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by @@ -29,4 +30,4 @@ public: void DeleteObject(bool bAll=false); bool Create(Math::Vector pos, float angle, ObjectType type, float power); -}; \ No newline at end of file +}; -- cgit v1.2.3-1-g7c22 From c2932f4ee3c65aa5546a8b2fd605af9043aba72a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 29 Apr 2013 15:33:28 +0200 Subject: Added new Intro music (by PiXeL) --- src/sound/sound.h | 1 + src/ui/maindialog.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sound/sound.h b/src/sound/sound.h index a2302c4..11eca89 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -178,6 +178,7 @@ class CSoundInterface /** Function called to add all music files to list */ inline void AddMusicFiles(std::string path) { m_soundPath = path; + CacheMusic("Intro.ogg"); CacheMusic("music010.ogg"); CacheMusic("music011.ogg"); }; diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 092903d..699cb7b 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -747,7 +747,7 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_PROTO ) { if (!m_sound->IsPlayingMusic()) { - m_sound->PlayMusic(11, true); + m_sound->PlayMusic("Intro.ogg", false); } if ( m_phase == PHASE_TRAINER ) m_index = 0; @@ -1742,7 +1742,7 @@ pos.y -= 0.048f; if ( m_phase == PHASE_WELCOME1 ) { m_sound->StopMusic(); - m_sound->PlayMusic(11, false); + m_sound->PlayMusic("Intro.ogg", false); pos.x = 0.0f; pos.y = 0.0f; -- cgit v1.2.3-1-g7c22 From 75950c55ba2065e792dc573adbaa31897cbc113a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 29 Apr 2013 17:26:32 +0200 Subject: MissionController improved --- src/object/brain.cpp | 14 +++++++++----- src/object/motion/motiondummy.cpp | 33 +++++++++++++++++++++++++++------ src/object/robotmain.cpp | 29 +++++++++++++++++++++++++---- src/object/robotmain.h | 2 ++ src/object/task/taskgoto.cpp | 2 +- src/physics/physics.cpp | 3 ++- src/script/cmdtoken.cpp | 2 ++ src/script/script.cpp | 2 +- 8 files changed, 69 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/object/brain.cpp b/src/object/brain.cpp index f42ea7e..266a8ac 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -1309,7 +1309,8 @@ bool CBrain::CreateInterface(bool bSelect) type == OBJECT_ANT || type == OBJECT_SPIDER || type == OBJECT_BEE || - type == OBJECT_WORM ) // vehicle? + type == OBJECT_WORM || + type == OBJECT_CONTROLLER) // vehicle? { if (!(m_main->GetRetroMode())) { ddim.x = dim.x*5.1f; @@ -1334,7 +1335,8 @@ bool CBrain::CreateInterface(bool bSelect) type == OBJECT_MOBILEfi || type == OBJECT_MOBILEfs || type == OBJECT_MOBILEft || - type == OBJECT_BEE ) // driving? + type == OBJECT_BEE || + type == OBJECT_CONTROLLER) // driving? { pos.x = ox+sx*6.4f; pos.y = oy+sy*0; @@ -1346,8 +1348,9 @@ bool CBrain::CreateInterface(bool bSelect) pb = pw->CreateButton(pos, dim, 28, EVENT_OBJECT_GASUP); pb->SetImmediat(true); - if ( type != OBJECT_HUMAN || - m_object->GetOption() != 2 ) + if ( (type != OBJECT_HUMAN && + type != OBJECT_CONTROLLER) || + m_object->GetOption() != 2 ) { pos.x = ox+sx*15.3f; pos.y = oy+sy*0; @@ -2305,7 +2308,8 @@ void CBrain::UpdateInterface() type == OBJECT_ANT || type == OBJECT_SPIDER || type == OBJECT_BEE || - type == OBJECT_WORM ) // vehicle? + type == OBJECT_WORM || + type == OBJECT_CONTROLLER) // vehicle? { bRun = false; if ( m_script[m_selScript] != 0 ) diff --git a/src/object/motion/motiondummy.cpp b/src/object/motion/motiondummy.cpp index 577ff47..5b35cc4 100644 --- a/src/object/motion/motiondummy.cpp +++ b/src/object/motion/motiondummy.cpp @@ -17,16 +17,12 @@ #include "object/motion/motiondummy.h" - +#include "physics/physics.h" #include "graphics/engine/modelmanager.h" #include #include - - - - // Object's constructor. CMotionDummy::CMotionDummy(CObject* object) : CMotion(object) @@ -59,5 +55,30 @@ bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); + // Movement + m_physics->SetType(TYPE_FLYING); + + m_physics->SetLinMotionX(MO_ADVSPEED, 50.0f); + m_physics->SetLinMotionX(MO_RECSPEED, 50.0f); + m_physics->SetLinMotionX(MO_ADVACCEL, 20.0f); + m_physics->SetLinMotionX(MO_RECACCEL, 20.0f); + m_physics->SetLinMotionX(MO_STOACCEL, 20.0f); + m_physics->SetLinMotionX(MO_TERSLIDE, 5.0f); + m_physics->SetLinMotionZ(MO_TERSLIDE, 5.0f); + m_physics->SetLinMotionX(MO_TERFORCE, 50.0f); + m_physics->SetLinMotionZ(MO_TERFORCE, 50.0f); + m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f); + m_physics->SetLinMotionY(MO_ADVSPEED, 60.0f); + m_physics->SetLinMotionY(MO_RECSPEED, 60.0f); + m_physics->SetLinMotionY(MO_ADVACCEL, 20.0f); + m_physics->SetLinMotionY(MO_RECACCEL, 50.0f); + m_physics->SetLinMotionY(MO_STOACCEL, 50.0f); + + m_physics->SetCirMotionY(MO_ADVSPEED, 0.4f*Math::PI); + m_physics->SetCirMotionY(MO_RECSPEED, 0.4f*Math::PI); + m_physics->SetCirMotionY(MO_ADVACCEL, 2.0f); + m_physics->SetCirMotionY(MO_RECACCEL, 2.0f); + m_physics->SetCirMotionY(MO_STOACCEL, 2.0f); + return true; -} +} \ No newline at end of file diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ddd6545..991449e 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -656,6 +656,7 @@ CRobotMain::CRobotMain(CApplication* app) m_terrainCreate = false; m_version = 1; + m_controller = nullptr; m_retroStyle = false; m_immediatSatCom = false; m_beginSatCom = false; @@ -1791,6 +1792,23 @@ void CRobotMain::ExecuteCmd(char *cmd) return; } + if (strcmp(cmd, "controller") == 0) + { + 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(); + + CObject* prev = DeselectAll(); + if (prev != nullptr && prev != m_controller) + m_controller->AddDeselList(prev); + + SelectOneObject(m_controller, true); + m_short->UpdateShortcuts(); + } + return; + } + if (strcmp(cmd, "photo1") == 0) { m_freePhoto = !m_freePhoto; @@ -3839,6 +3857,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_mapImage = false; m_mapFilename[0] = 0; + m_controller = nullptr; + m_colorRefBot.r = 10.0f/256.0f; m_colorRefBot.g = 166.0f/256.0f; m_colorRefBot.b = 254.0f/256.0f; // blue @@ -4358,14 +4378,15 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - CObject* obj = CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, 1.0f, 0.0f, OBJECT_CONTROLLER, 100.0f, false, false, 0); - CBrain* brain = obj->GetBrain(); + m_controller = CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, 1.0f, 0.0f, OBJECT_CONTROLLER, 100.0f, false, false, 0); + m_controller->SetMagnifyDamage(100.0f); + CBrain* brain = m_controller->GetBrain(); if (brain != nullptr) { OpString(line, "script", name); if (name[0] != 0) - brain->SetScriptName(1, name); - brain->SetScriptRun(1); + brain->SetScriptName(0, name); + brain->SetScriptRun(0); } } diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 73315af..1ab1b46 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -469,6 +469,8 @@ protected: int m_delayWriteMessage; int m_movieInfoIndex; + CObject* m_controller; + //Level Checker flags bool m_beginObject; bool m_terrainGenerate; diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 19d129d..3177131 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -1455,7 +1455,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) // The worm goes everywhere and through everything! iType = m_object->GetType(); - if ( iType == OBJECT_WORM ) return; + if ( iType == OBJECT_WORM || iType == OBJECT_CONTROLLER ) return; m_object->GetCrashSphere(0, iPos, iRadius); gDist = Math::Distance(iPos, m_goal); diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 6311ecf..f443513 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -794,7 +794,8 @@ void CPhysics::MotorUpdate(float aTime, float rTime) type == OBJECT_BEE || type == OBJECT_WORM || type == OBJECT_APOLLO2 || - type == OBJECT_MOBILEdr ) + type == OBJECT_MOBILEdr || + type == OBJECT_CONTROLLER) { power = 0; } diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp index ab0528b..9c97f7d 100644 --- a/src/script/cmdtoken.cpp +++ b/src/script/cmdtoken.cpp @@ -401,6 +401,7 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def) if ( Cmd(p, "ApolloAntenna" ) ) return OBJECT_APOLLO5; if ( Cmd(p, "Me" ) ) return OBJECT_HUMAN; if ( Cmd(p, "Tech" ) ) return OBJECT_TECH; + if ( Cmd(p, "MissionController" ) ) return OBJECT_CONTROLLER; return def; } @@ -647,6 +648,7 @@ const char* GetTypeObject(ObjectType type) if ( type == OBJECT_APOLLO5 ) return "ApolloAntenna"; if ( type == OBJECT_HUMAN ) return "Me"; if ( type == OBJECT_TECH ) return "Tech"; + if ( type == OBJECT_CONTROLLER ) return "MissionController"; return ""; } diff --git a/src/script/script.cpp b/src/script/script.cpp index c9e3c66..9f002a7 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -668,7 +668,7 @@ bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user) if ( pObj->GetProxyActivate() ) continue; oType = pObj->GetType(); - if ( oType == OBJECT_TOTO ) continue; + if ( oType == OBJECT_TOTO || oType == OBJECT_CONTROLLER ) continue; if ( oType == OBJECT_RUINmobilew2 || oType == OBJECT_RUINmobilet1 || -- cgit v1.2.3-1-g7c22 From 643153d64dd25cb27fae76c9cc22e9bdaa2e352e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 30 Apr 2013 21:43:59 +0200 Subject: Added function endmission() Works only with MissionFile version=3 Created for MissionController, but works on any bot - 1st parameter: * ResultWin - win mission * ResultLost - lost mission * ResultLostQuick - lost mission (Me died) - 2nd parameter: win/lost delay, like in mission file. Doesn't work for ResultLostQuick. Please don't use for cheating =) --- src/object/robotmain.cpp | 39 ++++++++++++++++++++++++++++++++++++++- src/object/robotmain.h | 3 +++ src/script/script.cpp | 31 +++++++++++++++++++++++++++++++ src/script/script.h | 2 ++ 4 files changed, 74 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 991449e..67d4f44 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -811,6 +811,11 @@ CRobotMain::CRobotMain(CApplication* app) CBotProgram::DefineNum("ExploBurn", EXPLO_BURN); CBotProgram::DefineNum("ExploWater", EXPLO_WATER); + CBotProgram::DefineNum("ResultNotEnded", ERR_MISSION_NOTERM); + CBotProgram::DefineNum("ResultLost", INFO_LOST); + CBotProgram::DefineNum("ResultLostQuick", INFO_LOSTq); + CBotProgram::DefineNum("ResultWin", ERR_OK); + CBotProgram::DefineNum("PolskiPortalColobota", 1337); CBotClass* bc; @@ -3896,6 +3901,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_version = 1; m_retroStyle = false; + + m_missionResult = ERR_MISSION_NOTERM; } char line[500]; @@ -6727,10 +6734,40 @@ void CRobotMain::UpdateAudio(bool frame) } } +void CRobotMain::SetEndMission(Error result, float delay) +{ + if (m_version >= 3) { + m_endTakeWinDelay = delay; + m_endTakeLostDelay = delay; + m_missionResult = result; + } +} + //! Checks if the mission is over Error CRobotMain::CheckEndMission(bool frame) { - if (m_version >= 3) return ERR_MISSION_NOTERM; //disabled. TODO: Control from program + if (m_version >= 3) { + 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; + m_displayText->SetEnable(false); + } + if (m_missionResult == INFO_LOSTq) { //mission lost? + m_winDelay = 0.0f; + 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? + if (!(frame && m_base)) m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f)); + if(m_winDelay == 0) m_winDelay = m_endTakeWinDelay; + m_lostDelay = 0.0f; + m_displayText->SetEnable(false); + } + if (m_missionResult == ERR_MISSION_NOTERM) m_displayText->SetEnable(true); + return m_missionResult; + } CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 1ab1b46..f80d611 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -265,6 +265,7 @@ public: void ResetObject(); void ResetCreate(); void UpdateAudio(bool frame); + void SetEndMission(Error result, float delay); Error CheckEndMission(bool frame); void CheckEndMessage(const char* message); int GetObligatoryToken(); @@ -556,6 +557,8 @@ protected: int m_freeBuild; // constructible buildings int m_freeResearch; // researches possible + Error m_missionResult; + ShowLimit m_showLimit[MAXSHOWLIMIT]; Gfx::Color m_colorRefBot; diff --git a/src/script/script.cpp b/src/script/script.cpp index 9f002a7..a9cebe6 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -313,6 +313,35 @@ bool CScript::rAbs(CBotVar* var, CBotVar* result, int& exception, void* user) return true; } +// Compilation of the instruction "endmission(result)" + +CBotTypResult CScript::cEndMission(CBotVar* &var, void* user) +{ + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + return CBotTypResult(CBotTypFloat); +} + +// Instruction "endmission(result)" + +bool CScript::rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + Error ended; + float delay; + + ended = static_cast(var->GetValFloat()); + var = var->GetNext(); + + delay = var->GetValFloat(); + + CRobotMain::GetInstancePointer()->SetEndMission(ended, delay); + return true; +} // Compilation of the instruction "retobject(rank)". @@ -2950,6 +2979,8 @@ void CScript::InitFonctions() CBotProgram::AddFunction("rand", rRand, CScript::cNull); CBotProgram::AddFunction("abs", rAbs, CScript::cOneFloat); + CBotProgram::AddFunction("endmission",rEndMission,CScript::cEndMission); + CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy); CBotProgram::AddFunction("search", rSearch, CScript::cSearch); diff --git a/src/script/script.h b/src/script/script.h index 702138b..956aca6 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -99,6 +99,7 @@ private: static CBotTypResult cOneFloat(CBotVar* &var, void* user); static CBotTypResult cTwoFloat(CBotVar* &var, void* user); static CBotTypResult cString(CBotVar* &var, void* user); + static CBotTypResult cEndMission(CBotVar* &var, void* user); static CBotTypResult cGetObject(CBotVar* &var, void* user); static CBotTypResult cDestroy(CBotVar* &var, void* user); static CBotTypResult cSearch(CBotVar* &var, void* user); @@ -134,6 +135,7 @@ private: static bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From f419293207fe27113fb16daebec959e94a30dbee Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 12:12:32 +0200 Subject: Minor refactoring --- src/object/robotmain.cpp | 2 +- src/sound/oalsound/alsound.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 67d4f44..ad4f48c 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -6760,7 +6760,7 @@ Error CRobotMain::CheckEndMission(bool frame) } if (frame && m_base) return ERR_MISSION_NOTERM; if (m_missionResult == ERR_OK) { //mission win? - if (!(frame && m_base)) m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f)); + m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f)); if(m_winDelay == 0) m_winDelay = m_endTakeWinDelay; m_lostDelay = 0.0f; m_displayText->SetEnable(false); diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index cfb0c70..a37cced 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -258,7 +258,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) return true; } delete chn; - GetLogger()->Error("Could not open channel to play sound!"); + GetLogger()->Error("Could not open channel to play sound!\n"); return false; } @@ -279,7 +279,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) return true; } delete chn; - GetLogger()->Warn("Could not open additional channel to play sound!"); + GetLogger()->Warn("Could not open additional channel to play sound!\n"); } } } @@ -287,7 +287,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) int lowerOrEqual = -1; for (auto it : mChannels) { if (it.second->GetPriority() < priority) { - GetLogger()->Debug("Sound channel with lower priority will be reused."); + GetLogger()->Debug("Sound channel with lower priority will be reused.\n"); channel = it.first; return true; } @@ -297,7 +297,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) if (lowerOrEqual != -1) { channel = lowerOrEqual; - GetLogger()->Debug("Sound channel with lower or equal priority will be reused."); + GetLogger()->Debug("Sound channel with lower or equal priority will be reused.\n"); return true; } -- cgit v1.2.3-1-g7c22 From 293376b82d8fa313b17685b73c110a33123f9077 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 12:47:06 +0200 Subject: Removed sound081.wav It wasn't used in Colobot and caused errors because we removed it from data package. --- src/physics/physics.cpp | 4 ++-- src/sound/sound.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index f443513..2c5f95e 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -1917,7 +1917,7 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type) if ( m_object->GetToy() ) { - sound = SOUND_MOTORd; + sound = SOUND_NONE; //SOUND_MOTORd; amplitude = 1.0f; time = 0.1f; } @@ -2016,7 +2016,7 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) if ( m_object->GetToy() ) { - sound = SOUND_MOTORd; + sound = SOUND_NONE; // SOUND_MOTORd; amplitude = 0.0f; } diff --git a/src/sound/sound.h b/src/sound/sound.h index 11eca89..0148242 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -130,7 +130,7 @@ enum Sound SOUND_FIREp = 78, /*!< shooting with phazer */ SOUND_EXPLOg1 = 79, /*!< impact gun 1 */ SOUND_EXPLOg2 = 80, /*!< impact gun 2 */ - SOUND_MOTORd = 81, /*!< engine friction */ +// SOUND_MOTORd = 81, /*!< engine friction */ }; -- cgit v1.2.3-1-g7c22 From 9e1870f6bdb24e278c06929b8bd13225a7fdf8d3 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 13:19:10 +0200 Subject: Removed some warnings + fix for previous commit --- src/object/auto/autosafe.cpp | 2 +- src/object/motion/motionant.cpp | 2 +- src/object/motion/motionbee.cpp | 2 +- src/object/motion/motionhuman.cpp | 2 +- src/object/motion/motionspider.cpp | 2 +- src/object/motion/motionvehicle.cpp | 2 +- src/object/task/taskbuild.cpp | 2 +- src/object/task/taskgoto.cpp | 4 ++-- src/script/script.cpp | 6 ++++-- src/sound/sound.h | 2 +- src/ui/edit.cpp | 10 +++++----- 11 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp index fc83400..58c459a 100644 --- a/src/object/auto/autosafe.cpp +++ b/src/object/auto/autosafe.cpp @@ -400,7 +400,7 @@ int CAutoSafe::CountKeys() Math::Vector cPos, oPos; Math::Point rot; ObjectType oType; - float dist, angle, limit, cAngle, oAngle; + float dist, angle, limit = 0.0f, cAngle, oAngle = 0.0f; int i, index; cPos = m_object->GetPosition(0); diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp index 07e743f..3eabc0e 100644 --- a/src/object/motion/motionant.cpp +++ b/src/object/motion/motionant.cpp @@ -425,7 +425,7 @@ bool CMotionAnt::EventFrame(const Event &event) { Math::Vector dir, pos, speed; Math::Point dim; - float s, a, prog, time; + float s, a, prog = 0.0f, time; float tSt[9], tNd[9]; int i, ii, st, nd, action; bool bStop; diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp index e4fdd49..a0f4734 100644 --- a/src/object/motion/motionbee.cpp +++ b/src/object/motion/motionbee.cpp @@ -406,7 +406,7 @@ bool CMotionBee::EventProcess(const Event &event) bool CMotionBee::EventFrame(const Event &event) { Math::Vector dir; - float s, a, prog; + float s, a, prog = 0.0f; int action, i, st, nd; bool bStop; diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index 76ff353..c469a7e 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -677,7 +677,7 @@ bool CMotionHuman::EventFrame(const Event &event) float s, a, prog, rTime[2], lTime[2], time, rot, hr, hl; float al, ar, af; float tSt[9], tNd[9]; - float aa, bb, shield, deadFactor, level; + float aa, bb, shield, deadFactor = 0.0f, level; int i, ii, st, nd, action, legAction, armAction; bool bOnBoard, bSwim; diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp index f76b65b..a9a9b9b 100644 --- a/src/object/motion/motionspider.cpp +++ b/src/object/motion/motionspider.cpp @@ -363,7 +363,7 @@ bool CMotionSpider::EventFrame(const Event &event) { Math::Vector dir, pos, speed; Math::Point dim; - float s, a, prog, time; + float s, a, prog = 0.0f, time; float tSt[12], tNd[12]; int i, ii, st, nd, action; bool bStop; diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index d65809e..966fe75 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -1650,7 +1650,7 @@ bool CMotionVehicle::EventFrameFly(const Event &event) bool CMotionVehicle::EventFrameInsect(const Event &event) { Math::Vector dir; - float s, a, prog, time; + float s, a, prog = 0.0f, time; int i, st, nd, action; bool bStop, bOnBoard; diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index b9af475..39479a6 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -557,7 +557,7 @@ Error CTaskBuild::FlatFloor() ObjectType type; Math::Vector center, pos, oPos, bPos; Math::Point c, p; - float radius, max, oRadius, bRadius, angle, dist; + float radius, max, oRadius, bRadius = 0.0f, angle, dist; int i, j; bool bLittleFlat, bBase; diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 3177131..97331dd 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -756,7 +756,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, Error CTaskGoto::IsEnded() { Math::Vector pos; - float limit, angle, dist, h, level; + float limit, angle = 0.0f, dist, h, level; if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_error != ERR_OK ) return m_error; @@ -1338,7 +1338,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay) { - CObject *pObj, *pObstacle; + CObject *pObj, *pObstacle = nullptr; Math::Vector iPos, oPos, bPos; float iRadius, oRadius, bRadius, dist, min, dir; int i, j; diff --git a/src/script/script.cpp b/src/script/script.cpp index a9cebe6..5c430d7 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -617,9 +617,10 @@ bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user) RadarFilter filter; float best, minDist, maxDist, sens, iAngle, angle, focus, d, a; int type, oType, i; - bool bArray; + bool bArray = false; type = OBJECT_NULL; + array = 0; angle = 0.0f; focus = Math::PI*2.0f; minDist = 0.0f*g_unit; @@ -836,7 +837,7 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user) RadarFilter filter; float bGoal, best, minDist, maxDist, sens, iAngle, angle, focus, d, a; int type, oType, i; - bool bArray; + bool bArray = false; Error err; exception = 0; @@ -844,6 +845,7 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user) if ( script->m_primaryTask == 0 ) // no task in progress? { type = OBJECT_NULL; + array = 0; angle = 0.0f; focus = 45.0f*Math::PI/180.0f; minDist = 0.0f*g_unit; diff --git a/src/sound/sound.h b/src/sound/sound.h index 0148242..e6a97df 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -167,7 +167,7 @@ class CSoundInterface * Function calls \link CSoundInterface::Cache() \endlink for each file */ inline void CacheAll(std::string path) { - for ( int i = 1; i <= 81; i++ ) { + for ( int i = 1; i <= 80; i++ ) { std::stringstream filename; filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav"; if ( !Cache(static_cast(i), filename.str()) ) diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp index 7e657c8..c9831dd 100644 --- a/src/ui/edit.cpp +++ b/src/ui/edit.cpp @@ -688,7 +688,7 @@ void CEdit::MouseMove(Math::Point mouse) int CEdit::MouseDetect(Math::Point mouse) { Math::Point pos; - float indentLength, offset, size; + float indentLength = 0.0f, offset, size; int i, len, c; bool bTitle; @@ -886,7 +886,7 @@ bool CEdit::HyperGo(EventType event) void CEdit::Draw() { Math::Point pos, ppos, dim, start, end; - float size, indentLength; + float size = 0.0f, indentLength = 0.0f; int i, j, beg, len, c1, c2, o1, o2, eol, iIndex, line; if ( (m_state & STATE_VISIBLE) == 0 ) return; @@ -1877,7 +1877,7 @@ bool CEdit::WriteText(std::string filename) FILE* file; char buffer[1000+20]; int i, j, k, n; - float iDim; + float iDim = 0.0f; if ( filename[0] == 0 ) return false; file = fopen(filename.c_str(), "wb"); @@ -2397,7 +2397,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect) void CEdit::MoveLine(int move, bool bWord, bool bSelect) { - float column, indentLength; + float column, indentLength = 0.0f; int i, line, c; if ( move == 0 ) return; @@ -2956,7 +2956,7 @@ bool CEdit::MinMaj(bool bMaj) void CEdit::Justif() { - float width, size, indentLength; + float width, size, indentLength = 0.0f; int i, j, line, indent; bool bDual, bString, bRem; -- cgit v1.2.3-1-g7c22 From 23e3e552f3a93b382e494d0a60ab22c266d1dcd1 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 19:44:55 +0200 Subject: Made colobot.ini & savegame dir location depended on build type For Debug, it's current dir For Release it's like it was before Made on @CoLoRaptor's request :) --- src/common/profile.cpp | 8 ++++++++ src/ui/maindialog.cpp | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/common/profile.cpp b/src/common/profile.cpp index 654648d..f36baca 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -43,7 +43,11 @@ CProfile::~CProfile() { try { + #ifdef NDEBUG bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); + #else + bp::ini_parser::write_ini("colobot.ini", m_propertyTree); + #endif } catch (std::exception & e) { @@ -57,7 +61,11 @@ bool CProfile::InitCurrentDirectory() { try { + #ifdef NDEBUG bp::ini_parser::read_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); + #else + bp::ini_parser::read_ini("colobot.ini", m_propertyTree); + #endif } catch (std::exception & e) { diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 699cb7b..2a8bb42 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -174,7 +174,11 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; + #ifdef NDEBUG m_savegameDir = GetSystemUtils()->savegameDirectoryLocation(); + #else + m_savegameDir = "savegame"; + #endif m_publicDir = "program"; m_userDir = "user"; m_filesDir = "files"; -- cgit v1.2.3-1-g7c22 From d815fbf09e0e99b42d449bce7083bc0968f581be Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 21:02:43 +0200 Subject: Saving information to profile (#154) --- src/common/restext.cpp | 4 +-- src/common/restext.h | 4 ++- src/object/robotmain.cpp | 80 +++++++++++++++++++++--------------------------- src/object/robotmain.h | 2 +- 4 files changed, 41 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 9af73e4..b610d7f 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -731,9 +731,9 @@ void InitializeRestext() static char g_gamerName[100]; -void SetGlobalGamerName(char *name) +void SetGlobalGamerName(std::string name) { - strcpy(g_gamerName, name); + strcpy(g_gamerName, name.c_str()); } diff --git a/src/common/restext.h b/src/common/restext.h index 8199f9f..1c99473 100644 --- a/src/common/restext.h +++ b/src/common/restext.h @@ -24,6 +24,8 @@ #include "common/global.h" +#include + /** * \enum ResType @@ -153,6 +155,6 @@ enum ResTextType void InitializeRestext(); -void SetGlobalGamerName(char *name); +void SetGlobalGamerName(std::string name); bool SearchKey(const char *cmd, InputSlot& slot); bool GetResource(ResType type, int num, char* text); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ad4f48c..f57220d 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -706,27 +706,25 @@ CRobotMain::CRobotMain(CApplication* app) m_windowPos = Math::Point(0.15f, 0.17f); m_windowDim = Math::Point(0.70f, 0.66f); - // TODO: profile - // float fValue; - // int iValue; + float fValue; + int iValue; - // if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; - // if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue; - // if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue; - // if (GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue; - // if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; m_IOPublic = false; m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle m_IOPos.y = (1.0f-m_IODim.y)/2.0f; - /* TODO: profile - if (GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; - if (GetLocalProfileFloat("Edit", "IOPos.x", fValue)) m_IOPos.x = fValue; - if (GetLocalProfileFloat("Edit", "IOPos.y", fValue)) m_IOPos.y = fValue; - if (GetLocalProfileFloat("Edit", "IODim.x", fValue)) m_IODim.x = fValue; - if (GetLocalProfileFloat("Edit", "IODim.y", fValue)) m_IODim.y = fValue; */ + if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IOPos.x", fValue)) m_IOPos.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IOPos.y", fValue)) m_IOPos.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IODim.x", fValue)) m_IODim.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IODim.y", fValue)) m_IODim.y = fValue; m_short->FlushShortcuts(); InitEye(); @@ -742,9 +740,8 @@ CRobotMain::CRobotMain(CApplication* app) g_researchEnable = 0; g_unit = UNIT; - m_gamerName[0] = 0; - /* TODO: profile - GetLocalProfileString("Gamer", "LastName", m_gamerName, 100); */ + m_gamerName = ""; + GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName); SetGlobalGamerName(m_gamerName); ReadFreeParam(); m_dialog->SetupRecall(); @@ -907,11 +904,10 @@ Ui::CDisplayText* CRobotMain::GetDisplayText() //! Creates the file colobot.ini at the first time void CRobotMain::CreateIni() { - /* TODO: profile int iValue; // colobot.ini doesn't exist? - if (!GetLocalProfileInt("Setup", "TotoMode", iValue)) - m_dialog->SetupMemorize();*/ + if (!GetProfile().GetLocalProfileInt("Setup", "TotoMode", iValue)) + m_dialog->SetupMemorize(); } void CRobotMain::SetDefaultInputBindings() @@ -2235,8 +2231,7 @@ float CRobotMain::GetGameTime() void CRobotMain::SetFontSize(float size) { m_fontSize = size; - /* TODO: profile - SetLocalProfileFloat("Edit", "FontSize", m_fontSize); */ + GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize); } float CRobotMain::GetFontSize() @@ -2248,9 +2243,8 @@ float CRobotMain::GetFontSize() void CRobotMain::SetWindowPos(Math::Point pos) { m_windowPos = pos; - /* TODO: profile - SetLocalProfileFloat("Edit", "WindowPos.x", m_windowPos.x); - SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y); */ + GetProfile().SetLocalProfileFloat("Edit", "WindowPos.x", m_windowPos.x); + GetProfile().SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y); } Math::Point CRobotMain::GetWindowPos() @@ -2261,9 +2255,8 @@ Math::Point CRobotMain::GetWindowPos() void CRobotMain::SetWindowDim(Math::Point dim) { m_windowDim = dim; - /* TODO: profile - SetLocalProfileFloat("Edit", "WindowDim.x", m_windowDim.x); - SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y); */ + GetProfile().SetLocalProfileFloat("Edit", "WindowDim.x", m_windowDim.x); + GetProfile().SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y); } Math::Point CRobotMain::GetWindowDim() @@ -2276,8 +2269,7 @@ Math::Point CRobotMain::GetWindowDim() void CRobotMain::SetIOPublic(bool mode) { m_IOPublic = mode; - /* TODO: profile - SetLocalProfileInt("Edit", "IOPublic", m_IOPublic); */ + GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic); } bool CRobotMain::GetIOPublic() @@ -2288,9 +2280,8 @@ bool CRobotMain::GetIOPublic() void CRobotMain::SetIOPos(Math::Point pos) { m_IOPos = pos; - /* TODO: profile - SetLocalProfileFloat("Edit", "IOPos.x", m_IOPos.x); - SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y); */ + GetProfile().SetLocalProfileFloat("Edit", "IOPos.x", m_IOPos.x); + GetProfile().SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y); } Math::Point CRobotMain::GetIOPos() @@ -2301,9 +2292,8 @@ Math::Point CRobotMain::GetIOPos() void CRobotMain::SetIODim(Math::Point dim) { m_IODim = dim; - /* TODO: profile - SetLocalProfileFloat("Edit", "IODim.x", m_IODim.x); - SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y); */ + GetProfile().SetLocalProfileFloat("Edit", "IODim.x", m_IODim.x); + GetProfile().SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y); } Math::Point CRobotMain::GetIODim() @@ -5874,7 +5864,7 @@ void CRobotMain::LoadOneScript(CObject *obj, int &nbError) char filename[MAX_FNAME]; sprintf(filename, "%s/%s/%c%.3d%.3d%.1d.txt", - GetSavegameDir(), m_gamerName, name[0], rank, objRank, i); + GetSavegameDir(), m_gamerName.c_str(), name[0], rank, objRank, i); brain->ReadProgram(i, filename); if (!brain->GetCompile(i)) nbError++; } @@ -5944,7 +5934,7 @@ void CRobotMain::SaveOneScript(CObject *obj) { char filename[MAX_FNAME]; sprintf(filename, "%s/%s/%c%.3d%.3d%.1d.txt", - GetSavegameDir(), m_gamerName, name[0], rank, objRank, i); + GetSavegameDir(), m_gamerName.c_str(), name[0], rank, objRank, i); brain->WriteProgram(i, filename); } } @@ -6494,10 +6484,10 @@ void CRobotMain::WriteFreeParam() m_freeResearch |= g_researchDone; m_freeBuild |= g_build; - if (m_gamerName[0] == 0) return; + if (m_gamerName == "") return; char filename[MAX_FNAME]; - sprintf(filename, "%s/%s/research.gam", GetSavegameDir(), m_gamerName); + sprintf(filename, "%s/%s/research.gam", GetSavegameDir(), m_gamerName.c_str()); FILE* file = fopen(filename, "w"); if (file == NULL) return; @@ -6513,10 +6503,10 @@ void CRobotMain::ReadFreeParam() m_freeResearch = 0; m_freeBuild = 0; - if (m_gamerName[0] == 0) return; + if (m_gamerName == "") return; char filename[MAX_FNAME]; - sprintf(filename, "%s/%s/research.gam", GetSavegameDir(), m_gamerName); + sprintf(filename, "%s/%s/research.gam", GetSavegameDir(), m_gamerName.c_str()); FILE* file = fopen(filename, "r"); if (file == NULL) return; @@ -7063,15 +7053,15 @@ bool CRobotMain::GetRetroMode() //! Change the player's name void CRobotMain::SetGamerName(const char *name) { - strcpy(m_gamerName, name); + m_gamerName = std::string(name); SetGlobalGamerName(m_gamerName); ReadFreeParam(); } -//! Getes the player's name +//! Gets the player's name char* CRobotMain::GetGamerName() { - return m_gamerName; + return const_cast(m_gamerName.c_str()); } diff --git a/src/object/robotmain.h b/src/object/robotmain.h index f80d611..6c331ab 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -552,7 +552,7 @@ protected: int m_prohibitedTotal; char m_prohibitedToken[100][20]; - char m_gamerName[100]; + std::string m_gamerName; int m_freeBuild; // constructible buildings int m_freeResearch; // researches possible -- cgit v1.2.3-1-g7c22 From 07374db2a34448f961c31f2ae617d73f46eac0f6 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 21:32:40 +0200 Subject: Increased maximum font size --- src/ui/displayinfo.cpp | 10 +++++----- src/ui/studio.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index fcc77db..f83ff5a 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -154,28 +154,28 @@ bool CDisplayInfo::EventProcess(const Event &event) { m_main->SetFontSize(9.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } if ( event.type == EVENT_HYPER_SIZE2 ) // size 2? { m_main->SetFontSize(10.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } if ( event.type == EVENT_HYPER_SIZE3 ) // size 3? { m_main->SetFontSize(12.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } if ( event.type == EVENT_HYPER_SIZE4 ) // size 4? { m_main->SetFontSize(15.0f); slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); - if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f); + if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/12.0f); ViewDisplayInfo(); } @@ -183,7 +183,7 @@ bool CDisplayInfo::EventProcess(const Event &event) { slider = static_cast(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider == 0 ) return false; - m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); + m_main->SetFontSize(9.0f+slider->GetVisibleValue()*12.0f); ViewDisplayInfo(); } diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 1cedabb..52a0ddc 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -167,7 +167,7 @@ bool CStudio::EventProcess(const Event &event) { slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider == nullptr ) return false; - m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); + m_main->SetFontSize(9.0f+slider->GetVisibleValue()*12.0f); ViewEditScript(); } -- cgit v1.2.3-1-g7c22 From fb5d14dddf180a369617968bc3b14492ded329af Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 1 May 2013 22:11:08 +0200 Subject: Functions playmusic(filename, repeat) and stopmusic() for MissionController Parameter repeat can be 0 or 1 --- src/script/script.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/script/script.h | 3 +++ 2 files changed, 51 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index 5c430d7..d108c7a 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -39,6 +39,8 @@ #include "script/cbottoken.h" +#include "sound/sound.h" + #include "ui/interface.h" #include "ui/edit.h" #include "ui/list.h" @@ -313,7 +315,7 @@ bool CScript::rAbs(CBotVar* var, CBotVar* result, int& exception, void* user) return true; } -// Compilation of the instruction "endmission(result)" +// Compilation of the instruction "endmission(result, delay)" CBotTypResult CScript::cEndMission(CBotVar* &var, void* user) { @@ -327,7 +329,7 @@ CBotTypResult CScript::cEndMission(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } -// Instruction "endmission(result)" +// Instruction "endmission(result, delay)" bool CScript::rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user) { @@ -343,6 +345,48 @@ bool CScript::rEndMission(CBotVar* var, CBotVar* result, int& exception, void* u return true; } +// Compilation of the instruction "playmusic(filename, repeat)" + +CBotTypResult CScript::cPlayMusic(CBotVar* &var, void* user) +{ + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + return CBotTypResult(CBotTypFloat); +} + +// Instruction "playmusic(filename, repeat)" + +bool CScript::rPlayMusic(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + std::string filename; + CBotString cbs; + bool repeat; + + cbs = var->GetValString(); + filename = std::string(cbs); + var = var->GetNext(); + + repeat = var->GetValInt(); + + CApplication::GetInstancePointer()->GetSound()->StopMusic(); + CApplication::GetInstancePointer()->GetSound()->PlayMusic(filename, repeat); + return true; +} + +// Instruction "stopmusic()" + +bool CScript::rStopMusic(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + CApplication::GetInstancePointer()->GetSound()->StopMusic(); + return true; +} + + // Compilation of the instruction "retobject(rank)". CBotTypResult CScript::cGetObject(CBotVar* &var, void* user) @@ -2982,6 +3026,8 @@ void CScript::InitFonctions() CBotProgram::AddFunction("abs", rAbs, CScript::cOneFloat); CBotProgram::AddFunction("endmission",rEndMission,CScript::cEndMission); + CBotProgram::AddFunction("playmusic", rPlayMusic ,CScript::cPlayMusic); + CBotProgram::AddFunction("stopmusic", rStopMusic ,CScript::cNull); CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy); diff --git a/src/script/script.h b/src/script/script.h index 956aca6..535b974 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -100,6 +100,7 @@ private: static CBotTypResult cTwoFloat(CBotVar* &var, void* user); static CBotTypResult cString(CBotVar* &var, void* user); static CBotTypResult cEndMission(CBotVar* &var, void* user); + static CBotTypResult cPlayMusic(CBotVar* &var, void* user); static CBotTypResult cGetObject(CBotVar* &var, void* user); static CBotTypResult cDestroy(CBotVar* &var, void* user); static CBotTypResult cSearch(CBotVar* &var, void* user); @@ -136,6 +137,8 @@ private: static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rPlayMusic(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rStopMusic(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From c1db140ad36402271914be8d993413aa5f4676bc Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 10:44:07 +0200 Subject: Updated Main Mnu music For now only code - we need to wait for PiXeL to give us new music :) --- src/object/objman.h | 2 +- src/sound/sound.h | 3 ++- src/ui/maindialog.cpp | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/object/objman.h b/src/object/objman.h index 3bdf1a2..c776a86 100644 --- a/src/object/objman.h +++ b/src/object/objman.h @@ -15,7 +15,7 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. /** - * \file common/objman.h + * \file object/objman.h * \brief Instance manager for objects */ diff --git a/src/sound/sound.h b/src/sound/sound.h index e6a97df..360f0de 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -178,7 +178,8 @@ class CSoundInterface /** Function called to add all music files to list */ inline void AddMusicFiles(std::string path) { m_soundPath = path; - CacheMusic("Intro.ogg"); + CacheMusic("Intro1.ogg"); + CacheMusic("Intro2.ogg"); CacheMusic("music010.ogg"); CacheMusic("music011.ogg"); }; diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 2a8bb42..050f87a 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -751,7 +751,7 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_PROTO ) { if (!m_sound->IsPlayingMusic()) { - m_sound->PlayMusic("Intro.ogg", false); + m_sound->PlayMusic("Intro1.ogg", false); } if ( m_phase == PHASE_TRAINER ) m_index = 0; @@ -1746,7 +1746,7 @@ pos.y -= 0.048f; if ( m_phase == PHASE_WELCOME1 ) { m_sound->StopMusic(); - m_sound->PlayMusic("Intro.ogg", false); + m_sound->PlayMusic("Intro1.ogg", false); pos.x = 0.0f; pos.y = 0.0f; @@ -2005,6 +2005,23 @@ bool CMainDialog::EventProcess(const Event &event) //? else welcomeLength = WELCOME_LENGTH; welcomeLength = WELCOME_LENGTH; + if ( m_phase != PHASE_SIMUL && + m_phase != PHASE_WIN && + m_phase != PHASE_LOST && + m_phase != PHASE_WRITE && + m_phase != PHASE_READs && + m_phase != PHASE_WRITEs && + m_phase != PHASE_SETUPds && + m_phase != PHASE_SETUPgs && + m_phase != PHASE_SETUPps && + m_phase != PHASE_SETUPcs && + m_phase != PHASE_SETUPss ) + { + if (!m_sound->IsPlayingMusic()) { + m_sound->PlayMusic("Intro2.ogg", true); + } + } + if ( m_phase == PHASE_WELCOME1 || m_phase == PHASE_WELCOME2 || m_phase == PHASE_WELCOME3 ) -- cgit v1.2.3-1-g7c22 From d9f1b4f69d4408c0357a399aa61bd38998fd354b Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 10:53:18 +0200 Subject: Added CacheAudio to level files --- src/object/robotmain.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f57220d..ff930cd 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3998,6 +3998,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { m_displayText->SetDelay(OpFloat(line, "factor", 1.0f)); } + + if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 3) + { + char filename[100]; + OpString(line, "filename", filename); + m_sound->CacheMusic(filename); + continue; + } if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2) { -- cgit v1.2.3-1-g7c22 From 56709f0e5630a2874ccd133d08604a99f6095157 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 10:58:38 +0200 Subject: Small changes to looping main menu music --- src/ui/maindialog.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 050f87a..0b0b848 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -742,6 +742,23 @@ pb->SetState(STATE_SHADOW); CameraPerso(); } + if ( m_phase != PHASE_SIMUL && + m_phase != PHASE_WIN && + m_phase != PHASE_LOST && + m_phase != PHASE_WRITE && + m_phase != PHASE_READs && + m_phase != PHASE_WRITEs && + m_phase != PHASE_SETUPds && + m_phase != PHASE_SETUPgs && + m_phase != PHASE_SETUPps && + m_phase != PHASE_SETUPcs && + m_phase != PHASE_SETUPss ) + { + if (!m_sound->IsPlayingMusic()) { + m_sound->PlayMusic("Intro1.ogg", false); + } + } + if ( m_phase == PHASE_TRAINER || m_phase == PHASE_DEFI || m_phase == PHASE_MISSION || @@ -750,10 +767,6 @@ pb->SetState(STATE_SHADOW); m_phase == PHASE_USER || m_phase == PHASE_PROTO ) { - if (!m_sound->IsPlayingMusic()) { - m_sound->PlayMusic("Intro1.ogg", false); - } - if ( m_phase == PHASE_TRAINER ) m_index = 0; if ( m_phase == PHASE_DEFI ) m_index = 1; if ( m_phase == PHASE_MISSION ) m_index = 2; @@ -1745,9 +1758,6 @@ pos.y -= 0.048f; if ( m_phase == PHASE_WELCOME1 ) { - m_sound->StopMusic(); - m_sound->PlayMusic("Intro1.ogg", false); - pos.x = 0.0f; pos.y = 0.0f; ddim.x = 0.0f; -- cgit v1.2.3-1-g7c22 From 166a6b44035f4b70a3edcc0dcaa04c8220e6e4ca Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 16:37:11 +0200 Subject: Improved music cache --- src/sound/oalsound/alsound.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index a37cced..ef8ff8d 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -169,17 +169,18 @@ bool ALSound::Cache(Sound sound, std::string filename) bool ALSound::CacheMusic(std::string filename) { - Buffer *buffer = new Buffer(); - std::stringstream file; - file << m_soundPath << "/" << filename; - if (buffer->LoadFromFile(file.str(), static_cast(-1))) { - mMusic[filename] = buffer; - return true; + if(mMusic.find(filename) == mMusic.end()) { + Buffer *buffer = new Buffer(); + std::stringstream file; + file << m_soundPath << "/" << filename; + if (buffer->LoadFromFile(file.str(), static_cast(-1))) { + mMusic[filename] = buffer; + return true; + } } return false; } - int ALSound::GetPriority(Sound sound) { if ( sound == SOUND_FLYh || -- cgit v1.2.3-1-g7c22 From 8a1e4b1e5f9a321aaa10b120881c52706c48c68a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 17:55:53 +0200 Subject: Added button for Destroyer Issue #142 --- src/common/event.h | 1 + src/common/restext.cpp | 1 + src/object/auto/autodestroyer.cpp | 161 ++++++++++++-------------------------- src/object/auto/autodestroyer.h | 2 +- 4 files changed, 52 insertions(+), 113 deletions(-) (limited to 'src') diff --git a/src/common/event.h b/src/common/event.h index 153b732..b9c6623 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -396,6 +396,7 @@ enum EventType EVENT_OBJECT_MPOWER = 1024, EVENT_OBJECT_BHELP = 1040, EVENT_OBJECT_BTAKEOFF = 1041, + EVENT_OBJECT_BDESTROY = 1042, EVENT_OBJECT_BDERRICK = 1050, EVENT_OBJECT_BSTATION = 1051, EVENT_OBJECT_BFACTORY = 1052, diff --git a/src/common/restext.cpp b/src/common/restext.cpp index b610d7f..7fdcdbd 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -295,6 +295,7 @@ void InitializeRestext() stringsEvent[EVENT_OBJECT_MPOWER] = "..power cell"; stringsEvent[EVENT_OBJECT_BHELP] = "Instructions for the mission (\\key help;)"; stringsEvent[EVENT_OBJECT_BTAKEOFF] = "Take off to finish the mission"; + stringsEvent[EVENT_OBJECT_BDESTROY] = "Destroy"; stringsEvent[EVENT_OBJECT_BDERRICK] = "Build a derrick"; stringsEvent[EVENT_OBJECT_BSTATION] = "Build a power station"; stringsEvent[EVENT_OBJECT_BFACTORY] = "Build a bot factory"; diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index b62a45a..2d64fb1 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -72,14 +72,35 @@ void CAutoDestroyer::Init() bool CAutoDestroyer::EventProcess(const Event &event) { - CObject* scrap; - Gfx::CPyro* pyro; + CObject* scrap; + Gfx::CPyro* pyro; Math::Vector pos, speed; Math::Point dim; + Ui::CWindow* pw; CAuto::EventProcess(event); if ( m_engine->GetPause() ) return true; + + if ( event.type == EVENT_OBJECT_BDESTROY ) + { + if ( m_object->GetVirusMode() ) // contaminated by a virus? + { + return true; // Don't do anything. TODO: Error? + } + + scrap = SearchPlastic(); + scrap->SetLock(true); // usable waste +//? scrap->SetTruck(m_object); // usable waste + + m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); + + m_phase = ADEP_DOWN; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + m_bExplo = false; + } + if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; @@ -98,55 +119,13 @@ bool CAutoDestroyer::EventProcess(const Event &event) { if ( m_progress >= 1.0f ) { + m_phase = ADEP_WAIT; // still waiting ... + m_progress = 0.0f; + m_speed = 1.0f/0.5f; scrap = SearchPlastic(); - if ( scrap == 0 ) - { - m_phase = ADEP_WAIT; // still waiting ... - m_progress = 0.0f; - m_speed = 1.0f/0.5f; - } - else - { - scrap->SetLock(true); // usable waste -//? scrap->SetTruck(m_object); // usable waste - - if ( SearchVehicle() ) - { - if ( m_progress < 20.0f ) { - m_phase = ADEP_WAIT; // still waiting ... - //m_progress = 0.0f; - m_speed = 1.0f/0.5f; - } else { - if ( m_object->GetLock() ) { // If still building... - m_phase = ADEP_WAIT; // still waiting ... - m_progress = 0.0f; - m_speed = 1.0f/0.5f; - } else { - m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); - - m_phase = ADEP_DOWN; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - m_bExplo = false; - } - } - } - else - { - if ( m_object->GetLock() ) { // If still building... - m_phase = ADEP_WAIT; // still waiting ... - m_progress = 0.0f; - m_speed = 1.0f/0.5f; - } else { - m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); - - m_phase = ADEP_DOWN; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - m_bExplo = false; - } - } - } + pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); + if ( pw == 0 ) return true; + EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); } } @@ -224,6 +203,7 @@ bool CAutoDestroyer::CreateInterface(bool bSelect) Ui::CWindow* pw; Math::Point pos, ddim; float ox, oy, sx, sy; + CObject* scrap; CAuto::CreateInterface(bSelect); @@ -243,6 +223,15 @@ bool CAutoDestroyer::CreateInterface(bool bSelect) ddim.y = 66.0f/480.0f; pw->CreateGroup(pos, ddim, 106, EVENT_OBJECT_TYPE); + pos.x = ox+sx*8.00f; + pos.y = oy+sy*0.25f; + ddim.x = (33.0f/640.0f)*1.5f; + ddim.y = (33.0f/480.0f)*1.5f; + pw->CreateButton(pos, ddim, 12, EVENT_OBJECT_BDESTROY); + + scrap = SearchPlastic(); + EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); + return true; } @@ -323,68 +312,6 @@ CObject* CAutoDestroyer::SearchPlastic() return nullptr; } -// Seeks if one vehicle is too close. - -bool CAutoDestroyer::SearchVehicle() -{ - CObject* pObj; - Math::Vector cPos, oPos; - ObjectType type; - float oRadius, dist; - int i; - - cPos = m_object->GetPosition(0); - - for ( i=0 ; i<1000000 ; i++ ) - { - pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); - if ( pObj == nullptr ) break; - - type = pObj->GetType(); - if ( type != OBJECT_HUMAN && - 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_MOTHER && - type != OBJECT_ANT && - type != OBJECT_SPIDER && - type != OBJECT_BEE && - type != OBJECT_WORM ) continue; - - if ( !pObj->GetCrashSphere(0, oPos, oRadius) ) continue; - dist = Math::Distance(oPos, cPos)-oRadius; - - if ( dist < 20.0f ) return true; - } - - return false; -} - - // Returns an error due the state of the automation. Error CAutoDestroyer::GetError() @@ -440,4 +367,14 @@ bool CAutoDestroyer::Read(char *line) return true; } +// Changes the state of a button interface. + +void CAutoDestroyer::EnableInterface(Ui::CWindow *pw, EventType event, bool bState) +{ + Ui::CControl* control; + + control = pw->SearchControl(event); + if ( control == 0 ) return; + control->SetState(Ui::STATE_ENABLE, bState); +} \ No newline at end of file diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h index 26981c3..4ab1118 100644 --- a/src/object/auto/autodestroyer.h +++ b/src/object/auto/autodestroyer.h @@ -53,7 +53,7 @@ public: protected: CObject* SearchPlastic(); - bool SearchVehicle(); + void EnableInterface(Ui::CWindow *pw, EventType event, bool bState); protected: AutoDestroyerPhase m_phase; -- cgit v1.2.3-1-g7c22 From 02b65fecd3e99df5ef4fcd953795d06b616bf035 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 18:07:20 +0200 Subject: Fixed Destroyer button * Commands were executed for all Destroyers on map * Button can't be clicked when Destroyer is working --- src/object/auto/autodestroyer.cpp | 38 +++++++++++++++++++++----------------- src/object/robotmain.h | 3 ++- 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index 2d64fb1..e33c317 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -82,23 +82,26 @@ bool CAutoDestroyer::EventProcess(const Event &event) if ( m_engine->GetPause() ) return true; - if ( event.type == EVENT_OBJECT_BDESTROY ) + if (m_main->GetSelect() == m_object) { - if ( m_object->GetVirusMode() ) // contaminated by a virus? + if ( event.type == EVENT_OBJECT_BDESTROY ) { - return true; // Don't do anything. TODO: Error? - } + if ( m_object->GetVirusMode() ) // contaminated by a virus? + { + return true; // Don't do anything. TODO: Error? + } - scrap = SearchPlastic(); - scrap->SetLock(true); // usable waste -//? scrap->SetTruck(m_object); // usable waste + scrap = SearchPlastic(); + scrap->SetLock(true); // usable waste +//? scrap->SetTruck(m_object); // usable waste - m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); + m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); - m_phase = ADEP_DOWN; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - m_bExplo = false; + m_phase = ADEP_DOWN; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + m_bExplo = false; + } } if ( event.type != EVENT_FRAME ) return true; @@ -115,6 +118,7 @@ bool CAutoDestroyer::EventProcess(const Event &event) return true; } + pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( m_phase == ADEP_WAIT ) { if ( m_progress >= 1.0f ) @@ -122,12 +126,12 @@ bool CAutoDestroyer::EventProcess(const Event &event) m_phase = ADEP_WAIT; // still waiting ... m_progress = 0.0f; m_speed = 1.0f/0.5f; - scrap = SearchPlastic(); - pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); - if ( pw == 0 ) return true; - EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); + if (m_main->GetSelect() == m_object) { + scrap = SearchPlastic(); + if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0)); + } } - } + } else if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, false); if ( m_phase == ADEP_DOWN ) { diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 6c331ab..adabf64 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -374,6 +374,8 @@ public: void SetNumericLocale(); void RestoreNumericLocale(); + CObject* GetSelect(); + protected: bool EventFrame(const Event &event); bool EventObject(const Event &event); @@ -404,7 +406,6 @@ protected: void DeleteAllObjects(); void UpdateInfoText(); CObject* SearchObject(ObjectType type); - CObject* GetSelect(); void StartDisplayVisit(EventType event); void FrameVisit(float rTime); void StopDisplayVisit(); -- cgit v1.2.3-1-g7c22 From 1250f889d95b8e710f80d374e6b23f02bd76f617 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 20:59:20 +0200 Subject: Improved MissionController movement a little bit --- src/object/motion/motiondummy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/object/motion/motiondummy.cpp b/src/object/motion/motiondummy.cpp index 5b35cc4..f25b81b 100644 --- a/src/object/motion/motiondummy.cpp +++ b/src/object/motion/motiondummy.cpp @@ -63,10 +63,10 @@ bool CMotionDummy::Create(Math::Vector pos, float angle, ObjectType type, m_physics->SetLinMotionX(MO_ADVACCEL, 20.0f); m_physics->SetLinMotionX(MO_RECACCEL, 20.0f); m_physics->SetLinMotionX(MO_STOACCEL, 20.0f); - m_physics->SetLinMotionX(MO_TERSLIDE, 5.0f); - m_physics->SetLinMotionZ(MO_TERSLIDE, 5.0f); - m_physics->SetLinMotionX(MO_TERFORCE, 50.0f); - m_physics->SetLinMotionZ(MO_TERFORCE, 50.0f); + m_physics->SetLinMotionX(MO_TERSLIDE, 0.0f); + m_physics->SetLinMotionZ(MO_TERSLIDE, 0.0f); + m_physics->SetLinMotionX(MO_TERFORCE, 0.0f); + m_physics->SetLinMotionZ(MO_TERFORCE, 0.0f); m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f); m_physics->SetLinMotionY(MO_ADVSPEED, 60.0f); m_physics->SetLinMotionY(MO_RECSPEED, 60.0f); -- cgit v1.2.3-1-g7c22 From f68581a3aef1aff0df0881248cf7440ede29a806 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 3 May 2013 12:26:26 +0200 Subject: Improved log levels of trace control --- src/object/object.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/object/object.cpp b/src/object/object.cpp index 3459644..5df4393 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -7325,7 +7325,7 @@ bool CObject::GetTraceDown() CMotionVehicle* mv = dynamic_cast(m_motion); if (mv == nullptr) { - GetLogger()->Debug("GetTraceDown() invalid m_motion class!\n"); + GetLogger()->Trace("GetTraceDown() invalid m_motion class!\n"); return false; } return mv->GetTraceDown(); @@ -7337,7 +7337,7 @@ void CObject::SetTraceDown(bool bDown) CMotionVehicle* mv = dynamic_cast(m_motion); if (mv == nullptr) { - GetLogger()->Debug("SetTraceDown() invalid m_motion class!\n"); + GetLogger()->Trace("SetTraceDown() invalid m_motion class!\n"); return; } mv->SetTraceDown(bDown); @@ -7349,7 +7349,7 @@ int CObject::GetTraceColor() CMotionVehicle* mv = dynamic_cast(m_motion); if (mv == nullptr) { - GetLogger()->Debug("GetTraceColor() invalid m_motion class!\n"); + GetLogger()->Trace("GetTraceColor() invalid m_motion class!\n"); return 0; } return mv->GetTraceColor(); @@ -7361,7 +7361,7 @@ void CObject::SetTraceColor(int color) CMotionVehicle* mv = dynamic_cast(m_motion); if (mv == nullptr) { - GetLogger()->Debug("SetTraceColor() invalid m_motion class!\n"); + GetLogger()->Trace("SetTraceColor() invalid m_motion class!\n"); return; } mv->SetTraceColor(color); @@ -7373,7 +7373,7 @@ float CObject::GetTraceWidth() CMotionVehicle* mv = dynamic_cast(m_motion); if (mv == nullptr) { - GetLogger()->Debug("GetTraceWidth() invalid m_motion class!\n"); + GetLogger()->Trace("GetTraceWidth() invalid m_motion class!\n"); return 0.0f; } return mv->GetTraceWidth(); @@ -7385,7 +7385,7 @@ void CObject::SetTraceWidth(float width) CMotionVehicle* mv = dynamic_cast(m_motion); if (mv == nullptr) { - GetLogger()->Debug("SetTraceWidth() invalid m_motion class!\n"); + GetLogger()->Trace("SetTraceWidth() invalid m_motion class!\n"); return; } mv->SetTraceWidth(width); -- cgit v1.2.3-1-g7c22 From 3c442d17dcc0d81a17a5ee8e25a5adc6f0b3d1bd Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 3 May 2013 21:12:39 +0200 Subject: Fix for issue #202 with 3D sound disabled --- src/sound/oalsound/alsound.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index ef8ff8d..dc2b64d 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -662,8 +662,12 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) } mChannels[channel]->SetVolumeAtrib(1.0f - ((dist - 10.0f) / 100.0f)); - a = fmodf(Angle(mLookat, mEye), Math::PI * 2.0f); - g = fmodf(Angle(pos, mEye), Math::PI * 2.0f); + 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; @@ -682,5 +686,5 @@ void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) } } - mChannels[channel]->SetPan( Math::Vector(sinf(g - a), 0.0f, 0.0f) ); + mChannels[channel]->SetPan( Math::Vector(0.0f, 0.0f, sinf(g - a)) ); } -- cgit v1.2.3-1-g7c22 From 5a31a936105a070856740b3e2431350d97214b1d Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 3 May 2013 21:33:19 +0200 Subject: Changed log level in profile.cpp to error --- src/common/profile.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/common/profile.cpp b/src/common/profile.cpp index f36baca..f165119 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -51,7 +51,7 @@ CProfile::~CProfile() } catch (std::exception & e) { - GetLogger()->Info("Error on storing profile: %s\n", e.what()); + GetLogger()->Error("Error on storing profile: %s\n", e.what()); } } } @@ -69,7 +69,7 @@ bool CProfile::InitCurrentDirectory() } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -86,7 +86,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std:: } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -101,7 +101,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std:: } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -117,7 +117,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -132,7 +132,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -148,7 +148,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -163,7 +163,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); return false; } return true; @@ -187,7 +187,7 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Error("Error on parsing profile: %s\n", e.what()); } return ret_list; -- cgit v1.2.3-1-g7c22 From 64ebda0ab958ccd7b9046d833db79ce366395717 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 3 May 2013 21:34:10 +0200 Subject: Added creating ini file with default values --- src/app/app.cpp | 66 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 6231eb6..2d2df2b 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -337,8 +337,22 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) bool CApplication::Create() { + std::string path; + bool defaultValues = false; + GetLogger()->Info("Creating CApplication\n"); + if (!GetProfile().InitCurrentDirectory()) + { + GetLogger()->Warn("Config not found. Default values will be used!\n"); + defaultValues = true; + } + else + { + if (GetProfile().GetLocalProfileString("Resources", "Data", path)) + m_dataPath = path; + } + boost::filesystem::path dataPath(m_dataPath); if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) ) { @@ -353,38 +367,30 @@ bool CApplication::Create() SetLanguage(m_language); //Create the sound instance. - if (!GetProfile().InitCurrentDirectory()) - { - GetLogger()->Warn("Config not found. Default values will be used!\n"); - m_sound = new CSoundInterface(); + #ifdef OPENAL_SOUND + m_sound = static_cast(new ALSound()); + #else + GetLogger()->Info("No sound support.\n"); + m_sound = new CSoundInterface(); + #endif + + m_sound->Create(true); + + // Cache sound files + if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) { + m_sound->CacheAll(path); + } else { + m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND)); } - else - { - std::string path; - if (GetProfile().GetLocalProfileString("Resources", "Data", path)) - m_dataPath = path; - - #ifdef OPENAL_SOUND - m_sound = static_cast(new ALSound()); - #else - GetLogger()->Info("No sound support.\n"); - m_sound = new CSoundInterface(); - #endif - - m_sound->Create(true); - if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) { - m_sound->CacheAll(path); - } else { - m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND)); - } - if (GetProfile().GetLocalProfileString("Resources", "Music", path)) { - m_sound->AddMusicFiles(path); - } else { - m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC)); - } + if (GetProfile().GetLocalProfileString("Resources", "Music", path)) { + m_sound->AddMusicFiles(path); + } else { + m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC)); } + GetLogger()->Info("CApplication created successfully\n"); + std::string standardInfoMessage = "\nPlease see the console output or log file\n" "to get more information on the source of error"; @@ -481,9 +487,9 @@ bool CApplication::Create() // Create the robot application. m_robotMain = new CRobotMain(this); - m_robotMain->ChangePhase(PHASE_WELCOME1); + if (defaultValues) m_robotMain->CreateIni(); - GetLogger()->Info("CApplication created successfully\n"); + m_robotMain->ChangePhase(PHASE_WELCOME1); return true; } -- cgit v1.2.3-1-g7c22 From 26c92d074dd88fb4b1409e71d2f7025d93c10d10 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 3 May 2013 21:39:02 +0200 Subject: Fixed "ptree is too deep" --- src/object/robotmain.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ff930cd..1ca9e82 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -710,10 +710,10 @@ CRobotMain::CRobotMain(CApplication* app) int iValue; if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; m_IOPublic = false; m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); @@ -721,10 +721,10 @@ CRobotMain::CRobotMain(CApplication* app) m_IOPos.y = (1.0f-m_IODim.y)/2.0f; if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IOPos.x", fValue)) m_IOPos.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IOPos.y", fValue)) m_IOPos.y = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IODim.x", fValue)) m_IODim.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IODim.y", fValue)) m_IODim.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.y = fValue; m_short->FlushShortcuts(); InitEye(); @@ -2243,8 +2243,8 @@ float CRobotMain::GetFontSize() void CRobotMain::SetWindowPos(Math::Point pos) { m_windowPos = pos; - GetProfile().SetLocalProfileFloat("Edit", "WindowPos.x", m_windowPos.x); - GetProfile().SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y); + GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x); + GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y); } Math::Point CRobotMain::GetWindowPos() @@ -2255,8 +2255,8 @@ Math::Point CRobotMain::GetWindowPos() void CRobotMain::SetWindowDim(Math::Point dim) { m_windowDim = dim; - GetProfile().SetLocalProfileFloat("Edit", "WindowDim.x", m_windowDim.x); - GetProfile().SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y); + GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x); + GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y); } Math::Point CRobotMain::GetWindowDim() @@ -2280,8 +2280,8 @@ bool CRobotMain::GetIOPublic() void CRobotMain::SetIOPos(Math::Point pos) { m_IOPos = pos; - GetProfile().SetLocalProfileFloat("Edit", "IOPos.x", m_IOPos.x); - GetProfile().SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y); + GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x); + GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y); } Math::Point CRobotMain::GetIOPos() @@ -2292,8 +2292,8 @@ Math::Point CRobotMain::GetIOPos() void CRobotMain::SetIODim(Math::Point dim) { m_IODim = dim; - GetProfile().SetLocalProfileFloat("Edit", "IODim.x", m_IODim.x); - GetProfile().SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y); + GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x); + GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y); } Math::Point CRobotMain::GetIODim() -- cgit v1.2.3-1-g7c22 From c3e95d40a2839fb8d00ff7b1c61aa513da0ebcea Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 3 May 2013 22:23:36 +0200 Subject: Added relative install paths for MXE build --- src/app/app.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 2d2df2b..79c00c9 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1636,7 +1636,7 @@ void CApplication::SetLanguage(Language language) } if (envLang == NULL) { - GetLogger()->Error("Failed to get language from environment, setting default language"); + GetLogger()->Error("Failed to get language from environment, setting default language\n"); m_language = LANGUAGE_ENGLISH; } else if (strncmp(envLang,"en",2) == 0) -- cgit v1.2.3-1-g7c22 From 6333d2d38e9801f67925cae194b07abcf8f1260e Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 4 May 2013 11:56:03 +0200 Subject: Removed most of "No such node" messages --- src/app/app.cpp | 9 ++++++++- src/common/profile.cpp | 37 +++++++++++++++++++++---------------- src/common/profile.h | 5 +++++ src/object/robotmain.cpp | 48 +++++++++++++++++++++++++++++++----------------- src/object/robotmain.h | 2 +- src/ui/maindialog.cpp | 3 +++ 6 files changed, 69 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 79c00c9..616caf9 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -364,6 +364,8 @@ bool CApplication::Create() return false; } + GetProfile().SetLocalProfileString("Resources", "Data", m_dataPath); + SetLanguage(m_language); //Create the sound instance. @@ -377,6 +379,11 @@ bool CApplication::Create() m_sound->Create(true); // Cache sound files + if (defaultValues) { + GetProfile().SetLocalProfileString("Resources", "Sound", GetDataSubdirPath(DIR_SOUND)); + GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC)); + } + if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) { m_sound->CacheAll(path); } else { @@ -485,7 +492,7 @@ bool CApplication::Create() m_modelManager = new Gfx::CModelManager(m_engine); // Create the robot application. - m_robotMain = new CRobotMain(this); + m_robotMain = new CRobotMain(this, !defaultValues); if (defaultValues) m_robotMain->CreateIni(); diff --git a/src/common/profile.cpp b/src/common/profile.cpp index f165119..0bc40cf 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -39,21 +39,7 @@ CProfile::CProfile() : CProfile::~CProfile() { - if (m_profileNeedSave) - { - try - { - #ifdef NDEBUG - bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); - #else - bp::ini_parser::write_ini("colobot.ini", m_propertyTree); - #endif - } - catch (std::exception & e) - { - GetLogger()->Error("Error on storing profile: %s\n", e.what()); - } - } + SaveCurrentDirectory(); } @@ -75,7 +61,26 @@ bool CProfile::InitCurrentDirectory() return true; } - +bool CProfile::SaveCurrentDirectory() +{ + if (m_profileNeedSave) + { + try + { + #ifdef NDEBUG + bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); + #else + bp::ini_parser::write_ini("colobot.ini", m_propertyTree); + #endif + } + catch (std::exception & e) + { + GetLogger()->Error("Error on storing profile: %s\n", e.what()); + return false; + } + } + return true; +} bool CProfile::SetLocalProfileString(std::string section, std::string key, std::string value) { diff --git a/src/common/profile.h b/src/common/profile.h index 7f99d81..ba797e9 100644 --- a/src/common/profile.h +++ b/src/common/profile.h @@ -50,6 +50,11 @@ class CProfile : public CSingleton */ 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 diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 1ca9e82..d291397 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -606,7 +606,7 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception) //! Constructor of robot application -CRobotMain::CRobotMain(CApplication* app) +CRobotMain::CRobotMain(CApplication* app, bool loadProfile) { m_app = app; @@ -709,22 +709,26 @@ CRobotMain::CRobotMain(CApplication* app) float fValue; int iValue; - 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; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; + 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; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; + } m_IOPublic = false; m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle m_IOPos.y = (1.0f-m_IODim.y)/2.0f; - if (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; - if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.y = fValue; + 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; + if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue; + if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.y = fValue; + } m_short->FlushShortcuts(); InitEye(); @@ -741,10 +745,10 @@ CRobotMain::CRobotMain(CApplication* app) g_unit = UNIT; m_gamerName = ""; - GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName); + if (loadProfile) GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName); SetGlobalGamerName(m_gamerName); ReadFreeParam(); - m_dialog->SetupRecall(); + if (loadProfile) m_dialog->SetupRecall(); for (int i = 0; i < MAXSHOWLIMIT; i++) { @@ -904,10 +908,20 @@ Ui::CDisplayText* CRobotMain::GetDisplayText() //! Creates the file colobot.ini at the first time void CRobotMain::CreateIni() { - int iValue; - // colobot.ini doesn't exist? - if (!GetProfile().GetLocalProfileInt("Setup", "TotoMode", iValue)) - m_dialog->SetupMemorize(); + m_dialog->SetupMemorize(); + + GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize); + GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x); + GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y); + GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x); + GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y); + GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic); + GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x); + GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y); + GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x); + GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y); + + GetProfile().SaveCurrentDirectory(); } void CRobotMain::SetDefaultInputBindings() diff --git a/src/object/robotmain.h b/src/object/robotmain.h index adabf64..a459a59 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -191,7 +191,7 @@ const int AXIS_INVALID = -1; class CRobotMain : public CSingleton { public: - CRobotMain(CApplication* app); + CRobotMain(CApplication* app, bool loadProfile); ~CRobotMain(); Gfx::CCamera* GetCamera(); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 0b0b848..1b87a04 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5509,6 +5509,7 @@ void CMainDialog::SetupMemorize() GetProfile().SetLocalProfileInt("Setup", "HimselfDamage", m_bHimselfDamage); GetProfile().SetLocalProfileInt("Setup", "CameraScroll", m_bCameraScroll); GetProfile().SetLocalProfileInt("Setup", "CameraInvertX", m_bCameraInvertX); + GetProfile().SetLocalProfileInt("Setup", "CameraInvertY", m_bCameraInvertY); GetProfile().SetLocalProfileInt("Setup", "InterfaceEffect", m_bEffect); GetProfile().SetLocalProfileInt("Setup", "GroundShadow", m_engine->GetShadow()); GetProfile().SetLocalProfileInt("Setup", "GroundSpot", m_engine->GetGroundSpot()); @@ -5544,6 +5545,8 @@ void CMainDialog::SetupMemorize() if ( pl != 0 ) { GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect()); } + } else { + // TODO: Default value } std::stringstream key; -- cgit v1.2.3-1-g7c22 From 9549359b4649efd4bd0b6f085d8277f6d12d0ecb Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 4 May 2013 20:12:15 +0200 Subject: Fix for saving wrong Fullscreen value --- src/ui/maindialog.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 1b87a04..2dede28 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -183,6 +183,8 @@ CMainDialog::CMainDialog() m_userDir = "user"; m_filesDir = "files"; + m_setupFull = m_app->GetVideoConfig().fullScreen; + m_bDialog = false; } -- cgit v1.2.3-1-g7c22 From 78e32cf894797fbbe865e67299800292597c92ae Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 5 May 2013 13:43:05 +0200 Subject: Changed MissionController version requirement 3->2 Also, adding it before BeginObject isn't wrong, and now recommended because it disables Audio and EndMissionTake commands --- src/object/robotmain.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index d291397..80ef8ce 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4013,7 +4013,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_displayText->SetDelay(OpFloat(line, "factor", 1.0f)); } - if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 3) + if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2) { char filename[100]; OpString(line, "filename", filename); @@ -4021,7 +4021,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2) + if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2 && m_controller == nullptr) { int i = m_audioChangeTotal; if (i < 10) @@ -4042,7 +4042,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if (Cmd(line, "Audio") && !resetObject) + if (Cmd(line, "Audio") && !resetObject && m_controller == nullptr) { if(m_version < 2) { int trackid = OpInt(line, "track", 0); @@ -4390,12 +4390,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_beginObject = true; } - if (Cmd(line, "MissionController") && read[0] == 0 && m_version == 3) + if (Cmd(line, "MissionController") && read[0] == 0 && m_version >= 2) { - if (!m_beginObject) { + /*if (!m_beginObject) { GetLogger()->Error("Syntax error in file '%s' (line %d): MissionController before BeginObject\n", filename, lineNum); continue; - } + }*/ m_controller = CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, 1.0f, 0.0f, OBJECT_CONTROLLER, 100.0f, false, false, 0); m_controller->SetMagnifyDamage(100.0f); @@ -4514,7 +4514,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) sel = obj; } - obj->SetSelectable(OpInt(line, "selectable", 1)); + bool selectable = OpInt(line, "selectable", 1); + obj->SetSelectable(selectable); obj->SetEnable(OpInt(line, "enable", 1)); obj->SetProxyActivate(OpInt(line, "proxyActivate", 0)); obj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit); @@ -4522,9 +4523,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) obj->SetShield(OpFloat(line, "shield", 1.0f)); obj->SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f)); obj->SetClip(OpInt(line, "clip", 1)); - obj->SetCheckToken(m_version >= 2 ? trainer : OpInt(line, "checkToken", 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)); } @@ -4730,7 +4731,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*Math::PI); } - if (Cmd(line, "EndMissionTake") && !resetObject && m_version<3) + if (Cmd(line, "EndMissionTake") && !resetObject && m_controller == nullptr) { int i = m_endTakeTotal; if (i < 10) @@ -4753,16 +4754,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_endTakeTotal ++; } } - if (Cmd(line, "EndMissionDelay") && !resetObject && m_version<3) + if (Cmd(line, "EndMissionDelay") && !resetObject && m_controller == nullptr) { m_endTakeWinDelay = OpFloat(line, "win", 2.0f); m_endTakeLostDelay = OpFloat(line, "lost", 2.0f); } - if (Cmd(line, "EndMissionResearch") && !resetObject && m_version<3) + if (Cmd(line, "EndMissionResearch") && !resetObject && m_controller == nullptr) { m_endTakeResearch |= OpResearch(line, "type"); } - if (Cmd(line, "EndMissionNever") && !resetObject && m_version == 2) + if (Cmd(line, "EndMissionNever") && !resetObject && m_controller == nullptr) { m_endTakeNever = true; } @@ -6748,7 +6749,7 @@ void CRobotMain::UpdateAudio(bool frame) void CRobotMain::SetEndMission(Error result, float delay) { - if (m_version >= 3) { + if (m_controller != nullptr) { m_endTakeWinDelay = delay; m_endTakeLostDelay = delay; m_missionResult = result; @@ -6758,7 +6759,7 @@ void CRobotMain::SetEndMission(Error result, float delay) //! Checks if the mission is over Error CRobotMain::CheckEndMission(bool frame) { - if (m_version >= 3) { + 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; @@ -7315,4 +7316,4 @@ void CRobotMain::RestoreNumericLocale() { setlocale(LC_NUMERIC, m_oldLocale.c_str()); } - \ No newline at end of file + -- cgit v1.2.3-1-g7c22 From fcb052cc8d1abb2e1872c9684bba225686f25b34 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 5 May 2013 14:44:51 +0200 Subject: Added [set/get][build/research[done/enable]] ( ); function fo CBot * setbuild ( ); * setresearchdone ( ); * setresearchenable ( ); * getbuild ( ); * getresearchdone ( ); * getresearchenable ( ); --- src/script/cbottoken.cpp | 16 ++++-- src/script/script.cpp | 129 ++++++++++++++++++++++++++++++++++------------- src/script/script.h | 7 ++- 3 files changed, 112 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 6eb6592..2ae2c72 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -249,6 +249,9 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "pow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt"); if ( strcmp(token, "rand" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt"); if ( strcmp(token, "abs" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt"); + if ( strcmp(token, "getbuild" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getbuild.txt"); + if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt"); + if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt"); if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt"); if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt"); if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt"); @@ -262,7 +265,6 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt"); if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt"); if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt"); - if ( strcmp(token, "buildinfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/buildinfo.txt"); if ( strcmp(token, "canbuild" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/canbuild.txt"); if ( strcmp(token, "build" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/build.txt"); if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt"); @@ -368,6 +370,9 @@ bool IsFunction(const char *token) if ( strcmp(token, "pow" ) == 0 ) return true; if ( strcmp(token, "rand" ) == 0 ) return true; if ( strcmp(token, "abs" ) == 0 ) return true; + if ( strcmp(token, "getbuild" ) == 0 ) return true; + if ( strcmp(token, "getresearchenable" ) == 0 ) return true; + if ( strcmp(token, "getresearchdone" ) == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; @@ -382,9 +387,8 @@ bool IsFunction(const char *token) if ( strcmp(token, "turn" ) == 0 ) return true; if ( strcmp(token, "goto" ) == 0 ) return true; if ( strcmp(token, "grab" ) == 0 ) return true; - if ( strcmp(token, "buildinfo" ) == 0 ) return true; - if ( strcmp(token, "canbuild" ) == 0 ) return true; - if ( strcmp(token, "build" ) == 0 ) return true; + if ( strcmp(token, "canbuild" ) == 0 ) return true; + if ( strcmp(token, "build" ) == 0 ) return true; if ( strcmp(token, "drop" ) == 0 ) return true; if ( strcmp(token, "sniff" ) == 0 ) return true; if ( strcmp(token, "receive" ) == 0 ) return true; @@ -453,6 +457,9 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "pow" ) == 0 ) return "pow ( x, y );"; if ( strcmp(token, "rand" ) == 0 ) return "rand ( );"; if ( strcmp(token, "abs" ) == 0 ) return "abs ( value );"; + if ( strcmp(token, "getbuild" ) == 0 ) return "getbuild ( );"; + if ( strcmp(token, "getresearchenable" ) == 0 ) return "getresearchenable ( );"; + if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; @@ -467,7 +474,6 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "turn" ) == 0 ) return "turn ( angle );"; if ( strcmp(token, "goto" ) == 0 ) return "goto ( position, altitude );"; if ( strcmp(token, "grab" ) == 0 ) return "grab ( order );"; - if ( strcmp(token, "buildinfo" ) == 0 ) return "buildinfo ( category );"; if ( strcmp(token, "canbuild" ) == 0 ) return "canbuild ( category );"; if ( strcmp(token, "build" ) == 0 ) return "build ( category );"; if ( strcmp(token, "drop" ) == 0 ) return "drop ( order );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index d108c7a..9537630 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -386,6 +386,56 @@ bool CScript::rStopMusic(CBotVar* var, CBotVar* result, int& exception, void* us return true; } +// Instruction "getbuild()" + +bool CScript::rGetBuild(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + result->SetValInt(g_build); + return true; +} + +// Instruction "getresearchenable()" + +bool CScript::rGetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + result->SetValInt(g_researchEnable); + return true; +} + +// Instruction "getresearchdone()" + +bool CScript::rGetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + result->SetValInt(g_researchDone); + return true; +} + +// Instruction "setbuild()" + +bool CScript::rSetBuild(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + g_build = var->GetValInt(); + CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_UPDINTERFACE)); + return true; +} + +// Instruction "setresearchenable()" + +bool CScript::rSetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + g_researchEnable = var->GetValInt(); + CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_UPDINTERFACE)); + return true; +} + +// Instruction "setresearchdone()" + +bool CScript::rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + g_researchDone = var->GetValInt(); + CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_UPDINTERFACE)); + return true; +} // Compilation of the instruction "retobject(rank)". @@ -1093,32 +1143,11 @@ CBotTypResult CScript::cCanBuild(CBotVar* &var, void* user) // returns true if this building can be built bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user) -{ - exception = 0; - - CScript::rBuildInfo(var, result, exception, user); - Error err = static_cast(result->GetValInt()); - - if (err == ERR_OK) - result->SetValInt(true); - else - result->SetValInt(false); - - return true; -} - -// Instruction "buildinfo ( category );" -// This function indicates if this building can be built, and returns a specific value -// -// returns 0(ERR_OK) if this building can be built -// returns 132(ERR_BUILD_DISABLED) if can not build in a current mission -// returns 133(ERR_BUILD_RESEARCH) if this building needs to be researched - -bool CScript::rBuildInfo(CBotVar* var, CBotVar* result, int& exception, void* user) { ObjectType category = static_cast(var->GetValInt()); //get category parameter exception = 0; - int value = ERR_BUILD_DISABLED; + + bool can = false; if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) || (category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) || @@ -1136,20 +1165,22 @@ bool CScript::rBuildInfo(CBotVar* var, CBotVar* result, int& exception, void* us { //if we want to build not researched one - if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || + if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) ) { - value = ERR_BUILD_RESEARCH; + can = false; } else { - value = ERR_OK; + can = true; } } - result->SetValInt(value); + result->SetValInt(can); + + return true; } @@ -1162,7 +1193,7 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user) CObject* pThis = static_cast(user); ObjectType oType; ObjectType category; - Error err; + Error err = ERR_BUILD_DISABLED; exception = 0; @@ -1177,14 +1208,38 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user) } else { - //Let's check is building this object is possible - CScript::rBuildInfo(var, result, exception, user); - err = static_cast(result->GetValInt()); + category = static_cast(var->GetValInt()); //get category parameter + if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) || + (category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) || + (category == OBJECT_STATION && (g_build & BUILD_STATION)) || + (category == OBJECT_CONVERT && (g_build & BUILD_CONVERT)) || + (category == OBJECT_REPAIR && (g_build & BUILD_REPAIR)) || + (category == OBJECT_TOWER && (g_build & BUILD_TOWER)) || + (category == OBJECT_RESEARCH && (g_build & BUILD_RESEARCH)) || + (category == OBJECT_RADAR && (g_build & BUILD_RADAR)) || + (category == OBJECT_ENERGY && (g_build & BUILD_ENERGY)) || + (category == OBJECT_LABO && (g_build & BUILD_LABO)) || + (category == OBJECT_NUCLEAR && (g_build & BUILD_NUCLEAR)) || + (category == OBJECT_INFO && (g_build & BUILD_INFO )) || + (category == OBJECT_PARA && (g_build & BUILD_PARA ))) + { + + //if we want to build not researched one + if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || + (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) + ) + { + err = ERR_BUILD_RESEARCH; + } + else + { + err = ERR_OK; + } + + } if (err == ERR_OK && script->m_primaryTask == 0) //if we can build and no task is present { - category = static_cast(var->GetValInt()); //get category parameter - script->m_primaryTask = new CTaskManager(script->m_object); err = script->m_primaryTask->StartTaskBuild(category); @@ -3029,6 +3084,13 @@ void CScript::InitFonctions() CBotProgram::AddFunction("playmusic", rPlayMusic ,CScript::cPlayMusic); CBotProgram::AddFunction("stopmusic", rStopMusic ,CScript::cNull); + CBotProgram::AddFunction("getbuild", rGetBuild, CScript::cNull); + CBotProgram::AddFunction("getresearchenable", rGetResearchEnable, CScript::cNull); + CBotProgram::AddFunction("getresearchdone", rGetResearchDone, CScript::cNull); + CBotProgram::AddFunction("setbuild", rSetBuild, CScript::cOneFloat); + CBotProgram::AddFunction("setresearchenable", rSetResearchEnable, CScript::cOneFloat); + CBotProgram::AddFunction("setresearchdone", rSetResearchDone, CScript::cOneFloat); + CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy); CBotProgram::AddFunction("search", rSearch, CScript::cSearch); @@ -3071,7 +3133,6 @@ void CScript::InitFonctions() CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat); CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat); - CBotProgram::AddFunction("buildinfo", rBuildInfo, CScript::cOneFloat); CBotProgram::AddFunction("canbuild", rCanBuild, CScript::cCanBuild); CBotProgram::AddFunction("build", rBuild, CScript::cOneFloat); diff --git a/src/script/script.h b/src/script/script.h index 535b974..f0907f3 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -139,13 +139,18 @@ private: static bool rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rPlayMusic(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rStopMusic(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rGetBuild(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rGetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rGetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rSetBuild(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rSetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user); - static bool rBuildInfo(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rBuild(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From dbcc2c61f9ba2269e273f984473eb0fddeeb8311 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 5 May 2013 20:10:36 +0200 Subject: Added Build and Research constants --- src/object/robotmain.cpp | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 80ef8ce..75cd9f6 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -807,15 +807,47 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) CBotProgram::DefineNum("FilterOnlyLanding", FILTER_ONLYLANDING); CBotProgram::DefineNum("FilterOnlyFliying", FILTER_ONLYFLYING); - CBotProgram::DefineNum("ExploNone", 0); - CBotProgram::DefineNum("ExploBoum", EXPLO_BOUM); - CBotProgram::DefineNum("ExploBurn", EXPLO_BURN); + CBotProgram::DefineNum("ExploNone", 0); + CBotProgram::DefineNum("ExploBoum", EXPLO_BOUM); + CBotProgram::DefineNum("ExploBurn", EXPLO_BURN); CBotProgram::DefineNum("ExploWater", EXPLO_WATER); - CBotProgram::DefineNum("ResultNotEnded", ERR_MISSION_NOTERM); - CBotProgram::DefineNum("ResultLost", INFO_LOST); + CBotProgram::DefineNum("ResultNotEnded", ERR_MISSION_NOTERM); + CBotProgram::DefineNum("ResultLost", INFO_LOST); CBotProgram::DefineNum("ResultLostQuick", INFO_LOSTq); - CBotProgram::DefineNum("ResultWin", ERR_OK); + CBotProgram::DefineNum("ResultWin", ERR_OK); + + CBotProgram::DefineNum("BuildBotFactory", BUILD_FACTORY); + CBotProgram::DefineNum("BuildDerrick", BUILD_DERRICK); + CBotProgram::DefineNum("BuildConverter", BUILD_CONVERT); + CBotProgram::DefineNum("BuildRadarStation", BUILD_RADAR); + CBotProgram::DefineNum("BuildPowerPlant", BUILD_ENERGY); + CBotProgram::DefineNum("BuildNuclearPlant", BUILD_NUCLEAR); + CBotProgram::DefineNum("BuildPowerStation", BUILD_STATION); + CBotProgram::DefineNum("BuildRepairCenter", BUILD_REPAIR); + CBotProgram::DefineNum("BuildDefenseTower", BUILD_TOWER); + CBotProgram::DefineNum("BuildResearchCenter", BUILD_RESEARCH); + CBotProgram::DefineNum("BuildAutoLab", BUILD_LABO); + CBotProgram::DefineNum("BuildPowerCaptor", BUILD_PARA); + CBotProgram::DefineNum("BuildExchangePost", BUILD_INFO); + CBotProgram::DefineNum("BuildDestroyer", BUILD_DESTROYER); + CBotProgram::DefineNum("FlatGround", BUILD_GFLAT); + CBotProgram::DefineNum("UseFlags", BUILD_FLAG); + CBotProgram::DefineNum("ResearchTracked", RESEARCH_TANK); + CBotProgram::DefineNum("ResearchWinged", RESEARCH_FLY); + CBotProgram::DefineNum("ResearchShooter", RESEARCH_CANON); + CBotProgram::DefineNum("ResearchDefenseTower", RESEARCH_TOWER); + CBotProgram::DefineNum("ResearchNuclearPlant", RESEARCH_ATOMIC); + CBotProgram::DefineNum("ResearchThumper", RESEARCH_THUMP); + CBotProgram::DefineNum("ResearchShielder", RESEARCH_SHIELD); + CBotProgram::DefineNum("ResearchPhazerShooter", RESEARCH_PHAZER); + CBotProgram::DefineNum("ResearchLegged", RESEARCH_iPAW); + CBotProgram::DefineNum("ResearchOrgaShooter", RESEARCH_iGUN); + CBotProgram::DefineNum("ResearchRecycler", RESEARCH_RECYCLER); + CBotProgram::DefineNum("ResearchSubber", RESEARCH_SUBM); + CBotProgram::DefineNum("ResearchSniffer", RESEARCH_SNIFFER); + + CBotProgram:: CBotProgram::DefineNum("PolskiPortalColobota", 1337); -- cgit v1.2.3-1-g7c22 From 4dcee0a4d17cfe3b263a86c1b21d1a2bbf1eebca Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 5 May 2013 20:33:49 +0200 Subject: Added continue at end of every Cmd() check As mentioned in issue #173 --- src/object/robotmain.cpp | 107 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 75cd9f6..5791826 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3965,6 +3965,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) SetNumericLocale(); + /* + * NOTE: Moving frequently used lines to the top + * may speed up loading + */ + while (fgets(line, 500, file) != NULL) { lineNum++; @@ -3983,19 +3988,27 @@ 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; + } - if (Cmd(line, "ScriptFile") && !resetObject) + if (Cmd(line, "ScriptFile") && !resetObject) { OpString(line, "name", m_scriptFile); + continue; + } if (Cmd(line, "Instructions") && !resetObject) { @@ -4005,6 +4018,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_immediatSatCom = OpInt(line, "immediat", 0); if(m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0); + continue; } if (Cmd(line, "Satellite") && !resetObject) @@ -4012,6 +4026,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "name", name); std::string path = m_app->GetDataFilePath(DIR_HELP, name); strcpy(m_infoFilename[SATCOM_SAT], path.c_str()); + continue; } if (Cmd(line, "Loading") && !resetObject) @@ -4019,6 +4034,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "name", name); std::string path = m_app->GetDataFilePath(DIR_HELP, name); strcpy(m_infoFilename[SATCOM_LOADING], path.c_str()); + continue; } if (Cmd(line, "HelpFile") && !resetObject) @@ -4026,23 +4042,27 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "name", name); std::string path = m_app->GetDataFilePath(DIR_HELP, name); strcpy(m_infoFilename[SATCOM_PROG], path.c_str()); + continue; } if (Cmd(line, "SoluceFile") && !resetObject) { OpString(line, "name", name); std::string path = m_app->GetDataFilePath(DIR_HELP, name); strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str()); + continue; } if (Cmd(line, "EndingFile") && !resetObject) { m_endingWinRank = OpInt(line, "win", 0); m_endingLostRank = OpInt(line, "lost", 0); + continue; } if (Cmd(line, "MessageDelay") && !resetObject) { m_displayText->SetDelay(OpFloat(line, "factor", 1.0f)); + continue; } if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2) @@ -4090,43 +4110,56 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } m_audioRepeat = OpInt(line, "repeat", 1); if(m_audioTrack != "") m_sound->CacheMusic(m_audioTrack); + continue; } if (Cmd(line, "AmbientColor") && !resetObject) { m_engine->SetAmbientColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); m_engine->SetAmbientColor(OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1); + continue; } if (Cmd(line, "FogColor") && !resetObject) { m_engine->SetFogColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); m_engine->SetFogColor(OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1); + 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; + } if (Cmd(line, "DeepView") && !resetObject) { m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*g_unit, 0, true); m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*g_unit, 1, true); + continue; } if (Cmd(line, "FogStart") && !resetObject) { m_engine->SetFogStart(OpFloat(line, "air", 0.5f), 0); m_engine->SetFogStart(OpFloat(line, "water", 0.5f), 1); + continue; } - if (Cmd(line, "SecondTexture") && !resetObject) + if (Cmd(line, "SecondTexture") && !resetObject) { m_engine->SetSecondTexture(OpInt(line, "rank", 1)); + continue; + } if (Cmd(line, "Background") && !resetObject) { @@ -4137,6 +4170,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpColor(line, "cloudUp", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), OpColor(line, "cloudDown", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), OpInt(line, "full", 0)); + continue; } if (Cmd(line, "Planet") && !resetObject) @@ -4157,12 +4191,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) Math::Point(uv2.x, uv2.z), strstr(name, "planet") != nullptr // TODO: add transparent op or modify textures ); + continue; } if (Cmd(line, "ForegroundName") && !resetObject) { OpString(line, "image", name); m_engine->SetForegroundName(name); + continue; } if (((m_version == 1 && Cmd(line, "Global")) || (m_version >= 2 && Cmd(line, "Mission"))) && !resetObject) @@ -4174,6 +4210,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_retroStyle = OpInt(line, "retro", 0); if(m_retroStyle) GetLogger()->Info("Retro mode enabled.\n"); } + continue; } if (Cmd(line, "TerrainGenerate") && !resetObject) @@ -4196,6 +4233,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpFloat(line, "hard", 0.5f)); m_terrainGenerate = true; + continue; } if (Cmd(line, "TerrainWind") && !resetObject) { @@ -4215,6 +4253,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } m_terrain->SetWind(OpPos(line, "speed")); + continue; } if (Cmd(line, "TerrainRelief") && !resetObject) @@ -4236,6 +4275,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "image", name); m_terrain->LoadRelief(name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1)); + continue; } if (Cmd(line, "TerrainResource") && !resetObject) @@ -4257,6 +4297,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "image", name); m_terrain->LoadResources(name); + continue; } if (Cmd(line, "TerrainWater") && !resetObject) @@ -4276,10 +4317,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) pos); m_colorNewWater = OpColor(line, "color", m_colorRefWater); m_colorShiftWater = OpFloat(line, "brightness", 0.0f); + continue; } - if (Cmd(line, "TerrainLava") && !resetObject) + if (Cmd(line, "TerrainLava") && !resetObject) { m_water->SetLava(OpInt(line, "mode", 0)); + continue; + } if (Cmd(line, "TerrainCloud") && !resetObject) { @@ -4288,6 +4332,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpFloat(line, "level", 500.0f) * g_unit); + continue; } if (Cmd(line, "TerrainBlitz") && !resetObject) @@ -4295,6 +4340,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_lightning->Create(OpFloat(line, "sleep", 0.0f), OpFloat(line, "delay", 3.0f), OpFloat(line, "magnetic", 50.0f) * g_unit); + continue; } if (Cmd(line, "TerrainInitTextures") && !resetObject) @@ -4330,6 +4376,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_terrain->InitMaterials(OpInt(line, "id", 1)); m_terrainInit = true; + continue; } if (Cmd(line, "TerrainMaterial") && !resetObject) @@ -4364,6 +4411,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpInt(line, "down", 1), OpInt(line, "left", 1), OpFloat(line, "hard", 0.5f)); + continue; } if (Cmd(line, "TerrainLevel") && !resetObject) @@ -4404,11 +4452,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpFloat(line, "freq", 100.0f), OpPos(line, "center")*g_unit, OpFloat(line, "radius", 0.0f)*g_unit); + continue; } if (Cmd(line, "TerrainCreate") && !resetObject) { m_terrain->CreateObjects(); m_terrainCreate = true; + continue; } if (Cmd(line, "BeginObject")) @@ -4420,6 +4470,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) sel = IOReadScene(read, stack); m_beginObject = true; + continue; } if (Cmd(line, "MissionController") && read[0] == 0 && m_version >= 2) @@ -4439,6 +4490,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) brain->SetScriptName(0, name); brain->SetScriptRun(0); } + continue; } if (Cmd(line, "CreateObject") && read[0] == 0) @@ -4638,6 +4690,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } rankObj ++; + continue; } if (Cmd(line, "CreateFog") && !resetObject) @@ -4653,6 +4706,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) dim.x = ddim; dim.y = dim.x; m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f); + continue; } if (Cmd(line, "CreateLight") && !resetObject) @@ -4674,6 +4728,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (type == Gfx::ENG_OBJTYPE_FIX) m_lightMan->SetLightExcludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN); + + continue; } if (Cmd(line, "CreateSpot") && !resetObject) { @@ -4694,6 +4750,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (type == Gfx::ENG_OBJTYPE_FIX) m_lightMan->SetLightExcludeType(rankLight, Gfx::ENG_OBJTYPE_TERRAIN); + + continue; } if (Cmd(line, "GroundSpot") && !resetObject) @@ -4708,10 +4766,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_engine->SetObjectGroundSpotMinMax(rank, OpFloat(line, "min", 0.0f)*g_unit, OpFloat(line, "max", 0.0f)*g_unit); } + 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; + } if (Cmd(line, "MapColor") && !resetObject) { @@ -4732,23 +4793,29 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpInt(line, "mode", 0), OpInt(line, "debug", 0)); } + continue; } + if (Cmd(line, "MapZoom") && !resetObject) { m_map->ZoomMap(OpFloat(line, "factor", 2.0f)); m_map->MapEnable(OpInt(line, "enable", 1)); + continue; } if (Cmd(line, "MaxFlyingHeight") && !resetObject) { m_terrain->SetFlyingMaxHeight(OpFloat(line, "max", 280.0f)*g_unit); + continue; } + if (Cmd(line, "AddFlyingHeight") && !resetObject) { m_terrain->AddFlyingLimit(OpPos(line, "center")*g_unit, OpFloat(line, "extRadius", 20.0f)*g_unit, OpFloat(line, "intRadius", 10.0f)*g_unit, OpFloat(line, "maxHeight", 200.0f)); + continue; } if (Cmd(line, "Camera")) @@ -4761,6 +4828,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_camera->StartOver(Gfx::CAM_OVER_EFFECT_FADEIN_WHITE, Math::Vector(0.0f, 0.0f, 0.0f), 1.0f); m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*Math::PI); + continue; } if (Cmd(line, "EndMissionTake") && !resetObject && m_controller == nullptr) @@ -4785,19 +4853,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "message", m_endTake[i].message); m_endTakeTotal ++; } + continue; } if (Cmd(line, "EndMissionDelay") && !resetObject && m_controller == nullptr) { m_endTakeWinDelay = OpFloat(line, "win", 2.0f); m_endTakeLostDelay = OpFloat(line, "lost", 2.0f); + continue; } if (Cmd(line, "EndMissionResearch") && !resetObject && m_controller == nullptr) { m_endTakeResearch |= OpResearch(line, "type"); + continue; } if (Cmd(line, "EndMissionNever") && !resetObject && m_controller == nullptr) { m_endTakeNever = true; + continue; } if (Cmd(line, "ObligatoryToken") && !resetObject) @@ -4808,6 +4880,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "text", m_obligatoryToken[i]); m_obligatoryTotal ++; } + continue; } if (Cmd(line, "ProhibitedToken") && !resetObject) @@ -4818,21 +4891,29 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) OpString(line, "text", m_prohibitedToken[i]); m_prohibitedTotal ++; } + 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; + } if (Cmd(line, "NewScript") && !resetObject) { OpString(line, "name", name); AddNewScriptName(OpTypeObject(line, "type", OBJECT_NULL), name); + continue; } } -- cgit v1.2.3-1-g7c22 From 40954038abfbba7d1c5986c93f5d88f0e3da11ec Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 5 May 2013 20:51:08 +0200 Subject: Added error message for undefined command --- src/object/robotmain.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 5791826..3715424 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4005,6 +4005,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } + if (Cmd(line, "Title")) continue; // Ignore + if (Cmd(line, "Resume")) continue; // Ignore + if (Cmd(line, "ScriptName")) continue; // Ignore + if (Cmd(line, "ScriptFile") && !resetObject) { OpString(line, "name", m_scriptFile); continue; @@ -4915,6 +4919,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) AddNewScriptName(OpTypeObject(line, "type", OBJECT_NULL), name); continue; } + + if (line[0] == '\n') 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 } fclose(file); -- cgit v1.2.3-1-g7c22 From cc8ed2979b14449f2dcf2b85daa7f13612d1dd00 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 11 May 2013 19:04:43 +0200 Subject: Fixed deleting of CObjectManager * fix in CApplication destructor * re-enabled unit tests --- src/app/app.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 616caf9..190f667 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -170,6 +170,9 @@ CApplication::~CApplication() delete m_private; m_private = nullptr; + delete m_objMan; + m_objMan = nullptr; + delete m_eventQueue; m_eventQueue = nullptr; -- cgit v1.2.3-1-g7c22 From f7f6e10c704585c4652fda359dc225fbb95b6075 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 11 May 2013 21:40:09 +0200 Subject: Added check and warning about non-power-of-2 textures --- src/graphics/opengl/gldevice.cpp | 6 +++++- src/math/func.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index df64e34..86f92b2 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -417,12 +417,16 @@ bool CGLDevice::GetLightEnabled(int index) Texture CGLDevice::CreateTexture(CImage *image, const TextureCreateParams ¶ms) { ImageData *data = image->GetData(); - if (data == NULL) + if (data == nullptr) { GetLogger()->Error("Invalid texture data\n"); return Texture(); // invalid texture } + Math::IntPoint size = image->GetSize(); + if (!Math::IsPowerOfTwo(size.x) || !Math::IsPowerOfTwo(size.y)) + GetLogger()->Warn("Creating non-power-of-2 texture (%dx%d)!\n", size.x, size.y); + return CreateTexture(data, params); } diff --git a/src/math/func.h b/src/math/func.h index 413b5d9..83e8ca4 100644 --- a/src/math/func.h +++ b/src/math/func.h @@ -128,6 +128,12 @@ inline float Rand() return static_cast(rand()) / static_cast(RAND_MAX); } +//! Returns whether \a x is an even power of 2 +inline bool IsPowerOfTwo(unsigned int x) +{ + return x && !(x & (x - 1)); +} + //! Returns the next nearest power of two to \a x inline int NextPowerOfTwo(int x) { -- cgit v1.2.3-1-g7c22 From dcf4c8941f3d0d287f0068ef64949890edeefa95 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 11 May 2013 23:07:31 +0200 Subject: Corrected print --- src/object/robotmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 3715424..981c1ed 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4923,7 +4923,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line[0] == '\n') 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 + GetLogger()->Error("Syntax error in file '%s' (line %d): Unknown command: %s\n", filename, lineNum, line); // Don't add \n at the end of log message - it's included in line variable } fclose(file); -- cgit v1.2.3-1-g7c22 From cec406ea31c3ccb22ab676ce3fd52d4cd0dfcb0d Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 11 May 2013 23:05:20 +0200 Subject: Non-power-of-2 padding for background images * added padding options * removed old hardcoded image sizes --- src/common/image.cpp | 29 +++++++++++++++++++++++++++++ src/common/image.h | 3 +++ src/graphics/core/texture.h | 5 +++++ src/graphics/engine/engine.cpp | 29 ++++++++++++++++++----------- src/graphics/engine/engine.h | 5 ++--- src/graphics/opengl/gldevice.cpp | 17 +++++++++++++---- src/object/auto/autobase.cpp | 3 +-- src/ui/maindialog.cpp | 20 ++++++++++---------- 8 files changed, 81 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/common/image.cpp b/src/common/image.cpp index db14797..fd55217 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -17,6 +17,8 @@ #include "common/image.h" +#include "math/func.h" + #include #include #include @@ -199,6 +201,33 @@ void CImage::Fill(Gfx::IntColor color) SDL_FillRect(m_data->surface, nullptr, c); } +/** + * Image must be valid. + * + * The dimensions are increased to nearest even power of two values. + * If image is already in power-of-two format, nothing is done. + */ +void CImage::PadToNearestPowerOfTwo() +{ + assert(m_data != nullptr); + + if (Math::IsPowerOfTwo(m_data->surface->w) && Math::IsPowerOfTwo(m_data->surface->h)) + return; + + int w = Math::NextPowerOfTwo(m_data->surface->w); + int h = Math::NextPowerOfTwo(m_data->surface->h); + + m_data->surface->flags &= (~SDL_SRCALPHA); + SDL_Surface* resizedSurface = SDL_CreateRGBSurface(0, w, h, 32, 0x00ff0000, 0x0000ff00, + 0x000000ff, 0xff000000); + assert(resizedSurface != NULL); + SDL_BlitSurface(m_data->surface, NULL, resizedSurface, NULL); + + SDL_FreeSurface(m_data->surface); + + m_data->surface = resizedSurface; +} + /** * Image must be valid and pixel coords in valid range. * diff --git a/src/common/image.h b/src/common/image.h index d9da75b..f0b50a3 100644 --- a/src/common/image.h +++ b/src/common/image.h @@ -94,6 +94,9 @@ public: //! Returns the precise color at given pixel Gfx::IntColor GetPixelInt(Math::IntPoint pixel); + //! Pads the image to nearest power of 2 dimensions + void PadToNearestPowerOfTwo(); + //! Loads an image from the specified file bool Load(const std::string &fileName); diff --git a/src/graphics/core/texture.h b/src/graphics/core/texture.h index 49b29f8..31e3774 100644 --- a/src/graphics/core/texture.h +++ b/src/graphics/core/texture.h @@ -136,6 +136,8 @@ struct TextureCreateParams TexMinFilter minFilter; //! Magnification filter TexMagFilter magFilter; + //! Pad the image to nearest power of 2 dimensions + bool padToNearestPowerOfTwo; //! Constructor; calls LoadDefault() TextureCreateParams() @@ -146,6 +148,7 @@ struct TextureCreateParams { format = TEX_IMG_RGB; mipmap = false; + padToNearestPowerOfTwo = false; minFilter = TEX_MIN_FILTER_NEAREST; magFilter = TEX_MAG_FILTER_NEAREST; @@ -212,6 +215,8 @@ struct Texture unsigned int id; //! Size of texture Math::IntPoint size; + //! Original size of texture (as loaded from image) + Math::IntPoint originalSize; //! Whether the texture has alpha channel bool alpha; diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 5d77e29..806cb5f 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -94,7 +94,6 @@ CEngine::CEngine(CApplication *app) m_backgroundCloudUp = Color(); m_backgroundCloudDown = Color(); m_backgroundFull = false; - m_backgroundScale = Math::Point(1.0f, 1.0f); m_overFront = true; m_overColor = Color(); m_overMode = ENG_RSTATE_TCOLOR_BLACK; @@ -2188,7 +2187,11 @@ bool CEngine::LoadAllTextures() LoadTexture("map.png"); if (! m_backgroundName.empty()) - m_backgroundTex = LoadTexture(m_backgroundName); + { + TextureCreateParams params = m_defaultTexParams; + params.padToNearestPowerOfTwo = true; + m_backgroundTex = LoadTexture(m_backgroundName, params); + } else m_backgroundTex.SetInvalid(); @@ -2609,8 +2612,7 @@ float CEngine::GetFogStart(int rank) } void CEngine::SetBackground(const std::string& name, Color up, Color down, - Color cloudUp, Color cloudDown, - bool full, Math::Point scale) + Color cloudUp, Color cloudDown, bool full) { if (m_backgroundTex.Valid()) { @@ -2624,15 +2626,17 @@ void CEngine::SetBackground(const std::string& name, Color up, Color down, m_backgroundCloudUp = cloudUp; m_backgroundCloudDown = cloudDown; m_backgroundFull = full; - m_backgroundScale = scale; if (! m_backgroundName.empty()) - m_backgroundTex = LoadTexture(m_backgroundName); + { + TextureCreateParams params = m_defaultTexParams; + params.padToNearestPowerOfTwo = true; + m_backgroundTex = LoadTexture(m_backgroundName, params); + } } void CEngine::GetBackground(std::string& name, Color& up, Color& down, - Color& cloudUp, Color& cloudDown, - bool &full, Math::Point& scale) + Color& cloudUp, Color& cloudDown, bool &full) { name = m_backgroundName; up = m_backgroundColorUp; @@ -2640,7 +2644,6 @@ void CEngine::GetBackground(std::string& name, Color& up, Color& down, cloudUp = m_backgroundCloudUp; cloudDown = m_backgroundCloudDown; full = m_backgroundFull; - scale = m_backgroundScale; } void CEngine::SetForegroundName(const std::string& name) @@ -3900,8 +3903,12 @@ void CEngine::DrawBackgroundImage() v2 = v1+h; } - u2 *= m_backgroundScale.x; - v2 *= m_backgroundScale.y; + Math::Point backgroundScale; + backgroundScale.x = static_cast(m_backgroundTex.originalSize.x) / static_cast(m_backgroundTex.size.x); + backgroundScale.y = static_cast(m_backgroundTex.originalSize.y) / static_cast(m_backgroundTex.size.y); + + u2 *= backgroundScale.x; + v2 *= backgroundScale.y; SetTexture(m_backgroundTex); SetState(ENG_RSTATE_OPAQUE_TEXTURE | ENG_RSTATE_WRAP); diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 671924f..16fb4e6 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -1050,10 +1050,10 @@ public: //! Management of the background image to use void SetBackground(const std::string& name, Color up = Color(), Color down = Color(), Color cloudUp = Color(), Color cloudDown = Color(), - bool full = false, Math::Point scale = Math::Point(1.0f, 1.0f)); + bool full = false); void GetBackground(std::string& name, Color& up, Color& down, Color& cloudUp, Color& cloudDown, - bool& full, Math::Point& scale); + bool& full); //@} //! Specifies the name of foreground texture @@ -1346,7 +1346,6 @@ protected: bool m_firstGroundSpot; int m_secondTexNum; bool m_backgroundFull; - Math::Point m_backgroundScale; std::string m_backgroundName; Texture m_backgroundTex; Color m_backgroundColorUp; diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 86f92b2..f351f22 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -423,11 +423,15 @@ Texture CGLDevice::CreateTexture(CImage *image, const TextureCreateParams ¶m return Texture(); // invalid texture } - Math::IntPoint size = image->GetSize(); - if (!Math::IsPowerOfTwo(size.x) || !Math::IsPowerOfTwo(size.y)) - GetLogger()->Warn("Creating non-power-of-2 texture (%dx%d)!\n", size.x, size.y); + Math::IntPoint originalSize = image->GetSize(); - return CreateTexture(data, params); + if (params.padToNearestPowerOfTwo) + image->PadToNearestPowerOfTwo(); + + Texture tex = CreateTexture(data, params); + tex.originalSize = originalSize; + + return tex; } Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams ¶ms) @@ -437,6 +441,11 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par result.size.x = data->surface->w; result.size.y = data->surface->h; + if (!Math::IsPowerOfTwo(result.size.x) || !Math::IsPowerOfTwo(result.size.y)) + GetLogger()->Warn("Creating non-power-of-2 texture (%dx%d)!\n", result.size.x, result.size.y); + + result.originalSize = result.size; + // Use & enable 1st texture stage if (m_multitextureAvailable) glActiveTexture(GL_TEXTURE0); diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp index cb7f04c..d0bd87b 100644 --- a/src/object/auto/autobase.cpp +++ b/src/object/auto/autobase.cpp @@ -1412,9 +1412,8 @@ void CAutoBase::BeginTransit() m_engine->SetDeepView(2000.0f); // we see very far m_engine->ApplyChange(); - Math::Point scale; bool full; - m_engine->GetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown, full, scale); + m_engine->GetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown, full); m_engine->DeleteTexture(m_bgName); m_engine->SetBackground(m_bgBack, Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 2dede28..985e00e 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -389,7 +389,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } @@ -509,7 +509,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } @@ -978,7 +978,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } @@ -1177,7 +1177,7 @@ pb->SetState(STATE_SHADOW); Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } } @@ -1702,7 +1702,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } } @@ -1752,7 +1752,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); m_loadingCounter = 1; // enough time to display! @@ -1774,7 +1774,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(861.0f / 1024.0f, 646.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } if ( m_phase == PHASE_WELCOME2 ) @@ -1793,7 +1793,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f)); + true); m_engine->SetBackForce(true); } if ( m_phase == PHASE_WELCOME3 ) @@ -1812,7 +1812,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f)); + true); m_engine->SetBackForce(true); } @@ -1948,7 +1948,7 @@ pos.y -= 0.048f; Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), - true, Math::Point(1.0f, 768.0f / 1024.0f)); + true); m_engine->SetBackForce(true); } -- cgit v1.2.3-1-g7c22 From 06cf93f466871eb9f6d6d93feaeaef14f58573af Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 12 May 2013 13:05:32 +0200 Subject: Better print fix --- src/object/robotmain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 981c1ed..2c72a27 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4921,9 +4921,10 @@ 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 (read[0] != 0) continue; // Ignore when loading saved game - GetLogger()->Error("Syntax error in file '%s' (line %d): Unknown command: %s\n", filename, lineNum, line); // Don't add \n at the end of log message - it's included in line variable + 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 } fclose(file); -- cgit v1.2.3-1-g7c22 From 04f747b00b95ebbd32457eae8a397695dc6981af Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 12 May 2013 14:55:41 +0200 Subject: Added simple texturepack support (#208) --- src/app/app.cpp | 17 +++++++++++++++-- src/app/app.h | 3 +++ src/graphics/engine/engine.cpp | 35 +++++++++++++++++++++++++++++------ src/graphics/engine/engine.h | 9 ++++++++- 4 files changed, 55 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 190f667..87b9e39 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -149,6 +149,8 @@ CApplication::CApplication() m_language = LANGUAGE_ENV; + m_texPack = ""; + m_lowCPU = true; for (int i = 0; i < DIR_MAX; ++i) @@ -219,7 +221,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) OPT_LOGLEVEL, OPT_LANGUAGE, OPT_LANGDIR, - OPT_VBO + OPT_VBO, + OPT_TEXPACK }; option options[] = @@ -230,7 +233,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) { "loglevel", required_argument, nullptr, OPT_LOGLEVEL }, { "language", required_argument, nullptr, OPT_LANGUAGE }, { "langdir", required_argument, nullptr, OPT_LANGDIR }, - { "vbo", required_argument, nullptr, OPT_VBO } + { "vbo", required_argument, nullptr, OPT_VBO }, + { "texpack", required_argument, nullptr, OPT_TEXPACK } }; opterr = 0; @@ -267,6 +271,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n"); GetLogger()->Message(" -langdir path set custom language directory path\n"); GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n"); + GetLogger()->Message(" -texpack name set texture pack\n"); return PARSE_ARGS_HELP; } case OPT_DEBUG: @@ -330,6 +335,12 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) break; } + case OPT_TEXPACK: + { + m_texPack = optarg; + GetLogger()->Info("Using texturepack: '%s'\n", m_texPack.c_str()); + break; + } default: assert(false); // should never get here } @@ -484,6 +495,8 @@ bool CApplication::Create() m_engine->SetDevice(m_device); + m_engine->SetTexturePack(m_texPack); + if (! m_engine->Create() ) { m_errorMessage = std::string("Error in CEngine::Init()\n") + standardInfoMessage; diff --git a/src/app/app.h b/src/app/app.h index 07f1b90..073ac97 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -467,6 +467,9 @@ protected: //! Application language Language m_language; + //! Texture pack + std::string m_texPack; + //! Low cpu mode bool m_lowCPU; }; diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 806cb5f..5bd51fe 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -62,6 +62,8 @@ CEngine::CEngine(CApplication *app) m_sound = nullptr; m_terrain = nullptr; + m_texPack = ""; + m_showStats = false; m_focus = 0.75f; @@ -236,6 +238,11 @@ void CEngine::SetTerrain(CTerrain* terrain) m_terrain = terrain; } +void CEngine::SetTexturePack(const std::string& texpackName) +{ + m_texPack = texpackName; +} + bool CEngine::Create() { @@ -2109,7 +2116,7 @@ void CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector& looka m_sound->SetListener(eyePt, lookatPt); } -Texture CEngine::CreateTexture(const std::string& texName, const TextureCreateParams& params, CImage* image) +Texture CEngine::CreateTexture(const std::string& texName, const TextureCreateParams& params, CImage* image, std::string orginalName) { if (texName.empty()) return Texture(); // invalid texture @@ -2125,7 +2132,7 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName))) { std::string error = img.GetError(); - GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); + if(orginalName == "") GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); m_texBlacklist.insert(texName); return Texture(); // invalid texture } @@ -2139,13 +2146,18 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa if (! tex.Valid()) { - GetLogger()->Error("Couldn't load texture '%s', blacklisting\n", texName.c_str()); + if(orginalName == "") GetLogger()->Error("Couldn't load texture '%s', blacklisting\n", texName.c_str()); m_texBlacklist.insert(texName); return tex; } - m_texNameMap[texName] = tex; - m_revTexNameMap[tex] = texName; + if(orginalName == "") { + m_texNameMap[texName] = tex; + m_revTexNameMap[tex] = texName; + } else { + m_texNameMap[orginalName] = tex; + m_revTexNameMap[tex] = orginalName; + } return tex; } @@ -2170,7 +2182,18 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams& if (it != m_texNameMap.end()) return (*it).second; - Texture tex = CreateTexture(name, params); + Texture tex; + if (m_texPack != "") { + std::string name_texpack = m_texPack + "/" + name; + + if (m_texBlacklist.find(name_texpack) == m_texBlacklist.end()) { + tex = CreateTexture(name_texpack, params, nullptr, name); + if (tex.Valid()) + return tex; + } + } + + tex = CreateTexture(name, params); return tex; } diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 16fb4e6..8df912e 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -726,6 +726,10 @@ public: //! Writes a screenshot containing the current frame bool WriteScreenShot(const std::string& fileName, int width, int height); + //! Set texture pack + void SetTexturePack(const std::string& texpackName); + + //@{ //! Management of game pause mode void SetPause(bool pause); @@ -1229,7 +1233,7 @@ protected: const Material& mat, int state); //! Create texture and add it to cache - Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr); + Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr, std::string orginalName = ""); //! Tests whether the given object is visible bool IsVisible(int objRank); @@ -1403,6 +1407,9 @@ protected: * so are disabled for subsequent load calls. */ std::set m_texBlacklist; + //! Texture pack + std::string m_texPack; + //! Mouse cursor definitions EngineMouse m_mice[ENG_MOUSE_COUNT]; //! Texture with mouse cursors -- cgit v1.2.3-1-g7c22 From c25b6ab472e372f2b6c0ec2bc10a5a7a4632b503 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 12 May 2013 15:23:26 +0200 Subject: Fix for #192 --- src/ui/maindialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 985e00e..30538f3 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -181,7 +181,7 @@ CMainDialog::CMainDialog() #endif m_publicDir = "program"; m_userDir = "user"; - m_filesDir = "files"; + m_filesDir = m_savegameDir; m_setupFull = m_app->GetVideoConfig().fullScreen; -- cgit v1.2.3-1-g7c22 From 1f77efb9cb3f39fae5567c3af65fd3e9ad8736aa Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 12 May 2013 15:37:23 +0200 Subject: Fixed bug with std::bad_alloc when using produce() I'm not sure why it wasn't happening before, but it's fixed :) --- src/script/script.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index 9537630..ba9b8e6 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1544,8 +1544,10 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user return true; } - object->ReadProgram(0, static_cast(name)); - object->RunProgram(0); + if(name[0] != 0) { + object->ReadProgram(0, static_cast(name)); + object->RunProgram(0); + } result->SetValInt(0); // no error return true; -- cgit v1.2.3-1-g7c22 From 61841b3f40c3381bd591ca14af290e46d3d9a76c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 12 May 2013 15:54:35 +0200 Subject: Backwards combatibility for retobject() (#209) --- src/script/cbottoken.cpp | 4 +++- src/script/script.cpp | 24 +++++++++++++++++++++++- src/script/script.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 2ae2c72..f24aba1 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -373,6 +373,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "getbuild" ) == 0 ) return true; if ( strcmp(token, "getresearchenable" ) == 0 ) return true; if ( strcmp(token, "getresearchdone" ) == 0 ) return true; + if ( strcmp(token, "retobjectbyid") == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; @@ -460,7 +461,8 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "getbuild" ) == 0 ) return "getbuild ( );"; if ( strcmp(token, "getresearchenable" ) == 0 ) return "getresearchenable ( );"; if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; - if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( );"; + if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; + if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; if ( strcmp(token, "detect" ) == 0 ) return "detect ( cat );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index ba9b8e6..0d2238d 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -449,6 +449,27 @@ CBotTypResult CScript::cGetObject(CBotVar* &var, void* user) return CBotTypResult(CBotTypPointer, "object"); } +// Instruction "retobjectbyid(rank)". + +bool CScript::rGetObjectById(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + CObject* pObj; + int rank; + + rank = var->GetValInt(); + + pObj = static_cast(CObjectManager::GetInstancePointer()->SearchInstance(rank)); + if ( pObj == 0 ) + { + result->SetPointer(0); + } + else + { + result->SetPointer(pObj->GetBotVar()); + } + return true; +} + // Instruction "retobject(rank)". bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user) @@ -458,7 +479,7 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us rank = var->GetValInt(); - pObj = static_cast(CObjectManager::GetInstancePointer()->SearchInstance(rank)); + pObj = static_cast(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_OBJECT, rank)); if ( pObj == 0 ) { result->SetPointer(0); @@ -3094,6 +3115,7 @@ void CScript::InitFonctions() CBotProgram::AddFunction("setresearchdone", rSetResearchDone, CScript::cOneFloat); CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); + CBotProgram::AddFunction("retobjectbyid", rGetObjectById, CScript::cGetObject); CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy); CBotProgram::AddFunction("search", rSearch, CScript::cSearch); CBotProgram::AddFunction("radar", rRadar, CScript::cRadar); diff --git a/src/script/script.h b/src/script/script.h index f0907f3..cd2a122 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -145,6 +145,7 @@ private: static bool rSetBuild(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rGetObjectById(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From 07839a561fa876539484fdc44e68d3f17e20a89b Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 12 May 2013 18:38:01 +0200 Subject: Unicode symbols for special characters * added support for special characters from original text bitmaps --- src/graphics/engine/text.cpp | 122 ++++++++++++++++++++++++++++++++++++------- src/graphics/engine/text.h | 31 +++++++++-- 2 files changed, 131 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 308c813..0f0122d 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -56,6 +56,7 @@ CText::CText(CEngine* engine) m_engine = engine; m_defaultSize = 12.0f; + m_tabSize = 4; m_lastFontType = FONT_COLOBOT; m_lastFontSize = 0; @@ -148,6 +149,16 @@ void CText::FlushCache() m_lastCachedFont = nullptr; } +int CText::GetTabSize() +{ + return m_tabSize; +} + +void CText::SetTabSize(int tabSize) +{ + m_tabSize = tabSize; +} + void CText::DrawText(const std::string &text, std::vector::iterator format, std::vector::iterator end, float size, Math::Point pos, float width, TextAlign align, @@ -309,11 +320,16 @@ float CText::GetStringWidth(const std::string &text, return width; } -float CText::GetStringWidth(const std::string &text, FontType font, float size) +float CText::GetStringWidth(std::string text, FontType font, float size) { assert(font != FONT_BUTTON); - // TODO: special chars? + // Skip special chars + for (char& c : text) + { + if (c < 32) + c = ':'; + } CachedFont* cf = GetOrOpenFont(font, size); assert(cf != nullptr); @@ -328,8 +344,16 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset) // TODO: if (font == FONT_BUTTON) if (font == FONT_BUTTON) return 0.0f; - // TODO: special chars? - // TODO: tab sizing + int width = 1; + if (ch.c1 < 32) + { + if (ch.c1 == '\t') + width = m_tabSize; + + // TODO: tab sizing at intervals? + + ch.c1 = ':'; + } CachedFont* cf = GetOrOpenFont(font, size); assert(cf != nullptr); @@ -341,7 +365,7 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset) else tex = CreateCharTexture(ch, cf); - return tex.charSize.x; + return tex.charSize.x * width; } @@ -505,6 +529,63 @@ int CText::Detect(const std::string &text, FontType font, float size, float offs return index; } +UTF8Char CText::TranslateSpecialChar(int specialChar) +{ + UTF8Char ch; + + switch (specialChar) + { + case CHAR_TAB: + ch.c1 = ':'; + ch.c2 = 0; + ch.c3 = 0; + break; + + case CHAR_NEWLINE: + // Unicode: U+21B2 + ch.c1 = 0xE2; + ch.c2 = 0x86; + ch.c3 = 0xB2; + break; + + case CHAR_DOT: + // Unicode: U+23C5 + ch.c1 = 0xE2; + ch.c2 = 0x8F; + ch.c3 = 0x85; + break; + + case CHAR_SQUARE: + // Unicode: U+25FD + ch.c1 = 0xE2; + ch.c2 = 0x97; + ch.c3 = 0xBD; + break; + + case CHAR_SKIP_RIGHT: + // Unicode: U+25B6 + ch.c1 = 0xE2; + ch.c2 = 0x96; + ch.c3 = 0xB6; + break; + + case CHAR_SKIP_LEFT: + // Unicode: U+25C0 + ch.c1 = 0xE2; + ch.c2 = 0x97; + ch.c3 = 0x80; + break; + + default: + ch.c1 = '?'; + ch.c2 = 0; + ch.c3 = 0; + break; + } + + return ch; +} + void CText::DrawString(const std::string &text, std::vector::iterator format, std::vector::iterator end, float size, Math::Point pos, float width, int eol, Color color) @@ -532,7 +613,11 @@ void CText::DrawString(const std::string &text, std::vector::itera float cw = GetCharWidth(ch, font, size, offset); if (offset + cw > width) // exceeds the maximum width? { - // TODO: special end-of-line char + UTF8Char ch = TranslateSpecialChar(CHAR_SKIP_RIGHT); + cw = GetCharWidth(ch, font, size, offset); + pos.x = start + width - cw; + color = Color(1.0f, 0.0f, 0.0f); + DrawCharAndAdjustPos(ch, font, size, pos, color); break; } @@ -550,7 +635,13 @@ void CText::DrawString(const std::string &text, std::vector::itera fmtIndex++; } - // TODO: eol + if (eol != 0) + { + FontType font = FONT_COLOBOT; + UTF8Char ch = TranslateSpecialChar(eol); + color = Color(1.0f, 0.0f, 0.0f); + DrawCharAndAdjustPos(ch, font, size, pos, color); + } } void CText::StringToUTFCharList(const std::string &text, std::vector &chars) @@ -675,23 +766,18 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P // TODO: if (font == FONT_BUTTON) if (font == FONT_BUTTON) return; - // TODO: special chars? - CachedFont* cf = GetOrOpenFont(font, size); if (cf == nullptr) return; int width = 1; - if (ch.c1 > 0 && ch.c1 < 32) { // FIXME add support for chars with code 9 10 23 - if (ch.c1 == '\t') { - ch.c1 = ':'; - width = 4; - } else { - ch.c1 = ' '; - } - ch.c2 = 0; - ch.c3 = 0; + if (ch.c1 > 0 && ch.c1 < 32) + { + if (ch.c1 == '\t') + width = m_tabSize; + + ch = TranslateSpecialChar(ch.c1); } auto it = cf->cache.find(ch); diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h index 6bcc59b..b19a224 100644 --- a/src/graphics/engine/text.h +++ b/src/graphics/engine/text.h @@ -205,6 +205,20 @@ struct MultisizeFont : fileName(fn) {} }; +/** + * \enum SpecialChar + * \brief Special codes for certain characters + */ +enum SpecialChar +{ + CHAR_TAB = '\t', //! Tab character - : + CHAR_NEWLINE = '\n', //! Newline character - arrow pointing down and left + CHAR_DOT = 1, //! Single dot in the middle + CHAR_SQUARE = 2, //! Square + CHAR_SKIP_RIGHT = 5, //! Filled triangle pointing right + CHAR_SKIP_LEFT = 6 //! Filled triangle pointing left +}; + /** * \class CText * \brief Text rendering engine @@ -240,6 +254,12 @@ public: //! Flushes cached textures void FlushCache(); + //@{ + //! Tab size management + void SetTabSize(int tabSize); + int GetTabSize(); + //@} + //! Draws text (multi-format) void DrawText(const std::string &text, std::vector::iterator format, std::vector::iterator end, @@ -268,11 +288,11 @@ public: float GetHeight(FontType font, float size); //! Returns width of string (multi-format) - TEST_VIRTUAL float GetStringWidth(const std::string &text, - std::vector::iterator format, - std::vector::iterator end, float size); + TEST_VIRTUAL float GetStringWidth(const std::string& text, + std::vector::iterator format, + std::vector::iterator end, float size); //! Returns width of string (single font) - TEST_VIRTUAL float GetStringWidth(const std::string &text, FontType font, float size); + TEST_VIRTUAL float GetStringWidth(std::string text, FontType font, float size); //! Returns width of single character TEST_VIRTUAL float GetCharWidth(UTF8Char ch, FontType font, float size, float offset); @@ -290,6 +310,8 @@ public: //! Returns the most suitable position to a given offset (one font) int Detect(const std::string &text, FontType font, float size, float offset); + UTF8Char TranslateSpecialChar(int specialChar); + protected: CachedFont* GetOrOpenFont(FontType type, float size); CharTexture CreateCharTexture(UTF8Char ch, CachedFont* font); @@ -309,6 +331,7 @@ protected: std::string m_error; float m_defaultSize; + int m_tabSize; std::map m_fonts; -- cgit v1.2.3-1-g7c22 From 47d7b805070e317894efbed653b1d44cd789f2fa Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 16:44:22 +0200 Subject: Added object.factory(cat) --- src/object/auto/auto.cpp | 6 ++ src/object/auto/auto.h | 2 + src/object/auto/autofactory.cpp | 81 ++++++++++++-------- src/object/auto/autofactory.h | 2 + src/object/robotmain.cpp | 6 +- src/script/cbottoken.cpp | 3 + src/script/script.cpp | 165 ++++++++++++++++++++++++++++++++++++++++ src/script/script.h | 6 +- 8 files changed, 233 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp index 3d88012..8dc1d94 100644 --- a/src/object/auto/auto.cpp +++ b/src/object/auto/auto.cpp @@ -107,6 +107,12 @@ void CAuto::Start(int param) { } +// Starts an action + +Error CAuto::StartAction(int param) +{ + return ERR_GENERIC; +} // Gete a type. diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h index 53ccdf9..e27804c 100644 --- a/src/object/auto/auto.h +++ b/src/object/auto/auto.h @@ -61,6 +61,8 @@ public: virtual Error IsEnded(); virtual bool Abort(); + virtual Error StartAction(int param); + virtual bool SetType(ObjectType type); virtual bool SetValue(int rank, float value); virtual bool SetString(char *string); diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index 82877c6..6aca426 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -107,17 +107,59 @@ void CAutoFactory::Init() } +// Starts an action + +Error CAutoFactory::StartAction(int param) +{ + CObject* fret; + ObjectType type = static_cast(param); + + if ( type != OBJECT_NULL ) + { + if ( m_phase != AFP_WAIT ) + { + return ERR_OK; + } + + m_type = type; + + fret = SearchFret(); // transform metal? + if ( fret == 0 ) + { + return ERR_FACTORY_NULL; + } + if ( NearestVehicle() ) + { + return ERR_FACTORY_NEAR; + } + + SetBusy(true); + InitProgressTotal(3.0f+2.0f+15.0f+2.0f+3.0f); + UpdateInterface(); + + fret->SetLock(true); // usable metal + SoundManip(3.0f, 1.0f, 0.5f); + + m_phase = AFP_CLOSE_S; + m_progress = 0.0f; + m_speed = 1.0f/3.0f; + return ERR_OK; + } + return ERR_GENERIC; +} + + // Management of an event. bool CAutoFactory::EventProcess(const Event &event) { + ObjectType type; CObject* fret; CObject* vehicle; Math::Matrix* mat; CPhysics* physics; Math::Vector pos, speed; Math::Point dim; - ObjectType type; float zoom, angle, prog; int i; @@ -155,39 +197,12 @@ bool CAutoFactory::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_FACTORYrs ) type = OBJECT_MOBILErs; if ( event.type == EVENT_OBJECT_FACTORYsa ) type = OBJECT_MOBILEsa; - if ( type != OBJECT_NULL ) - { - m_type = type; - - if ( m_phase != AFP_WAIT ) - { - return false; - } + Error err = StartAction(type); + if( err != ERR_OK && err != ERR_GENERIC ) + m_displayText->DisplayError(err, m_object); - fret = SearchFret(); // transform metal? - if ( fret == 0 ) - { - m_displayText->DisplayError(ERR_FACTORY_NULL, m_object); - return false; - } - if ( NearestVehicle() ) - { - m_displayText->DisplayError(ERR_FACTORY_NEAR, m_object); - return false; - } - - SetBusy(true); - InitProgressTotal(3.0f+2.0f+15.0f+2.0f+3.0f); - UpdateInterface(); - - fret->SetLock(true); // usable metal - SoundManip(3.0f, 1.0f, 0.5f); - - m_phase = AFP_CLOSE_S; - m_progress = 0.0f; - m_speed = 1.0f/3.0f; - return true; - } + if( err != ERR_GENERIC ) + return false; } if ( event.type != EVENT_FRAME ) return true; diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h index 7c5013d..e5a415b 100644 --- a/src/object/auto/autofactory.h +++ b/src/object/auto/autofactory.h @@ -48,6 +48,8 @@ public: void Init(); bool EventProcess(const Event &event); + Error StartAction(int param); + bool CreateInterface(bool bSelect); bool Write(char *line); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 2c72a27..dbd69f3 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -602,9 +602,6 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception) return true; // no interruption } - - - //! Constructor of robot application CRobotMain::CRobotMain(CApplication* app, bool loadProfile) { @@ -847,7 +844,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) CBotProgram::DefineNum("ResearchSubber", RESEARCH_SUBM); CBotProgram::DefineNum("ResearchSniffer", RESEARCH_SNIFFER); - CBotProgram:: +//? CBotProgram:: CBotProgram::DefineNum("PolskiPortalColobota", 1337); @@ -876,6 +873,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) bc->AddItem("energyCell", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ); + bc->AddFunction("factory", CScript::rFactory, CScript::cClassOneFloat); // Initializes the class FILE. InitClassFILE(); diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index f24aba1..c101f17 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -253,6 +253,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt"); if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt"); if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt"); + if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt"); if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt"); if ( strcmp(token, "direction" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/direct.txt"); @@ -375,6 +376,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return true; if ( strcmp(token, "retobjectbyid") == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; + if ( strcmp(token, "factory" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; if ( strcmp(token, "detect" ) == 0 ) return true; @@ -463,6 +465,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; + if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; if ( strcmp(token, "detect" ) == 0 ) return "detect ( cat );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 0d2238d..25a7e73 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -35,6 +35,9 @@ #include "object/task/taskmanager.h" #include "object/objman.h" +#include "object/auto/auto.h" +#include "object/auto/autofactory.h" + #include "physics/physics.h" #include "script/cbottoken.h" @@ -78,6 +81,11 @@ CBotTypResult CScript::cOneFloat(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } +CBotTypResult CScript::cClassOneFloat(CBotVar* thisclass, CBotVar* &var) +{ + return CScript::cOneFloat(var, nullptr); +} + // Compiling a procedure with two real numbers. CBotTypResult CScript::cTwoFloat(CBotVar* &var, void* user) @@ -491,6 +499,163 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us return true; } +// Instruction "object.factory(cat)" + +bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) +{ + Error err; + + exception = 0; + + CBotVar* classVars = thisclass->GetItemList(); // "category" + ObjectType thisType = static_cast(classVars->GetValInt()); + classVars = classVars->GetNext(); // "position" + classVars = classVars->GetNext(); // "orientation" + classVars = classVars->GetNext(); // "pitch" + classVars = classVars->GetNext(); // "roll" + classVars = classVars->GetNext(); // "energyLevel" + classVars = classVars->GetNext(); // "shieldLevel" + classVars = classVars->GetNext(); // "temperature" + classVars = classVars->GetNext(); // "altitude" + classVars = classVars->GetNext(); // "lifeTime" + classVars = classVars->GetNext(); // "material" + classVars = classVars->GetNext(); // "energyCell" + classVars = classVars->GetNext(); // "load" + classVars = classVars->GetNext(); // "id" + int rank = classVars->GetValInt(); + CObject* factory = CObjectManager::GetInstancePointer()->SearchInstance(rank); + CAuto* automat = factory->GetAuto(); + + if ( thisType == OBJECT_FACTORY ) + { + ObjectType type = static_cast(var->GetValInt()); + bool bEnable = false; + + if ( type == OBJECT_MOBILEwa ) + { + bEnable = true; + } + if ( type == OBJECT_MOBILEta ) + { + bEnable = g_researchDone&RESEARCH_TANK; + } + if ( type == OBJECT_MOBILEfa ) + { + bEnable = g_researchDone&RESEARCH_FLY; + } + if ( type == OBJECT_MOBILEia ) + { + bEnable = g_researchDone&RESEARCH_iPAW; + } + + if ( type == OBJECT_MOBILEws ) + { + bEnable = g_researchDone&RESEARCH_SNIFFER; + } + if ( type == OBJECT_MOBILEts ) + { + bEnable = ( (g_researchDone&RESEARCH_SNIFFER) && + (g_researchDone&RESEARCH_TANK) ); + } + if ( type == OBJECT_MOBILEfs ) + { + bEnable = ( (g_researchDone&RESEARCH_SNIFFER) && + (g_researchDone&RESEARCH_FLY) ); + } + if ( type == OBJECT_MOBILEis ) + { + bEnable = ( (g_researchDone&RESEARCH_SNIFFER) && + (g_researchDone&RESEARCH_iPAW) ); + } + + if ( type == OBJECT_MOBILEwc ) + { + bEnable = g_researchDone&RESEARCH_CANON; + } + if ( type == OBJECT_MOBILEtc ) + { + bEnable = ( (g_researchDone&RESEARCH_CANON) && + (g_researchDone&RESEARCH_TANK) ); + } + if ( type == OBJECT_MOBILEfc ) + { + bEnable = ( (g_researchDone&RESEARCH_CANON) && + (g_researchDone&RESEARCH_FLY) ); + } + if ( type == OBJECT_MOBILEic ) + { + bEnable = ( (g_researchDone&RESEARCH_CANON) && + (g_researchDone&RESEARCH_iPAW) ); + } + + if ( type == OBJECT_MOBILEwi ) + { + bEnable = g_researchDone&RESEARCH_iGUN; + } + if ( type == OBJECT_MOBILEti ) + { + bEnable = ( (g_researchDone&RESEARCH_iGUN) && + (g_researchDone&RESEARCH_TANK) ); + } + if ( type == OBJECT_MOBILEfi ) + { + bEnable = ( (g_researchDone&RESEARCH_iGUN) && + (g_researchDone&RESEARCH_FLY) ); + } + if ( type == OBJECT_MOBILEii ) + { + bEnable = ( (g_researchDone&RESEARCH_iGUN) && + (g_researchDone&RESEARCH_iPAW) ); + } + + if ( type == OBJECT_MOBILErt ) + { + bEnable = ( (g_researchDone&RESEARCH_THUMP) && + (g_researchDone&RESEARCH_TANK) ); + } + if ( type == OBJECT_MOBILErc ) + { + bEnable = ( (g_researchDone&RESEARCH_PHAZER) && + (g_researchDone&RESEARCH_TANK) ); + } + if ( type == OBJECT_MOBILErr ) + { + bEnable = ( (g_researchDone&RESEARCH_RECYCLER) && + (g_researchDone&RESEARCH_TANK) ); + } + if ( type == OBJECT_MOBILErs ) + { + bEnable = ( (g_researchDone&RESEARCH_SHIELD) && + (g_researchDone&RESEARCH_TANK) ); + } + + if ( type == OBJECT_MOBILEsa ) + { + bEnable = g_researchDone&RESEARCH_SUBM; + } + + if ( bEnable ) + err = automat->StartAction(type); + else + err = ERR_BUILD_DISABLED; + } else + err = ERR_MANIP_VEH; + + if ( err != ERR_OK ) + { + result->SetValInt(err); // return error +//TODO: if ( script->m_errMode == ERM_STOP ) + if( true ) + { + exception = err; + return false; + } + return true; + } + + return true; +} + // Compilation of the instruction "destroy(rank[, exploType[, force]])". CBotTypResult CScript::cDestroy(CBotVar* &var, void* user) diff --git a/src/script/script.h b/src/script/script.h index cd2a122..481df8e 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -94,7 +94,6 @@ protected: bool Compile(); private: - static CBotTypResult cNull(CBotVar* &var, void* user); static CBotTypResult cOneFloat(CBotVar* &var, void* user); static CBotTypResult cTwoFloat(CBotVar* &var, void* user); @@ -191,6 +190,11 @@ private: static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user); +public: + static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var); + static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); + +private: static bool Process(CScript* script, CBotVar* result, int &exception); static CObject* SearchInfo(CScript* script, CObject* object, float power); -- cgit v1.2.3-1-g7c22 From 8004e689481d01decbde351d1925e0efe23daf94 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 16:58:35 +0200 Subject: Added object.busy() --- src/object/robotmain.cpp | 1 + src/script/cbottoken.cpp | 3 +++ src/script/script.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/script/script.h | 3 +++ 4 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index dbd69f3..52387f8 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -873,6 +873,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) bc->AddItem("energyCell", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ); + bc->AddFunction("busy", CScript::rBusy, CScript::cBusy); bc->AddFunction("factory", CScript::rFactory, CScript::cClassOneFloat); // Initializes the class FILE. diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index c101f17..c56482f 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -253,6 +253,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt"); if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt"); if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt"); + if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt"); if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt"); if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt"); @@ -376,6 +377,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return true; if ( strcmp(token, "retobjectbyid") == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; + if ( strcmp(token, "busy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; @@ -465,6 +467,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; + if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( cat );"; if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 25a7e73..31ede8d 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -499,6 +499,45 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us return true; } +// Compilation of instruction "object.busy()" +CBotTypResult CScript::cBusy(CBotVar* thisclass, CBotVar* &var) +{ + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + return CBotTypResult(CBotTypBoolean); +} + +// Instruction "object.busy()" + +bool CScript::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) +{ + exception = 0; + + CBotVar* classVars = thisclass->GetItemList(); // "category" + classVars = classVars->GetNext(); // "position" + classVars = classVars->GetNext(); // "orientation" + classVars = classVars->GetNext(); // "pitch" + classVars = classVars->GetNext(); // "roll" + classVars = classVars->GetNext(); // "energyLevel" + classVars = classVars->GetNext(); // "shieldLevel" + classVars = classVars->GetNext(); // "temperature" + classVars = classVars->GetNext(); // "altitude" + classVars = classVars->GetNext(); // "lifeTime" + classVars = classVars->GetNext(); // "material" + classVars = classVars->GetNext(); // "energyCell" + classVars = classVars->GetNext(); // "load" + classVars = classVars->GetNext(); // "id" + int rank = classVars->GetValInt(); + CObject* obj = CObjectManager::GetInstancePointer()->SearchInstance(rank); + CAuto* automat = obj->GetAuto(); + + if ( automat != nullptr ) + result->SetValInt(automat->GetBusy()); + else + exception = ERR_MANIP_VEH; + + return true; +} + // Instruction "object.factory(cat)" bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) diff --git a/src/script/script.h b/src/script/script.h index 481df8e..62e95b3 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -191,7 +191,10 @@ private: static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user); public: + static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var); static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var); + + static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); private: -- cgit v1.2.3-1-g7c22 From d0de6a88ba5095c4d485e281e6fb3e804b0c21b6 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 17:01:52 +0200 Subject: Renamed destroy() -> delete() --- src/script/script.cpp | 10 +++++----- src/script/script.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index 31ede8d..0271eb6 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -695,9 +695,9 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e return true; } -// Compilation of the instruction "destroy(rank[, exploType[, force]])". +// Compilation of the instruction "delete(rank[, exploType[, force]])". -CBotTypResult CScript::cDestroy(CBotVar* &var, void* user) +CBotTypResult CScript::cDelete(CBotVar* &var, void* user) { if ( var == 0 ) return CBotTypResult(CBotErrLowParam); @@ -719,9 +719,9 @@ CBotTypResult CScript::cDestroy(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } -// Instruction "destroy(rank[, exploType[, force]])". +// Instruction "delete(rank[, exploType[, force]])". -bool CScript::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user) +bool CScript::rDelete(CBotVar* var, CBotVar* result, int& exception, void* user) { CObject* pObj; int rank; @@ -3320,7 +3320,7 @@ void CScript::InitFonctions() CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); CBotProgram::AddFunction("retobjectbyid", rGetObjectById, CScript::cGetObject); - CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy); + CBotProgram::AddFunction("delete", rDelete, CScript::cDelete); CBotProgram::AddFunction("search", rSearch, CScript::cSearch); CBotProgram::AddFunction("radar", rRadar, CScript::cRadar); CBotProgram::AddFunction("detect", rDetect, CScript::cDetect); diff --git a/src/script/script.h b/src/script/script.h index 62e95b3..ae9011b 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -101,7 +101,7 @@ private: static CBotTypResult cEndMission(CBotVar* &var, void* user); static CBotTypResult cPlayMusic(CBotVar* &var, void* user); static CBotTypResult cGetObject(CBotVar* &var, void* user); - static CBotTypResult cDestroy(CBotVar* &var, void* user); + static CBotTypResult cDelete(CBotVar* &var, void* user); static CBotTypResult cSearch(CBotVar* &var, void* user); static CBotTypResult cRadar(CBotVar* &var, void* user); static CBotTypResult cDetect(CBotVar* &var, void* user); @@ -146,7 +146,7 @@ private: static bool rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObjectById(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); - static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rDelete(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From 796cb92ffc7dc03f9cc7107cac5ddb81795d0549 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 17:38:44 +0200 Subject: Added object.destroy() --- src/common/global.h | 1 + src/common/restext.cpp | 1 + src/object/auto/autodestroyer.cpp | 51 +++++++++++++++++++++++++++------------ src/object/auto/autodestroyer.h | 2 ++ src/object/robotmain.cpp | 1 + src/script/cbottoken.cpp | 5 +++- src/script/script.cpp | 50 ++++++++++++++++++++++++++++++++++++++ src/script/script.h | 2 ++ 8 files changed, 97 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/common/global.h b/src/common/global.h index db601df..5e03536 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -106,6 +106,7 @@ enum Error ERR_INFO_NULL = 390, //! < no information terminal ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus ERR_BAT_VIRUS = 401, //! < building infected by a virus + ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy ERR_VEH_POWER = 500, //! < no battery ERR_VEH_ENERGY = 501, //! < more energy ERR_FLAG_FLY = 510, //! < impossible in flight diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 7fdcdbd..663a82e 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -623,6 +623,7 @@ void InitializeRestext() stringsErr[ERR_FLAG_CREATE] = "Too many flags of this color (maximum 5)"; stringsErr[ERR_FLAG_PROXY] = "Too close to an existing flag"; stringsErr[ERR_FLAG_DELETE] = "No flag nearby"; + stringsErr[ERR_DESTROY_NOTFOUND]= "Not found anything to destroy"; stringsErr[ERR_MISSION_NOTERM] = "The mission is not accomplished yet (press \\key help; for more details)"; stringsErr[ERR_DELETEMOBILE] = "Bot destroyed"; stringsErr[ERR_DELETEBUILDING] = "Building destroyed"; diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index e33c317..8e3fa98 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -24,6 +24,7 @@ #include "ui/interface.h" #include "ui/window.h" +#include "ui/displaytext.h" #include #include @@ -68,6 +69,36 @@ void CAutoDestroyer::Init() } +// Starts an action +Error CAutoDestroyer::StartAction(int param) +{ + CObject* scrap; + + if ( m_object->GetVirusMode() ) // contaminated by a virus? + { + return ERR_BAT_VIRUS; + } + + scrap = SearchPlastic(); + if ( scrap == nullptr ) + return ERR_DESTROY_NOTFOUND; + else { + if ( m_phase == ADEP_WAIT ) { + scrap->SetLock(true); // usable waste +//? scrap->SetTruck(m_object); // usable waste + + m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); + + m_phase = ADEP_DOWN; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + m_bExplo = false; + } else + return ERR_GENERIC; + } + return ERR_OK; +} + // Management of an event. bool CAutoDestroyer::EventProcess(const Event &event) @@ -86,21 +117,11 @@ bool CAutoDestroyer::EventProcess(const Event &event) { if ( event.type == EVENT_OBJECT_BDESTROY ) { - if ( m_object->GetVirusMode() ) // contaminated by a virus? - { - return true; // Don't do anything. TODO: Error? - } + Error err = StartAction(0); + if ( err != ERR_OK ) + m_displayText->DisplayError(err, m_object); - scrap = SearchPlastic(); - scrap->SetLock(true); // usable waste -//? scrap->SetTruck(m_object); // usable waste - - m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); - - m_phase = ADEP_DOWN; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - m_bExplo = false; + return false; } } @@ -381,4 +402,4 @@ void CAutoDestroyer::EnableInterface(Ui::CWindow *pw, EventType event, bool bSta if ( control == 0 ) return; control->SetState(Ui::STATE_ENABLE, bState); -} \ No newline at end of file +} diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h index 4ab1118..ef3d5ae 100644 --- a/src/object/auto/autodestroyer.h +++ b/src/object/auto/autodestroyer.h @@ -46,6 +46,8 @@ public: bool EventProcess(const Event &event); Error GetError(); + Error StartAction(int param); + bool CreateInterface(bool bSelect); bool Write(char *line); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 52387f8..2957799 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -875,6 +875,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ); bc->AddFunction("busy", CScript::rBusy, CScript::cBusy); bc->AddFunction("factory", CScript::rFactory, CScript::cClassOneFloat); + bc->AddFunction("destroy", CScript::rDestroy, CScript::cClassNull); // Initializes the class FILE. InitClassFILE(); diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index c56482f..b5e99f5 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -255,6 +255,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt"); if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt"); if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); + if ( strcmp(token, "destroy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/destroy.txt"); if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt"); if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt"); if ( strcmp(token, "direction" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/direct.txt"); @@ -379,6 +380,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "retobject" ) == 0 ) return true; if ( strcmp(token, "busy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; + if ( strcmp(token, "destroy" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; if ( strcmp(token, "detect" ) == 0 ) return true; @@ -467,8 +469,9 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; - if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( cat );"; + if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );"; if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat );"; + if ( strcmp(token, "destroy" ) == 0 ) return "object.destroy ( );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; if ( strcmp(token, "detect" ) == 0 ) return "detect ( cat );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 0271eb6..527da93 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -70,6 +70,11 @@ CBotTypResult CScript::cNull(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } +CBotTypResult CScript::cClassNull(CBotVar* thisclass, CBotVar* &var) +{ + return CScript::cNull(var, nullptr); +} + // Compiling a procedure with a single real number. CBotTypResult CScript::cOneFloat(CBotVar* &var, void* user) @@ -538,6 +543,51 @@ bool CScript::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exce return true; } +bool CScript::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) +{ + exception = 0; + Error err; + + CBotVar* classVars = thisclass->GetItemList(); // "category" + ObjectType thisType = static_cast(classVars->GetValInt()); + classVars = classVars->GetNext(); // "position" + classVars = classVars->GetNext(); // "orientation" + classVars = classVars->GetNext(); // "pitch" + classVars = classVars->GetNext(); // "roll" + classVars = classVars->GetNext(); // "energyLevel" + classVars = classVars->GetNext(); // "shieldLevel" + classVars = classVars->GetNext(); // "temperature" + classVars = classVars->GetNext(); // "altitude" + classVars = classVars->GetNext(); // "lifeTime" + classVars = classVars->GetNext(); // "material" + classVars = classVars->GetNext(); // "energyCell" + classVars = classVars->GetNext(); // "load" + classVars = classVars->GetNext(); // "id" + int rank = classVars->GetValInt(); + CObject* obj = CObjectManager::GetInstancePointer()->SearchInstance(rank); + CAuto* automat = obj->GetAuto(); + + if ( thisType == OBJECT_DESTROYER ) + { + err = automat->StartAction(0); + } else + err = ERR_MANIP_VEH; + + if ( err != ERR_OK ) + { + result->SetValInt(err); // return error +//TODO: if ( script->m_errMode == ERM_STOP ) + if( true ) + { + exception = err; + return false; + } + return true; + } + + return true; +} + // Instruction "object.factory(cat)" bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) diff --git a/src/script/script.h b/src/script/script.h index ae9011b..75f0d72 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -193,9 +193,11 @@ private: public: static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var); static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var); + static CBotTypResult cClassNull(CBotVar* thisclass, CBotVar* &var); static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); + static bool rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); private: static bool Process(CScript* script, CBotVar* result, int &exception); -- cgit v1.2.3-1-g7c22 From 58cc0603cc62f1286835bf8af8c346b8e7e6042a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 17:44:26 +0200 Subject: Fix for build() not being able to build Detroyer --- src/script/script.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index 527da93..fb9ee93 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1435,11 +1435,12 @@ bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* use (category == OBJECT_ENERGY && (g_build & BUILD_ENERGY)) || (category == OBJECT_LABO && (g_build & BUILD_LABO)) || (category == OBJECT_NUCLEAR && (g_build & BUILD_NUCLEAR)) || - (category == OBJECT_INFO && (g_build & BUILD_INFO )) || - (category == OBJECT_PARA && (g_build & BUILD_PARA ))) + (category == OBJECT_INFO && (g_build & BUILD_INFO)) || + (category == OBJECT_PARA && (g_build & BUILD_PARA)) || + (category == OBJECT_DESTROYER && (g_build & BUILD_DESTROYER))) { - //if we want to build not researched one + //if we want to build not researched one if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) ) @@ -1495,11 +1496,12 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user) (category == OBJECT_ENERGY && (g_build & BUILD_ENERGY)) || (category == OBJECT_LABO && (g_build & BUILD_LABO)) || (category == OBJECT_NUCLEAR && (g_build & BUILD_NUCLEAR)) || - (category == OBJECT_INFO && (g_build & BUILD_INFO )) || - (category == OBJECT_PARA && (g_build & BUILD_PARA ))) + (category == OBJECT_INFO && (g_build & BUILD_INFO)) || + (category == OBJECT_PARA && (g_build & BUILD_PARA)) || + (category == OBJECT_DESTROYER && (g_build & BUILD_DESTROYER))) { - //if we want to build not researched one + //if we want to build not researched one if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) || (category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC)) ) -- cgit v1.2.3-1-g7c22 From b65196c17f1fb553e2b1a0cada042b47c1459486 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 18:22:18 +0200 Subject: Change in goto() for Destroyer --- src/object/task/taskgoto.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 97331dd..b3a7221 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -1310,16 +1310,6 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, return true; } - if ( type == OBJECT_DESTROYER ) - { - mat = pObj->GetWorldMatrix(0); - pos.x += 0.0f; - if ( bTake && distance != 0.0f ) suppl = 4.0f; - if ( bTake ) pos.x += TAKE_DIST+distance+suppl; - pos = Transform(*mat, pos); - return true; - } - if ( type == OBJECT_PARA && m_physics->GetType() == TYPE_FLYING ) { mat = pObj->GetWorldMatrix(0); -- cgit v1.2.3-1-g7c22 From 7662f312b399b58faf20db4a850a2b0298d659df Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 18:29:07 +0200 Subject: Changed "Inappropariate bot"->"Inappropariate object" in newly added functions --- src/common/global.h | 1 + src/common/restext.cpp | 1 + src/script/script.cpp | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common/global.h b/src/common/global.h index 5e03536..716b711 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -107,6 +107,7 @@ enum Error ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus ERR_BAT_VIRUS = 401, //! < building infected by a virus ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy + ERR_WRONG_OBJ = 420, //! < inappropriate vehicle ERR_VEH_POWER = 500, //! < no battery ERR_VEH_ENERGY = 501, //! < more energy ERR_FLAG_FLY = 510, //! < impossible in flight diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 663a82e..bbec7ec 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -624,6 +624,7 @@ void InitializeRestext() stringsErr[ERR_FLAG_PROXY] = "Too close to an existing flag"; stringsErr[ERR_FLAG_DELETE] = "No flag nearby"; stringsErr[ERR_DESTROY_NOTFOUND]= "Not found anything to destroy"; + stringsErr[ERR_WRONG_OBJ] = "Inappropriate object"; stringsErr[ERR_MISSION_NOTERM] = "The mission is not accomplished yet (press \\key help; for more details)"; stringsErr[ERR_DELETEMOBILE] = "Bot destroyed"; stringsErr[ERR_DELETEBUILDING] = "Building destroyed"; diff --git a/src/script/script.cpp b/src/script/script.cpp index fb9ee93..250f052 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -538,7 +538,7 @@ bool CScript::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exce if ( automat != nullptr ) result->SetValInt(automat->GetBusy()); else - exception = ERR_MANIP_VEH; + exception = ERR_WRONG_OBJ; return true; } @@ -571,7 +571,7 @@ bool CScript::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e { err = automat->StartAction(0); } else - err = ERR_MANIP_VEH; + err = ERR_WRONG_OBJ; if ( err != ERR_OK ) { @@ -728,7 +728,7 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e else err = ERR_BUILD_DISABLED; } else - err = ERR_MANIP_VEH; + err = ERR_WRONG_OBJ; if ( err != ERR_OK ) { -- cgit v1.2.3-1-g7c22 From b9d0ee034e1e0b78cbca137cc2f39930fb7ad127 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 May 2013 16:25:53 +0200 Subject: Running program in robots created using object.factory() --- src/common/restext.cpp | 1 + src/object/auto/autofactory.cpp | 25 +++++++++++++++- src/object/auto/autofactory.h | 6 +++- src/object/brain.cpp | 17 +++++++++++ src/object/brain.h | 1 + src/object/robotmain.cpp | 2 +- src/script/cbottoken.cpp | 2 +- src/script/script.cpp | 63 +++++++++++++++++++++++++++++++++-------- src/script/script.h | 4 +-- 9 files changed, 103 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/common/restext.cpp b/src/common/restext.cpp index bbec7ec..ac40dad 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -540,6 +540,7 @@ void InitializeRestext() + stringsErr[ERR_GENERIC] = "Internal error - tell the developers"; stringsErr[ERR_CMD] = "Unknown command"; stringsErr[ERR_MANIP_VEH] = "Inappropriate bot"; stringsErr[ERR_MANIP_FLY] = "Impossible when flying"; diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index 6aca426..fb82497 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -24,6 +24,7 @@ #include "math/geometry.h" #include "object/robotmain.h" +#include "object/brain.h" #include "physics/physics.h" @@ -103,6 +104,8 @@ void CAutoFactory::Init() m_fretPos = m_object->GetPosition(0); + m_program = nullptr; + CAuto::Init(); } @@ -149,6 +152,15 @@ Error CAutoFactory::StartAction(int param) } +// Sets program for created robot + +void CAutoFactory::SetProgram(const char* program) +{ + m_program = new char[strlen(program)+1]; + strcpy(m_program, program); +} + + // Management of an event. bool CAutoFactory::EventProcess(const Event &event) @@ -377,7 +389,7 @@ bool CAutoFactory::EventProcess(const Event &event) delete fret; } - vehicle = SearchVehicle(); + m_vehicle = vehicle = SearchVehicle(); if ( vehicle != 0 ) { physics = vehicle->GetPhysics(); @@ -476,6 +488,17 @@ bool CAutoFactory::EventProcess(const Event &event) m_object->SetZoomZ(10+i, 0.30f); } + if ( m_program != nullptr ) + { + CBrain* brain = m_vehicle->GetBrain(); + if ( brain != nullptr ) + { + brain->SendProgram(0, const_cast(m_program)); + brain->SetScriptRun(0); + brain->RunProgram(0); + } + } + SetBusy(false); UpdateInterface(); diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h index e5a415b..d9350e6 100644 --- a/src/object/auto/autofactory.h +++ b/src/object/auto/autofactory.h @@ -49,6 +49,7 @@ public: bool EventProcess(const Event &event); Error StartAction(int param); + void SetProgram(const char* program); bool CreateInterface(bool bSelect); @@ -71,7 +72,10 @@ protected: float m_progress; float m_speed; float m_lastParticle; - Math::Vector m_fretPos; + Math::Vector m_fretPos; int m_channelSound; + + CObject* m_vehicle; + char* m_program; }; diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 266a8ac..56221b1 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -2720,6 +2720,23 @@ bool CBrain::ReadSoluce(char* filename) return true; } +// Load a script from text buffer. + +bool CBrain::SendProgram(int rank, const char* buffer) +{ + if ( m_script[rank] == 0 ) + { + m_script[rank] = new CScript(m_object, &m_secondaryTask); + } + + if ( m_script[rank]->SendScript(buffer) ) return true; + + delete m_script[rank]; + m_script[rank] = 0; + + return false; +} + // Load a script with a text file. bool CBrain::ReadProgram(int rank, const char* filename) diff --git a/src/object/brain.h b/src/object/brain.h index eba8004..38fb96f 100644 --- a/src/object/brain.h +++ b/src/object/brain.h @@ -114,6 +114,7 @@ public: char* GetScriptName(int rank); void SetSoluceName(char *name); char* GetSoluceName(); + bool SendProgram(int rank, const char* buffer); bool ReadSoluce(char* filename); bool ReadProgram(int rank, const char* filename); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 2957799..b959d44 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -874,7 +874,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ); bc->AddFunction("busy", CScript::rBusy, CScript::cBusy); - bc->AddFunction("factory", CScript::rFactory, CScript::cClassOneFloat); + bc->AddFunction("factory", CScript::rFactory, CScript::cFactory); bc->AddFunction("destroy", CScript::rDestroy, CScript::cClassNull); // Initializes the class FILE. diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index b5e99f5..bf29e1d 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -470,7 +470,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );"; - if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat );"; + if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat, program );"; if ( strcmp(token, "destroy" ) == 0 ) return "object.destroy ( );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 250f052..1f86e71 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -86,11 +86,6 @@ CBotTypResult CScript::cOneFloat(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } -CBotTypResult CScript::cClassOneFloat(CBotVar* thisclass, CBotVar* &var) -{ - return CScript::cOneFloat(var, nullptr); -} - // Compiling a procedure with two real numbers. CBotTypResult CScript::cTwoFloat(CBotVar* &var, void* user) @@ -588,6 +583,23 @@ bool CScript::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e return true; } + +// Compilation of instruction "object.factory(cat)" + +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->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + } + return CBotTypResult(CBotTypFloat); +} + // Instruction "object.factory(cat)" bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) @@ -596,6 +608,18 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e exception = 0; + ObjectType type = static_cast(var->GetValInt()); + var = var->GetNext(); + CBotString cbs; + const char* program; + if ( var != 0 ) + { + cbs = var->GetValString(); + program = cbs; + } + else + program = ""; + CBotVar* classVars = thisclass->GetItemList(); // "category" ObjectType thisType = static_cast(classVars->GetValInt()); classVars = classVars->GetNext(); // "position" @@ -613,11 +637,10 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e classVars = classVars->GetNext(); // "id" int rank = classVars->GetValInt(); CObject* factory = CObjectManager::GetInstancePointer()->SearchInstance(rank); - CAuto* automat = factory->GetAuto(); + CAutoFactory* automat = static_cast(factory->GetAuto()); if ( thisType == OBJECT_FACTORY ) { - ObjectType type = static_cast(var->GetValInt()); bool bEnable = false; if ( type == OBJECT_MOBILEwa ) @@ -724,10 +747,19 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e } if ( bEnable ) - err = automat->StartAction(type); + { + if ( automat != nullptr ) + { + err = automat->StartAction(type); + if ( err == ERR_OK ) automat->SetProgram(program); + } + else + err = ERR_GENERIC; + } else err = ERR_BUILD_DISABLED; - } else + } + else err = ERR_WRONG_OBJ; if ( err != ERR_OK ) @@ -4307,13 +4339,20 @@ void CScript::New(Ui::CEdit* edit, const char* name) // Provided a script for all parts. -bool CScript::SendScript(char* text) +bool CScript::SendScript(const char* text) { - m_len = strlen(text); + /*m_len = strlen(text); m_script = new char[m_len+1]; strcpy(m_script, text); if ( !CheckToken() ) return false; - if ( !Compile() ) return false; + if ( !Compile() ) return false;*/ + + Ui::CEdit* edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9); + edit->SetMaxChar(Ui::EDITSTUDIOMAX); + edit->SetAutoIndent(m_engine->GetEditIndentMode()); + edit->SetText(text, true); + GetScript(edit); + m_interface->DeleteControl(EVENT_EDIT9); return true; } diff --git a/src/script/script.h b/src/script/script.h index 75f0d72..e3d3b7a 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -78,7 +78,7 @@ public: void GetError(char* buffer); void New(Ui::CEdit* edit, const char* name); - bool SendScript(char* text); + bool SendScript(const char* text); bool ReadScript(const char* filename); bool WriteScript(const char* filename); bool ReadStack(FILE *file); @@ -192,7 +192,7 @@ private: public: static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var); - static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var); + static CBotTypResult cFactory(CBotVar* thisclass, CBotVar* &var); static CBotTypResult cClassNull(CBotVar* thisclass, CBotVar* &var); static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); -- cgit v1.2.3-1-g7c22 From 6b25608e698cc117ffeeaa6454bd6fc1a72fdc50 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 May 2013 16:56:08 +0200 Subject: Added progfunc( funcname ); For simple creating of programs executing public functions :) Example: public void object::SecondBot() { message("It works!"); } extern void object::FirstBot() { object item = radar(BotFactory); item.factory(WheeledGrabber, progfunc("SecondBot")); } --- src/script/cbottoken.cpp | 3 +++ src/script/script.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/script/script.h | 2 ++ 3 files changed, 41 insertions(+) (limited to 'src') diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index bf29e1d..1747e5c 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -253,6 +253,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt"); if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt"); if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt"); + if ( strcmp(token, "progfunc" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt"); if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); if ( strcmp(token, "destroy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/destroy.txt"); @@ -378,6 +379,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return true; if ( strcmp(token, "retobjectbyid") == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; + if ( strcmp(token, "progfunc" ) == 0 ) return true; if ( strcmp(token, "busy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; if ( strcmp(token, "destroy" ) == 0 ) return true; @@ -469,6 +471,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; + if ( strcmp(token, "progfunc" ) == 0 ) return "progfunc ( funcname );"; if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );"; if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat, program );"; if ( strcmp(token, "destroy" ) == 0 ) return "object.destroy ( );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 1f86e71..dc10425 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -155,6 +155,18 @@ CBotTypResult CScript::cString(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } +// Compiling a procedure with a single string, returning string. + +CBotTypResult CScript::cStringString(CBotVar* &var, void* user) +{ + if ( var == 0 ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() != CBotTypString && + var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != 0 ) return CBotTypResult(CBotErrOverParam); + return CBotTypResult(CBotTypString); +} + // Seeking value in an array of integers. @@ -499,6 +511,29 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us return true; } + +// Instruction "progfunc(funcname)". + +bool CScript::rProgFunc(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + CBotString cbs; + const char* funcname; + std::string program; + + cbs = var->GetValString(); + funcname = cbs; + + //TODO: Translation :) + program = "extern void object::Auto()\n{\n\t\n\t//Automatically generated by progfunc(\""; + program += funcname; + program += "\");\n\t"; + program += funcname; + program += "();\n\t\n}\n"; + + result->SetValString(program.c_str()); + + return true; +} // Compilation of instruction "object.busy()" CBotTypResult CScript::cBusy(CBotVar* thisclass, CBotVar* &var) { @@ -3402,6 +3437,7 @@ void CScript::InitFonctions() CBotProgram::AddFunction("setresearchenable", rSetResearchEnable, CScript::cOneFloat); CBotProgram::AddFunction("setresearchdone", rSetResearchDone, CScript::cOneFloat); + CBotProgram::AddFunction("progfunc", rProgFunc, CScript::cStringString); CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject); CBotProgram::AddFunction("retobjectbyid", rGetObjectById, CScript::cGetObject); CBotProgram::AddFunction("delete", rDelete, CScript::cDelete); diff --git a/src/script/script.h b/src/script/script.h index e3d3b7a..1c02daf 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -98,6 +98,7 @@ private: static CBotTypResult cOneFloat(CBotVar* &var, void* user); static CBotTypResult cTwoFloat(CBotVar* &var, void* user); static CBotTypResult cString(CBotVar* &var, void* user); + static CBotTypResult cStringString(CBotVar* &var, void* user); static CBotTypResult cEndMission(CBotVar* &var, void* user); static CBotTypResult cPlayMusic(CBotVar* &var, void* user); static CBotTypResult cGetObject(CBotVar* &var, void* user); @@ -146,6 +147,7 @@ private: static bool rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObjectById(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user); + static bool rProgFunc(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rDelete(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user); static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user); -- cgit v1.2.3-1-g7c22 From 6798641a71e18e1e3ea798617deb38f557b3c497 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 May 2013 17:03:55 +0200 Subject: Translated and --- src/script/script.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/script/script.cpp b/src/script/script.cpp index dc10425..e2fb302 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -3674,7 +3674,7 @@ bool CScript::Compile() { if ( liste.GetSize() == 0 ) { - strcpy(m_title, ""); + strcpy(m_title, ""); } else { @@ -3711,7 +3711,7 @@ bool CScript::Compile() { m_cursor1 = m_cursor2 = 0; } - strcpy(m_title, ""); + strcpy(m_title, ""); return false; } } -- cgit v1.2.3-1-g7c22 From f90a4b48f5ecdc498c32b1b4a35d57f107f36fd5 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 May 2013 21:48:29 +0200 Subject: Added object.research(type) --- src/object/auto/autolabo.cpp | 101 +++++++++++++--------- src/object/auto/autolabo.h | 3 +- src/object/auto/autoresearch.cpp | 175 +++++++++++++++++++-------------------- src/object/auto/autoresearch.h | 4 +- src/object/robotmain.cpp | 7 +- src/script/cbottoken.cpp | 3 + src/script/script.cpp | 92 +++++++++++++++++++- src/script/script.h | 2 + 8 files changed, 250 insertions(+), 137 deletions(-) (limited to 'src') diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp index 6984fd6..8424b93 100644 --- a/src/object/auto/autolabo.cpp +++ b/src/object/auto/autolabo.cpp @@ -42,7 +42,7 @@ const float LABO_DELAY = 20.0f; // duration of the analysis // Object's constructor. - CAutoLabo::CAutoLabo(CObject* object) : CAuto(object) +CAutoLabo::CAutoLabo(CObject* object) : CAuto(object) { int i; @@ -111,6 +111,48 @@ void CAutoLabo::Init() } +// Starts an action + +Error CAutoLabo::StartAction(int param) +{ + CObject* power; + + if ( m_phase != ALAP_WAIT ) + { + return ERR_GENERIC; + } + + m_research = static_cast(param); + + if ( g_researchDone & m_research ) + { + return ERR_LABO_ALREADY; + } + + power = m_object->GetPower(); + if ( power == 0 ) + { + return ERR_LABO_NULL; + } + if ( power->GetType() != OBJECT_BULLET ) + { + return ERR_LABO_BAD; + } + + SetBusy(true); + InitProgressTotal(1.0f+1.5f+1.5f+LABO_DELAY+1.5f+1.5f+1.0f); + UpdateInterface(); + + power->SetLock(true); // ball longer usable + + SoundManip(1.0f, 1.0f, 1.0f); + m_phase = ALAP_OPEN1; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + return ERR_OK; +} + + // Management of an event. bool CAutoLabo::EventProcess(const Event &event) @@ -130,46 +172,17 @@ bool CAutoLabo::EventProcess(const Event &event) if ( m_object->GetSelect() ) CreateInterface(true); } - if ( m_object->GetSelect() && // center selected? - (event.type == EVENT_OBJECT_RiPAW || - event.type == EVENT_OBJECT_RiGUN) ) + if ( m_object->GetSelect() ) // center selected? { - if ( m_phase != ALAP_WAIT ) - { - return false; - } - - m_research = event.type; - - if ( TestResearch(m_research) ) - { - m_displayText->DisplayError(ERR_LABO_ALREADY, m_object); - return false; - } - - power = m_object->GetPower(); - if ( power == 0 ) - { - m_displayText->DisplayError(ERR_LABO_NULL, m_object); + 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 ) + m_displayText->DisplayError(err, m_object); + + if( err != ERR_GENERIC ) return false; - } - if ( power->GetType() != OBJECT_BULLET ) - { - m_displayText->DisplayError(ERR_LABO_BAD, m_object); - return false; - } - - SetBusy(true); - InitProgressTotal(1.0f+1.5f+1.5f+LABO_DELAY+1.5f+1.5f+1.0f); - UpdateInterface(); - - power->SetLock(true); // ball longer usable - - SoundManip(1.0f, 1.0f, 1.0f); - m_phase = ALAP_OPEN1; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - return true; } if ( event.type != EVENT_FRAME ) return true; @@ -341,7 +354,13 @@ bool CAutoLabo::EventProcess(const Event &event) } else { - SetResearch(m_research); // research done + g_researchDone |= m_research; // research done + + m_main->WriteFreeParam(); + + Event newEvent(EVENT_UPDINTERFACE); + m_eventQueue->AddEvent(newEvent); + UpdateInterface(); power = m_object->GetPower(); if ( power != 0 ) @@ -606,7 +625,7 @@ bool CAutoLabo::Read(char *line) m_phase = static_cast< AutoLaboPhase >(OpInt(line, "aPhase", ALAP_WAIT)); m_progress = OpFloat(line, "aProgress", 0.0f); m_speed = OpFloat(line, "aSpeed", 1.0f); - m_research = static_cast< EventType >(OpInt(line, "aResearch", 0)); + m_research = static_cast< ResearchType >(OpInt(line, "aResearch", 0)); m_lastParticle = 0.0f; diff --git a/src/object/auto/autolabo.h b/src/object/auto/autolabo.h index b61e8e3..b3b08bb 100644 --- a/src/object/auto/autolabo.h +++ b/src/object/auto/autolabo.h @@ -47,6 +47,7 @@ public: void DeleteObject(bool bAll=false); void Init(); + Error StartAction(int param); bool EventProcess(const Event &event); Error GetError(); @@ -68,7 +69,7 @@ protected: float m_speed; float m_timeVirus; float m_lastParticle; - EventType m_research; + ResearchType m_research; int m_partiRank[3]; int m_partiSphere; int m_soundChannel; diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp index 3c32307..7564bb8 100644 --- a/src/object/auto/autoresearch.cpp +++ b/src/object/auto/autoresearch.cpp @@ -92,6 +92,60 @@ void CAutoResearch::Init() } +// Starts an action + +Error CAutoResearch::StartAction(int param) +{ + CObject* power; + float time; + + if ( m_phase != ALP_WAIT ) + { + return ERR_GENERIC; + } + + m_research = static_cast(param); + + if ( g_researchDone & m_research ) + { + return ERR_RESEARCH_ALREADY; + } + + power = m_object->GetPower(); + if ( power == 0 ) + { + return ERR_RESEARCH_POWER; + } + if ( power->GetCapacity() > 1.0f ) + { + return ERR_RESEARCH_TYPE; + } + if ( power->GetEnergy() < 1.0f ) + { + return ERR_RESEARCH_ENERGY; + } + + time = SEARCH_TIME; + if ( m_research == RESEARCH_TANK ) time *= 0.3f; + if ( m_research == RESEARCH_FLY ) time *= 0.3f; + if ( m_research == RESEARCH_ATOMIC ) time *= 2.0f; + + SetBusy(true); + InitProgressTotal(time); + UpdateInterface(); + + m_channelSound = m_sound->Play(SOUND_RESEARCH, m_object->GetPosition(0), 0.0f, 1.0f, true); + m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 2.0f, SOPER_CONTINUE); + m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, time-4.0f, SOPER_CONTINUE); + m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP); + + m_phase = ALP_SEARCH; + m_progress = 0.0f; + m_speed = 1.0f/time; + return ERR_OK; +} + + // Management of an event. bool CAutoResearch::EventProcess(const Event &event) @@ -100,7 +154,7 @@ bool CAutoResearch::EventProcess(const Event &event) Math::Vector pos, speed; Error message; Math::Point dim; - float angle, time; + float angle; CAuto::EventProcess(event); @@ -111,64 +165,23 @@ bool CAutoResearch::EventProcess(const Event &event) if ( m_object->GetSelect() ) CreateInterface(true); } - if ( m_object->GetSelect() && // center selected? - (event.type == EVENT_OBJECT_RTANK || - event.type == EVENT_OBJECT_RFLY || - event.type == EVENT_OBJECT_RTHUMP || - event.type == EVENT_OBJECT_RCANON || - event.type == EVENT_OBJECT_RTOWER || - event.type == EVENT_OBJECT_RPHAZER || - event.type == EVENT_OBJECT_RSHIELD || - event.type == EVENT_OBJECT_RATOMIC ) ) + if ( m_object->GetSelect() ) // center selected? { - if ( m_phase != ALP_WAIT ) - { - return false; - } - - m_research = event.type; - - if ( TestResearch(m_research) ) - { - m_displayText->DisplayError(ERR_RESEARCH_ALREADY, m_object); - return false; - } - - power = m_object->GetPower(); - if ( power == 0 ) - { - m_displayText->DisplayError(ERR_RESEARCH_POWER, m_object); + Error err = ERR_GENERIC; + if ( event.type == EVENT_OBJECT_RTANK ) err = StartAction(RESEARCH_TANK); + if ( event.type == EVENT_OBJECT_RFLY ) err = StartAction(RESEARCH_FLY); + if ( event.type == EVENT_OBJECT_RTHUMP ) err = StartAction(RESEARCH_THUMP); + if ( event.type == EVENT_OBJECT_RCANON ) err = StartAction(RESEARCH_CANON); + if ( event.type == EVENT_OBJECT_RTOWER ) err = StartAction(RESEARCH_TOWER); + 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 ) + m_displayText->DisplayError(err, m_object); + + if( err != ERR_GENERIC ) return false; - } - if ( power->GetCapacity() > 1.0f ) - { - m_displayText->DisplayError(ERR_RESEARCH_TYPE, m_object); - return false; - } - if ( power->GetEnergy() < 1.0f ) - { - m_displayText->DisplayError(ERR_RESEARCH_ENERGY, m_object); - return false; - } - - time = SEARCH_TIME; - if ( event.type == EVENT_OBJECT_RTANK ) time *= 0.3f; - if ( event.type == EVENT_OBJECT_RFLY ) time *= 0.3f; - if ( event.type == EVENT_OBJECT_RATOMIC ) time *= 2.0f; - - SetBusy(true); - InitProgressTotal(time); - UpdateInterface(); - - m_channelSound = m_sound->Play(SOUND_RESEARCH, m_object->GetPosition(0), 0.0f, 1.0f, true); - m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 2.0f, SOPER_CONTINUE); - m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, time-4.0f, SOPER_CONTINUE); - m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP); - - m_phase = ALP_SEARCH; - m_progress = 0.0f; - m_speed = 1.0f/time; - return true; } if ( event.type != EVENT_FRAME ) return true; @@ -236,18 +249,25 @@ bool CAutoResearch::EventProcess(const Event &event) } else { - SetResearch(m_research); // research done + g_researchDone |= m_research; // research done + + m_main->WriteFreeParam(); + + Event newEvent(EVENT_UPDINTERFACE); + m_eventQueue->AddEvent(newEvent); + UpdateInterface(); + m_displayText->DisplayError(INFO_RESEARCH, m_object); message = ERR_OK; - if ( m_research == EVENT_OBJECT_RTANK ) message = INFO_RESEARCHTANK; - if ( m_research == EVENT_OBJECT_RFLY ) message = INFO_RESEARCHFLY; - if ( m_research == EVENT_OBJECT_RTHUMP ) message = INFO_RESEARCHTHUMP; - if ( m_research == EVENT_OBJECT_RCANON ) message = INFO_RESEARCHCANON; - if ( m_research == EVENT_OBJECT_RTOWER ) message = INFO_RESEARCHTOWER; - if ( m_research == EVENT_OBJECT_RPHAZER ) message = INFO_RESEARCHPHAZER; - if ( m_research == EVENT_OBJECT_RSHIELD ) message = INFO_RESEARCHSHIELD; - if ( m_research == EVENT_OBJECT_RATOMIC ) message = INFO_RESEARCHATOMIC; + if ( m_research == RESEARCH_TANK ) message = INFO_RESEARCHTANK; + if ( m_research == RESEARCH_FLY ) message = INFO_RESEARCHFLY; + if ( m_research == RESEARCH_THUMP ) message = INFO_RESEARCHTHUMP; + if ( m_research == RESEARCH_CANON ) message = INFO_RESEARCHCANON; + if ( m_research == RESEARCH_TOWER ) message = INFO_RESEARCHTOWER; + if ( m_research == RESEARCH_PHAZER ) message = INFO_RESEARCHPHAZER; + if ( m_research == RESEARCH_SHIELD ) message = INFO_RESEARCHSHIELD; + if ( m_research == RESEARCH_ATOMIC ) message = INFO_RESEARCHATOMIC; if ( message != ERR_OK ) { m_displayText->DisplayError(message, m_object); @@ -474,27 +494,6 @@ bool CAutoResearch::TestResearch(EventType event) return false; } -// Indicates a search as made. - -void CAutoResearch::SetResearch(EventType event) -{ - - if ( event == EVENT_OBJECT_RTANK ) g_researchDone |= RESEARCH_TANK; - if ( event == EVENT_OBJECT_RFLY ) g_researchDone |= RESEARCH_FLY; - if ( event == EVENT_OBJECT_RTHUMP ) g_researchDone |= RESEARCH_THUMP; - if ( event == EVENT_OBJECT_RCANON ) g_researchDone |= RESEARCH_CANON; - if ( event == EVENT_OBJECT_RTOWER ) g_researchDone |= RESEARCH_TOWER; - if ( event == EVENT_OBJECT_RPHAZER ) g_researchDone |= RESEARCH_PHAZER; - if ( event == EVENT_OBJECT_RSHIELD ) g_researchDone |= RESEARCH_SHIELD; - if ( event == EVENT_OBJECT_RATOMIC ) g_researchDone |= RESEARCH_ATOMIC; - - m_main->WriteFreeParam(); - - Event newEvent(EVENT_UPDINTERFACE); - m_eventQueue->AddEvent(newEvent); - UpdateInterface(); -} - // Updates the stop lights. @@ -600,7 +599,7 @@ bool CAutoResearch::Read(char *line) m_phase = static_cast< AutoResearchPhase >(OpInt(line, "aPhase", ALP_WAIT)); m_progress = OpFloat(line, "aProgress", 0.0f); m_speed = OpFloat(line, "aSpeed", 1.0f); - m_research = static_cast< EventType >(OpInt(line, "aResearch", 0)); + m_research = static_cast< ResearchType >(OpInt(line, "aResearch", 0)); m_lastUpdateTime = 0.0f; m_lastParticle = 0.0f; diff --git a/src/object/auto/autoresearch.h b/src/object/auto/autoresearch.h index 6c804ef..dcb9f7b 100644 --- a/src/object/auto/autoresearch.h +++ b/src/object/auto/autoresearch.h @@ -41,6 +41,7 @@ public: void DeleteObject(bool bAll=false); void Init(); + Error StartAction(int result); bool EventProcess(const Event &event); Error GetError(); @@ -54,7 +55,6 @@ protected: void UpdateInterface(float rTime); void OkayButton(Ui::CWindow *pw, EventType event); bool TestResearch(EventType event); - void SetResearch(EventType event); void FireStopUpdate(float progress, bool bLightOn); protected: @@ -64,7 +64,7 @@ protected: float m_timeVirus; float m_lastUpdateTime; float m_lastParticle; - EventType m_research; + ResearchType m_research; int m_partiStop[6]; int m_channelSound; }; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index b959d44..15250c6 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -873,9 +873,10 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) bc->AddItem("energyCell", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("load", CBotTypResult(CBotTypPointer, "object"), PR_READ); bc->AddItem("id", CBotTypResult(CBotTypInt), PR_READ); - bc->AddFunction("busy", CScript::rBusy, CScript::cBusy); - bc->AddFunction("factory", CScript::rFactory, CScript::cFactory); - bc->AddFunction("destroy", CScript::rDestroy, CScript::cClassNull); + bc->AddFunction("busy", CScript::rBusy, CScript::cBusy); + bc->AddFunction("factory", CScript::rFactory, CScript::cFactory); + bc->AddFunction("research", CScript::rResearch, CScript::cClassOneFloat); + bc->AddFunction("destroy", CScript::rDestroy, CScript::cClassNull); // Initializes the class FILE. InitClassFILE(); diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 1747e5c..b5af5c3 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -256,6 +256,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "progfunc" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt"); if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); + if ( strcmp(token, "research" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/research.txt"); if ( strcmp(token, "destroy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/destroy.txt"); if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt"); if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt"); @@ -382,6 +383,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "progfunc" ) == 0 ) return true; if ( strcmp(token, "busy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; + if ( strcmp(token, "research" ) == 0 ) return true; if ( strcmp(token, "destroy" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; @@ -474,6 +476,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "progfunc" ) == 0 ) return "progfunc ( funcname );"; if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );"; if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat, program );"; + if ( strcmp(token, "research" ) == 0 ) return "object.research ( type );"; if ( strcmp(token, "destroy" ) == 0 ) return "object.destroy ( );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index e2fb302..3c04575 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -86,6 +86,11 @@ CBotTypResult CScript::cOneFloat(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } +CBotTypResult CScript::cClassOneFloat(CBotVar* thisclass, CBotVar* &var) +{ + return CScript::cOneFloat(var, nullptr); +} + // Compiling a procedure with two real numbers. CBotTypResult CScript::cTwoFloat(CBotVar* &var, void* user) @@ -534,6 +539,7 @@ bool CScript::rProgFunc(CBotVar* var, CBotVar* result, int& exception, void* use return true; } + // Compilation of instruction "object.busy()" CBotTypResult CScript::cBusy(CBotVar* thisclass, CBotVar* &var) { @@ -619,7 +625,7 @@ bool CScript::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e } -// Compilation of instruction "object.factory(cat)" +// Compilation of instruction "object.factory(cat, program)" CBotTypResult CScript::cFactory(CBotVar* thisclass, CBotVar* &var) { @@ -635,7 +641,7 @@ CBotTypResult CScript::cFactory(CBotVar* thisclass, CBotVar* &var) return CBotTypResult(CBotTypFloat); } -// Instruction "object.factory(cat)" +// Instruction "object.factory(cat, program)" bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) { @@ -812,6 +818,88 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e return true; } +// Instruction "object.research(type)" + +bool CScript::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) +{ + Error err; + + exception = 0; + + ResearchType type = static_cast(var->GetValInt()); + + CBotVar* classVars = thisclass->GetItemList(); // "category" + ObjectType thisType = static_cast(classVars->GetValInt()); + classVars = classVars->GetNext(); // "position" + classVars = classVars->GetNext(); // "orientation" + classVars = classVars->GetNext(); // "pitch" + classVars = classVars->GetNext(); // "roll" + classVars = classVars->GetNext(); // "energyLevel" + classVars = classVars->GetNext(); // "shieldLevel" + classVars = classVars->GetNext(); // "temperature" + classVars = classVars->GetNext(); // "altitude" + classVars = classVars->GetNext(); // "lifeTime" + classVars = classVars->GetNext(); // "material" + classVars = classVars->GetNext(); // "energyCell" + classVars = classVars->GetNext(); // "load" + classVars = classVars->GetNext(); // "id" + int rank = classVars->GetValInt(); + CObject* center = CObjectManager::GetInstancePointer()->SearchInstance(rank); + CAuto* automat = center->GetAuto(); + + if ( thisType == OBJECT_RESEARCH || + thisType == OBJECT_LABO ) + { + bool ok = false; + if ( type == RESEARCH_iPAW || + type == RESEARCH_iGUN ) + { + if ( thisType != OBJECT_LABO ) + err = ERR_WRONG_OBJ; + else + ok = true; + } + else + { + if ( thisType != OBJECT_RESEARCH ) + err = ERR_WRONG_OBJ; + else + ok = true; + } + if ( ok ) + { + bool bEnable = ( g_researchEnable & type ); + if ( bEnable ) + { + if ( automat != nullptr ) + { + err = automat->StartAction(type); + } + else + err = ERR_GENERIC; + } + else + err = ERR_BUILD_DISABLED; + } + } + else + err = ERR_WRONG_OBJ; + + if ( err != ERR_OK ) + { + result->SetValInt(err); // return error +//TODO: if ( script->m_errMode == ERM_STOP ) + if( true ) + { + exception = err; + return false; + } + return true; + } + + return true; +} + // Compilation of the instruction "delete(rank[, exploType[, force]])". CBotTypResult CScript::cDelete(CBotVar* &var, void* user) diff --git a/src/script/script.h b/src/script/script.h index 1c02daf..74b81df 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -196,9 +196,11 @@ public: static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var); static CBotTypResult cFactory(CBotVar* thisclass, CBotVar* &var); static CBotTypResult cClassNull(CBotVar* thisclass, CBotVar* &var); + static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var); static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); + static bool rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); static bool rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); private: -- cgit v1.2.3-1-g7c22 From 1cd0bc3152894e1d6a5c542a02ff0348e71b3699 Mon Sep 17 00:00:00 2001 From: adiblol Date: Sat, 25 May 2013 23:18:27 +0200 Subject: Resizing is fully functional so it can be enabled by default. --- src/graphics/core/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index 41d7796..b714358 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -72,7 +72,7 @@ struct DeviceConfig size = Math::IntPoint(800, 600); bpp = 32; fullScreen = false; - resizeable = false; + resizeable = true; doubleBuf = true; noFrame = false; } -- cgit v1.2.3-1-g7c22 From ff101c6973baeac63f8027118d4dad644354d869 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 10:23:30 +0200 Subject: Fix for #213 Was caused by invalid options for getopt --- src/app/app.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 87b9e39..ed76c69 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -234,7 +234,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) { "language", required_argument, nullptr, OPT_LANGUAGE }, { "langdir", required_argument, nullptr, OPT_LANGDIR }, { "vbo", required_argument, nullptr, OPT_VBO }, - { "texpack", required_argument, nullptr, OPT_TEXPACK } + { "texpack", required_argument, nullptr, OPT_TEXPACK }, + { nullptr, 0, nullptr, 0} }; opterr = 0; -- cgit v1.2.3-1-g7c22 From b41957f2f95d8f62817705a1c82322d9463d28a2 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 11:34:53 +0200 Subject: Corrected some valgrind issues * fixed several uninitialized variable issues * fixed possible memory corruption in CEngine --- src/graphics/engine/engine.cpp | 3 ++- src/graphics/opengl/gldevice.cpp | 13 +++++++++++-- src/graphics/opengl/gldevice.h | 2 ++ src/object/robotmain.cpp | 2 +- src/ui/maindialog.cpp | 3 +++ 5 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 5bd51fe..b697a37 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -998,7 +998,8 @@ void CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name) continue; // already new EngineBaseObjTexTier& newP2 = AddLevel2(p1, p2.tex1Name, tex2Name); - newP2.next.swap(p2.next); + newP2.next.insert(newP2.next.end(), p2.next.begin(), p2.next.end()); + p2.next.clear(); } } diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index f351f22..9d5abc3 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -653,7 +653,7 @@ void CGLDevice::SetTexture(int index, const Texture &texture) glBindTexture(GL_TEXTURE_2D, texture.id); // Params need to be updated for the new bound texture - SetTextureStageParams(index, m_textureStageParams[index]); + UpdateTextureParams(index); } void CGLDevice::SetTexture(int index, unsigned int textureId) @@ -674,7 +674,7 @@ void CGLDevice::SetTexture(int index, unsigned int textureId) glBindTexture(GL_TEXTURE_2D, textureId); // Params need to be updated for the new bound texture - SetTextureStageParams(index, m_textureStageParams[index]); + UpdateTextureParams(index); } /** @@ -727,6 +727,13 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶m // Remember the settings m_textureStageParams[index] = params; + UpdateTextureParams(index); +} + +void CGLDevice::UpdateTextureParams(int index) +{ + assert(index >= 0 && index < static_cast( m_currentTextures.size() )); + if (!m_multitextureAvailable && index != 0) return; @@ -734,6 +741,8 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶m if (! m_currentTextures[index].Valid()) return; + const TextureStageParams ¶ms = m_textureStageParams[index]; + if (m_multitextureAvailable) glActiveTexture(GL_TEXTURE0 + index); diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h index fe3f2a1..6f956cf 100644 --- a/src/graphics/opengl/gldevice.h +++ b/src/graphics/opengl/gldevice.h @@ -192,6 +192,8 @@ private: void UpdateModelviewMatrix(); //! Updates position for given light based on transformation matrices void UpdateLightPosition(int index); + //! Updates the texture params for given texture stage + void UpdateTextureParams(int index); private: //! Current config diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 15250c6..47c8d7f 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -2116,7 +2116,7 @@ void CRobotMain::FlushDisplayInfo() m_infoFilename[i][0] = 0; m_infoPos[i] = 0; } - strcpy(m_infoFilename[SATCOM_OBJECT], "help/") + m_app->GetLanguageChar() + std::string("/objects.txt"); + strcpy(m_infoFilename[SATCOM_OBJECT], "objects.txt"); m_infoIndex = 0; } diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 30538f3..14c1e82 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5046,6 +5046,9 @@ void CMainDialog::UpdateSceneResume(int rank) { for ( i=0 ; i<500 ; i++ ) { + if (line[i] == 0) + break; + if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space if ( line[i] == '/' && line[i+1] == '/' ) { -- cgit v1.2.3-1-g7c22 From 8f6fd2a1316432970f1d86515819e7bbe15ddab3 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 14:50:23 +0200 Subject: Changes in texture code & refactoring * refactored and altered slightly the texture pack code * added flushing of texture cache * some refactoring and const-correctness in CApplication methods --- src/app/app.cpp | 154 ++++++++++++++++++++++++----------------- src/app/app.h | 71 ++++++++++--------- src/graphics/engine/engine.cpp | 85 ++++++++++++----------- src/graphics/engine/engine.h | 11 ++- 4 files changed, 173 insertions(+), 148 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index ed76c69..932e61e 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -146,25 +146,24 @@ CApplication::CApplication() m_dataPath = COLOBOT_DEFAULT_DATADIR; m_langPath = COLOBOT_I18N_DIR; + m_texPackPath = ""; m_language = LANGUAGE_ENV; - m_texPack = ""; - m_lowCPU = true; for (int i = 0; i < DIR_MAX; ++i) - m_dataDirs[i] = nullptr; + m_standardDataDirs[i] = nullptr; - m_dataDirs[DIR_AI] = "ai"; - m_dataDirs[DIR_FONT] = "fonts"; - m_dataDirs[DIR_HELP] = "help"; - m_dataDirs[DIR_ICON] = "icons"; - m_dataDirs[DIR_LEVEL] = "levels"; - m_dataDirs[DIR_MODEL] = "models"; - m_dataDirs[DIR_MUSIC] = "music"; - m_dataDirs[DIR_SOUND] = "sounds"; - m_dataDirs[DIR_TEXTURE] = "textures"; + m_standardDataDirs[DIR_AI] = "ai"; + m_standardDataDirs[DIR_FONT] = "fonts"; + m_standardDataDirs[DIR_HELP] = "help"; + m_standardDataDirs[DIR_ICON] = "icons"; + m_standardDataDirs[DIR_LEVEL] = "levels"; + m_standardDataDirs[DIR_MODEL] = "models"; + m_standardDataDirs[DIR_MUSIC] = "music"; + m_standardDataDirs[DIR_SOUND] = "sounds"; + m_standardDataDirs[DIR_TEXTURE] = "textures"; } CApplication::~CApplication() @@ -272,7 +271,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n"); GetLogger()->Message(" -langdir path set custom language directory path\n"); GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n"); - GetLogger()->Message(" -texpack name set texture pack\n"); + GetLogger()->Message(" -texpack path set path to custom texture pack\n"); return PARSE_ARGS_HELP; } case OPT_DEBUG: @@ -286,6 +285,18 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str()); break; } + case OPT_LANGDIR: + { + m_langPath = optarg; + GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str()); + break; + } + case OPT_TEXPACK: + { + m_texPackPath = optarg; + GetLogger()->Info("Using texturepack: '%s'\n", m_texPackPath.c_str()); + break; + } case OPT_LOGLEVEL: { LogLevel logLevel; @@ -312,12 +323,6 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) m_language = language; break; } - case OPT_LANGDIR: - { - m_langPath = optarg; - GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str()); - break; - } case OPT_VBO: { std::string vbo; @@ -336,12 +341,6 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) break; } - case OPT_TEXPACK: - { - m_texPack = optarg; - GetLogger()->Info("Using texturepack: '%s'\n", m_texPack.c_str()); - break; - } default: assert(false); // should never get here } @@ -394,20 +393,27 @@ bool CApplication::Create() m_sound->Create(true); // Cache sound files - if (defaultValues) { + if (defaultValues) + { GetProfile().SetLocalProfileString("Resources", "Sound", GetDataSubdirPath(DIR_SOUND)); GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC)); } - if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) { + if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) + { m_sound->CacheAll(path); - } else { + } + else + { m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND)); } - if (GetProfile().GetLocalProfileString("Resources", "Music", path)) { + if (GetProfile().GetLocalProfileString("Resources", "Music", path)) + { m_sound->AddMusicFiles(path); - } else { + } + else + { m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC)); } @@ -496,8 +502,6 @@ bool CApplication::Create() m_engine->SetDevice(m_device); - m_engine->SetTexturePack(m_texPack); - if (! m_engine->Create() ) { m_errorMessage = std::string("Error in CEngine::Init()\n") + standardInfoMessage; @@ -970,12 +974,12 @@ end: return m_exitCode; } -int CApplication::GetExitCode() +int CApplication::GetExitCode() const { return m_exitCode; } -const std::string& CApplication::GetErrorMessage() +const std::string& CApplication::GetErrorMessage() const { return m_errorMessage; } @@ -1269,7 +1273,7 @@ void CApplication::ResumeSimulation() GetLogger()->Info("Resume simulation\n"); } -bool CApplication::GetSimulationSuspended() +bool CApplication::GetSimulationSuspended() const { return m_simulationSuspended; } @@ -1327,48 +1331,48 @@ Event CApplication::CreateUpdateEvent() return frameEvent; } -float CApplication::GetSimulationSpeed() +float CApplication::GetSimulationSpeed() const { return m_simulationSpeed; } -float CApplication::GetAbsTime() +float CApplication::GetAbsTime() const { return m_absTime; } -long long CApplication::GetExactAbsTime() +long long CApplication::GetExactAbsTime() const { return m_exactAbsTime; } -long long CApplication::GetRealAbsTime() +long long CApplication::GetRealAbsTime() const { return m_realAbsTime; } -float CApplication::GetRelTime() +float CApplication::GetRelTime() const { return m_relTime; } -long long CApplication::GetExactRelTime() +long long CApplication::GetExactRelTime() const { return m_exactRelTime; } -long long CApplication::GetRealRelTime() +long long CApplication::GetRealRelTime() const { return m_realRelTime; } -Gfx::GLDeviceConfig CApplication::GetVideoConfig() +Gfx::GLDeviceConfig CApplication::GetVideoConfig() const { return m_deviceConfig; } VideoQueryResult CApplication::GetVideoResolutionList(std::vector &resolutions, - bool fullScreen, bool resizeable) + bool fullScreen, bool resizeable) const { resolutions.clear(); @@ -1415,27 +1419,27 @@ void CApplication::SetDebugMode(bool mode) m_debugMode = mode; } -bool CApplication::GetDebugMode() +bool CApplication::GetDebugMode() const { return m_debugMode; } -int CApplication::GetKmods() +int CApplication::GetKmods() const { return m_kmodState; } -bool CApplication::GetKmodState(int kmod) +bool CApplication::GetKmodState(int kmod) const { return (m_kmodState & kmod) != 0; } -bool CApplication::GetTrackedKeyState(TrackedKey key) +bool CApplication::GetTrackedKeyState(TrackedKey key) const { return (m_trackedKeys & key) != 0; } -bool CApplication::GetMouseButtonState(int index) +bool CApplication::GetMouseButtonState(int index) const { return (m_mouseButtonsState & (1< CApplication::GetJoystickList() +std::vector CApplication::GetJoystickList() const { std::vector result; @@ -1503,7 +1507,7 @@ std::vector CApplication::GetJoystickList() return result; } -JoystickDevice CApplication::GetJoystick() +JoystickDevice CApplication::GetJoystick() const { return m_joystick; } @@ -1525,36 +1529,37 @@ void CApplication::SetJoystickEnabled(bool enable) } } -bool CApplication::GetJoystickEnabled() +bool CApplication::GetJoystickEnabled() const { return m_joystickEnabled; } -std::string CApplication::GetDataDirPath() +std::string CApplication::GetDataDirPath() const { return m_dataPath; } -std::string CApplication::GetDataSubdirPath(DataDir stdDir) +std::string CApplication::GetDataSubdirPath(DataDir stdDir) const { int index = static_cast(stdDir); assert(index >= 0 && index < DIR_MAX); std::stringstream str; str << m_dataPath; str << "/"; - str << m_dataDirs[index]; + str << m_standardDataDirs[index]; return str.str(); } -std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath) +std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath) const { int index = static_cast(stdDir); assert(index >= 0 && index < DIR_MAX); std::stringstream str; str << m_dataPath; str << "/"; - str << m_dataDirs[index]; - if (stdDir == DIR_HELP) { + str << m_standardDataDirs[index]; + if (stdDir == DIR_HELP) + { str << "/"; str << GetLanguageChar(); } @@ -1563,12 +1568,31 @@ std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& sub return str.str(); } -Language CApplication::GetLanguage() +std::string CApplication::GetTexPackFilePath(const std::string& textureName) const +{ + std::stringstream str; + + if (! m_texPackPath.empty()) + { + str << m_texPackPath; + str << "/"; + str << textureName; + if (! boost::filesystem::exists(str.str())) + { + GetLogger()->Trace("Texture '%s' not in texpack\n", textureName.c_str()); + str.str(""); + } + } + + return str.str(); +} + +Language CApplication::GetLanguage() const { return m_language; } -char CApplication::GetLanguageChar() +char CApplication::GetLanguageChar() const { char langChar = 'E'; switch (m_language) @@ -1703,7 +1727,7 @@ void CApplication::SetLowCPU(bool low) m_lowCPU = low; } -bool CApplication::GetLowCPU() +bool CApplication::GetLowCPU() const { return m_lowCPU; } @@ -1718,7 +1742,7 @@ void CApplication::StopPerformanceCounter(PerformanceCounter counter) GetSystemUtils()->GetCurrentTimeStamp(m_performanceCounters[counter][1]); } -float CApplication::GetPerformanceCounterData(PerformanceCounter counter) +float CApplication::GetPerformanceCounterData(PerformanceCounter counter) const { return m_performanceCountersData[counter]; } diff --git a/src/app/app.h b/src/app/app.h index 073ac97..34028c7 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -209,20 +209,20 @@ public: //! Main event loop int Run(); //! Returns the code to be returned at main() exit - int GetExitCode(); + int GetExitCode() const; //! Returns the message of error (set to something if exit code is not 0) - const std::string& GetErrorMessage(); + const std::string& GetErrorMessage() const; //! Cleans up before exit void Destroy(); //! Returns a list of possible video modes VideoQueryResult GetVideoResolutionList(std::vector &resolutions, - bool fullScreen, bool resizeable); + bool fullScreen, bool resizeable) const; //! Returns the current video mode - Gfx::GLDeviceConfig GetVideoConfig(); + Gfx::GLDeviceConfig GetVideoConfig() const; //! Change the video mode to given mode bool ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig); @@ -232,35 +232,35 @@ public: //! Resumes animation void ResumeSimulation(); //! Returns whether simulation is suspended - bool GetSimulationSuspended(); + bool GetSimulationSuspended() const; //@{ //! Management of simulation speed void SetSimulationSpeed(float speed); - float GetSimulationSpeed(); + float GetSimulationSpeed() const; //@} //! Returns the absolute time counter [seconds] - float GetAbsTime(); + float GetAbsTime() const; //! Returns the exact absolute time counter [nanoseconds] - long long GetExactAbsTime(); + long long GetExactAbsTime() const; //! Returns the exact absolute time counter disregarding speed setting [nanoseconds] - long long GetRealAbsTime(); + long long GetRealAbsTime() const; //! Returns the relative time since last update [seconds] - float GetRelTime(); + float GetRelTime() const; //! Returns the exact realative time since last update [nanoseconds] - long long GetExactRelTime(); + long long GetExactRelTime() const; //! Returns the exact relative time since last update disregarding speed setting [nanoseconds] - long long GetRealRelTime(); + long long GetRealRelTime() const; //! Returns a list of available joystick devices - std::vector GetJoystickList(); + std::vector GetJoystickList() const; //! Returns info about the current joystick - JoystickDevice GetJoystick(); + JoystickDevice GetJoystick() const; //! Change the current joystick device bool ChangeJoystick(const JoystickDevice &newJoystick); @@ -268,7 +268,7 @@ public: //! Management of joystick enable state //@{ void SetJoystickEnabled(bool enable); - bool GetJoystickEnabled(); + bool GetJoystickEnabled() const; //@} //! Polls the state of joystick axes and buttons @@ -278,15 +278,15 @@ public: void UpdateMouse(); //! Returns the current key modifiers - int GetKmods(); + int GetKmods() const; //! Returns whether the given kmod is active - bool GetKmodState(int kmod); + bool GetKmodState(int kmod) const; //! Returns whether the tracked key is pressed - bool GetTrackedKeyState(TrackedKey key); + bool GetTrackedKeyState(TrackedKey key) const; //! Returns whether the mouse button is pressed - bool GetMouseButtonState(int index); + bool GetMouseButtonState(int index) const; //! Resets tracked key states and modifiers void ResetKeyStates(); @@ -294,17 +294,17 @@ public: //! Management of the grab mode for input (keyboard & mouse) //@{ void SetGrabInput(bool grab); - bool GetGrabInput(); + bool GetGrabInput() const; //@} //! Management of mouse mode //@{ void SetMouseMode(MouseMode mode); - MouseMode GetMouseMode(); + MouseMode GetMouseMode() const; //@} //! Returns the position of mouse cursor (in interface coords) - Math::Point GetMousePos(); + Math::Point GetMousePos() const; //! Moves (warps) the mouse cursor to the specified position (in interface coords) void MoveMouse(Math::Point pos); @@ -312,22 +312,25 @@ public: //! Management of debug mode (prints more info in logger) //@{ void SetDebugMode(bool mode); - bool GetDebugMode(); + bool GetDebugMode() const; //@} //! Returns the full path to data directory - std::string GetDataDirPath(); + std::string GetDataDirPath() const; //! Returns the full path to a standard dir in data directory - std::string GetDataSubdirPath(DataDir stdDir); + std::string GetDataSubdirPath(DataDir stdDir) const; //! Returns the full path to a file in data directory given standard dir and subpath - std::string GetDataFilePath(DataDir stdDir, const std::string &subpath); + std::string GetDataFilePath(DataDir stdDir, const std::string &subpath) const; + + //! Returns the full path to a file in texture pack directory + std::string GetTexPackFilePath(const std::string& textureName) const; //! Management of language //@{ - Language GetLanguage(); - char GetLanguageChar(); + Language GetLanguage() const; + char GetLanguageChar() const; void SetLanguage(Language language); static bool ParseLanguage(const std::string& str, Language& language); //@} @@ -335,14 +338,14 @@ public: //! Management of sleep in main loop (lowers CPU usage) //@{ void SetLowCPU(bool low); - bool GetLowCPU(); + bool GetLowCPU() const; //@} //! Management of performance counters //@{ void StartPerformanceCounter(PerformanceCounter counter); void StopPerformanceCounter(PerformanceCounter counter); - float GetPerformanceCounterData(PerformanceCounter counter); + float GetPerformanceCounterData(PerformanceCounter counter) const; //@} protected: @@ -462,14 +465,14 @@ protected: //! Path to directory with language files std::string m_langPath; - const char* m_dataDirs[DIR_MAX]; + //! Path to directory with user texture pack + std::string m_texPackPath; + + const char* m_standardDataDirs[DIR_MAX]; //! Application language Language m_language; - //! Texture pack - std::string m_texPack; - //! Low cpu mode bool m_lowCPU; }; diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index b697a37..3959c02 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -62,8 +62,6 @@ CEngine::CEngine(CApplication *app) m_sound = nullptr; m_terrain = nullptr; - m_texPack = ""; - m_showStats = false; m_focus = 0.75f; @@ -238,12 +236,6 @@ void CEngine::SetTerrain(CTerrain* terrain) m_terrain = terrain; } -void CEngine::SetTexturePack(const std::string& texpackName) -{ - m_texPack = texpackName; -} - - bool CEngine::Create() { m_size = m_app->GetVideoConfig().size; @@ -323,7 +315,7 @@ void CEngine::ResetAfterDeviceChanged() m_text->FlushCache(); - // TODO reload textures, reset device state, etc. + FlushTextureCache(); } bool CEngine::ProcessEvent(const Event &event) @@ -2117,7 +2109,7 @@ void CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector& looka m_sound->SetListener(eyePt, lookatPt); } -Texture CEngine::CreateTexture(const std::string& texName, const TextureCreateParams& params, CImage* image, std::string orginalName) +Texture CEngine::CreateTexture(const std::string& texName, const TextureCreateParams& params, CImage* image) { if (texName.empty()) return Texture(); // invalid texture @@ -2126,39 +2118,53 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa return Texture(); // invalid texture Texture tex; + CImage img; if (image == nullptr) { - CImage img; - if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName))) + bool loadedFromTexPack = false; + + std::string texPackName = m_app->GetTexPackFilePath(texName); + if (! texPackName.empty()) { - std::string error = img.GetError(); - if(orginalName == "") GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); - m_texBlacklist.insert(texName); - return Texture(); // invalid texture + if (img.Load(texPackName)) + { + loadedFromTexPack = true; + } + else + { + std::string error = img.GetError(); + GetLogger()->Error("Couldn't load texture '%s' from texpack: %s, blacklisting the texpack path\n", + texName.c_str(), error.c_str()); + m_texBlacklist.insert(texPackName); + } } - tex = m_device->CreateTexture(&img, params); - } - else - { - tex = m_device->CreateTexture(image, params); + if (!loadedFromTexPack) + { + if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName))) + { + std::string error = img.GetError(); + GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str()); + m_texBlacklist.insert(texName); + return Texture(); // invalid texture + } + } + + image = &img; } + tex = m_device->CreateTexture(&img, params); + if (! tex.Valid()) { - if(orginalName == "") GetLogger()->Error("Couldn't load texture '%s', blacklisting\n", texName.c_str()); + GetLogger()->Error("Couldn't load texture '%s', blacklisting\n", texName.c_str()); m_texBlacklist.insert(texName); return tex; } - if(orginalName == "") { - m_texNameMap[texName] = tex; - m_revTexNameMap[tex] = texName; - } else { - m_texNameMap[orginalName] = tex; - m_revTexNameMap[tex] = orginalName; - } + m_texNameMap[texName] = tex; + m_revTexNameMap[tex] = texName; return tex; } @@ -2183,19 +2189,7 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams& if (it != m_texNameMap.end()) return (*it).second; - Texture tex; - if (m_texPack != "") { - std::string name_texpack = m_texPack + "/" + name; - - if (m_texBlacklist.find(name_texpack) == m_texBlacklist.end()) { - tex = CreateTexture(name_texpack, params, nullptr, name); - if (tex.Valid()) - return tex; - } - } - - tex = CreateTexture(name, params); - return tex; + return CreateTexture(name, params); } bool CEngine::LoadAllTextures() @@ -2453,6 +2447,13 @@ void CEngine::DeleteTexture(const Texture& tex) m_texNameMap.erase(it); } +void CEngine::FlushTextureCache() +{ + m_texNameMap.clear(); + m_revTexNameMap.clear(); + m_texBlacklist.clear(); +} + bool CEngine::SetTexture(const std::string& name, int stage) { auto it = m_texNameMap.find(name); diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 8df912e..af8cf6a 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -726,9 +726,6 @@ public: //! Writes a screenshot containing the current frame bool WriteScreenShot(const std::string& fileName, int width, int height); - //! Set texture pack - void SetTexturePack(const std::string& texpackName); - //@{ //! Management of game pause mode @@ -961,6 +958,9 @@ public: //! Deletes the given texture, unloading it and removing from cache void DeleteTexture(const Texture& tex); + //! Empties the texture cache + void FlushTextureCache(); + //! Defines of the distance field of vision void SetTerrainVision(float vision); @@ -1233,7 +1233,7 @@ protected: const Material& mat, int state); //! Create texture and add it to cache - Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr, std::string orginalName = ""); + Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr); //! Tests whether the given object is visible bool IsVisible(int objRank); @@ -1407,9 +1407,6 @@ protected: * so are disabled for subsequent load calls. */ std::set m_texBlacklist; - //! Texture pack - std::string m_texPack; - //! Mouse cursor definitions EngineMouse m_mice[ENG_MOUSE_COUNT]; //! Texture with mouse cursors -- cgit v1.2.3-1-g7c22 From cc2e192f0d71a48d211fe47d6eb07419aac810c3 Mon Sep 17 00:00:00 2001 From: adiblol Date: Sun, 26 May 2013 18:40:25 +0200 Subject: Reorganize string parsing in CBotToken::NextToken to fix #212 --- src/CBot/CBotToken.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp index f03ca91..7c00e87 100644 --- a/src/CBot/CBotToken.cpp +++ b/src/CBot/CBotToken.cpp @@ -248,17 +248,15 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, bool first) { while (c != 0 && !CharInList(c, nch)) { - mot += c; - c = *(program++); // next character if ( c == '\\' ) { c = *(program++); // next character if ( c == 'n' ) c = '\n'; if ( c == 'r' ) c = '\r'; if ( c == 't' ) c = '\t'; - mot += c; - c = *(program++); // next character } + mot += c; + c = *(program++); } if ( c == '\"' ) { -- cgit v1.2.3-1-g7c22 From 538745a731d07facd7a1574c04a5d34d23ce3bfa Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 17:45:15 +0200 Subject: Fixed some compilation warnings * fixed warnings about hiding virtual functions and several others --- src/object/auto/autoinfo.cpp | 4 ++-- src/object/auto/autojostle.cpp | 5 +++++ src/object/auto/autojostle.h | 4 +++- src/object/brain.cpp | 2 +- src/script/script.cpp | 8 ++++---- src/ui/list.cpp | 14 +++++++++++--- src/ui/list.h | 11 +++++++---- src/ui/maindialog.cpp | 36 ++++++++++++++++++------------------ src/ui/studio.cpp | 4 ++-- src/ui/window.cpp | 4 ++-- src/ui/window.h | 2 +- 11 files changed, 56 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp index 56c21d2..e8f31c8 100644 --- a/src/object/auto/autoinfo.cpp +++ b/src/object/auto/autoinfo.cpp @@ -428,7 +428,7 @@ void CAutoInfo::UpdateList() { info = m_object->GetInfo(i); sprintf(text, "%s = %.2f", info.name, info.value); - pl->SetName(i, text); + pl->SetItemName(i, text); } } @@ -466,7 +466,7 @@ void CAutoInfo::UpdateListVirus() } text[j] = 0; - pl->SetName(i, text); + pl->SetItemName(i, text); } } diff --git a/src/object/auto/autojostle.cpp b/src/object/auto/autojostle.cpp index 11952c2..df82ad5 100644 --- a/src/object/auto/autojostle.cpp +++ b/src/object/auto/autojostle.cpp @@ -77,6 +77,11 @@ void CAutoJostle::Start(int param, float force) } } +// Should never be called +void CAutoJostle::Start(int param) +{ +} + // Management of an event. diff --git a/src/object/auto/autojostle.h b/src/object/auto/autojostle.h index 7b700ad..3822421 100644 --- a/src/object/auto/autojostle.h +++ b/src/object/auto/autojostle.h @@ -37,7 +37,9 @@ public: bool EventProcess(const Event &event); Error IsEnded(); -protected: +private: + // Overriden to avoid warning about hiding virtual function + virtual void Start(int param) override; protected: float m_force; diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 56221b1..4fab449 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -2486,7 +2486,7 @@ void CBrain::UpdateScript(Ui::CWindow *pw) } } - pl->SetName(i, name); + pl->SetItemName(i, name); } if ( !bSoluce ) diff --git a/src/script/script.cpp b/src/script/script.cpp index 3c04575..3a88a8e 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -4038,7 +4038,7 @@ void PutList(const char *baseName, bool bArray, CBotVar *var, Ui::CList *list, i if ( var == 0 && baseName[0] != 0 ) { sprintf(buffer, "%s = null;", baseName); - list->SetName(rankList++, buffer); + list->SetItemName(rankList++, buffer); return; } @@ -4080,7 +4080,7 @@ void PutList(const char *baseName, bool bArray, CBotVar *var, Ui::CList *list, i value = pStatic->GetValString(); p = value; sprintf(buffer, "%s = %s;", varName, p); - list->SetName(rankList++, buffer); + list->SetItemName(rankList++, buffer); } else if ( type == CBotTypString ) { @@ -4088,7 +4088,7 @@ void PutList(const char *baseName, bool bArray, CBotVar *var, Ui::CList *list, i value = pStatic->GetValString(); p = value; sprintf(buffer, "%s = \"%s\";", varName, p); - list->SetName(rankList++, buffer); + list->SetItemName(rankList++, buffer); } else if ( type == CBotTypArrayPointer ) { @@ -4104,7 +4104,7 @@ void PutList(const char *baseName, bool bArray, CBotVar *var, Ui::CList *list, i else { sprintf(buffer, "%s = ?;", varName); - list->SetName(rankList++, buffer); + list->SetItemName(rankList++, buffer); } index ++; diff --git a/src/ui/list.cpp b/src/ui/list.cpp index fae7af9..7593582 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -88,6 +88,14 @@ bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMs return MoveAdjust(); } +// Should never be called +bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) +{ + assert(false); + return false; +} + + // Adjusted after a change of dimensions. bool CList::MoveAdjust() @@ -611,7 +619,7 @@ bool CList::GetBlink() // Specifies the text of a line. -void CList::SetName(int i, const char* name) +void CList::SetItemName(int i, const char* name) { if ( i < 0 || i >= LISTMAXTOTAL ) return; @@ -630,7 +638,7 @@ void CList::SetName(int i, const char* name) // Returns the text of a line. -char* CList::GetName(int i) +char* CList::GetItemName(int i) { if ( i < 0 || i >= m_totalLine ) return 0; @@ -808,4 +816,4 @@ void CList::MoveScroll() } -} +} // namespace Ui diff --git a/src/ui/list.h b/src/ui/list.h index 97bd48c..3d2e517 100644 --- a/src/ui/list.h +++ b/src/ui/list.h @@ -69,8 +69,8 @@ class CList : public CControl void SetBlink(bool bEnable); bool GetBlink(); - void SetName(int i, const char* name); - char* GetName(int i); + void SetItemName(int i, const char* name); + char* GetItemName(int i); void SetCheck(int i, bool bMode); bool GetCheck(int i); @@ -93,6 +93,10 @@ class CList : public CControl void MoveScroll(); void DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif); + private: + // Overridden to avoid warning about hiding the virtual function + virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) override; + protected: CButton* m_button[LISTMAXDISPLAY]; CScroll* m_scroll; @@ -117,5 +121,4 @@ class CList : public CControl }; -} - +} // namespace Ui diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 14c1e82..696c156 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -199,7 +199,7 @@ CMainDialog::~CMainDialog() void CMainDialog::ChangePhase(Phase phase) { - CWindow* pw; + CWindow* pw = nullptr; CEdit* pe; CEditValue* pv; CLabel* pl; @@ -2310,7 +2310,7 @@ bool CMainDialog::EventProcess(const Event &event) if ( pw == 0 ) break; pl = static_cast(pw->SearchControl(EVENT_INTERFACE_NLIST)); if ( pl == 0 ) break; - StartDeleteGame(pl->GetName(pl->GetSelect())); + StartDeleteGame(pl->GetItemName(pl->GetSelect())); break; default: @@ -3688,7 +3688,7 @@ void CMainDialog::ReadNameList() for (size_t i=0 ; iSetName(i, fileNames.at(i).c_str()); + pl->SetItemName(i, fileNames.at(i).c_str()); } } @@ -3764,7 +3764,7 @@ void CMainDialog::UpdateNameList() for ( i=0 ; iGetName(i)) == 0 ) + if ( strcmp(name, pl->GetItemName(i)) == 0 ) { pl->SetSelect(i); pl->ShowSelect(false); @@ -3800,7 +3800,7 @@ void CMainDialog::UpdateNameEdit() } else { - name = pl->GetName(sel); + name = pl->GetItemName(sel); pe->SetText(name); pe->SetCursor(strlen(name), 0); } @@ -3824,7 +3824,7 @@ void CMainDialog::UpdateNameFace() sel = pl->GetSelect(); if ( sel == -1 ) return; - name = pl->GetName(sel); + name = pl->GetItemName(sel); ReadGamerPerso(name); } @@ -3855,7 +3855,7 @@ void CMainDialog::NameSelect() } else { - m_main->SetGamerName(pl->GetName(sel)); + m_main->SetGamerName(pl->GetItemName(sel)); m_main->ChangePhase(PHASE_INIT); } @@ -3982,7 +3982,7 @@ void CMainDialog::NameDelete() m_sound->Play(SOUND_TZOING); return; } - gamer = pl->GetName(sel); + gamer = pl->GetItemName(sel); // Deletes all the contents of the file. sprintf(dir, "%s/%s", m_savegameDir.c_str(), gamer); @@ -4417,7 +4417,7 @@ void CMainDialog::IOReadList() } fclose(file); - pl->SetName(m_saveList.size(), name); + pl->SetItemName(m_saveList.size(), name); m_saveList.push_back(dir_iter->path()); } } @@ -4426,7 +4426,7 @@ void CMainDialog::IOReadList() // zly indeks if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs ) { GetResource(RES_TEXT, RT_IO_NEW, name); - pl->SetName(m_saveList.size(), name); + pl->SetItemName(m_saveList.size(), name); } pl->SetSelect(m_saveList.size()); @@ -4505,7 +4505,7 @@ void CMainDialog::IODeleteScene() } } catch (std::exception & e) { - GetLogger()->Error("Error removing save %s : %s\n", pl->GetName(sel), e.what()); + GetLogger()->Error("Error removing save %s : %s\n", pl->GetItemName(sel), e.what()); } IOReadList(); @@ -4754,7 +4754,7 @@ void CMainDialog::UpdateSceneChap(int &chap) fclose(file); } - pl->SetName(j, name); + pl->SetItemName(j, name); pl->SetEnable(j, true); } } @@ -4807,7 +4807,7 @@ void CMainDialog::UpdateSceneChap(int &chap) bPassed = GetGamerInfoPassed((j+1)*100); sprintf(line, "%d: %s", j+1, name); - pl->SetName(j, line); + pl->SetItemName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); @@ -4917,7 +4917,7 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) bPassed = GetGamerInfoPassed((chap+1)*100+(j+1)); sprintf(line, "%d: %s", j+1, name); - pl->SetName(j, line); + pl->SetItemName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); @@ -5099,7 +5099,7 @@ void CMainDialog::UpdateDisplayDevice() j = 0; while ( bufDevices[i] != 0 ) { - pl->SetName(j++, bufDevices+i); + pl->SetItemName(j++, bufDevices+i); while ( bufDevices[i++] != 0 ); } @@ -5129,7 +5129,7 @@ void CMainDialog::UpdateDisplayMode() for (Math::IntPoint mode : modes) { mode_text.str(""); mode_text << mode.x << "x" << mode.y; - pl->SetName(i++, mode_text.str().c_str()); + pl->SetItemName(i++, mode_text.str().c_str()); } pl->SetSelect(m_setupSelMode); @@ -5153,12 +5153,12 @@ void CMainDialog::ChangeDisplay() pl = static_cast(pw->SearchControl(EVENT_LIST1)); if ( pl == 0 ) return; m_setupSelDevice = pl->GetSelect(); - //device = pl->GetName(m_setupSelDevice); + //device = pl->GetItemName(m_setupSelDevice); pl = static_cast(pw->SearchControl(EVENT_LIST2)); if ( pl == 0 ) return; m_setupSelMode = pl->GetSelect(); - //mode = pl->GetName(m_setupSelMode); + //mode = pl->GetItemName(m_setupSelMode); pc = static_cast(pw->SearchControl(EVENT_INTERFACE_FULL)); if ( pc == 0 ) return; diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 52a0ddc..5027924 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1397,7 +1397,7 @@ void CStudio::UpdateChangeList() pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe == nullptr ) return; - strcpy(name, pl->GetName(pl->GetSelect())); + strcpy(name, pl->GetItemName(pl->GetSelect())); name[pe->GetMaxChar()] = 0; // truncates according lg max editable p = strchr(name, '\t'); // seeks first tab if ( p != 0 ) *p = 0; @@ -1526,7 +1526,7 @@ void CStudio::UpdateDialogList() std::ostringstream temp; TimeToAscii(fs::last_write_time(file->path()), time); temp << file->path().filename().string() << '\t' << fs::file_size(file->path()) << " \t" << time; - pl->SetName(i++, temp.str().c_str()); + pl->SetItemName(i++, temp.str().c_str()); } } } diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 69ef857..1820642 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -576,12 +576,12 @@ bool CWindow::GetTooltip(Math::Point pos, std::string &name) // Specifies the name for the title bar. -void CWindow::SetName(std::string name) +void CWindow::SetName(std::string name, bool tooltip) { CButton* pc; bool bAdjust; - CControl::SetName(name); + CControl::SetName(name, tooltip); if ( m_buttonReduce != 0 ) { diff --git a/src/ui/window.h b/src/ui/window.h index e39b8a9..6cb6e5d 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -83,7 +83,7 @@ public: EventType GetEventTypeFull(); EventType GetEventTypeClose(); - void SetName(std::string name); + virtual void SetName(std::string name, bool tooltip = true) override; void SetTrashEvent(bool bTrash); bool GetTrashEvent(); -- cgit v1.2.3-1-g7c22 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 imdiatement 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 From 950a3474d561c48b70a13fb638f169b7e8b34d60 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 26 May 2013 19:34:05 +0200 Subject: Refactored sound code * fixed formatting and naming to be uniform with rest of code * moved default implementation of CSound to cpp module --- src/CMakeLists.txt | 1 + src/common/logger.cpp | 32 ++-- src/common/logger.h | 6 +- src/graphics/engine/engine.cpp | 2 + src/object/robotmain.cpp | 1 + src/sound/README.txt | 1 + src/sound/oalsound/alsound.cpp | 399 +++++++++++++++++++++++++---------------- src/sound/oalsound/alsound.h | 146 +++++++-------- src/sound/oalsound/buffer.cpp | 64 ++++--- src/sound/oalsound/buffer.h | 48 ++--- src/sound/oalsound/channel.cpp | 236 ++++++++++++++---------- src/sound/oalsound/channel.h | 152 ++++++++-------- src/sound/oalsound/check.h | 1 + src/sound/sound.cpp | 191 ++++++++++++++++++++ src/sound/sound.h | 93 ++++------ 15 files changed, 847 insertions(+), 526 deletions(-) create mode 100644 src/sound/sound.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5980d32..6318ef2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,6 +155,7 @@ physics/physics.cpp script/cbottoken.cpp script/cmdtoken.cpp script/script.cpp +sound/sound.cpp ui/button.cpp ui/check.cpp ui/color.cpp diff --git a/src/common/logger.cpp b/src/common/logger.cpp index 8bc4cef..a02854d 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -25,8 +25,8 @@ template<> CLogger* CSingleton::m_instance = nullptr; CLogger::CLogger() { - mFile = NULL; - mLogLevel = LOG_INFO; + m_file = NULL; + m_logLevel = LOG_INFO; } @@ -38,31 +38,31 @@ CLogger::~CLogger() void CLogger::Log(LogLevel type, const char* str, va_list args) { - if (type < mLogLevel) + if (type < m_logLevel) return; switch (type) { case LOG_TRACE: - fprintf(IsOpened() ? mFile : stderr, "[TRACE]: "); + fprintf(IsOpened() ? m_file : stderr, "[TRACE]: "); break; case LOG_DEBUG: - fprintf(IsOpened() ? mFile : stderr, "[DEBUG]: "); + fprintf(IsOpened() ? m_file : stderr, "[DEBUG]: "); break; case LOG_WARN: - fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); + fprintf(IsOpened() ? m_file : stderr, "[WARN]: "); break; case LOG_INFO: - fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); + fprintf(IsOpened() ? m_file : stderr, "[INFO]: "); break; case LOG_ERROR: - fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); + fprintf(IsOpened() ? m_file : stderr, "[ERROR]: "); break; default: break; } - vfprintf(IsOpened() ? mFile : stderr, str, args); + vfprintf(IsOpened() ? m_file : stderr, str, args); } @@ -122,36 +122,36 @@ void CLogger::Message(const char* str, ...) void CLogger::SetOutputFile(std::string filename) { - mFilename = filename; + m_filename = filename; Open(); } void CLogger::Open() { - mFile = fopen(mFilename.c_str(), "w"); + m_file = fopen(m_filename.c_str(), "w"); - if (mFile == NULL) - fprintf(stderr, "Could not create file %s\n", mFilename.c_str()); + if (m_file == NULL) + fprintf(stderr, "Could not create file %s\n", m_filename.c_str()); } void CLogger::Close() { if (IsOpened()) - fclose(mFile); + fclose(m_file); } bool CLogger::IsOpened() { - return mFile != NULL; + return m_file != NULL; } void CLogger::SetLogLevel(LogLevel type) { - mLogLevel = type; + m_logLevel = type; } diff --git a/src/common/logger.h b/src/common/logger.h index 83a915c..1a5f3b9 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -113,9 +113,9 @@ public: static bool ParseLogLevel(const std::string& str, LogLevel& logLevel); private: - std::string mFilename; - FILE *mFile; - LogLevel mLogLevel; + std::string m_filename; + FILE *m_file; + LogLevel m_logLevel; void Open(); void Close(); diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 0faddbb..4d0687a 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -42,6 +42,8 @@ #include "ui/interface.h" +#include + template<> Gfx::CEngine* CSingleton::m_instance = nullptr; // Graphics module namespace diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 3cd8384..34f13f6 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -79,6 +79,7 @@ #include "ui/slider.h" #include "ui/window.h" +#include template<> CRobotMain* CSingleton::m_instance = nullptr; diff --git a/src/sound/README.txt b/src/sound/README.txt index fa2f531..f0ccb9e 100644 --- a/src/sound/README.txt +++ b/src/sound/README.txt @@ -2,3 +2,4 @@ * \dir src/sound * \brief Sound module - playing sounds and music */ + diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index c50f6ec..992b8b2 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -16,19 +16,22 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include "alsound.h" +#include "sound/oalsound/alsound.h" -#define MIN(a, b) (a > b ? b : a) +#include +#include + +#include ALSound::ALSound() { - mEnabled = false; - m3D = false; - mAudioVolume = 1.0f; - mMusicVolume = 1.0f; - mCurrentMusic = nullptr; - mEye.LoadZero(); - mLookat.LoadZero(); + m_enabled = false; + m_3D = false; + m_audioVolume = 1.0f; + m_musicVolume = 1.0f; + m_currentMusic = nullptr; + m_eye.LoadZero(); + m_lookat.LoadZero(); } @@ -40,31 +43,36 @@ ALSound::~ALSound() void ALSound::CleanUp() { - if (mEnabled) { + if (m_enabled) + { GetLogger()->Info("Unloading files and closing device...\n"); StopAll(); StopMusic(); - for (auto channel : mChannels) { + for (auto channel : m_channels) + { delete channel.second; } - if (mCurrentMusic) { - delete mCurrentMusic; + if (m_currentMusic) + { + delete m_currentMusic; } - for (auto item : mSounds) { + for (auto item : m_sounds) + { delete item.second; } - for (auto item : mMusic) { + for (auto item : m_music) + { delete item.second; } - mEnabled = false; + m_enabled = false; - alcDestroyContext(mContext); - alcCloseDevice(mDevice); + alcDestroyContext(m_context); + alcCloseDevice(m_device); } } @@ -73,41 +81,43 @@ bool ALSound::Create(bool b3D) { CleanUp(); - if (mEnabled) + if (m_enabled) return true; GetLogger()->Info("Opening audio device...\n"); - mDevice = alcOpenDevice(NULL); - if (!mDevice) { + m_device = alcOpenDevice(NULL); + if (!m_device) + { GetLogger()->Error("Could not open audio device!\n"); return false; } - mContext = alcCreateContext(mDevice, NULL); - if (!mContext) { + m_context = alcCreateContext(m_device, NULL); + if (!m_context) + { GetLogger()->Error("Could not create audio context!\n"); return false; } - alcMakeContextCurrent(mContext); - alListenerf(AL_GAIN, mAudioVolume); + alcMakeContextCurrent(m_context); + alListenerf(AL_GAIN, m_audioVolume); alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); - mCurrentMusic = new Channel(); + m_currentMusic = new Channel(); GetLogger()->Info("Done.\n"); - mEnabled = true; + m_enabled = true; return true; } void ALSound::SetSound3D(bool bMode) { - m3D = bMode; + m_3D = bMode; } bool ALSound::GetSound3D() { - return m3D; + return m_3D; } @@ -120,48 +130,50 @@ bool ALSound::GetSound3DCap() bool ALSound::GetEnable() { - return mEnabled; + return m_enabled; } void ALSound::SetAudioVolume(int volume) { - mAudioVolume = static_cast(volume) / MAXVOLUME; + m_audioVolume = static_cast(volume) / MAXVOLUME; } int ALSound::GetAudioVolume() { - if ( !mEnabled ) + if ( !m_enabled ) return 0; - return mAudioVolume * MAXVOLUME; + return m_audioVolume * MAXVOLUME; } void ALSound::SetMusicVolume(int volume) { - mMusicVolume = static_cast(volume) / MAXVOLUME; - if (mCurrentMusic) { - mCurrentMusic->SetVolume(mMusicVolume); + m_musicVolume = static_cast(volume) / MAXVOLUME; + if (m_currentMusic) + { + m_currentMusic->SetVolume(m_musicVolume); } } int ALSound::GetMusicVolume() { - if ( !mEnabled ) + if ( !m_enabled ) return 0.0f; - return mMusicVolume * MAXVOLUME; + return m_musicVolume * MAXVOLUME; } bool ALSound::Cache(Sound sound, std::string filename) { Buffer *buffer = new Buffer(); - if (buffer->LoadFromFile(filename, sound)) { - mSounds[sound] = buffer; + if (buffer->LoadFromFile(filename, sound)) + { + m_sounds[sound] = buffer; return true; } return false; @@ -169,12 +181,14 @@ bool ALSound::Cache(Sound sound, std::string filename) bool ALSound::CacheMusic(std::string filename) { - if(mMusic.find(filename) == mMusic.end()) { + if (m_music.find(filename) == m_music.end()) + { Buffer *buffer = new Buffer(); std::stringstream file; file << m_soundPath << "/" << filename; - if (buffer->LoadFromFile(file.str(), static_cast(-1))) { - mMusic[filename] = buffer; + if (buffer->LoadFromFile(file.str(), static_cast(-1))) + { + m_music[filename] = buffer; return true; } } @@ -235,7 +249,8 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) int priority = GetPriority(sound); // Seeks a channel used which sound is stopped. - for (auto it : mChannels) { + for (auto it : m_channels) + { if (it.second->IsPlaying()) continue; if (it.second->GetSoundType() != sound) @@ -248,12 +263,14 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) } // just add a new channel if we dont have any - if (mChannels.size() == 0) { + if (m_channels.size() == 0) + { Channel *chn = new Channel(); // check if we channel ready to play music, if not report error - if (chn->IsReady()) { + if (chn->IsReady()) + { chn->SetPriority(priority); - mChannels[1] = chn; + m_channels[1] = chn; channel = 1; bAlreadyLoaded = false; return true; @@ -264,17 +281,21 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) } // Seeks a channel completely free. - if (mChannels.size() < 64) { - auto it = mChannels.end(); + if (m_channels.size() < 64) + { + auto it = m_channels.end(); it--; int i = (*it).first; - while (++i) { - if (mChannels.find(i) == mChannels.end()) { + while (++i) + { + if (m_channels.find(i) == m_channels.end()) + { Channel *chn = new Channel(); // check if channel is ready to play music, if not destroy it and seek free one - if (chn->IsReady()) { + if (chn->IsReady()) + { chn->SetPriority(priority); - mChannels[++i] = chn; + m_channels[++i] = chn; channel = i; bAlreadyLoaded = false; return true; @@ -286,8 +307,10 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) } int lowerOrEqual = -1; - for (auto it : mChannels) { - if (it.second->GetPriority() < priority) { + for (auto it : m_channels) + { + if (it.second->GetPriority() < priority) + { GetLogger()->Debug("Sound channel with lower priority will be reused.\n"); channel = it.first; return true; @@ -296,7 +319,8 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) lowerOrEqual = it.first; } - if (lowerOrEqual != -1) { + if (lowerOrEqual != -1) + { channel = lowerOrEqual; GetLogger()->Debug("Sound channel with lower or equal priority will be reused.\n"); return true; @@ -309,16 +333,18 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) int ALSound::Play(Sound sound, float amplitude, float frequency, bool bLoop) { - return Play(sound, mEye, amplitude, frequency, bLoop); + return Play(sound, m_eye, amplitude, frequency, bLoop); } int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequency, bool bLoop) { - if (!mEnabled) { + if (!m_enabled) + { return -1; } - if (mSounds.find(sound) == mSounds.end()) { + if (m_sounds.find(sound) == m_sounds.end()) + { GetLogger()->Warn("Sound %d was not loaded!\n", sound); return -1; } @@ -328,29 +354,34 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded)) return -1; - if (!bAlreadyLoaded) { - if (!mChannels[channel]->SetBuffer(mSounds[sound])) { - mChannels[channel]->SetBuffer(nullptr); + if (!bAlreadyLoaded) + { + if (!m_channels[channel]->SetBuffer(m_sounds[sound])) + { + m_channels[channel]->SetBuffer(nullptr); return -1; } } Position(channel, pos); - if (!m3D) { + if (!m_3D) + { ComputeVolumePan2D(channel, pos); - } else { - mChannels[channel]->SetVolumeAtrib(1.0f); + } + else + { + m_channels[channel]->SetVolumeAtrib(1.0f); } // setting initial values - mChannels[channel]->SetStartAmplitude(amplitude); - mChannels[channel]->SetStartFrequency(frequency); - mChannels[channel]->SetChangeFrequency(1.0f); - mChannels[channel]->ResetOper(); - mChannels[channel]->SetFrequency(frequency); - mChannels[channel]->SetVolume(powf(amplitude * mChannels[channel]->GetVolumeAtrib(), 0.2f) * mAudioVolume); - mChannels[channel]->SetLoop(bLoop); - mChannels[channel]->Play(); + m_channels[channel]->SetStartAmplitude(amplitude); + m_channels[channel]->SetStartFrequency(frequency); + m_channels[channel]->SetChangeFrequency(1.0f); + m_channels[channel]->ResetOper(); + m_channels[channel]->SetFrequency(frequency); + m_channels[channel]->SetVolume(powf(amplitude * m_channels[channel]->GetVolumeAtrib(), 0.2f) * m_audioVolume); + m_channels[channel]->SetLoop(bLoop); + m_channels[channel]->Play(); return channel; } @@ -358,21 +389,23 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc bool ALSound::FlushEnvelope(int channel) { - if (mChannels.find(channel) == mChannels.end()) { + if (m_channels.find(channel) == m_channels.end()) + { return false; } - mChannels[channel]->ResetOper(); + m_channels[channel]->ResetOper(); return true; } bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) { - if (!mEnabled) + if (!m_enabled) return false; - if (mChannels.find(channel) == mChannels.end()) { + if (m_channels.find(channel) == m_channels.end()) + { return false; } @@ -382,7 +415,7 @@ bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float t op.totalTime = time; op.nextOper = oper; op.currentTime = 0.0f; - mChannels[channel]->AddOper(op); + m_channels[channel]->AddOper(op); return true; } @@ -390,21 +423,26 @@ bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float t bool ALSound::Position(int channel, Math::Vector pos) { - if (!mEnabled) + if (!m_enabled) return false; - if (mChannels.find(channel) == mChannels.end()) { + if (m_channels.find(channel) == m_channels.end()) + { return false; } - if (m3D) { - mChannels[channel]->SetPan(pos); - } else { + if (m_3D) + { + m_channels[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); + if (!m_channels[channel]->HasEnvelope()) + { + float volume = m_channels[channel]->GetStartAmplitude(); + m_channels[channel]->SetVolume(powf(volume * m_channels[channel]->GetVolumeAtrib(), 0.2f) * m_audioVolume); } } return true; @@ -413,29 +451,31 @@ bool ALSound::Position(int channel, Math::Vector pos) bool ALSound::Frequency(int channel, float frequency) { - if (!mEnabled) + if (!m_enabled) return false; - if (mChannels.find(channel) == mChannels.end()) { + if (m_channels.find(channel) == m_channels.end()) + { return false; } - mChannels[channel]->SetFrequency(frequency * mChannels[channel]->GetInitFrequency()); - mChannels[channel]->SetChangeFrequency(frequency); + m_channels[channel]->SetFrequency(frequency * m_channels[channel]->GetInitFrequency()); + m_channels[channel]->SetChangeFrequency(frequency); return true; } bool ALSound::Stop(int channel) { - if (!mEnabled) + if (!m_enabled) return false; - if (mChannels.find(channel) == mChannels.end()) { + if (m_channels.find(channel) == m_channels.end()) + { return false; } - mChannels[channel]->Stop(); - mChannels[channel]->ResetOper(); + m_channels[channel]->Stop(); + m_channels[channel]->ResetOper(); return true; } @@ -443,10 +483,11 @@ bool ALSound::Stop(int channel) bool ALSound::StopAll() { - if (!mEnabled) + if (!m_enabled) return false; - for (auto channel : mChannels) { + for (auto channel : m_channels) + { channel.second->Stop(); channel.second->ResetOper(); } @@ -457,19 +498,24 @@ bool ALSound::StopAll() bool ALSound::MuteAll(bool bMute) { - if (!mEnabled) + if (!m_enabled) return false; - for (auto it : mChannels) { - if (it.second->IsPlaying()) { + for (auto it : m_channels) + { + if (it.second->IsPlaying()) + { it.second->Mute(bMute); } } - if (bMute) { - mCurrentMusic->SetVolume(0.0f); - } else { - mCurrentMusic->SetVolume(mMusicVolume); + if (bMute) + { + m_currentMusic->SetVolume(0.0f); + } + else + { + m_currentMusic->SetVolume(m_musicVolume); } return true; } @@ -477,17 +523,20 @@ bool ALSound::MuteAll(bool bMute) void ALSound::FrameMove(float delta) { - if (!mEnabled) + if (!m_enabled) return; float progress; float volume, frequency; - for (auto it : mChannels) { - if (!it.second->IsPlaying()) { + for (auto it : m_channels) + { + if (!it.second->IsPlaying()) + { continue; } - if (it.second->IsMuted()) { + if (it.second->IsMuted()) + { it.second->SetVolume(0.0f); continue; } @@ -498,12 +547,12 @@ void ALSound::FrameMove(float delta) SoundOper &oper = it.second->GetEnvelope(); oper.currentTime += delta; progress = oper.currentTime / oper.totalTime; - progress = MIN(progress, 1.0f); + progress = std::min(progress, 1.0f); // setting volume volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude()); volume = volume + it.second->GetStartAmplitude(); - it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * mAudioVolume); + it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * m_audioVolume); // setting frequency frequency = progress; @@ -513,14 +562,19 @@ void ALSound::FrameMove(float delta) frequency = (frequency * it.second->GetInitFrequency()); it.second->SetFrequency(frequency); - if (oper.totalTime <= oper.currentTime) { - if (oper.nextOper == SOPER_LOOP) { + if (oper.totalTime <= oper.currentTime) + { + if (oper.nextOper == SOPER_LOOP) + { oper.currentTime = 0.0f; it.second->Play(); - } else { + } + else + { it.second->SetStartAmplitude(oper.finalAmplitude); it.second->SetStartFrequency(oper.finalFrequency); - if (oper.nextOper == SOPER_STOP) { + if (oper.nextOper == SOPER_STOP) + { it.second->Stop(); } @@ -533,26 +587,32 @@ void ALSound::FrameMove(float delta) void ALSound::SetListener(Math::Vector eye, Math::Vector lookat) { - mEye = eye; - mLookat = lookat; - if (m3D) { + m_eye = eye; + m_lookat = lookat; + if (m_3D) + { 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 { + } + else + { 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()) { + for (auto it : m_channels) + { + if (it.second->IsPlaying()) + { Math::Vector pos = it.second->GetPosition(); ComputeVolumePan2D(it.first, pos); - if (!it.second->HasEnvelope()) { + if (!it.second->HasEnvelope()) + { float volume = it.second->GetStartAmplitude(); - it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * mAudioVolume); + it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * m_audioVolume); } } } @@ -568,7 +628,8 @@ bool ALSound::PlayMusic(int rank, bool bRepeat) bool ALSound::PlayMusic(std::string filename, bool bRepeat) { - if (!mEnabled) { + if (!m_enabled) + { return false; } @@ -576,23 +637,27 @@ bool ALSound::PlayMusic(std::string filename, bool bRepeat) file << m_soundPath << "/" << filename; // check if we have music in cache - if (mMusic.find(filename) == mMusic.end()) { + if (m_music.find(filename) == m_music.end()) + { GetLogger()->Warn("Music %s was not cached!\n", filename.c_str()); - if (!boost::filesystem::exists(file.str())) { + if (!boost::filesystem::exists(file.str())) + { GetLogger()->Warn("Requested music %s was not found.\n", filename.c_str()); return false; } Buffer *buffer = new Buffer(); buffer->LoadFromFile(file.str(), static_cast(-1)); - mCurrentMusic->SetBuffer(buffer); - } else { + m_currentMusic->SetBuffer(buffer); + } + else + { GetLogger()->Debug("Music loaded from cache\n"); - mCurrentMusic->SetBuffer(mMusic[filename]); + m_currentMusic->SetBuffer(m_music[filename]); } - mCurrentMusic->SetVolume(mMusicVolume); - mCurrentMusic->SetLoop(bRepeat); - mCurrentMusic->Play(); + m_currentMusic->SetVolume(m_musicVolume); + m_currentMusic->SetLoop(bRepeat); + m_currentMusic->Play(); return true; } @@ -600,18 +665,20 @@ bool ALSound::PlayMusic(std::string filename, bool bRepeat) bool ALSound::RestartMusic() { - if (!mEnabled || !mCurrentMusic) { + if (!m_enabled || !m_currentMusic) + { return false; } - mCurrentMusic->Stop(); - mCurrentMusic->Play(); + m_currentMusic->Stop(); + m_currentMusic->Play(); return true; } void ALSound::StopMusic() { - if (!mEnabled || !mCurrentMusic) { + if (!m_enabled || !m_currentMusic) + { return; } @@ -621,70 +688,84 @@ void ALSound::StopMusic() bool ALSound::IsPlayingMusic() { - if (!mEnabled || !mCurrentMusic) { + if (!m_enabled || !m_currentMusic) + { return false; } - return mCurrentMusic->IsPlaying(); + return m_currentMusic->IsPlaying(); } void ALSound::SuspendMusic() { - if (!mEnabled || !mCurrentMusic) { + if (!m_enabled || !m_currentMusic) + { return; } - mCurrentMusic->Stop(); + m_currentMusic->Stop(); } void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos) { float dist, a, g; - mChannels[channel]->SetPosition(pos); + m_channels[channel]->SetPosition(pos); - if (VectorsEqual(pos, mEye)) { - mChannels[channel]->SetVolumeAtrib(1.0f); // maximum volume - mChannels[channel]->SetPan(Math::Vector()); // at the center + if (VectorsEqual(pos, m_eye)) + { + m_channels[channel]->SetVolumeAtrib(1.0f); // maximum volume + m_channels[channel]->SetPan(Math::Vector()); // at the center return; } - dist = Distance(pos, mEye); - if ( dist >= 110.0f ) { // very far? - mChannels[channel]->SetVolumeAtrib(0.0f); // silence - mChannels[channel]->SetPan(Math::Vector()); // at the center + dist = Distance(pos, m_eye); + if ( dist >= 110.0f ) // very far? + { + m_channels[channel]->SetVolumeAtrib(0.0f); // silence + m_channels[channel]->SetPan(Math::Vector()); // at the center return; - } else if ( dist <= 10.0f ) { // very close? - mChannels[channel]->SetVolumeAtrib(1.0f); // maximum volume - mChannels[channel]->SetPan(Math::Vector()); // at the center + } + else if ( dist <= 10.0f ) // very close? + { + m_channels[channel]->SetVolumeAtrib(1.0f); // maximum volume + m_channels[channel]->SetPan(Math::Vector()); // at the center return; } - mChannels[channel]->SetVolumeAtrib(1.0f - ((dist - 10.0f) / 100.0f)); + m_channels[channel]->SetVolumeAtrib(1.0f - ((dist - 10.0f) / 100.0f)); 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); + float angle_a = Angle(Math::Vector(m_lookat.x - m_eye.x, m_lookat.z - m_eye.z, 0.0f), one); + float angle_g = Angle(Math::Vector(pos.x - m_eye.x, pos.z - m_eye.z, 0.0f), one); a = fmodf(angle_a, Math::PI * 2.0f); g = fmodf(angle_g, Math::PI * 2.0f); - if ( a < 0.0f ) { + if ( a < 0.0f ) + { a += Math::PI * 2.0f; } - if ( g < 0.0f ) { + if ( g < 0.0f ) + { g += Math::PI * 2.0f; } - if ( a < g ) { - if (a + Math::PI * 2.0f - g < g - a ) { + if ( a < g ) + { + if (a + Math::PI * 2.0f - g < g - a ) + { a += Math::PI * 2.0f; } - } else { - if ( g + Math::PI * 2.0f - a < a - g ) { + } + else + { + if ( g + Math::PI * 2.0f - a < a - g ) + { g += Math::PI * 2.0f; } } - mChannels[channel]->SetPan( Math::Vector(0.0f, 0.0f, sinf(g - a)) ); + m_channels[channel]->SetPan( Math::Vector(0.0f, 0.0f, sinf(g - a)) ); } + diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index b8afd4d..ad32204 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -15,86 +15,90 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// alsound.h +/** + * \file alsound.h + * \brief OpenAL implementation of sound system + */ #pragma once +#include "common/logger.h" +#include "sound/sound.h" + +#include "sound/oalsound/buffer.h" +#include "sound/oalsound/channel.h" +#include "sound/oalsound/check.h" + #include #include #include -#include "common/logger.h" -#include "sound/sound.h" - -#include "buffer.h" -#include "channel.h" -#include "check.h" - class ALSound : public CSoundInterface { - public: - ALSound(); - ~ALSound(); - - bool Create(bool b3D); - bool Cache(Sound, std::string); - bool CacheMusic(std::string); - - bool GetEnable(); - - void SetSound3D(bool bMode); - bool GetSound3D(); - bool GetSound3DCap(); - - void SetAudioVolume(int volume); - int GetAudioVolume(); - void SetMusicVolume(int volume); - int GetMusicVolume(); - - void SetListener(Math::Vector eye, Math::Vector lookat); - void FrameMove(float rTime); - - int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false); - int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false); - bool FlushEnvelope(int channel); - bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper); - bool Position(int channel, Math::Vector pos); - bool Frequency(int channel, float frequency); - bool Stop(int channel); - bool StopAll(); - bool MuteAll(bool bMute); - - bool PlayMusic(int rank, bool bRepeat); - bool PlayMusic(std::string filename, bool bRepeat); - bool RestartMusic(); - void SuspendMusic(); - void StopMusic(); - bool IsPlayingMusic(); - - // plugin interface - std::string PluginName(); - int PluginVersion(); - void InstallPlugin(); - bool UninstallPlugin(std::string &); - - private: - void CleanUp(); - int GetPriority(Sound); - bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded); - void ComputeVolumePan2D(int channel, Math::Vector &pos); - - bool mEnabled; - bool m3D; - float mAudioVolume; - float mMusicVolume; - ALCdevice* mDevice; - ALCcontext* mContext; - std::map mSounds; - std::map mMusic; - std::map mChannels; - Channel *mCurrentMusic; - Math::Vector mEye; - Math::Vector mLookat; +public: + ALSound(); + ~ALSound(); + + bool Create(bool b3D); + bool Cache(Sound, std::string); + bool CacheMusic(std::string); + + bool GetEnable(); + + void SetSound3D(bool bMode); + bool GetSound3D(); + bool GetSound3DCap(); + + void SetAudioVolume(int volume); + int GetAudioVolume(); + void SetMusicVolume(int volume); + int GetMusicVolume(); + + void SetListener(Math::Vector eye, Math::Vector lookat); + void FrameMove(float rTime); + + int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false); + int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false); + bool FlushEnvelope(int channel); + bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper); + bool Position(int channel, Math::Vector pos); + bool Frequency(int channel, float frequency); + bool Stop(int channel); + bool StopAll(); + bool MuteAll(bool bMute); + + bool PlayMusic(int rank, bool bRepeat); + bool PlayMusic(std::string filename, bool bRepeat); + bool RestartMusic(); + void SuspendMusic(); + void StopMusic(); + bool IsPlayingMusic(); + + // plugin interface + std::string PluginName(); + int PluginVersion(); + void InstallPlugin(); + bool UninstallPlugin(std::string &); + +private: + void CleanUp(); + int GetPriority(Sound); + bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded); + void ComputeVolumePan2D(int channel, Math::Vector &pos); + + bool m_enabled; + bool m_3D; + float m_audioVolume; + float m_musicVolume; + ALCdevice* m_device; + ALCcontext* m_context; + std::map m_sounds; + std::map m_music; + std::map m_channels; + Channel *m_currentMusic; + Math::Vector m_eye; + Math::Vector m_lookat; }; + diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp index 4640504..193e624 100644 --- a/src/sound/oalsound/buffer.cpp +++ b/src/sound/oalsound/buffer.cpp @@ -15,25 +15,29 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include "buffer.h" +#include "sound/oalsound/buffer.h" -Buffer::Buffer() { - mLoaded = false; - mDuration = 0.0f; +Buffer::Buffer() +{ + m_loaded = false; + m_duration = 0.0f; } -Buffer::~Buffer() { - if (mLoaded) { - alDeleteBuffers(1, &mBuffer); +Buffer::~Buffer() +{ + if (m_loaded) + { + alDeleteBuffers(1, &m_buffer); if (alCheck()) GetLogger()->Warn("Failed to unload buffer. Code %d\n", alGetCode()); } } -bool Buffer::LoadFromFile(std::string filename, Sound sound) { - mSound = sound; +bool Buffer::LoadFromFile(std::string filename, Sound sound) +{ + m_sound = sound; GetLogger()->Debug("Loading audio file: %s\n", filename.c_str()); SF_INFO fileInfo; @@ -45,16 +49,18 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound) { GetLogger()->Trace(" samplerate %d\n", fileInfo.samplerate); GetLogger()->Trace(" sections %d\n", fileInfo.sections); - if (!file) { + if (!file) + { GetLogger()->Warn("Could not load file. Reason: %s\n", sf_strerror(file)); - mLoaded = false; + m_loaded = false; return false; } - alGenBuffers(1, &mBuffer); - if (!mBuffer) { + alGenBuffers(1, &m_buffer); + if (!m_buffer) + { GetLogger()->Warn("Could not create audio buffer\n"); - mLoaded = false; + m_loaded = false; sf_close(file); return false; } @@ -64,33 +70,39 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound) { std::array buffer; data.reserve(fileInfo.frames); size_t read = 0; - while ((read = sf_read_short(file, buffer.data(), buffer.size())) != 0) { + while ((read = sf_read_short(file, buffer.data(), buffer.size())) != 0) + { data.insert(data.end(), buffer.begin(), buffer.begin() + read); } 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; - mLoaded = true; + alBufferData(m_buffer, fileInfo.channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, &data.front(), data.size() * sizeof(uint16_t), fileInfo.samplerate); + m_duration = static_cast(fileInfo.frames) / fileInfo.samplerate; + m_loaded = true; return true; } -Sound Buffer::GetSoundType() { - return mSound; +Sound Buffer::GetSoundType() +{ + return m_sound; } -ALuint Buffer::GetBuffer() { - return mBuffer; +ALuint Buffer::GetBuffer() +{ + return m_buffer; } -bool Buffer::IsLoaded() { - return mLoaded; +bool Buffer::IsLoaded() +{ + return m_loaded; } -float Buffer::GetDuration() { - return mDuration; +float Buffer::GetDuration() +{ + return m_duration; } + diff --git a/src/sound/oalsound/buffer.h b/src/sound/oalsound/buffer.h index 7286deb..d847426 100644 --- a/src/sound/oalsound/buffer.h +++ b/src/sound/oalsound/buffer.h @@ -14,10 +14,18 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// buffer.h +/** + * \file buffer.h + * \brief OpenAL buffer + */ #pragma once +#include "sound/sound.h" +#include "common/logger.h" + +#include "sound/oalsound/check.h" + #include #include #include @@ -25,27 +33,23 @@ #include #include -#include "sound/sound.h" -#include "common/logger.h" - -#include "check.h" - class Buffer { - public: - Buffer(); - ~Buffer(); - - bool LoadFromFile(std::string, Sound); - bool IsLoaded(); - - Sound GetSoundType(); - ALuint GetBuffer(); - float GetDuration(); - - private: - ALuint mBuffer; - Sound mSound; - bool mLoaded; - float mDuration; +public: + Buffer(); + ~Buffer(); + + bool LoadFromFile(std::string, Sound); + bool IsLoaded(); + + Sound GetSoundType(); + ALuint GetBuffer(); + float GetDuration(); + +private: + ALuint m_buffer; + Sound m_sound; + bool m_loaded; + float m_duration; }; + diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index d64d6b5..4d89df5 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -15,37 +15,41 @@ // * along with this program. If not, see http://www.gnu.org/licenses/. -#include "channel.h" +#include "sound/oalsound/channel.h" Channel::Channel() { - alGenSources(1, &mSource); + alGenSources(1, &m_source); - if (alCheck()) { + if (alCheck()) + { GetLogger()->Warn("Failed to create sound source. Code: %d\n", alGetCode()); - mReady = false; - } else { - mReady = true; + m_ready = false; + } + else + { + m_ready = true; } - mPriority = 0; - mBuffer = nullptr; - mLoop = false; - mMute = false; - mInitFrequency = 0.0f; - mStartAmplitude = 0.0f; - mStartFrequency = 0.0f; - mChangeFrequency = 0.0f; - mVolume = 0.0f; + m_priority = 0; + m_buffer = nullptr; + m_loop = false; + m_mute = false; + m_initFrequency = 0.0f; + m_startAmplitude = 0.0f; + m_startFrequency = 0.0f; + m_changeFrequency = 0.0f; + m_volume = 0.0f; } Channel::~Channel() { - if (mReady) { - alSourceStop(mSource); - alSourcei(mSource, AL_BUFFER, 0); - alDeleteSources(1, &mSource); + if (m_ready) + { + alSourceStop(m_source); + alSourcei(m_source, AL_BUFFER, 0); + alDeleteSources(1, &m_source); if (alCheck()) GetLogger()->Warn("Failed to delete sound source. Code: %d\n", alGetCode()); } @@ -54,15 +58,17 @@ Channel::~Channel() bool Channel::Play() { - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return false; } - alSourcei(mSource, AL_LOOPING, static_cast(mLoop)); - alSourcei(mSource, AL_REFERENCE_DISTANCE, 10.0f); - alSourcei(mSource, AL_MAX_DISTANCE, 110.0f); - alSourcePlay(mSource); - if (alCheck()) { + alSourcei(m_source, AL_LOOPING, static_cast(m_loop)); + alSourcei(m_source, AL_REFERENCE_DISTANCE, 10.0f); + alSourcei(m_source, AL_MAX_DISTANCE, 110.0f); + alSourcePlay(m_source); + if (alCheck()) + { GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode()); } return true; @@ -71,12 +77,14 @@ bool Channel::Play() bool Channel::SetPan(Math::Vector pos) { - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return false; } - alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z); - if (alCheck()) { + alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z); + if (alCheck()) + { GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode()); return false; } @@ -86,24 +94,26 @@ bool Channel::SetPan(Math::Vector pos) void Channel::SetPosition(Math::Vector pos) { - mPosition = pos; + m_position = pos; } Math::Vector Channel::GetPosition() { - return mPosition; + return m_position; } bool Channel::SetFrequency(float freq) { - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return false; } - alSourcef(mSource, AL_PITCH, freq); - if (alCheck()) { + alSourcef(m_source, AL_PITCH, freq); + if (alCheck()) + { GetLogger()->Warn("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode()); return false; } @@ -114,12 +124,14 @@ bool Channel::SetFrequency(float freq) float Channel::GetFrequency() { ALfloat freq; - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return 0; } - alGetSourcef(mSource, AL_PITCH, &freq); - if (alCheck()) { + alGetSourcef(m_source, AL_PITCH, &freq); + if (alCheck()) + { GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode()); return 0; } @@ -130,12 +142,14 @@ float Channel::GetFrequency() bool Channel::SetVolume(float vol) { - if (!mReady || vol < 0 || mBuffer == nullptr) { + if (!m_ready || vol < 0 || m_buffer == nullptr) + { return false; } - alSourcef(mSource, AL_GAIN, vol); - if (alCheck()) { + alSourcef(m_source, AL_GAIN, vol); + if (alCheck()) + { GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode()); return false; } @@ -146,12 +160,14 @@ bool Channel::SetVolume(float vol) float Channel::GetVolume() { ALfloat vol; - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return 0; } - alGetSourcef(mSource, AL_GAIN, &vol); - if (alCheck()) { + alGetSourcef(m_source, AL_GAIN, &vol); + if (alCheck()) + { GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode()); return 0; } @@ -162,134 +178,144 @@ float Channel::GetVolume() void Channel::SetVolumeAtrib(float volume) { - mVolume = volume; + m_volume = volume; } float Channel::GetVolumeAtrib() { - return mVolume; + return m_volume; } int Channel::GetPriority() { - return mPriority; + return m_priority; } void Channel::SetPriority(int pri) { - mPriority = pri; + m_priority = pri; } void Channel::SetStartAmplitude(float gain) { - mStartAmplitude = gain; + m_startAmplitude = gain; } void Channel::SetStartFrequency(float freq) { - mStartFrequency = freq; + m_startFrequency = freq; } void Channel::SetChangeFrequency(float freq) { - mChangeFrequency = freq; + m_changeFrequency = freq; } float Channel::GetStartAmplitude() { - return mStartAmplitude; + return m_startAmplitude; } float Channel::GetStartFrequency() { - return mStartFrequency; + return m_startFrequency; } float Channel::GetChangeFrequency() { - return mChangeFrequency; + return m_changeFrequency; } float Channel::GetInitFrequency() { - return mInitFrequency; + return m_initFrequency; } void Channel::AddOper(SoundOper oper) { - mOper.push_back(oper); + m_oper.push_back(oper); } void Channel::ResetOper() { - mOper.clear(); + m_oper.clear(); } -Sound Channel::GetSoundType() { - if (!mReady || mBuffer == nullptr) { +Sound Channel::GetSoundType() +{ + if (!m_ready || m_buffer == nullptr) + { return SOUND_NONE; } - return mBuffer->GetSoundType(); + return m_buffer->GetSoundType(); } -bool Channel::SetBuffer(Buffer *buffer) { - if (!mReady) +bool Channel::SetBuffer(Buffer *buffer) +{ + if (!m_ready) return false; Stop(); - mBuffer = buffer; - if (buffer == nullptr) { - alSourcei(mSource, AL_BUFFER, 0); + m_buffer = buffer; + if (buffer == nullptr) + { + alSourcei(m_source, AL_BUFFER, 0); return true; } - alSourcei(mSource, AL_BUFFER, buffer->GetBuffer()); - if (alCheck()) { + alSourcei(m_source, AL_BUFFER, buffer->GetBuffer()); + if (alCheck()) + { GetLogger()->Warn("Could not set sound buffer. Code: %d\n", alGetCode()); return false; } - mInitFrequency = GetFrequency(); + m_initFrequency = GetFrequency(); return true; } -bool Channel::FreeBuffer() { - if (!mReady || !mBuffer) { +bool Channel::FreeBuffer() +{ + if (!m_ready || !m_buffer) + { return false; } - alSourceStop(mSource); - alSourcei(mSource, AL_BUFFER, 0); - delete mBuffer; - mBuffer = nullptr; + alSourceStop(m_source); + alSourcei(m_source, AL_BUFFER, 0); + delete m_buffer; + m_buffer = nullptr; return true; } -bool Channel::IsPlaying() { +bool Channel::IsPlaying() +{ ALint status; - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return false; } - alGetSourcei(mSource, AL_SOURCE_STATE, &status); - if (alCheck()) { + alGetSourcei(m_source, AL_SOURCE_STATE, &status); + if (alCheck()) + { GetLogger()->Warn("Could not get sound status. Code: %d\n", alGetCode()); return false; } @@ -298,22 +324,27 @@ bool Channel::IsPlaying() { } -bool Channel::IsReady() { - return mReady; +bool Channel::IsReady() +{ + return m_ready; } -bool Channel::IsLoaded() { - return mBuffer != nullptr; +bool Channel::IsLoaded() +{ + return m_buffer != nullptr; } -bool Channel::Stop() { - if (!mReady || mBuffer == nullptr) { +bool Channel::Stop() +{ + if (!m_ready || m_buffer == nullptr) + { return false; } - alSourceStop(mSource); - if (alCheck()) { + alSourceStop(m_source); + if (alCheck()) + { GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode()); return false; } @@ -323,13 +354,15 @@ bool Channel::Stop() { float Channel::GetCurrentTime() { - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return 0.0f; } ALfloat current; - alGetSourcef(mSource, AL_SEC_OFFSET, ¤t); - if (alCheck()) { + alGetSourcef(m_source, AL_SEC_OFFSET, ¤t); + if (alCheck()) + { GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode()); return 0.0f; } @@ -339,12 +372,14 @@ float Channel::GetCurrentTime() void Channel::SetCurrentTime(float current) { - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return; } - alSourcef(mSource, AL_SEC_OFFSET, current); - if (alCheck()) { + alSourcef(m_source, AL_SEC_OFFSET, current); + if (alCheck()) + { GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode()); } } @@ -352,44 +387,47 @@ void Channel::SetCurrentTime(float current) float Channel::GetDuration() { - if (!mReady || mBuffer == nullptr) { + if (!m_ready || m_buffer == nullptr) + { return 0.0f; } - return mBuffer->GetDuration(); + return m_buffer->GetDuration(); } bool Channel::HasEnvelope() { - return mOper.size() > 0; + return m_oper.size() > 0; } SoundOper& Channel::GetEnvelope() { - return mOper.front(); + return m_oper.front(); } void Channel::PopEnvelope() { - mOper.pop_front(); + m_oper.pop_front(); } -void Channel::SetLoop(bool loop) { - mLoop = loop; +void Channel::SetLoop(bool loop) +{ + m_loop = loop; } void Channel::Mute(bool mute) { - mMute = mute; + m_mute = mute; } bool Channel::IsMuted() { - return mMute; + return m_mute; } + diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index c0b0436..a04b509 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -14,10 +14,18 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// channel.h +/** + * \file channel.h + * \brief OpenAL channel + */ #pragma once +#include "sound/sound.h" + +#include "sound/oalsound/buffer.h" +#include "sound/oalsound/check.h" + #include #include #include @@ -25,11 +33,6 @@ #include #include -#include "sound/sound.h" - -#include "buffer.h" -#include "check.h" - struct SoundOper { float finalAmplitude; @@ -42,72 +45,73 @@ struct SoundOper class Channel { - public: - Channel(); - ~Channel(); - - bool Play(); - bool Stop(); - - bool SetPan(Math::Vector); - void SetPosition(Math::Vector); - Math::Vector GetPosition(); - - bool SetFrequency(float); - float GetFrequency(); - - float GetCurrentTime(); - void SetCurrentTime(float); - float GetDuration(); - - bool SetVolume(float); - 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); - - float GetStartAmplitude(); - 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; - - int mPriority; - float mStartAmplitude; - float mStartFrequency; - float mChangeFrequency; - float mInitFrequency; - float mVolume; - std::deque mOper; - bool mReady; - bool mLoop; - bool mMute; - Math::Vector mPosition; +public: + Channel(); + ~Channel(); + + bool Play(); + bool Stop(); + + bool SetPan(Math::Vector); + void SetPosition(Math::Vector); + Math::Vector GetPosition(); + + bool SetFrequency(float); + float GetFrequency(); + + float GetCurrentTime(); + void SetCurrentTime(float); + float GetDuration(); + + bool SetVolume(float); + 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); + + float GetStartAmplitude(); + float GetStartFrequency(); + float GetChangeFrequency(); + float GetInitFrequency(); + + void AddOper(SoundOper); + void ResetOper(); + Sound GetSoundType(); + void SetLoop(bool); + void Mute(bool); + bool IsMuted(); + +private: + Buffer *m_buffer; + ALuint m_source; + + int m_priority; + float m_startAmplitude; + float m_startFrequency; + float m_changeFrequency; + float m_initFrequency; + float m_volume; + std::deque m_oper; + bool m_ready; + bool m_loop; + bool m_mute; + Math::Vector m_position; }; + diff --git a/src/sound/oalsound/check.h b/src/sound/oalsound/check.h index cf3e468..f677e17 100644 --- a/src/sound/oalsound/check.h +++ b/src/sound/oalsound/check.h @@ -37,3 +37,4 @@ inline ALenum alGetCode() CODE = AL_NO_ERROR; return ret; } + diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp new file mode 100644 index 0000000..d392612 --- /dev/null +++ b/src/sound/sound.cpp @@ -0,0 +1,191 @@ +// * This file is part of the COLOBOT source code +// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * Copyright (C) 2012-2013, Polish Portal of Colobot (PPC) +// * +// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// * +// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// * +// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see http://www.gnu.org/licenses/. + +#include "sound/sound.h" + +#include "math/vector.h" + +#include "common/logger.h" + +#include +#include +#include + +#include + + +CSoundInterface::CSoundInterface() +{ +} + +CSoundInterface::~CSoundInterface() +{ +} + +bool CSoundInterface::Create(bool b3D) +{ + return true; +} + +void CSoundInterface::CacheAll(std::string path) +{ + for ( int i = 1; i < SOUND_MAX; i++ ) + { + std::stringstream filename; + filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav"; + if ( !Cache(static_cast(i), filename.str()) ) + GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str()); + } +} + +void CSoundInterface::AddMusicFiles(std::string path) +{ + m_soundPath = path; + CacheMusic("Intro1.ogg"); + CacheMusic("Intro2.ogg"); + CacheMusic("music010.ogg"); + CacheMusic("music011.ogg"); +} + +bool CSoundInterface::Cache(Sound bSound, std::string bFile) +{ + return true; +} + +bool CSoundInterface::CacheMusic(std::string bFile) +{ + return true; +} + +bool CSoundInterface::GetEnable() +{ + return true; +} + +void CSoundInterface::SetSound3D(bool bMode) +{ +} + +bool CSoundInterface::GetSound3D() +{ + return true; +} + +bool CSoundInterface::GetSound3DCap() +{ + return true; +} + +void CSoundInterface::SetAudioVolume(int volume) +{ +} + +int CSoundInterface::GetAudioVolume() +{ + return 0; +} + +void CSoundInterface::SetMusicVolume(int volume) +{ +} + +int CSoundInterface::GetMusicVolume() +{ + return 0; +} + +void CSoundInterface::SetListener(Math::Vector eye, Math::Vector lookat) +{ +} + +void CSoundInterface::FrameMove(float rTime) +{ +} + +int CSoundInterface::Play(Sound sound, float amplitude, float frequency, bool bLoop) +{ + return 0; +} + +int CSoundInterface::Play(Sound sound, Math::Vector pos, float amplitude, float frequency, bool bLoop) +{ + return 0; +} + +bool CSoundInterface::FlushEnvelope(int channel) +{ + return true; +} + +bool CSoundInterface::AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) +{ + return true; +} + +bool CSoundInterface::Position(int channel, Math::Vector pos) +{ + return true; +} + +bool CSoundInterface::Frequency(int channel, float frequency) +{ + return true; +} + +bool CSoundInterface::Stop(int channel) +{ + return true; +} + +bool CSoundInterface::StopAll() +{ + return true; +} + +bool CSoundInterface::MuteAll(bool bMute) +{ + return true; +} + +bool CSoundInterface::PlayMusic(int rank, bool bRepeat) +{ + return true; +} + +bool CSoundInterface::PlayMusic(std::string filename, bool bRepeat) +{ + return true; +} + +bool CSoundInterface::RestartMusic() +{ + return true; +} + +void CSoundInterface::SuspendMusic() +{ +} + +void CSoundInterface::StopMusic() +{ +} + +bool CSoundInterface::IsPlayingMusic() +{ + return true; +} + diff --git a/src/sound/sound.h b/src/sound/sound.h index 1fd79c3..9ccc1b6 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -22,23 +22,16 @@ #pragma once -#include - #include "math/vector.h" #include "common/logger.h" #include -#include -#include -#include -#include - /*! * Maximum possible audio volume */ -#define MAXVOLUME 100.0f +const float MAXVOLUME = 100.0f; /** @@ -131,6 +124,7 @@ enum Sound SOUND_EXPLOg1 = 79, /*!< impact gun 1 */ SOUND_EXPLOg2 = 80, /*!< impact gun 2 */ // SOUND_MOTORd = 81, /*!< engine friction */ + SOUND_MAX /** number of items in enum */ }; @@ -154,35 +148,22 @@ enum SoundNext */ class CSoundInterface { - public: - inline CSoundInterface() {} - inline virtual ~CSoundInterface() {} +public: + CSoundInterface(); + virtual ~CSoundInterface(); /** Function to initialize sound device * \param b3D - enable support for 3D sound */ - inline virtual bool Create(bool b3D) { return true; }; + virtual bool Create(bool b3D); /** Function called to cache all sound effect files. * Function calls \link CSoundInterface::Cache() \endlink for each file */ - inline void CacheAll(std::string path) { - for ( int i = 1; i <= 80; i++ ) { - std::stringstream filename; - filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav"; - if ( !Cache(static_cast(i), filename.str()) ) - GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str()); - } - }; + void CacheAll(std::string path); /** Function called to add all music files to list */ - inline void AddMusicFiles(std::string path) { - m_soundPath = path; - CacheMusic("Intro1.ogg"); - CacheMusic("Intro2.ogg"); - CacheMusic("music010.ogg"); - CacheMusic("music011.ogg"); - }; + void AddMusicFiles(std::string path); /** Function called to cache sound effect file. * This function is called by plugin interface for each file. @@ -190,65 +171,65 @@ class CSoundInterface * \param bFile - file to load * \return return true on success */ - inline virtual bool Cache(Sound bSound, std::string bFile) { return true; }; + virtual bool Cache(Sound bSound, std::string bFile); /** Function called to cache music file. * This function is called by CRobotMain for each file used in the mission. * \param bFile - file to load * \return return true on success */ - inline virtual bool CacheMusic(std::string bFile) { return true; }; + virtual bool CacheMusic(std::string bFile); /** Return if plugin is enabled * \return return true if plugin is enabled */ - inline virtual bool GetEnable() {return true;}; + virtual bool GetEnable(); /** Change sound mode to 2D/3D * \param bMode - true to enable 3D sound */ - inline virtual void SetSound3D(bool bMode) {}; + virtual void SetSound3D(bool bMode); /** Return if we use 3D sound * \return true if we have 3D sound enabled */ - inline virtual bool GetSound3D() {return true;}; + virtual bool GetSound3D(); /** Return if we have 3D sound capable card * \return true for 3D sound support */ - inline virtual bool GetSound3DCap() {return true;}; + virtual bool GetSound3DCap(); /** Change global sound volume * \param volume - range from 0 to MAXVOLUME */ - inline virtual void SetAudioVolume(int volume) {}; + virtual void SetAudioVolume(int volume); /** Return global sound volume * \return global volume as int in range from 0 to MAXVOLUME */ - inline virtual int GetAudioVolume() {return 0;}; + virtual int GetAudioVolume(); /** Set music volume * \param volume - range from 0 to MAXVOLUME */ - inline virtual void SetMusicVolume(int volume) {}; + virtual void SetMusicVolume(int volume); /** Return music volume * \return music volume as int in range from 0 to MAXVOLUME */ - inline virtual int GetMusicVolume() {return 0;}; + virtual int GetMusicVolume(); /** Set listener position * \param eye - position of listener * \param lookat - direction listener is looking at */ - inline virtual void SetListener(Math::Vector eye, Math::Vector lookat) {}; + virtual void SetListener(Math::Vector eye, Math::Vector lookat); /** Update data each frame * \param rTime - time since last update */ - inline virtual void FrameMove(float rTime) {}; + virtual void FrameMove(float rTime); /** Play specific sound * \param sound - sound to play @@ -257,7 +238,7 @@ class CSoundInterface * \param bLoop - loop sound * \return identifier of channel that sound will be played on */ - inline virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) {return 0;}; + virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false); /** Play specific sound * \param sound - sound to play @@ -267,13 +248,13 @@ class CSoundInterface * \param bLoop - loop sound * \return identifier of channel that sound will be played on */ - inline virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) {return 0;}; + virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false); /** Remove all operations that would be made on sound in channel. * \param channel - channel to work on * \return return true on success */ - inline virtual bool FlushEnvelope(int channel) {return true;}; + virtual bool FlushEnvelope(int channel); /** Add envelope to sound. Envelope is a operatino that will be performend on sound in future like changing frequency * \param channel - channel to work on @@ -283,74 +264,74 @@ class CSoundInterface * \param oper - operation to perform * \return return true on success */ - inline virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) {return true;}; + virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper); /** Set sound position in space * \param channel - channel to work on * \param pos - new positino of a sound * \return return true on success */ - inline virtual bool Position(int channel, Math::Vector pos) {return true;}; + virtual bool Position(int channel, Math::Vector pos); /** Set sound frequency * \param channel - channel to work on * \param frequency - change sound frequency * \return return true on success */ - inline virtual bool Frequency(int channel, float frequency) {return true;}; + virtual bool Frequency(int channel, float frequency); /** Stop playing sound * \param channel - channel to work on * \return return true on success */ - inline virtual bool Stop(int channel) {return true;}; + virtual bool Stop(int channel); /** Stop playing all sounds * \return return true on success */ - inline virtual bool StopAll() {return true;}; + virtual bool StopAll(); /** Mute/unmute all sounds * \param bMute * \return return true on success */ - inline virtual bool MuteAll(bool bMute) {return true;}; + virtual bool MuteAll(bool bMute); /** Start playing music * \param rank - track number * \param bRepeat - repeat playing * \return return true on success */ - inline virtual bool PlayMusic(int rank, bool bRepeat) {return true;}; + virtual bool PlayMusic(int rank, bool bRepeat); /** Start playing music * \param filename - name of file to play * \param bRepeat - repeat playing * \return return true on success */ - inline virtual bool PlayMusic(std::string filename, bool bRepeat) {return true;}; + virtual bool PlayMusic(std::string filename, bool bRepeat); /** Restart music * @return return true on success */ - inline virtual bool RestartMusic() {return true;}; + virtual bool RestartMusic(); /** Susspend paying music * \return return true on success */ - inline virtual void SuspendMusic() {}; + virtual void SuspendMusic(); /** Stop playing music * \return return true on success */ - inline virtual void StopMusic() {}; + virtual void StopMusic(); /** Check if music if playing * \return return true if music is playing */ - inline virtual bool IsPlayingMusic() {return true;}; + virtual bool IsPlayingMusic(); - protected: - std::string m_soundPath; +protected: + std::string m_soundPath; }; -- cgit v1.2.3-1-g7c22 From 12313fecf5a0ccad45f88575a24582b8363bd5a7 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 27 May 2013 20:59:50 +0200 Subject: Fixed some memory issues * invalid pointer, uninitialized buffer --- src/sound/oalsound/buffer.cpp | 3 +++ src/ui/studio.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp index 193e624..0047f91 100644 --- a/src/sound/oalsound/buffer.cpp +++ b/src/sound/oalsound/buffer.cpp @@ -17,6 +17,8 @@ #include "sound/oalsound/buffer.h" +#include + Buffer::Buffer() { m_loaded = false; @@ -41,6 +43,7 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound) GetLogger()->Debug("Loading audio file: %s\n", filename.c_str()); SF_INFO fileInfo; + memset(&fileInfo, 0, sizeof(SF_INFO)); SNDFILE *file = sf_open(filename.c_str(), SFM_READ, &fileInfo); GetLogger()->Trace(" channels %d\n", fileInfo.channels); diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 24a64c4..e44a465 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -904,7 +904,7 @@ void CStudio::SetInfoText(std::string text, bool bClickable) if ( list == 0 ) return; list->Flush(); // just text - list->SetName(0, text.c_str()); + list->SetItemName(0, text.c_str()); if ( text[0] == 0 ) bClickable = false; list->SetSelectCap(bClickable); -- cgit v1.2.3-1-g7c22 From b22d852b4c4aa89e0394397a703ecfa442b0a928 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 27 May 2013 22:26:44 +0200 Subject: Fixed variable shadowing warnings * fixed -Wshadow warnings * refactored some constructors --- src/common/event.h | 19 ++++++++------- src/graphics/core/color.h | 8 +++---- src/graphics/engine/engine.h | 47 ++++++++++++++++++++++---------------- src/graphics/engine/modelmanager.h | 6 +++-- src/graphics/engine/particle.cpp | 6 ++--- src/graphics/engine/pyro.cpp | 12 ++++++---- src/graphics/engine/text.cpp | 2 +- src/math/matrix.h | 8 +++---- src/math/point.h | 15 ++++++------ src/math/vector.h | 18 +++++++-------- src/object/motion/motionhuman.cpp | 8 +++---- src/object/robotmain.cpp | 19 ++++++++------- src/ui/maindialog.cpp | 6 +++-- src/ui/shortcut.cpp | 2 +- 14 files changed, 93 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/common/event.h b/src/common/event.h index 97b798a..8aef603 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -730,16 +730,15 @@ struct Event ActiveEventData active; }; - Event(EventType type = EVENT_NULL) - { - this->type = type; - - systemEvent = false; - rTime = 0.0f; - mouseButtonsState = 0; - trackedKeysState = 0; - customParam = 0; - } + explicit Event(EventType _type = EVENT_NULL) + : type(_type) + , systemEvent(false) + , rTime(0.0f) + , kmodState(0) + , trackedKeysState(0) + , mouseButtonsState(0) + , customParam(0) + {} }; diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h index 3546611..87a50f4 100644 --- a/src/graphics/core/color.h +++ b/src/graphics/core/color.h @@ -139,10 +139,10 @@ struct ColorHSV //! Returns a string "(h, s, v)" inline std::string ToString() const { - std::stringstream s; - s.precision(3); - s << "(" << h << ", " << s << ", " << v << ")"; - return s.str(); + std::stringstream str; + str.precision(3); + str << "(" << h << ", " << s << ", " << v << ")"; + return str.str(); } }; diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 8763a4e..27aa5dc 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -194,10 +194,15 @@ struct EngineBaseObjDataTier unsigned int staticBufferId; bool updateStaticBuffer; - inline EngineBaseObjDataTier(EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES, - const Material& material = Material(), - int state = ENG_RSTATE_NORMAL) - : type(type), material(material), state(state), staticBufferId(0), updateStaticBuffer(false) {} + inline EngineBaseObjDataTier(EngineTriangleType _type = ENG_TRIANGLE_TYPE_TRIANGLES, + const Material& _material = Material(), + int _state = ENG_RSTATE_NORMAL) + : type(_type) + , material(_material) + , state(_state) + , staticBufferId(0) + , updateStaticBuffer(false) + {} }; /** @@ -209,8 +214,9 @@ struct EngineBaseObjLODTier LODLevel lodLevel; std::vector next; - inline EngineBaseObjLODTier(LODLevel lodLevel = LOD_Constant) - : lodLevel(lodLevel) {} + inline EngineBaseObjLODTier(LODLevel _lodLevel = LOD_Constant) + : lodLevel(_lodLevel) + {} }; /** @@ -225,8 +231,10 @@ struct EngineBaseObjTexTier Texture tex2; std::vector next; - inline EngineBaseObjTexTier(const std::string& tex1Name = "", const std::string& tex2Name = "") - : tex1Name(tex1Name), tex2Name(tex2Name) {} + inline EngineBaseObjTexTier(const std::string& _tex1Name = "", const std::string& _tex2Name = "") + : tex1Name(_tex1Name) + , tex2Name(_tex2Name) + {} }; /** @@ -556,18 +564,17 @@ struct EngineMouse //! Hot point Math::Point hotPoint; - inline EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1, - EngineRenderState mode1 = ENG_RSTATE_NORMAL, - EngineRenderState mode2 = ENG_RSTATE_NORMAL, - Math::Point hotPoint = Math::Point()) - { - this->icon1 = icon1; - this->icon2 = icon2; - this->iconShadow = iconShadow; - this->mode1 = mode1; - this->mode2 = mode2; - this->hotPoint = hotPoint; - } + inline EngineMouse(int _icon1 = -1, int _icon2 = -1, int _iconShadow = -1, + EngineRenderState _mode1 = ENG_RSTATE_NORMAL, + EngineRenderState _mode2 = ENG_RSTATE_NORMAL, + Math::Point _hotPoint = Math::Point()) + : icon1(_icon1) + , icon2(_icon2) + , iconShadow(_iconShadow) + , mode1(_mode1) + , mode2(_mode2) + , hotPoint(_hotPoint) + {} }; diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h index 26ee130..9d50b97 100644 --- a/src/graphics/engine/modelmanager.h +++ b/src/graphics/engine/modelmanager.h @@ -79,8 +79,10 @@ private: std::string fileName; bool mirrored; - inline FileInfo(const std::string& fileName, bool mirrored) - : fileName(fileName), mirrored(mirrored) {} + inline FileInfo(const std::string& _fileName, bool _mirrored) + : fileName(_fileName) + , mirrored(_mirrored) + {} inline bool operator<(const FileInfo& other) const { diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index 10b945e..abee2e2 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -3553,9 +3553,9 @@ void CParticle::DrawParticle(int sheet) { m_engine->SetTexture("text.png"); m_engine->SetState(ENG_RSTATE_TTEXTURE_WHITE); - Math::Matrix mat; - mat.LoadIdentity(); - m_device->SetTransform(TRANSFORM_WORLD, mat); + Math::Matrix matrix; + matrix.LoadIdentity(); + m_device->SetTransform(TRANSFORM_WORLD, matrix); for (int i = 0; i < m_wheelTraceTotal; i++) DrawParticleWheel(i); diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index 975a211..0a85beb 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -89,13 +89,15 @@ bool CPyro::Create(PyroType type, CObject* obj, float force) DisplayError(type, obj); // displays eventual messages - int i = 0; - // Copies all spheres of the object. - for (; i < 50; i++) { - if ( !obj->GetCrashSphere(i, m_crashSpherePos[i], m_crashSphereRadius[i]) ) break; + int i = 0; + // Copies all spheres of the object. + for (; i < 50; i++) + { + if ( !obj->GetCrashSphere(i, m_crashSpherePos[i], m_crashSphereRadius[i]) ) break; + } + m_crashSphereUsed = i; } - m_crashSphereUsed = i; // Calculates the size of the effect. if ( oType == OBJECT_ANT || diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 9bc8bd0..610bfcf 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -613,7 +613,7 @@ void CText::DrawString(const std::string &text, std::vector::itera float cw = GetCharWidth(ch, font, size, offset); if (offset + cw > width) // exceeds the maximum width? { - UTF8Char ch = TranslateSpecialChar(CHAR_SKIP_RIGHT); + ch = TranslateSpecialChar(CHAR_SKIP_RIGHT); cw = GetCharWidth(ch, font, size, offset); pos.x = start + width - cw; color = Color(1.0f, 0.0f, 0.0f); diff --git a/src/math/matrix.h b/src/math/matrix.h index 67ccb48..a13f823 100644 --- a/src/math/matrix.h +++ b/src/math/matrix.h @@ -73,10 +73,10 @@ struct Matrix //! Creates the matrix from 1D array /** \a m matrix values in column-major order */ - inline explicit Matrix(const float (&m)[16]) + inline explicit Matrix(const float (&_m)[16]) { for (int i = 0; i < 16; ++i) - this->m[i] = m[i]; + m[i] = _m[i]; } //! Creates the matrix from 2D array @@ -84,13 +84,13 @@ struct Matrix * The array's first index is row, second is column. * \param m array with values */ - inline explicit Matrix(const float (&m)[4][4]) + inline explicit Matrix(const float (&_m)[4][4]) { for (int c = 0; c < 4; ++c) { for (int r = 0; r < 4; ++r) { - this->m[4*c+r] = m[r][c]; + m[4*c+r] = _m[r][c]; } } } diff --git a/src/math/point.h b/src/math/point.h index 65de94c..edb902b 100644 --- a/src/math/point.h +++ b/src/math/point.h @@ -52,16 +52,15 @@ struct Point //! Constructs a zero point: (0,0) inline Point() - { - LoadZero(); - } + : x(0.0f) + , y(0.0f) + {} //! Constructs a point from given coords: (x,y) - inline explicit Point(float x, float y) - { - this->x = x; - this->y = y; - } + inline explicit Point(float _x, float _y) + : x(_x) + , y(_y) + {} //! Sets the zero point: (0,0) inline void LoadZero() diff --git a/src/math/vector.h b/src/math/vector.h index 38886d0..6827785 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -57,17 +57,17 @@ struct Vector //! Creates a zero vector (0, 0, 0) inline Vector() - { - LoadZero(); - } + : x(0.0f) + , y(0.0f) + , z(0.0f) + {} //! Creates a vector from given values - inline explicit Vector(float x, float y, float z) - { - this->x = x; - this->y = y; - this->z = z; - } + inline explicit Vector(float _x, float _y, float _z) + : x(_x) + , y(_y) + , z(_z) + {} //! Loads the zero vector (0, 0, 0) inline void LoadZero() diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index b1de44e..edee260 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -1617,18 +1617,18 @@ bool CMotionHuman::EventFrame(const Event &event) legAction == MH_MARCHTAKE ) { Sound sound[2]; - float speed, synchro, volume[2], freq[2], hard, level; + float synchro, volume[2], freq[2], hard; - speed = m_physics->GetLinMotionX(MO_REASPEED); + float speedX = m_physics->GetLinMotionX(MO_REASPEED); if ( m_object->GetFret() == 0 ) { - if ( speed > 0.0f ) synchro = 0.21f; // synchro forward + if ( speedX > 0.0f ) synchro = 0.21f; // synchro forward else synchro = 0.29f; // synchro backward } else { - if ( speed > 0.0f ) synchro = 0.15f; // synchro forward + if ( speedX > 0.0f ) synchro = 0.15f; // synchro forward else synchro = 0.35f; // synchro backward } time = rTime[1]+synchro; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 34f13f6..27492f3 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4082,7 +4082,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2) { - char filename[100]; OpString(line, "filename", filename); m_sound->CacheMusic(filename); continue; @@ -4116,9 +4115,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) int trackid = OpInt(line, "track", 0); if (trackid != 0) { - std::stringstream filename; - filename << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; - m_audioTrack = filename.str(); + std::stringstream filenameStr; + filenameStr << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; + m_audioTrack = filenameStr.str(); } } else @@ -4392,10 +4391,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) AddExt(name, ".png"); int dx = OpInt(line, "dx", 1); int dy = OpInt(line, "dy", 1); - char* op = SearchOp(line, "table"); + char* opTable = SearchOp(line, "table"); int tt[100]; for (int i = 0; i < dx*dy; i++) - tt[i] = GetInt(op, i, 0); + tt[i] = GetInt(opTable, i, 0); if (strstr(name, "%user%") != 0) CopyFileListToTemp(name, tt, dx*dy); @@ -4484,12 +4483,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - char* op = SearchOp(line, "id"); + char* opId = SearchOp(line, "id"); int id[50]; int i = 0; while (i < 50) { - id[i] = GetInt(op, i, 0); + id[i] = GetInt(opId, i, 0); if (id[i++] == 0) break; } @@ -4589,9 +4588,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } Math::Vector pos = OpPos(line, "pos")*g_unit; - float dir = OpFloat(line, "dir", 0.0f)*Math::PI; + float dirAngle = OpFloat(line, "dir", 0.0f)*Math::PI; bool trainer = OpInt(line, "trainer", 0); - CObject* obj = CreateObject(pos, dir, + CObject* obj = CreateObject(pos, dirAngle, OpFloat(line, "z", 1.0f), OpFloat(line, "h", 0.0f), type, diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index dfc2d52..8f5b936 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -3677,8 +3677,9 @@ void CMainDialog::ReadNameList() { fs::directory_iterator dirIt(m_savegameDir), dirEndIt; - BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt)) + for (; dirIt != dirEndIt; ++dirIt) { + const fs::path& p = *dirIt; if (fs::is_directory(p)) { fileNames.push_back(p.leaf().string()); @@ -4745,8 +4746,9 @@ void CMainDialog::UpdateSceneChap(int &chap) fs::directory_iterator dirIt(m_savegameDir), dirEndIt; m_userList.clear(); - BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt)) + for (; dirIt != dirEndIt; ++dirIt) { + const fs::path& p = *dirIt; if (fs::is_directory(p)) { m_userList.push_back(p.leaf().string()); diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index 7231d5d..a01864a 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -128,7 +128,7 @@ void CShortcut::Draw() if ( m_state & STATE_FRAME ) { Math::Point p1, p2, c, uv1, uv2; - float zoom, dp; + float dp; m_engine->SetTexture("button2.png"); m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); -- cgit v1.2.3-1-g7c22 From 18b27d258efa59a08406c061190d8ea1d70f314c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 8 Jun 2013 17:51:31 +0200 Subject: Fixed bug with white map I'm not sure when it was introduced, probably in 8f6fd2a1316432970f1d86515819e7bbe15ddab3. It was showing errors like "Couldn't load texture 'map.png'" and "Invalid texture data" --- src/graphics/engine/engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 4d0687a..785383a 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -2156,7 +2156,7 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa image = &img; } - tex = m_device->CreateTexture(&img, params); + tex = m_device->CreateTexture(image, params); if (! tex.Valid()) { -- cgit v1.2.3-1-g7c22 From e8e220085a73e470bf29aa47e63e19d427913962 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 10 Jun 2013 15:44:25 +0200 Subject: Fixed bug with showing wrong filename in Level Checker errors after using CacheAudio --- src/object/robotmain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 27492f3..6539372 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4082,8 +4082,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2) { - OpString(line, "filename", filename); - m_sound->CacheMusic(filename); + OpString(line, "filename", name); + m_sound->CacheMusic(name); continue; } -- cgit v1.2.3-1-g7c22 From 7cf88118885699a23daa4768285d512fc06d5a2a Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 13 Jun 2013 17:25:58 +0200 Subject: Fix for #195 * loading time now is not counted in elapsed time --- src/app/app.cpp | 15 +++++++++++++-- src/app/app.h | 6 ++++++ src/object/robotmain.cpp | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 932e61e..7acef31 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1264,13 +1264,24 @@ void CApplication::SuspendSimulation() void CApplication::ResumeSimulation() { m_simulationSuspended = false; + InternalResumeSimulation(); + GetLogger()->Info("Resume simulation\n"); +} + +void CApplication::ResetTimeAfterLoading() +{ + InternalResumeSimulation(); + + GetLogger()->Trace("Resume simulation on loading\n"); +} + +void CApplication::InternalResumeSimulation() +{ GetSystemUtils()->GetCurrentTimeStamp(m_baseTimeStamp); GetSystemUtils()->CopyTimeStamp(m_curTimeStamp, m_baseTimeStamp); m_realAbsTimeBase = m_realAbsTime; m_absTimeBase = m_exactAbsTime; - - GetLogger()->Info("Resume simulation\n"); } bool CApplication::GetSimulationSuspended() const diff --git a/src/app/app.h b/src/app/app.h index 34028c7..6c53cf9 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -234,6 +234,9 @@ public: //! Returns whether simulation is suspended bool GetSimulationSuspended() const; + //! Resets time counters to account for time spent loading game + void ResetTimeAfterLoading(); + //@{ //! Management of simulation speed void SetSimulationSpeed(float speed); @@ -368,6 +371,9 @@ protected: //! Closes the joystick device void CloseJoystick(); + //! Internal procedure to reset time counters + void InternalResumeSimulation(); + //! Resets all performance counters to zero void ResetPerformanceCounters(); //! Updates performance counters from gathered timer data diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 6539372..9b37a84 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1196,6 +1196,8 @@ void CRobotMain::ChangePhase(Phase phase) if (m_mapImage) m_map->SetFixImage(m_mapFilename); + m_app->ResetTimeAfterLoading(); + /*Math::Point ddim; pos.x = 620.0f/640.0f; -- cgit v1.2.3-1-g7c22 From 7874aca10ce6da823f88e8aabe4a0ea6431cc480 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Jun 2013 21:39:21 +0200 Subject: Enhanced logging, option to auto-start mission * added logging of application events * changed debug mode flag to independent debug modes * added option to auto-start mission (load a mission immediately after startup) * removed "enum value out of range" prints * some refactoring --- src/CMakeLists.txt | 2 +- src/app/app.cpp | 345 ++++++++++++---------- src/app/app.h | 35 ++- src/app/main.cpp | 4 +- src/common/event.cpp | 536 ++++++++++++++++++++++++++++++++++- src/common/event.h | 29 +- src/common/profile.h | 2 +- src/common/restext.cpp | 6 +- src/graphics/engine/modelfile.cpp | 79 +++--- src/graphics/engine/modelfile.h | 4 + src/graphics/engine/modelmanager.cpp | 3 + src/object/robotmain.cpp | 23 +- src/object/robotmain.h | 5 +- src/ui/maindialog.cpp | 3 +- 14 files changed, 861 insertions(+), 215 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6318ef2..8493fe8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,7 +219,7 @@ ${GLEW_INCLUDE_PATH} ${Boost_INCLUDE_DIRS} ${LIBSNDFILE_INCLUDE_DIR} ${OPTIONAL_INCLUDE_DIRS} -${CLIPBOARD_DIR} +${CLIPBOARD_INCLUDE_DIR} ) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot) diff --git a/src/app/app.cpp b/src/app/app.cpp index 7acef31..d57bbc3 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -25,13 +25,19 @@ #include "common/iman.h" #include "common/image.h" #include "common/key.h" +#include "common/stringutils.h" #include "graphics/engine/modelmanager.h" #include "graphics/opengl/gldevice.h" #include "object/robotmain.h" +#ifdef OPENAL_SOUND + #include "sound/oalsound/alsound.h" +#endif + #include +#include #include #include @@ -42,11 +48,6 @@ #include -#ifdef OPENAL_SOUND - #include "sound/oalsound/alsound.h" -#endif - - template<> CApplication* CSingleton::m_instance = nullptr; //! Static buffer for putenv locale @@ -107,7 +108,7 @@ CApplication::CApplication() m_exitCode = 0; m_active = false; - m_debugMode = false; + m_debugModes = 0; m_windowTitle = "COLOBOT"; @@ -148,10 +149,15 @@ CApplication::CApplication() m_langPath = COLOBOT_I18N_DIR; m_texPackPath = ""; + m_runSceneName = ""; + m_runSceneRank = 0; + m_language = LANGUAGE_ENV; m_lowCPU = true; + m_protoMode = false; + for (int i = 0; i < DIR_MAX; ++i) m_standardDataDirs[i] = nullptr; @@ -216,24 +222,27 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) { OPT_HELP = 1, OPT_DEBUG, - OPT_DATADIR, + OPT_RUNSCENE, OPT_LOGLEVEL, OPT_LANGUAGE, + OPT_DATADIR, OPT_LANGDIR, + OPT_TEXPACK, OPT_VBO, - OPT_TEXPACK + OPT_PROTO }; option options[] = { { "help", no_argument, nullptr, OPT_HELP }, - { "debug", no_argument, nullptr, OPT_DEBUG }, - { "datadir", required_argument, nullptr, OPT_DATADIR }, + { "debug", required_argument, nullptr, OPT_DEBUG }, + { "runscene", required_argument, nullptr, OPT_RUNSCENE }, { "loglevel", required_argument, nullptr, OPT_LOGLEVEL }, { "language", required_argument, nullptr, OPT_LANGUAGE }, + { "datadir", required_argument, nullptr, OPT_DATADIR }, { "langdir", required_argument, nullptr, OPT_LANGDIR }, - { "vbo", required_argument, nullptr, OPT_VBO }, { "texpack", required_argument, nullptr, OPT_TEXPACK }, + { "vbo", required_argument, nullptr, OPT_VBO }, { nullptr, 0, nullptr, 0} }; @@ -264,37 +273,44 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) GetLogger()->Message("Colobot %s (%s)\n", COLOBOT_CODENAME, COLOBOT_VERSION); GetLogger()->Message("\n"); GetLogger()->Message("List of available options:\n"); - GetLogger()->Message(" -help this help\n"); - GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n"); - GetLogger()->Message(" -datadir path set custom data directory path\n"); - GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n"); - GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n"); - GetLogger()->Message(" -langdir path set custom language directory path\n"); - GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n"); - GetLogger()->Message(" -texpack path set path to custom texture pack\n"); + GetLogger()->Message(" -help this help\n"); + GetLogger()->Message(" -debug modes enable debug modes (more info printed in logs; see code for reference of modes)\n"); + GetLogger()->Message(" -runscene sceneNNN run given scene on start\n"); + GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n"); + GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n"); + GetLogger()->Message(" -datadir path set custom data directory path\n"); + GetLogger()->Message(" -langdir path set custom language directory path\n"); + GetLogger()->Message(" -texpack path set path to custom texture pack\n"); + GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n"); + GetLogger()->Message(" -proto show prototype levels\n"); return PARSE_ARGS_HELP; } case OPT_DEBUG: { - SetDebugMode(true); - break; - } - case OPT_DATADIR: - { - m_dataPath = optarg; - GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str()); - break; - } - case OPT_LANGDIR: - { - m_langPath = optarg; - GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str()); + if (optarg == nullptr) + { + m_debugModes = DEBUG_ALL; + GetLogger()->Info("All debug modes active\n"); + } + else + { + int debugModes; + if (! ParseDebugModes(optarg, debugModes)) + { + return PARSE_ARGS_FAIL; + } + + m_debugModes = debugModes; + GetLogger()->Info("Active debug modes: %s\n", optarg); + } break; } - case OPT_TEXPACK: + case OPT_RUNSCENE: { - m_texPackPath = optarg; - GetLogger()->Info("Using texturepack: '%s'\n", m_texPackPath.c_str()); + std::string file = optarg; + m_runSceneName = file.substr(0, file.size()-3); + m_runSceneRank = StrUtils::FromString(file.substr(file.size()-3, 3)); + GetLogger()->Info("Running scene '%s%d' on start\n", m_runSceneName.c_str(), m_runSceneRank); break; } case OPT_LOGLEVEL: @@ -302,7 +318,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) LogLevel logLevel; if (! CLogger::ParseLogLevel(optarg, logLevel)) { - GetLogger()->Error("Invalid log level: \"%s\"\n", optarg); + GetLogger()->Error("Invalid log level: '%s'\n", optarg); return PARSE_ARGS_FAIL; } @@ -315,7 +331,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) Language language; if (! ParseLanguage(optarg, language)) { - GetLogger()->Error("Invalid language: \"%s\"\n", optarg); + GetLogger()->Error("Invalid language: '%s'\n", optarg); return PARSE_ARGS_FAIL; } @@ -323,6 +339,24 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) m_language = language; break; } + case OPT_DATADIR: + { + m_dataPath = optarg; + GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str()); + break; + } + case OPT_LANGDIR: + { + m_langPath = optarg; + GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str()); + break; + } + case OPT_TEXPACK: + { + m_texPackPath = optarg; + GetLogger()->Info("Using texturepack: '%s'\n", m_texPackPath.c_str()); + break; + } case OPT_VBO: { std::string vbo; @@ -335,12 +369,17 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) m_deviceConfig.vboMode = Gfx::VBO_MODE_DISABLE; else { - GetLogger()->Error("Invalid vbo mode: \"%s\"\n", optarg); + GetLogger()->Error("Invalid vbo mode: '%s'\n", optarg); return PARSE_ARGS_FAIL; } break; } + case OPT_PROTO: + { + m_protoMode = true; + break; + } default: assert(false); // should never get here } @@ -517,7 +556,10 @@ bool CApplication::Create() if (defaultValues) m_robotMain->CreateIni(); - m_robotMain->ChangePhase(PHASE_WELCOME1); + if (! m_runSceneName.empty()) + m_robotMain->LoadSceneOnStart(m_runSceneName, m_runSceneRank); + else + m_robotMain->ChangePhase(PHASE_WELCOME1); return true; } @@ -641,7 +683,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig) if (! CreateVideoSurface()) { // Fatal error, so post the quit event - m_eventQueue->AddEvent(Event(EVENT_QUIT)); + m_eventQueue->AddEvent(Event(EVENT_SYS_QUIT)); return false; } @@ -670,7 +712,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig) // Fatal error, so post the quit event - m_eventQueue->AddEvent(Event(EVENT_QUIT)); + m_eventQueue->AddEvent(Event(EVENT_SYS_QUIT)); return false; } } @@ -854,31 +896,15 @@ int CApplication::Run() Event event = ProcessSystemEvent(); - if (event.type == EVENT_QUIT) + if (event.type == EVENT_SYS_QUIT) goto end; // exit the loop if (event.type != EVENT_NULL) - { - bool passOn = ProcessEvent(event); - - if (m_engine != nullptr && passOn) - passOn = m_engine->ProcessEvent(event); - - if (passOn) - m_eventQueue->AddEvent(event); - } + m_eventQueue->AddEvent(event); Event virtualEvent = CreateVirtualEvent(event); if (virtualEvent.type != EVENT_NULL) - { - bool passOn = ProcessEvent(virtualEvent); - - if (m_engine != nullptr && passOn) - passOn = m_engine->ProcessEvent(virtualEvent); - - if (passOn) - m_eventQueue->AddEvent(virtualEvent); - } + m_eventQueue->AddEvent(virtualEvent); } } @@ -889,19 +915,11 @@ int CApplication::Run() Event event = ProcessSystemEvent(); - if (event.type == EVENT_QUIT) + if (event.type == EVENT_SYS_QUIT) goto end; // exit the loop if (event.type != EVENT_NULL) - { - bool passOn = ProcessEvent(event); - - if (m_engine != nullptr && passOn) - passOn = m_engine->ProcessEvent(event); - - if (passOn) - m_eventQueue->AddEvent(event); - } + m_eventQueue->AddEvent(event); } // Enter game update & frame rendering only if active @@ -910,22 +928,17 @@ int CApplication::Run() Event event; while (m_eventQueue->GetEvent(event)) { - if (event.type == EVENT_QUIT) + if (event.type == EVENT_SYS_QUIT || event.type == EVENT_QUIT) goto end; // exit both loops - bool passOn = true; - - // Skip system events (they have been processed earlier) - if (! event.systemEvent) - { - passOn = ProcessEvent(event); + LogEvent(event); - if (passOn && m_engine != nullptr) - passOn = m_engine->ProcessEvent(event); - } + bool passOn = true; + if (m_engine != nullptr) + passOn = m_engine->ProcessEvent(event); if (passOn && m_robotMain != nullptr) - m_robotMain->EventProcess(event); + m_robotMain->ProcessEvent(event); } StopPerformanceCounter(PCNT_EVENT_PROCESSING); @@ -936,6 +949,8 @@ int CApplication::Run() event = CreateUpdateEvent(); if (event.type != EVENT_NULL && m_robotMain != nullptr) { + LogEvent(event); + StartPerformanceCounter(PCNT_UPDATE_ENGINE); m_engine->FrameUpdate(); StopPerformanceCounter(PCNT_UPDATE_ENGINE); @@ -943,7 +958,7 @@ int CApplication::Run() m_sound->FrameMove(m_relTime); StartPerformanceCounter(PCNT_UPDATE_GAME); - m_robotMain->EventProcess(event); + m_robotMain->ProcessEvent(event); StopPerformanceCounter(PCNT_UPDATE_GAME); } @@ -989,11 +1004,10 @@ const std::string& CApplication::GetErrorMessage() const Event CApplication::ProcessSystemEvent() { Event event; - event.systemEvent = true; if (m_private->currentEvent.type == SDL_QUIT) { - event.type = EVENT_QUIT; + event.type = EVENT_SYS_QUIT; } else if (m_private->currentEvent.type == SDL_VIDEORESIZE) { @@ -1139,76 +1153,74 @@ Event CApplication::ProcessSystemEvent() return event; } -/** - * Processes incoming events. It is the first function called after an event is captured. - * Event is modified, updating its tracked keys state and mouse position to current values. - * Function returns \c true if the event is to be passed on to other processing functions - * or \c false if not. */ -bool CApplication::ProcessEvent(const Event &event) +void CApplication::LogEvent(const Event &event) { CLogger *l = GetLogger(); - // Print the events in debug mode to test the code - if (m_debugMode) + auto PrintEventDetails = [&]() { - switch (event.type) - { - case EVENT_KEY_DOWN: - case EVENT_KEY_UP: - l->Trace("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP"); - l->Trace(" virt = %s\n", (event.key.virt) ? "true" : "false"); - l->Trace(" key = %d\n", event.key.key); - l->Trace(" unicode = 0x%04x\n", event.key.unicode); - break; - case EVENT_MOUSE_MOVE: - l->Trace("EVENT_MOUSE_MOVE:\n"); - break; - case EVENT_MOUSE_BUTTON_DOWN: - case EVENT_MOUSE_BUTTON_UP: - l->Trace("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP"); - l->Trace(" button = %d\n", event.mouseButton.button); - break; - case EVENT_MOUSE_WHEEL: - l->Trace("EVENT_MOUSE_WHEEL:\n"); - l->Trace(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP"); - break; - case EVENT_JOY_AXIS: - l->Trace("EVENT_JOY_AXIS:\n"); - l->Trace(" axis = %d\n", event.joyAxis.axis); - l->Trace(" value = %d\n", event.joyAxis.value); - break; - case EVENT_JOY_BUTTON_DOWN: - case EVENT_JOY_BUTTON_UP: - l->Trace("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP"); - l->Trace(" button = %d\n", event.joyButton.button); - break; - case EVENT_ACTIVE: - l->Trace("EVENT_ACTIVE:\n"); - l->Trace(" flags = 0x%x\n", event.active.flags); - l->Trace(" gain = %s\n", event.active.gain ? "true" : "false"); - break; - default: - l->Trace("Event type = %d:\n", static_cast(event.type)); - break; - } - - l->Trace(" systemEvent = %s\n", event.systemEvent ? "true" : "false"); l->Trace(" rTime = %f\n", event.rTime); l->Trace(" kmodState = %04x\n", event.kmodState); l->Trace(" trackedKeysState = %04x\n", event.trackedKeysState); l->Trace(" mousePos = %f, %f\n", event.mousePos.x, event.mousePos.y); l->Trace(" mouseButtonsState = %02x\n", event.mouseButtonsState); - } + l->Trace(" customParam = %d\n", event.customParam); + }; - // By default, pass on all events - return true; + // Print the events in debug mode to test the code + if (IsDebugModeActive(DEBUG_SYS_EVENTS) || IsDebugModeActive(DEBUG_APP_EVENTS)) + { + std::string eventType = ParseEventType(event.type); + + if (IsDebugModeActive(DEBUG_SYS_EVENTS) && event.type <= EVENT_SYS_MAX) + { + l->Trace("System event %s:\n", eventType.c_str()); + switch (event.type) + { + case EVENT_KEY_DOWN: + case EVENT_KEY_UP: + l->Trace(" virt = %s\n", (event.key.virt) ? "true" : "false"); + l->Trace(" key = %d\n", event.key.key); + l->Trace(" unicode = 0x%04x\n", event.key.unicode); + break; + case EVENT_MOUSE_BUTTON_DOWN: + case EVENT_MOUSE_BUTTON_UP: + l->Trace(" button = %d\n", event.mouseButton.button); + break; + case EVENT_MOUSE_WHEEL: + l->Trace(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP"); + break; + case EVENT_JOY_AXIS: + l->Trace(" axis = %d\n", event.joyAxis.axis); + l->Trace(" value = %d\n", event.joyAxis.value); + break; + case EVENT_JOY_BUTTON_DOWN: + case EVENT_JOY_BUTTON_UP: + l->Trace(" button = %d\n", event.joyButton.button); + break; + case EVENT_ACTIVE: + l->Trace(" flags = 0x%x\n", event.active.flags); + l->Trace(" gain = %s\n", event.active.gain ? "true" : "false"); + break; + default: + break; + } + + PrintEventDetails(); + } + + if (IsDebugModeActive(DEBUG_APP_EVENTS) && event.type > EVENT_SYS_MAX) + { + l->Trace("App event %s:\n", eventType.c_str()); + PrintEventDetails(); + } + } } Event CApplication::CreateVirtualEvent(const Event& sourceEvent) { Event virtualEvent; - virtualEvent.systemEvent = true; if ((sourceEvent.type == EVENT_KEY_DOWN) || (sourceEvent.type == EVENT_KEY_UP)) { @@ -1316,7 +1328,7 @@ Event CApplication::CreateUpdateEvent() { GetLogger()->Error("Fatal error: got negative system counter difference!\n"); GetLogger()->Error("This should never happen. Please report this error.\n"); - m_eventQueue->AddEvent(Event(EVENT_QUIT)); + m_eventQueue->AddEvent(Event(EVENT_SYS_QUIT)); return Event(EVENT_NULL); } else @@ -1332,7 +1344,6 @@ Event CApplication::CreateUpdateEvent() } Event frameEvent(EVENT_FRAME); - frameEvent.systemEvent = true; frameEvent.trackedKeysState = m_trackedKeys; frameEvent.kmodState = m_kmodState; frameEvent.mousePos = m_mousePos; @@ -1425,14 +1436,55 @@ VideoQueryResult CApplication::GetVideoResolutionList(std::vector sep(","); + boost::tokenizer> tokens(str, sep); + for (const auto& modeToken : tokens) + { + if (modeToken == "sys_events") + { + debugModes |= DEBUG_SYS_EVENTS; + } + else if (modeToken == "app_events") + { + debugModes |= DEBUG_APP_EVENTS; + } + else if (modeToken == "events") + { + debugModes |= DEBUG_EVENTS; + } + else if (modeToken == "models") + { + debugModes |= DEBUG_MODELS; + } + else if (modeToken == "all") + { + debugModes = DEBUG_ALL; + } + else + { + GetLogger()->Error("Invalid debug mode: '%s'\n", modeToken.c_str()); + return false; + } + } + + return true; } int CApplication::GetKmods() const @@ -1782,3 +1834,8 @@ void CApplication::UpdatePerformanceCountersData() } } +bool CApplication::GetProtoMode() const +{ + return m_protoMode; +} + diff --git a/src/app/app.h b/src/app/app.h index 6c53cf9..269fa9b 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -143,6 +143,15 @@ enum PerformanceCounter PCNT_MAX }; +enum DebugMode +{ + DEBUG_SYS_EVENTS = 1 << 0, + DEBUG_APP_EVENTS = 1 << 1, + DEBUG_EVENTS = DEBUG_SYS_EVENTS | DEBUG_APP_EVENTS, + DEBUG_MODELS = 1 << 2, + DEBUG_ALL = DEBUG_SYS_EVENTS | DEBUG_APP_EVENTS | DEBUG_MODELS +}; + struct ApplicationPrivate; /** @@ -312,10 +321,11 @@ public: //! Moves (warps) the mouse cursor to the specified position (in interface coords) void MoveMouse(Math::Point pos); - //! Management of debug mode (prints more info in logger) + //! Management of debug modes (printing more info in logger) //@{ - void SetDebugMode(bool mode); - bool GetDebugMode() const; + void SetDebugModeActive(DebugMode mode, bool active); + bool IsDebugModeActive(DebugMode mode) const; + static bool ParseDebugModes(const std::string& str, int& debugModes); //@} //! Returns the full path to data directory @@ -351,6 +361,8 @@ public: float GetPerformanceCounterData(PerformanceCounter counter) const; //@} + bool GetProtoMode() const; + protected: //! Creates the window's SDL_Surface bool CreateVideoSurface(); @@ -361,8 +373,8 @@ protected: Event CreateVirtualEvent(const Event& sourceEvent); //! Prepares a simulation update event TEST_VIRTUAL Event CreateUpdateEvent(); - //! Handles some incoming events - bool ProcessEvent(const Event& event); + //! Logs debug data for event + void LogEvent(const Event& event); //! Renders the image in window void Render(); @@ -406,8 +418,8 @@ protected: int m_exitCode; //! Whether application window is active bool m_active; - //! Whether debug mode is enabled - bool m_debugMode; + //! Bit array of active debug modes + long m_debugModes; //! Message to be displayed as error to the user std::string m_errorMessage; @@ -474,6 +486,12 @@ protected: //! Path to directory with user texture pack std::string m_texPackPath; + //@{ + //! Scene to run on startup + std::string m_runSceneName; + int m_runSceneRank; + //@} + const char* m_standardDataDirs[DIR_MAX]; //! Application language @@ -481,5 +499,8 @@ protected: //! Low cpu mode bool m_lowCPU; + + //! Show prototype levels + bool m_protoMode; }; diff --git a/src/app/main.cpp b/src/app/main.cpp index 4bd5daa..5c0afd3 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -78,7 +78,9 @@ int SDL_MAIN_FUNC(int argc, char *argv[]) { CLogger logger; // single istance of logger - InitializeRestext(); // init static translation strings + // Initialize static string arrays + InitializeRestext(); + InitializeEventTypeTexts(); CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils systemUtils->Init(); diff --git a/src/common/event.cpp b/src/common/event.cpp index ff3fbc7..7acac77 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -19,15 +19,541 @@ #include "common/logger.h" -static EventType g_uniqueEventType = EVENT_USER; +namespace +{ +static EventType UNIQUE_EVENT_TYPE = EVENT_USER; +const char* EVENT_TYPE_TEXT[EVENT_STD_MAX]; +} +EventType GetUniqueEventType() +{ + int i = static_cast(UNIQUE_EVENT_TYPE+1); + UNIQUE_EVENT_TYPE = static_cast(i); + return UNIQUE_EVENT_TYPE; +} +void InitializeEventTypeTexts() +{ + for (int i = 0; i < EVENT_STD_MAX; ++i) + EVENT_TYPE_TEXT[i] = ""; -EventType GetUniqueEventType() + EVENT_TYPE_TEXT[EVENT_NULL] = "EVENT_NULL"; + + EVENT_TYPE_TEXT[EVENT_QUIT] = "EVENT_QUIT"; + + EVENT_TYPE_TEXT[EVENT_FRAME] = "EVENT_FRAME"; + + EVENT_TYPE_TEXT[EVENT_MOUSE_BUTTON_DOWN] = "EVENT_MOUSE_BUTTON_DOWN"; + EVENT_TYPE_TEXT[EVENT_MOUSE_BUTTON_UP] = "EVENT_MOUSE_BUTTON_UP"; + EVENT_TYPE_TEXT[EVENT_MOUSE_WHEEL] = "EVENT_MOUSE_WHEEL"; + EVENT_TYPE_TEXT[EVENT_MOUSE_MOVE] = "EVENT_MOUSE_MOVE"; + EVENT_TYPE_TEXT[EVENT_KEY_DOWN] = "EVENT_KEY_DOWN"; + EVENT_TYPE_TEXT[EVENT_KEY_UP] = "EVENT_KEY_UP"; + + EVENT_TYPE_TEXT[EVENT_ACTIVE] = "EVENT_ACTIVE"; + + EVENT_TYPE_TEXT[EVENT_JOY_AXIS] = "EVENT_JOY_AXIS"; + EVENT_TYPE_TEXT[EVENT_JOY_BUTTON_DOWN] = "EVENT_JOY_BUTTON_DOWN"; + EVENT_TYPE_TEXT[EVENT_JOY_BUTTON_UP] = "EVENT_JOY_BUTTON_UP"; + + + EVENT_TYPE_TEXT[EVENT_UPDINTERFACE] = "EVENT_UPDINTERFACE"; + EVENT_TYPE_TEXT[EVENT_WIN] = "EVENT_WIN"; + EVENT_TYPE_TEXT[EVENT_LOST] = "EVENT_LOST"; + + EVENT_TYPE_TEXT[EVENT_FOCUS] = "EVENT_FOCUS"; + + EVENT_TYPE_TEXT[EVENT_BUTTON_OK] = "EVENT_BUTTON_OK"; + EVENT_TYPE_TEXT[EVENT_BUTTON_CANCEL] = "EVENT_BUTTON_CANCEL"; + EVENT_TYPE_TEXT[EVENT_BUTTON_NEXT] = "EVENT_BUTTON_NEXT"; + EVENT_TYPE_TEXT[EVENT_BUTTON_PREV] = "EVENT_BUTTON_PREV"; + EVENT_TYPE_TEXT[EVENT_BUTTON_QUIT] = "EVENT_BUTTON_QUIT"; + + EVENT_TYPE_TEXT[EVENT_BUTTON0] = "EVENT_BUTTON0"; + EVENT_TYPE_TEXT[EVENT_BUTTON1] = "EVENT_BUTTON1"; + EVENT_TYPE_TEXT[EVENT_BUTTON2] = "EVENT_BUTTON2"; + EVENT_TYPE_TEXT[EVENT_BUTTON3] = "EVENT_BUTTON3"; + EVENT_TYPE_TEXT[EVENT_BUTTON4] = "EVENT_BUTTON4"; + EVENT_TYPE_TEXT[EVENT_BUTTON5] = "EVENT_BUTTON5"; + EVENT_TYPE_TEXT[EVENT_BUTTON6] = "EVENT_BUTTON6"; + EVENT_TYPE_TEXT[EVENT_BUTTON7] = "EVENT_BUTTON7"; + EVENT_TYPE_TEXT[EVENT_BUTTON8] = "EVENT_BUTTON8"; + EVENT_TYPE_TEXT[EVENT_BUTTON9] = "EVENT_BUTTON9"; + EVENT_TYPE_TEXT[EVENT_BUTTON10] = "EVENT_BUTTON10"; + EVENT_TYPE_TEXT[EVENT_BUTTON11] = "EVENT_BUTTON11"; + EVENT_TYPE_TEXT[EVENT_BUTTON12] = "EVENT_BUTTON12"; + EVENT_TYPE_TEXT[EVENT_BUTTON13] = "EVENT_BUTTON13"; + EVENT_TYPE_TEXT[EVENT_BUTTON14] = "EVENT_BUTTON14"; + EVENT_TYPE_TEXT[EVENT_BUTTON15] = "EVENT_BUTTON15"; + EVENT_TYPE_TEXT[EVENT_BUTTON16] = "EVENT_BUTTON16"; + EVENT_TYPE_TEXT[EVENT_BUTTON17] = "EVENT_BUTTON17"; + EVENT_TYPE_TEXT[EVENT_BUTTON18] = "EVENT_BUTTON18"; + EVENT_TYPE_TEXT[EVENT_BUTTON19] = "EVENT_BUTTON19"; + + EVENT_TYPE_TEXT[EVENT_EDIT0] = "EVENT_EDIT0"; + EVENT_TYPE_TEXT[EVENT_EDIT1] = "EVENT_EDIT1"; + EVENT_TYPE_TEXT[EVENT_EDIT2] = "EVENT_EDIT2"; + EVENT_TYPE_TEXT[EVENT_EDIT3] = "EVENT_EDIT3"; + EVENT_TYPE_TEXT[EVENT_EDIT4] = "EVENT_EDIT4"; + EVENT_TYPE_TEXT[EVENT_EDIT5] = "EVENT_EDIT5"; + EVENT_TYPE_TEXT[EVENT_EDIT6] = "EVENT_EDIT6"; + EVENT_TYPE_TEXT[EVENT_EDIT7] = "EVENT_EDIT7"; + EVENT_TYPE_TEXT[EVENT_EDIT8] = "EVENT_EDIT8"; + EVENT_TYPE_TEXT[EVENT_EDIT9] = "EVENT_EDIT9"; + + EVENT_TYPE_TEXT[EVENT_WINDOW0] = "EVENT_WINDOW0"; + EVENT_TYPE_TEXT[EVENT_WINDOW1] = "EVENT_WINDOW1"; + EVENT_TYPE_TEXT[EVENT_WINDOW2] = "EVENT_WINDOW2"; + EVENT_TYPE_TEXT[EVENT_WINDOW3] = "EVENT_WINDOW3"; + EVENT_TYPE_TEXT[EVENT_WINDOW4] = "EVENT_WINDOW4"; + EVENT_TYPE_TEXT[EVENT_WINDOW5] = "EVENT_WINDOW5"; + EVENT_TYPE_TEXT[EVENT_WINDOW6] = "EVENT_WINDOW6"; + EVENT_TYPE_TEXT[EVENT_WINDOW7] = "EVENT_WINDOW7"; + EVENT_TYPE_TEXT[EVENT_WINDOW8] = "EVENT_WINDOW8"; + EVENT_TYPE_TEXT[EVENT_WINDOW9] = "EVENT_WINDOW9"; + + EVENT_TYPE_TEXT[EVENT_LABEL0] = "EVENT_LABEL0"; + EVENT_TYPE_TEXT[EVENT_LABEL1] = "EVENT_LABEL1"; + EVENT_TYPE_TEXT[EVENT_LABEL2] = "EVENT_LABEL2"; + EVENT_TYPE_TEXT[EVENT_LABEL3] = "EVENT_LABEL3"; + EVENT_TYPE_TEXT[EVENT_LABEL4] = "EVENT_LABEL4"; + EVENT_TYPE_TEXT[EVENT_LABEL5] = "EVENT_LABEL5"; + EVENT_TYPE_TEXT[EVENT_LABEL6] = "EVENT_LABEL6"; + EVENT_TYPE_TEXT[EVENT_LABEL7] = "EVENT_LABEL7"; + EVENT_TYPE_TEXT[EVENT_LABEL8] = "EVENT_LABEL8"; + EVENT_TYPE_TEXT[EVENT_LABEL9] = "EVENT_LABEL9"; + EVENT_TYPE_TEXT[EVENT_LABEL10] = "EVENT_LABEL10"; + EVENT_TYPE_TEXT[EVENT_LABEL11] = "EVENT_LABEL11"; + EVENT_TYPE_TEXT[EVENT_LABEL12] = "EVENT_LABEL12"; + EVENT_TYPE_TEXT[EVENT_LABEL13] = "EVENT_LABEL13"; + EVENT_TYPE_TEXT[EVENT_LABEL14] = "EVENT_LABEL14"; + EVENT_TYPE_TEXT[EVENT_LABEL15] = "EVENT_LABEL15"; + EVENT_TYPE_TEXT[EVENT_LABEL16] = "EVENT_LABEL16"; + EVENT_TYPE_TEXT[EVENT_LABEL17] = "EVENT_LABEL17"; + EVENT_TYPE_TEXT[EVENT_LABEL18] = "EVENT_LABEL18"; + EVENT_TYPE_TEXT[EVENT_LABEL19] = "EVENT_LABEL19"; + + EVENT_TYPE_TEXT[EVENT_LIST0] = "EVENT_LIST0"; + EVENT_TYPE_TEXT[EVENT_LIST1] = "EVENT_LIST1"; + EVENT_TYPE_TEXT[EVENT_LIST2] = "EVENT_LIST2"; + EVENT_TYPE_TEXT[EVENT_LIST3] = "EVENT_LIST3"; + EVENT_TYPE_TEXT[EVENT_LIST4] = "EVENT_LIST4"; + EVENT_TYPE_TEXT[EVENT_LIST5] = "EVENT_LIST5"; + EVENT_TYPE_TEXT[EVENT_LIST6] = "EVENT_LIST6"; + EVENT_TYPE_TEXT[EVENT_LIST7] = "EVENT_LIST7"; + EVENT_TYPE_TEXT[EVENT_LIST8] = "EVENT_LIST8"; + EVENT_TYPE_TEXT[EVENT_LIST9] = "EVENT_LIST9"; + + EVENT_TYPE_TEXT[EVENT_TOOLTIP] = "EVENT_TOOLTIP"; + + EVENT_TYPE_TEXT[EVENT_DIALOG_OK] = "EVENT_DIALOG_OK"; + EVENT_TYPE_TEXT[EVENT_DIALOG_CANCEL] = "EVENT_DIALOG_CANCEL"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL] = "EVENT_DIALOG_LABEL"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL1] = "EVENT_DIALOG_LABEL1"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL2] = "EVENT_DIALOG_LABEL2"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LABEL3] = "EVENT_DIALOG_LABEL3"; + EVENT_TYPE_TEXT[EVENT_DIALOG_LIST] = "EVENT_DIALOG_LIST"; + EVENT_TYPE_TEXT[EVENT_DIALOG_EDIT] = "EVENT_DIALOG_EDIT"; + EVENT_TYPE_TEXT[EVENT_DIALOG_CHECK1] = "EVENT_DIALOG_CHECK1"; + EVENT_TYPE_TEXT[EVENT_DIALOG_CHECK2] = "EVENT_DIALOG_CHECK2"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_TRAINER] = "EVENT_INTERFACE_TRAINER"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_DEFI] = "EVENT_INTERFACE_DEFI"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MISSION] = "EVENT_INTERFACE_MISSION"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_FREE] = "EVENT_INTERFACE_FREE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PROTO] = "EVENT_INTERFACE_PROTO"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NAME] = "EVENT_INTERFACE_NAME"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUP] = "EVENT_INTERFACE_SETUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_QUIT] = "EVENT_INTERFACE_QUIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_BACK] = "EVENT_INTERFACE_BACK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_AGAIN] = "EVENT_INTERFACE_AGAIN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_WRITE] = "EVENT_INTERFACE_WRITE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_READ] = "EVENT_INTERFACE_READ"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_ABORT] = "EVENT_INTERFACE_ABORT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_USER] = "EVENT_INTERFACE_USER"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEEN] = "EVENT_INTERFACE_TEEN"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_CHAP] = "EVENT_INTERFACE_CHAP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_LIST] = "EVENT_INTERFACE_LIST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_RESUME] = "EVENT_INTERFACE_RESUME"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PLAY] = "EVENT_INTERFACE_PLAY"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPd] = "EVENT_INTERFACE_SETUPd"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPg] = "EVENT_INTERFACE_SETUPg"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPp] = "EVENT_INTERFACE_SETUPp"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPc] = "EVENT_INTERFACE_SETUPc"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUPs] = "EVENT_INTERFACE_SETUPs"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_DEVICE] = "EVENT_INTERFACE_DEVICE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_RESOL] = "EVENT_INTERFACE_RESOL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_FULL] = "EVENT_INTERFACE_FULL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_APPLY] = "EVENT_INTERFACE_APPLY"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_TOTO] = "EVENT_INTERFACE_TOTO"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SHADOW] = "EVENT_INTERFACE_SHADOW"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_DIRTY] = "EVENT_INTERFACE_DIRTY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_LENS] = "EVENT_INTERFACE_LENS"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SKY] = "EVENT_INTERFACE_SKY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PLANET] = "EVENT_INTERFACE_PLANET"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_LIGHT] = "EVENT_INTERFACE_LIGHT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PARTI] = "EVENT_INTERFACE_PARTI"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_CLIP] = "EVENT_INTERFACE_CLIP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_DETAIL] = "EVENT_INTERFACE_DETAIL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEXTURE] = "EVENT_INTERFACE_TEXTURE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_RAIN] = "EVENT_INTERFACE_RAIN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINT] = "EVENT_INTERFACE_GLINT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TOOLTIP] = "EVENT_INTERFACE_TOOLTIP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MOVIES] = "EVENT_INTERFACE_MOVIES"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NICERST] = "EVENT_INTERFACE_NICERST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SCROLL] = "EVENT_INTERFACE_SCROLL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTX] = "EVENT_INTERFACE_INVERTX"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_INVERTY] = "EVENT_INTERFACE_INVERTY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_EFFECT] = "EVENT_INTERFACE_EFFECT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MOUSE] = "EVENT_INTERFACE_MOUSE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GROUND] = "EVENT_INTERFACE_GROUND"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GADGET] = "EVENT_INTERFACE_GADGET"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_FOG] = "EVENT_INTERFACE_FOG"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_HIMSELF] = "EVENT_INTERFACE_HIMSELF"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITMODE]= "EVENT_INTERFACE_EDITMODE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITVALUE]= "EVENT_INTERFACE_EDITVALUE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE4] = "EVENT_INTERFACE_SOLUCE4"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO1] = "EVENT_INTERFACE_KINFO1"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO2] = "EVENT_INTERFACE_KINFO2"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KGROUP] = "EVENT_INTERFACE_KGROUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSCROLL] = "EVENT_INTERFACE_KSCROLL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KDEF] = "EVENT_INTERFACE_KDEF"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KLEFT] = "EVENT_INTERFACE_KLEFT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KRIGHT] = "EVENT_INTERFACE_KRIGHT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KUP] = "EVENT_INTERFACE_KUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KDOWN] = "EVENT_INTERFACE_KDOWN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KGUP] = "EVENT_INTERFACE_KGUP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KGDOWN] = "EVENT_INTERFACE_KGDOWN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KCAMERA] = "EVENT_INTERFACE_KCAMERA"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KDESEL] = "EVENT_INTERFACE_KDESEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KACTION] = "EVENT_INTERFACE_KACTION"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KNEAR] = "EVENT_INTERFACE_KNEAR"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KAWAY] = "EVENT_INTERFACE_KAWAY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KNEXT] = "EVENT_INTERFACE_KNEXT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KHUMAN] = "EVENT_INTERFACE_KHUMAN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KQUIT] = "EVENT_INTERFACE_KQUIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KHELP] = "EVENT_INTERFACE_KHELP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KPROG] = "EVENT_INTERFACE_KPROG"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KCBOT] = "EVENT_INTERFACE_KCBOT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KVISIT] = "EVENT_INTERFACE_KVISIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED10]= "EVENT_INTERFACE_KSPEED10"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED15]= "EVENT_INTERFACE_KSPEED15"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED20]= "EVENT_INTERFACE_KSPEED20"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_KSPEED30]= "EVENT_INTERFACE_KSPEED30"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_VOLSOUND]= "EVENT_INTERFACE_VOLSOUND"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_VOLMUSIC]= "EVENT_INTERFACE_VOLMUSIC"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SOUND3D] = "EVENT_INTERFACE_SOUND3D"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_MIN] = "EVENT_INTERFACE_MIN"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NORM] = "EVENT_INTERFACE_NORM"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MAX] = "EVENT_INTERFACE_MAX"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_SILENT] = "EVENT_INTERFACE_SILENT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NOISY] = "EVENT_INTERFACE_NOISY"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_JOYSTICK]= "EVENT_INTERFACE_JOYSTICK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE] = "EVENT_INTERFACE_SOLUCE"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTl] = "EVENT_INTERFACE_GLINTl"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTr] = "EVENT_INTERFACE_GLINTr"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTu] = "EVENT_INTERFACE_GLINTu"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_GLINTb] = "EVENT_INTERFACE_GLINTb"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_NEDIT] = "EVENT_INTERFACE_NEDIT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NLIST] = "EVENT_INTERFACE_NLIST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NOK] = "EVENT_INTERFACE_NOK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NCANCEL] = "EVENT_INTERFACE_NCANCEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NDELETE] = "EVENT_INTERFACE_NDELETE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_NLABEL] = "EVENT_INTERFACE_NLABEL"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOWRITE] = "EVENT_INTERFACE_IOWRITE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOREAD] = "EVENT_INTERFACE_IOREAD"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOLIST] = "EVENT_INTERFACE_IOLIST"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IONAME] = "EVENT_INTERFACE_IONAME"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOLABEL] = "EVENT_INTERFACE_IOLABEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IOIMAGE] = "EVENT_INTERFACE_IOIMAGE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_IODELETE]= "EVENT_INTERFACE_IODELETE"; + + EVENT_TYPE_TEXT[EVENT_INTERFACE_PERSO] = "EVENT_INTERFACE_PERSO"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_POK] = "EVENT_INTERFACE_POK"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCANCEL] = "EVENT_INTERFACE_PCANCEL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PDEF] = "EVENT_INTERFACE_PDEF"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PHEAD] = "EVENT_INTERFACE_PHEAD"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PBODY] = "EVENT_INTERFACE_PBODY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PLROT] = "EVENT_INTERFACE_PLROT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PRROT] = "EVENT_INTERFACE_PRROT"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC0a] = "EVENT_INTERFACE_PC0a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC1a] = "EVENT_INTERFACE_PC1a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC2a] = "EVENT_INTERFACE_PC2a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC3a] = "EVENT_INTERFACE_PC3a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC4a] = "EVENT_INTERFACE_PC4a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC5a] = "EVENT_INTERFACE_PC5a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC6a] = "EVENT_INTERFACE_PC6a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC7a] = "EVENT_INTERFACE_PC7a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC8a] = "EVENT_INTERFACE_PC8a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC9a] = "EVENT_INTERFACE_PC9a"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCRa] = "EVENT_INTERFACE_PCRa"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCGa] = "EVENT_INTERFACE_PCGa"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCBa] = "EVENT_INTERFACE_PCBa"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC0b] = "EVENT_INTERFACE_PC0b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC1b] = "EVENT_INTERFACE_PC1b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC2b] = "EVENT_INTERFACE_PC2b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC3b] = "EVENT_INTERFACE_PC3b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC4b] = "EVENT_INTERFACE_PC4b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC5b] = "EVENT_INTERFACE_PC5b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC6b] = "EVENT_INTERFACE_PC6b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC7b] = "EVENT_INTERFACE_PC7b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC8b] = "EVENT_INTERFACE_PC8b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PC9b] = "EVENT_INTERFACE_PC9b"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCRb] = "EVENT_INTERFACE_PCRb"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCGb] = "EVENT_INTERFACE_PCGb"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PCBb] = "EVENT_INTERFACE_PCBb"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE1] = "EVENT_INTERFACE_PFACE1"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE2] = "EVENT_INTERFACE_PFACE2"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE3] = "EVENT_INTERFACE_PFACE3"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PFACE4] = "EVENT_INTERFACE_PFACE4"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS0] = "EVENT_INTERFACE_PGLASS0"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS1] = "EVENT_INTERFACE_PGLASS1"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS2] = "EVENT_INTERFACE_PGLASS2"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS3] = "EVENT_INTERFACE_PGLASS3"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS4] = "EVENT_INTERFACE_PGLASS4"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS5] = "EVENT_INTERFACE_PGLASS5"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS6] = "EVENT_INTERFACE_PGLASS6"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS7] = "EVENT_INTERFACE_PGLASS7"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS8] = "EVENT_INTERFACE_PGLASS8"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_PGLASS9] = "EVENT_INTERFACE_PGLASS9"; + + EVENT_TYPE_TEXT[EVENT_DT_GROUP0] = "EVENT_DT_GROUP0"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP1] = "EVENT_DT_GROUP1"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP2] = "EVENT_DT_GROUP2"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP3] = "EVENT_DT_GROUP3"; + EVENT_TYPE_TEXT[EVENT_DT_GROUP4] = "EVENT_DT_GROUP4"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL0] = "EVENT_DT_LABEL0"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL1] = "EVENT_DT_LABEL1"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL2] = "EVENT_DT_LABEL2"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL3] = "EVENT_DT_LABEL3"; + EVENT_TYPE_TEXT[EVENT_DT_LABEL4] = "EVENT_DT_LABEL4"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT0] = "EVENT_DT_VISIT0"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT1] = "EVENT_DT_VISIT1"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT2] = "EVENT_DT_VISIT2"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT3] = "EVENT_DT_VISIT3"; + EVENT_TYPE_TEXT[EVENT_DT_VISIT4] = "EVENT_DT_VISIT4"; + EVENT_TYPE_TEXT[EVENT_DT_END] = "EVENT_DT_END"; + + EVENT_TYPE_TEXT[EVENT_CMD] = "EVENT_CMD"; + EVENT_TYPE_TEXT[EVENT_SPEED] = "EVENT_SPEED"; + + EVENT_TYPE_TEXT[EVENT_HYPER_PREV] = "EVENT_HYPER_PREV"; + EVENT_TYPE_TEXT[EVENT_HYPER_NEXT] = "EVENT_HYPER_NEXT"; + EVENT_TYPE_TEXT[EVENT_HYPER_HOME] = "EVENT_HYPER_HOME"; + EVENT_TYPE_TEXT[EVENT_HYPER_COPY] = "EVENT_HYPER_COPY"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE1] = "EVENT_HYPER_SIZE1"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE2] = "EVENT_HYPER_SIZE2"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE3] = "EVENT_HYPER_SIZE3"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE4] = "EVENT_HYPER_SIZE4"; + EVENT_TYPE_TEXT[EVENT_HYPER_SIZE5] = "EVENT_HYPER_SIZE5"; + + EVENT_TYPE_TEXT[EVENT_SATCOM_HUSTON] = "EVENT_SATCOM_HUSTON"; + EVENT_TYPE_TEXT[EVENT_SATCOM_SAT] = "EVENT_SATCOM_SAT"; + EVENT_TYPE_TEXT[EVENT_SATCOM_LOADING] = "EVENT_SATCOM_LOADING"; + EVENT_TYPE_TEXT[EVENT_SATCOM_OBJECT] = "EVENT_SATCOM_OBJECT"; + EVENT_TYPE_TEXT[EVENT_SATCOM_PROG] = "EVENT_SATCOM_PROG"; + EVENT_TYPE_TEXT[EVENT_SATCOM_SOLUCE] = "EVENT_SATCOM_SOLUCE"; + + EVENT_TYPE_TEXT[EVENT_OBJECT_DESELECT] = "EVENT_OBJECT_DESELECT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_LEFT] = "EVENT_OBJECT_LEFT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RIGHT] = "EVENT_OBJECT_RIGHT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_UP] = "EVENT_OBJECT_UP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_DOWN] = "EVENT_OBJECT_DOWN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GASUP] = "EVENT_OBJECT_GASUP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GASDOWN] = "EVENT_OBJECT_GASDOWN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_HTAKE] = "EVENT_OBJECT_HTAKE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MTAKE] = "EVENT_OBJECT_MTAKE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MFRONT] = "EVENT_OBJECT_MFRONT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MBACK] = "EVENT_OBJECT_MBACK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MPOWER] = "EVENT_OBJECT_MPOWER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BHELP] = "EVENT_OBJECT_BHELP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BTAKEOFF] = "EVENT_OBJECT_BTAKEOFF"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BDESTROY] = "EVENT_OBJECT_BDESTROY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BDERRICK] = "EVENT_OBJECT_BDERRICK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BSTATION] = "EVENT_OBJECT_BSTATION"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BFACTORY] = "EVENT_OBJECT_BFACTORY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BCONVERT] = "EVENT_OBJECT_BCONVERT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BTOWER] = "EVENT_OBJECT_BTOWER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BREPAIR] = "EVENT_OBJECT_BREPAIR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BRESEARCH] = "EVENT_OBJECT_BRESEARCH"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BRADAR] = "EVENT_OBJECT_BRADAR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BENERGY] = "EVENT_OBJECT_BENERGY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BLABO] = "EVENT_OBJECT_BLABO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BNUCLEAR] = "EVENT_OBJECT_BNUCLEAR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BPARA] = "EVENT_OBJECT_BPARA"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BINFO] = "EVENT_OBJECT_BINFO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BDESTROYER] = "EVENT_OBJECT_BDESTROYER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GFLAT] = "EVENT_OBJECT_GFLAT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCREATE] = "EVENT_OBJECT_FCREATE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FDELETE] = "EVENT_OBJECT_FDELETE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORb] = "EVENT_OBJECT_FCOLORb"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORr] = "EVENT_OBJECT_FCOLORr"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORg] = "EVENT_OBJECT_FCOLORg"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORy] = "EVENT_OBJECT_FCOLORy"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FCOLORv] = "EVENT_OBJECT_FCOLORv"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwa] = "EVENT_OBJECT_FACTORYwa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYta] = "EVENT_OBJECT_FACTORYta"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfa] = "EVENT_OBJECT_FACTORYfa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYia] = "EVENT_OBJECT_FACTORYia"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwc] = "EVENT_OBJECT_FACTORYwc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYtc] = "EVENT_OBJECT_FACTORYtc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfc] = "EVENT_OBJECT_FACTORYfc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYic] = "EVENT_OBJECT_FACTORYic"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwi] = "EVENT_OBJECT_FACTORYwi"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYti] = "EVENT_OBJECT_FACTORYti"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfi] = "EVENT_OBJECT_FACTORYfi"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYii] = "EVENT_OBJECT_FACTORYii"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYws] = "EVENT_OBJECT_FACTORYws"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYts] = "EVENT_OBJECT_FACTORYts"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfs] = "EVENT_OBJECT_FACTORYfs"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYis] = "EVENT_OBJECT_FACTORYis"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrt] = "EVENT_OBJECT_FACTORYrt"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrc] = "EVENT_OBJECT_FACTORYrc"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrr] = "EVENT_OBJECT_FACTORYrr"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrs] = "EVENT_OBJECT_FACTORYrs"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYsa] = "EVENT_OBJECT_FACTORYsa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SEARCH] = "EVENT_OBJECT_SEARCH"; + EVENT_TYPE_TEXT[EVENT_OBJECT_TERRAFORM] = "EVENT_OBJECT_TERRAFORM"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FIRE] = "EVENT_OBJECT_FIRE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FIREANT] = "EVENT_OBJECT_FIREANT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SPIDEREXPLO]= "EVENT_OBJECT_SPIDEREXPLO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RECOVER] = "EVENT_OBJECT_RECOVER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BEGSHIELD] = "EVENT_OBJECT_BEGSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_ENDSHIELD] = "EVENT_OBJECT_ENDSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTANK] = "EVENT_OBJECT_RTANK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RFLY] = "EVENT_OBJECT_RFLY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTHUMP] = "EVENT_OBJECT_RTHUMP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RCANON] = "EVENT_OBJECT_RCANON"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTOWER] = "EVENT_OBJECT_RTOWER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RPHAZER] = "EVENT_OBJECT_RPHAZER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RSHIELD] = "EVENT_OBJECT_RSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RATOMIC] = "EVENT_OBJECT_RATOMIC"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RiPAW] = "EVENT_OBJECT_RiPAW"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RiGUN] = "EVENT_OBJECT_RiGUN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RESET] = "EVENT_OBJECT_RESET"; + EVENT_TYPE_TEXT[EVENT_OBJECT_DIMSHIELD] = "EVENT_OBJECT_DIMSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_TARGET] = "EVENT_OBJECT_TARGET"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGLIST] = "EVENT_OBJECT_PROGLIST"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGRUN] = "EVENT_OBJECT_PROGRUN"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGEDIT] = "EVENT_OBJECT_PROGEDIT"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGSTART] = "EVENT_OBJECT_PROGSTART"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PROGSTOP] = "EVENT_OBJECT_PROGSTOP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_INFOOK] = "EVENT_OBJECT_INFOOK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_DELETE] = "EVENT_OBJECT_DELETE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GENERGY] = "EVENT_OBJECT_GENERGY"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GSHIELD] = "EVENT_OBJECT_GSHIELD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GRANGE] = "EVENT_OBJECT_GRANGE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_COMPASS] = "EVENT_OBJECT_COMPASS"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAP] = "EVENT_OBJECT_MAP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAPZOOM] = "EVENT_OBJECT_MAPZOOM"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GPROGRESS] = "EVENT_OBJECT_GPROGRESS"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GRADAR] = "EVENT_OBJECT_GRADAR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_GINFO] = "EVENT_OBJECT_GINFO"; + EVENT_TYPE_TEXT[EVENT_OBJECT_TYPE] = "EVENT_OBJECT_TYPE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CROSSHAIR] = "EVENT_OBJECT_CROSSHAIR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERul] = "EVENT_OBJECT_CORNERul"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERur] = "EVENT_OBJECT_CORNERur"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERdl] = "EVENT_OBJECT_CORNERdl"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CORNERdr] = "EVENT_OBJECT_CORNERdr"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAPi] = "EVENT_OBJECT_MAPi"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MAPg] = "EVENT_OBJECT_MAPg"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERA] = "EVENT_OBJECT_CAMERA"; + EVENT_TYPE_TEXT[EVENT_OBJECT_HELP] = "EVENT_OBJECT_HELP"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SOLUCE] = "EVENT_OBJECT_SOLUCE"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAleft] = "EVENT_OBJECT_CAMERAleft"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAright]= "EVENT_OBJECT_CAMERAright"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAnear] = "EVENT_OBJECT_CAMERAnear"; + EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAaway] = "EVENT_OBJECT_CAMERAaway"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT00] = "EVENT_OBJECT_SHORTCUT00"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT01] = "EVENT_OBJECT_SHORTCUT01"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT02] = "EVENT_OBJECT_SHORTCUT02"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT03] = "EVENT_OBJECT_SHORTCUT03"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT04] = "EVENT_OBJECT_SHORTCUT04"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT05] = "EVENT_OBJECT_SHORTCUT05"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT06] = "EVENT_OBJECT_SHORTCUT06"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT07] = "EVENT_OBJECT_SHORTCUT07"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT08] = "EVENT_OBJECT_SHORTCUT08"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT09] = "EVENT_OBJECT_SHORTCUT09"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT10] = "EVENT_OBJECT_SHORTCUT10"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT11] = "EVENT_OBJECT_SHORTCUT11"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT12] = "EVENT_OBJECT_SHORTCUT12"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT13] = "EVENT_OBJECT_SHORTCUT13"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT14] = "EVENT_OBJECT_SHORTCUT14"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT15] = "EVENT_OBJECT_SHORTCUT15"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT16] = "EVENT_OBJECT_SHORTCUT16"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT17] = "EVENT_OBJECT_SHORTCUT17"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT18] = "EVENT_OBJECT_SHORTCUT18"; + EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT19] = "EVENT_OBJECT_SHORTCUT19"; + EVENT_TYPE_TEXT[EVENT_OBJECT_MOVIELOCK] = "EVENT_OBJECT_MOVIELOCK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_EDITLOCK] = "EVENT_OBJECT_EDITLOCK"; + EVENT_TYPE_TEXT[EVENT_OBJECT_LIMIT] = "EVENT_OBJECT_LIMIT"; + + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN0] = "EVENT_OBJECT_PEN0"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN1] = "EVENT_OBJECT_PEN1"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN2] = "EVENT_OBJECT_PEN2"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN3] = "EVENT_OBJECT_PEN3"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN4] = "EVENT_OBJECT_PEN4"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN5] = "EVENT_OBJECT_PEN5"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN6] = "EVENT_OBJECT_PEN6"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN7] = "EVENT_OBJECT_PEN7"; + EVENT_TYPE_TEXT[EVENT_OBJECT_PEN8] = "EVENT_OBJECT_PEN8"; + EVENT_TYPE_TEXT[EVENT_OBJECT_REC] = "EVENT_OBJECT_REC"; + EVENT_TYPE_TEXT[EVENT_OBJECT_STOP] = "EVENT_OBJECT_STOP"; + + EVENT_TYPE_TEXT[EVENT_STUDIO_OK] = "EVENT_STUDIO_OK"; + EVENT_TYPE_TEXT[EVENT_STUDIO_CANCEL] = "EVENT_STUDIO_CANCEL"; + EVENT_TYPE_TEXT[EVENT_STUDIO_EDIT] = "EVENT_STUDIO_EDIT"; + EVENT_TYPE_TEXT[EVENT_STUDIO_LIST] = "EVENT_STUDIO_LIST"; + EVENT_TYPE_TEXT[EVENT_STUDIO_NEW] = "EVENT_STUDIO_NEW"; + EVENT_TYPE_TEXT[EVENT_STUDIO_OPEN] = "EVENT_STUDIO_OPEN"; + EVENT_TYPE_TEXT[EVENT_STUDIO_SAVE] = "EVENT_STUDIO_SAVE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_UNDO] = "EVENT_STUDIO_UNDO"; + EVENT_TYPE_TEXT[EVENT_STUDIO_CUT] = "EVENT_STUDIO_CUT"; + EVENT_TYPE_TEXT[EVENT_STUDIO_COPY] = "EVENT_STUDIO_COPY"; + EVENT_TYPE_TEXT[EVENT_STUDIO_PASTE] = "EVENT_STUDIO_PASTE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_SIZE] = "EVENT_STUDIO_SIZE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_TOOL] = "EVENT_STUDIO_TOOL"; + EVENT_TYPE_TEXT[EVENT_STUDIO_HELP] = "EVENT_STUDIO_HELP"; + EVENT_TYPE_TEXT[EVENT_STUDIO_COMPILE] = "EVENT_STUDIO_COMPILE"; + EVENT_TYPE_TEXT[EVENT_STUDIO_RUN] = "EVENT_STUDIO_RUN"; + EVENT_TYPE_TEXT[EVENT_STUDIO_REALTIME] = "EVENT_STUDIO_REALTIME"; + EVENT_TYPE_TEXT[EVENT_STUDIO_STEP] = "EVENT_STUDIO_STEP"; +} + +std::string ParseEventType(EventType eventType) { - int i = static_cast(g_uniqueEventType+1); - g_uniqueEventType = static_cast(i); - return g_uniqueEventType; + auto Other = [&](const char* name) + { + std::stringstream str; + str << name << "(" << static_cast(eventType) << ")"; + return str.str(); + }; + + if (eventType < EVENT_STD_MAX) + { + const char* stdEvent = EVENT_TYPE_TEXT[eventType]; + if (stdEvent[0] == 0) + return Other("STD_UNDEFINED"); + + return stdEvent; + } + + if (eventType >= EVENT_USER) + return Other("USER_EVENT"); + + return Other("UNDEFINED"); } diff --git a/src/common/event.h b/src/common/event.h index 8aef603..9405660 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -40,8 +40,10 @@ enum EventType //! Invalid event / no event EVENT_NULL = 0, - //! Event sent on user or system quit request - EVENT_QUIT = 1, + // System events (originating in CApplication) + + //! Event sent on system quit request + EVENT_SYS_QUIT = 1, //! Frame update event EVENT_FRAME = 2, @@ -69,10 +71,15 @@ enum EventType //! Event sent after releasing a joystick button EVENT_JOY_BUTTON_UP = 14, + //!< Maximum value of system events + EVENT_SYS_MAX, + /* Events sent/received in game and user interface */ - EVENT_UPDINTERFACE = 20, + //! Event sent on user quit request + EVENT_QUIT = 20, + EVENT_UPDINTERFACE = 21, EVENT_WIN = 30, EVENT_LOST = 31, @@ -548,7 +555,8 @@ enum EventType EVENT_STUDIO_REALTIME = 2052, EVENT_STUDIO_STEP = 2053, - EVENT_STD_MAX, //! < maximum value of standard events + //! Maximum value of standard events + EVENT_STD_MAX, EVENT_USER = 10000, EVENT_FORCE_LONG = 0x7fffffff @@ -669,8 +677,8 @@ struct ActiveEventData * \struct Event * \brief Event sent by system, interface or game * - * Event is described by its type (EventType) and the union - * \a data contains additional data about the event. + * Event is described by its type (EventType) and anonymous union that + * contains additional data about the event. * Different members of the union are filled with different event types. * With some events, nothing is filled (it's zeroed out). * The union contains roughly the same information as SDL_Event struct @@ -681,9 +689,6 @@ struct Event //! Type of event EventType type; - //! If true, the event was produced by system in CApplication; else, it has come from game engine - bool systemEvent; - //! Relative time since last EVENT_FRAME //! Scope: only EVENT_FRAME events // TODO: gradually replace the usage of this with new CApplication's time functions @@ -732,7 +737,6 @@ struct Event explicit Event(EventType _type = EVENT_NULL) : type(_type) - , systemEvent(false) , rTime(0.0f) , kmodState(0) , trackedKeysState(0) @@ -745,6 +749,11 @@ struct Event //! Returns an unique event type (above the standard IDs) EventType GetUniqueEventType(); +//! Initializes static array with event type strings +void InitializeEventTypeTexts(); + +//! Parses event type to string +std::string ParseEventType(EventType eventType); /** * \class CEventQueue diff --git a/src/common/profile.h b/src/common/profile.h index 8ea2aee..f084ece 100644 --- a/src/common/profile.h +++ b/src/common/profile.h @@ -43,7 +43,7 @@ class CProfile : public CSingleton { public: CProfile(); - ~CProfile(); + virtual ~CProfile(); /** Loads colobot.ini from current directory * \return return true on success diff --git a/src/common/restext.cpp b/src/common/restext.cpp index ead8ef3..d61fa63 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -848,10 +848,8 @@ static const char* GetResourceBase(ResType type, int num) case RES_EVENT: if (num >= EVENT_STD_MAX) - { - GetLogger()->Trace("GetResource event num out of range: %d\n", num); // TODO: fix later - return ""; - } + return ""; // can be safely ignored (user events) + str = stringsEvent[num]; break; diff --git a/src/graphics/engine/modelfile.cpp b/src/graphics/engine/modelfile.cpp index 8383b15..99496aa 100644 --- a/src/graphics/engine/modelfile.cpp +++ b/src/graphics/engine/modelfile.cpp @@ -310,6 +310,7 @@ bool ReadLineString(std::istream& stream, const std::string& prefix, std::string CModelFile::CModelFile() + : m_printDebugInfo(false) { } @@ -615,23 +616,26 @@ bool CModelFile::ReadModel(std::istream& stream) if (m_triangles[i].tex1Name == "plant.png") m_triangles[i].state |= ENG_RSTATE_ALPHA; - GetLogger()->Trace("ModelTriangle %d\n", i+1); - std::string s1 = m_triangles[i].p1.ToString(); - GetLogger()->Trace(" p1: %s\n", s1.c_str()); - std::string s2 = m_triangles[i].p2.ToString(); - GetLogger()->Trace(" p2: %s\n", s2.c_str()); - std::string s3 = m_triangles[i].p3.ToString(); - GetLogger()->Trace(" p3: %s\n", s3.c_str()); - - std::string d = m_triangles[i].material.diffuse.ToString(); - std::string a = m_triangles[i].material.ambient.ToString(); - std::string s = m_triangles[i].material.specular.ToString(); - GetLogger()->Trace(" mat: d: %s a: %s s: %s\n", d.c_str(), a.c_str(), s.c_str()); - - GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(), - m_triangles[i].variableTex2 ? "(variable)" : m_triangles[i].tex2Name.c_str()); - GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel); - GetLogger()->Trace(" state: %ld\n", m_triangles[i].state); + if (m_printDebugInfo) + { + GetLogger()->Trace("ModelTriangle %d\n", i+1); + std::string s1 = m_triangles[i].p1.ToString(); + GetLogger()->Trace(" p1: %s\n", s1.c_str()); + std::string s2 = m_triangles[i].p2.ToString(); + GetLogger()->Trace(" p2: %s\n", s2.c_str()); + std::string s3 = m_triangles[i].p3.ToString(); + GetLogger()->Trace(" p3: %s\n", s3.c_str()); + + std::string d = m_triangles[i].material.diffuse.ToString(); + std::string a = m_triangles[i].material.ambient.ToString(); + std::string s = m_triangles[i].material.specular.ToString(); + GetLogger()->Trace(" mat: d: %s a: %s s: %s\n", d.c_str(), a.c_str(), s.c_str()); + + GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(), + m_triangles[i].variableTex2 ? "(variable)" : m_triangles[i].tex2Name.c_str()); + GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel); + GetLogger()->Trace(" state: %ld\n", m_triangles[i].state); + } } return true; @@ -1093,24 +1097,27 @@ bool CModelFile::ReadBinaryModel(std::istream& stream) return false; } - for (int i = 0; i < static_cast( m_triangles.size() ); ++i) + if (m_printDebugInfo) { - GetLogger()->Trace("ModelTriangle %d\n", i+1); - std::string s1 = m_triangles[i].p1.ToString(); - GetLogger()->Trace(" p1: %s\n", s1.c_str()); - std::string s2 = m_triangles[i].p2.ToString(); - GetLogger()->Trace(" p2: %s\n", s2.c_str()); - std::string s3 = m_triangles[i].p3.ToString(); - GetLogger()->Trace(" p3: %s\n", s3.c_str()); - - std::string d = m_triangles[i].material.diffuse.ToString(); - std::string a = m_triangles[i].material.ambient.ToString(); - std::string s = m_triangles[i].material.specular.ToString(); - GetLogger()->Trace(" mat: d: %s a: %s s: %s\n", d.c_str(), a.c_str(), s.c_str()); - - GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(), m_triangles[i].tex2Name.c_str()); - GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel); - GetLogger()->Trace(" state: %ld\n", m_triangles[i].state); + for (int i = 0; i < static_cast( m_triangles.size() ); ++i) + { + GetLogger()->Trace("ModelTriangle %d\n", i+1); + std::string s1 = m_triangles[i].p1.ToString(); + GetLogger()->Trace(" p1: %s\n", s1.c_str()); + std::string s2 = m_triangles[i].p2.ToString(); + GetLogger()->Trace(" p2: %s\n", s2.c_str()); + std::string s3 = m_triangles[i].p3.ToString(); + GetLogger()->Trace(" p3: %s\n", s3.c_str()); + + std::string d = m_triangles[i].material.diffuse.ToString(); + std::string a = m_triangles[i].material.ambient.ToString(); + std::string s = m_triangles[i].material.specular.ToString(); + GetLogger()->Trace(" mat: d: %s a: %s s: %s\n", d.c_str(), a.c_str(), s.c_str()); + + GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(), m_triangles[i].tex2Name.c_str()); + GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel); + GetLogger()->Trace(" state: %ld\n", m_triangles[i].state); + } } return true; @@ -1197,6 +1204,10 @@ int CModelFile::GetTriangleCount() return m_triangles.size(); } +void CModelFile::SetPrintDebugInfo(bool printDebugInfo) +{ + m_printDebugInfo = printDebugInfo; +} } // namespace Gfx diff --git a/src/graphics/engine/modelfile.h b/src/graphics/engine/modelfile.h index 9a01f78..3b4019b 100644 --- a/src/graphics/engine/modelfile.h +++ b/src/graphics/engine/modelfile.h @@ -137,6 +137,9 @@ public: //! Returns the triangle vector const std::vector& GetTriangles(); + //! Controls printing of debug information + void SetPrintDebugInfo(bool printDebugInfo); + protected: //@{ //! @deprecated min, max conversions @@ -147,6 +150,7 @@ protected: protected: //! Model triangles std::vector m_triangles; + bool m_printDebugInfo; }; }; // namespace Gfx diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp index 8397e15..abc8c6c 100644 --- a/src/graphics/engine/modelmanager.cpp +++ b/src/graphics/engine/modelmanager.cpp @@ -27,6 +27,9 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored) CModelFile modelFile; + if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS)) + modelFile.SetPrintDebugInfo(true); + std::string filePath = CApplication::GetInstance().GetDataFilePath(DIR_MODEL, fileName); if (!modelFile.ReadModel(filePath)) diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 9b37a84..23f5a28 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -940,6 +940,14 @@ Ui::CDisplayText* CRobotMain::GetDisplayText() return m_displayText; } +void CRobotMain::LoadSceneOnStart(const std::string& name, int rank) +{ + // TODO: fix this ugly dependency :( + m_dialog->SetSceneName(name.c_str()); + m_dialog->SetSceneRank(rank); + ChangePhase(PHASE_LOADING); +} + //! Creates the file colobot.ini at the first time void CRobotMain::CreateIni() @@ -1010,28 +1018,24 @@ void CRobotMain::SetDefaultInputBindings() void CRobotMain::SetInputBinding(InputSlot slot, InputBinding binding) { unsigned int index = static_cast(slot); - assert(index >= 0 && index < INPUT_SLOT_MAX); m_inputBindings[index] = binding; } const InputBinding& CRobotMain::GetInputBinding(InputSlot slot) { unsigned int index = static_cast(slot); - assert(index >= 0 && index < INPUT_SLOT_MAX); return m_inputBindings[index]; } void CRobotMain::SetJoyAxisBinding(JoyAxisSlot slot, JoyAxisBinding binding) { unsigned int index = static_cast(slot); - assert(index >= 0 && index < JOY_AXIS_SLOT_MAX); m_joyAxisBindings[index] = binding; } const JoyAxisBinding& CRobotMain::GetJoyAxisBinding(JoyAxisSlot slot) { unsigned int index = static_cast(slot); - assert(index >= 0 && index < JOY_AXIS_SLOT_MAX); return m_joyAxisBindings[index]; } @@ -1300,7 +1304,7 @@ void CRobotMain::ChangePhase(Phase phase) } //! Processes an event -bool CRobotMain::EventProcess(Event &event) +bool CRobotMain::ProcessEvent(Event &event) { /* Motion vector management */ @@ -1997,7 +2001,14 @@ void CRobotMain::ExecuteCmd(char *cmd) if (strcmp(cmd, "debugmode") == 0) { - m_app->SetDebugMode(!m_app->GetDebugMode()); + if (m_app->IsDebugModeActive(DEBUG_ALL)) + { + m_app->SetDebugModeActive(DEBUG_ALL, false); + } + else + { + m_app->SetDebugModeActive(DEBUG_ALL, true); + } return; } diff --git a/src/object/robotmain.h b/src/object/robotmain.h index a75509d..04efea7 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -199,6 +199,9 @@ public: Ui::CInterface* GetInterface(); Ui::CDisplayText* GetDisplayText(); + //! Caused the given mission to be loaded immediately after start + void LoadSceneOnStart(const std::string& name, int rank); + void CreateIni(); //! Sets the default input bindings (key and axes) @@ -226,7 +229,7 @@ public: void ResetKeyStates(); void ChangePhase(Phase phase); - bool EventProcess(Event &event); + bool ProcessEvent(Event &event); bool CreateShortcuts(); void ScenePerso(); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 8f5b936..3a31883 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -366,7 +366,8 @@ pb->SetState(STATE_SHADOW); } // #endif - if ( m_app->GetDebugMode() ) + // TODO: remove? + if (m_app->GetProtoMode()) { pos.x = 139.0f/640.0f; pos.y = 313.0f/480.0f; -- cgit v1.2.3-1-g7c22 From b4700e3bedc52f9fc7b5008ae06c4e6f9e3fe130 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 17 Jun 2013 11:48:57 +0200 Subject: Fix for #133 * objects are now copied and textures are updated correctly * also added function to debug objects --- src/graphics/engine/engine.cpp | 93 +++++++++++++++++++++++++++++++++++++++--- src/graphics/engine/engine.h | 5 ++- src/graphics/engine/pyro.cpp | 16 +++++++- 3 files changed, 106 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 785383a..3423864 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -698,6 +698,82 @@ void CEngine::AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buff p1.totalTriangles += p4.vertices.size() - 2; } +void CEngine::DebugObject(int objRank) +{ + assert(objRank >= 0 && objRank < static_cast( m_objects.size() )); + + CLogger* l = GetLogger(); + + l->Debug("Debug object: %d\n", objRank); + if (! m_objects[objRank].used) + { + l->Debug(" not used\n"); + return; + } + + l->Debug(" baseObjRank = %d\n", m_objects[objRank].baseObjRank); + l->Debug(" visible = %s\n", m_objects[objRank].visible ? "true" : "false"); + l->Debug(" drawWorld = %s\n", m_objects[objRank].drawWorld ? "true" : "false"); + l->Debug(" drawFront = %s\n", m_objects[objRank].drawFront ? "true" : "false"); + l->Debug(" type = %d\n", m_objects[objRank].type); + l->Debug(" distance = %f\n", m_objects[objRank].distance); + l->Debug(" shadowRank = %d\n", m_objects[objRank].shadowRank); + l->Debug(" transparency = %f\n", m_objects[objRank].transparency); + + l->Debug(" baseObj:\n"); + int baseObjRank = m_objects[objRank].baseObjRank; + if (baseObjRank == -1) + { + l->Debug(" null\n"); + return; + } + + assert(baseObjRank >= 0 && baseObjRank < static_cast( m_baseObjects.size() )); + + EngineBaseObject& p1 = m_baseObjects[baseObjRank]; + if (!p1.used) + { + l->Debug(" not used\n"); + return; + } + + std::string vecStr; + + vecStr = p1.bboxMin.ToString(); + l->Debug(" bboxMin: %s\n", vecStr.c_str()); + vecStr = p1.bboxMax.ToString(); + l->Debug(" bboxMax: %s\n", vecStr.c_str()); + l->Debug(" totalTriangles: %d\n", p1.totalTriangles); + l->Debug(" radius: %f\n", p1.radius); + + for (int l2 = 0; l2 < static_cast( p1.next.size() ); l2++) + { + EngineBaseObjTexTier& p2 = p1.next[l2]; + l->Debug(" l2:\n"); + + l->Debug(" tex1: %s (id: %u)\n", p2.tex1Name.c_str(), p2.tex1.id); + l->Debug(" tex2: %s (id: %u)\n", p2.tex2Name.c_str(), p2.tex2.id); + + for (int l3 = 0; l3 < static_cast( p2.next.size() ); l3++) + { + EngineBaseObjLODTier& p3 = p2.next[l3]; + + l->Debug(" l3:\n"); + l->Debug(" lodLevel: %d\n", p3.lodLevel); + + for (int l4 = 0; l4 < static_cast( p3.next.size() ); l4++) + { + EngineBaseObjDataTier& p4 = p3.next[l4]; + + l->Debug(" l4:\n"); + l->Debug(" type: %d\n", p4.type); + l->Debug(" state: %d\n", p4.state); + l->Debug(" staticBufferId: %u\n", p4.staticBufferId); + l->Debug(" updateStaticBuffer: %s\n", p4.updateStaticBuffer ? "true" : "false"); + } + } + } +} int CEngine::CreateObject() { @@ -986,14 +1062,19 @@ void CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name) for (int l2 = 0; l2 < static_cast( p1.next.size() ); l2++) { - EngineBaseObjTexTier& p2 = p1.next[l2]; - - if (p2.tex2Name == tex2Name) + if (p1.next[l2].tex2Name == tex2Name) continue; // already new - EngineBaseObjTexTier& newP2 = AddLevel2(p1, p2.tex1Name, tex2Name); - newP2.next.insert(newP2.next.end(), p2.next.begin(), p2.next.end()); - p2.next.clear(); + std::string tex1Name = p1.next[l2].tex1Name; + EngineBaseObjTexTier& newP2 = AddLevel2(p1, tex1Name, tex2Name); + newP2.next.insert(newP2.next.end(), p1.next[l2].next.begin(), p1.next[l2].next.end()); + p1.next[l2].next.clear(); + + if (!newP2.tex1.Valid()) + newP2.tex1 = LoadTexture(newP2.tex1Name); + + if (!newP2.tex2.Valid()) + newP2.tex2 = LoadTexture(newP2.tex2Name); } } diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 27aa5dc..207ae27 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -118,7 +118,7 @@ enum EngineRenderState //! Mode for rendering text ENG_RSTATE_TEXT = (1<<18), //! Only opaque texture, no blending, etc. - ENG_RSTATE_OPAQUE_TEXTURE = (1<<19), + ENG_RSTATE_OPAQUE_TEXTURE = (1<<19), //! Only opaque color, no texture, blending, etc. ENG_RSTATE_OPAQUE_COLOR = (1<<20) }; @@ -807,6 +807,9 @@ public: // Objects + //! Print debug info about an object + void DebugObject(int rank); + //! Creates a new object and returns its rank int CreateObject(); //! Deletes all objects, shadows and ground spots diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index 0a85beb..93198ec 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -1556,7 +1556,14 @@ void CPyro::ExploStart() for (int i = 0; i < OBJECTMAXPART; i++) { int objRank = m_object->GetObjectRank(i); - if ( objRank == -1 ) continue; + if (objRank == -1) continue; + + // TODO: refactor later to material change + int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank); + int newBaseObjRank = m_engine->CreateBaseObject(); + m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank); + m_engine->SetObjectBaseRank(objRank, newBaseObjRank); + m_engine->ChangeSecondTexture(objRank, "dirty04.png"); Math::Vector pos = m_object->GetPosition(i); @@ -1618,6 +1625,13 @@ void CPyro::BurnStart() { int objRank = m_object->GetObjectRank(i); if (objRank == -1) continue; + + // TODO: refactor later to material change + int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank); + int newBaseObjRank = m_engine->CreateBaseObject(); + m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank); + m_engine->SetObjectBaseRank(objRank, newBaseObjRank); + m_engine->ChangeSecondTexture(objRank, "dirty04.png"); } m_engine->LoadTexture("dirty04.png"); -- cgit v1.2.3-1-g7c22 From 868b5927064aba1ca72bd403446f9ff84c99c29b Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 17 Jun 2013 16:11:00 +0200 Subject: Added -proto to options[] --- src/app/app.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index d57bbc3..44a7a74 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -243,6 +243,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) { "langdir", required_argument, nullptr, OPT_LANGDIR }, { "texpack", required_argument, nullptr, OPT_TEXPACK }, { "vbo", required_argument, nullptr, OPT_VBO }, + { "proto", no_argument, nullptr, OPT_PROTO }, { nullptr, 0, nullptr, 0} }; -- cgit v1.2.3-1-g7c22 From 366d3a551ef3541f6eeb226f80a16b8de8fdd2e9 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 17 Jun 2013 18:06:39 +0200 Subject: Added debug aids for lighting * displaying positions of current lights (F11) * dumping info to console (F10) * added assert() in suspicious place in CPyro --- src/graphics/core/device.h | 3 ++ src/graphics/engine/engine.cpp | 27 +++++++++++ src/graphics/engine/engine.h | 3 ++ src/graphics/engine/lightman.cpp | 64 +++++++++++++++++++++++-- src/graphics/engine/lightman.h | 6 +++ src/graphics/engine/pyro.cpp | 1 + src/graphics/opengl/gldevice.cpp | 100 +++++++++++++++++++++++++++++++++++++++ src/graphics/opengl/gldevice.h | 1 + src/math/matrix.h | 8 ++-- 9 files changed, 206 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index 38bc463..4c1189c 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -240,6 +240,9 @@ public: //! Provides a hook to debug graphics code (implementation-specific) virtual void DebugHook() = 0; + //! Displays light positions to aid in debuggings + virtual void DebugLights() = 0; + //! Initializes the device, setting the initial state virtual bool Create() = 0; //! Destroys the device, releasing every acquired resource diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 3423864..669ea42 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -128,6 +128,9 @@ CEngine::CEngine(CApplication *app) m_interfaceMode = false; + m_debugLights = false; + m_debugDumpLights = false; + m_mice[ENG_MOUSE_NORM] = EngineMouse( 0, 1, 32, ENG_RSTATE_TTEXTURE_WHITE, ENG_RSTATE_TTEXTURE_BLACK, Math::Point( 1.0f, 1.0f)); m_mice[ENG_MOUSE_WAIT] = EngineMouse( 2, 3, 33, ENG_RSTATE_TTEXTURE_WHITE, ENG_RSTATE_TTEXTURE_BLACK, Math::Point( 8.0f, 12.0f)); m_mice[ENG_MOUSE_HAND] = EngineMouse( 4, 5, 34, ENG_RSTATE_TTEXTURE_WHITE, ENG_RSTATE_TTEXTURE_BLACK, Math::Point( 7.0f, 2.0f)); @@ -325,7 +328,22 @@ bool CEngine::ProcessEvent(const Event &event) if (event.type == EVENT_KEY_DOWN) { if (event.key.key == KEY(F12)) + { m_showStats = !m_showStats; + return false; + } + + if (event.key.key == KEY(F11)) + { + m_debugLights = !m_debugLights; + return false; + } + + if (event.key.key == KEY(F10)) + { + m_debugDumpLights = true; + return false; + } } // By default, pass on all events @@ -3293,6 +3311,15 @@ void CEngine::Draw3DScene() m_lightMan->UpdateDeviceLights(ENG_OBJTYPE_TERRAIN); + if (m_debugLights) + m_device->DebugLights(); + + if (m_debugDumpLights) + { + m_debugDumpLights = false; + m_lightMan->DebugDumpLights(); + } + if (m_waterMode) { m_app->StartPerformanceCounter(PCNT_RENDER_WATER); diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 207ae27..5ecde8f 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -1437,6 +1437,9 @@ protected: //! True when drawing 2D UI bool m_interfaceMode; + + bool m_debugLights; + bool m_debugDumpLights; }; diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index cbb8509..3e512d8 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -71,6 +71,7 @@ void LightProgression::SetTarget(float value) DynamicLight::DynamicLight() { + rank = 0; used = enabled = false; priority = LIGHT_PRI_LOW; includeType = excludeType = ENG_OBJTYPE_NULL; @@ -98,6 +99,61 @@ void CLightManager::SetDevice(CDevice* device) m_lightMap = std::vector(m_device->GetMaxLightCount(), -1); } +void CLightManager::DebugDumpLights() +{ + CLogger* l = GetLogger(); + + l->Debug("Dynamic lights:\n"); + + for (int i = 0; i < static_cast( m_dynLights.size() ); ++i) + { + const DynamicLight& dynLight = m_dynLights[i]; + if (!dynLight.used) + continue; + + int deviceLight = -1; + for (int j = 0; j < m_lightMap.size(); ++j) + { + if (m_lightMap[j] == i) + { + deviceLight = j; + break; + } + } + + l->Debug(" light %d\n", i); + l->Debug(" enabled = %s\n", dynLight.enabled ? "true" : "false"); + l->Debug(" priority = %d\n", dynLight.priority); + l->Debug(" device light = %d\n", deviceLight); + l->Debug(" light:\n"); + + const Light& light = dynLight.light; + std::string str; + + l->Debug(" type = %d\n", light.type); + str = light.ambient.ToString(); + l->Debug(" ambient = %s\n", str.c_str()); + str = light.diffuse.ToString(); + l->Debug(" diffuse = %s\n", str.c_str()); + str = light.specular.ToString(); + l->Debug(" specular = %s\n", str.c_str()); + str = light.position.ToString(); + l->Debug(" position = %s\n", str.c_str()); + str = light.direction.ToString(); + l->Debug(" direction = %s\n", str.c_str()); + l->Debug(" attenuation0 = %s\n", light.attenuation0); + l->Debug(" attenuation1 = %s\n", light.attenuation1); + l->Debug(" attenuation2 = %s\n", light.attenuation2); + l->Debug(" spotAngle = %s\n", light.spotAngle); + l->Debug(" spotIntensity = %s\n", light.spotIntensity); + + l->Debug(" intensity: %f\n", dynLight.intensity.current); + l->Debug(" color: %f %f %f\n", dynLight.colorRed.current, dynLight.colorGreen.current, dynLight.colorBlue.current); + l->Debug(" includeType: %d\n", dynLight.includeType); + l->Debug(" excludeType: %d\n", dynLight.excludeType); + } +} + void CLightManager::FlushLights() { m_dynLights.clear(); @@ -117,6 +173,7 @@ int CLightManager::CreateLight(LightPriority priority) m_dynLights.push_back(DynamicLight()); m_dynLights[index] = DynamicLight(); + m_dynLights[index].rank = index; m_dynLights[index].used = true; m_dynLights[index].enabled = true; m_dynLights[index].priority = priority; @@ -411,7 +468,7 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type) if (enabled) { - m_lightMap[lightMapIndex] = i; + m_lightMap[lightMapIndex] = sortedLights[i].rank; ++lightMapIndex; } @@ -424,8 +481,9 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type) int rank = m_lightMap[i]; if (rank != -1) { - sortedLights[rank].light.ambient = Gfx::Color(0.2f, 0.2f, 0.2f); - m_device->SetLight(i, sortedLights[rank].light); + Light light = m_dynLights[rank].light; + light.ambient = Gfx::Color(0.2f, 0.2f, 0.2f); + m_device->SetLight(i, light); m_device->SetLightEnabled(i, true); } else diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h index 171299c..d0ac338 100644 --- a/src/graphics/engine/lightman.h +++ b/src/graphics/engine/lightman.h @@ -84,6 +84,9 @@ enum LightPriority */ struct DynamicLight { + //! Rank (index) + int rank; + //! Whether the light is used bool used; //! Whether the light is turned on @@ -136,6 +139,9 @@ public: //! Sets the device to be used void SetDevice(CDevice* device); + //! Prints debug info + void DebugDumpLights(); + //! Clears and disables all lights void FlushLights(); //! Creates a new dynamic light and returns its index (lightRank) diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index 93198ec..7c51829 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -2398,6 +2398,7 @@ void CPyro::LightOperFrame(float rTime) { if ( m_progress < m_lightOper[i].progress ) { + assert(i > 0); // TODO: if assert fails, fix the code float progress = (m_progress-m_lightOper[i-1].progress) / (m_lightOper[i].progress-m_lightOper[i-1].progress); float intensity = m_lightOper[i-1].intensity + (m_lightOper[i].intensity-m_lightOper[i-1].intensity)*progress; diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 4bfc542..534a13f 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -79,6 +79,106 @@ void CGLDevice::DebugHook() glColor3i(0, 0, 0); } +void CGLDevice::DebugLights() +{ + Gfx::ColorHSV color(0.0, 1.0, 1.0); + + glLineWidth(3.0f); + glDisable(GL_LIGHTING); + glDepthMask(GL_FALSE); + glDisable(GL_BLEND); + + Math::Matrix saveWorldMat = m_worldMat; + m_worldMat.LoadIdentity(); + UpdateModelviewMatrix(); + + for (int i = 0; i < m_lights.size(); ++i) + { + color.h = static_cast(i) / static_cast(m_lights.size()); + if (m_lightsEnabled[i]) + { + const Light& l = m_lights[i]; + if (l.type == LIGHT_DIRECTIONAL) + { + Gfx::VertexCol v[2]; + v[0].coord = -Math::Normalize(l.direction) * 100.0f + Math::Vector(0.0f, 0.0f, 1.0f) * i; + v[0].color = HSV2RGB(color); + v[1].coord = Math::Normalize(l.direction) * 100.0f + Math::Vector(0.0f, 0.0f, 1.0f) * i; + v[1].color = HSV2RGB(color); + while (v[0].coord.y < 60.0f && v[0].coord.y < 60.0f) + { + v[0].coord.y += 10.0f; + v[1].coord.y += 10.0f; + } + DrawPrimitive(PRIMITIVE_LINES, v, 2); + + v[0].coord = v[1].coord + Math::Normalize(v[0].coord - v[1].coord) * 50.0f; + + glLineWidth(10.0f); + DrawPrimitive(PRIMITIVE_LINES, v, 2); + glLineWidth(3.0f); + } + else if (l.type == LIGHT_POINT) + { + Gfx::VertexCol v[8]; + for (int i = 0; i < 8; ++i) + v[i].color = HSV2RGB(color); + + v[0].coord = l.position + Math::Vector(-1.0f, -1.0f, -1.0f) * 4.0f; + v[1].coord = l.position + Math::Vector( 1.0f, -1.0f, -1.0f) * 4.0f; + v[2].coord = l.position + Math::Vector( 1.0f, 1.0f, -1.0f) * 4.0f; + v[3].coord = l.position + Math::Vector(-1.0f, 1.0f, -1.0f) * 4.0f; + v[4].coord = l.position + Math::Vector(-1.0f, -1.0f, -1.0f) * 4.0f; + DrawPrimitive(PRIMITIVE_LINE_STRIP, v, 5); + + v[0].coord = l.position + Math::Vector(-1.0f, -1.0f, 1.0f) * 4.0f; + v[1].coord = l.position + Math::Vector( 1.0f, -1.0f, 1.0f) * 4.0f; + v[2].coord = l.position + Math::Vector( 1.0f, 1.0f, 1.0f) * 4.0f; + v[3].coord = l.position + Math::Vector(-1.0f, 1.0f, 1.0f) * 4.0f; + v[4].coord = l.position + Math::Vector(-1.0f, -1.0f, 1.0f) * 4.0f; + DrawPrimitive(PRIMITIVE_LINE_STRIP, v, 5); + + v[0].coord = l.position + Math::Vector(-1.0f, -1.0f, -1.0f) * 4.0f; + v[1].coord = l.position + Math::Vector(-1.0f, -1.0f, 1.0f) * 4.0f; + v[2].coord = l.position + Math::Vector( 1.0f, -1.0f, -1.0f) * 4.0f; + v[3].coord = l.position + Math::Vector( 1.0f, -1.0f, 1.0f) * 4.0f; + v[4].coord = l.position + Math::Vector( 1.0f, 1.0f, -1.0f) * 4.0f; + v[5].coord = l.position + Math::Vector( 1.0f, 1.0f, 1.0f) * 4.0f; + v[6].coord = l.position + Math::Vector(-1.0f, 1.0f, -1.0f) * 4.0f; + v[7].coord = l.position + Math::Vector(-1.0f, 1.0f, 1.0f) * 4.0f; + DrawPrimitive(PRIMITIVE_LINES, v, 8); + } + else if (l.type == LIGHT_SPOT) + { + Gfx::VertexCol v[5]; + for (int i = 0; i < 5; ++i) + v[i].color = HSV2RGB(color); + + v[0].coord = l.position + Math::Vector(-1.0f, 0.0f, -1.0f) * 4.0f; + v[1].coord = l.position + Math::Vector( 1.0f, 0.0f, -1.0f) * 4.0f; + v[2].coord = l.position + Math::Vector( 1.0f, 0.0f, 1.0f) * 4.0f; + v[3].coord = l.position + Math::Vector(-1.0f, 0.0f, 1.0f) * 4.0f; + v[4].coord = l.position + Math::Vector(-1.0f, 0.0f, -1.0f) * 4.0f; + DrawPrimitive(PRIMITIVE_LINE_STRIP, v, 5); + + v[0].coord = l.position; + v[1].coord = l.position + Math::Normalize(l.direction) * 100.0f; + glEnable(GL_LINE_STIPPLE); + glLineStipple(3.0, 0xFF); + DrawPrimitive(PRIMITIVE_LINES, v, 2); + glDisable(GL_LINE_STIPPLE); + } + } + } + + glLineWidth(1.0f); + glEnable(GL_LIGHTING); + glDepthMask(GL_TRUE); + glEnable(GL_BLEND); + m_worldMat = saveWorldMat; + UpdateModelviewMatrix(); +} + bool CGLDevice::Create() { GetLogger()->Info("Creating CDevice\n"); diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h index 004a18b..c648161 100644 --- a/src/graphics/opengl/gldevice.h +++ b/src/graphics/opengl/gldevice.h @@ -93,6 +93,7 @@ public: virtual ~CGLDevice(); virtual void DebugHook(); + virtual void DebugLights(); virtual bool Create(); virtual void Destroy(); diff --git a/src/math/matrix.h b/src/math/matrix.h index a13f823..f139517 100644 --- a/src/math/matrix.h +++ b/src/math/matrix.h @@ -97,8 +97,8 @@ struct Matrix //! Sets value in given row and col /** - * \param row row (0 to 3) - * \param col column (0 to 3) + * \param row row (1 to 4) + * \param col column (1 to 4) * \param value value */ inline void Set(int row, int col, float value) @@ -108,8 +108,8 @@ struct Matrix //! Returns the value in given row and col /** - * \param row row (0 to 3) - * \param col column (0 to 3) + * \param row row (1 to 4) + * \param col column (1 to 4) * \returns value */ inline float Get(int row, int col) -- cgit v1.2.3-1-g7c22 From 4c33172e173b8f815a367f1e1c0fae06d9051df5 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 17 Jun 2013 20:52:56 +0200 Subject: Fixed string formats in light debug prints --- src/graphics/engine/lightman.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index 3e512d8..cd743a5 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -141,11 +141,11 @@ void CLightManager::DebugDumpLights() l->Debug(" position = %s\n", str.c_str()); str = light.direction.ToString(); l->Debug(" direction = %s\n", str.c_str()); - l->Debug(" attenuation0 = %s\n", light.attenuation0); - l->Debug(" attenuation1 = %s\n", light.attenuation1); - l->Debug(" attenuation2 = %s\n", light.attenuation2); - l->Debug(" spotAngle = %s\n", light.spotAngle); - l->Debug(" spotIntensity = %s\n", light.spotIntensity); + l->Debug(" attenuation0 = %f\n", light.attenuation0); + l->Debug(" attenuation1 = %f\n", light.attenuation1); + l->Debug(" attenuation2 = %f\n", light.attenuation2); + l->Debug(" spotAngle = %f\n", light.spotAngle); + l->Debug(" spotIntensity = %f\n", light.spotIntensity); l->Debug(" intensity: %f\n", dynLight.intensity.current); l->Debug(" color: %f %f %f\n", dynLight.colorRed.current, dynLight.colorGreen.current, dynLight.colorBlue.current); -- cgit v1.2.3-1-g7c22 From 28b4e9a63450110978d60de80a9af2e901d49a97 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 20 Jun 2013 23:14:37 +0200 Subject: Fixed terrain light priorities (fix for #139) * lights illuminating the terrain specified in scene file are now always moved to front of light ordering --- src/graphics/engine/lightman.cpp | 12 ++++++++++++ src/graphics/engine/lightman.h | 7 +++++-- src/graphics/opengl/gldevice.cpp | 2 +- src/object/robotmain.cpp | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index cd743a5..295b3da 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -236,6 +236,15 @@ bool CLightManager::SetLightEnabled(int lightRank, bool enabled) return true; } +bool CLightManager::SetLightPriority(int lightRank, LightPriority priority) +{ + if ( (lightRank < 0) || (lightRank >= static_cast( m_dynLights.size() )) ) + return false; + + m_dynLights[lightRank].priority = priority; + return true; +} + bool CLightManager::SetLightIncludeType(int lightRank, EngineObjectType type) { if ( (lightRank < 0) || (lightRank >= static_cast( m_dynLights.size() )) ) @@ -503,6 +512,9 @@ CLightManager::LightsComparator::LightsComparator(Math::Vector eyePos, EngineObj float CLightManager::LightsComparator::GetLightWeight(const DynamicLight& dynLight) { + if (dynLight.priority == LIGHT_PRI_HIGHEST) + return -1.0f; + bool enabled = true; if (!dynLight.used || !dynLight.enabled || dynLight.intensity.current == 0.0f) enabled = false; diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h index d0ac338..9677555 100644 --- a/src/graphics/engine/lightman.h +++ b/src/graphics/engine/lightman.h @@ -71,8 +71,9 @@ struct LightProgression */ enum LightPriority { - LIGHT_PRI_HIGH = 1, - LIGHT_PRI_LOW = 2 + LIGHT_PRI_HIGHEST = 1, //!< always highest weight (always picked) + LIGHT_PRI_HIGH = 2, //!< high weight + LIGHT_PRI_LOW = 3 //!< low weight }; /** @@ -154,6 +155,8 @@ public: bool GetLight(int lightRank, Light &light); //! Enables/disables the given dynamic light bool SetLightEnabled(int lightRank, bool enable); + //! Changes the light priority + bool SetLightPriority(int lightRank, LightPriority priority); //! Sets what objects are included in given dynamic light bool SetLightIncludeType(int lightRank, EngineObjectType type); diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 534a13f..bbabdd6 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -92,7 +92,7 @@ void CGLDevice::DebugLights() m_worldMat.LoadIdentity(); UpdateModelviewMatrix(); - for (int i = 0; i < m_lights.size(); ++i) + for (int i = 0; i < static_cast( m_lights.size() ); ++i) { color.h = static_cast(i) / static_cast(m_lights.size()); if (m_lightsEnabled[i]) diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 23f5a28..7eaa3f6 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4784,7 +4784,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL); if (type == Gfx::ENG_OBJTYPE_TERRAIN) + { + m_lightMan->SetLightPriority(lightRank, Gfx::LIGHT_PRI_HIGHEST); m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN); + } if (type == Gfx::ENG_OBJTYPE_QUARTZ) m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_QUARTZ); -- cgit v1.2.3-1-g7c22 From 1377e48910c1bef1829c67740360b0a8309239a1 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 22 Jun 2013 01:16:40 +0200 Subject: Reverted enum values to fix UT regression --- src/graphics/engine/lightman.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h index 9677555..a2f6044 100644 --- a/src/graphics/engine/lightman.h +++ b/src/graphics/engine/lightman.h @@ -71,9 +71,9 @@ struct LightProgression */ enum LightPriority { - LIGHT_PRI_HIGHEST = 1, //!< always highest weight (always picked) - LIGHT_PRI_HIGH = 2, //!< high weight - LIGHT_PRI_LOW = 3 //!< low weight + LIGHT_PRI_HIGHEST = 0, //!< always highest weight (always picked) + LIGHT_PRI_HIGH = 1, //!< high weight + LIGHT_PRI_LOW = 2 //!< low weight }; /** -- cgit v1.2.3-1-g7c22 From bfcce26f8949f4ba42cc1bd8203dff51884aa0da Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 22 Jun 2013 01:11:37 +0200 Subject: Changes in build organization * targets are now created in top-level build directory * more things are now configured through CMake options * changed debug build detection from NDEBUG to DEV_BUILD * moved po and desktop directories * moved last unit test out of src directory --- src/CMakeLists.txt | 8 +- src/common/profile.cpp | 13 +- src/desktop/.gitignore | 2 - src/desktop/CMakeLists.txt | 98 -- src/desktop/colobot.desktop.in | 7 - src/desktop/colobot.ini | 4 - src/desktop/colobot.pod | 48 - src/desktop/colobot.svg | 239 ---- src/desktop/create_desktop_file.sh | 18 - src/desktop/po/colobot-desktop.pot | 135 -- src/desktop/po/fr.po | 153 -- src/desktop/po4a.cfg | 5 - src/graphics/engine/lightman.cpp | 2 +- src/graphics/engine/test/CMakeLists.txt | 28 - src/graphics/engine/test/modelfile_test.cpp | 263 ---- src/object/robotmain.cpp | 8 +- src/object/robotmain.h | 2 +- src/po/CMakeLists.txt | 19 - src/po/colobot.pot | 1819 ----------------------- src/po/de.po | 2056 -------------------------- src/po/fr.po | 2058 -------------------------- src/po/pl.po | 2066 --------------------------- src/ui/maindialog.cpp | 8 +- 23 files changed, 19 insertions(+), 9040 deletions(-) delete mode 100644 src/desktop/.gitignore delete mode 100644 src/desktop/CMakeLists.txt delete mode 100644 src/desktop/colobot.desktop.in delete mode 100644 src/desktop/colobot.ini delete mode 100644 src/desktop/colobot.pod delete mode 100644 src/desktop/colobot.svg delete mode 100755 src/desktop/create_desktop_file.sh delete mode 100644 src/desktop/po/colobot-desktop.pot delete mode 100644 src/desktop/po/fr.po delete mode 100644 src/desktop/po4a.cfg delete mode 100644 src/graphics/engine/test/CMakeLists.txt delete mode 100644 src/graphics/engine/test/modelfile_test.cpp delete mode 100644 src/po/CMakeLists.txt delete mode 100644 src/po/colobot.pot delete mode 100644 src/po/de.po delete mode 100644 src/po/fr.po delete mode 100644 src/po/pl.po (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8493fe8..7c02aa1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,12 +8,8 @@ set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG}) add_subdirectory(CBot) -add_subdirectory(tools) - -add_subdirectory(po) - -if(${DESKTOP}) - add_subdirectory(desktop) +if(${TOOLS}) + add_subdirectory(tools) endif() diff --git a/src/common/profile.cpp b/src/common/profile.cpp index c6af6cc..77c70c3 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -47,11 +47,10 @@ bool CProfile::InitCurrentDirectory() { try { - // TODO: NDEBUG should be replaced with something like BUILD_TYPE == "DEBUG"/"RELEASE" - #ifdef NDEBUG - bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #else + #if DEV_BUILD bp::ini_parser::read_ini("colobot.ini", m_propertyTree); + #else + bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); #endif } catch (std::exception & e) @@ -68,10 +67,10 @@ bool CProfile::SaveCurrentDirectory() { try { - #ifdef NDEBUG - bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #else + #if DEV_BUILD bp::ini_parser::write_ini("colobot.ini", m_propertyTree); + #else + bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); #endif } catch (std::exception & e) diff --git a/src/desktop/.gitignore b/src/desktop/.gitignore deleted file mode 100644 index 0e770f7..0000000 --- a/src/desktop/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -lang/ - diff --git a/src/desktop/CMakeLists.txt b/src/desktop/CMakeLists.txt deleted file mode 100644 index 23f2280..0000000 --- a/src/desktop/CMakeLists.txt +++ /dev/null @@ -1,98 +0,0 @@ -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}" - ) -add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}) -install( - 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/ - ) - -# 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() -endif() - -# Create manpage from pod-formatted file -find_program(POD2MAN pod2man) -if(POD2MAN AND (NOT MSYS)) - 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} - 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" - ) - 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}/ ) - - add_dependencies(man man${PM_LOCALE}) - endmacro() - - # Create the english manpage - podman(PODFILE colobot.pod) - -endif() - -# Translate translatable material -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) - - 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 deleted file mode 100644 index 9b48d87..0000000 --- a/src/desktop/colobot.desktop.in +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Exec=colobot -Icon=colobot -Categories=Education;Robotics;Game;AdventureGame;StrategyGame; - diff --git a/src/desktop/colobot.ini b/src/desktop/colobot.ini deleted file mode 100644 index 27193df..0000000 --- a/src/desktop/colobot.ini +++ /dev/null @@ -1,4 +0,0 @@ -Name="Colobot" -GenericName="Game to learn programming" -Comment="Colonize with bots" - diff --git a/src/desktop/colobot.pod b/src/desktop/colobot.pod deleted file mode 100644 index 6a25f70..0000000 --- a/src/desktop/colobot.pod +++ /dev/null @@ -1,48 +0,0 @@ -=encoding utf8 - -=head1 NAME - -colobot - educational programming strategy game - -=head1 SYNOPSIS - -B [B<-datadir> I] [B<-debug>] [B<-loglevel> I] [B<-language> I] - -=head1 DESCRIPTION - -Colobot (Colonize with Bots) is an educational game aiming to teach -programming through entertainment. You are playing as an astronaut on a -journey with robot helpers to find a planet for colonization. It features 3D -real-time graphics and a C++ and Java-like, object-oriented language, CBOT, -which can be used to program the robots available in the game. - -=head1 OPTIONS - -=over 8 - -=item B<-help> - -Display a short help text - -=item B<-datadir> F - -Set custom data directory path - -=item B<-debug> - -Enable debug mode (more info printed in logs) - -=item B<-loglevel> I - -Set log level. Possible choices are: trace, debug, info, warn, error, none. - -=item B<-language> I - -Set language. Note that you can also fill the B environment variable. - -=back - -=head1 AUTHOR - -This manpage was written by Didier Raboud >. - diff --git a/src/desktop/colobot.svg b/src/desktop/colobot.svg deleted file mode 100644 index ef5949f..0000000 --- a/src/desktop/colobot.svg +++ /dev/null @@ -1,239 +0,0 @@ - - - - - diff --git a/src/desktop/create_desktop_file.sh b/src/desktop/create_desktop_file.sh deleted file mode 100755 index 8f3d15b..0000000 --- a/src/desktop/create_desktop_file.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -# Create colobot.desktop from various colobot.ini's - -fname=colobot.ini - -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 -done diff --git a/src/desktop/po/colobot-desktop.pot b/src/desktop/po/colobot-desktop.pot deleted file mode 100644 index ac6bbd2..0000000 --- a/src/desktop/po/colobot-desktop.pot +++ /dev/null @@ -1,135 +0,0 @@ -# SOME DESCRIPTIVE TITLE -# Copyright (C) YEAR Free Software Foundation, Inc. -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2013-01-20 14:26+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: colobot.ini:1 -#, no-wrap -msgid "Colobot" -msgstr "" - -#: colobot.ini:2 -#, no-wrap -msgid "Game to learn programming" -msgstr "" - -#: colobot.ini:3 -#, no-wrap -msgid "Colonize with bots" -msgstr "" - -#. type: =head1 -#: colobot.pod:3 -msgid "NAME" -msgstr "" - -#. type: textblock -#: colobot.pod:5 -msgid "colobot - educational programming strategy game" -msgstr "" - -#. type: =head1 -#: colobot.pod:7 -msgid "SYNOPSIS" -msgstr "" - -#. type: textblock -#: colobot.pod:9 -msgid "" -"B [B<-datadir> I] [B<-debug>] [B<-loglevel> I] " -"[B<-language> I]" -msgstr "" - -#. type: =head1 -#: colobot.pod:11 -msgid "DESCRIPTION" -msgstr "" - -#. type: textblock -#: colobot.pod:13 -msgid "" -"Colobot (Colonize with Bots) is an educational game aiming to teach " -"programming through entertainment. You are playing as an astronaut on a " -"journey with robot helpers to find a planet for colonization. It features 3D " -"real-time graphics and a C++ and Java-like, object-oriented language, CBOT, " -"which can be used to program the robots available in the game." -msgstr "" - -#. type: =head1 -#: colobot.pod:19 -msgid "OPTIONS" -msgstr "" - -#. type: =item -#: colobot.pod:23 -msgid "B<-help>" -msgstr "" - -#. type: textblock -#: colobot.pod:25 -msgid "Display a short help text" -msgstr "" - -#. type: =item -#: colobot.pod:27 -msgid "B<-datadir> F" -msgstr "" - -#. type: textblock -#: colobot.pod:29 -msgid "Set custom data directory path" -msgstr "" - -#. type: =item -#: colobot.pod:31 -msgid "B<-debug>" -msgstr "" - -#. type: textblock -#: colobot.pod:33 -msgid "Enable debug mode (more info printed in logs)" -msgstr "" - -#. type: =item -#: colobot.pod:35 -msgid "B<-loglevel> I" -msgstr "" - -#. type: textblock -#: colobot.pod:37 -msgid "Set log level. Possible choices are: trace, debug, info, warn, error, none." -msgstr "" - -#. type: =item -#: colobot.pod:39 -msgid "B<-language> I" -msgstr "" - -#. type: textblock -#: colobot.pod:41 -msgid "Set language. Note that you can also fill the B environment variable." -msgstr "" - -#. type: =head1 -#: colobot.pod:45 -msgid "AUTHOR" -msgstr "" - -#. type: textblock -#: colobot.pod:47 -msgid "This manpage was written by Didier Raboud >." -msgstr "" - diff --git a/src/desktop/po/fr.po b/src/desktop/po/fr.po deleted file mode 100644 index 40fa9e1..0000000 --- a/src/desktop/po/fr.po +++ /dev/null @@ -1,153 +0,0 @@ -# French translations for PACKAGE package -# Copyright (C) 2012 Free Software Foundation, Inc. -# This file is distributed under the same license as the PACKAGE package. -# -# Didier Raboud , 2012. -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2013-01-20 14:26+0100\n" -"PO-Revision-Date: 2012-12-27 11:00+0100\n" -"Last-Translator: Didier Raboud \n" -"Language-Team: none\n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" - -#: colobot.ini:1 -#, no-wrap -msgid "Colobot" -msgstr "Colobot" - -#: colobot.ini:2 -#, no-wrap -msgid "Game to learn programming" -msgstr "Apprentissage de la programmation par le jeu" - -#: colobot.ini:3 -#, no-wrap -msgid "Colonize with bots" -msgstr "Colonise avec des roBots" - -#. type: =head1 -#: colobot.pod:3 -msgid "NAME" -msgstr "NOM" - -#. type: textblock -#: colobot.pod:5 -msgid "colobot - educational programming strategy game" -msgstr "colobot - Jeu éducatif de stratégie et de programmation" - -#. type: =head1 -#: colobot.pod:7 -msgid "SYNOPSIS" -msgstr "RÉSUMÉ" - -#. type: textblock -#: colobot.pod:9 -msgid "" -"B [B<-datadir> I] [B<-debug>] [B<-loglevel> I] [B<-" -"language> I]" -msgstr "" -"B [B<-datadir> I] [B<-debug>] [B<-loglevel> I] [B<-" -"language> I]" - -#. type: =head1 -#: colobot.pod:11 -msgid "DESCRIPTION" -msgstr "DESCRIPTION" - -#. type: textblock -#: colobot.pod:13 -msgid "" -"Colobot (Colonize with Bots) is an educational game aiming to teach " -"programming through entertainment. You are playing as an astronaut on a " -"journey with robot helpers to find a planet for colonization. It features 3D " -"real-time graphics and a C++ and Java-like, object-oriented language, CBOT, " -"which can be used to program the robots available in the game." -msgstr "" -"Colobot (Colonise avec des roBots) est un jeu éducatif visant à " -"l'enseignement de la programmation par le jeu. Vous jouez un astronaute en " -"voyage avec des robots à la recherche d'une planète à coloniser. Son " -"interface est en trois-dimensions et en temps réel; le language utilisé " -"(CBOT) ressemble au C++ et à Java et peut être utilisé pour programmer les " -"robots disponibles dans le jeu." - -#. type: =head1 -#: colobot.pod:19 -msgid "OPTIONS" -msgstr "OPTIONS" - -#. type: =item -#: colobot.pod:23 -msgid "B<-help>" -msgstr "B<-help>" - -#. type: textblock -#: colobot.pod:25 -msgid "Display a short help text" -msgstr "Affiche un court texte d'aide" - -#. type: =item -#: colobot.pod:27 -msgid "B<-datadir> F" -msgstr "B<-datadir> F" - -#. type: textblock -#: colobot.pod:29 -msgid "Set custom data directory path" -msgstr "Définit le chemin vers un répertoire de données spécifique" - -#. type: =item -#: colobot.pod:31 -msgid "B<-debug>" -msgstr "B<-debug>" - -#. type: textblock -#: colobot.pod:33 -msgid "Enable debug mode (more info printed in logs)" -msgstr "" -"Active le mode de déboguage (plus d'informations sont affichées dans le " -"journal)" - -#. type: =item -#: colobot.pod:35 -msgid "B<-loglevel> I" -msgstr "B<-loglevel> I" - -#. type: textblock -#: colobot.pod:37 -msgid "" -"Set log level. Possible choices are: trace, debug, info, warn, error, none." -msgstr "" -"Définit le niveau de journalisation parmi: trace, debug, info, warn, error, " -"none." - -#. type: =item -#: colobot.pod:39 -msgid "B<-language> I" -msgstr "B<-language> I" - -#. type: textblock -#: colobot.pod:41 -msgid "" -"Set language. Note that you can also fill the B environment variable." -msgstr "" -"Définit la langue. Il est aussi possible d'utiliser la variable " -"d'environnement B." - -#. type: =head1 -#: colobot.pod:45 -msgid "AUTHOR" -msgstr "Auteur" - -#. type: textblock -#: colobot.pod:47 -msgid "This manpage was written by Didier Raboud >." -msgstr "" -"Cette page de manuel a été écrite et traduite par Didier Raboud " -">." - diff --git a/src/desktop/po4a.cfg b/src/desktop/po4a.cfg deleted file mode 100644 index 881929d..0000000 --- a/src/desktop/po4a.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[po_directory] po/ - -[type:ini] colobot.ini $lang:lang/$lang/colobot.ini -[type:pod] colobot.pod $lang:lang/$lang/colobot.pod - diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp index 295b3da..8694c7a 100644 --- a/src/graphics/engine/lightman.cpp +++ b/src/graphics/engine/lightman.cpp @@ -112,7 +112,7 @@ void CLightManager::DebugDumpLights() continue; int deviceLight = -1; - for (int j = 0; j < m_lightMap.size(); ++j) + for (int j = 0; j < static_cast( m_lightMap.size() ); ++j) { if (m_lightMap[j] == i) { diff --git a/src/graphics/engine/test/CMakeLists.txt b/src/graphics/engine/test/CMakeLists.txt deleted file mode 100644 index 134ed2a..0000000 --- a/src/graphics/engine/test/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -set(MODELFILE_TEST_SOURCES -modelfile_test.cpp -../modelfile.cpp -../../../common/logger.cpp -../../../common/stringutils.cpp -) - -add_definitions(-DMODELFILE_NO_ENGINE) - -include_directories( -. -../../.. -${GTEST_INCLUDE_DIR} -) - -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 deleted file mode 100644 index 1ca7f0a..0000000 --- a/src/graphics/engine/test/modelfile_test.cpp +++ /dev/null @@ -1,263 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. - - -#include "common/logger.h" -#include "graphics/engine/modelfile.h" -#include "math/func.h" - -#include - -#include -#include - -/* Test model file (new text format) */ -const char* const TEXT_MODEL = -"# Colobot text model\n" -"\n" -"### HEAD\n" -"version 1\n" -"total_triangles 2\n" -"\n" -"### TRIANGLES\n" -"p1 c -12.4099 10.0016 -2.54558 n 1 -0 1.87319e-07 t1 0.970703 0.751953 t2 0 0\n" -"p2 c -12.4099 10.0016 2.54558 n 1 -0 1.87319e-07 t1 0.998047 0.751953 t2 0 0\n" -"p3 c -12.4099 4.00165 -2.54558 n 1 -0 1.87319e-07 t1 0.970703 0.998047 t2 0 0\n" -"mat dif 1 1 1 0 amb 0.5 0.5 0.5 0 spc 0 0 0 0\n" -"tex1 lemt.png\n" -"tex2\n" -"var_tex2 N\n" -"lod_level 0\n" -"state 1024\n" -"\n" -"p1 c -19 -1 4 n -1 0 0 t1 0.248047 0.123047 t2 0.905224 0.52067\n" -"p2 c -19 4 4 n -1 0 0 t1 0.248047 0.00195312 t2 0.905224 0.614223\n" -"p3 c -19 4 -4 n -1 0 0 t1 0.00195312 0.00195312 t2 0.0947756 0.614223\n" -"mat dif 1 1 1 0 amb 0.5 0.5 0.5 0 spc 0 0 0 0\n" -"tex1 derrick.png\n" -"tex2\n" -"var_tex2 Y\n" -"lod_level 1\n" -"state 0\n" -""; - -// Triangles as defined in model file -Gfx::ModelTriangle TRIANGLE_1; -Gfx::ModelTriangle TRIANGLE_2; - -// Sets triangle data -void Init() -{ - - TRIANGLE_1.p1 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, -2.54558), - Math::Vector(1, 0, 1.87319e-07), - Math::Point(0.970703, 0.751953), - Math::Point(0, 0)); - TRIANGLE_1.p2 = Gfx::VertexTex2(Math::Vector(-12.4099, 10.0016, 2.54558), - Math::Vector(1, 0, 1.87319e-07), - Math::Point(0.998047, 0.751953), - Math::Point(0, 0)); - TRIANGLE_1.p3 = Gfx::VertexTex2(Math::Vector(-12.4099, 4.00165, -2.54558), - Math::Vector(1, 0, 1.87319e-07), - Math::Point(0.970703, 0.998047), - Math::Point(0, 0)); - TRIANGLE_1.material.diffuse = Gfx::Color(1, 1, 1, 0); - TRIANGLE_1.material.ambient = Gfx::Color(0.5, 0.5, 0.5, 0); - TRIANGLE_1.material.specular = Gfx::Color(0, 0, 0, 0); - TRIANGLE_1.tex1Name = "lemt.png"; - TRIANGLE_1.variableTex2 = false; - TRIANGLE_1.lodLevel = Gfx::LOD_Constant; - TRIANGLE_1.state = 1024; - - TRIANGLE_2.p1 = Gfx::VertexTex2(Math::Vector(-19, -1, 4), - Math::Vector(-1, 0, 0), - Math::Point(0.248047, 0.123047), - Math::Point(0.905224, 0.52067)); - TRIANGLE_2.p2 = Gfx::VertexTex2(Math::Vector(-19, 4, 4), - Math::Vector(-1, 0, 0), - Math::Point(0.248047, 0.00195312), - Math::Point(0.905224, 0.614223)); - TRIANGLE_2.p3 = Gfx::VertexTex2(Math::Vector(-19, 4, -4), - Math::Vector(-1, 0, 0), - Math::Point(0.00195312, 0.00195312), - Math::Point(0.0947756, 0.614223)); - TRIANGLE_2.material.diffuse = Gfx::Color(1, 1, 1, 0); - TRIANGLE_2.material.ambient = Gfx::Color(0.5, 0.5, 0.5, 0); - TRIANGLE_2.material.specular = Gfx::Color(0, 0, 0, 0); - TRIANGLE_2.tex1Name = "derrick.png"; - TRIANGLE_2.variableTex2 = true; - TRIANGLE_2.lodLevel = Gfx::LOD_Low; - TRIANGLE_2.state = 0; -} - - -// Compares vertices (within Math::TOLERANCE) -bool CompareVertices(const Gfx::VertexTex2& v1, const Gfx::VertexTex2& v2) -{ - if ( !( Math::IsEqual(v1.coord.x, v2.coord.x) && - Math::IsEqual(v1.coord.y, v2.coord.y) && - Math::IsEqual(v1.coord.z, v2.coord.z) ) ) - return false; - - if ( !( Math::IsEqual(v1.normal.x, v2.normal.x) && - Math::IsEqual(v1.normal.y, v2.normal.y) && - Math::IsEqual(v1.normal.z, v2.normal.z) ) ) - return false; - - if ( !( Math::IsEqual(v1.texCoord.x, v2.texCoord.x) && - Math::IsEqual(v1.texCoord.y, v2.texCoord.y) ) ) - return false; - - if ( !( Math::IsEqual(v1.texCoord2.x, v2.texCoord2.x) && - Math::IsEqual(v1.texCoord2.y, v2.texCoord2.y) ) ) - return false; - - return true; -} - -// Compares colors (within Math::TOLERANCE) -bool CompareColors(const Gfx::Color& c1, const Gfx::Color& c2) -{ - return Math::IsEqual(c1.r, c2.r) && - Math::IsEqual(c1.g, c2.g) && - Math::IsEqual(c1.b, c2.b) && - Math::IsEqual(c1.a, c2.a); -} - -// Compares model triangles (within Math::TOLERANCE) -bool CompareTriangles(const Gfx::ModelTriangle& t1, const Gfx::ModelTriangle& t2) -{ - if (! CompareVertices(t1.p1, t2.p1)) - return false; - - if (! CompareVertices(t1.p2, t2.p2)) - return false; - - if (! CompareVertices(t1.p3, t2.p3)) - return false; - - if (! CompareColors(t1.material.diffuse, t2.material.diffuse)) - return false; - - if (! CompareColors(t1.material.ambient, t2.material.ambient)) - return false; - - if (! CompareColors(t1.material.specular, t2.material.specular)) - return false; - - if (t1.tex1Name != t2.tex1Name) - return false; - - if (t1.tex2Name != t2.tex2Name) - return false; - - if (t1.variableTex2 != t2.variableTex2) - return false; - - if (t1.lodLevel != t2.lodLevel) - return false; - - if (t1.state != t2.state) - return false; - - return true; -} - -// Tests reading/writing new text model file -TEST(ModelFileTest, RWTxtModel) -{ - std::stringstream str; - str.str(TEXT_MODEL); - - Gfx::CModelFile modelFile; - - EXPECT_TRUE(modelFile.ReadTextModel(str)); - - EXPECT_EQ(modelFile.GetTriangleCount(), 2); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); - - str.str(""); - - EXPECT_TRUE(modelFile.WriteTextModel(str)); - str.seekg(0); - EXPECT_TRUE(modelFile.ReadTextModel(str)); - - EXPECT_EQ(modelFile.GetTriangleCount(), 2); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); -} - -// Tests reading/writing new binary model -TEST(ModelFileTest, RWBinModel) -{ - std::stringstream str; - str.str(TEXT_MODEL); - - Gfx::CModelFile modelFile; - - EXPECT_TRUE(modelFile.ReadTextModel(str)); - - EXPECT_EQ(modelFile.GetTriangleCount(), 2); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); - - str.str(""); - - EXPECT_TRUE(modelFile.WriteBinaryModel(str)); - str.seekg(0); - EXPECT_TRUE(modelFile.ReadBinaryModel(str)); - - EXPECT_EQ(modelFile.GetTriangleCount(), 2); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); -} - -// Tests reading/writing old model file -TEST(ModelFileTest, RWOldModel) -{ - std::stringstream str; - str.str(TEXT_MODEL); - - Gfx::CModelFile modelFile; - - EXPECT_TRUE(modelFile.ReadTextModel(str)); - - EXPECT_EQ(modelFile.GetTriangleCount(), 2); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); - - str.str(""); - - EXPECT_TRUE(modelFile.WriteModel(str)); - str.seekg(0); - EXPECT_TRUE(modelFile.ReadModel(str)); - - EXPECT_EQ(modelFile.GetTriangleCount(), 2); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[0], TRIANGLE_1)); - EXPECT_TRUE(CompareTriangles(modelFile.GetTriangles()[1], TRIANGLE_2)); -} - -int main(int argc, char **argv) -{ - CLogger logger; - - Init(); - - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 7eaa3f6..b58e5f8 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -669,11 +669,13 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_showPos = false; m_selectInsect = false; m_showSoluce = false; - #ifdef NDEBUG - m_showAll = false; - #else + + #if DEV_BUILD m_showAll = true; // for development + #else + m_showAll = false; #endif + m_cheatRadar = false; m_fixScene = false; m_trainerPilot = false; diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 04efea7..525e5df 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -192,7 +192,7 @@ class CRobotMain : public CSingleton { public: CRobotMain(CApplication* app, bool loadProfile); - ~CRobotMain(); + virtual ~CRobotMain(); Gfx::CCamera* GetCamera(); Gfx::CTerrain* GetTerrain(); diff --git a/src/po/CMakeLists.txt b/src/po/CMakeLists.txt deleted file mode 100644 index 85b401c..0000000 --- a/src/po/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -set(_potFile colobot.pot) - -find_program(XGETTEXT_CMD xgettext) - -add_custom_command(OUTPUT ${_potFile} - COMMAND ${XGETTEXT_CMD} ../app/app.cpp --output=${_potFile} - COMMAND ${XGETTEXT_CMD} ../common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location - - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Extract translatable messages to ${_potFile}" -) - -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 deleted file mode 100644 index 8ce386f..0000000 --- a/src/po/colobot.pot +++ /dev/null @@ -1,1819 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 17:09+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -msgid "Colobot rules!" -msgstr "" - -msgid "SatCom" -msgstr "" - -msgid "Maximize" -msgstr "" - -msgid "Minimize" -msgstr "" - -msgid "Normal size" -msgstr "" - -msgid "Close" -msgstr "" - -msgid "Program editor" -msgstr "" - -msgid "New" -msgstr "" - -msgid "Player" -msgstr "" - -msgid "New ..." -msgstr "" - -msgid " or " -msgstr "" - -msgid "COLOBOT" -msgstr "" - -msgid "Programming exercises" -msgstr "" - -msgid "Challenges" -msgstr "" - -msgid "Missions" -msgstr "" - -msgid "Free game" -msgstr "" - -msgid "User levels" -msgstr "" - -msgid "Prototypes" -msgstr "" - -msgid "Options" -msgstr "" - -msgid "Player's name" -msgstr "" - -msgid "Customize your appearance" -msgstr "" - -msgid "Save the current mission" -msgstr "" - -msgid "Load a saved mission" -msgstr "" - -msgid " Chapters:" -msgstr "" - -msgid " Planets:" -msgstr "" - -msgid " User levels:" -msgstr "" - -msgid " Exercises in the chapter:" -msgstr "" - -msgid " Challenges in the chapter:" -msgstr "" - -msgid " Missions on this planet:" -msgstr "" - -msgid " Free game on this planet:" -msgstr "" - -msgid " Missions on this level:" -msgstr "" - -msgid " Prototypes on this planet:" -msgstr "" - -msgid " Free game on this chapter:" -msgstr "" - -msgid " Summary:" -msgstr "" - -msgid " Drivers:" -msgstr "" - -msgid " Resolution:" -msgstr "" - -msgid "1) First click on the key you want to redefine." -msgstr "" - -msgid "2) Then press the key you want to use instead." -msgstr "" - -msgid "Face type:" -msgstr "" - -msgid "Eyeglasses:" -msgstr "" - -msgid "Hair color:" -msgstr "" - -msgid "Suit color:" -msgstr "" - -msgid "Strip color:" -msgstr "" - -msgid "Do you want to quit COLOBOT ?" -msgstr "" - -msgid "Quit\\Quit COLOBOT" -msgstr "" - -msgid "Quit the mission?" -msgstr "" - -msgid "Abort\\Abort the current mission" -msgstr "" - -msgid "Continue\\Continue the current mission" -msgstr "" - -msgid "Continue\\Continue the game" -msgstr "" - -msgid "Do you really want to destroy the selected building?" -msgstr "" - -#, c-format -msgid "Do you want to delete %s's saved games? " -msgstr "" - -msgid "Delete" -msgstr "" - -msgid "Cancel" -msgstr "" - -msgid "LOADING" -msgstr "" - -msgid "Keyword help(\\key cbot;)" -msgstr "" - -msgid "Compilation ok (0 errors)" -msgstr "" - -msgid "Program finished" -msgstr "" - -msgid "\\b;List of objects\n" -msgstr "" - -msgid "\\b;Robots\n" -msgstr "" - -msgid "\\b;Buildings\n" -msgstr "" - -msgid "\\b;Moveable objects\n" -msgstr "" - -msgid "\\b;Aliens\n" -msgstr "" - -msgid "\\c; (none)\\n;\n" -msgstr "" - -msgid "\\b;Error\n" -msgstr "" - -msgid "" -"The list is only available if a \\l;radar station\\u object\\radar; is " -"working.\n" -msgstr "" - -msgid "Open" -msgstr "" - -msgid "Save" -msgstr "" - -#, c-format -msgid "Folder: %s" -msgstr "" - -msgid "Name:" -msgstr "" - -msgid "Folder:" -msgstr "" - -msgid "Private\\Private folder" -msgstr "" - -msgid "Public\\Common folder" -msgstr "" - -msgid "Developed by :" -msgstr "" - -msgid "www.epsitec.com" -msgstr "" - -msgid " " -msgstr "" - -msgid "Recorder" -msgstr "" - -msgid "OK" -msgstr "" - -msgid "Next" -msgstr "" - -msgid "Previous" -msgstr "" - -msgid "Menu (\\key quit;)" -msgstr "" - -msgid "Exercises\\Programming exercises" -msgstr "" - -msgid "Challenges\\Programming challenges" -msgstr "" - -msgid "Missions\\Select mission" -msgstr "" - -msgid "Free game\\Free game without a specific goal" -msgstr "" - -msgid "User\\User levels" -msgstr "" - -msgid "Proto\\Prototypes under development" -msgstr "" - -msgid "New player\\Choose player's name" -msgstr "" - -msgid "Options\\Preferences" -msgstr "" - -msgid "Restart\\Restart the mission from the beginning" -msgstr "" - -msgid "Save\\Save the current mission " -msgstr "" - -msgid "Load\\Load a saved mission" -msgstr "" - -msgid "\\Return to COLOBOT" -msgstr "" - -msgid "<< Back \\Back to the previous screen" -msgstr "" - -msgid "Play\\Start mission!" -msgstr "" - -msgid "Device\\Driver and resolution settings" -msgstr "" - -msgid "Graphics\\Graphics settings" -msgstr "" - -msgid "Game\\Game settings" -msgstr "" - -msgid "Controls\\Keyboard, joystick and mouse settings" -msgstr "" - -msgid "Sound\\Music and game sound volume" -msgstr "" - -msgid "Unit" -msgstr "" - -msgid "Resolution" -msgstr "" - -msgid "Full screen\\Full screen or window mode" -msgstr "" - -msgid "Apply changes\\Activates the changed settings" -msgstr "" - -msgid "Robbie\\Your assistant" -msgstr "" - -msgid "Shadows\\Shadows on the ground" -msgstr "" - -msgid "Marks on the ground\\Marks on the ground" -msgstr "" - -msgid "Dust\\Dust and dirt on bots and buildings" -msgstr "" - -msgid "Fog\\Fog" -msgstr "" - -msgid "Sunbeams\\Sunbeams in the sky" -msgstr "" - -msgid "Sky\\Clouds and nebulae" -msgstr "" - -msgid "Planets and stars\\Astronomical objects in the sky" -msgstr "" - -msgid "Dynamic lighting\\Mobile light sources" -msgstr "" - -msgid "Number of particles\\Explosions, dust, reflections, etc." -msgstr "" - -msgid "Depth of field\\Maximum visibility" -msgstr "" - -msgid "Details\\Visual quality of 3D objects" -msgstr "" - -msgid "Textures\\Quality of textures " -msgstr "" - -msgid "Num of decorative objects\\Number of purely ornamental objects" -msgstr "" - -msgid "Particles in the interface\\Steam clouds and sparks in the interface" -msgstr "" - -msgid "Reflections on the buttons \\Shiny buttons" -msgstr "" - -msgid "Help balloons\\Explain the function of the buttons" -msgstr "" - -msgid "Film sequences\\Films before and after the missions" -msgstr "" - -msgid "Exit film\\Film at the exit of exercises" -msgstr "" - -msgid "Friendly fire\\Your shooting can damage your own objects " -msgstr "" - -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" - -msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" -msgstr "" - -msgid "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis" -msgstr "" - -msgid "Quake at explosions\\The screen shakes at explosions" -msgstr "" - -msgid "Mouse shadow\\Gives the mouse a shadow" -msgstr "" - -msgid "Automatic indent\\When program editing" -msgstr "" - -msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces" -msgstr "" - -msgid "Access to solutions\\Show program \"4: Solution\" in the exercises" -msgstr "" - -msgid "Standard controls\\Standard key functions" -msgstr "" - -msgid "Turn left\\turns the bot to the left" -msgstr "" - -msgid "Turn right\\turns the bot to the right" -msgstr "" - -msgid "Forward\\Moves forward" -msgstr "" - -msgid "Backward\\Moves backward" -msgstr "" - -msgid "Climb\\Increases the power of the jet" -msgstr "" - -msgid "Descend\\Reduces the power of the jet" -msgstr "" - -msgid "Change camera\\Switches between onboard camera and following camera" -msgstr "" - -msgid "Previous object\\Selects the previous object" -msgstr "" - -msgid "" -"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)" -msgstr "" - -msgid "Camera closer\\Moves the camera forward" -msgstr "" - -msgid "Camera back\\Moves the camera backward" -msgstr "" - -msgid "Next object\\Selects the next object" -msgstr "" - -msgid "Select the astronaut\\Selects the astronaut" -msgstr "" - -msgid "Quit\\Quit the current mission or exercise" -msgstr "" - -msgid "Instructions\\Shows the instructions for the current mission" -msgstr "" - -msgid "Programming help\\Gives more detailed help with programming" -msgstr "" - -msgid "Key word help\\More detailed help about key words" -msgstr "" - -msgid "Origin of last message\\Shows where the last message was sent from" -msgstr "" - -msgid "Speed 1.0x\\Normal speed" -msgstr "" - -msgid "Speed 1.5x\\1.5 times faster" -msgstr "" - -msgid "Speed 2.0x\\Double speed" -msgstr "" - -msgid "Speed 3.0x\\Three times faster" -msgstr "" - -msgid "Sound effects:\\Volume of engines, voice, shooting, etc." -msgstr "" - -msgid "Background sound :\\Volume of audio tracks on the CD" -msgstr "" - -msgid "3D sound\\3D positioning of the sound" -msgstr "" - -msgid "Lowest\\Minimum graphic quality (highest frame rate)" -msgstr "" - -msgid "Normal\\Normal graphic quality" -msgstr "" - -msgid "Highest\\Highest graphic quality (lowest frame rate)" -msgstr "" - -msgid "Mute\\No sound" -msgstr "" - -msgid "Normal\\Normal sound volume" -msgstr "" - -msgid "Use a joystick\\Joystick or keyboard" -msgstr "" - -msgid "" -"Access to solution\\Shows the solution (detailed instructions for missions)" -msgstr "" - -msgid "\\New player name" -msgstr "" - -msgid "OK\\Choose the selected player" -msgstr "" - -msgid "Cancel\\Keep current player name" -msgstr "" - -msgid "Delete player\\Deletes the player from the list" -msgstr "" - -msgid "Player name" -msgstr "" - -msgid "Save\\Saves the current mission" -msgstr "" - -msgid "Load\\Loads the selected mission" -msgstr "" - -msgid "List of saved missions" -msgstr "" - -msgid "Filename:" -msgstr "" - -msgid "Mission name" -msgstr "" - -msgid "Photography" -msgstr "" - -msgid "Delete\\Deletes the selected file" -msgstr "" - -msgid "Appearance\\Choose your appearance" -msgstr "" - -msgid "Standard\\Standard appearance settings" -msgstr "" - -msgid "Head\\Face and hair" -msgstr "" - -msgid "Suit\\Astronaut suit" -msgstr "" - -msgid "\\Turn left" -msgstr "" - -msgid "\\Turn right" -msgstr "" - -msgid "Red" -msgstr "" - -msgid "Green" -msgstr "" - -msgid "Blue" -msgstr "" - -msgid "\\Face 1" -msgstr "" - -msgid "\\Face 4" -msgstr "" - -msgid "\\Face 3" -msgstr "" - -msgid "\\Face 2" -msgstr "" - -msgid "\\No eyeglasses" -msgstr "" - -msgid "\\Eyeglasses 1" -msgstr "" - -msgid "\\Eyeglasses 2" -msgstr "" - -msgid "\\Eyeglasses 3" -msgstr "" - -msgid "\\Eyeglasses 4" -msgstr "" - -msgid "\\Eyeglasses 5" -msgstr "" - -msgid "Previous selection (\\key desel;)" -msgstr "" - -msgid "Turn left (\\key left;)" -msgstr "" - -msgid "Turn right (\\key right;)" -msgstr "" - -msgid "Forward (\\key up;)" -msgstr "" - -msgid "Backward (\\key down;)" -msgstr "" - -msgid "Up (\\key gup;)" -msgstr "" - -msgid "Down (\\key gdown;)" -msgstr "" - -msgid "Grab or drop (\\key action;)" -msgstr "" - -msgid "..in front" -msgstr "" - -msgid "..behind" -msgstr "" - -msgid "..power cell" -msgstr "" - -msgid "Instructions for the mission (\\key help;)" -msgstr "" - -msgid "Take off to finish the mission" -msgstr "" - -msgid "Build a derrick" -msgstr "" - -msgid "Build a power station" -msgstr "" - -msgid "Build a bot factory" -msgstr "" - -msgid "Build a repair center" -msgstr "" - -msgid "Build a converter" -msgstr "" - -msgid "Build a defense tower" -msgstr "" - -msgid "Build a research center" -msgstr "" - -msgid "Build a radar station" -msgstr "" - -msgid "Build a power cell factory" -msgstr "" - -msgid "Build an autolab" -msgstr "" - -msgid "Build a nuclear power plant" -msgstr "" - -msgid "Build a lightning conductor" -msgstr "" - -msgid "Build a exchange post" -msgstr "" - -msgid "Show if the ground is flat" -msgstr "" - -msgid "Plant a flag" -msgstr "" - -msgid "Remove a flag" -msgstr "" - -msgid "\\Blue flags" -msgstr "" - -msgid "\\Red flags" -msgstr "" - -msgid "\\Green flags" -msgstr "" - -msgid "\\Yellow flags" -msgstr "" - -msgid "\\Violet flags" -msgstr "" - -msgid "Build a winged grabber" -msgstr "" - -msgid "Build a tracked grabber" -msgstr "" - -msgid "Build a wheeled grabber" -msgstr "" - -msgid "Build a legged grabber" -msgstr "" - -msgid "Build a winged shooter" -msgstr "" - -msgid "Build a tracked shooter" -msgstr "" - -msgid "Build a wheeled shooter" -msgstr "" - -msgid "Build a legged shooter" -msgstr "" - -msgid "Build a winged orga shooter" -msgstr "" - -msgid "Build a tracked orga shooter" -msgstr "" - -msgid "Build a wheeled orga shooter" -msgstr "" - -msgid "Build a legged orga shooter" -msgstr "" - -msgid "Build a winged sniffer" -msgstr "" - -msgid "Build a tracked sniffer" -msgstr "" - -msgid "Build a wheeled sniffer" -msgstr "" - -msgid "Build a legged sniffer" -msgstr "" - -msgid "Build a thumper" -msgstr "" - -msgid "Build a phazer shooter" -msgstr "" - -msgid "Build a recycler" -msgstr "" - -msgid "Build a shielder" -msgstr "" - -msgid "Build a subber" -msgstr "" - -msgid "Run research program for tracked bots" -msgstr "" - -msgid "Run research program for winged bots" -msgstr "" - -msgid "Run research program for thumper" -msgstr "" - -msgid "Run research program for shooter" -msgstr "" - -msgid "Run research program for defense tower" -msgstr "" - -msgid "Run research program for phazer shooter" -msgstr "" - -msgid "Run research program for shielder" -msgstr "" - -msgid "Run research program for nuclear power" -msgstr "" - -msgid "Run research program for legged bots" -msgstr "" - -msgid "Run research program for orga shooter" -msgstr "" - -msgid "Return to start" -msgstr "" - -msgid "Sniff (\\key action;)" -msgstr "" - -msgid "Thump (\\key action;)" -msgstr "" - -msgid "Shoot (\\key action;)" -msgstr "" - -msgid "Recycle (\\key action;)" -msgstr "" - -msgid "Extend shield (\\key action;)" -msgstr "" - -msgid "Withdraw shield (\\key action;)" -msgstr "" - -msgid "Shield radius" -msgstr "" - -msgid "Execute the selected program" -msgstr "" - -msgid "Edit the selected program" -msgstr "" - -msgid "\\SatCom on standby" -msgstr "" - -msgid "Destroy the building" -msgstr "" - -msgid "Energy level" -msgstr "" - -msgid "Shield level" -msgstr "" - -msgid "Jet temperature" -msgstr "" - -msgid "Still working ..." -msgstr "" - -msgid "Number of insects detected" -msgstr "" - -msgid "Transmitted information" -msgstr "" - -msgid "Compass" -msgstr "" - -msgid "Zoom mini-map" -msgstr "" - -msgid "Camera (\\key camera;)" -msgstr "" - -msgid "Camera to left" -msgstr "" - -msgid "Camera to right" -msgstr "" - -msgid "Camera nearest" -msgstr "" - -msgid "Camera awayest" -msgstr "" - -msgid "Help about selected object" -msgstr "" - -msgid "Show the solution" -msgstr "" - -msgid "Switch bots <-> buildings" -msgstr "" - -msgid "Show the range" -msgstr "" - -msgid "\\Raise the pencil" -msgstr "" - -msgid "\\Use the black pencil" -msgstr "" - -msgid "\\Use the yellow pencil" -msgstr "" - -msgid "\\Use the orange pencil" -msgstr "" - -msgid "\\Use the red pencil" -msgstr "" - -msgid "\\Use the purple pencil" -msgstr "" - -msgid "\\Use the blue pencil" -msgstr "" - -msgid "\\Use the green pencil" -msgstr "" - -msgid "\\Use the brown pencil" -msgstr "" - -msgid "\\Start recording" -msgstr "" - -msgid "\\Stop recording" -msgstr "" - -msgid "Show the place" -msgstr "" - -msgid "Continue" -msgstr "" - -msgid "Command line" -msgstr "" - -msgid "Game speed" -msgstr "" - -msgid "Back" -msgstr "" - -msgid "Forward" -msgstr "" - -msgid "Home" -msgstr "" - -msgid "Copy" -msgstr "" - -msgid "Size 1" -msgstr "" - -msgid "Size 2" -msgstr "" - -msgid "Size 3" -msgstr "" - -msgid "Size 4" -msgstr "" - -msgid "Size 5" -msgstr "" - -msgid "Instructions from Houston" -msgstr "" - -msgid "Satellite report" -msgstr "" - -msgid "Programs dispatched by Houston" -msgstr "" - -msgid "List of objects" -msgstr "" - -msgid "Programming help" -msgstr "" - -msgid "Solution" -msgstr "" - -msgid "OK\\Close program editor and return to game" -msgstr "" - -msgid "Cancel\\Cancel all changes" -msgstr "" - -msgid "Open (Ctrl+o)" -msgstr "" - -msgid "Save (Ctrl+s)" -msgstr "" - -msgid "Undo (Ctrl+z)" -msgstr "" - -msgid "Cut (Ctrl+x)" -msgstr "" - -msgid "Copy (Ctrl+c)" -msgstr "" - -msgid "Paste (Ctrl+v)" -msgstr "" - -msgid "Font size" -msgstr "" - -msgid "Instructions (\\key help;)" -msgstr "" - -msgid "Programming help (\\key prog;)" -msgstr "" - -msgid "Compile" -msgstr "" - -msgid "Execute/stop" -msgstr "" - -msgid "Pause/continue" -msgstr "" - -msgid "One step" -msgstr "" - -msgid "Gantry crane" -msgstr "" - -msgid "Spaceship" -msgstr "" - -msgid "Derrick" -msgstr "" - -msgid "Bot factory" -msgstr "" - -msgid "Repair center" -msgstr "" - -msgid "Destroyer" -msgstr "" - -msgid "Power station" -msgstr "" - -msgid "Converts ore to titanium" -msgstr "" - -msgid "Defense tower" -msgstr "" - -msgid "Nest" -msgstr "" - -msgid "Research center" -msgstr "" - -msgid "Radar station" -msgstr "" - -msgid "Information exchange post" -msgstr "" - -msgid "Power cell factory" -msgstr "" - -msgid "Autolab" -msgstr "" - -msgid "Nuclear power station" -msgstr "" - -msgid "Lightning conductor" -msgstr "" - -msgid "Vault" -msgstr "" - -msgid "Houston Mission Control" -msgstr "" - -msgid "Target" -msgstr "" - -msgid "Start" -msgstr "" - -msgid "Finish" -msgstr "" - -msgid "Titanium ore" -msgstr "" - -msgid "Uranium ore" -msgstr "" - -msgid "Organic matter" -msgstr "" - -msgid "Titanium" -msgstr "" - -msgid "Power cell" -msgstr "" - -msgid "Nuclear power cell" -msgstr "" - -msgid "Black box" -msgstr "" - -msgid "Key A" -msgstr "" - -msgid "Key B" -msgstr "" - -msgid "Key C" -msgstr "" - -msgid "Key D" -msgstr "" - -msgid "Explosive" -msgstr "" - -msgid "Fixed mine" -msgstr "" - -msgid "Survival kit" -msgstr "" - -msgid "Checkpoint" -msgstr "" - -msgid "Blue flag" -msgstr "" - -msgid "Red flag" -msgstr "" - -msgid "Green flag" -msgstr "" - -msgid "Yellow flag" -msgstr "" - -msgid "Violet flag" -msgstr "" - -msgid "Energy deposit (site for power station)" -msgstr "" - -msgid "Uranium deposit (site for derrick)" -msgstr "" - -msgid "Found key A (site for derrick)" -msgstr "" - -msgid "Found key B (site for derrick)" -msgstr "" - -msgid "Found key C (site for derrick)" -msgstr "" - -msgid "Found key D (site for derrick)" -msgstr "" - -msgid "Titanium deposit (site for derrick)" -msgstr "" - -msgid "Practice bot" -msgstr "" - -msgid "Winged grabber" -msgstr "" - -msgid "Tracked grabber" -msgstr "" - -msgid "Wheeled grabber" -msgstr "" - -msgid "Legged grabber" -msgstr "" - -msgid "Winged shooter" -msgstr "" - -msgid "Tracked shooter" -msgstr "" - -msgid "Wheeled shooter" -msgstr "" - -msgid "Legged shooter" -msgstr "" - -msgid "Winged orga shooter" -msgstr "" - -msgid "Tracked orga shooter" -msgstr "" - -msgid "Wheeled orga shooter" -msgstr "" - -msgid "Legged orga shooter" -msgstr "" - -msgid "Winged sniffer" -msgstr "" - -msgid "Tracked sniffer" -msgstr "" - -msgid "Wheeled sniffer" -msgstr "" - -msgid "Legged sniffer" -msgstr "" - -msgid "Thumper" -msgstr "" - -msgid "Phazer shooter" -msgstr "" - -msgid "Recycler" -msgstr "" - -msgid "Shielder" -msgstr "" - -msgid "Subber" -msgstr "" - -msgid "Target bot" -msgstr "" - -msgid "Drawer bot" -msgstr "" - -msgid "Engineer" -msgstr "" - -msgid "Robbie" -msgstr "" - -msgid "Alien Queen" -msgstr "" - -msgid "Ant" -msgstr "" - -msgid "Spider" -msgstr "" - -msgid "Wasp" -msgstr "" - -msgid "Worm" -msgstr "" - -msgid "Egg" -msgstr "" - -msgid "Wreckage" -msgstr "" - -msgid "Ruin" -msgstr "" - -msgid "Waste" -msgstr "" - -msgid "Spaceship ruin" -msgstr "" - -msgid "Remains of Apollo mission" -msgstr "" - -msgid "Lunar Roving Vehicle" -msgstr "" - -msgid "Unknown command" -msgstr "" - -msgid "Inappropriate bot" -msgstr "" - -msgid "Impossible when flying" -msgstr "" - -msgid "Already carrying something" -msgstr "" - -msgid "Nothing to grab" -msgstr "" - -msgid "Impossible when moving" -msgstr "" - -msgid "Place occupied" -msgstr "" - -msgid "No other robot" -msgstr "" - -msgid "You can not carry a radioactive object" -msgstr "" - -msgid "You can not carry an object under water" -msgstr "" - -msgid "Nothing to drop" -msgstr "" - -msgid "Impossible under water" -msgstr "" - -msgid "Not enough energy" -msgstr "" - -msgid "Titanium too far away" -msgstr "" - -msgid "Titanium too close" -msgstr "" - -msgid "No titanium around" -msgstr "" - -msgid "Ground not flat enough" -msgstr "" - -msgid "Flat ground not large enough" -msgstr "" - -msgid "Too close to space ship" -msgstr "" - -msgid "Too close to a building" -msgstr "" - -msgid "Ground inappropriate" -msgstr "" - -msgid "Building too close" -msgstr "" - -msgid "Object too close" -msgstr "" - -msgid "Nothing to recycle" -msgstr "" - -msgid "No more energy" -msgstr "" - -msgid "Error in instruction move" -msgstr "" - -msgid "Object not found" -msgstr "" - -msgid "Goto: inaccessible destination" -msgstr "" - -msgid "Goto: destination occupied" -msgstr "" - -msgid "No titanium ore to convert" -msgstr "" - -msgid "No ore in the subsoil" -msgstr "" - -msgid "No energy in the subsoil" -msgstr "" - -msgid "No power cell" -msgstr "" - -msgid "Inappropriate cell type" -msgstr "" - -msgid "Research program already performed" -msgstr "" - -msgid "Not enough energy yet" -msgstr "" - -msgid "No titanium to transform" -msgstr "" - -msgid "Transforms only titanium" -msgstr "" - -msgid "Doors blocked by a robot or another object " -msgstr "" - -msgid "You must get on the spaceship to take off " -msgstr "" - -msgid "Nothing to analyze" -msgstr "" - -msgid "Analyzes only organic matter" -msgstr "" - -msgid "Analysis already performed" -msgstr "" - -msgid "Not yet enough energy" -msgstr "" - -msgid "No uranium to transform" -msgstr "" - -msgid "Transforms only uranium" -msgstr "" - -msgid "No titanium" -msgstr "" - -msgid "No information exchange post within range" -msgstr "" - -msgid "Program infected by a virus" -msgstr "" - -msgid "Infected by a virus; temporarily out of order" -msgstr "" - -msgid "Impossible when swimming" -msgstr "" - -msgid "Impossible when carrying an object" -msgstr "" - -msgid "Too many flags of this color (maximum 5)" -msgstr "" - -msgid "Too close to an existing flag" -msgstr "" - -msgid "No flag nearby" -msgstr "" - -msgid "" -"The mission is not accomplished yet (press \\key help; for more details)" -msgstr "" - -msgid "Bot destroyed" -msgstr "" - -msgid "Building destroyed" -msgstr "" - -msgid "Can not create this; there are too many objects" -msgstr "" - -#, c-format -msgid "\"%s\" missing in this exercise" -msgstr "" - -msgid "Do not use in this exercise" -msgstr "" - -msgid "Building completed" -msgstr "" - -msgid "Titanium available" -msgstr "" - -msgid "Research program completed" -msgstr "" - -msgid "Plans for tracked robots available " -msgstr "" - -msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)" -msgstr "" - -msgid "Plans for thumper available" -msgstr "" - -msgid "Plans for shooter available" -msgstr "" - -msgid "Plans for defense tower available" -msgstr "" - -msgid "Plans for phazer shooter available" -msgstr "" - -msgid "Plans for shielder available" -msgstr "" - -msgid "Plans for nuclear power plant available" -msgstr "" - -msgid "New bot available" -msgstr "" - -msgid "Analysis performed" -msgstr "" - -msgid "Power cell available" -msgstr "" - -msgid "Nuclear power cell available" -msgstr "" - -msgid "You found a usable object" -msgstr "" - -msgid "Found a site for power station" -msgstr "" - -msgid "Found a site for a derrick" -msgstr "" - -msgid "<<< Well done; mission accomplished >>>" -msgstr "" - -msgid "<<< Sorry; mission failed >>>" -msgstr "" - -msgid "Current mission saved" -msgstr "" - -msgid "Checkpoint crossed" -msgstr "" - -msgid "Alien Queen killed" -msgstr "" - -msgid "Ant fatally wounded" -msgstr "" - -msgid "Wasp fatally wounded" -msgstr "" - -msgid "Worm fatally wounded" -msgstr "" - -msgid "Spider fatally wounded" -msgstr "" - -msgid "Press \\key help; to read instructions on your SatCom" -msgstr "" - -msgid "Opening bracket missing" -msgstr "" - -msgid "Closing bracket missing " -msgstr "" - -msgid "The expression must return a boolean value" -msgstr "" - -msgid "Variable not declared" -msgstr "" - -msgid "Assignment impossible" -msgstr "" - -msgid "Semicolon terminator missing" -msgstr "" - -msgid "Instruction \"case\" outside a block \"switch\"" -msgstr "" - -msgid "Instructions after the final closing brace" -msgstr "" - -msgid "End of block missing" -msgstr "" - -msgid "Instruction \"else\" without corresponding \"if\" " -msgstr "" - -msgid "Opening brace missing " -msgstr "" - -msgid "Wrong type for the assignment" -msgstr "" - -msgid "A variable can not be declared twice" -msgstr "" - -msgid "The types of the two operands are incompatible " -msgstr "" - -msgid "Unknown function" -msgstr "" - -msgid "Sign \" : \" missing" -msgstr "" - -msgid "Keyword \"while\" missing" -msgstr "" - -msgid "Instruction \"break\" outside a loop" -msgstr "" - -msgid "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\"" -msgstr "" - -msgid "This label does not exist" -msgstr "" - -msgid "Instruction \"case\" missing" -msgstr "" - -msgid "Number missing" -msgstr "" - -msgid "Void parameter" -msgstr "" - -msgid "Type declaration missing" -msgstr "" - -msgid "Variable name missing" -msgstr "" - -msgid "Function name missing" -msgstr "" - -msgid "Too many parameters" -msgstr "" - -msgid "Function already exists" -msgstr "" - -msgid "Parameters missing " -msgstr "" - -msgid "No function with this name accepts this kind of parameter" -msgstr "" - -msgid "No function with this name accepts this number of parameters" -msgstr "" - -msgid "This is not a member of this class" -msgstr "" - -msgid "This object is not a member of a class" -msgstr "" - -msgid "Appropriate constructor missing" -msgstr "" - -msgid "This class already exists" -msgstr "" - -msgid "\" ] \" missing" -msgstr "" - -msgid "Reserved keyword of CBOT language" -msgstr "" - -msgid "Bad argument for \"new\"" -msgstr "" - -msgid "\" [ \" expected" -msgstr "" - -msgid "String missing" -msgstr "" - -msgid "Incorrect index type" -msgstr "" - -msgid "Private element" -msgstr "" - -msgid "Public required" -msgstr "" - -msgid "Dividing by zero" -msgstr "" - -msgid "Variable not initialized" -msgstr "" - -msgid "Negative value rejected by \"throw\"" -msgstr "" - -msgid "The function returned no value " -msgstr "" - -msgid "No function running" -msgstr "" - -msgid "Calling an unknown function" -msgstr "" - -msgid "This class does not exist" -msgstr "" - -msgid "Unknown Object" -msgstr "" - -msgid "Operation impossible with value \"nan\"" -msgstr "" - -msgid "Access beyond array limit" -msgstr "" - -msgid "Stack overflow" -msgstr "" - -msgid "Illegal object" -msgstr "" - -msgid "Can't open file" -msgstr "" - -msgid "File not open" -msgstr "" - -msgid "Read error" -msgstr "" - -msgid "Write error" -msgstr "" - -msgid "left;" -msgstr "" - -msgid "right;" -msgstr "" - -msgid "up;" -msgstr "" - -msgid "down;" -msgstr "" - -msgid "gup;" -msgstr "" - -msgid "gdown;" -msgstr "" - -msgid "camera;" -msgstr "" - -msgid "desel;" -msgstr "" - -msgid "action;" -msgstr "" - -msgid "near;" -msgstr "" - -msgid "away;" -msgstr "" - -msgid "next;" -msgstr "" - -msgid "human;" -msgstr "" - -msgid "quit;" -msgstr "" - -msgid "help;" -msgstr "" - -msgid "prog;" -msgstr "" - -msgid "cbot;" -msgstr "" - -msgid "visit;" -msgstr "" - -msgid "speed10;" -msgstr "" - -msgid "speed15;" -msgstr "" - -msgid "speed20;" -msgstr "" - -#, c-format -msgid "GetResource event num out of range: %d\n" -msgstr "" - -msgid "Ctrl" -msgstr "" - -msgid "Shift" -msgstr "" - -msgid "Alt" -msgstr "" - -msgid "Win" -msgstr "" - -msgid "Button %1" -msgstr "" - -msgid "%1" -msgstr "" - diff --git a/src/po/de.po b/src/po/de.po deleted file mode 100644 index d0943ab..0000000 --- a/src/po/de.po +++ /dev/null @@ -1,2056 +0,0 @@ -msgid "" -msgstr "" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 17:09+0100\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Language: de_DE\n" -"X-Source-Language: en_US\n" - -msgid " " -msgstr " " - -msgid " Challenges in the chapter:" -msgstr " Liste der Challenges des Kapitels:" - -msgid " Chapters:" -msgstr " Liste der Kapitel:" - -msgid " Drivers:" -msgstr " Driver:" - -msgid " Exercises in the chapter:" -msgstr " Liste der Übungen des Kapitels:" - -msgid " Free game on this chapter:" -msgstr " Liste der freien Levels des Kapitel:" - -msgid " Free game on this planet:" -msgstr " Liste der freien Levels des Planeten:" - -msgid " Missions on this level:" -msgstr " Missionen des Userlevels:" - -msgid " Missions on this planet:" -msgstr " Liste der Missionen des Planeten:" - -msgid " Planets:" -msgstr " Liste der Planeten:" - -msgid " Prototypes on this planet:" -msgstr " Liste der Prototypen des Planeten:" - -msgid " Resolution:" -msgstr " Auflösung:" - -msgid " Summary:" -msgstr " Zusammenfassung:" - -msgid " User levels:" -msgstr " Userlevels:" - -msgid " or " -msgstr " oder " - -msgid "\" [ \" expected" -msgstr "Es fehlt eine offene eckige Klammer \" [ \"" - -msgid "\" ] \" missing" -msgstr "Es fehlt eine geschlossene eckige Klammer \" ] \"" - -#, c-format -msgid "\"%s\" missing in this exercise" -msgstr "Es fehlt \"%s\" in Ihrem Programm" - -msgid "%1" -msgstr "" - -msgid "..behind" -msgstr "..hinten" - -msgid "..in front" -msgstr "..vorne" - -msgid "..power cell" -msgstr "..Batterie" - -msgid "1) First click on the key you want to redefine." -msgstr "1) Klicken Sie auf die neu zu definierende Taste." - -msgid "2) Then press the key you want to use instead." -msgstr "2) Drücken Sie auf die neue Taste." - -msgid "3D sound\\3D positioning of the sound" -msgstr "3D-Geräusche\\Orten der Geräusche im Raum" - -msgid "<< Back \\Back to the previous screen" -msgstr "<< Zurück \\Zurück zum Hauptmenü" - -#, fuzzy -msgid "<<< Sorry; mission failed >>>" -msgstr "<<< Mission gescheitert >>>" - -#, fuzzy -msgid "<<< Well done; mission accomplished >>>" -msgstr "<<< Bravo, Mission vollendet >>>" - -#, fuzzy -msgid "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\"" -msgstr "" -"Ein Label kann nur vor den Anweisungen \"for\", \"while\", \"do\" oder " -"\"switch\" vorkommen" - -msgid "A variable can not be declared twice" -msgstr "Eine Variable wird zum zweiten Mal deklariert" - -msgid "Abort\\Abort the current mission" -msgstr "Abbrechen\\Mission abbrechen" - -msgid "Access beyond array limit" -msgstr "Zugriff im Array außerhalb der Grenzen" - -msgid "" -"Access to solution\\Shows the solution (detailed instructions for missions)" -msgstr "Zeigt die Lösung\\Zeigt nach 3mal Scheitern die Lösung" - -msgid "Access to solutions\\Show program \"4: Solution\" in the exercises" -msgstr "" -"Lösung zugänglich\\Die Lösung ist im Programmslot \"4: Lösung\" zugänglich" - -msgid "Alien Queen" -msgstr "Insektenkönigin" - -msgid "Alien Queen killed" -msgstr "Insektenkönigin tödlich verwundet" - -msgid "Already carrying something" -msgstr "Trägt schon etwas" - -msgid "Alt" -msgstr "Alt" - -msgid "Analysis already performed" -msgstr "Analyse schon durchgeführt" - -msgid "Analysis performed" -msgstr "Analyse vollendet" - -msgid "Analyzes only organic matter" -msgstr "Analysiert nur Orgastoff" - -msgid "Ant" -msgstr "Ameise" - -msgid "Ant fatally wounded" -msgstr "Ameise tödlich verwundet" - -msgid "Appearance\\Choose your appearance" -msgstr "Aussehen\\Erscheinungsbild des Astronauten einstellen" - -msgid "Apply changes\\Activates the changed settings" -msgstr "Änderungen ausführen\\Getätigte Einstellungen ausführen" - -msgid "Appropriate constructor missing" -msgstr "Es gibt keinen geeigneten Konstruktor" - -msgid "Assignment impossible" -msgstr "Zuweisung unmöglich" - -msgid "Autolab" -msgstr "Automatisches Labor" - -msgid "Automatic indent\\When program editing" -msgstr "Automatisches Einrücken\\Beim Bearbeiten der Programme" - -msgid "Back" -msgstr "Vorherg. Seite" - -msgid "Background sound :\\Volume of audio tracks on the CD" -msgstr "Geräuschkulisse:\\Lautstärke der Soundtracks der CD" - -msgid "Backward (\\key down;)" -msgstr "Rückwärts (\\key down;)" - -msgid "Backward\\Moves backward" -msgstr "Rückwärts\\Bewegung nach hinten" - -msgid "Bad argument for \"new\"" -msgstr "Falsche Argumente für \"new\"" - -msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces" -msgstr "Einrücken mit 4 Leerstellen\\Einrücken mit 2 oder 4 Leerstellen" - -msgid "Black box" -msgstr "Flugschreiber" - -msgid "Blue" -msgstr "Blau" - -msgid "Blue flag" -msgstr "Blaue Fahne" - -msgid "Bot destroyed" -msgstr "Roboter zerstört" - -msgid "Bot factory" -msgstr "Roboterfabrik" - -msgid "Build a bot factory" -msgstr "Baut eine Roboterfabrik" - -msgid "Build a converter" -msgstr "Baut einen Konverter" - -msgid "Build a defense tower" -msgstr "Baut einen Geschützturm" - -msgid "Build a derrick" -msgstr "Baut einen Bohrturm" - -msgid "Build a exchange post" -msgstr "Baut einen Infoserver" - -msgid "Build a legged grabber" -msgstr "Baut einen Krabbeltransporter" - -msgid "Build a legged orga shooter" -msgstr "Baut einen Krabbelorgashooter" - -msgid "Build a legged shooter" -msgstr "Baut einen Krabbelshooter" - -msgid "Build a legged sniffer" -msgstr "Baut einen Krabbelschnüffler" - -msgid "Build a lightning conductor" -msgstr "Baut einen Blitzableiter" - -msgid "Build a nuclear power plant" -msgstr "Baut eine Brennstoffzellenfabrik" - -msgid "Build a phazer shooter" -msgstr "Baut einen Phazershooter" - -msgid "Build a power cell factory" -msgstr "Baut eine Batteriefabrik" - -msgid "Build a power station" -msgstr "Baut ein Kraftwerk" - -msgid "Build a radar station" -msgstr "Baut ein Radar" - -msgid "Build a recycler" -msgstr "Baut einen Recycler" - -msgid "Build a repair center" -msgstr "Baut ein Reparaturzentrum" - -msgid "Build a research center" -msgstr "Baut ein Forschungszentrum" - -msgid "Build a shielder" -msgstr "Baut einen Schutzschild" - -msgid "Build a subber" -msgstr "Baut einen Kettentaucher" - -msgid "Build a thumper" -msgstr "Baut einen Stampfer" - -msgid "Build a tracked grabber" -msgstr "Baut einen Kettentransporter" - -msgid "Build a tracked orga shooter" -msgstr "Baut einen Kettenorgashooter" - -msgid "Build a tracked shooter" -msgstr "Baut einen Kettenshooter" - -msgid "Build a tracked sniffer" -msgstr "Baut einen Kettenschnüffler" - -msgid "Build a wheeled grabber" -msgstr "Baut einen Radtransporter" - -msgid "Build a wheeled orga shooter" -msgstr "Baut einen Radorgashooter" - -msgid "Build a wheeled shooter" -msgstr "Baut einen Radshooter" - -msgid "Build a wheeled sniffer" -msgstr "Baut einen Radschnüffler" - -msgid "Build a winged grabber" -msgstr "Baut einen Jettransporter" - -msgid "Build a winged orga shooter" -msgstr "Baut einen Jetorgashooter" - -msgid "Build a winged shooter" -msgstr "Baut einen Jetshooter" - -msgid "Build a winged sniffer" -msgstr "Baut einen Jetschnüffler" - -msgid "Build an autolab" -msgstr "Baut ein automatisches Labor" - -msgid "Building completed" -msgstr "Gebäude fertiggestellt" - -msgid "Building destroyed" -msgstr "Gebäude zerstört" - -msgid "Building too close" -msgstr "Gebäude zu nahe" - -msgid "Button %1" -msgstr "Knopf %1" - -msgid "COLOBOT" -msgstr "COLOBOT" - -msgid "Calling an unknown function" -msgstr "Die aufgerufene Funktion existiert nicht" - -msgid "Camera (\\key camera;)" -msgstr "Kamera (\\key camera;)" - -msgid "Camera awayest" -msgstr "Kamera weiter weg" - -msgid "Camera back\\Moves the camera backward" -msgstr "Kamera weiter\\Bewegung der Kamera rückwärts" - -msgid "Camera closer\\Moves the camera forward" -msgstr "Kamera näher\\Bewegung der Kamera vorwärts" - -msgid "Camera nearest" -msgstr "Kamera näher" - -msgid "Camera to left" -msgstr "Kamera links" - -msgid "Camera to right" -msgstr "Kamera rechts" - -#, fuzzy -msgid "Can not create this; there are too many objects" -msgstr "Kein neues Objekt kann erstellt werden (zu viele vorhanden)" - -msgid "Can't open file" -msgstr "Die Datei kann nicht geöffnet werden" - -msgid "Cancel" -msgstr "Abbrechen" - -msgid "Cancel\\Cancel all changes" -msgstr "Abbrechen\\Editor schließen" - -msgid "Cancel\\Keep current player name" -msgstr "Abbrechen\\Behält den bisherigen Spieler bei" - -msgid "Challenges" -msgstr "Challenges" - -msgid "Challenges\\Programming challenges" -msgstr "Challenges\\Herausforderungen" - -msgid "Change camera\\Switches between onboard camera and following camera" -msgstr "Andere Kamera\\Sichtpunkt einstellen" - -msgid "Checkpoint" -msgstr "Checkpoint" - -msgid "Checkpoint crossed" -msgstr "Checkpoint erreicht" - -msgid "Climb\\Increases the power of the jet" -msgstr "Steigen\\Leistung des Triebwerks steigern" - -msgid "Close" -msgstr "Schließen" - -msgid "Closing bracket missing " -msgstr "Es fehlt eine geschlossene Klammer \")\"" - -msgid "Colobot rules!" -msgstr "Colobot ist wunderbar!" - -msgid "Command line" -msgstr "Befehleingabe" - -msgid "Compass" -msgstr "Kompass" - -msgid "Compilation ok (0 errors)" -msgstr "Kompilieren OK (0 Fehler)" - -msgid "Compile" -msgstr "Kompilieren" - -msgid "Continue" -msgstr "Weitermachen" - -msgid "Continue\\Continue the current mission" -msgstr "Weitermachen\\Mission weitermachen" - -msgid "Continue\\Continue the game" -msgstr "Weitermachen\\Weitermachen" - -msgid "Controls\\Keyboard, joystick and mouse settings" -msgstr "Steuerung\\Auswahl der Tasten" - -msgid "Converts ore to titanium" -msgstr "Konverter Erz-Titan" - -msgid "Copy" -msgstr "Kopieren" - -msgid "Copy (Ctrl+c)" -msgstr "Kopieren (Ctrl+c)" - -msgid "Ctrl" -msgstr "Ctrl" - -msgid "Current mission saved" -msgstr "Mission gespeichert" - -msgid "Customize your appearance" -msgstr "Aussehen einstellen" - -msgid "Cut (Ctrl+x)" -msgstr "Ausschneiden (Ctrl+x)" - -msgid "Defense tower" -msgstr "Geschützturm" - -msgid "Delete" -msgstr "Zerstören" - -msgid "Delete player\\Deletes the player from the list" -msgstr "Spieler löschen\\Löscht den Spieler aus der Liste" - -msgid "Delete\\Deletes the selected file" -msgstr "Löschen\\Löscht die gespeicherte Mission" - -msgid "Depth of field\\Maximum visibility" -msgstr "Sichtweite\\Maximale Sichtweite" - -msgid "Derrick" -msgstr "Bohrturm" - -msgid "Descend\\Reduces the power of the jet" -msgstr "Sinken\\Leistung des Triebwerks drosseln" - -msgid "Destroy the building" -msgstr "Gebäude sprengen" - -msgid "Destroyer" -msgstr "Einstampfer" - -msgid "Details\\Visual quality of 3D objects" -msgstr "Details\\Detailliertheit der Objekte in 3D" - -msgid "Developed by :" -msgstr "Entwickelt von:" - -msgid "Device\\Driver and resolution settings" -msgstr "Bildschirm\\Driver und Bildschirmauflösung" - -msgid "Dividing by zero" -msgstr "Teilung durch Null" - -msgid "Do not use in this exercise" -msgstr "In dieser Übung verboten" - -msgid "Do you really want to destroy the selected building?" -msgstr "Wollen Sie das angewählte Gebäude wirklich zerstören ?" - -#, c-format -msgid "Do you want to delete %s's saved games? " -msgstr "Wollen Sie die gespeicherten Missionen von %s löschen ?" - -msgid "Do you want to quit COLOBOT ?" -msgstr "Wollen Sie COLOBOT schließen ?" - -msgid "Doors blocked by a robot or another object " -msgstr "Die Türen werden von einem Gegenstand blockiert" - -msgid "Down (\\key gdown;)" -msgstr "Sinkt (\\key gdown;)" - -msgid "Drawer bot" -msgstr "Zeichner" - -msgid "Dust\\Dust and dirt on bots and buildings" -msgstr "Schmutz\\Schmutz auf Robotern und Bauten" - -msgid "Dynamic lighting\\Mobile light sources" -msgstr "Dynamische Beleuchtung\\Dynamische Beleuchtung" - -msgid "Edit the selected program" -msgstr "Gewähltes Programm bearbeiten" - -msgid "Egg" -msgstr "Ei" - -msgid "End of block missing" -msgstr "Es fehlt eine geschlossene geschweifte Klammer \"}\" (Ende des Blocks)" - -msgid "Energy deposit (site for power station)" -msgstr "Markierung für unterirdische Energiequelle" - -msgid "Energy level" -msgstr "Energievorrat" - -msgid "Engineer" -msgstr "Techniker" - -msgid "Error in instruction move" -msgstr "Ziel kann nicht erreicht werden" - -msgid "Execute the selected program" -msgstr "Gewähltes Programm ausführen" - -msgid "Execute/stop" -msgstr "Start/Stop" - -msgid "Exercises\\Programming exercises" -msgstr "Programmieren\\Programmierübungen" - -msgid "Exit film\\Film at the exit of exercises" -msgstr "Zurücksetzen \\Kleine Show beim Zurücksetzen in den Übungen" - -msgid "Explosive" -msgstr "Sprengstoff" - -msgid "Extend shield (\\key action;)" -msgstr "Schutzschild ausfahren (\\key action;)" - -msgid "Eyeglasses:" -msgstr "Brille:" - -msgid "Face type:" -msgstr "Kopf:" - -msgid "File not open" -msgstr "Die Datei wurde nicht geöffnet" - -msgid "Filename:" -msgstr "Dateiname:" - -msgid "Film sequences\\Films before and after the missions" -msgstr "Filme\\Filme vor und nach den Missionen" - -msgid "Finish" -msgstr "Zielfläche" - -msgid "Fixed mine" -msgstr "Landmine" - -msgid "Flat ground not large enough" -msgstr "Ebener Boden nicht groß genug" - -msgid "Fog\\Fog" -msgstr "Nebel\\Nebelschwaden" - -msgid "Folder:" -msgstr "In:" - -#, c-format -msgid "Folder: %s" -msgstr "Ordner: %s" - -msgid "Font size" -msgstr "Zeichengröße" - -msgid "Forward" -msgstr "Nächste Seite" - -msgid "Forward (\\key up;)" -msgstr "Vorwärts (\\key up;)" - -msgid "Forward\\Moves forward" -msgstr "Vorwärts\\Bewegung nach vorne" - -msgid "Found a site for a derrick" -msgstr "Geeignete Stelle für Bohrturm gefunden" - -msgid "Found a site for power station" -msgstr "Geeignete Stelle für Kraftwerk gefunden" - -msgid "Found key A (site for derrick)" -msgstr "Markierung für vergrabenen Schlüssel A" - -msgid "Found key B (site for derrick)" -msgstr "Markierung für vergrabenen Schlüssel B" - -msgid "Found key C (site for derrick)" -msgstr "Markierung für vergrabenen Schlüssel C" - -msgid "Found key D (site for derrick)" -msgstr "Markierung für vergrabenen Schlüssel D" - -msgid "Free game" -msgstr "Freestyle" - -msgid "Free game\\Free game without a specific goal" -msgstr "Freestyle\\Freies Spielen ohne vorgegebenes Ziel" - -msgid "Friendly fire\\Your shooting can damage your own objects " -msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt" - -msgid "Full screen\\Full screen or window mode" -msgstr "Vollbildschirm\\Vollbildschirm oder Fenster" - -msgid "Function already exists" -msgstr "Diese Funktion gibt es schon" - -msgid "Function name missing" -msgstr "Hier muss der Name der Funktion stehen" - -msgid "Game speed" -msgstr "Spielgeschwindigkeit" - -msgid "Game\\Game settings" -msgstr "Spiel\\Gameplay Einstellungen" - -msgid "Gantry crane" -msgstr "Träger" - -#, c-format -msgid "GetResource event num out of range: %d\n" -msgstr "" - -msgid "Goto: destination occupied" -msgstr "Ziel ist schon besetzt" - -msgid "Goto: inaccessible destination" -msgstr "Ziel kann nicht erreicht werden" - -msgid "Grab or drop (\\key action;)" -msgstr "Nehmen oder hinlegen (\\key action;)" - -msgid "Graphics\\Graphics settings" -msgstr "Grafik\\Grafische Einstellungen" - -msgid "Green" -msgstr "Grün" - -msgid "Green flag" -msgstr "Grüne Fahne" - -msgid "Ground inappropriate" -msgstr "Boden ungeeignet" - -msgid "Ground not flat enough" -msgstr "Boden nicht eben genug" - -msgid "Hair color:" -msgstr "Haarfarbe:" - -msgid "Head\\Face and hair" -msgstr "Kopf\\Gesicht und Haare" - -msgid "Help about selected object" -msgstr "Anweisungen über das ausgewählte Objekt" - -msgid "Help balloons\\Explain the function of the buttons" -msgstr "Hilfsblasen\\Hilfsblasen" - -msgid "Highest\\Highest graphic quality (lowest frame rate)" -msgstr "Max.\\Beste Qualität (niedriges Framerate)" - -msgid "Home" -msgstr "Home" - -msgid "Houston Mission Control" -msgstr "Kontrollzentrum" - -msgid "Illegal object" -msgstr "Objekt nicht verfügbar" - -msgid "Impossible under water" -msgstr "Unter Wasser unmöglich" - -msgid "Impossible when carrying an object" -msgstr "Unmöglich wenn Sie etwas tragen" - -msgid "Impossible when flying" -msgstr "Im Flug unmöglich" - -msgid "Impossible when moving" -msgstr "In Fahrt unmöglich" - -msgid "Impossible when swimming" -msgstr "Im Wasser unmöglich" - -msgid "Inappropriate bot" -msgstr "Roboter ungeeignet" - -msgid "Inappropriate cell type" -msgstr "Falscher Batterietyp" - -msgid "Incorrect index type" -msgstr "Falscher Typ für einen Index" - -#, fuzzy -msgid "Infected by a virus; temporarily out of order" -msgstr "Von Virus infiziert, zeitweise außer Betrieb" - -msgid "Information exchange post" -msgstr "Infoserver" - -msgid "Instruction \"break\" outside a loop" -msgstr "Anweisung \"break\" außerhalb einer Schleife" - -msgid "Instruction \"case\" missing" -msgstr "Es fehlt eine Anweisung \"case\"" - -msgid "Instruction \"case\" outside a block \"switch\"" -msgstr "Anweisung \"case\" ohne vorhergehende Anweisung \"switch\"" - -msgid "Instruction \"else\" without corresponding \"if\" " -msgstr "Anweisung \"else\" ohne vorhergehende Anweisung \"if\"" - -msgid "Instructions (\\key help;)" -msgstr "Anweisungen (\\key help;)" - -msgid "Instructions after the final closing brace" -msgstr "Hier ist eine Anweisung nach dem Ende des Programms" - -msgid "Instructions for the mission (\\key help;)" -msgstr "Anweisungen über die Mission(\\key help;)" - -msgid "Instructions from Houston" -msgstr "Anweisungen von Houston" - -msgid "Instructions\\Shows the instructions for the current mission" -msgstr "Anweisungen\\Anweisungen für die Mission oder Übung" - -msgid "Jet temperature" -msgstr "Triebwerktemperatur" - -msgid "Key A" -msgstr "Schlüssel A" - -msgid "Key B" -msgstr "Schlüssel B" - -msgid "Key C" -msgstr "Schlüssel C" - -msgid "Key D" -msgstr "Schlüssel D" - -msgid "Key word help\\More detailed help about key words" -msgstr "Hilfe über Begriff\\Hilfe über einen Begriff" - -msgid "Keyword \"while\" missing" -msgstr "Es fehlt das Wort \"while\"" - -msgid "Keyword help(\\key cbot;)" -msgstr "Hilfe über den Begriff (\\key cbot;)" - -msgid "LOADING" -msgstr "Laden" - -msgid "Legged grabber" -msgstr "Transporter" - -msgid "Legged orga shooter" -msgstr "OrgaShooter" - -msgid "Legged shooter" -msgstr "Shooter" - -msgid "Legged sniffer" -msgstr "Schnüffler" - -msgid "Lightning conductor" -msgstr "Blitzableiter" - -msgid "List of objects" -msgstr "Liste der Objekte" - -msgid "List of saved missions" -msgstr "Liste der gespeicherten Missionen" - -msgid "Load a saved mission" -msgstr "Gespeicherte Mission laden" - -msgid "Load\\Load a saved mission" -msgstr "Laden\\Eine gespeicherte Mission öffnen" - -msgid "Load\\Loads the selected mission" -msgstr "Laden\\Öffnet eine gespeicherte Mission" - -msgid "Lowest\\Minimum graphic quality (highest frame rate)" -msgstr "Min.\\Minimale Qualität (großes Framerate)" - -msgid "Lunar Roving Vehicle" -msgstr "Lunar Roving Vehicle" - -msgid "Marks on the ground\\Marks on the ground" -msgstr "Markierungen\\Markierungen auf dem Boden" - -msgid "Maximize" -msgstr "Großes Fenster" - -msgid "Menu (\\key quit;)" -msgstr "Menü (\\key quit;)" - -msgid "Minimize" -msgstr "Reduzieren" - -msgid "Mission name" -msgstr "Name der Mission" - -msgid "Missions" -msgstr "Missionen" - -msgid "Missions\\Select mission" -msgstr "Missionen\\Aufbruch ins Weltall" - -msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" -msgstr "Umkehr X\\Umkehr der Kameradrehung X-Achse" - -msgid "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis" -msgstr "Umkehr Y\\Umkehr der Kameradrehung Y-Achse" - -msgid "Mouse shadow\\Gives the mouse a shadow" -msgstr "Schatten unter der Maus\\Ein Schatten erscheint unter der Maus" - -msgid "Mute\\No sound" -msgstr "Kein Ton\\Keine Geräusche und Geräuschkulisse" - -msgid "Name:" -msgstr "Name:" - -msgid "Negative value rejected by \"throw\"" -msgstr "Negativer Wert ungeeignet für Anweisung \"throw\"" - -msgid "Nest" -msgstr "Orgastoffquelle" - -msgid "New" -msgstr "Neu" - -msgid "New ..." -msgstr "Neu ..." - -msgid "New bot available" -msgstr "Neuer Roboter verfügbar" - -msgid "New player\\Choose player's name" -msgstr "Anderer Spieler\\Spielername ändern" - -msgid "Next" -msgstr "Nächster" - -msgid "Next object\\Selects the next object" -msgstr "Nächstes auswählen\\Nächstes Objekt auswählen" - -msgid "No energy in the subsoil" -msgstr "Kein unterirdisches Energievorkommen" - -msgid "No flag nearby" -msgstr "Keine Fahne in Reichweite" - -msgid "No function running" -msgstr "Keine Funktion wird ausgeführt" - -msgid "No function with this name accepts this kind of parameter" -msgstr "Keine Funktion mit diesem Namen verträgt Parameter diesen Typs" - -msgid "No function with this name accepts this number of parameters" -msgstr "Keine Funktion mit diesem Namen verträgt diese Anzahl Parameter" - -msgid "No information exchange post within range" -msgstr "Kein Infoserver in Reichweite" - -msgid "No more energy" -msgstr "Keine Energie mehr" - -msgid "No ore in the subsoil" -msgstr "Keine unterirdische Erzlagerstätte" - -msgid "No other robot" -msgstr "Kein anderer Roboter" - -msgid "No power cell" -msgstr "Keine Batterie" - -msgid "No titanium" -msgstr "Kein Titan vorhanden" - -msgid "No titanium around" -msgstr "Kein Titan vorhanden" - -msgid "No titanium ore to convert" -msgstr "Kein konvertierbares Titanerz vorhanden" - -msgid "No titanium to transform" -msgstr "Kein konvertierbares Titanerz vorhanden" - -msgid "No uranium to transform" -msgstr "Kein konvertierbares Platin" - -msgid "Normal size" -msgstr "Normale Größe" - -msgid "Normal\\Normal graphic quality" -msgstr "Normal\\Standardqualität" - -msgid "Normal\\Normal sound volume" -msgstr "Normal\\Normale Lautstärke" - -msgid "Not enough energy" -msgstr "Nicht genug Energie" - -msgid "Not enough energy yet" -msgstr "Noch nicht genug Energie" - -msgid "Not yet enough energy" -msgstr "Noch nicht genug Energie" - -msgid "Nothing to analyze" -msgstr "Nichts zu analysieren" - -msgid "Nothing to drop" -msgstr "Nichts abzulegen" - -msgid "Nothing to grab" -msgstr "Nichts zu ergreifen" - -msgid "Nothing to recycle" -msgstr "Nichts zu recyceln" - -msgid "Nuclear power cell" -msgstr "Brennstoffzelle" - -msgid "Nuclear power cell available" -msgstr "Brennstoffzelle verfügbar" - -msgid "Nuclear power station" -msgstr "Brennstoffzellenfabrik" - -msgid "Num of decorative objects\\Number of purely ornamental objects" -msgstr "Anzahl Ziergegenstände\\Anzahl Gegenstände ohne Funktion" - -msgid "Number missing" -msgstr "Es fehlt eine Zahl" - -msgid "Number of insects detected" -msgstr "Anzahl erfasster Insekten" - -msgid "Number of particles\\Explosions, dust, reflections, etc." -msgstr "Anzahl Partikel\\Explosionen, Staub, usw." - -msgid "OK" -msgstr "OK" - -msgid "OK\\Choose the selected player" -msgstr "OK\\Spieler auswählen" - -msgid "OK\\Close program editor and return to game" -msgstr "OK\\Programm kompilieren" - -msgid "Object not found" -msgstr "Das Objekt existiert nicht" - -msgid "Object too close" -msgstr "Gegenstand zu nahe" - -msgid "One step" -msgstr "Ein Schritt" - -msgid "Open" -msgstr "Öffnen" - -msgid "Open (Ctrl+o)" -msgstr "Öffnen (Ctrl+o)" - -msgid "Opening brace missing " -msgstr "Es fehlt eine offene geschweifte Klammer\"{\"" - -msgid "Opening bracket missing" -msgstr "Es fehlt eine offene Klammer \"(\"" - -msgid "Operation impossible with value \"nan\"" -msgstr "Operation mit dem Wert \"nan\"" - -msgid "Options" -msgstr "Einstellungen" - -msgid "Options\\Preferences" -msgstr "Einstellungen\\Einstellungen" - -msgid "Organic matter" -msgstr "Orgastoff" - -msgid "Origin of last message\\Shows where the last message was sent from" -msgstr "Ort der Meldung\\Zeigt den Ort, von dem die letzte Meldung stammt" - -msgid "Parameters missing " -msgstr "Nicht genug Parameter" - -msgid "Particles in the interface\\Steam clouds and sparks in the interface" -msgstr "Partikel in den Menüs\\Funken und Sterne in den Menüs" - -msgid "Paste (Ctrl+v)" -msgstr "Einfügen (Ctrl+v)" - -msgid "Pause/continue" -msgstr "Pause/Weitermachen" - -msgid "Phazer shooter" -msgstr "Phazershooter" - -msgid "Photography" -msgstr "Ansicht der Mission" - -msgid "Place occupied" -msgstr "Stelle schon besetzt" - -msgid "Planets and stars\\Astronomical objects in the sky" -msgstr "Planeten und Sterne\\Kreisende Planeten und Sterne" - -msgid "Plans for defense tower available" -msgstr "Errichtung eines Geschützturms möglich" - -msgid "Plans for nuclear power plant available" -msgstr "Errichtung einer Brennstoffzellenfabrik möglich" - -msgid "Plans for phazer shooter available" -msgstr "Herstellung eines Phazershooters möglich" - -msgid "Plans for shielder available" -msgstr "Herstellung eines Schutzschildes möglich" - -msgid "Plans for shooter available" -msgstr "Herstellung eines Shooters möglich" - -msgid "Plans for thumper available" -msgstr "Herstellung eines Stampfers möglich" - -msgid "Plans for tracked robots available " -msgstr "Herstellung eines Roboters mit Kettenantrieb möglich" - -msgid "Plant a flag" -msgstr "Setzt eine Fahne" - -msgid "Play\\Start mission!" -msgstr "Spielen ...\\Los geht's!" - -msgid "Player" -msgstr "Spieler" - -msgid "Player name" -msgstr "Name " - -msgid "Player's name" -msgstr "Name " - -msgid "Power cell" -msgstr "Elektrolytische Batterie" - -msgid "Power cell available" -msgstr "Batterie verfügbar" - -msgid "Power cell factory" -msgstr "Batteriefabrik" - -msgid "Power station" -msgstr "Kraftwerk" - -msgid "Practice bot" -msgstr "Übungsroboter" - -msgid "Press \\key help; to read instructions on your SatCom" -msgstr "Beziehen Sie sich auf Ihren SatCom, indem Sie auf \\key help; drücken" - -msgid "Previous" -msgstr "Vorherg" - -msgid "Previous object\\Selects the previous object" -msgstr "Vorherg. Auswahl\\Das vorhergehende Objekt auswählen" - -msgid "Previous selection (\\key desel;)" -msgstr "Vorherg. Auwahl (\\key desel;)" - -msgid "Private element" -msgstr "Geschütztes Element (private)" - -msgid "Private\\Private folder" -msgstr "Privat\\Privater Ordner" - -msgid "Program editor" -msgstr "Programmeditor" - -msgid "Program finished" -msgstr "Programm beendet" - -msgid "Program infected by a virus" -msgstr "Ein Programm wurde von einem Virus infiziert" - -msgid "Programming exercises" -msgstr "Programmieren" - -msgid "Programming help" -msgstr "Hilfe über Programmieren" - -msgid "Programming help (\\key prog;)" -msgstr "Hilfe über Programmieren (\\key prog;)" - -msgid "Programming help\\Gives more detailed help with programming" -msgstr "Hilfe CBOT-Sprache\\Hilfe über die Programmiersprache CBOT" - -msgid "Programs dispatched by Houston" -msgstr "Von Houston übermittelte Programme" - -msgid "Proto\\Prototypes under development" -msgstr "Proto\\In Entwicklung befindliche Prototypen" - -msgid "Prototypes" -msgstr "Prototypen" - -msgid "Public required" -msgstr "Hier muss das Wort \"public\" stehen" - -msgid "Public\\Common folder" -msgstr "Öffentlich\\Gemeinsamer Ordner für alle Spieler" - -msgid "Quake at explosions\\The screen shakes at explosions" -msgstr "Beben bei Explosionen\\Die Kamera bebt bei Explosionen" - -msgid "Quit the mission?" -msgstr "Mission abbrechen ?" - -msgid "Quit\\Quit COLOBOT" -msgstr "Schließen\\COLOBOT schließen" - -msgid "Quit\\Quit the current mission or exercise" -msgstr "Mission verlassen\\Eine Mission oder Übung verlassen" - -msgid "Radar station" -msgstr "Radar" - -msgid "Read error" -msgstr "Fehler beim Lesezugriff" - -msgid "Recorder" -msgstr "Recorder" - -msgid "Recycle (\\key action;)" -msgstr "Recyceln (\\key action;)" - -msgid "Recycler" -msgstr "Recycler" - -msgid "Red" -msgstr "Rot" - -msgid "Red flag" -msgstr "Rote Fahne" - -msgid "Reflections on the buttons \\Shiny buttons" -msgstr "Glänzende Tasten\\Glänzende Tasten in den Menüs" - -msgid "Remains of Apollo mission" -msgstr "Überreste einer Apollo-Mission" - -msgid "Remove a flag" -msgstr "Sammelt die Fahne ein" - -msgid "Repair center" -msgstr "Reparaturzentrum" - -msgid "Research center" -msgstr "Forschungszentrum" - -msgid "Research program already performed" -msgstr "Forschungsprogramm schon ausgeführt" - -msgid "Research program completed" -msgstr "Forschungsprogramm abgeschlossen" - -msgid "Reserved keyword of CBOT language" -msgstr "Dieses Wort ist reserviert" - -msgid "Resolution" -msgstr "Auflösung" - -msgid "Restart\\Restart the mission from the beginning" -msgstr "Neu anfangen\\Die Mission von vorne anfangen" - -msgid "Return to start" -msgstr "Alles zurücksetzen" - -msgid "Robbie" -msgstr "Robby" - -msgid "Robbie\\Your assistant" -msgstr "Robby\\Ihr Assistent" - -msgid "Ruin" -msgstr "Gebäuderuine" - -msgid "Run research program for defense tower" -msgstr "Forschungsprogramm Geschützturm" - -msgid "Run research program for legged bots" -msgstr "Forschungsprogramm Krabbelantrieb" - -msgid "Run research program for nuclear power" -msgstr "Forschungsprogramm Brennstoffzelle" - -msgid "Run research program for orga shooter" -msgstr "Forschungsprogramm Orgashooterkanone" - -msgid "Run research program for phazer shooter" -msgstr "Forschungsprogramm Phazerkanone" - -msgid "Run research program for shielder" -msgstr "Forschungsprogramm Schutzschild" - -msgid "Run research program for shooter" -msgstr "Forschungsprogramm Shooterkanone" - -msgid "Run research program for thumper" -msgstr "Forschungsprogramm Stampfer" - -msgid "Run research program for tracked bots" -msgstr "Forschungsprogramm Kettenantrieb" - -msgid "Run research program for winged bots" -msgstr "Forschungsprogramm Jetantrieb" - -msgid "SatCom" -msgstr "SatCom" - -msgid "Satellite report" -msgstr "Satellitenbericht" - -msgid "Save" -msgstr "Speichern" - -msgid "Save (Ctrl+s)" -msgstr "Speichern (Ctrl+s)" - -msgid "Save the current mission" -msgstr "Aktuelle Mission speichern" - -msgid "Save\\Save the current mission " -msgstr "Speichern\\Aktuelle Mission speichern" - -msgid "Save\\Saves the current mission" -msgstr "Speichern\\Speichert die Mission" - -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht" - -msgid "Select the astronaut\\Selects the astronaut" -msgstr "Astronauten auswählen\\Astronauten auswählen" - -msgid "Semicolon terminator missing" -msgstr "Es fehlt ein Strichpunkt \";\" am Ende der Anweisung" - -msgid "Shadows\\Shadows on the ground" -msgstr "Schatten\\Schlagschatten auf dem Boden" - -msgid "Shield level" -msgstr "Schäden" - -msgid "Shield radius" -msgstr "Reichweite Schutzschild" - -msgid "Shielder" -msgstr "Schutzschild" - -msgid "Shift" -msgstr "Shift" - -msgid "Shoot (\\key action;)" -msgstr "Feuer (\\key action;)" - -msgid "Show if the ground is flat" -msgstr "Zeigt ob der Boden eben ist" - -msgid "Show the place" -msgstr "Zeigt den Ort" - -msgid "Show the range" -msgstr "Zeigt die Reichweite" - -msgid "Show the solution" -msgstr "Zeigt die Lösung" - -msgid "Sign \" : \" missing" -msgstr "Es fehlt ein Doppelpunkt \" : \"" - -msgid "Size 1" -msgstr "Größe 1" - -msgid "Size 2" -msgstr "Größe 2" - -msgid "Size 3" -msgstr "Größe 3" - -msgid "Size 4" -msgstr "Größe 4" - -msgid "Size 5" -msgstr "Größe 5" - -msgid "Sky\\Clouds and nebulae" -msgstr "Himmel\\Himmel und Wolken" - -msgid "Sniff (\\key action;)" -msgstr "Schnüffeln (\\key action;)" - -msgid "Solution" -msgstr "Lösung" - -msgid "Sound effects:\\Volume of engines, voice, shooting, etc." -msgstr "Geräusche:\\Lautstärke Motoren, Stimmen, usw." - -msgid "Sound\\Music and game sound volume" -msgstr "Geräusche\\Lautstärke Geräusche und Musik" - -msgid "Spaceship" -msgstr "Raumschiff" - -msgid "Spaceship ruin" -msgstr "Raumschiffruine" - -msgid "Speed 1.0x\\Normal speed" -msgstr "Geschwindigkeit 1.0x\\Normale Spielgeschwindigkeit" - -msgid "Speed 1.5x\\1.5 times faster" -msgstr "Geschwindigkeit 1.5x\\Spielgeschwindigkeit anderthalb Mal schneller" - -msgid "Speed 2.0x\\Double speed" -msgstr "Geschwindigkeit 2.0x\\Spielgeschwindigkeit doppelt so schnell" - -msgid "Speed 3.0x\\Three times faster" -msgstr "Geschwindigkeit 3.0x\\Spielgeschwindigkeit drei Mal schneller" - -msgid "Spider" -msgstr "Spinne" - -msgid "Spider fatally wounded" -msgstr "Spinne tödlich verwundet" - -msgid "Stack overflow" -msgstr "Stack overflow" - -msgid "" -"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)" -msgstr "Standardhandlung\\Führt die Standardhandlung des Roboters aus" - -msgid "Standard controls\\Standard key functions" -msgstr "Alles zurücksetzen\\Standarddefinition aller Tasten" - -msgid "Standard\\Standard appearance settings" -msgstr "Standard\\Standardfarben einsetzen" - -msgid "Start" -msgstr "Startfläche" - -msgid "Still working ..." -msgstr "Prozess im Gang ..." - -msgid "String missing" -msgstr "Hier wird eine Zeichenkette erwartet" - -msgid "Strip color:" -msgstr "Farbe der Streifen:" - -msgid "Subber" -msgstr "Kettentaucher" - -msgid "Suit color:" -msgstr "Farbe des Anzugs:" - -msgid "Suit\\Astronaut suit" -msgstr "Anzug\\Raumfahrtanzug" - -msgid "Sunbeams\\Sunbeams in the sky" -msgstr "Sonnenstrahlen\\Sonnenstrahlen" - -msgid "Survival kit" -msgstr "Überlebenskit" - -msgid "Switch bots <-> buildings" -msgstr "Anzeige Roboter <-> Bauten" - -msgid "Take off to finish the mission" -msgstr "Abheben nach vollbrachter Mission" - -msgid "Target" -msgstr "Zielscheibe" - -msgid "Target bot" -msgstr "Mobile Zielscheibe" - -msgid "Textures\\Quality of textures " -msgstr "Qualität der Texturen\\Qualität der Anzeige" - -msgid "The expression must return a boolean value" -msgstr "Der Ausdruck muss einen boolschen Wert ergeben" - -msgid "The function returned no value " -msgstr "Die Funktion hat kein Ergebnis zurückgegeben" - -msgid "" -"The list is only available if a \\l;radar station\\u object\\radar; is " -"working.\n" -msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar.\n" - -msgid "" -"The mission is not accomplished yet (press \\key help; for more details)" -msgstr "" -"Mission noch nicht beendet (Drücken Sie auf \\key help; für weitere " -"Informationen)" - -msgid "The types of the two operands are incompatible " -msgstr "Die zwei Operanden sind nicht kompatibel" - -msgid "This class already exists" -msgstr "Diese Klasse gibt es schon" - -msgid "This class does not exist" -msgstr "Diese Klasse existiert nicht" - -msgid "This is not a member of this class" -msgstr "Dieses Element gibt es nicht in dieser Klasse" - -msgid "This label does not exist" -msgstr "Dieses Label existiert nicht" - -msgid "This object is not a member of a class" -msgstr "Das Objekt ist nicht eine Instanz einer Klasse" - -msgid "Thump (\\key action;)" -msgstr "Stampfen (\\key action;)" - -msgid "Thumper" -msgstr "Stampfer" - -msgid "Titanium" -msgstr "Titan" - -msgid "Titanium available" -msgstr "Titan verfügbar" - -msgid "Titanium deposit (site for derrick)" -msgstr "Markierung für unterirdisches Titanvorkommen" - -msgid "Titanium ore" -msgstr "Titanerz" - -msgid "Titanium too close" -msgstr "Titan zu nahe" - -msgid "Titanium too far away" -msgstr "Titan zu weit weg" - -msgid "Too close to a building" -msgstr "Zu nahe an einem Gebäude" - -msgid "Too close to an existing flag" -msgstr "Zu nahe an einer anderen Fahne" - -msgid "Too close to space ship" -msgstr "Zu nahe am Raumschiff" - -msgid "Too many flags of this color (maximum 5)" -msgstr "Zu viele Fahnen dieser Farbe (Maximum 5)" - -msgid "Too many parameters" -msgstr "Zu viele Parameter" - -msgid "Tracked grabber" -msgstr "Transporter" - -msgid "Tracked orga shooter" -msgstr "OrgaShooter" - -msgid "Tracked shooter" -msgstr "Shooter" - -msgid "Tracked sniffer" -msgstr "Schnüffler" - -msgid "Transforms only titanium" -msgstr "Wandelt nur Titanerz um" - -msgid "Transforms only uranium" -msgstr "Wandelt nur Platin um" - -msgid "Transmitted information" -msgstr "Gesendete Informationen" - -msgid "Turn left (\\key left;)" -msgstr "Drehung links (\\key left;)" - -msgid "Turn left\\turns the bot to the left" -msgstr "Drehung nach links\\Steuer links" - -msgid "Turn right (\\key right;)" -msgstr "Drehung rechts (\\key right;)" - -msgid "Turn right\\turns the bot to the right" -msgstr "Drehung nach rechts\\Steuer rechts" - -msgid "Type declaration missing" -msgstr "Hier muss ein Variablentyp stehen" - -msgid "Undo (Ctrl+z)" -msgstr "Widerrufen (Ctrl+z)" - -msgid "Unit" -msgstr "Einheit" - -msgid "Unknown Object" -msgstr "Das Objekt existiert nicht" - -msgid "Unknown command" -msgstr "Befehl unbekannt" - -msgid "Unknown function" -msgstr "Unbekannte Funktion" - -msgid "Up (\\key gup;)" -msgstr "Steigt (\\key gup;)" - -msgid "Uranium deposit (site for derrick)" -msgstr "Markierung für unterirdisches Platinvorkommen" - -msgid "Uranium ore" -msgstr "Platinerz" - -msgid "Use a joystick\\Joystick or keyboard" -msgstr "Joystick\\Joystick oder Tastatur" - -msgid "User levels" -msgstr "Userlevels" - -msgid "User\\User levels" -msgstr "User\\Userlevels" - -msgid "Variable name missing" -msgstr "Es fehlt der Name einer Variable" - -msgid "Variable not declared" -msgstr "Variable nicht deklariert" - -msgid "Variable not initialized" -msgstr "Der Wert dieser Variable wurde nicht definiert" - -msgid "Vault" -msgstr "Bunker" - -msgid "Violet flag" -msgstr "Violette Fahne" - -msgid "Void parameter" -msgstr "Parameter void" - -msgid "Wasp" -msgstr "Wespe" - -msgid "Wasp fatally wounded" -msgstr "Wespe tödlich verwundet" - -msgid "Waste" -msgstr "Abfall" - -msgid "Wheeled grabber" -msgstr "Transporter" - -msgid "Wheeled orga shooter" -msgstr "OrgaShooter" - -msgid "Wheeled shooter" -msgstr "Shooter" - -msgid "Wheeled sniffer" -msgstr "Schnüffler" - -msgid "Win" -msgstr "" - -msgid "Winged grabber" -msgstr "Transporter" - -msgid "Winged orga shooter" -msgstr "OrgaShooter" - -msgid "Winged shooter" -msgstr "Shooter" - -msgid "Winged sniffer" -msgstr "Schnüffler" - -msgid "Withdraw shield (\\key action;)" -msgstr "Schutzschild einholen (\\key action;)" - -msgid "Worm" -msgstr "Wurm" - -msgid "Worm fatally wounded" -msgstr "Wurm tödlich verwundet" - -msgid "Wreckage" -msgstr "Roboterwrack" - -msgid "Write error" -msgstr "Fehler beim Schreibzugriff" - -msgid "Wrong type for the assignment" -msgstr "Der Ausdruck ergibt einen falschen Typ für die Zuweisung" - -msgid "Yellow flag" -msgstr "Gelbe Fahne" - -msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)" -msgstr "Sie können jetzt mit den Tasten \\key gup; und \\key gdown; fliegen" - -msgid "You can not carry a radioactive object" -msgstr "Sie können keinen radioaktiven Gegenstand tragen" - -msgid "You can not carry an object under water" -msgstr "Sie können unter Wasser nichts tragen" - -msgid "You found a usable object" -msgstr "Sie haben ein brauchbares Objekt gefunden" - -msgid "You must get on the spaceship to take off " -msgstr "Gehen Sie an Bord, bevor Sie abheben" - -msgid "Zoom mini-map" -msgstr "Zoom Minikarte" - -msgid "\\Blue flags" -msgstr "\\Blaue Fahne" - -msgid "\\Eyeglasses 1" -msgstr "\\Brille 1" - -msgid "\\Eyeglasses 2" -msgstr "\\Brille 2" - -msgid "\\Eyeglasses 3" -msgstr "\\Brille 3" - -msgid "\\Eyeglasses 4" -msgstr "\\Brille 4" - -msgid "\\Eyeglasses 5" -msgstr "\\Brille 5" - -msgid "\\Face 1" -msgstr "\\Kopf 1" - -msgid "\\Face 2" -msgstr "\\Kopf 2" - -msgid "\\Face 3" -msgstr "\\Kopf 3" - -msgid "\\Face 4" -msgstr "\\Kopf 4" - -msgid "\\Green flags" -msgstr "\\Grüne Fahne" - -msgid "\\New player name" -msgstr "\\Name des Spielers" - -msgid "\\No eyeglasses" -msgstr "\\Keine Brille" - -msgid "\\Raise the pencil" -msgstr "\\Bleistift abheben" - -msgid "\\Red flags" -msgstr "\\Rote Fahne" - -msgid "\\Return to COLOBOT" -msgstr "\\Zurück zu COLOBOT" - -msgid "\\SatCom on standby" -msgstr "\\SatCom in Standby" - -msgid "\\Start recording" -msgstr "\\Aufnahme starten" - -msgid "\\Stop recording" -msgstr "\\Aufnahme stoppen" - -msgid "\\Turn left" -msgstr "\\Drehung links" - -msgid "\\Turn right" -msgstr "\\Drehung rechts" - -msgid "\\Use the black pencil" -msgstr "\\Schwarzen Bleistift hinunterlassen" - -msgid "\\Use the blue pencil" -msgstr "\\Blauen Bleistift hinunterlassen" - -msgid "\\Use the brown pencil" -msgstr "\\Braunen Bleistift hinunterlassen" - -msgid "\\Use the green pencil" -msgstr "\\Grünen Bleistift hinunterlassen" - -msgid "\\Use the orange pencil" -msgstr "\\Orangefarbenen Bleistift hinunterlassen" - -msgid "\\Use the purple pencil" -msgstr "\\Violetten Bleistift hinunterlassen" - -msgid "\\Use the red pencil" -msgstr "\\Roten Bleistift hinunterlassen" - -msgid "\\Use the yellow pencil" -msgstr "\\Gelben Bleistift hinunterlassen" - -msgid "\\Violet flags" -msgstr "\\Violette Fahne" - -msgid "\\Yellow flags" -msgstr "\\Gelbe Fahne" - -msgid "\\b;Aliens\n" -msgstr "\\b;Listes der Feinde\n" - -msgid "\\b;Buildings\n" -msgstr "\\b;Listes der Gebäude\n" - -msgid "\\b;Error\n" -msgstr "\\b;Fehler\n" - -msgid "\\b;List of objects\n" -msgstr "\\b;Liste der Objekte\n" - -msgid "\\b;Moveable objects\n" -msgstr "\\b;Listes der tragbaren Gegenstände\n" - -msgid "\\b;Robots\n" -msgstr "\\b;Liste der Roboter\n" - -msgid "\\c; (none)\\n;\n" -msgstr "\\c; (keine)\\n;\n" - -msgid "action;" -msgstr "" - -msgid "away;" -msgstr "" - -msgid "camera;" -msgstr "" - -msgid "cbot;" -msgstr "" - -msgid "desel;" -msgstr "" - -msgid "down;" -msgstr "" - -msgid "gdown;" -msgstr "" - -msgid "gup;" -msgstr "" - -msgid "help;" -msgstr "" - -msgid "human;" -msgstr "" - -msgid "left;" -msgstr "" - -msgid "near;" -msgstr "" - -msgid "next;" -msgstr "" - -msgid "prog;" -msgstr "" - -msgid "quit;" -msgstr "" - -msgid "right;" -msgstr "" - -msgid "speed10;" -msgstr "" - -msgid "speed15;" -msgstr "" - -msgid "speed20;" -msgstr "" - -msgid "up;" -msgstr "" - -msgid "visit;" -msgstr "" - -msgid "www.epsitec.com" -msgstr "www.epsitec.com" - -#~ msgid "< none >" -#~ msgstr "< keine >" - -#~ msgid "<--" -#~ msgstr "<--" - -#~ msgid "Application key" -#~ msgstr "Application key" - -#~ msgid "Arrow down" -#~ msgstr "Pfeil nach unten" - -#~ msgid "Arrow left" -#~ msgstr "Pfeiltaste links" - -#~ msgid "Arrow right" -#~ msgstr "Pfeiltaste rechts" - -#~ msgid "Arrow up" -#~ msgstr "Pfeil nach oben" - -#~ msgid "Attn" -#~ msgstr "Attn" - -#~ msgid "Caps Lock" -#~ msgstr "Caps Lock" - -#~ msgid "Clear" -#~ msgstr "Clear" - -#~ msgid "Control-break" -#~ msgstr "Ctrl-Break" - -#~ msgid "CrSel" -#~ msgstr "CrSel" - -#~ msgid "Delete Key" -#~ msgstr "Delete" - -#~ msgid "Dictionnary" -#~ msgstr "Wörterbuch Englisch-Deutsch" - -#~ msgid "Disintegrator" -#~ msgstr "Auflöser" - -#~ msgid "End" -#~ msgstr "End" - -#~ msgid "Enter" -#~ msgstr "Eingabe" - -#~ msgid "Erase EOF" -#~ msgstr "Erase EOF" - -#~ msgid "Error" -#~ msgstr "Fehler" - -#~ msgid "Esc" -#~ msgstr "Esc" - -#~ msgid "ExSel" -#~ msgstr "ExSel" - -#~ msgid "Execute" -#~ msgstr "Execute" - -#~ msgid "F1" -#~ msgstr "F1" - -#~ msgid "F10" -#~ msgstr "F10" - -#~ msgid "F11" -#~ msgstr "F11" - -#~ msgid "F12" -#~ msgstr "F12" - -#~ msgid "F13" -#~ msgstr "F13" - -#~ msgid "F14" -#~ msgstr "F14" - -#~ msgid "F15" -#~ msgstr "F15" - -#~ msgid "F16" -#~ msgstr "F16" - -#~ msgid "F17" -#~ msgstr "F17" - -#~ msgid "F18" -#~ msgstr "F18" - -#~ msgid "F19" -#~ msgstr "F19" - -#~ msgid "F2" -#~ msgstr "F2" - -#~ msgid "F20" -#~ msgstr "F20" - -#~ msgid "F3" -#~ msgstr "F3" - -#~ msgid "F4" -#~ msgstr "F4" - -#~ msgid "F5" -#~ msgstr "F5" - -#~ msgid "F6" -#~ msgstr "F6" - -#~ msgid "F7" -#~ msgstr "F7" - -#~ msgid "F8" -#~ msgstr "F8" - -#~ msgid "F9" -#~ msgstr "F9" - -#~ msgid "Help" -#~ msgstr "Help" - -#~ msgid "Home Key" -#~ msgstr "Home" - -#~ msgid "Insert" -#~ msgstr "Insert" - -#~ msgid "Left Windows" -#~ msgstr "Left Windows" - -#~ msgid "Mini-map" -#~ msgstr "Minikarte" - -#~ msgid "Num Lock" -#~ msgstr "Num Lock" - -#~ msgid "NumPad *" -#~ msgstr "NumPad *" - -#~ msgid "NumPad +" -#~ msgstr "NumPad +" - -#~ msgid "NumPad -" -#~ msgstr "NumPad -" - -#~ msgid "NumPad ." -#~ msgstr "NumPad ." - -#~ msgid "NumPad /" -#~ msgstr "NumPad /" - -#~ msgid "NumPad 0" -#~ msgstr "NumPad 0" - -#~ msgid "NumPad 1" -#~ msgstr "NumPad 1" - -#~ msgid "NumPad 2" -#~ msgstr "NumPad 2" - -#~ msgid "NumPad 3" -#~ msgstr "NumPad 3" - -#~ msgid "NumPad 4" -#~ msgstr "NumPad 4" - -#~ msgid "NumPad 5" -#~ msgstr "NumPad 5" - -#~ msgid "NumPad 6" -#~ msgstr "NumPad 6" - -#~ msgid "NumPad 7" -#~ msgstr "NumPad 7" - -#~ msgid "NumPad 8" -#~ msgstr "NumPad 8" - -#~ msgid "NumPad 9" -#~ msgstr "NumPad 9" - -#~ msgid "NumPad sep" -#~ msgstr "NumPad sep" - -#~ msgid "PA1" -#~ msgstr "PA1" - -#~ msgid "Page Down" -#~ msgstr "Page Down" - -#~ msgid "Page Up" -#~ msgstr "Page Up" - -#~ msgid "Pause" -#~ msgstr "Pause" - -#~ msgid "Play" -#~ msgstr "Play" - -#~ msgid "Print Scrn" -#~ msgstr "Print Scrn" - -#~ msgid "Right Windows" -#~ msgstr "Right Windows" - -#~ msgid "Scroll" -#~ msgstr "Scroll" - -#~ msgid "Select" -#~ msgstr "Select" - -#~ msgid "Space" -#~ msgstr "Leertaste" - -#~ msgid "Tab" -#~ msgstr "Tab" - -#~ msgid "Wheel down" -#~ msgstr "Mausrad zurück" - -#~ msgid "Wheel up" -#~ msgstr "Mausrad nach vorne" - -#~ msgid "Zoom" -#~ msgstr "Zoom" - diff --git a/src/po/fr.po b/src/po/fr.po deleted file mode 100644 index 343458d..0000000 --- a/src/po/fr.po +++ /dev/null @@ -1,2058 +0,0 @@ -# Didier Raboud , 2012. -msgid "" -msgstr "" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 17:09+0100\n" -"PO-Revision-Date: 2012-12-27 14:07+0100\n" -"Last-Translator: Didier Raboud \n" -"Language: fr\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Language: fr_FR\n" -"X-Source-Language: en_US\n" -"X-Generator: Lokalize 1.4\n" - -msgid " " -msgstr " " - -msgid " Challenges in the chapter:" -msgstr " Liste des défis du chapitre :" - -msgid " Chapters:" -msgstr " Liste des chapitres :" - -msgid " Drivers:" -msgstr " Pilotes :" - -msgid " Exercises in the chapter:" -msgstr " Liste des exercices du chapitre :" - -msgid " Free game on this chapter:" -msgstr " Liste des jeux libres du chapitre :" - -msgid " Free game on this planet:" -msgstr " Liste des jeux libres du chapitre :" - -msgid " Missions on this level:" -msgstr " Missions du niveau :" - -msgid " Missions on this planet:" -msgstr " Liste des missions du chapitre :" - -msgid " Planets:" -msgstr " Liste des planètes :" - -msgid " Prototypes on this planet:" -msgstr " Liste des prototypes du chapitre :" - -msgid " Resolution:" -msgstr " Résolutions :" - -msgid " Summary:" -msgstr " Résumé :" - -msgid " User levels:" -msgstr " Niveaux supplémentaires :" - -msgid " or " -msgstr " ou " - -msgid "\" [ \" expected" -msgstr "\" [ \" attendu" - -msgid "\" ] \" missing" -msgstr "\" ] \" attendu" - -#, c-format -msgid "\"%s\" missing in this exercise" -msgstr "Il manque \"%s\" dans le programme" - -msgid "%1" -msgstr "%1" - -msgid "..behind" -msgstr "..derrière" - -msgid "..in front" -msgstr "..devant" - -msgid "..power cell" -msgstr "..pile" - -msgid "1) First click on the key you want to redefine." -msgstr "1) Cliquez d'abord sur la touche à redéfinir." - -msgid "2) Then press the key you want to use instead." -msgstr "2) Appuyez ensuite sur la nouvelle touche souhaitée." - -msgid "3D sound\\3D positioning of the sound" -msgstr "Bruitages 3D\\Positionnement sonore dans l'espace" - -msgid "<< Back \\Back to the previous screen" -msgstr "<< Retour \\Retour au niveau précédent" - -msgid "<<< Sorry; mission failed >>>" -msgstr "<<< Désolé; mission échouée >>>" - -msgid "<<< Well done; mission accomplished >>>" -msgstr "<<< Bravo; mission terminée >>>" - -msgid "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\"" -msgstr "" -"Un label ne peut se placer que devant un \"for\"; un \"while\"; un \"do\" ou " -"un \"switch\"" - -msgid "A variable can not be declared twice" -msgstr "Redéfinition d'une variable" - -msgid "Abort\\Abort the current mission" -msgstr "Abandonner\\Abandonner la mission en cours" - -msgid "Access beyond array limit" -msgstr "Accès hors du tableau" - -msgid "" -"Access to solution\\Shows the solution (detailed instructions for missions)" -msgstr "Accès à la solution\\Donne la solution" - -msgid "Access to solutions\\Show program \"4: Solution\" in the exercises" -msgstr "Accès aux solutions\\Programme \"4: Solution\" dans les exercices" - -msgid "Alien Queen" -msgstr "Pondeuse" - -msgid "Alien Queen killed" -msgstr "Pondeuse mortellement touchée" - -msgid "Already carrying something" -msgstr "Porte déjà quelque chose" - -msgid "Alt" -msgstr "Alt" - -msgid "Analysis already performed" -msgstr "Analyse déjà effectuée" - -msgid "Analysis performed" -msgstr "Analyse terminée" - -msgid "Analyzes only organic matter" -msgstr "N'analyse que la matière organique" - -msgid "Ant" -msgstr "Fourmi" - -msgid "Ant fatally wounded" -msgstr "Fourmi mortellement touchée" - -msgid "Appearance\\Choose your appearance" -msgstr "Aspect\\Choisir votre aspect" - -msgid "Apply changes\\Activates the changed settings" -msgstr "Appliquer les changements\\Active les changements effectués" - -msgid "Appropriate constructor missing" -msgstr "Il n'y a pas de constructeur approprié" - -msgid "Assignment impossible" -msgstr "Assignation impossible" - -msgid "Autolab" -msgstr "Laboratoire de matières organiques" - -msgid "Automatic indent\\When program editing" -msgstr "Indentation automatique\\Pendant l'édition d'un programme" - -msgid "Back" -msgstr "Page précédente" - -msgid "Background sound :\\Volume of audio tracks on the CD" -msgstr "Fond sonore :\\Volume des pistes audio du CD" - -msgid "Backward (\\key down;)" -msgstr "Recule (\\key down;)" - -msgid "Backward\\Moves backward" -msgstr "Reculer\\Moteur en arrière" - -msgid "Bad argument for \"new\"" -msgstr "Mauvais argument pour \"new\"" - -msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces" -msgstr "Grande indentation\\Indente avec 2 ou 4 espaces" - -msgid "Black box" -msgstr "Boîte noire" - -msgid "Blue" -msgstr "Bleu" - -msgid "Blue flag" -msgstr "Drapeau bleu" - -msgid "Bot destroyed" -msgstr "Robot détruit" - -msgid "Bot factory" -msgstr "Fabrique de robots" - -msgid "Build a bot factory" -msgstr "Construit une fabrique de robots" - -msgid "Build a converter" -msgstr "Construit un convertisseur" - -msgid "Build a defense tower" -msgstr "Construit une tour" - -msgid "Build a derrick" -msgstr "Construit un derrick" - -msgid "Build a exchange post" -msgstr "Construit une borne d'information" - -msgid "Build a legged grabber" -msgstr "Fabrique un déménageur à pattes" - -msgid "Build a legged orga shooter" -msgstr "Fabrique un orgaShooter à pattes" - -msgid "Build a legged shooter" -msgstr "Fabrique un shooter à pattes" - -msgid "Build a legged sniffer" -msgstr "Fabrique un renifleur à pattes" - -msgid "Build a lightning conductor" -msgstr "Construit un paratonnerre" - -msgid "Build a nuclear power plant" -msgstr "Construit une centrale nucléaire" - -msgid "Build a phazer shooter" -msgstr "Fabrique un robot phazer" - -msgid "Build a power cell factory" -msgstr "Construit une fabrique de piles" - -msgid "Build a power station" -msgstr "Construit une station" - -msgid "Build a radar station" -msgstr "Construit un radar" - -msgid "Build a recycler" -msgstr "Fabrique un robot recycleur" - -msgid "Build a repair center" -msgstr "Construit un centre de réparation" - -msgid "Build a research center" -msgstr "Construit un centre de recherches" - -msgid "Build a shielder" -msgstr "Fabrique un robot bouclier" - -msgid "Build a subber" -msgstr "Fabrique un robot sous-marin" - -msgid "Build a thumper" -msgstr "Fabrique un robot secoueur" - -msgid "Build a tracked grabber" -msgstr "Fabrique un déménageur à chenilles" - -msgid "Build a tracked orga shooter" -msgstr "Fabrique un orgaShooter à chenilles" - -msgid "Build a tracked shooter" -msgstr "Fabrique un shooter à chenilles" - -msgid "Build a tracked sniffer" -msgstr "Fabrique un renifleur à chenilles" - -msgid "Build a wheeled grabber" -msgstr "Fabrique un déménageur à roues" - -msgid "Build a wheeled orga shooter" -msgstr "Fabrique un orgaShooter à roues" - -msgid "Build a wheeled shooter" -msgstr "Fabrique un shooter à roues" - -msgid "Build a wheeled sniffer" -msgstr "Fabrique un renifleur à roues" - -msgid "Build a winged grabber" -msgstr "Fabrique un déménageur volant" - -msgid "Build a winged orga shooter" -msgstr "Fabrique un orgaShooter volant" - -msgid "Build a winged shooter" -msgstr "Fabrique un shooter volant" - -msgid "Build a winged sniffer" -msgstr "Fabrique un renifleur volant" - -msgid "Build an autolab" -msgstr "Construit un laboratoire" - -msgid "Building completed" -msgstr "Bâtiment terminé" - -msgid "Building destroyed" -msgstr "Bâtiment détruit" - -msgid "Building too close" -msgstr "Bâtiment trop proche" - -msgid "Button %1" -msgstr "Bouton %1" - -msgid "COLOBOT" -msgstr "COLOBOT" - -msgid "Calling an unknown function" -msgstr "Appel d'une fonction inexistante" - -msgid "Camera (\\key camera;)" -msgstr "Caméra (\\key camera;)" - -msgid "Camera awayest" -msgstr "Caméra plus loin" - -msgid "Camera back\\Moves the camera backward" -msgstr "Caméra plus loin\\Recule la caméra" - -msgid "Camera closer\\Moves the camera forward" -msgstr "Caméra plus proche\\Avance la caméra" - -msgid "Camera nearest" -msgstr "Caméra plus proche" - -msgid "Camera to left" -msgstr "Caméra à gauche" - -msgid "Camera to right" -msgstr "Caméra à droite" - -msgid "Can not create this; there are too many objects" -msgstr "Création impossible; il y a trop d'objets" - -msgid "Can't open file" -msgstr "Ouverture du fichier impossible" - -msgid "Cancel" -msgstr "Annuler" - -msgid "Cancel\\Cancel all changes" -msgstr "Annuler\\Annuler toutes les modifications" - -msgid "Cancel\\Keep current player name" -msgstr "Annuler\\Conserver le joueur actuel" - -msgid "Challenges" -msgstr "Défis" - -msgid "Challenges\\Programming challenges" -msgstr "Défis\\Défis de programmation" - -msgid "Change camera\\Switches between onboard camera and following camera" -msgstr "Changement de caméra\\Autre de point de vue" - -msgid "Checkpoint" -msgstr "Indicateur" - -msgid "Checkpoint crossed" -msgstr "Indicateur atteint" - -msgid "Climb\\Increases the power of the jet" -msgstr "Monter\\Augmenter la puissance du réacteur" - -msgid "Close" -msgstr "Fermer" - -msgid "Closing bracket missing " -msgstr "Il manque une parenthèse fermante" - -msgid "Colobot rules!" -msgstr "Colobot est super!" - -msgid "Command line" -msgstr "Console de commande" - -msgid "Compass" -msgstr "Boussole" - -msgid "Compilation ok (0 errors)" -msgstr "Compilation ok (0 erreur)" - -msgid "Compile" -msgstr "Compiler" - -msgid "Continue" -msgstr "Continuer" - -msgid "Continue\\Continue the current mission" -msgstr "Continuer\\Continuer la mission en cours" - -msgid "Continue\\Continue the game" -msgstr "Continuer\\Continuer de jouer" - -msgid "Controls\\Keyboard, joystick and mouse settings" -msgstr "Commandes\\Touches du clavier" - -msgid "Converts ore to titanium" -msgstr "Conversion minerai en titanium" - -msgid "Copy" -msgstr "Copier" - -msgid "Copy (Ctrl+c)" -msgstr "Copier (Ctrl+c)" - -msgid "Ctrl" -msgstr "Ctrl" - -msgid "Current mission saved" -msgstr "Enregistrement effectué" - -msgid "Customize your appearance" -msgstr "Personnalisation de votre apparence" - -msgid "Cut (Ctrl+x)" -msgstr "Couper (Ctrl+x)" - -msgid "Defense tower" -msgstr "Tour de défense" - -msgid "Delete" -msgstr "Détruire" - -msgid "Delete player\\Deletes the player from the list" -msgstr "Supprimer le joueur\\Supprimer le joueur de la liste" - -msgid "Delete\\Deletes the selected file" -msgstr "Supprimer\\Supprime l'enregistrement sélectionné" - -msgid "Depth of field\\Maximum visibility" -msgstr "Profondeur de champ\\Distance de vue maximale" - -msgid "Derrick" -msgstr "Derrick" - -msgid "Descend\\Reduces the power of the jet" -msgstr "Descendre\\Diminuer la puissance du réacteur" - -msgid "Destroy the building" -msgstr "Démolit le bâtiment" - -msgid "Destroyer" -msgstr "Destructeur" - -msgid "Details\\Visual quality of 3D objects" -msgstr "Détails des objets\\Qualité des objets en 3D" - -msgid "Developed by :" -msgstr "Développé par :" - -msgid "Device\\Driver and resolution settings" -msgstr "Affichage\\Pilote et résolution d'affichage" - -msgid "Dividing by zero" -msgstr "Division par zéro" - -msgid "Do not use in this exercise" -msgstr "Interdit dans cet exercice" - -msgid "Do you really want to destroy the selected building?" -msgstr "Voulez-vous vraiment détruire le bâtiment sélectionné ?" - -#, c-format -msgid "Do you want to delete %s's saved games? " -msgstr "Voulez-vous détruire les sauvegardes de %s ?" - -msgid "Do you want to quit COLOBOT ?" -msgstr "Voulez-vous quitter COLOBOT ?" - -msgid "Doors blocked by a robot or another object " -msgstr "Portes bloquées par un robot ou un objet" - -msgid "Down (\\key gdown;)" -msgstr "Descend (\\key gdown;)" - -msgid "Drawer bot" -msgstr "Robot dessinateur" - -msgid "Dust\\Dust and dirt on bots and buildings" -msgstr "Salissures\\Salissures des robots et bâtiments" - -msgid "Dynamic lighting\\Mobile light sources" -msgstr "Lumières dynamiques\\Éclairages mobiles" - -msgid "Edit the selected program" -msgstr "Édite le programme sélectionné" - -msgid "Egg" -msgstr "Oeuf" - -msgid "End of block missing" -msgstr "Il manque la fin du bloc" - -msgid "Energy deposit (site for power station)" -msgstr "Emplacement pour station" - -msgid "Energy level" -msgstr "Niveau d'énergie" - -msgid "Engineer" -msgstr "Technicien" - -msgid "Error in instruction move" -msgstr "Déplacement impossible" - -msgid "Execute the selected program" -msgstr "Exécute le programme sélectionné" - -msgid "Execute/stop" -msgstr "Démarrer/stopper" - -msgid "Exercises\\Programming exercises" -msgstr "Programmation\\Exercices de programmation" - -msgid "Exit film\\Film at the exit of exercises" -msgstr "Retour animé\\Retour animé dans les exercices" - -msgid "Explosive" -msgstr "Explosif" - -msgid "Extend shield (\\key action;)" -msgstr "Déploie le bouclier (\\key action;)" - -msgid "Eyeglasses:" -msgstr "Lunettes :" - -msgid "Face type:" -msgstr "Type de visage :" - -msgid "File not open" -msgstr "Le fichier n'est pas ouvert" - -msgid "Filename:" -msgstr "Nom du fichier :" - -msgid "Film sequences\\Films before and after the missions" -msgstr "Séquences cinématiques\\Films avant ou après une mission" - -msgid "Finish" -msgstr "But" - -msgid "Fixed mine" -msgstr "Mine fixe" - -msgid "Flat ground not large enough" -msgstr "Sol plat pas assez grand" - -msgid "Fog\\Fog" -msgstr "Brouillard\\Nappes de brouillard" - -msgid "Folder:" -msgstr "Dans:" - -#, c-format -msgid "Folder: %s" -msgstr "Dossier: %s" - -msgid "Font size" -msgstr "Taille des caractères" - -msgid "Forward" -msgstr "Page suivante" - -msgid "Forward (\\key up;)" -msgstr "Avance (\\key up;)" - -msgid "Forward\\Moves forward" -msgstr "Avancer\\Moteur en avant" - -msgid "Found a site for a derrick" -msgstr "Emplacement pour derrick trouvé" - -msgid "Found a site for power station" -msgstr "Emplacement pour station trouvé" - -msgid "Found key A (site for derrick)" -msgstr "Emplacement pour derrick (clé A)" - -msgid "Found key B (site for derrick)" -msgstr "Emplacement pour derrick (clé B)" - -msgid "Found key C (site for derrick)" -msgstr "Emplacement pour derrick (clé C)" - -msgid "Found key D (site for derrick)" -msgstr "Emplacement pour derrick (clé D)" - -msgid "Free game" -msgstr "Jeu libre" - -msgid "Free game\\Free game without a specific goal" -msgstr "Jeu libre\\Jeu libre sans but précis" - -msgid "Friendly fire\\Your shooting can damage your own objects " -msgstr "Dégâts à soi-même\\Vos tirs infligent des dommages à vos unités" - -msgid "Full screen\\Full screen or window mode" -msgstr "Plein écran\\Plein écran ou fenêtré" - -msgid "Function already exists" -msgstr "Cette fonction existe déjà" - -msgid "Function name missing" -msgstr "Nom de la fonction attendu" - -msgid "Game speed" -msgstr "Vitesse du jeu" - -msgid "Game\\Game settings" -msgstr "Jeu\\Options de jouabilité" - -msgid "Gantry crane" -msgstr "Portique" - -#, c-format -msgid "GetResource event num out of range: %d\n" -msgstr "" - -msgid "Goto: destination occupied" -msgstr "Goto: Destination occupée" - -msgid "Goto: inaccessible destination" -msgstr "Chemin introuvable" - -msgid "Grab or drop (\\key action;)" -msgstr "Prend ou dépose (\\key action;)" - -msgid "Graphics\\Graphics settings" -msgstr "Graphique\\Options graphiques" - -msgid "Green" -msgstr "Vert" - -msgid "Green flag" -msgstr "Drapeau vert" - -msgid "Ground inappropriate" -msgstr "Terrain inadapté" - -msgid "Ground not flat enough" -msgstr "Sol pas assez plat" - -msgid "Hair color:" -msgstr "Couleur des cheveux :" - -msgid "Head\\Face and hair" -msgstr "Tête\\Visage et cheveux" - -msgid "Help about selected object" -msgstr "Instructions sur la sélection" - -msgid "Help balloons\\Explain the function of the buttons" -msgstr "Bulles d'aide\\Bulles explicatives" - -msgid "Highest\\Highest graphic quality (lowest frame rate)" -msgstr "Maxi\\Haute qualité (+ lent)" - -msgid "Home" -msgstr "Page initiale" - -msgid "Houston Mission Control" -msgstr "Centre de contrôle" - -msgid "Illegal object" -msgstr "Objet inaccessible" - -msgid "Impossible under water" -msgstr "Impossible sous l'eau" - -msgid "Impossible when carrying an object" -msgstr "Impossible en portant un objet" - -msgid "Impossible when flying" -msgstr "Impossible en vol" - -msgid "Impossible when moving" -msgstr "Impossible en mouvement" - -msgid "Impossible when swimming" -msgstr "Impossible en nageant" - -msgid "Inappropriate bot" -msgstr "Robot inadapté" - -msgid "Inappropriate cell type" -msgstr "Pas le bon type de pile" - -msgid "Incorrect index type" -msgstr "Mauvais type d'index" - -msgid "Infected by a virus; temporarily out of order" -msgstr "Infecté par un virus; ne fonctionne plus temporairement" - -msgid "Information exchange post" -msgstr "Borne d'information" - -msgid "Instruction \"break\" outside a loop" -msgstr "Instruction \"break\" en dehors d'une boucle" - -msgid "Instruction \"case\" missing" -msgstr "Manque une instruction \"case\"" - -msgid "Instruction \"case\" outside a block \"switch\"" -msgstr "Instruction \"case\" hors d'un bloc \"switch\"" - -msgid "Instruction \"else\" without corresponding \"if\" " -msgstr "Instruction \"else\" sans \"if\" correspondant" - -msgid "Instructions (\\key help;)" -msgstr "Instructions (\\key help;)" - -msgid "Instructions after the final closing brace" -msgstr "Instructions après la fin" - -msgid "Instructions for the mission (\\key help;)" -msgstr "Instructions sur la mission (\\key help;)" - -msgid "Instructions from Houston" -msgstr "Instructions de Houston" - -msgid "Instructions\\Shows the instructions for the current mission" -msgstr "Instructions mission\\Marche à suivre" - -msgid "Jet temperature" -msgstr "Température du réacteur" - -msgid "Key A" -msgstr "Clé A" - -msgid "Key B" -msgstr "Clé B" - -msgid "Key C" -msgstr "Clé C" - -msgid "Key D" -msgstr "Clé D" - -msgid "Key word help\\More detailed help about key words" -msgstr "Instructions mot-clé\\Explication sur le mot-clé" - -msgid "Keyword \"while\" missing" -msgstr "Manque le mot \"while\"" - -msgid "Keyword help(\\key cbot;)" -msgstr "Aide sur le mot-clé (\\key cbot;)" - -msgid "LOADING" -msgstr "CHARGEMENT" - -msgid "Legged grabber" -msgstr "Robot déménageur" - -msgid "Legged orga shooter" -msgstr "Robot orgaShooter" - -msgid "Legged shooter" -msgstr "Robot shooter" - -msgid "Legged sniffer" -msgstr "Robot renifleur" - -msgid "Lightning conductor" -msgstr "Paratonnerre" - -msgid "List of objects" -msgstr "Liste des objets" - -msgid "List of saved missions" -msgstr "Liste des missions enregistrées" - -msgid "Load a saved mission" -msgstr "Chargement d'une mission enregistrée" - -msgid "Load\\Load a saved mission" -msgstr "Charger\\Charger une mission enregistrée" - -msgid "Load\\Loads the selected mission" -msgstr "Charger\\Charger la mission sélectionnée" - -msgid "Lowest\\Minimum graphic quality (highest frame rate)" -msgstr "Mini\\Qualité minimale (+ rapide)" - -msgid "Lunar Roving Vehicle" -msgstr "Lunar Roving Vehicle" - -msgid "Marks on the ground\\Marks on the ground" -msgstr "Marques sur le sol\\Marques dessinées sur le sol" - -msgid "Maximize" -msgstr "Taille maximale" - -msgid "Menu (\\key quit;)" -msgstr "Menu (\\key quit;)" - -msgid "Minimize" -msgstr "Taille réduite" - -msgid "Mission name" -msgstr "Nom de la mission" - -msgid "Missions" -msgstr "Missions" - -msgid "Missions\\Select mission" -msgstr "Missions\\La grande aventure" - -msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" -msgstr "" -"Inversion souris X\\Inversion de la rotation lorsque la souris touche un bord" - -msgid "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis" -msgstr "" -"Inversion souris Y\\Inversion de la rotation lorsque la souris touche un bord" - -msgid "Mouse shadow\\Gives the mouse a shadow" -msgstr "Souris ombrée\\Jolie souris avec une ombre" - -msgid "Mute\\No sound" -msgstr "Silencieux\\Totalement silencieux" - -msgid "Name:" -msgstr "Nom:" - -msgid "Negative value rejected by \"throw\"" -msgstr "Valeur négative refusée pour \"throw\"" - -msgid "Nest" -msgstr "Nid" - -msgid "New" -msgstr "Nouveau" - -msgid "New ..." -msgstr "Nouveau ..." - -msgid "New bot available" -msgstr "Nouveau robot disponible" - -msgid "New player\\Choose player's name" -msgstr "Autre joueur\\Choix du nom du joueur" - -msgid "Next" -msgstr "Suivant" - -msgid "Next object\\Selects the next object" -msgstr "Sélectionner l'objet suivant\\Sélectionner l'objet suivant" - -msgid "No energy in the subsoil" -msgstr "Pas d'énergie en sous-sol" - -msgid "No flag nearby" -msgstr "Aucun drapeau à proximité" - -msgid "No function running" -msgstr "Pas de fonction en exécution" - -msgid "No function with this name accepts this kind of parameter" -msgstr "Aucune fonction de ce nom n'accepte ce(s) type(s) de paramètre(s)" - -msgid "No function with this name accepts this number of parameters" -msgstr "Aucune fonction de ce nom n'accepte ce nombre de paramètres" - -msgid "No information exchange post within range" -msgstr "Pas trouvé de borne d'information" - -msgid "No more energy" -msgstr "Plus d'énergie" - -msgid "No ore in the subsoil" -msgstr "Pas de minerai en sous-sol" - -msgid "No other robot" -msgstr "Pas d'autre robot" - -msgid "No power cell" -msgstr "Pas de pile" - -msgid "No titanium" -msgstr "Pas de titanium" - -msgid "No titanium around" -msgstr "Titanium inexistant" - -msgid "No titanium ore to convert" -msgstr "Pas de minerai de titanium à convertir" - -msgid "No titanium to transform" -msgstr "Pas de titanium à transformer" - -msgid "No uranium to transform" -msgstr "Pas d'uranium à transformer" - -msgid "Normal size" -msgstr "Taille normale" - -msgid "Normal\\Normal graphic quality" -msgstr "Normal\\Qualité standard" - -msgid "Normal\\Normal sound volume" -msgstr "Normal\\Niveaux normaux" - -msgid "Not enough energy" -msgstr "Pas assez d'énergie" - -msgid "Not enough energy yet" -msgstr "Pas encore assez d'énergie" - -msgid "Not yet enough energy" -msgstr "Pas encore assez d'énergie" - -msgid "Nothing to analyze" -msgstr "Rien à analyser" - -msgid "Nothing to drop" -msgstr "Rien à déposer" - -msgid "Nothing to grab" -msgstr "Rien à prendre" - -msgid "Nothing to recycle" -msgstr "Rien à recycler" - -msgid "Nuclear power cell" -msgstr "Pile nucléaire" - -msgid "Nuclear power cell available" -msgstr "Pile nucléaire disponible" - -msgid "Nuclear power station" -msgstr "Centrale nucléaire" - -msgid "Num of decorative objects\\Number of purely ornamental objects" -msgstr "Nb d'objets décoratifs\\Qualité d'objets non indispensables" - -msgid "Number missing" -msgstr "Un nombre est attendu" - -msgid "Number of insects detected" -msgstr "Nombre d'insectes détectés" - -msgid "Number of particles\\Explosions, dust, reflections, etc." -msgstr "Quantité de particules\\Explosions, poussières, reflets, etc." - -msgid "OK" -msgstr "D'accord" - -msgid "OK\\Choose the selected player" -msgstr "D'accord\\Choisir le joueur" - -msgid "OK\\Close program editor and return to game" -msgstr "D'accord\\Compiler le programme" - -msgid "Object not found" -msgstr "Objet n'existe pas" - -msgid "Object too close" -msgstr "Objet trop proche" - -msgid "One step" -msgstr "Un pas" - -msgid "Open" -msgstr "Ouvrir" - -msgid "Open (Ctrl+o)" -msgstr "Ouvrir (Ctrl+o)" - -msgid "Opening brace missing " -msgstr "Début d'un bloc attendu" - -msgid "Opening bracket missing" -msgstr "Il manque une parenthèse ouvrante" - -msgid "Operation impossible with value \"nan\"" -msgstr "Opération sur un \"nan\"" - -msgid "Options" -msgstr "Options" - -msgid "Options\\Preferences" -msgstr "Options\\Réglages" - -msgid "Organic matter" -msgstr "Matière organique" - -msgid "Origin of last message\\Shows where the last message was sent from" -msgstr "Montrer le lieu d'un message\\Montrer le lieu du dernier message" - -msgid "Parameters missing " -msgstr "Pas assez de paramètres" - -msgid "Particles in the interface\\Steam clouds and sparks in the interface" -msgstr "Particules dans l'interface\\Pluie de particules" - -msgid "Paste (Ctrl+v)" -msgstr "Coller (Ctrl+v)" - -msgid "Pause/continue" -msgstr "Pause/continuer" - -msgid "Phazer shooter" -msgstr "Robot phazer" - -msgid "Photography" -msgstr "Vue de la mission" - -msgid "Place occupied" -msgstr "Emplacement occupé" - -msgid "Planets and stars\\Astronomical objects in the sky" -msgstr "Planètes et étoiles\\Motifs mobiles dans le ciel" - -msgid "Plans for defense tower available" -msgstr "Construction d'une tour de défense possible" - -msgid "Plans for nuclear power plant available" -msgstr "Construction d'une centrale nucléaire possible" - -msgid "Plans for phazer shooter available" -msgstr "Fabrication d'un robot phazer possible" - -msgid "Plans for shielder available" -msgstr "Fabrication d'un robot bouclier possible" - -msgid "Plans for shooter available" -msgstr "Fabrication de robots shooter possible" - -msgid "Plans for thumper available" -msgstr "Fabrication d'un robot secoueur possible" - -msgid "Plans for tracked robots available " -msgstr "Fabrication d'un robot à chenilles possible" - -msgid "Plant a flag" -msgstr "Pose un drapeau de couleur" - -msgid "Play\\Start mission!" -msgstr "Jouer ...\\Démarrer l'action!" - -msgid "Player" -msgstr "Joueur" - -msgid "Player name" -msgstr "Nom du joueur" - -msgid "Player's name" -msgstr "Nom du joueur" - -msgid "Power cell" -msgstr "Pile normale" - -msgid "Power cell available" -msgstr "Pile disponible" - -msgid "Power cell factory" -msgstr "Fabrique de piles" - -msgid "Power station" -msgstr "Station de recharge" - -msgid "Practice bot" -msgstr "Robot d'entraînement" - -msgid "Press \\key help; to read instructions on your SatCom" -msgstr "Consultez votre SatCom en appuyant sur \\key help;" - -msgid "Previous" -msgstr "Précédent" - -msgid "Previous object\\Selects the previous object" -msgstr "Sélection précédente\\Sélectionne l'objet précédent" - -msgid "Previous selection (\\key desel;)" -msgstr "Sélection précédente (\\key desel;)" - -msgid "Private element" -msgstr "Elément protégé" - -msgid "Private\\Private folder" -msgstr "Privé\\Dossier privé" - -msgid "Program editor" -msgstr "Edition du programme" - -msgid "Program finished" -msgstr "Programme terminé" - -msgid "Program infected by a virus" -msgstr "Un programme est infecté par un virus" - -msgid "Programming exercises" -msgstr "Programmation" - -msgid "Programming help" -msgstr "Aide à la programmation" - -msgid "Programming help (\\key prog;)" -msgstr "Aide à la programmation (\\key prog;)" - -msgid "Programming help\\Gives more detailed help with programming" -msgstr "Instructions programmation\\Explication sur la programmation" - -msgid "Programs dispatched by Houston" -msgstr "Programmes envoyés par Houston" - -msgid "Proto\\Prototypes under development" -msgstr "Proto\\Prototypes en cours d'élaboration" - -msgid "Prototypes" -msgstr "Prototypes" - -msgid "Public required" -msgstr "Public requis" - -msgid "Public\\Common folder" -msgstr "Public\\Dossier commun à tous les joueurs" - -msgid "Quake at explosions\\The screen shakes at explosions" -msgstr "Secousses lors d'explosions\\L'écran vibre lors d'une explosion" - -msgid "Quit the mission?" -msgstr "Quitter la mission ?" - -msgid "Quit\\Quit COLOBOT" -msgstr "Quitter\\Quitter COLOBOT" - -msgid "Quit\\Quit the current mission or exercise" -msgstr "Quitter la mission en cours\\Terminer un exercice ou une mssion" - -msgid "Radar station" -msgstr "Radar" - -msgid "Read error" -msgstr "Erreur à la lecture" - -msgid "Recorder" -msgstr "Enregistreur" - -msgid "Recycle (\\key action;)" -msgstr "Recycle (\\key action;)" - -msgid "Recycler" -msgstr "Robot recycleur" - -msgid "Red" -msgstr "Rouge" - -msgid "Red flag" -msgstr "Drapeau rouge" - -msgid "Reflections on the buttons \\Shiny buttons" -msgstr "Reflets sur les boutons\\Boutons brillants" - -msgid "Remains of Apollo mission" -msgstr "Vestige d'une mission Apollo" - -msgid "Remove a flag" -msgstr "Enlève un drapeau" - -msgid "Repair center" -msgstr "Centre de réparation" - -msgid "Research center" -msgstr "Centre de recherches" - -msgid "Research program already performed" -msgstr "Recherche déjà effectuée" - -msgid "Research program completed" -msgstr "Recherche terminée" - -msgid "Reserved keyword of CBOT language" -msgstr "Ce mot est réservé" - -msgid "Resolution" -msgstr "Résolution" - -msgid "Restart\\Restart the mission from the beginning" -msgstr "Recommencer\\Recommencer la mission au début" - -msgid "Return to start" -msgstr "Remet au départ" - -msgid "Robbie" -msgstr "Robbie" - -msgid "Robbie\\Your assistant" -msgstr "Robbie\\Votre assistant" - -msgid "Ruin" -msgstr "Bâtiment en ruine" - -msgid "Run research program for defense tower" -msgstr "Recherche la tour de défense" - -msgid "Run research program for legged bots" -msgstr "Recherche les pattes" - -msgid "Run research program for nuclear power" -msgstr "Recherche le nucléaire" - -msgid "Run research program for orga shooter" -msgstr "Recherche le canon orgaShooter" - -msgid "Run research program for phazer shooter" -msgstr "Recherche le canon phazer" - -msgid "Run research program for shielder" -msgstr "Recherche le bouclier" - -msgid "Run research program for shooter" -msgstr "Recherche le canon shooter" - -msgid "Run research program for thumper" -msgstr "Recherche le secoueur" - -msgid "Run research program for tracked bots" -msgstr "Recherche les chenilles" - -msgid "Run research program for winged bots" -msgstr "Recherche les robots volants" - -msgid "SatCom" -msgstr "SatCom" - -msgid "Satellite report" -msgstr "Rapport du satellite" - -msgid "Save" -msgstr "Enregistrer" - -msgid "Save (Ctrl+s)" -msgstr "Enregistrer (Ctrl+s)" - -msgid "Save the current mission" -msgstr "Enregistrement de la mission en cours" - -msgid "Save\\Save the current mission " -msgstr "Enregistrer\\Enregistrer la mission en cours" - -msgid "Save\\Saves the current mission" -msgstr "Enregistrer\\Enregistrer la mission en cours" - -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Défilement dans les bords\\Défilement lorsque la souris touches les bords " -"gauche ou droite" - -msgid "Select the astronaut\\Selects the astronaut" -msgstr "Sélectionner le cosmonaute\\Sélectionner le cosmonaute" - -msgid "Semicolon terminator missing" -msgstr "Terminateur point-virgule non trouvé" - -msgid "Shadows\\Shadows on the ground" -msgstr "Ombres\\Ombres projetées au sol" - -msgid "Shield level" -msgstr "Niveau du bouclier" - -msgid "Shield radius" -msgstr "Rayon du bouclier" - -msgid "Shielder" -msgstr "Robot bouclier" - -msgid "Shift" -msgstr "Shift" - -msgid "Shoot (\\key action;)" -msgstr "Tir (\\key action;)" - -msgid "Show if the ground is flat" -msgstr "Montre si le sol est plat" - -msgid "Show the place" -msgstr "Montre l'endroit" - -msgid "Show the range" -msgstr "Montre le rayon d'action" - -msgid "Show the solution" -msgstr "Donne la solution" - -msgid "Sign \" : \" missing" -msgstr "Séparateur \" : \" attendu" - -msgid "Size 1" -msgstr "Taille 1" - -msgid "Size 2" -msgstr "Taille 2" - -msgid "Size 3" -msgstr "Taille 3" - -msgid "Size 4" -msgstr "Taille 4" - -msgid "Size 5" -msgstr "Taille 5" - -msgid "Sky\\Clouds and nebulae" -msgstr "Ciel\\Ciel et nuages" - -msgid "Sniff (\\key action;)" -msgstr "Cherche (\\key action;)" - -msgid "Solution" -msgstr "Solution" - -msgid "Sound effects:\\Volume of engines, voice, shooting, etc." -msgstr "Bruitages :\\Volume des moteurs, voix, etc." - -msgid "Sound\\Music and game sound volume" -msgstr "Son\\Volumes bruitages & musiques" - -msgid "Spaceship" -msgstr "Vaisseau spatial" - -msgid "Spaceship ruin" -msgstr "Epave de vaisseau spatial" - -msgid "Speed 1.0x\\Normal speed" -msgstr "Vitesse 1.0x\\Vitesse normale" - -msgid "Speed 1.5x\\1.5 times faster" -msgstr "Vitesse 1.5x\\Une fois et demi plus rapide" - -msgid "Speed 2.0x\\Double speed" -msgstr "Vitesse 2.0x\\Deux fois plus rapide" - -msgid "Speed 3.0x\\Three times faster" -msgstr "Vitesse 3.0x\\Trois fois plus rapide" - -msgid "Spider" -msgstr "Araignée" - -msgid "Spider fatally wounded" -msgstr "Araignée mortellement touchée" - -msgid "Stack overflow" -msgstr "Débordement de la pile" - -msgid "" -"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)" -msgstr "Action standard\\Action du bouton avec le cadre rouge" - -msgid "Standard controls\\Standard key functions" -msgstr "Tout réinitialiser\\Remet toutes les touches standards" - -msgid "Standard\\Standard appearance settings" -msgstr "Standard\\Remet les couleurs standards" - -msgid "Start" -msgstr "Départ" - -msgid "Still working ..." -msgstr "Travail en cours ..." - -msgid "String missing" -msgstr "Une chaîne de caractère est attendue" - -msgid "Strip color:" -msgstr "Couleur des bandes :" - -msgid "Subber" -msgstr "Robot sous-marin" - -msgid "Suit color:" -msgstr "Couleur de la combinaison :" - -msgid "Suit\\Astronaut suit" -msgstr "Corps\\Combinaison" - -msgid "Sunbeams\\Sunbeams in the sky" -msgstr "Rayons du soleil\\Rayons selon l'orientation" - -msgid "Survival kit" -msgstr "Sac de survie" - -msgid "Switch bots <-> buildings" -msgstr "Permute robots <-> bâtiments" - -msgid "Take off to finish the mission" -msgstr "Décolle pour terminer la mission" - -msgid "Target" -msgstr "Cible" - -msgid "Target bot" -msgstr "Cible d'entraînement" - -msgid "Textures\\Quality of textures " -msgstr "Qualité des textures\\Qualité des images" - -msgid "The expression must return a boolean value" -msgstr "L'expression doit ętre un boolean" - -msgid "The function returned no value " -msgstr "La fonction n'a pas retourné de résultat" - -msgid "" -"The list is only available if a \\l;radar station\\u object\\radar; is " -"working.\n" -msgstr "Liste non disponible sans \\l;radar\\u object\\radar;.\n" - -msgid "" -"The mission is not accomplished yet (press \\key help; for more details)" -msgstr "" -"La misssion n'est pas terminée (appuyez sur \\key help; pour plus de détails)" - -msgid "The types of the two operands are incompatible " -msgstr "Les deux opérandes ne sont pas de types compatibles" - -msgid "This class already exists" -msgstr "Cette classe existe déjà" - -msgid "This class does not exist" -msgstr "Cette classe n'existe pas" - -msgid "This is not a member of this class" -msgstr "Cet élément n'existe pas dans cette classe" - -msgid "This label does not exist" -msgstr "Cette étiquette n'existe pas" - -msgid "This object is not a member of a class" -msgstr "L'objet n'est pas une instance d'une classe" - -msgid "Thump (\\key action;)" -msgstr "Secoue (\\key action;)" - -msgid "Thumper" -msgstr "Robot secoueur" - -msgid "Titanium" -msgstr "Titanium" - -msgid "Titanium available" -msgstr "Titanium disponible" - -msgid "Titanium deposit (site for derrick)" -msgstr "Emplacement pour derrick (titanium)" - -msgid "Titanium ore" -msgstr "Minerai de titanium" - -msgid "Titanium too close" -msgstr "Titanium trop proche" - -msgid "Titanium too far away" -msgstr "Titanium trop loin" - -msgid "Too close to a building" -msgstr "Trop proche d'un bâtiment" - -msgid "Too close to an existing flag" -msgstr "Trop proche d'un drapeau existant" - -msgid "Too close to space ship" -msgstr "Trop proche du vaisseau spatial" - -msgid "Too many flags of this color (maximum 5)" -msgstr "Trop de drapeaux de cette couleur (maximum 5)" - -msgid "Too many parameters" -msgstr "Trop de paramètres" - -msgid "Tracked grabber" -msgstr "Robot déménageur" - -msgid "Tracked orga shooter" -msgstr "Robot orgaShooter" - -msgid "Tracked shooter" -msgstr "Robot shooter" - -msgid "Tracked sniffer" -msgstr "Robot renifleur" - -msgid "Transforms only titanium" -msgstr "Ne transforme que le titanium" - -msgid "Transforms only uranium" -msgstr "Ne transforme que l'uranium" - -msgid "Transmitted information" -msgstr "Informations diffusées" - -msgid "Turn left (\\key left;)" -msgstr "Tourne à gauche (\\key left;)" - -msgid "Turn left\\turns the bot to the left" -msgstr "Tourner à gauche\\Moteur à gauche" - -msgid "Turn right (\\key right;)" -msgstr "Tourne à droite (\\key right;)" - -msgid "Turn right\\turns the bot to the right" -msgstr "Tourner à droite\\Moteur à droite" - -msgid "Type declaration missing" -msgstr "Déclaration de type attendu" - -msgid "Undo (Ctrl+z)" -msgstr "Annuler (Ctrl+z)" - -msgid "Unit" -msgstr "Unité" - -msgid "Unknown Object" -msgstr "Objet n'existe pas" - -msgid "Unknown command" -msgstr "Commande inconnue" - -msgid "Unknown function" -msgstr "Routine inconnue" - -msgid "Up (\\key gup;)" -msgstr "Monte (\\key gup;)" - -msgid "Uranium deposit (site for derrick)" -msgstr "Emplacement pour derrick (uranium)" - -msgid "Uranium ore" -msgstr "Minerai d'uranium" - -msgid "Use a joystick\\Joystick or keyboard" -msgstr "Utilise un joystick\\Joystick ou clavier" - -msgid "User levels" -msgstr "Niveaux supplémentaires" - -msgid "User\\User levels" -msgstr "Suppl.\\Niveaux supplémentaires" - -msgid "Variable name missing" -msgstr "Nom d'une variable attendu" - -msgid "Variable not declared" -msgstr "Variable non déclarée" - -msgid "Variable not initialized" -msgstr "Variable non initialisée" - -msgid "Vault" -msgstr "Coffre-fort" - -msgid "Violet flag" -msgstr "Drapeau violet" - -msgid "Void parameter" -msgstr "Paramètre void" - -msgid "Wasp" -msgstr "Guępe" - -msgid "Wasp fatally wounded" -msgstr "Guępe mortellement touchée" - -msgid "Waste" -msgstr "Déchet" - -msgid "Wheeled grabber" -msgstr "Robot déménageur" - -msgid "Wheeled orga shooter" -msgstr "Robot orgaShooter" - -msgid "Wheeled shooter" -msgstr "Robot shooter" - -msgid "Wheeled sniffer" -msgstr "Robot renifleur" - -msgid "Win" -msgstr "Gagné" - -msgid "Winged grabber" -msgstr "Robot déménageur" - -msgid "Winged orga shooter" -msgstr "Robot orgaShooter" - -msgid "Winged shooter" -msgstr "Robot shooter" - -msgid "Winged sniffer" -msgstr "Robot renifleur" - -msgid "Withdraw shield (\\key action;)" -msgstr "Stoppe le bouclier (\\key action;)" - -msgid "Worm" -msgstr "Ver" - -msgid "Worm fatally wounded" -msgstr "Ver mortellement touché" - -msgid "Wreckage" -msgstr "Epave de robot" - -msgid "Write error" -msgstr "Erreur à l'écriture" - -msgid "Wrong type for the assignment" -msgstr "Mauvais type de résultat pour l'assignation" - -msgid "Yellow flag" -msgstr "Drapeau jaune" - -msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)" -msgstr "" -"Il est possible de voler avec les touches (\\key gup;) et (\\key gdown;)" - -msgid "You can not carry a radioactive object" -msgstr "Vous ne pouvez pas transporter un objet radioactif" - -msgid "You can not carry an object under water" -msgstr "Vous ne pouvez pas transporter un objet sous l'eau" - -msgid "You found a usable object" -msgstr "Vous avez trouvé un objet utilisable" - -msgid "You must get on the spaceship to take off " -msgstr "Vous devez embarquer pour pouvoir décoller" - -msgid "Zoom mini-map" -msgstr "Zoom mini-carte" - -msgid "\\Blue flags" -msgstr "\\Drapeaux bleus" - -msgid "\\Eyeglasses 1" -msgstr "\\Lunettes 1" - -msgid "\\Eyeglasses 2" -msgstr "\\Lunettes 2" - -msgid "\\Eyeglasses 3" -msgstr "\\Lunettes 3" - -msgid "\\Eyeglasses 4" -msgstr "\\Lunettes 4" - -msgid "\\Eyeglasses 5" -msgstr "\\Lunettes 5" - -msgid "\\Face 1" -msgstr "\\Visage 1" - -msgid "\\Face 2" -msgstr "\\Visage 2" - -msgid "\\Face 3" -msgstr "\\Visage 3" - -msgid "\\Face 4" -msgstr "\\Visage 4" - -msgid "\\Green flags" -msgstr "\\Drapeaux verts" - -msgid "\\New player name" -msgstr "\\Nom du joueur à créer" - -msgid "\\No eyeglasses" -msgstr "\\Pas de lunettes" - -msgid "\\Raise the pencil" -msgstr "\\Relève le crayon" - -msgid "\\Red flags" -msgstr "\\Drapeaux rouges" - -msgid "\\Return to COLOBOT" -msgstr "\\Retourner dans COLOBOT" - -msgid "\\SatCom on standby" -msgstr "\\Mettre le SatCom en veille" - -msgid "\\Start recording" -msgstr "\\Démarre l'enregistrement" - -msgid "\\Stop recording" -msgstr "\\Stoppe l'enregistrement" - -msgid "\\Turn left" -msgstr "\\Rotation à gauche" - -msgid "\\Turn right" -msgstr "\\Rotation à droite" - -msgid "\\Use the black pencil" -msgstr "\\Abaisse le crayon noir" - -msgid "\\Use the blue pencil" -msgstr "\\Abaisse le crayon bleu" - -msgid "\\Use the brown pencil" -msgstr "\\Abaisse le crayon brun" - -msgid "\\Use the green pencil" -msgstr "\\Abaisse le crayon vert" - -msgid "\\Use the orange pencil" -msgstr "\\Abaisse le crayon orange" - -msgid "\\Use the purple pencil" -msgstr "\\Abaisse le crayon violet" - -msgid "\\Use the red pencil" -msgstr "\\Abaisse le crayon rouge" - -msgid "\\Use the yellow pencil" -msgstr "\\Abaisse le crayon jaune" - -msgid "\\Violet flags" -msgstr "\\Drapeaux violets" - -msgid "\\Yellow flags" -msgstr "\\Drapeaux jaunes" - -msgid "\\b;Aliens\n" -msgstr "\\b;Listes des ennemis\n" - -msgid "\\b;Buildings\n" -msgstr "\\b;Listes des bâtiments\n" - -msgid "\\b;Error\n" -msgstr "\\b;Erreur\n" - -msgid "\\b;List of objects\n" -msgstr "\\b;Listes des objets\n" - -msgid "\\b;Moveable objects\n" -msgstr "\\b;Listes des objets transportables\n" - -msgid "\\b;Robots\n" -msgstr "\\b;Listes des robots\n" - -msgid "\\c; (none)\\n;\n" -msgstr "\\c; (aucun)\\n;\n" - -msgid "action;" -msgstr "" - -msgid "away;" -msgstr "" - -msgid "camera;" -msgstr "" - -msgid "cbot;" -msgstr "" - -msgid "desel;" -msgstr "" - -msgid "down;" -msgstr "" - -msgid "gdown;" -msgstr "" - -msgid "gup;" -msgstr "" - -msgid "help;" -msgstr "" - -msgid "human;" -msgstr "" - -msgid "left;" -msgstr "" - -msgid "near;" -msgstr "" - -msgid "next;" -msgstr "" - -msgid "prog;" -msgstr "" - -msgid "quit;" -msgstr "" - -msgid "right;" -msgstr "" - -msgid "speed10;" -msgstr "" - -msgid "speed15;" -msgstr "" - -msgid "speed20;" -msgstr "" - -msgid "up;" -msgstr "" - -msgid "visit;" -msgstr "" - -msgid "www.epsitec.com" -msgstr "www.epsitec.com" - -#~ msgid "< none >" -#~ msgstr "< aucune >" - -#~ msgid "<--" -#~ msgstr "<--" - -#~ msgid "Application key" -#~ msgstr "Application key" - -#~ msgid "Arrow down" -#~ msgstr "Flèche Bas" - -#~ msgid "Arrow left" -#~ msgstr "Flèche Gauche" - -#~ msgid "Arrow right" -#~ msgstr "Flèche Droite" - -#~ msgid "Arrow up" -#~ msgstr "Flèche Haut" - -#~ msgid "Attn" -#~ msgstr "Attn" - -#~ msgid "Caps Lock" -#~ msgstr "Caps Lock" - -#~ msgid "Clear" -#~ msgstr "Clear" - -#~ msgid "Control-break" -#~ msgstr "Control-break" - -#~ msgid "CrSel" -#~ msgstr "CrSel" - -#~ msgid "Delete Key" -#~ msgstr "Delete" - -#~ msgid "Dictionnary" -#~ msgstr "Dictionnaire anglais-français" - -#~ msgid "Disintegrator" -#~ msgstr "Désintégrateur" - -#~ msgid "End" -#~ msgstr "End" - -#~ msgid "Enter" -#~ msgstr "Entrée" - -#~ msgid "Erase EOF" -#~ msgstr "Erase EOF" - -#~ msgid "Error" -#~ msgstr "Erreur" - -#~ msgid "Esc" -#~ msgstr "Esc" - -#~ msgid "ExSel" -#~ msgstr "ExSel" - -#~ msgid "Execute" -#~ msgstr "Execute" - -#~ msgid "F1" -#~ msgstr "F1" - -#~ msgid "F10" -#~ msgstr "F10" - -#~ msgid "F11" -#~ msgstr "F11" - -#~ msgid "F12" -#~ msgstr "F12" - -#~ msgid "F13" -#~ msgstr "F13" - -#~ msgid "F14" -#~ msgstr "F14" - -#~ msgid "F15" -#~ msgstr "F15" - -#~ msgid "F16" -#~ msgstr "F16" - -#~ msgid "F17" -#~ msgstr "F17" - -#~ msgid "F18" -#~ msgstr "F18" - -#~ msgid "F19" -#~ msgstr "F19" - -#~ msgid "F2" -#~ msgstr "F2" - -#~ msgid "F20" -#~ msgstr "F20" - -#~ msgid "F3" -#~ msgstr "F3" - -#~ msgid "F4" -#~ msgstr "F4" - -#~ msgid "F5" -#~ msgstr "F5" - -#~ msgid "F6" -#~ msgstr "F6" - -#~ msgid "F7" -#~ msgstr "F7" - -#~ msgid "F8" -#~ msgstr "F8" - -#~ msgid "F9" -#~ msgstr "F9" - -#~ msgid "Help" -#~ msgstr "Help" - -#~ msgid "Home Key" -#~ msgstr "Home" - -#~ msgid "Insert" -#~ msgstr "Insert" - -#~ msgid "Left Windows" -#~ msgstr "Left Windows" - -#~ msgid "Mini-map" -#~ msgstr "Mini-carte" - -#~ msgid "Num Lock" -#~ msgstr "Num Lock" - -#~ msgid "NumPad *" -#~ msgstr "NumPad *" - -#~ msgid "NumPad +" -#~ msgstr "NumPad +" - -#~ msgid "NumPad -" -#~ msgstr "NumPad -" - -#~ msgid "NumPad ." -#~ msgstr "NumPad ." - -#~ msgid "NumPad /" -#~ msgstr "NumPad /" - -#~ msgid "NumPad 0" -#~ msgstr "NumPad 0" - -#~ msgid "NumPad 1" -#~ msgstr "NumPad 1" - -#~ msgid "NumPad 2" -#~ msgstr "NumPad 2" - -#~ msgid "NumPad 3" -#~ msgstr "NumPad 3" - -#~ msgid "NumPad 4" -#~ msgstr "NumPad 4" - -#~ msgid "NumPad 5" -#~ msgstr "NumPad 5" - -#~ msgid "NumPad 6" -#~ msgstr "NumPad 6" - -#~ msgid "NumPad 7" -#~ msgstr "NumPad 7" - -#~ msgid "NumPad 8" -#~ msgstr "NumPad 8" - -#~ msgid "NumPad 9" -#~ msgstr "NumPad 9" - -#~ msgid "NumPad sep" -#~ msgstr "NumPad sep" - -#~ msgid "PA1" -#~ msgstr "PA1" - -#~ msgid "Page Down" -#~ msgstr "Page Down" - -#~ msgid "Page Up" -#~ msgstr "Page Up" - -#~ msgid "Pause" -#~ msgstr "Pause" - -#~ msgid "Play" -#~ msgstr "Play" - -#~ msgid "Print Scrn" -#~ msgstr "Print Scrn" - -#~ msgid "Right Windows" -#~ msgstr "Right Windows" - -#~ msgid "Scroll" -#~ msgstr "Scroll" - -#~ msgid "Select" -#~ msgstr "Select" - -#~ msgid "Space" -#~ msgstr "Espace" - -#~ msgid "Tab" -#~ msgstr "Tab" - -#~ msgid "Wheel down" -#~ msgstr "Molette bas" - -#~ msgid "Wheel up" -#~ msgstr "Molette haut" - -#~ msgid "Zoom" -#~ msgstr "Zoom" - diff --git a/src/po/pl.po b/src/po/pl.po deleted file mode 100644 index 4cbfe60..0000000 --- a/src/po/pl.po +++ /dev/null @@ -1,2066 +0,0 @@ -msgid "" -msgstr "" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 17:09+0100\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " -"|| n%100>=20) ? 1 : 2);\n" -"X-Language: pl_PL\n" -"X-Source-Language: en_US\n" - -msgid " " -msgstr " " - -msgid " Challenges in the chapter:" -msgstr " Wyzwania w tym rozdziale:" - -msgid " Chapters:" -msgstr " Rozdziały:" - -msgid " Drivers:" -msgstr " Sterowniki:" - -msgid " Exercises in the chapter:" -msgstr " Ćwiczenia w tym rozdziale:" - -msgid " Free game on this chapter:" -msgstr " Prototypy na tej planecie:" - -msgid " Free game on this planet:" -msgstr " Swobodna gra na tej planecie:" - -msgid " Missions on this level:" -msgstr " Misje na tym poziomie:" - -msgid " Missions on this planet:" -msgstr " Misje na tej planecie:" - -msgid " Planets:" -msgstr " Planety:" - -msgid " Prototypes on this planet:" -msgstr " Prototypy na tej planecie:" - -msgid " Resolution:" -msgstr " Rozdzielczość:" - -msgid " Summary:" -msgstr " Streszczenie:" - -msgid " User levels:" -msgstr " Poziomy użytkownika:" - -msgid " or " -msgstr " lub " - -msgid "\" [ \" expected" -msgstr "Oczekiwane \" [ \"" - -msgid "\" ] \" missing" -msgstr "Brak \" ] \"" - -#, c-format -msgid "\"%s\" missing in this exercise" -msgstr "It misses \"%s\" in this exercise" - -msgid "%1" -msgstr "" - -msgid "..behind" -msgstr "..za" - -msgid "..in front" -msgstr "..przed" - -msgid "..power cell" -msgstr "..ogniwo elektryczne" - -msgid "1) First click on the key you want to redefine." -msgstr "1) Najpierw kliknij klawisz, który chcesz przedefiniować." - -msgid "2) Then press the key you want to use instead." -msgstr "2) Następnie naciśnij klawisz, którego chcesz używać." - -msgid "3D sound\\3D positioning of the sound" -msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków" - -msgid "<< Back \\Back to the previous screen" -msgstr "<< Wstecz \\Wraca do poprzedniego ekranu" - -#, fuzzy -msgid "<<< Sorry; mission failed >>>" -msgstr "<<< Niestety, misja nie powiodła się >>>" - -#, fuzzy -msgid "<<< Well done; mission accomplished >>>" -msgstr "<<< Dobra robota, misja wypełniona >>>" - -#, fuzzy -msgid "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\"" -msgstr "Po etykiecie musi wystąpić \"for\", \"while\", \"do\" lub \"switch\"" - -msgid "A variable can not be declared twice" -msgstr "Zmienna nie może być zadeklarowana dwukrotnie" - -msgid "Abort\\Abort the current mission" -msgstr "Przerwij\\Przerywa bieżącą misję" - -msgid "Access beyond array limit" -msgstr "Dostęp poza tablicę" - -msgid "" -"Access to solution\\Shows the solution (detailed instructions for missions)" -msgstr "" -"Dostęp do rozwiązania\\Pokazuje rozwiązanie (szczegółowe instrukcje " -"dotyczące misji)" - -msgid "Access to solutions\\Show program \"4: Solution\" in the exercises" -msgstr "Accčs aux solutions\\Programme \"4: Solution\" dans les exercices" - -msgid "Alien Queen" -msgstr "Królowa Obcych" - -msgid "Alien Queen killed" -msgstr "Królowa Obcych została zabita" - -msgid "Already carrying something" -msgstr "Nie można nieść więcej przedmiotów" - -msgid "Alt" -msgstr "Alt" - -msgid "Analysis already performed" -msgstr "Analiza została już wykonana" - -msgid "Analysis performed" -msgstr "Analiza wykonana" - -msgid "Analyzes only organic matter" -msgstr "Analizuje jedynie materię organiczną" - -msgid "Ant" -msgstr "Mrówka" - -msgid "Ant fatally wounded" -msgstr "Mrówka śmiertelnie raniona" - -msgid "Appearance\\Choose your appearance" -msgstr "Wygląd\\Wybierz swoją postać" - -msgid "Apply changes\\Activates the changed settings" -msgstr "Zastosuj zmiany\\Aktywuje zmienione ustawienia" - -msgid "Appropriate constructor missing" -msgstr "Brak odpowiedniego konstruktora" - -msgid "Assignment impossible" -msgstr "Przypisanie niemożliwe" - -msgid "Autolab" -msgstr "Laboratorium" - -msgid "Automatic indent\\When program editing" -msgstr "Automatyczne wcięcia\\Automatyczne wcięcia podczas edycji programu" - -msgid "Back" -msgstr "Wstecz" - -msgid "Background sound :\\Volume of audio tracks on the CD" -msgstr "Muzyka w tle :\\Głośność ścieżek dźwiękowych z płyty CD" - -msgid "Backward (\\key down;)" -msgstr "Cofnij (\\key down;)" - -msgid "Backward\\Moves backward" -msgstr "Wstecz\\Porusza do tyłu" - -msgid "Bad argument for \"new\"" -msgstr "Zły argument dla funkcji \"new\"" - -msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces" -msgstr "" -"Duże wcięcie\\2 lub 4 spacje wcięcia na każdy poziom zdefiniowany przez " -"klamry" - -msgid "Black box" -msgstr "Czarna skrzynka" - -msgid "Blue" -msgstr "Niebieski" - -msgid "Blue flag" -msgstr "Niebieska flaga" - -msgid "Bot destroyed" -msgstr "Robot zniszczony" - -msgid "Bot factory" -msgstr "Fabryka robotów" - -msgid "Build a bot factory" -msgstr "Zbuduj fabrykę robotów" - -msgid "Build a converter" -msgstr "Zbuduj hutę" - -msgid "Build a defense tower" -msgstr "Zbuduj wieżę obronną" - -msgid "Build a derrick" -msgstr "Zbuduj kopalnię" - -msgid "Build a exchange post" -msgstr "Zbuduj stację przekaźnikową" - -msgid "Build a legged grabber" -msgstr "Zbuduj transporter na nogach" - -msgid "Build a legged orga shooter" -msgstr "Zbuduj działo organiczne na nogach" - -msgid "Build a legged shooter" -msgstr "Zbuduj działo na nogach" - -msgid "Build a legged sniffer" -msgstr "Zbuduj szperacz na nogach" - -msgid "Build a lightning conductor" -msgstr "Zbuduj odgromnik" - -msgid "Build a nuclear power plant" -msgstr "Zbuduj elektrownię atomową" - -msgid "Build a phazer shooter" -msgstr "Zbuduj działo fazowe" - -msgid "Build a power cell factory" -msgstr "Zbuduj fabrykę ogniw elektrycznych" - -msgid "Build a power station" -msgstr "Zbuduj elektrownię" - -msgid "Build a radar station" -msgstr "Zbuduj stację radarową" - -msgid "Build a recycler" -msgstr "Zbuduj robota recyklera" - -msgid "Build a repair center" -msgstr "Zbuduj warsztat" - -msgid "Build a research center" -msgstr "Zbuduj centrum badawcze" - -msgid "Build a shielder" -msgstr "Zbuduj robota osłaniajacza" - -msgid "Build a subber" -msgstr "Zbuduj robota nurka" - -msgid "Build a thumper" -msgstr "Zbuduj robota uderzacza" - -msgid "Build a tracked grabber" -msgstr "Zbuduj transporter na gąsienicach" - -msgid "Build a tracked orga shooter" -msgstr "Zbuduj działo organiczne na gąsienicach" - -msgid "Build a tracked shooter" -msgstr "Zbuduj działo na gąsienicach" - -msgid "Build a tracked sniffer" -msgstr "Zbuduj szperacz na gąsienicach" - -msgid "Build a wheeled grabber" -msgstr "Zbuduj transporter na kołach" - -msgid "Build a wheeled orga shooter" -msgstr "Zbuduj działo organiczne na kołach" - -msgid "Build a wheeled shooter" -msgstr "Zbuduj działo na kołach" - -msgid "Build a wheeled sniffer" -msgstr "Zbuduj szperacz na kołach" - -msgid "Build a winged grabber" -msgstr "Zbuduj transporter latający" - -msgid "Build a winged orga shooter" -msgstr "Zbuduj latające działo organiczne" - -msgid "Build a winged shooter" -msgstr "Zbuduj działo latające" - -msgid "Build a winged sniffer" -msgstr "Zbuduj szperacz latający" - -msgid "Build an autolab" -msgstr "Zbuduj laboratorium" - -msgid "Building completed" -msgstr "Budowa zakończona" - -msgid "Building destroyed" -msgstr "Budynek zniszczony" - -msgid "Building too close" -msgstr "Budynek za blisko" - -msgid "Button %1" -msgstr "Przycisk %1" - -msgid "COLOBOT" -msgstr "COLOBOT" - -msgid "Calling an unknown function" -msgstr "Odwołanie do nieznanej funkcji" - -msgid "Camera (\\key camera;)" -msgstr "Kamera (\\key camera;)" - -msgid "Camera awayest" -msgstr "Camera awayest" - -msgid "Camera back\\Moves the camera backward" -msgstr "Kamera dalej\\Oddala kamerę" - -msgid "Camera closer\\Moves the camera forward" -msgstr "Kamera bliżej\\Przybliża kamerę" - -msgid "Camera nearest" -msgstr "Camera nearest" - -msgid "Camera to left" -msgstr "Camera to left" - -msgid "Camera to right" -msgstr "Camera to right" - -#, fuzzy -msgid "Can not create this; there are too many objects" -msgstr "Nie można tego utworzyć, za dużo obiektów" - -msgid "Can't open file" -msgstr "Nie można otworzyć pliku" - -msgid "Cancel" -msgstr "Anuluj" - -msgid "Cancel\\Cancel all changes" -msgstr "Anuluj\\Pomija wszystkie zmiany" - -msgid "Cancel\\Keep current player name" -msgstr "Anuluj\\Zachowuje bieżące imię gracza" - -msgid "Challenges" -msgstr "Wyzwania" - -msgid "Challenges\\Programming challenges" -msgstr "Wyzwania\\Wyzwania programistyczne" - -msgid "Change camera\\Switches between onboard camera and following camera" -msgstr "Zmień kamerę\\Przełącza pomiędzy kamerą pokładową i śledzącą" - -msgid "Checkpoint" -msgstr "Punkt kontrolny" - -msgid "Checkpoint crossed" -msgstr "Przekroczono punkt kontrolny" - -msgid "Climb\\Increases the power of the jet" -msgstr "W górę\\Zwiększa moc silnika" - -msgid "Close" -msgstr "Zamknij" - -msgid "Closing bracket missing " -msgstr "Brak nawiasu zamykającego" - -msgid "Colobot rules!" -msgstr "Colobot rządzi!" - -msgid "Command line" -msgstr "Linia polecenia" - -msgid "Compass" -msgstr "Kompas" - -msgid "Compilation ok (0 errors)" -msgstr "Program skompilowany (0 błędów)" - -msgid "Compile" -msgstr "Kompiluj" - -msgid "Continue" -msgstr "Kontynuuj" - -msgid "Continue\\Continue the current mission" -msgstr "Kontynuuj\\Kontynuuje bieżącą misję" - -msgid "Continue\\Continue the game" -msgstr "Kontynuuj\\Kontynuuje grę" - -msgid "Controls\\Keyboard, joystick and mouse settings" -msgstr "Sterowanie\\Ustawienia klawiatury, joysticka i myszy" - -msgid "Converts ore to titanium" -msgstr "Przetop rudę na tytan" - -msgid "Copy" -msgstr "Kopiuj" - -msgid "Copy (Ctrl+c)" -msgstr "Kopiuj (Ctrl+C)" - -msgid "Ctrl" -msgstr "Ctrl" - -msgid "Current mission saved" -msgstr "Bieżąca misja zapisana" - -msgid "Customize your appearance" -msgstr "Dostosuj wygląd" - -msgid "Cut (Ctrl+x)" -msgstr "Wytnij (Ctrl+X)" - -msgid "Defense tower" -msgstr "Wieża obronna" - -msgid "Delete" -msgstr "Usuń" - -msgid "Delete player\\Deletes the player from the list" -msgstr "Usuń gracza\\Usuwa gracza z listy" - -msgid "Delete\\Deletes the selected file" -msgstr "Usuń\\Usuwa zaznaczony plik" - -msgid "Depth of field\\Maximum visibility" -msgstr "Głębokość pola\\Maksymalna widoczność" - -msgid "Derrick" -msgstr "Kopalnia" - -msgid "Descend\\Reduces the power of the jet" -msgstr "W dół\\Zmniejsza moc silnika" - -msgid "Destroy the building" -msgstr "Zniszcz budynek" - -msgid "Destroyer" -msgstr "Destroyer" - -msgid "Details\\Visual quality of 3D objects" -msgstr "Szczegóły\\Jakość wizualna obiektów 3D" - -msgid "Developed by :" -msgstr "Twórcy:" - -msgid "Device\\Driver and resolution settings" -msgstr "Urządzenie\\Ustawienia sterownika i rozdzielczości" - -msgid "Dividing by zero" -msgstr "Dzielenie przez zero" - -msgid "Do not use in this exercise" -msgstr "Do not use in this exercise" - -msgid "Do you really want to destroy the selected building?" -msgstr "Czy na pewno chcesz zniszczyć zaznaczony budynek?" - -#, c-format -msgid "Do you want to delete %s's saved games? " -msgstr "Czy na pewno chcesz skasować zapisane gry gracza %s? " - -msgid "Do you want to quit COLOBOT ?" -msgstr "Czy na pewno chcesz opuścić grę COLOBOT?" - -msgid "Doors blocked by a robot or another object " -msgstr "Drzwi zablokowane przez robota lub inny obiekt " - -msgid "Down (\\key gdown;)" -msgstr "Dół (\\key gdown;)" - -msgid "Drawer bot" -msgstr "Drawer bot" - -msgid "Dust\\Dust and dirt on bots and buildings" -msgstr "Kurz\\Kurz i bród na robotach i budynkach" - -msgid "Dynamic lighting\\Mobile light sources" -msgstr "Dynamiczne oświetlenie\\Ruchome źródła światła" - -msgid "Edit the selected program" -msgstr "Edytuj zaznaczony program" - -msgid "Egg" -msgstr "Jajo" - -msgid "End of block missing" -msgstr "Brak końca bloku" - -msgid "Energy deposit (site for power station)" -msgstr "Źródło energii (miejsce na elektrownię)" - -msgid "Energy level" -msgstr "Poziom energii" - -msgid "Engineer" -msgstr "Inżynier" - -msgid "Error in instruction move" -msgstr "Błąd w poleceniu ruchu" - -msgid "Execute the selected program" -msgstr "Wykonaj zaznaczony program" - -msgid "Execute/stop" -msgstr "Wykonaj/Zatrzymaj" - -msgid "Exercises\\Programming exercises" -msgstr "Ćwiczenia\\Ćwiczenia programistyczne" - -msgid "Exit film\\Film at the exit of exercises" -msgstr "Końcowy film\\Film na zakończenie ćwiczeń" - -msgid "Explosive" -msgstr "Materiały wybuchowe" - -msgid "Extend shield (\\key action;)" -msgstr "Rozszerz osłonę (\\key action;)" - -msgid "Eyeglasses:" -msgstr "Okulary:" - -msgid "Face type:" -msgstr "Rodzaj twarzy:" - -msgid "File not open" -msgstr "Plik nie jest otwarty" - -msgid "Filename:" -msgstr "Nazwa pliku:" - -msgid "Film sequences\\Films before and after the missions" -msgstr "Sekwencje filmowe\\Filmy przed rozpoczęciem i na zakończenie misji" - -msgid "Finish" -msgstr "Koniec" - -msgid "Fixed mine" -msgstr "Mina" - -msgid "Flat ground not large enough" -msgstr "Za mało płaskiego terenu" - -msgid "Fog\\Fog" -msgstr "Mgła\\Mgła" - -msgid "Folder:" -msgstr "Folder:" - -#, c-format -msgid "Folder: %s" -msgstr "Folder: %s" - -msgid "Font size" -msgstr "Wielkość czcionki" - -msgid "Forward" -msgstr "Naprzód" - -msgid "Forward (\\key up;)" -msgstr "Naprzód (\\key up;)" - -msgid "Forward\\Moves forward" -msgstr "Naprzód\\Porusza do przodu" - -msgid "Found a site for a derrick" -msgstr "Znaleziono miejsce na kopalnię" - -msgid "Found a site for power station" -msgstr "Znaleziono miejsce na elektrownię" - -msgid "Found key A (site for derrick)" -msgstr "Znaleziono klucz A (miejsce na kopalnię)" - -msgid "Found key B (site for derrick)" -msgstr "Znaleziono klucz B (miejsce na kopalnię)" - -msgid "Found key C (site for derrick)" -msgstr "Znaleziono klucz C (miejsce na kopalnię)" - -msgid "Found key D (site for derrick)" -msgstr "Znaleziono klucz D (miejsce na kopalnię)" - -msgid "Free game" -msgstr "Swobodna gra" - -msgid "Free game\\Free game without a specific goal" -msgstr "Swobodna gra\\Swobodna gra bez konkretnych celów" - -msgid "Friendly fire\\Your shooting can damage your own objects " -msgstr "Przyjacielski ogień\\Własne strzały uszkadzają Twoje obiekty" - -msgid "Full screen\\Full screen or window mode" -msgstr "Pełny ekran\\Pełny ekran lub tryb okna" - -msgid "Function already exists" -msgstr "Funkcja już istnieje" - -msgid "Function name missing" -msgstr "Brakująca nazwa funkcji" - -msgid "Game speed" -msgstr "Prędkość gry" - -msgid "Game\\Game settings" -msgstr "Gra\\Ustawienia gry" - -msgid "Gantry crane" -msgstr "Żuraw przesuwalny" - -#, c-format -msgid "GetResource event num out of range: %d\n" -msgstr "" - -msgid "Goto: destination occupied" -msgstr "Goto: miejsce docelowe zajęte" - -msgid "Goto: inaccessible destination" -msgstr "Goto: miejsce docelowe niedostępne" - -msgid "Grab or drop (\\key action;)" -msgstr "Podnieś lub upuść (\\key action;)" - -msgid "Graphics\\Graphics settings" -msgstr "Grafika\\Ustawienia grafiki" - -msgid "Green" -msgstr "Zielony" - -msgid "Green flag" -msgstr "Zielona flaga" - -msgid "Ground inappropriate" -msgstr "Nieodpowiedni teren" - -msgid "Ground not flat enough" -msgstr "Powierzchnia nie jest wystarczająco płaska" - -msgid "Hair color:" -msgstr "Kolor włosów:" - -msgid "Head\\Face and hair" -msgstr "Głowa\\Twarz i włosy" - -msgid "Help about selected object" -msgstr "Pomoc na temat zaznaczonego obiektu" - -msgid "Help balloons\\Explain the function of the buttons" -msgstr "Dymki pomocy\\Wyjaśnia funkcje przycisków" - -msgid "Highest\\Highest graphic quality (lowest frame rate)" -msgstr "" -"Najwyższa\\Maksymalna jakość grafiki (najniższa częstotliwość odświeżania)" - -msgid "Home" -msgstr "Początek" - -msgid "Houston Mission Control" -msgstr "Centrum Kontroli Misji w Houston" - -msgid "Illegal object" -msgstr "Nieprawidłowy obiekt" - -msgid "Impossible under water" -msgstr "Niemożliwe pod wodą" - -msgid "Impossible when carrying an object" -msgstr "Niemożliwe podczas przenoszenia przedmiotu" - -msgid "Impossible when flying" -msgstr "Niemożliwe podczas lotu" - -msgid "Impossible when moving" -msgstr "Niemożliwe podczas ruchu" - -msgid "Impossible when swimming" -msgstr "Niemożliwe podczas pływania" - -msgid "Inappropriate bot" -msgstr "Nieodpowiedni robot" - -msgid "Inappropriate cell type" -msgstr "Nieodpowiedni rodzaj ogniw" - -msgid "Incorrect index type" -msgstr "Nieprawidłowy typ indeksu" - -#, fuzzy -msgid "Infected by a virus; temporarily out of order" -msgstr "Zainfekowane wirusem, chwilowo niesprawne" - -msgid "Information exchange post" -msgstr "Stacja przekaźnikowa informacji" - -msgid "Instruction \"break\" outside a loop" -msgstr "Polecenie \"break\" na zewnątrz pętli" - -msgid "Instruction \"case\" missing" -msgstr "Brak polecenia \"case" - -msgid "Instruction \"case\" outside a block \"switch\"" -msgstr "Polecenie \"case\" na zewnątrz bloku \"switch\"" - -msgid "Instruction \"else\" without corresponding \"if\" " -msgstr "Polecenie \"else\" bez wystąpienia \"if\" " - -msgid "Instructions (\\key help;)" -msgstr "Rozkazy (\\key help;)" - -msgid "Instructions after the final closing brace" -msgstr "Polecenie po końcowej klamrze zamykającej" - -msgid "Instructions for the mission (\\key help;)" -msgstr "Rozkazy dotyczące misji (\\key help;)" - -msgid "Instructions from Houston" -msgstr "Rozkazy z Houston" - -msgid "Instructions\\Shows the instructions for the current mission" -msgstr "Rozkazy\\Pokazuje rozkazy dotyczące bieżącej misji" - -msgid "Jet temperature" -msgstr "Temperatura silnika" - -msgid "Key A" -msgstr "Klucz A" - -msgid "Key B" -msgstr "Klucz B" - -msgid "Key C" -msgstr "Klucz C" - -msgid "Key D" -msgstr "Klucz D" - -msgid "Key word help\\More detailed help about key words" -msgstr "" -"Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych" - -msgid "Keyword \"while\" missing" -msgstr "Brak kluczowego słowa \"while" - -msgid "Keyword help(\\key cbot;)" -msgstr "Skróty klawiszowe (\\key cbot;)" - -msgid "LOADING" -msgstr "WCZYTYWANIE" - -msgid "Legged grabber" -msgstr "Transporter na nogach" - -msgid "Legged orga shooter" -msgstr "Działo organiczne na nogach" - -msgid "Legged shooter" -msgstr "Działo na nogach" - -msgid "Legged sniffer" -msgstr "Szperacz na nogach" - -msgid "Lightning conductor" -msgstr "Odgromnik" - -msgid "List of objects" -msgstr "Lista obiektów" - -msgid "List of saved missions" -msgstr "Lista zapisanych misji" - -msgid "Load a saved mission" -msgstr "Wczytaj zapisaną misję" - -msgid "Load\\Load a saved mission" -msgstr "Wczytaj\\Wczytuje zapisaną misję" - -msgid "Load\\Loads the selected mission" -msgstr "Wczytaj\\Wczytuje zaznaczoną misję" - -msgid "Lowest\\Minimum graphic quality (highest frame rate)" -msgstr "" -"Najniższa\\Minimalna jakość grafiki (najwyższa częstotliwość odświeżania)" - -msgid "Lunar Roving Vehicle" -msgstr "Pojazd Księżycowy" - -msgid "Marks on the ground\\Marks on the ground" -msgstr "Znaki na ziemi\\Znaki na ziemi" - -msgid "Maximize" -msgstr "Powiększ" - -msgid "Menu (\\key quit;)" -msgstr "Menu (\\key quit;)" - -msgid "Minimize" -msgstr "Pomniejsz" - -msgid "Mission name" -msgstr "Nazwa misji" - -msgid "Missions" -msgstr "Misje" - -msgid "Missions\\Select mission" -msgstr "Misje\\Wybierz misję" - -msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis" -msgstr "Odwrócenie myszy X\\Odwrócenie kierunków przewijania w poziomie" - -msgid "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis" -msgstr "Odwrócenie myszy Y\\Odwrócenie kierunków przewijania w pionie" - -msgid "Mouse shadow\\Gives the mouse a shadow" -msgstr "Cień kursora myszy\\Dodaje cień kursorowi myszy" - -msgid "Mute\\No sound" -msgstr "Cisza\\Brak dźwięków" - -msgid "Name:" -msgstr "Nazwa:" - -msgid "Negative value rejected by \"throw\"" -msgstr "Wartość ujemna odrzucona przez \"throw\"" - -msgid "Nest" -msgstr "Gniazdo" - -msgid "New" -msgstr "Nowy" - -msgid "New ..." -msgstr "Nowy ..." - -msgid "New bot available" -msgstr "Dostępny nowy robot" - -msgid "New player\\Choose player's name" -msgstr "Nowy gracz\\Wybierz imię gracza" - -msgid "Next" -msgstr "Następny" - -msgid "Next object\\Selects the next object" -msgstr "Następny obiekt\\Zaznacza następny obiekt" - -msgid "No energy in the subsoil" -msgstr "Brak energii w ziemi" - -msgid "No flag nearby" -msgstr "Nie ma flagi w pobliżu" - -msgid "No function running" -msgstr "Żadna funkcja nie działa" - -msgid "No function with this name accepts this kind of parameter" -msgstr "Funkcja o tej nazwie nie akceptuje parametrów tego typu" - -msgid "No function with this name accepts this number of parameters" -msgstr "Funkcja o tej nazwie nie akceptuje takiej liczby parametrów" - -msgid "No information exchange post within range" -msgstr "Nie ma żadnej stacji przekaźnikowej w zasięgu" - -msgid "No more energy" -msgstr "Nie ma więcej energii" - -msgid "No ore in the subsoil" -msgstr "W ziemi nie ma żadnej rudy" - -msgid "No other robot" -msgstr "Brak innego robota" - -msgid "No power cell" -msgstr "Brak ogniwa elektrycznego" - -msgid "No titanium" -msgstr "Brak tytanu" - -msgid "No titanium around" -msgstr "Brak tytanu w pobliżu" - -msgid "No titanium ore to convert" -msgstr "Brak rudy tytanu do przetopienia" - -msgid "No titanium to transform" -msgstr "Brak tytanu do przetworzenia" - -msgid "No uranium to transform" -msgstr "Brak uranu do przetworzenia" - -msgid "Normal size" -msgstr "Normalna wielkość" - -msgid "Normal\\Normal graphic quality" -msgstr "Normalna\\Normalna jakość grafiki" - -msgid "Normal\\Normal sound volume" -msgstr "Normalne\\Normalna głośność dźwięków" - -msgid "Not enough energy" -msgstr "Za mało energii" - -msgid "Not enough energy yet" -msgstr "Wciąż za mało energii" - -msgid "Not yet enough energy" -msgstr "Wciąż za mało energii" - -msgid "Nothing to analyze" -msgstr "Nie ma niczego do zanalizowania" - -msgid "Nothing to drop" -msgstr "Nie ma nic do upuszczenia" - -msgid "Nothing to grab" -msgstr "Nie ma nic do podniesienia" - -msgid "Nothing to recycle" -msgstr "Nie ma niczego do odzysku" - -msgid "Nuclear power cell" -msgstr "Atomowe ogniwa elektryczne" - -msgid "Nuclear power cell available" -msgstr "Wytworzono atomowe ogniwo elektryczne" - -msgid "Nuclear power station" -msgstr "Elektrownia atomowa" - -msgid "Num of decorative objects\\Number of purely ornamental objects" -msgstr "Ilość elementów dekoracyjnych \\Ilość elementów czysto dekoracyjnych" - -msgid "Number missing" -msgstr "Brak liczby" - -msgid "Number of insects detected" -msgstr "Liczba wykrytych insektów" - -msgid "Number of particles\\Explosions, dust, reflections, etc." -msgstr "Liczba cząstek\\Wybuchy, kurz, odbicia, itp." - -msgid "OK" -msgstr "OK" - -msgid "OK\\Choose the selected player" -msgstr "OK\\Wybiera zaznaczonego gracza" - -msgid "OK\\Close program editor and return to game" -msgstr "OK\\Zamyka edytor programu i powraca do gry" - -msgid "Object not found" -msgstr "Obiekt nieznany" - -msgid "Object too close" -msgstr "Obiekt za blisko" - -msgid "One step" -msgstr "Jeden krok" - -msgid "Open" -msgstr "Otwórz" - -msgid "Open (Ctrl+o)" -msgstr "Otwórz (Ctrl+O)" - -msgid "Opening brace missing " -msgstr "Brak klamry otwierającej" - -msgid "Opening bracket missing" -msgstr "Brak nawiasu otwierającego" - -msgid "Operation impossible with value \"nan\"" -msgstr "Działanie niemożliwe z wartością \"nan\"" - -msgid "Options" -msgstr "Opcje" - -msgid "Options\\Preferences" -msgstr "Opcje\\Preferencje" - -msgid "Organic matter" -msgstr "Materia organiczna" - -msgid "Origin of last message\\Shows where the last message was sent from" -msgstr "" -"Miejsce nadania wiadomości\\Pokazuje skąd została wysłana ostatnia wiadomość" - -msgid "Parameters missing " -msgstr "Brak wymaganego parametru" - -msgid "Particles in the interface\\Steam clouds and sparks in the interface" -msgstr "Cząstki w interfejsie\\Para i iskry z silników w interfejsie" - -msgid "Paste (Ctrl+v)" -msgstr "Wklej (Ctrl+V)" - -msgid "Pause/continue" -msgstr "Pauza/Kontynuuj" - -msgid "Phazer shooter" -msgstr "Działo fazowe" - -msgid "Photography" -msgstr "Fotografia" - -msgid "Place occupied" -msgstr "Miejsce zajęte" - -msgid "Planets and stars\\Astronomical objects in the sky" -msgstr "Planety i gwiazdy\\Obiekty astronomiczne na niebie" - -msgid "Plans for defense tower available" -msgstr "Dostępne plany wieży obronnej" - -msgid "Plans for nuclear power plant available" -msgstr "Dostępne plany elektrowni atomowej" - -msgid "Plans for phazer shooter available" -msgstr "Dostępne plany działa fazowego" - -msgid "Plans for shielder available" -msgstr "Dostępne plany robota osłaniacza" - -msgid "Plans for shooter available" -msgstr "Dostępne plany działa" - -msgid "Plans for thumper available" -msgstr "Dostępne plany robota uderzacza" - -msgid "Plans for tracked robots available " -msgstr "Dostępne plany tranporterów na gąsienicach" - -msgid "Plant a flag" -msgstr "Postaw flagę" - -msgid "Play\\Start mission!" -msgstr "Graj\\Rozpoczyna misję!" - -msgid "Player" -msgstr "Gracz" - -msgid "Player name" -msgstr "Imię gracza" - -msgid "Player's name" -msgstr "Imię gracza" - -msgid "Power cell" -msgstr "Ogniwo elektryczne" - -msgid "Power cell available" -msgstr "Wytworzono ogniwo elektryczne" - -msgid "Power cell factory" -msgstr "Fabryka ogniw elektrycznych" - -msgid "Power station" -msgstr "Stacja energetyczna" - -msgid "Practice bot" -msgstr "Robot treningowy" - -msgid "Press \\key help; to read instructions on your SatCom" -msgstr "" -"Naciśnij klawisz \\key help; aby wyświetlić rozkazy na przekaźniku SatCom" - -msgid "Previous" -msgstr "Poprzedni" - -msgid "Previous object\\Selects the previous object" -msgstr "Poprzedni obiekt\\Zaznacz poprzedni obiekt" - -msgid "Previous selection (\\key desel;)" -msgstr "Poprzednie zaznaczenie (\\key desel;)" - -msgid "Private element" -msgstr "Element prywatny" - -msgid "Private\\Private folder" -msgstr "Prywatny\\Folder prywatny" - -msgid "Program editor" -msgstr "Edytor programu" - -msgid "Program finished" -msgstr "Program zakończony" - -msgid "Program infected by a virus" -msgstr "Program zawirusowany" - -msgid "Programming exercises" -msgstr "Ćwiczenia programistyczne" - -msgid "Programming help" -msgstr "Podręcznik programowania" - -msgid "Programming help (\\key prog;)" -msgstr "Podręcznik programowania (\\key prog;)" - -msgid "Programming help\\Gives more detailed help with programming" -msgstr "Podręcznik programowania\\Dostarcza szczegółową pomoc w programowaniu" - -msgid "Programs dispatched by Houston" -msgstr "Program dostarczony z Houston" - -msgid "Proto\\Prototypes under development" -msgstr "Prototypy\\Prototypy w trakcie rozwijania" - -msgid "Prototypes" -msgstr "Prototypy" - -msgid "Public required" -msgstr "Wymagany publiczny" - -msgid "Public\\Common folder" -msgstr "Publiczny\\Folder ogólnodostępny" - -msgid "Quake at explosions\\The screen shakes at explosions" -msgstr "Wstrząsy przy wybuchach\\Ekran trzęsie się podczas wybuchów" - -msgid "Quit the mission?" -msgstr "Opuścić misję?" - -msgid "Quit\\Quit COLOBOT" -msgstr "Zakończ\\Kończy grę COLOBOT" - -msgid "Quit\\Quit the current mission or exercise" -msgstr "Zakończ\\Kończy bieżącą misję lub ćwiczenie" - -msgid "Radar station" -msgstr "Stacja radarowa" - -msgid "Read error" -msgstr "Błąd odczytu" - -msgid "Recorder" -msgstr "Recorder" - -msgid "Recycle (\\key action;)" -msgstr "Odzyskaj (\\key action;)" - -msgid "Recycler" -msgstr "Recykler" - -msgid "Red" -msgstr "Czerwony" - -msgid "Red flag" -msgstr "Czerwona flaga" - -msgid "Reflections on the buttons \\Shiny buttons" -msgstr "Odbicia na przyciskach \\Świecące przyciski" - -msgid "Remains of Apollo mission" -msgstr "Pozostałości z misji Apollo" - -msgid "Remove a flag" -msgstr "Usuń flagę" - -msgid "Repair center" -msgstr "Warsztat" - -msgid "Research center" -msgstr "Centrum badawcze" - -msgid "Research program already performed" -msgstr "Program badawczy został już wykonany" - -msgid "Research program completed" -msgstr "Program badawczy zakończony" - -msgid "Reserved keyword of CBOT language" -msgstr "Słowo zarezerwowane języka CBOT" - -msgid "Resolution" -msgstr "Rozdzielczość" - -msgid "Restart\\Restart the mission from the beginning" -msgstr "Uruchom ponownie\\Uruchamia ponownie misję od początku" - -msgid "Return to start" -msgstr "Powrót do początku" - -msgid "Robbie" -msgstr "Robbie" - -msgid "Robbie\\Your assistant" -msgstr "Robbie\\Twój asystent" - -msgid "Ruin" -msgstr "Ruiny" - -msgid "Run research program for defense tower" -msgstr "Rozpocznij prace badawcze nad wieżą obronną" - -msgid "Run research program for legged bots" -msgstr "Rozpocznij prace badawcze nad transporterem na nogach" - -msgid "Run research program for nuclear power" -msgstr "Rozpocznij prace badawcze nad energią atomową" - -msgid "Run research program for orga shooter" -msgstr "Rozpocznij prace badawcze nad działem organicznym" - -msgid "Run research program for phazer shooter" -msgstr "Rozpocznij prace badawcze nad działem fazowym" - -msgid "Run research program for shielder" -msgstr "Rozpocznij prace badawcze nad robotem osłaniaczem" - -msgid "Run research program for shooter" -msgstr "Rozpocznij prace badawcze nad działem" - -msgid "Run research program for thumper" -msgstr "Rozpocznij prace badawcze nad robotem uderzaczem" - -msgid "Run research program for tracked bots" -msgstr "Rozpocznij prace badawcze nad transporterem na gąsienicach" - -msgid "Run research program for winged bots" -msgstr "Rozpocznij prace badawcze nad transporterem latającym" - -msgid "SatCom" -msgstr "SatCom" - -msgid "Satellite report" -msgstr "Raport z satelity" - -msgid "Save" -msgstr "Zapisz" - -msgid "Save (Ctrl+s)" -msgstr "Zapisz (Ctrl+S)" - -msgid "Save the current mission" -msgstr "Zapisz bieżącą misję" - -msgid "Save\\Save the current mission " -msgstr "Zapisz\\Zapisuje bieżącą misję" - -msgid "Save\\Saves the current mission" -msgstr "Zapisz\\Zapisuje bieżącą misję" - -msgid "Scrolling\\Scrolling when the mouse touches right or left border" -msgstr "" -"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego " -"krawędzi" - -msgid "Select the astronaut\\Selects the astronaut" -msgstr "Zaznacz astronautę\\Zaznacza astronautę" - -msgid "Semicolon terminator missing" -msgstr "Brak średnika na końcu wiersza" - -msgid "Shadows\\Shadows on the ground" -msgstr "Cienie\\Cienie na ziemi" - -msgid "Shield level" -msgstr "Poziom osłony" - -msgid "Shield radius" -msgstr "Zasięg osłony" - -msgid "Shielder" -msgstr "Osłaniacz" - -msgid "Shift" -msgstr "Shift" - -msgid "Shoot (\\key action;)" -msgstr "Strzelaj (\\key action;)" - -msgid "Show if the ground is flat" -msgstr "Pokaż czy teren jest płaski" - -msgid "Show the place" -msgstr "Pokaż miejsce" - -msgid "Show the range" -msgstr "Pokaż zasięg" - -msgid "Show the solution" -msgstr "Pokaż rozwiązanie" - -msgid "Sign \" : \" missing" -msgstr "Brak znaku \" :\"" - -msgid "Size 1" -msgstr "Wielkość 1" - -msgid "Size 2" -msgstr "Wielkość 2" - -msgid "Size 3" -msgstr "Wielkość 3" - -msgid "Size 4" -msgstr "Wielkość 4" - -msgid "Size 5" -msgstr "Wielkość 5" - -msgid "Sky\\Clouds and nebulae" -msgstr "Niebo\\Chmury i mgławice" - -msgid "Sniff (\\key action;)" -msgstr "Szukaj (\\key action;)" - -msgid "Solution" -msgstr "Rozwiązanie" - -msgid "Sound effects:\\Volume of engines, voice, shooting, etc." -msgstr "Efekty dźwiękowe:\\Głośność silników, głosów, strzałów, itp." - -msgid "Sound\\Music and game sound volume" -msgstr "Dźwięk\\Głośność muzyki i dźwięków gry" - -msgid "Spaceship" -msgstr "Statek kosmiczny" - -msgid "Spaceship ruin" -msgstr "Ruiny statku kosmicznego" - -msgid "Speed 1.0x\\Normal speed" -msgstr "Prędkość 1,0x\\Prędkość normalna" - -msgid "Speed 1.5x\\1.5 times faster" -msgstr "Prędkość 1,5x\\1,5 raza szybciej" - -msgid "Speed 2.0x\\Double speed" -msgstr "Prędkość 2,0x\\Dwa razy szybciej" - -msgid "Speed 3.0x\\Three times faster" -msgstr "Prędkość 3,0x\\Trzy razy szybciej" - -msgid "Spider" -msgstr "Pająk" - -msgid "Spider fatally wounded" -msgstr "Pająk śmiertelnie raniony" - -msgid "Stack overflow" -msgstr "Przepełnienie stosu" - -msgid "" -"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)" -msgstr "" -"Standardowa akcja\\Standardowa akcja robota (podnieś/upuść, strzelaj, " -"szukaj, itp.)" - -msgid "Standard controls\\Standard key functions" -msgstr "Standardowa kontrola\\Standardowe klawisze funkcyjne" - -msgid "Standard\\Standard appearance settings" -msgstr "Standardowe\\Standardowe ustawienia wyglądu" - -msgid "Start" -msgstr "Początek" - -msgid "Still working ..." -msgstr "Wciąż pracuje..." - -msgid "String missing" -msgstr "Brak łańcucha" - -msgid "Strip color:" -msgstr "Kolor pasków:" - -msgid "Subber" -msgstr "Robot nurek" - -msgid "Suit color:" -msgstr "Kolor skafandra:" - -msgid "Suit\\Astronaut suit" -msgstr "Skafander\\Skafander astronauty" - -msgid "Sunbeams\\Sunbeams in the sky" -msgstr "Promienie słoneczne\\Promienie słoneczne na niebie" - -msgid "Survival kit" -msgstr "Zestaw przetrwania" - -msgid "Switch bots <-> buildings" -msgstr "Przełącz roboty <-> budynki" - -msgid "Take off to finish the mission" -msgstr "Odleć, aby zakończyć misję" - -msgid "Target" -msgstr "Cel" - -msgid "Target bot" -msgstr "Robot cel" - -msgid "Textures\\Quality of textures " -msgstr "Tekstury\\Jakość tekstur " - -msgid "The expression must return a boolean value" -msgstr "Wyrażenie musi zwrócić wartość logiczną" - -msgid "The function returned no value " -msgstr "Funkcja nie zwróciła żadnej wartości " - -msgid "" -"The list is only available if a \\l;radar station\\u object\\radar; is " -"working.\n" -msgstr "" -"Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u object" -"\\radar;.\n" - -msgid "" -"The mission is not accomplished yet (press \\key help; for more details)" -msgstr "Misja nie jest wypełniona (naciśnij \\key help; aby uzyskać szczegóły)" - -msgid "The types of the two operands are incompatible " -msgstr "Niezgodne typy operatorów" - -msgid "This class already exists" -msgstr "Taka klasa już istnieje" - -msgid "This class does not exist" -msgstr "Taka klasa nie istnieje" - -msgid "This is not a member of this class" -msgstr "To nie jest obiekt tej klasy" - -msgid "This label does not exist" -msgstr "Taka etykieta nie istnieje" - -msgid "This object is not a member of a class" -msgstr "Ten obiekt nie jest członkiem klasy" - -msgid "Thump (\\key action;)" -msgstr "Uderz (\\key action;)" - -msgid "Thumper" -msgstr "Uderzacz" - -msgid "Titanium" -msgstr "Tytan" - -msgid "Titanium available" -msgstr "Tytan dostępny" - -msgid "Titanium deposit (site for derrick)" -msgstr "Złoże tytanu (miejsce na kopalnię)" - -msgid "Titanium ore" -msgstr "Ruda tytanu" - -msgid "Titanium too close" -msgstr "Tytan za blisko" - -msgid "Titanium too far away" -msgstr "Tytan za daleko" - -msgid "Too close to a building" -msgstr "Za blisko budynku" - -msgid "Too close to an existing flag" -msgstr "Za blisko istniejącej flagi" - -msgid "Too close to space ship" -msgstr "Za blisko statku kosmicznego" - -msgid "Too many flags of this color (maximum 5)" -msgstr "Za dużo flag w tym kolorze (maksymalnie 5)" - -msgid "Too many parameters" -msgstr "Za dużo parametrów" - -msgid "Tracked grabber" -msgstr "Transporter na gąsienicach" - -msgid "Tracked orga shooter" -msgstr "Działo organiczne na gąsienicach" - -msgid "Tracked shooter" -msgstr "Działo na gąsienicach" - -msgid "Tracked sniffer" -msgstr "Szperacz na gąsienicach" - -msgid "Transforms only titanium" -msgstr "Przetwarza jedynie tytan" - -msgid "Transforms only uranium" -msgstr "Przetwarza jedynie uran" - -msgid "Transmitted information" -msgstr "Przesłane informacje" - -msgid "Turn left (\\key left;)" -msgstr "Skręć w lewo (\\key left;)" - -msgid "Turn left\\turns the bot to the left" -msgstr "Skręć w lewo\\Obraca robota w lewo" - -msgid "Turn right (\\key right;)" -msgstr "Skręć w prawo (\\key right;)" - -msgid "Turn right\\turns the bot to the right" -msgstr "Obróć w prawo\\Obraca robota w prawo" - -msgid "Type declaration missing" -msgstr "Brak deklaracji typu" - -msgid "Undo (Ctrl+z)" -msgstr "Cofnij (Ctrl+Z)" - -msgid "Unit" -msgstr "Jednostka" - -msgid "Unknown Object" -msgstr "Obiekt nieznany" - -msgid "Unknown command" -msgstr "Nieznane polecenie" - -msgid "Unknown function" -msgstr "Funkcja nieznana" - -msgid "Up (\\key gup;)" -msgstr "Góra (\\key gup;)" - -msgid "Uranium deposit (site for derrick)" -msgstr "Złoże uranu (miejsce na kopalnię)" - -msgid "Uranium ore" -msgstr "Ruda uranu" - -msgid "Use a joystick\\Joystick or keyboard" -msgstr "Używaj joysticka\\Joystick lub klawiatura" - -msgid "User levels" -msgstr "Poziomy użytkownika" - -msgid "User\\User levels" -msgstr "Poziomy\\Poziomy użytkownika" - -msgid "Variable name missing" -msgstr "Brak nazwy zmiennej" - -msgid "Variable not declared" -msgstr "Zmienna nie została zadeklarowana" - -msgid "Variable not initialized" -msgstr "Zmienna nie została zainicjalizowana" - -msgid "Vault" -msgstr "Skrytka" - -msgid "Violet flag" -msgstr "Fioletowa flaga" - -msgid "Void parameter" -msgstr "Pusty parametr" - -msgid "Wasp" -msgstr "Osa" - -msgid "Wasp fatally wounded" -msgstr "Osa śmiertelnie raniona" - -msgid "Waste" -msgstr "Odpady" - -msgid "Wheeled grabber" -msgstr "Transporter na kołach" - -msgid "Wheeled orga shooter" -msgstr "Działo organiczne na kołach" - -msgid "Wheeled shooter" -msgstr "Działo na kołach" - -msgid "Wheeled sniffer" -msgstr "Szperacz na kołach" - -msgid "Win" -msgstr "" - -msgid "Winged grabber" -msgstr "Transporter latający" - -msgid "Winged orga shooter" -msgstr "Latające działo organiczne" - -msgid "Winged shooter" -msgstr "Działo latające" - -msgid "Winged sniffer" -msgstr "Szperacz latający" - -msgid "Withdraw shield (\\key action;)" -msgstr "Wyłącz osłonę (\\key action;)" - -msgid "Worm" -msgstr "Robal" - -msgid "Worm fatally wounded" -msgstr "Robal śmiertelnie raniony" - -msgid "Wreckage" -msgstr "Wrak" - -msgid "Write error" -msgstr "Błąd zapisu" - -msgid "Wrong type for the assignment" -msgstr "Zły typ dla przypisania" - -msgid "Yellow flag" -msgstr "Żółta flaga" - -msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)" -msgstr "Możesz latać używając klawiszy (\\key gup;) oraz (\\key gdown;)" - -msgid "You can not carry a radioactive object" -msgstr "Nie możesz przenosić przedmiotów radioaktywnych" - -msgid "You can not carry an object under water" -msgstr "Nie możesz przenosić przedmiotów pod wodą" - -msgid "You found a usable object" -msgstr "Znaleziono użyteczny przedmiot" - -msgid "You must get on the spaceship to take off " -msgstr "Musisz być na statku kosmicznym aby nim odlecieć" - -msgid "Zoom mini-map" -msgstr "Powiększenie mapki" - -msgid "\\Blue flags" -msgstr "\\Niebieskie flagi" - -msgid "\\Eyeglasses 1" -msgstr "\\Okulary 1" - -msgid "\\Eyeglasses 2" -msgstr "\\Okulary 2" - -msgid "\\Eyeglasses 3" -msgstr "\\Okulary 3" - -msgid "\\Eyeglasses 4" -msgstr "\\Okulary 4" - -msgid "\\Eyeglasses 5" -msgstr "\\Okulary 5" - -msgid "\\Face 1" -msgstr "\\Twarz 1" - -msgid "\\Face 2" -msgstr "\\Twarz 2" - -msgid "\\Face 3" -msgstr "\\Twarz 3" - -msgid "\\Face 4" -msgstr "\\Twarz 4" - -msgid "\\Green flags" -msgstr "\\Zielone flagi" - -msgid "\\New player name" -msgstr "\\Nowe imię gracza" - -msgid "\\No eyeglasses" -msgstr "\\Bez okularów" - -msgid "\\Raise the pencil" -msgstr "\\Relčve le crayon" - -msgid "\\Red flags" -msgstr "\\Czerwone flagi" - -msgid "\\Return to COLOBOT" -msgstr "\\Powróć do gry COLOBOT" - -msgid "\\SatCom on standby" -msgstr "\\Przełącz przekaźnik SatCom w stan gotowości" - -msgid "\\Start recording" -msgstr "\\Démarre l'enregistrement" - -msgid "\\Stop recording" -msgstr "\\Stoppe l'enregistrement" - -msgid "\\Turn left" -msgstr "\\Obróć w lewo" - -msgid "\\Turn right" -msgstr "\\Obróć w prawo" - -msgid "\\Use the black pencil" -msgstr "\\Abaisse le crayon noir" - -msgid "\\Use the blue pencil" -msgstr "\\Abaisse le crayon bleu" - -msgid "\\Use the brown pencil" -msgstr "\\Abaisse le crayon brun" - -msgid "\\Use the green pencil" -msgstr "\\Abaisse le crayon vert" - -msgid "\\Use the orange pencil" -msgstr "\\Abaisse le crayon orange" - -msgid "\\Use the purple pencil" -msgstr "\\Abaisse le crayon violet" - -msgid "\\Use the red pencil" -msgstr "\\Abaisse le crayon rouge" - -msgid "\\Use the yellow pencil" -msgstr "\\Abaisse le crayon jaune" - -msgid "\\Violet flags" -msgstr "\\Fioletowe flagi" - -msgid "\\Yellow flags" -msgstr "\\Żółte flagi" - -msgid "\\b;Aliens\n" -msgstr "\\b;Obcy\n" - -msgid "\\b;Buildings\n" -msgstr "\\b;Budynki\n" - -msgid "\\b;Error\n" -msgstr "\\b;Błąd\n" - -msgid "\\b;List of objects\n" -msgstr "\\b;Lista obiektów\n" - -msgid "\\b;Moveable objects\n" -msgstr "\\b;Obiekty ruchome\n" - -msgid "\\b;Robots\n" -msgstr "\\b;Roboty\n" - -msgid "\\c; (none)\\n;\n" -msgstr "\\c; (brak)\\n;\n" - -msgid "action;" -msgstr "" - -msgid "away;" -msgstr "" - -msgid "camera;" -msgstr "" - -msgid "cbot;" -msgstr "" - -msgid "desel;" -msgstr "" - -msgid "down;" -msgstr "" - -msgid "gdown;" -msgstr "" - -msgid "gup;" -msgstr "" - -msgid "help;" -msgstr "" - -msgid "human;" -msgstr "" - -msgid "left;" -msgstr "" - -msgid "near;" -msgstr "" - -msgid "next;" -msgstr "" - -msgid "prog;" -msgstr "" - -msgid "quit;" -msgstr "" - -msgid "right;" -msgstr "" - -msgid "speed10;" -msgstr "" - -msgid "speed15;" -msgstr "" - -msgid "speed20;" -msgstr "" - -msgid "up;" -msgstr "" - -msgid "visit;" -msgstr "" - -msgid "www.epsitec.com" -msgstr "www.epsitec.com" - -#~ msgid "< none >" -#~ msgstr "< brak >" - -#~ msgid "<--" -#~ msgstr "<--" - -#~ msgid "Application key" -#~ msgstr "Klawisz menu kontekstowego" - -#~ msgid "Arrow down" -#~ msgstr "Strzałka w dół" - -#~ msgid "Arrow left" -#~ msgstr "Strzałka w lewo" - -#~ msgid "Arrow right" -#~ msgstr "Strzałka w prawo" - -#~ msgid "Arrow up" -#~ msgstr "Strzałka w górę" - -#~ msgid "Attn" -#~ msgstr "Attn" - -#~ msgid "Caps Lock" -#~ msgstr "Caps Lock" - -#~ msgid "Clear" -#~ msgstr "Delete" - -#~ msgid "Control-break" -#~ msgstr "Ctrl-break" - -#~ msgid "CrSel" -#~ msgstr "CrSel" - -#~ msgid "Delete Key" -#~ msgstr "Delete" - -#~ msgid "Dictionnary" -#~ msgstr "Raport z satelity" - -#~ msgid "Disintegrator" -#~ msgstr "Fabryka ogniw elektrycznych" - -#~ msgid "End" -#~ msgstr "End" - -#~ msgid "Enter" -#~ msgstr "Enter" - -#~ msgid "Erase EOF" -#~ msgstr "Erase EOF" - -#~ msgid "Error" -#~ msgstr "Błąd" - -#~ msgid "Esc" -#~ msgstr "Esc" - -#~ msgid "ExSel" -#~ msgstr "ExSel" - -#~ msgid "Execute" -#~ msgstr "Wykonaj" - -#~ msgid "F1" -#~ msgstr "F1" - -#~ msgid "F10" -#~ msgstr "F10" - -#~ msgid "F11" -#~ msgstr "F11" - -#~ msgid "F12" -#~ msgstr "F12" - -#~ msgid "F13" -#~ msgstr "F13" - -#~ msgid "F14" -#~ msgstr "F14" - -#~ msgid "F15" -#~ msgstr "F15" - -#~ msgid "F16" -#~ msgstr "F16" - -#~ msgid "F17" -#~ msgstr "F17" - -#~ msgid "F18" -#~ msgstr "F18" - -#~ msgid "F19" -#~ msgstr "F19" - -#~ msgid "F2" -#~ msgstr "F2" - -#~ msgid "F20" -#~ msgstr "F20" - -#~ msgid "F3" -#~ msgstr "F3" - -#~ msgid "F4" -#~ msgstr "F4" - -#~ msgid "F5" -#~ msgstr "F5" - -#~ msgid "F6" -#~ msgstr "F6" - -#~ msgid "F7" -#~ msgstr "F7" - -#~ msgid "F8" -#~ msgstr "F8" - -#~ msgid "F9" -#~ msgstr "F9" - -#~ msgid "Help" -#~ msgstr "Pomoc" - -#~ msgid "Home Key" -#~ msgstr "Home" - -#~ msgid "Insert" -#~ msgstr "Insert" - -#~ msgid "Left Windows" -#~ msgstr "Lewy klawisz Windows" - -#~ msgid "Mini-map" -#~ msgstr "Mapka" - -#~ msgid "Num Lock" -#~ msgstr "Num Lock" - -#~ msgid "NumPad *" -#~ msgstr "Klaw. Num. *" - -#~ msgid "NumPad +" -#~ msgstr "Klaw. Num. +" - -#~ msgid "NumPad -" -#~ msgstr "Klaw. Num. -" - -#~ msgid "NumPad ." -#~ msgstr "Klaw. Num. ." - -#~ msgid "NumPad /" -#~ msgstr "Klaw. Num. /" - -#~ msgid "NumPad 0" -#~ msgstr "Klaw. Num. 0" - -#~ msgid "NumPad 1" -#~ msgstr "Klaw. Num. 1" - -#~ msgid "NumPad 2" -#~ msgstr "Klaw. Num. 2" - -#~ msgid "NumPad 3" -#~ msgstr "Klaw. Num. 3" - -#~ msgid "NumPad 4" -#~ msgstr "Klaw. Num. 4" - -#~ msgid "NumPad 5" -#~ msgstr "Klaw. Num. 5" - -#~ msgid "NumPad 6" -#~ msgstr "Klaw. Num. 6" - -#~ msgid "NumPad 7" -#~ msgstr "Klaw. Num. 7" - -#~ msgid "NumPad 8" -#~ msgstr "Klaw. Num. 8" - -#~ msgid "NumPad 9" -#~ msgstr "Klaw. Num. 9" - -#~ msgid "NumPad sep" -#~ msgstr "Klaw. Num. separator" - -#~ msgid "PA1" -#~ msgstr "PA1" - -#~ msgid "Page Down" -#~ msgstr "Page Down" - -#~ msgid "Page Up" -#~ msgstr "Page Up" - -#~ msgid "Pause" -#~ msgstr "Pause" - -#~ msgid "Play" -#~ msgstr "Graj" - -#~ msgid "Print Scrn" -#~ msgstr "Print Scrn" - -#~ msgid "Right Windows" -#~ msgstr "Prawy klawisz Windows" - -#~ msgid "Scroll" -#~ msgstr "Scroll Lock" - -#~ msgid "Select" -#~ msgstr "Zaznacz" - -#~ msgid "Space" -#~ msgstr "Spacja" - -#~ msgid "Tab" -#~ msgstr "Tab" - -#~ msgid "Wheel down" -#~ msgstr "Kółko w dół" - -#~ msgid "Wheel up" -#~ msgstr "Kółko w górę" - -#~ msgid "Zoom" -#~ msgstr "Powiększenie" - diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 3a31883..defff84 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -175,12 +175,12 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; - // TODO: replace NDEBUG with something like BUILD_TYPE == "DEBUG"/"RELEASE" - #ifdef NDEBUG - m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); - #else + #if DEV_BUILD m_savegameDir = "savegame"; + #else + m_savegameDir = GetSystemUtils()->GetSavegameDirectoryLocation(); #endif + m_publicDir = "program"; m_userDir = "user"; m_filesDir = m_savegameDir; -- cgit v1.2.3-1-g7c22 From 9f819088a67a555d7bf18bf1da5db1ff66163055 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 22 Jun 2013 22:35:53 +0200 Subject: gitignore update * git should now ignore all generated files when building without separate build directory --- src/CBot/.gitignore | 1 + src/common/.gitignore | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 src/CBot/.gitignore create mode 100644 src/common/.gitignore (limited to 'src') diff --git a/src/CBot/.gitignore b/src/CBot/.gitignore new file mode 100644 index 0000000..4c80252 --- /dev/null +++ b/src/CBot/.gitignore @@ -0,0 +1 @@ +libCBot.so diff --git a/src/common/.gitignore b/src/common/.gitignore new file mode 100644 index 0000000..a13f82d --- /dev/null +++ b/src/common/.gitignore @@ -0,0 +1,2 @@ +# CMake config header +config.h -- cgit v1.2.3-1-g7c22 From 3e989c96dff7889aff5b6476bf2a8fb9c541bd95 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 24 Jun 2013 13:07:33 +0200 Subject: Fixed auto-detecting locale on Windows * localename library is now used to determine the actual locale used * added patched version of FindGettext.cmake to fix installation path of translation files --- src/CMakeLists.txt | 2 ++ src/app/app.cpp | 47 +++++++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c02aa1..6f93532 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -185,6 +185,7 @@ ${OPENAL_SRC} set(LIBS CBot clipboard +localename ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} @@ -214,6 +215,7 @@ ${PNG_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${Boost_INCLUDE_DIRS} ${LIBSNDFILE_INCLUDE_DIR} +${LOCALENAME_INCLUDE_DIR} ${OPTIONAL_INCLUDE_DIRS} ${CLIPBOARD_INCLUDE_DIR} ) diff --git a/src/app/app.cpp b/src/app/app.cpp index 44a7a74..f98e0fc 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -46,6 +46,7 @@ #include #include #include +#include template<> CApplication* CSingleton::m_instance = nullptr; @@ -1741,33 +1742,38 @@ void CApplication::SetLanguage(Language language) if (locale.empty()) { - char *envLang = getenv("LANGUAGE"); - if (envLang == NULL) - { - envLang = getenv("LANG"); - } + const char* envLang = gl_locale_name(LC_MESSAGES, "LC_MESSAGES"); if (envLang == NULL) { GetLogger()->Error("Failed to get language from environment, setting default language\n"); m_language = LANGUAGE_ENGLISH; } - else if (strncmp(envLang,"en",2) == 0) - { - m_language = LANGUAGE_ENGLISH; - } - else if (strncmp(envLang,"de",2) == 0) - { - m_language = LANGUAGE_GERMAN; - } - else if (strncmp(envLang,"fr",2) == 0) - { - m_language = LANGUAGE_FRENCH; - } - else if (strncmp(envLang,"pl",2) == 0) + else { - m_language = LANGUAGE_POLISH; + GetLogger()->Trace("gl_locale_name: '%s'\n", envLang); + + if (strncmp(envLang,"en",2) == 0) + { + m_language = LANGUAGE_ENGLISH; + } + else if (strncmp(envLang,"de",2) == 0) + { + m_language = LANGUAGE_GERMAN; + } + else if (strncmp(envLang,"fr",2) == 0) + { + m_language = LANGUAGE_FRENCH; + } + else if (strncmp(envLang,"pl",2) == 0) + { + m_language = LANGUAGE_POLISH; + } + else + { + GetLogger()->Warn("Enviromnent locale ('%s') is not supported, setting default language\n", envLang); + m_language = LANGUAGE_ENGLISH; + } } - GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", envLang); } else { @@ -1777,6 +1783,7 @@ void CApplication::SetLanguage(Language language) putenv(S_LANGUAGE); GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str()); } + setlocale(LC_ALL, ""); bindtextdomain("colobot", m_langPath.c_str()); -- cgit v1.2.3-1-g7c22 From 81a6de41a5f6f5a4340e834dfd4ca965ed694924 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 24 Jun 2013 13:28:18 +0200 Subject: Some further changes in CMakeLists * removed DEV_BUILD autodetection (could be confusing) * ignore desktop subdirectory on Windows * some refactoring --- src/CBot/CMakeLists.txt | 2 +- src/CMakeLists.txt | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt index ecde61f..8bb8a5c 100644 --- a/src/CBot/CMakeLists.txt +++ b/src/CBot/CMakeLists.txt @@ -12,7 +12,7 @@ CBotVar.cpp CBotWhile.cpp ) -if(${CBOT_STATIC}) +if(CBOT_STATIC) add_library(CBot STATIC ${SOURCES}) else() add_library(CBot SHARED ${SOURCES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f93532..40373a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG}) add_subdirectory(CBot) -if(${TOOLS}) +if(TOOLS) add_subdirectory(tools) endif() @@ -17,18 +17,18 @@ endif() set(OPTIONAL_LIBS "") set(OPTIONAL_INCLUDES "") -if (${OPENAL_SOUND}) +if(OPENAL_SOUND) set(OPTIONAL_LIBS ${OPENAL_LIBRARY}) set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR}) endif() # Additional libraries per platform -if (${MXE}) # MXE requires special treatment +if(MXE) # MXE requires special treatment set(PLATFORM_LIBS ${MXE_LIBS}) -elseif (${PLATFORM_WINDOWS}) +elseif(PLATFORM_WINDOWS) # because it isn't included in standard linking libraries set(PLATFORM_LIBS "-lintl") -elseif(${PLATFORM_LINUX}) +elseif(PLATFORM_LINUX) # for clock_gettime set(PLATFORM_LIBS "-lrt -lX11") endif() @@ -39,7 +39,7 @@ configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h set(OPENAL_SRC "") -if (${OPENAL_SOUND}) +if(OPENAL_SOUND) set(OPENAL_SRC sound/oalsound/alsound.cpp sound/oalsound/buffer.cpp @@ -48,9 +48,9 @@ if (${OPENAL_SOUND}) endif() # Platform-dependent implementation of system.h -if (${PLATFORM_WINDOWS}) +if(PLATFORM_WINDOWS) set(SYSTEM_CPP_MODULE "system_windows.cpp") -elseif(${PLATFORM_LINUX}) +elseif(PLATFORM_LINUX) set(SYSTEM_CPP_MODULE "system_linux.cpp") else() set(SYSTEM_CPP_MODULE "system_other.cpp") -- cgit v1.2.3-1-g7c22