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 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/object') 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)) { -- 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/object/object.cpp | 8 + src/object/objman.cpp | 388 +++++++++++++++++++++++++++++++++++++++++++++++ src/object/objman.h | 54 +++++++ src/object/robotmain.cpp | 1 + 4 files changed, 451 insertions(+) create mode 100644 src/object/objman.cpp create mode 100644 src/object/objman.h (limited to 'src/object') 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(); -- 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/object') 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 +++++ 1 file changed, 5 insertions(+) (limited to 'src/object') 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; -- 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/object/robotmain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/object') 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 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 ++++++ 2 files changed, 39 insertions(+), 7 deletions(-) (limited to 'src/object') 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; }; -- cgit v1.2.3-1-g7c22 From b0919139bdda0d0dd1f6935ca6894135517478ab Mon Sep 17 00:00:00 2001 From: erihel 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/object') 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 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/object') 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 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 ++++++++++- 2 files changed, 98 insertions(+), 2 deletions(-) (limited to 'src/object') 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]; -- 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/object') 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 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/object') 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 ++; } } -- 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/object') 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 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/object') 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/object') 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/object') 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/object') 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 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/object') 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 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 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/object') 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; -- 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/object') 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/object') 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/object') 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 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/object') 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 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/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 +- 10 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/object') 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 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/object') 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/object') 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/object/motion/motiondummy.cpp | 62 +++++++++++++++++++++++++++++++++++++++ src/object/motion/motiondummy.h | 32 ++++++++++++++++++++ src/object/object.cpp | 3 +- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/object/motion/motiondummy.cpp create mode 100644 src/object/motion/motiondummy.h (limited to 'src/object') 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/object/motion/motionvehicle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/object') 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/object/motion/motiondummy.cpp | 5 +++-- src/object/motion/motiondummy.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/object') 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 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 +- 5 files changed, 64 insertions(+), 16 deletions(-) (limited to 'src/object') 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); -- 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 +++ 2 files changed, 41 insertions(+), 1 deletion(-) (limited to 'src/object') 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; -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/object') 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); -- 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 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/object') 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; -- 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/object/robotmain.cpp | 80 +++++++++++++++++++++--------------------------- src/object/robotmain.h | 2 +- 2 files changed, 36 insertions(+), 46 deletions(-) (limited to 'src/object') 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 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/object') 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 */ -- 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/object') 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 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/object/auto/autodestroyer.cpp | 161 ++++++++++++-------------------------- src/object/auto/autodestroyer.h | 2 +- 2 files changed, 50 insertions(+), 113 deletions(-) (limited to 'src/object') 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/object') 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/object') 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/object') 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 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/object') 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 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/object/robotmain.cpp | 48 +++++++++++++++++++++++++++++++----------------- src/object/robotmain.h | 2 +- 2 files changed, 32 insertions(+), 18 deletions(-) (limited to 'src/object') 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(); -- 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/object') 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 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/object') 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/object') 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/object') 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 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/object') 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/object/auto/autobase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/object') 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), -- 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/object') 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 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 +-- 5 files changed, 60 insertions(+), 37 deletions(-) (limited to 'src/object') 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(); -- 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 + 1 file changed, 1 insertion(+) (limited to 'src/object') 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. -- 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/object/auto/autodestroyer.cpp | 51 +++++++++++++++++++++++++++------------ src/object/auto/autodestroyer.h | 2 ++ src/object/robotmain.cpp | 1 + 3 files changed, 39 insertions(+), 15 deletions(-) (limited to 'src/object') 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(); -- 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/object') 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 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/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 +- 5 files changed, 48 insertions(+), 3 deletions(-) (limited to 'src/object') 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. -- 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 +- 5 files changed, 155 insertions(+), 135 deletions(-) (limited to 'src/object') 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(); -- 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/object/robotmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/object') 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; } -- 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 +- 4 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/object') 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 ) -- 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/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 - 51 files changed, 195 insertions(+), 159 deletions(-) (limited to 'src/object') 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; } - -- 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/object/robotmain.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/object') 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; -- 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/object/motion/motionhuman.cpp | 8 ++++---- src/object/robotmain.cpp | 19 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/object') 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, -- 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/object') 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/object/robotmain.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/object') 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/object/robotmain.cpp | 23 +++++++++++++++++------ src/object/robotmain.h | 5 ++++- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src/object') 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(); -- 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/object/robotmain.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/object') 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 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/object/robotmain.cpp | 8 +++++--- src/object/robotmain.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/object') 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(); -- cgit v1.2.3-1-g7c22