From 6892d37a4f497821d8059dc40bc6ead4085d66d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Sun, 9 Sep 2012 14:28:19 +0200 Subject: [src/object/auto] Folder rewritten --- src/object/auto/autoenergy.cpp | 137 +++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 68 deletions(-) (limited to 'src/object/auto/autoenergy.cpp') diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp index 409e282..d0117ab 100644 --- a/src/object/auto/autoenergy.cpp +++ b/src/object/auto/autoenergy.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) 2012 Polish Portal of Colobot (PPC) // * // * This program is free software: you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by @@ -20,7 +21,7 @@ #include "object/auto/autoenergy.h" #include "common/iman.h" -#include "old/terrain.h" +#include "graphics/engine/terrain.h" #include "math/geometry.h" #include "script/cmdtoken.h" #include "ui/interface.h" @@ -60,7 +61,7 @@ void CAutoEnergy::DeleteObject(bool bAll) if ( m_partiSphere != -1 ) { - m_particule->DeleteParticule(m_partiSphere); + m_particle->DeleteParticle(m_partiSphere); m_partiSphere = -1; } @@ -92,7 +93,7 @@ void CAutoEnergy::Init() m_time = 0.0f; m_timeVirus = 0.0f; m_lastUpdateTime = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; m_phase = AENP_WAIT; // waiting ... m_progress = 0.0f; @@ -109,35 +110,35 @@ bool CAutoEnergy::EventProcess(const Event &event) CObject* fret; Math::Vector pos, ppos, speed; Math::Point dim, c, p; - TerrainRes res; + Gfx::TerrainRes res; float big; bool bGO; CAuto::EventProcess(event); - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; m_timeVirus -= event.rTime; - if ( m_object->RetVirusMode() ) // contaminated by a virus? + if ( m_object->GetVirusMode() ) // contaminated by a virus? { if ( m_timeVirus <= 0.0f ) { m_timeVirus = 0.1f+Math::Rand()*0.3f; - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; - pos = m_object->RetPosition(0); + m_lastParticle = m_time; + pos = m_object->GetPosition(0); pos.y += 10.0f; speed.x = (Math::Rand()-0.5f)*10.0f; speed.z = (Math::Rand()-0.5f)*10.0f; speed.y = -7.0f; dim.x = Math::Rand()*0.5f+0.5f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ, 1.0f, 0.0f, 0.0f); } } return true; @@ -146,10 +147,10 @@ bool CAutoEnergy::EventProcess(const Event &event) UpdateInterface(event.rTime); EventProgress(event.rTime); - big = m_object->RetEnergy(); + big = m_object->GetEnergy(); - res = m_terrain->RetResource(m_object->RetPosition(0)); - if ( res == TR_POWER ) + res = m_terrain->GetResource(m_object->GetPosition(0)); + if ( res == Gfx::TR_POWER ) { big += event.rTime*0.01f; // recharges the big pile } @@ -162,7 +163,7 @@ bool CAutoEnergy::EventProcess(const Event &event) fret = SearchMetal(); // transform metal? if ( fret != 0 ) { - if ( fret->RetType() == OBJECT_METAL ) + if ( fret->GetType() == OBJECT_METAL ) { if ( big > ENERGY_POWER ) bGO = true; } @@ -174,7 +175,7 @@ bool CAutoEnergy::EventProcess(const Event &event) if ( bGO ) { - if ( fret->RetType() == OBJECT_METAL ) + if ( fret->GetType() == OBJECT_METAL ) { fret->SetLock(true); // usable metal CreatePower(); // creates the battery @@ -184,12 +185,12 @@ bool CAutoEnergy::EventProcess(const Event &event) InitProgressTotal(ENERGY_DELAY); CAuto::UpdateInterface(); - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y += 4.0f; speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = 3.0f; dim.y = dim.x; - m_partiSphere = m_particule->CreateParticule(pos, speed, dim, PARTISPHERE1, ENERGY_DELAY, 0.0f, 0.0f); + m_partiSphere = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISPHERE1, ENERGY_DELAY, 0.0f, 0.0f); m_phase = AENP_CREATE; m_progress = 0.0f; @@ -217,17 +218,17 @@ bool CAutoEnergy::EventProcess(const Event &event) { if ( m_progress < 1.0f && big > 0.01f ) { - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; - pos = m_object->RetPosition(0); + m_lastParticle = m_time; + pos = m_object->GetPosition(0); pos.y += 10.0f; speed.x = (Math::Rand()-0.5f)*1.0f; speed.z = (Math::Rand()-0.5f)*1.0f; speed.y = -7.0f; dim.x = Math::Rand()*0.5f+0.5f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ, 1.0f, 0.0f, 0.0f); } } else @@ -245,7 +246,7 @@ bool CAutoEnergy::EventProcess(const Event &event) fret = SearchMetal(); if ( fret != 0 ) { - if ( fret->RetType() == OBJECT_METAL ) + if ( fret->GetType() == OBJECT_METAL ) { big -= event.rTime/ENERGY_DELAY*ENERGY_POWER; } @@ -262,11 +263,11 @@ bool CAutoEnergy::EventProcess(const Event &event) fret->SetZoom(0, m_progress); } - if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); c.x = pos.x; c.y = pos.z; p.x = c.x; @@ -278,27 +279,27 @@ bool CAutoEnergy::EventProcess(const Event &event) speed = Math::Vector(0.0f, 0.0f, 0.0f); dim.x = Math::Rand()*2.0f+1.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 1.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 1.0f, 0.0f, 0.0f); - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y += 3.0f; speed.x = (Math::Rand()-0.5f)*30.0f; speed.z = (Math::Rand()-0.5f)*30.0f; speed.y = Math::Rand()*20.0f+10.0f; dim.x = Math::Rand()*0.4f+0.4f; dim.y = dim.x; - m_particule->CreateTrack(pos, speed, dim, PARTITRACK2, 2.0f, 50.0f, 1.2f, 1.2f); + m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK2, 2.0f, 50.0f, 1.2f, 1.2f); - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y += 10.0f; speed.x = (Math::Rand()-0.5f)*1.5f; speed.z = (Math::Rand()-0.5f)*1.5f; speed.y = -6.0f; dim.x = Math::Rand()*1.0f+1.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ, 1.0f, 0.0f, 0.0f); - m_sound->Play(SOUND_ENERGY, m_object->RetPosition(0), + m_sound->Play(SOUND_ENERGY, m_object->GetPosition(0), 1.0f, 1.0f+Math::Rand()*1.5f); } } @@ -337,11 +338,11 @@ bool CAutoEnergy::EventProcess(const Event &event) { if ( m_progress < 1.0f ) { - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y += 17.0f; pos.x += (Math::Rand()-0.5f)*3.0f; pos.z += (Math::Rand()-0.5f)*3.0f; @@ -350,7 +351,7 @@ bool CAutoEnergy::EventProcess(const Event &event) speed.y = 6.0f+Math::Rand()*6.0f; dim.x = Math::Rand()*1.5f+1.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f); } } else @@ -376,10 +377,10 @@ CObject* CAutoEnergy::SearchMetal() CObject* pObj; ObjectType type; - pObj = m_object->RetPower(); + pObj = m_object->GetPower(); if ( pObj == 0 ) return 0; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_METAL || type == OBJECT_SCRAP1 || type == OBJECT_SCRAP2 || @@ -398,14 +399,14 @@ bool CAutoEnergy::SearchVehicle() float oRadius, dist; int i; - cPos = m_object->RetPosition(0); + cPos = m_object->GetPosition(0); for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_HUMAN && type != OBJECT_MOBILEfa && type != OBJECT_MOBILEta && @@ -457,8 +458,8 @@ void CAutoEnergy::CreatePower() Math::Vector pos; float angle; - pos = m_object->RetPosition(0); - angle = m_object->RetAngleY(0); + pos = m_object->GetPosition(0); + angle = m_object->GetAngleY(0); power = new CObject(m_iMan); if ( !power->CreateResource(pos, angle, OBJECT_POWER) ) @@ -469,7 +470,7 @@ void CAutoEnergy::CreatePower() } power->SetLock(true); // battery not yet usable - pos = power->RetPosition(0); + pos = power->GetPosition(0); pos.y += 3.0f; power->SetPosition(0, pos); } @@ -483,19 +484,19 @@ CObject* CAutoEnergy::SearchPower() ObjectType type; int i; - cPos = m_object->RetPosition(0); + cPos = m_object->GetPosition(0); for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetLock() ) continue; + if ( !pObj->GetLock() ) continue; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_POWER ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); if ( oPos.x == cPos.x && oPos.z == cPos.z ) { @@ -507,15 +508,15 @@ CObject* CAutoEnergy::SearchPower() } -// Returns an error due the state of the automation. +// Geturns an error due the state of the automation. -Error CAutoEnergy::RetError() +Error CAutoEnergy::GetError() { CObject* pObj; ObjectType type; - TerrainRes res; + Gfx::TerrainRes res; - if ( m_object->RetVirusMode() ) + if ( m_object->GetVirusMode() ) { return ERR_BAT_VIRUS; } @@ -523,14 +524,14 @@ Error CAutoEnergy::RetError() if ( m_phase != AENP_WAIT && m_phase != AENP_BLITZ ) return ERR_OK; - res = m_terrain->RetResource(m_object->RetPosition(0)); - if ( res != TR_POWER ) return ERR_ENERGY_NULL; + res = m_terrain->GetResource(m_object->GetPosition(0)); + if ( res != Gfx::TR_POWER ) return ERR_ENERGY_NULL; - if ( m_object->RetEnergy() < ENERGY_POWER ) return ERR_ENERGY_LOW; + if ( m_object->GetEnergy() < ENERGY_POWER ) return ERR_ENERGY_LOW; - pObj = m_object->RetPower(); + pObj = m_object->GetPower(); if ( pObj == 0 ) return ERR_ENERGY_EMPTY; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_POWER ) return ERR_OK; if ( type != OBJECT_METAL && type != OBJECT_SCRAP1 && @@ -545,7 +546,7 @@ Error CAutoEnergy::RetError() bool CAutoEnergy::CreateInterface(bool bSelect) { - CWindow* pw; + Ui::CWindow* pw; Math::Point pos, ddim; float ox, oy, sx, sy; @@ -553,7 +554,7 @@ bool CAutoEnergy::CreateInterface(bool bSelect) if ( !bSelect ) return true; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw == 0 ) return false; ox = 3.0f/640.0f; @@ -581,23 +582,23 @@ bool CAutoEnergy::CreateInterface(bool bSelect) void CAutoEnergy::UpdateInterface(float rTime) { - CWindow* pw; - CGauge* pg; + Ui::CWindow* pw; + Ui::CGauge* pg; CAuto::UpdateInterface(rTime); if ( m_time < m_lastUpdateTime+0.1f ) return; m_lastUpdateTime = m_time; - if ( !m_object->RetSelect() ) return; + if ( !m_object->GetSelect() ) return; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw == 0 ) return; - pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY); + pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GENERGY)); if ( pg != 0 ) { - pg->SetLevel(m_object->RetEnergy()); + pg->SetLevel(m_object->GetEnergy()); } } @@ -636,12 +637,12 @@ bool CAutoEnergy::Read(char *line) CAuto::Read(line); - m_phase = (AutoEnergyPhase)OpInt(line, "aPhase", AENP_WAIT); + m_phase = static_cast< AutoEnergyPhase >(OpInt(line, "aPhase", AENP_WAIT)); m_progress = OpFloat(line, "aProgress", 0.0f); m_speed = OpFloat(line, "aSpeed", 1.0f); m_lastUpdateTime = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; return true; } -- cgit v1.2.3-1-g7c22