summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2014-07-02 11:33:47 +0200
committerDidier Raboud <odyx@debian.org>2014-07-02 11:33:47 +0200
commit2e136acd34c45e5e6d105cabf91c67e5865c38fe (patch)
tree8561603160cce0b41ba31250539a22d37a2951de /src/object
parent562be6fe765d7742f7c38fbd82f8cc26369e238b (diff)
parentd9fee8b2adad613cf8c10d153cd5cd7b261b7863 (diff)
downloadcolobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.tar.gz
colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.tar.bz2
colobot-2e136acd34c45e5e6d105cabf91c67e5865c38fe.zip
Merge tag 'colobot-gold-0.1.3-alpha' into debian
Diffstat (limited to 'src/object')
-rw-r--r--src/object/auto/auto.cpp2
-rw-r--r--src/object/auto/autobase.cpp103
-rw-r--r--src/object/auto/autobase.h2
-rw-r--r--src/object/brain.cpp32
-rw-r--r--src/object/object.cpp86
-rw-r--r--src/object/object.h467
-rw-r--r--src/object/objman.cpp65
-rw-r--r--src/object/objman.h6
-rw-r--r--src/object/robotmain.cpp642
-rw-r--r--src/object/robotmain.h29
-rw-r--r--src/object/task/taskbuild.cpp3
-rw-r--r--src/object/task/taskgoto.cpp4
-rw-r--r--src/object/task/taskgungoal.cpp24
-rw-r--r--src/object/task/taskgungoal.h2
-rw-r--r--src/object/task/taskrecover.cpp4
-rw-r--r--src/object/task/taskterraform.cpp23
16 files changed, 644 insertions, 850 deletions
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 0aeaa0a..9e593a9 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -175,7 +175,6 @@ bool CAuto::CreateInterface(bool bSelect)
Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
- char name[100];
pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != nullptr )
@@ -195,6 +194,7 @@ bool CAuto::CreateInterface(bool bSelect)
pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
+ std::string name;
m_object->GetTooltipName(name);
pos.x = 0.0f;
pos.y = 64.0f/480.0f;
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index 6d61bc2..af6c6e0 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -121,7 +121,6 @@ bool CAutoBase::EventProcess(const Event &event)
CObject* pObj;
Math::Vector pos, speed, vibCir, iPos;
Math::Point dim, p;
- Error err;
float angle, dist, time, h, len, vSpeed;
int i, max;
@@ -313,50 +312,7 @@ begin:
if ( event.type == EVENT_OBJECT_BTAKEOFF )
{
- err = CheckCloseDoor();
- if ( err != ERR_OK )
- {
- m_main->DisplayError(err, m_object);
- return false;
- }
-
- err = m_main->CheckEndMission(false);
- if ( err != ERR_OK )
- {
- m_main->DisplayError(err, m_object);
- return false;
- }
-
- FreezeCargo(true); // freeze whole cargo
- m_main->SetMovieLock(true); // blocks everything until the end
- m_main->DeselectAll();
-
- newEvent.type = EVENT_UPDINTERFACE;
- m_eventQueue->AddEvent(newEvent);
-
- m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
-
- pos = m_pos;
- pos.x -= 110.0f;
- m_terrain->AdjustToFloor(pos);
- pos.y += 10.0f;
- m_camera->SetScriptEye(pos);
- m_posSound = pos;
-
- pos = m_object->GetPosition(0);
- pos.y += 50.0f;
- m_camera->SetScriptLookat(pos);
-
- m_engine->SetFocus(1.0f);
-
- m_soundChannel = m_sound->Play(SOUND_MANIP, m_posSound, 0.3f, 1.5f, true);
- m_sound->AddEnvelope(m_soundChannel, 0.3f, 1.5f, BASE_DOOR_TIME2, SOPER_CONTINUE);
- m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 0.5f, SOPER_STOP);
-
- m_phase = ABP_CLOSE2;
- m_progress = 0.0f;
- m_speed = 1.0f/BASE_DOOR_TIME2;
- return true;
+ return TakeOff(true);
}
if ( event.type != EVENT_FRAME ) return true;
@@ -1400,11 +1356,7 @@ void CAutoBase::BeginTransit()
}
else
{
-#if _DEMO
- m_bgBack = "back46b.png"; // paintings
-#else
m_bgBack = "back46.png"; // paintings
-#endif
}
m_engine->SetFogStart(0.9f); // hardly any fog
@@ -1444,3 +1396,56 @@ void CAutoBase::EndTransit()
m_main->StartMusic();
}
+Error CAutoBase::TakeOff(bool printMsg)
+{
+
+ Event newEvent;
+ Math::Vector pos;
+ Error err;
+
+ err = CheckCloseDoor();
+ if ( err != ERR_OK )
+ {
+ if(printMsg) m_main->DisplayError(err, m_object);
+ return err;
+ }
+
+ err = m_main->CheckEndMission(false);
+ if ( err != ERR_OK )
+ {
+ if(printMsg) m_main->DisplayError(err, m_object);
+ return err;
+ }
+
+ FreezeCargo(true); // freeze whole cargo
+ m_main->SetMovieLock(true); // blocks everything until the end
+ m_main->DeselectAll();
+
+ newEvent.type = EVENT_UPDINTERFACE;
+ m_eventQueue->AddEvent(newEvent);
+
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
+
+ pos = m_pos;
+ pos.x -= 110.0f;
+ m_terrain->AdjustToFloor(pos);
+ pos.y += 10.0f;
+ m_camera->SetScriptEye(pos);
+ m_posSound = pos;
+
+ pos = m_object->GetPosition(0);
+ pos.y += 50.0f;
+ m_camera->SetScriptLookat(pos);
+
+ m_engine->SetFocus(1.0f);
+
+ m_soundChannel = m_sound->Play(SOUND_MANIP, m_posSound, 0.3f, 1.5f, true);
+ m_sound->AddEnvelope(m_soundChannel, 0.3f, 1.5f, BASE_DOOR_TIME2, SOPER_CONTINUE);
+ m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 0.5f, SOPER_STOP);
+
+ m_phase = ABP_CLOSE2;
+ m_progress = 0.0f;
+ m_speed = 1.0f/BASE_DOOR_TIME2;
+ return ERR_OK;
+}
+
diff --git a/src/object/auto/autobase.h b/src/object/auto/autobase.h
index 422f340..967e43d 100644
--- a/src/object/auto/autobase.h
+++ b/src/object/auto/autobase.h
@@ -77,6 +77,8 @@ public:
Error GetError();
bool CreateInterface(bool bSelect);
+
+ Error TakeOff(bool printMsg);
protected:
void UpdateInterface();
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 1b1565a..4bd8742 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -1238,7 +1238,6 @@ bool CBrain::CreateInterface(bool bSelect)
Ui::CLabel* pl;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
- char name[100];
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
@@ -1259,13 +1258,14 @@ bool CBrain::CreateInterface(bool bSelect)
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
- m_object->GetTooltipName(name);
+ std::string tooltipLabel;
+ m_object->GetTooltipName(tooltipLabel);
pos.x = 0.0f;
pos.y = 64.0f/480.0f;
ddim.x = 540.0f/640.0f;
if ( !m_main->GetShowMap() ) ddim.x = 640.0f/640.0f;
ddim.y = 16.0f/480.0f;
- pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, name);
+ pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, tooltipLabel);
dim.x = 33.0f/640.0f;
dim.y = 33.0f/480.0f;
@@ -1674,8 +1674,10 @@ bool CBrain::CreateInterface(bool bSelect)
pos.y = oy+sy*1.2f;
ddim.x = dim.x*2.2f;
ddim.y = dim.y*0.4f;
- GetResource(RES_TEXT, RT_INTERFACE_REC, name);
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
+
+ std::string recordLabel;
+ GetResource(RES_TEXT, RT_INTERFACE_REC, recordLabel);
+ pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, recordLabel);
pl->SetFontSize(9.0f);
pos.x = ox+sx*7.0f;
@@ -1787,9 +1789,6 @@ bool CBrain::CreateInterface(bool bSelect)
pos.x = ox+sx*13.4f;
pos.y = oy+sy*0;
-#if _TEEN
- pw->CreateButton(pos, dim, 9, EVENT_OBJECT_RESET);
-#else
if ( m_object->GetTrainer() ) // Training?
{
pw->CreateButton(pos, dim, 9, EVENT_OBJECT_RESET);
@@ -1798,7 +1797,6 @@ bool CBrain::CreateInterface(bool bSelect)
{
pw->CreateButton(pos, dim, 10, EVENT_OBJECT_DESELECT);
}
-#endif
if ( type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
@@ -2457,17 +2455,10 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
char name[100];
char title[100];
int i;
- bool bSoluce;
pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_PROGLIST));
if ( pl == 0 ) return;
-#if _SCHOOL
- bSoluce = m_main->GetSoluce4();
-#else
- bSoluce = true;
-#endif
-
for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
sprintf(name, "%d", i+1);
@@ -2475,10 +2466,6 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
if ( m_script[i] != 0 )
{
m_script[i]->GetTitle(title);
- if ( !bSoluce && i == 3 )
- {
- title[0] = 0;
- }
if ( title[0] != 0 )
{
sprintf(name, "%d: %s", i+1, title);
@@ -2488,11 +2475,6 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
pl->SetItemName(i, name);
}
- if ( !bSoluce )
- {
- pl->SetEnable(3, false);
- }
-
pl->SetSelect(m_selScript);
pl->ShowSelect(true);
}
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 5a709e6..3c225d0 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -276,6 +276,7 @@ CObject::CObject()
m_lastVirusParticle = 0.0f;
m_totalDesectList = 0;
m_bLock = false;
+ m_bIgnoreBuildCheck = false;
m_bExplo = false;
m_bCargo = false;
m_bBurn = false;
@@ -6781,7 +6782,7 @@ float CObject::GetParam()
// Management of the mode "blocked" of an object.
// For example, a cube of titanium is blocked while it is used to make something,
-//or a vehicle is blocked as its construction is not finished.
+// or a vehicle is blocked as its construction is not finished.
void CObject::SetLock(bool bLock)
{
@@ -6793,6 +6794,18 @@ bool CObject::GetLock()
return m_bLock;
}
+// Ignore checks in build() function
+
+void CObject::SetIgnoreBuildCheck(bool bIgnoreBuildCheck)
+{
+ m_bIgnoreBuildCheck = bIgnoreBuildCheck;
+}
+
+bool CObject::GetIgnoreBuildCheck()
+{
+ return m_bIgnoreBuildCheck;
+}
+
// Management of the mode "current explosion" of an object.
// An object in this mode is not saving.
@@ -7263,10 +7276,10 @@ int CObject::GetDefRank()
// Getes the object name for the tooltip.
-bool CObject::GetTooltipName(char* name)
+bool CObject::GetTooltipName(std::string& name)
{
GetResource(RES_OBJECT, m_type, name);
- return ( name[0] != 0 );
+ return !name.empty();
}
@@ -7390,3 +7403,70 @@ void CObject::SetTraceWidth(float width)
mv->SetTraceWidth(width);
}
+DriveType CObject::GetDriveFromObject(ObjectType type)
+{
+ switch(type) {
+ case OBJECT_MOBILEwt:
+ case OBJECT_MOBILEwa:
+ case OBJECT_MOBILEwc:
+ case OBJECT_MOBILEwi:
+ case OBJECT_MOBILEws:
+ return DRIVE_WHEELED;
+
+ case OBJECT_MOBILEtt:
+ case OBJECT_MOBILEta:
+ case OBJECT_MOBILEtc:
+ case OBJECT_MOBILEti:
+ case OBJECT_MOBILEts:
+ return DRIVE_TRACKED;
+
+ case OBJECT_MOBILEft:
+ case OBJECT_MOBILEfa:
+ case OBJECT_MOBILEfc:
+ case OBJECT_MOBILEfi:
+ case OBJECT_MOBILEfs:
+ return DRIVE_WINGED;
+
+ case OBJECT_MOBILEit:
+ case OBJECT_MOBILEia:
+ case OBJECT_MOBILEic:
+ case OBJECT_MOBILEii:
+ case OBJECT_MOBILEis:
+ return DRIVE_LEGGED;
+
+ default:
+ return DRIVE_OTHER;
+ }
+}
+
+ToolType CObject::GetToolFromObject(ObjectType type)
+{
+ switch(type) {
+ case OBJECT_MOBILEwa:
+ case OBJECT_MOBILEta:
+ case OBJECT_MOBILEfa:
+ case OBJECT_MOBILEia:
+ return TOOL_GRABBER;
+
+ case OBJECT_MOBILEws:
+ case OBJECT_MOBILEts:
+ case OBJECT_MOBILEfs:
+ case OBJECT_MOBILEis:
+ return TOOL_SNIFFER;
+
+ case OBJECT_MOBILEwc:
+ case OBJECT_MOBILEtc:
+ case OBJECT_MOBILEfc:
+ case OBJECT_MOBILEic:
+ return TOOL_SHOOTER;
+
+ case OBJECT_MOBILEwi:
+ case OBJECT_MOBILEti:
+ case OBJECT_MOBILEfi:
+ case OBJECT_MOBILEii:
+ return TOOL_ORGASHOOTER;
+
+ default:
+ return TOOL_OTHER;
+ }
+}
diff --git a/src/object/object.h b/src/object/object.h
index e8b83d9..0e469f2 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -47,245 +47,207 @@ enum ObjectType
{
OBJECT_NULL = 0, //! < object destroyed
OBJECT_FIX = 1, //! < stationary scenery
- OBJECT_PORTICO = 2, //! < gantry
- OBJECT_BASE = 3, //! < great main base
- OBJECT_DERRICK = 4, //! < derrick set
- OBJECT_FACTORY = 5, //! < factory set
- OBJECT_STATION = 6, //! < recharging station
- OBJECT_CONVERT = 7, //! < converter station
- OBJECT_REPAIR = 8, //! < reparation
- OBJECT_TOWER = 9, //! < defense tower
- OBJECT_NEST = 10, //! < nest
- OBJECT_RESEARCH = 11, //! < research center
- OBJECT_RADAR = 12, //! < radar
- OBJECT_ENERGY = 13, //! < energy factory
- OBJECT_LABO = 14, //! < analytical laboratory for insect
- OBJECT_NUCLEAR = 15, //! < nuclear power plant
- OBJECT_START = 16, //! < starting
- OBJECT_END = 17, //! < finish
- OBJECT_INFO = 18, //! < information terminal
- OBJECT_PARA = 19, //! < lightning conductor
- OBJECT_TARGET1 = 20, //! < gate target
- OBJECT_TARGET2 = 21, //! < center target
- OBJECT_SAFE = 22, //! < safe
- OBJECT_HUSTON = 23, //! < control centre
- OBJECT_DESTROYER = 24, //! < destroyer
- OBJECT_FRET = 30, //! < transportable
- OBJECT_STONE = 31, //! < stone
- OBJECT_URANIUM = 32, //! < uranium
- OBJECT_METAL = 33, //! < metal
- OBJECT_POWER = 34, //! < normal battery
- OBJECT_ATOMIC = 35, //! < atomic battery
- OBJECT_BULLET = 36, //! < bullet
- OBJECT_BBOX = 37, //! < black-box
- OBJECT_TNT = 38, //! < box of TNT
- OBJECT_SCRAP1 = 40, //! < metal waste
- OBJECT_SCRAP2 = 41, //! < metal waste
- OBJECT_SCRAP3 = 42, //! < metal waste
- OBJECT_SCRAP4 = 43, //! < plastic waste
- OBJECT_SCRAP5 = 44, //! < plastic waste
- OBJECT_MARKPOWER = 50, //! < mark underground energy source
- OBJECT_MARKSTONE = 51, //! < mark underground ore
- OBJECT_MARKURANIUM = 52, //! < mark underground uranium
- OBJECT_MARKKEYa = 53, //! < mark underground key
- OBJECT_MARKKEYb = 54, //! < mark underground key
- OBJECT_MARKKEYc = 55, //! < mark underground key
- OBJECT_MARKKEYd = 56, //! < mark underground key
- OBJECT_BOMB = 60, //! < bomb
- OBJECT_WINFIRE = 61, //! < fireworks
- OBJECT_SHOW = 62, //! < shows a place
- OBJECT_BAG = 63, //! < survival bag
- OBJECT_PLANT0 = 70, //! < plant 0
- OBJECT_PLANT1 = 71, //! < plant 1
- OBJECT_PLANT2 = 72, //! < plant 2
- OBJECT_PLANT3 = 73, //! < plant 3
- OBJECT_PLANT4 = 74, //! < plant 4
- OBJECT_PLANT5 = 75, //! < plant 5
- OBJECT_PLANT6 = 76, //! < plant 6
- OBJECT_PLANT7 = 77, //! < plant 7
- OBJECT_PLANT8 = 78, //! < plant 8
- OBJECT_PLANT9 = 79, //! < plant 9
- OBJECT_PLANT10 = 80, //! < plant 10
- OBJECT_PLANT11 = 81, //! < plant 11
- OBJECT_PLANT12 = 82, //! < plant 12
- OBJECT_PLANT13 = 83, //! < plant 13
- OBJECT_PLANT14 = 84, //! < plant 14
- OBJECT_PLANT15 = 85, //! < plant 15
- OBJECT_PLANT16 = 86, //! < plant 16
- OBJECT_PLANT17 = 87, //! < plant 17
- OBJECT_PLANT18 = 88, //! < plant 18
- OBJECT_PLANT19 = 89, //! < plant 19
- OBJECT_TREE0 = 90, //! < tree 0
- OBJECT_TREE1 = 91, //! < tree 1
- OBJECT_TREE2 = 92, //! < tree 2
- OBJECT_TREE3 = 93, //! < tree 3
- OBJECT_TREE4 = 94, //! < tree 4
- OBJECT_TREE5 = 95, //! < tree 5
- OBJECT_TREE6 = 96, //! < tree 6
- OBJECT_TREE7 = 97, //! < tree 7
- OBJECT_TREE8 = 98, //! < tree 8
- OBJECT_TREE9 = 99, //! < tree 9
- OBJECT_MOBILEwt = 100, //! < wheel-trainer
- OBJECT_MOBILEtt = 101, //! < track-trainer
- OBJECT_MOBILEft = 102, //! < fly-trainer
- OBJECT_MOBILEit = 103, //! < insect-trainer
- OBJECT_MOBILEwa = 110, //! < wheel-arm
- OBJECT_MOBILEta = 111, //! < track-arm
- OBJECT_MOBILEfa = 112, //! < fly-arm
- OBJECT_MOBILEia = 113, //! < insect-arm
- OBJECT_MOBILEwc = 120, //! < wheel-cannon
- OBJECT_MOBILEtc = 121, //! < track-cannon
- OBJECT_MOBILEfc = 122, //! < fly-cannon
- OBJECT_MOBILEic = 123, //! < insect-cannon
- OBJECT_MOBILEwi = 130, //! < wheel-insect-cannon
- OBJECT_MOBILEti = 131, //! < track-insect-cannon
- OBJECT_MOBILEfi = 132, //! < fly-insect-cannon
- OBJECT_MOBILEii = 133, //! < insect-insect-cannon
- OBJECT_MOBILEws = 140, //! < wheel-search
- OBJECT_MOBILEts = 141, //! < track-search
- OBJECT_MOBILEfs = 142, //! < fly-search
- OBJECT_MOBILEis = 143, //! < insect-search
- OBJECT_MOBILErt = 200, //! < roller-terraform
- OBJECT_MOBILErc = 201, //! < roller-canon
- OBJECT_MOBILErr = 202, //! < roller-recover
- OBJECT_MOBILErs = 203, //! < roller-shield
- 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
- OBJECT_FLAGg = 262, //! < green flag
- OBJECT_FLAGy = 263, //! < yellow flag
- OBJECT_FLAGv = 264, //! < violet flag
- OBJECT_KEYa = 270, //! < key a
- OBJECT_KEYb = 271, //! < key b
- OBJECT_KEYc = 272, //! < key c
- OBJECT_KEYd = 273, //! < key d
- OBJECT_HUMAN = 300, //! < human
- OBJECT_TOTO = 301, //! < toto
- OBJECT_TECH = 302, //! < technician
- OBJECT_BARRIER0 = 400, //! < barrier
- OBJECT_BARRIER1 = 401, //! < barrier
- OBJECT_BARRIER2 = 402, //! < barrier
- OBJECT_BARRIER3 = 403, //! < barrier
- OBJECT_BARRIER4 = 404, //! < barrier
- OBJECT_MOTHER = 500, //! < insect queen
- OBJECT_EGG = 501, //! < egg
- OBJECT_ANT = 502, //! < ant
- OBJECT_SPIDER = 503, //! < spider
- OBJECT_BEE = 504, //! < bee
- OBJECT_WORM = 505, //! < worm
- OBJECT_RUINmobilew1 = 600, //! < ruin 1
- OBJECT_RUINmobilew2 = 601, //! < ruin 1
- OBJECT_RUINmobilet1 = 602, //! < ruin 2
- OBJECT_RUINmobilet2 = 603, //! < ruin 2
- OBJECT_RUINmobiler1 = 604, //! < ruin 3
- OBJECT_RUINmobiler2 = 605, //! < ruin 3
- OBJECT_RUINfactory = 606, //! < ruin 4
- OBJECT_RUINdoor = 607, //! < ruin 5
- OBJECT_RUINsupport = 608, //! < ruin 6
- OBJECT_RUINradar = 609, //! < ruin 7
- OBJECT_RUINconvert = 610, //! < ruin 8
- OBJECT_RUINbase = 611, //! < ruin 9
- OBJECT_RUINhead = 612, //! < ruin 10
- OBJECT_TEEN0 = 620, //! < toy
- OBJECT_TEEN1 = 621, //! < toy
- OBJECT_TEEN2 = 622, //! < toy
- OBJECT_TEEN3 = 623, //! < toy
- OBJECT_TEEN4 = 624, //! < toy
- OBJECT_TEEN5 = 625, //! < toy
- OBJECT_TEEN6 = 626, //! < toy
- OBJECT_TEEN7 = 627, //! < toy
- OBJECT_TEEN8 = 628, //! < toy
- OBJECT_TEEN9 = 629, //! < toy
- OBJECT_TEEN10 = 630, //! < toy
- OBJECT_TEEN11 = 631, //! < toy
- OBJECT_TEEN12 = 632, //! < toy
- OBJECT_TEEN13 = 633, //! < toy
- OBJECT_TEEN14 = 634, //! < toy
- OBJECT_TEEN15 = 635, //! < toy
- OBJECT_TEEN16 = 636, //! < toy
- OBJECT_TEEN17 = 637, //! < toy
- OBJECT_TEEN18 = 638, //! < toy
- OBJECT_TEEN19 = 639, //! < toy
- OBJECT_TEEN20 = 640, //! < toy
- OBJECT_TEEN21 = 641, //! < toy
- OBJECT_TEEN22 = 642, //! < toy
- OBJECT_TEEN23 = 643, //! < toy
- OBJECT_TEEN24 = 644, //! < toy
- OBJECT_TEEN25 = 645, //! < toy
- OBJECT_TEEN26 = 646, //! < toy
- OBJECT_TEEN27 = 647, //! < toy
- OBJECT_TEEN28 = 648, //! < toy
- OBJECT_TEEN29 = 649, //! < toy
- OBJECT_TEEN30 = 650, //! < toy
- OBJECT_TEEN31 = 651, //! < toy
- OBJECT_TEEN32 = 652, //! < toy
- OBJECT_TEEN33 = 653, //! < toy
- OBJECT_TEEN34 = 654, //! < toy
- OBJECT_TEEN35 = 655, //! < toy
- OBJECT_TEEN36 = 656, //! < toy
- OBJECT_TEEN37 = 657, //! < toy
- OBJECT_TEEN38 = 658, //! < toy
- OBJECT_TEEN39 = 659, //! < toy
- OBJECT_TEEN40 = 660, //! < toy
- OBJECT_TEEN41 = 661, //! < toy
- OBJECT_TEEN42 = 662, //! < toy
- OBJECT_TEEN43 = 663, //! < toy
- OBJECT_TEEN44 = 664, //! < toy
- OBJECT_TEEN45 = 665, //! < toy
- OBJECT_TEEN46 = 666, //! < toy
- OBJECT_TEEN47 = 667, //! < toy
- OBJECT_TEEN48 = 668, //! < toy
- OBJECT_TEEN49 = 669, //! < toy
- OBJECT_QUARTZ0 = 700, //! < crystal 0
- OBJECT_QUARTZ1 = 701, //! < crystal 1
- OBJECT_QUARTZ2 = 702, //! < crystal 2
- OBJECT_QUARTZ3 = 703, //! < crystal 3
- OBJECT_QUARTZ4 = 704, //! < crystal 4
- OBJECT_QUARTZ5 = 705, //! < crystal 5
- OBJECT_QUARTZ6 = 706, //! < crystal 6
- OBJECT_QUARTZ7 = 707, //! < crystal 7
- OBJECT_QUARTZ8 = 708, //! < crystal 8
- OBJECT_QUARTZ9 = 709, //! < crystal 9
- OBJECT_ROOT0 = 710, //! < root 0
- OBJECT_ROOT1 = 711, //! < root 1
- OBJECT_ROOT2 = 712, //! < root 2
- OBJECT_ROOT3 = 713, //! < root 3
- OBJECT_ROOT4 = 714, //! < root 4
- OBJECT_ROOT5 = 715, //! < root 5
- OBJECT_ROOT6 = 716, //! < root 6
- OBJECT_ROOT7 = 717, //! < root 7
- OBJECT_ROOT8 = 718, //! < root 8
- OBJECT_ROOT9 = 719, //! < root 9
- OBJECT_SEAWEED0 = 720, //! < seaweed 0
- OBJECT_SEAWEED1 = 721, //! < seaweed 1
- OBJECT_SEAWEED2 = 722, //! < seaweed 2
- OBJECT_SEAWEED3 = 723, //! < seaweed 3
- OBJECT_SEAWEED4 = 724, //! < seaweed 4
- OBJECT_SEAWEED5 = 725, //! < seaweed 5
- OBJECT_SEAWEED6 = 726, //! < seaweed 6
- OBJECT_SEAWEED7 = 727, //! < seaweed 7
- OBJECT_SEAWEED8 = 728, //! < seaweed 8
- OBJECT_SEAWEED9 = 729, //! < seaweed 9
- OBJECT_MUSHROOM0 = 730, //! < mushroom 0
- OBJECT_MUSHROOM1 = 731, //! < mushroom 1
- OBJECT_MUSHROOM2 = 732, //! < mushroom 2
- OBJECT_MUSHROOM3 = 733, //! < mushroom 3
- OBJECT_MUSHROOM4 = 734, //! < mushroom 4
- OBJECT_MUSHROOM5 = 735, //! < mushroom 5
- OBJECT_MUSHROOM6 = 736, //! < mushroom 6
- OBJECT_MUSHROOM7 = 737, //! < mushroom 7
- OBJECT_MUSHROOM8 = 738, //! < mushroom 8
- OBJECT_MUSHROOM9 = 739, //! < mushroom 9
- OBJECT_APOLLO1 = 900, //! < apollo lem
- OBJECT_APOLLO2 = 901, //! < apollo jeep
- OBJECT_APOLLO3 = 902, //! < apollo flag
- OBJECT_APOLLO4 = 903, //! < apollo module
- OBJECT_APOLLO5 = 904, //! < apollo antenna
- OBJECT_HOME1 = 910, //! < home 1
+ OBJECT_PORTICO = 2, //! < Portico
+ OBJECT_BASE = 3, //! < SpaceShip
+ OBJECT_DERRICK = 4, //! < Derrick
+ OBJECT_FACTORY = 5, //! < BotFactory
+ OBJECT_STATION = 6, //! < PowerStation
+ OBJECT_CONVERT = 7, //! < Converter
+ OBJECT_REPAIR = 8, //! < RepairStation
+ OBJECT_TOWER = 9, //! < DefenseTower
+ OBJECT_NEST = 10, //! < AlienNest
+ OBJECT_RESEARCH = 11, //! < ResearchCenter
+ OBJECT_RADAR = 12, //! < RadarStation
+ OBJECT_ENERGY = 13, //! < PowerPlant
+ OBJECT_LABO = 14, //! < AutoLab
+ OBJECT_NUCLEAR = 15, //! < NuclearPlant
+ OBJECT_START = 16, //! < StartArea
+ OBJECT_END = 17, //! < EndArea
+ OBJECT_INFO = 18, //! < ExchangePost
+ OBJECT_PARA = 19, //! < PowerCaptor
+ OBJECT_TARGET1 = 20, //! < Target1 (gate)
+ OBJECT_TARGET2 = 21, //! < Target2 (center)
+ OBJECT_SAFE = 22, //! < Vault
+ OBJECT_HUSTON = 23, //! < Houston
+ OBJECT_DESTROYER = 24, //! < Destroyer
+ OBJECT_FRET = 30, //! < transportable (unused)
+ OBJECT_STONE = 31, //! < TitaniumOre
+ OBJECT_URANIUM = 32, //! < UraniumOre
+ OBJECT_METAL = 33, //! < Titanium
+ OBJECT_POWER = 34, //! < PowerCell
+ OBJECT_ATOMIC = 35, //! < NuclearCell
+ OBJECT_BULLET = 36, //! < OrgaMatter
+ OBJECT_BBOX = 37, //! < BlackBox
+ OBJECT_TNT = 38, //! < TNT
+ OBJECT_SCRAP1 = 40, //! < Scrap1 (metal)
+ OBJECT_SCRAP2 = 41, //! < Scrap2 (metal)
+ OBJECT_SCRAP3 = 42, //! < Scrap3 (metal)
+ OBJECT_SCRAP4 = 43, //! < Scrap4 (plastic)
+ OBJECT_SCRAP5 = 44, //! < Scrap5 (plastic)
+ OBJECT_MARKPOWER = 50, //! < PowerSpot
+ OBJECT_MARKSTONE = 51, //! < TitaniumSpot
+ OBJECT_MARKURANIUM = 52, //! < UraniumSpot
+ OBJECT_MARKKEYa = 53, //! < KeyASpot
+ OBJECT_MARKKEYb = 54, //! < KeyBSpot
+ OBJECT_MARKKEYc = 55, //! < KeyCSpot
+ OBJECT_MARKKEYd = 56, //! < KeyDSpot
+ OBJECT_BOMB = 60, //! < Mine
+ OBJECT_WINFIRE = 61, //! < Firework
+ OBJECT_SHOW = 62, //! < arrow above object (Visit)
+ OBJECT_BAG = 63, //! < Bag
+ OBJECT_PLANT0 = 70, //! < Greenery0
+ OBJECT_PLANT1 = 71, //! < Greenery1
+ OBJECT_PLANT2 = 72, //! < Greenery2
+ OBJECT_PLANT3 = 73, //! < Greenery3
+ OBJECT_PLANT4 = 74, //! < Greenery4
+ OBJECT_PLANT5 = 75, //! < Greenery5
+ OBJECT_PLANT6 = 76, //! < Greenery6
+ OBJECT_PLANT7 = 77, //! < Greenery7
+ OBJECT_PLANT8 = 78, //! < Greenery8
+ OBJECT_PLANT9 = 79, //! < Greenery9
+ OBJECT_PLANT10 = 80, //! < Greenery10
+ OBJECT_PLANT11 = 81, //! < Greenery11
+ OBJECT_PLANT12 = 82, //! < Greenery12
+ OBJECT_PLANT13 = 83, //! < Greenery13
+ OBJECT_PLANT14 = 84, //! < Greenery14
+ OBJECT_PLANT15 = 85, //! < Greenery15
+ OBJECT_PLANT16 = 86, //! < Greenery16
+ OBJECT_PLANT17 = 87, //! < Greenery17
+ OBJECT_PLANT18 = 88, //! < Greenery18
+ OBJECT_PLANT19 = 89, //! < Greenery19
+ OBJECT_TREE0 = 90, //! < Tree0
+ OBJECT_TREE1 = 91, //! < Tree1
+ OBJECT_TREE2 = 92, //! < Tree2
+ OBJECT_TREE3 = 93, //! < Tree3
+ OBJECT_TREE4 = 94, //! < Tree4
+ OBJECT_TREE5 = 95, //! < Tree5
+ OBJECT_MOBILEwt = 100, //! < PracticeBot
+ OBJECT_MOBILEtt = 101, //! < track-trainer (unused)
+ OBJECT_MOBILEft = 102, //! < fly-trainer (unused)
+ OBJECT_MOBILEit = 103, //! < insect-trainer (unused)
+ OBJECT_MOBILEwa = 110, //! < WheeledGrabber
+ OBJECT_MOBILEta = 111, //! < TrackedGrabber
+ OBJECT_MOBILEfa = 112, //! < WingedGrabber
+ OBJECT_MOBILEia = 113, //! < LeggedGrabber
+ OBJECT_MOBILEwc = 120, //! < WheeledShooter
+ OBJECT_MOBILEtc = 121, //! < TrackedShooter
+ OBJECT_MOBILEfc = 122, //! < WingedShooter
+ OBJECT_MOBILEic = 123, //! < LeggedShooter
+ OBJECT_MOBILEwi = 130, //! < WheeledOrgaShooter
+ OBJECT_MOBILEti = 131, //! < TrackedOrgaShooter
+ OBJECT_MOBILEfi = 132, //! < WingedOrgaShooter
+ OBJECT_MOBILEii = 133, //! < LeggedOrgaShooter
+ OBJECT_MOBILEws = 140, //! < WheeledSniffer
+ OBJECT_MOBILEts = 141, //! < TrackedSniffer
+ OBJECT_MOBILEfs = 142, //! < WingedSniffer
+ OBJECT_MOBILEis = 143, //! < LeggedSniffer
+ OBJECT_MOBILErt = 200, //! < Thumper
+ OBJECT_MOBILErc = 201, //! < PhazerShooter
+ OBJECT_MOBILErr = 202, //! < Recycler
+ OBJECT_MOBILErs = 203, //! < Shielder
+ OBJECT_MOBILEsa = 210, //! < Subber
+ OBJECT_MOBILEtg = 211, //! < TargetBot
+ OBJECT_MOBILEdr = 212, //! < Scribbler
+ OBJECT_CONTROLLER = 213, //! < MissionController
+ OBJECT_WAYPOINT = 250, //! < WayPoint
+ OBJECT_FLAGb = 260, //! < BlueFlag
+ OBJECT_FLAGr = 261, //! < RedFlag
+ OBJECT_FLAGg = 262, //! < GreenFlag
+ OBJECT_FLAGy = 263, //! < YellowFlag
+ OBJECT_FLAGv = 264, //! < VioletFlag
+ OBJECT_KEYa = 270, //! < KeyA
+ OBJECT_KEYb = 271, //! < KeyB
+ OBJECT_KEYc = 272, //! < KeyC
+ OBJECT_KEYd = 273, //! < KeyD
+ OBJECT_HUMAN = 300, //! < Me
+ OBJECT_TOTO = 301, //! < Robby (toto)
+ OBJECT_TECH = 302, //! < Tech
+ OBJECT_BARRIER0 = 400, //! < Barrier0
+ OBJECT_BARRIER1 = 401, //! < Barrier1
+ OBJECT_BARRIER2 = 402, //! < Barrier2
+ OBJECT_BARRIER3 = 403, //! < Barrier3
+ OBJECT_MOTHER = 500, //! < AlienQueen
+ OBJECT_EGG = 501, //! < AlienEgg
+ OBJECT_ANT = 502, //! < AlienAnt
+ OBJECT_SPIDER = 503, //! < AlienSpider
+ OBJECT_BEE = 504, //! < AlienWasp
+ OBJECT_WORM = 505, //! < AlienWorm
+ OBJECT_RUINmobilew1 = 600, //! < WreckBotw1
+ OBJECT_RUINmobilew2 = 601, //! < WreckBotw2
+ OBJECT_RUINmobilet1 = 602, //! < WreckBott1
+ OBJECT_RUINmobilet2 = 603, //! < WreckBott2
+ OBJECT_RUINmobiler1 = 604, //! < WreckBotr1
+ OBJECT_RUINmobiler2 = 605, //! < WreckBotr2
+ OBJECT_RUINfactory = 606, //! < RuinBotFactory
+ OBJECT_RUINdoor = 607, //! < RuinDoor
+ OBJECT_RUINsupport = 608, //! < RuinSupport
+ OBJECT_RUINradar = 609, //! < RuinRadar
+ OBJECT_RUINconvert = 610, //! < RuinConvert
+ OBJECT_RUINbase = 611, //! < RuinBaseCamp
+ OBJECT_RUINhead = 612, //! < RuinHeadCamp
+ OBJECT_TEEN0 = 620, //! < Teen0
+ OBJECT_TEEN1 = 621, //! < Teen1
+ OBJECT_TEEN2 = 622, //! < Teen2
+ OBJECT_TEEN3 = 623, //! < Teen3
+ OBJECT_TEEN4 = 624, //! < Teen4
+ OBJECT_TEEN5 = 625, //! < Teen5
+ OBJECT_TEEN6 = 626, //! < Teen6
+ OBJECT_TEEN7 = 627, //! < Teen7
+ OBJECT_TEEN8 = 628, //! < Teen8
+ OBJECT_TEEN9 = 629, //! < Teen9
+ OBJECT_TEEN10 = 630, //! < Teen10
+ OBJECT_TEEN11 = 631, //! < Teen11
+ OBJECT_TEEN12 = 632, //! < Teen12
+ OBJECT_TEEN13 = 633, //! < Teen13
+ OBJECT_TEEN14 = 634, //! < Teen14
+ OBJECT_TEEN15 = 635, //! < Teen15
+ OBJECT_TEEN16 = 636, //! < Teen16
+ OBJECT_TEEN17 = 637, //! < Teen17
+ OBJECT_TEEN18 = 638, //! < Teen18
+ OBJECT_TEEN19 = 639, //! < Teen19
+ OBJECT_TEEN20 = 640, //! < Teen20
+ OBJECT_TEEN21 = 641, //! < Teen21
+ OBJECT_TEEN22 = 642, //! < Teen22
+ OBJECT_TEEN23 = 643, //! < Teen23
+ OBJECT_TEEN24 = 644, //! < Teen24
+ OBJECT_TEEN25 = 645, //! < Teen25
+ OBJECT_TEEN26 = 646, //! < Teen26
+ OBJECT_TEEN27 = 647, //! < Teen27
+ OBJECT_TEEN28 = 648, //! < Teen28
+ OBJECT_TEEN29 = 649, //! < Teen29
+ OBJECT_TEEN30 = 650, //! < Teen30
+ OBJECT_TEEN31 = 651, //! < Teen31
+ OBJECT_TEEN32 = 652, //! < Teen32
+ OBJECT_TEEN33 = 653, //! < Teen33
+ OBJECT_TEEN34 = 654, //! < Stone (Teen34)
+ OBJECT_TEEN35 = 655, //! < Teen35
+ OBJECT_TEEN36 = 656, //! < Teen36
+ OBJECT_TEEN37 = 657, //! < Teen37
+ OBJECT_TEEN38 = 658, //! < Teen38
+ OBJECT_TEEN39 = 659, //! < Teen39
+ OBJECT_TEEN40 = 660, //! < Teen40
+ OBJECT_TEEN41 = 661, //! < Teen41
+ OBJECT_TEEN42 = 662, //! < Teen42
+ OBJECT_TEEN43 = 663, //! < Teen43
+ OBJECT_TEEN44 = 664, //! < Teen44
+ OBJECT_QUARTZ0 = 700, //! < Quartz0
+ OBJECT_QUARTZ1 = 701, //! < Quartz1
+ OBJECT_QUARTZ2 = 702, //! < Quartz2
+ OBJECT_QUARTZ3 = 703, //! < Quartz3
+ OBJECT_ROOT0 = 710, //! < MegaStalk0
+ OBJECT_ROOT1 = 711, //! < MegaStalk1
+ OBJECT_ROOT2 = 712, //! < MegaStalk2
+ OBJECT_ROOT3 = 713, //! < MegaStalk3
+ OBJECT_ROOT4 = 714, //! < MegaStalk4
+ OBJECT_ROOT5 = 715, //! < MegaStalk5
+ OBJECT_MUSHROOM1 = 731, //! < Mushroom1
+ OBJECT_MUSHROOM2 = 732, //! < Mushroom2
+ OBJECT_APOLLO1 = 900, //! < ApolloLEM
+ OBJECT_APOLLO2 = 901, //! < ApolloJeep
+ OBJECT_APOLLO3 = 902, //! < ApolloFlag
+ OBJECT_APOLLO4 = 903, //! < ApolloModule
+ OBJECT_APOLLO5 = 904, //! < ApolloAntenna
+ OBJECT_HOME1 = 910, //! < Home
OBJECT_MAX = 1000 //! < number of values
};
@@ -311,6 +273,24 @@ enum ObjectMaterial
OM_MINERAL = 5, // stone
};
+enum DriveType
+{
+ DRIVE_OTHER = 0,
+ DRIVE_WHEELED,
+ DRIVE_TRACKED,
+ DRIVE_WINGED,
+ DRIVE_LEGGED,
+};
+
+enum ToolType
+{
+ TOOL_OTHER = 0,
+ TOOL_GRABBER,
+ TOOL_SNIFFER,
+ TOOL_SHOOTER,
+ TOOL_ORGASHOOTER,
+};
+
struct ObjectPart
{
char bUsed;
@@ -602,6 +582,9 @@ public:
void SetParam(float value);
float GetParam();
+
+ void SetIgnoreBuildCheck(bool bIgnoreBuildCheck);
+ bool GetIgnoreBuildCheck();
void SetExplo(bool bExplo);
bool GetExplo();
@@ -639,7 +622,7 @@ public:
void SetDefRank(int rank);
int GetDefRank();
- bool GetTooltipName(char* name);
+ bool GetTooltipName(std::string& name);
void AddDeselList(CObject* pObj);
CObject* SubDeselList();
@@ -659,6 +642,9 @@ public:
void SetTraceWidth(float width);
std::string GetModelDirName();
+
+ static DriveType GetDriveFromObject(ObjectType type);
+ static ToolType GetToolFromObject(ObjectType type);
protected:
bool EventFrame(const Event &event);
@@ -737,6 +723,7 @@ protected:
bool m_bTrainer; // drive vehicle (without remote)
bool m_bToy; // toy key
bool m_bManual; // manual control (Scribbler)
+ bool m_bIgnoreBuildCheck;
bool m_bFixed;
bool m_bClip;
bool m_bShowLimit;
diff --git a/src/object/objman.cpp b/src/object/objman.cpp
index e4102b8..b0bac1a 100644
--- a/src/object/objman.cpp
+++ b/src/object/objman.cpp
@@ -30,7 +30,7 @@ CObjectManager::CObjectManager()
{
m_table[i] = nullptr;
}
- usedCount = 0;
+ m_usedCount = 0;
}
CObjectManager::~CObjectManager()
@@ -39,16 +39,16 @@ CObjectManager::~CObjectManager()
bool CObjectManager::AddInstance(CObject* instance)
{
- if (usedCount >= MAX_OBJECTS) return false;
+ if (m_usedCount >= MAX_OBJECTS) return false;
m_table[instance->GetID()] = instance;
- usedCount++;
+ m_usedCount++;
return true;
}
bool CObjectManager::DeleteInstance(CObject* instance)
{
- for (int i = 0; i < usedCount; i++)
+ for (int i = 0; i < m_usedCount; i++)
{
if (m_table[i] == instance)
m_table[i] = nullptr;
@@ -63,10 +63,9 @@ CObject* CObjectManager::SearchInstance(int id)
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* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType type,
+ float power, float zoom, float height,
+ bool trainer, bool toy, int option)
{
CObject* object = nullptr;
@@ -161,8 +160,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
if ( type == OBJECT_BARRIER0 ||
type == OBJECT_BARRIER1 ||
type == OBJECT_BARRIER2 ||
- type == OBJECT_BARRIER3 ||
- type == OBJECT_BARRIER4 )
+ type == OBJECT_BARRIER3 )
{
object = new CObject();
object->CreateBarrier(pos, angle, height, type);
@@ -193,26 +191,14 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
type == OBJECT_TREE2 ||
type == OBJECT_TREE3 ||
type == OBJECT_TREE4 ||
- type == OBJECT_TREE5 ||
- type == OBJECT_TREE6 ||
- type == OBJECT_TREE7 ||
- type == OBJECT_TREE8 ||
- type == OBJECT_TREE9 )
+ type == OBJECT_TREE5 )
{
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 )
+ if ( type == OBJECT_MUSHROOM1 ||
+ type == OBJECT_MUSHROOM2 )
{
object = new CObject();
object->CreateMushroom(pos, angle, height, type);
@@ -262,12 +248,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
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 )
+ type == OBJECT_TEEN44 )
{
object = new CObject();
object->SetOption(option);
@@ -277,13 +258,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
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 )
+ type == OBJECT_QUARTZ3 )
{
object = new CObject();
object->CreateQuartz(pos, angle, height, type);
@@ -294,11 +269,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
type == OBJECT_ROOT2 ||
type == OBJECT_ROOT3 ||
type == OBJECT_ROOT4 ||
- type == OBJECT_ROOT5 ||
- type == OBJECT_ROOT6 ||
- type == OBJECT_ROOT7 ||
- type == OBJECT_ROOT8 ||
- type == OBJECT_ROOT9 )
+ type == OBJECT_ROOT5 )
{
object = new CObject();
object->CreateRoot(pos, angle, height, type);
@@ -387,3 +358,11 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
return object;
}
+void CObjectManager::Flush()
+{
+ for (int i = 0; i < MAX_OBJECTS; i++)
+ {
+ m_table[i] = nullptr;
+ }
+ m_usedCount = 0;
+}
diff --git a/src/object/objman.h b/src/object/objman.h
index 3087383..390587b 100644
--- a/src/object/objman.h
+++ b/src/object/objman.h
@@ -44,10 +44,12 @@ public:
//! 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);
+ CObject* CreateObject(Math::Vector pos, float angle, ObjectType type, float power = -1.f, float zoom = 1.f, float height = 0.f, bool trainer = false, bool toy = false, int option = 0);
+ //! Removes all objects
+ void Flush();
protected:
CObject* m_table[MAX_OBJECTS];
- int usedCount;
+ int m_usedCount;
};
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 26fa827..76c234d 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -20,6 +20,7 @@
#include "CBot/CBotDll.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/event.h"
#include "common/global.h"
@@ -81,6 +82,9 @@
#include <iomanip>
+#include <boost/regex.hpp>
+
+
template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
@@ -618,6 +622,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_cloud = m_engine->GetCloud();
m_lightning = m_engine->GetLightning();
m_planet = m_engine->GetPlanet();
+ m_pause = CPauseManager::GetInstancePointer();
m_interface = new Ui::CInterface();
m_terrain = new Gfx::CTerrain();
@@ -643,6 +648,10 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_visitArrow = 0;
m_audioTrack = "";
m_audioRepeat = true;
+ m_satcomTrack = "";
+ m_satcomRepeat = true;
+ m_editorTrack = "";
+ m_editorRepeat = true;
m_delayWriteMessage = 0;
m_selectObject = 0;
m_infoUsed = 0;
@@ -663,7 +672,6 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_satComLock = false;
m_editLock = false;
m_editFull = false;
- m_pause = false;
m_hilite = false;
m_freePhoto = false;
m_showPos = false;
@@ -690,12 +698,14 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_movieInfoIndex = -1;
m_tooltipPos = Math::Point(0.0f, 0.0f);
- m_tooltipName[0] = 0;
+ m_tooltipName.clear();
m_tooltipTime = 0.0f;
m_endingWinRank = 0;
m_endingLostRank = 0;
m_winTerminate = false;
+
+ m_exitAfterMission = false;
m_joystickDeadzone = 0.2f;
SetDefaultInputBindings();
@@ -881,6 +891,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
bc->AddFunction("busy", CScript::rBusy, CScript::cBusy);
bc->AddFunction("factory", CScript::rFactory, CScript::cFactory);
bc->AddFunction("research", CScript::rResearch, CScript::cClassOneFloat);
+ bc->AddFunction("takeoff", CScript::rTakeOff, CScript::cClassNull);
bc->AddFunction("destroy", CScript::rDestroy, CScript::cClassNull);
// Initializes the class FILE.
@@ -944,6 +955,7 @@ Ui::CDisplayText* CRobotMain::GetDisplayText()
void CRobotMain::LoadSceneOnStart(const std::string& name, int rank)
{
+ m_exitAfterMission = true;
// TODO: fix this ugly dependency :(
m_dialog->SetSceneName(name.c_str());
m_dialog->SetSceneRank(rank);
@@ -987,22 +999,27 @@ void CRobotMain::SetDefaultInputBindings()
m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT);
m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP);
m_inputBindings[INPUT_SLOT_DOWN ].primary = KEY(DOWN);
+ m_inputBindings[INPUT_SLOT_LEFT ].secondary = KEY(a);
+ m_inputBindings[INPUT_SLOT_RIGHT ].secondary = KEY(d);
+ m_inputBindings[INPUT_SLOT_UP ].secondary = KEY(w);
+ m_inputBindings[INPUT_SLOT_DOWN ].secondary = KEY(s);
m_inputBindings[INPUT_SLOT_GUP ].primary = VIRTUAL_KMOD(SHIFT);
m_inputBindings[INPUT_SLOT_GDOWN ].primary = VIRTUAL_KMOD(CTRL);
m_inputBindings[INPUT_SLOT_CAMERA ].primary = KEY(SPACE);
- m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
+// m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
m_inputBindings[INPUT_SLOT_DESEL ].primary = KEY(KP0);
- m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
+// m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
m_inputBindings[INPUT_SLOT_ACTION ].primary = KEY(RETURN);
- m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
+// m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
+ m_inputBindings[INPUT_SLOT_ACTION ].secondary = KEY(e);
m_inputBindings[INPUT_SLOT_NEAR ].primary = KEY(KP_PLUS);
- m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
+// m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
m_inputBindings[INPUT_SLOT_AWAY ].primary = KEY(KP_MINUS);
- m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
+// m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
m_inputBindings[INPUT_SLOT_NEXT ].primary = KEY(TAB);
- m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
+// m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
m_inputBindings[INPUT_SLOT_HUMAN ].primary = KEY(HOME);
- m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
+// m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
m_inputBindings[INPUT_SLOT_QUIT ].primary = KEY(ESCAPE);
m_inputBindings[INPUT_SLOT_HELP ].primary = KEY(F1);
m_inputBindings[INPUT_SLOT_PROG ].primary = KEY(F2);
@@ -1063,12 +1080,9 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_phase == PHASE_SIMUL) // ends a simulation?
{
SaveAllScript();
- m_sound->StopMusic();
+ m_sound->StopMusic(0.0f);
m_camera->SetControllingObject(0);
-/* TODO: #if _SCHOOL
- if ( true )
-#else*/
if (m_gameTime > 10.0f) // did you play at least 10 seconds?
{
int rank = m_dialog->GetSceneRank();
@@ -1101,7 +1115,7 @@ void CRobotMain::ChangePhase(Phase phase)
m_resetCreate = false;
m_engine->SetMovieLock(m_movieLock);
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
FlushDisplayInfo();
m_engine->SetRankView(0);
m_terrain->FlushRelief();
@@ -1139,6 +1153,8 @@ void CRobotMain::ChangePhase(Phase phase)
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
Math::Point dim, pos;
@@ -1153,12 +1169,6 @@ void CRobotMain::ChangePhase(Phase phase)
m_cmdEdit = false; // hidden for now
// Creates the speedometer.
-/* TODO: #if _TEEN
- dim.x = 30.0f/640.0f;
- dim.y = 20.0f/480.0f;
- pos.x = 4.0f/640.0f;
- pos.y = 454.0f/480.0f;
-#else*/
dim.x = 30.0f/640.0f;
dim.y = 20.0f/480.0f;
pos.x = 4.0f/640.0f;
@@ -1217,7 +1227,7 @@ void CRobotMain::ChangePhase(Phase phase)
m_infoFilename[SATCOM_HUSTON][0] != 0)
StartDisplayInfo(SATCOM_HUSTON, false); // shows the instructions
- m_sound->StopMusic();
+ m_sound->StopMusic(0.0f);
if (!m_base || loading) StartMusic();
}
@@ -1230,10 +1240,6 @@ void CRobotMain::ChangePhase(Phase phase)
}
else
{
-/* TODO: #if _TEEN
- m_winTerminate = (m_endingWinRank == 900);
- m_dialog->SetSceneName("teenw");
-#else*/
m_winTerminate = (m_endingWinRank == 904);
m_dialog->SetSceneName("win");
@@ -1247,16 +1253,6 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_winTerminate)
{
-/* TODO: #if _TEEN
- pos.x = ox+sx*3; pos.y = oy+sy*1;
- ddim.x = dim.x*15; ddim.y = dim.y*2;
- pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
- pe->SetFontType(FONT_COLOBOT);
- pe->SetEditCap(false);
- pe->SetHiliteCap(false);
- pe->ReadText("help/teenw.txt");
-#else*/
-
pos.x = ox+sx*3; pos.y = oy+sy*0.2f;
ddim.x = dim.x*15; ddim.y = dim.y*3.0f;
pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
@@ -1376,7 +1372,7 @@ bool CRobotMain::ProcessEvent(Event &event)
MainMovieType type = m_movie->GetStopType();
if (type == MM_SATCOMopen)
{
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
SelectObject(m_infoObject, false); // hands over the command buttons
m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
@@ -1408,7 +1404,7 @@ bool CRobotMain::ProcessEvent(Event &event)
if (pe == nullptr) return false;
pe->SetState(Ui::STATE_VISIBLE);
pe->SetFocus(true);
- if (m_phase == PHASE_SIMUL) ChangePause(true);
+ if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_CHEAT);
m_cmdEdit = true;
return false;
}
@@ -1421,7 +1417,7 @@ bool CRobotMain::ProcessEvent(Event &event)
pe->GetText(cmd, 50);
pe->SetText("");
pe->ClearState(Ui::STATE_VISIBLE);
- if (m_phase == PHASE_SIMUL) ChangePause(false);
+ if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_NONE);
ExecuteCmd(cmd);
m_cmdEdit = false;
return false;
@@ -1551,7 +1547,7 @@ bool CRobotMain::ProcessEvent(Event &event)
m_camera->GetType() != Gfx::CAM_TYPE_VISIT &&
!m_movie->IsExist())
{
- ChangePause(!m_engine->GetPause());
+ ChangePause(m_pause->GetPause(PAUSE_USER) ? PAUSE_NONE : PAUSE_USER);
}
}
if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).primary ||
@@ -1741,10 +1737,14 @@ bool CRobotMain::ProcessEvent(Event &event)
case EVENT_WIN:
ChangePhase(PHASE_WIN);
+ if(m_exitAfterMission)
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
break;
case EVENT_LOST:
ChangePhase(PHASE_LOST);
+ if(m_exitAfterMission)
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
break;
default:
@@ -1781,6 +1781,7 @@ bool CRobotMain::ProcessEvent(Event &event)
ChangePhase(PHASE_INIT);
else
ChangePhase(PHASE_TERM);
+
break;
default:
@@ -1875,12 +1876,12 @@ void CRobotMain::ExecuteCmd(char *cmd)
if (m_freePhoto)
{
m_camera->SetType(Gfx::CAM_TYPE_FREE);
- ChangePause(true);
+ ChangePause(PAUSE_PHOTO);
}
else
{
m_camera->SetType(Gfx::CAM_TYPE_BACK);
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
}
return;
}
@@ -1891,7 +1892,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
if (m_freePhoto)
{
m_camera->SetType(Gfx::CAM_TYPE_FREE);
- ChangePause(true);
+ ChangePause(PAUSE_PHOTO);
DeselectAll(); // removes the control buttons
m_map->ShowMap(false);
m_displayText->HideText(true);
@@ -1899,7 +1900,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
else
{
m_camera->SetType(Gfx::CAM_TYPE_BACK);
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
}
@@ -2082,9 +2083,6 @@ void CRobotMain::ExecuteCmd(char *cmd)
return;
}
-/* TODO: #if _TEEN
- if (strcmp(cmd, "allteens") == 0)
-#else*/
if (strcmp(cmd, "allmission") == 0)
{
m_showAll = !m_showAll;
@@ -2158,7 +2156,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
{
m_movieInfoIndex = index;
m_movie->Start(MM_SATCOMopen, 2.5f);
- ChangePause(true);
+ ChangePause(PAUSE_SATCOMMOVIE);
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
return;
@@ -2168,7 +2166,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
if (m_movie->IsExist())
{
m_movie->Stop();
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
SelectObject(m_infoObject, false); // hands over the command buttons
m_displayText->HideText(false);
}
@@ -2445,7 +2443,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
}
Math::Vector goal = m_displayText->GetVisitGoal(event);
- m_visitArrow = CreateObject(goal, 0.0f, 1.0f, 10.0f, OBJECT_SHOW, false, false, 0);
+ m_visitArrow = CObjectManager::GetInstancePointer()->CreateObject(goal, 0.0f, OBJECT_SHOW, -1.0f, 1.0f, 10.0f);
m_visitPos = m_visitArrow->GetPosition(0);
m_visitPosArrow = m_visitPos;
@@ -2460,7 +2458,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
m_camera->StartVisit(m_displayText->GetVisitGoal(event),
m_displayText->GetVisitDist(event));
m_displayText->SetVisit(event);
- ChangePause(true);
+ ChangePause(PAUSE_VISIT);
}
//! Move the arrow to visit
@@ -2514,7 +2512,7 @@ void CRobotMain::StopDisplayVisit()
m_camera->StopVisit();
m_displayText->ClearVisit();
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
if (m_visitObject != 0)
{
SelectObject(m_visitObject, false); // gives the command buttons
@@ -2612,7 +2610,7 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError)
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
StopDisplayVisit();
- if (m_movieLock || m_editLock || m_pause) return false;
+ if (m_movieLock || m_editLock || m_pause->GetPause()) return false;
if (m_movie->IsExist()) return false;
if (obj == nullptr || !IsSelectable(obj)) return false;
@@ -3025,7 +3023,7 @@ bool CRobotMain::DeleteObject()
void CRobotMain::HiliteClear()
{
ClearTooltip();
- m_tooltipName[0] = 0; // really removes the tooltip
+ m_tooltipName.clear(); // really removes the tooltip
if (!m_hilite) return;
@@ -3059,11 +3057,11 @@ void CRobotMain::HiliteObject(Math::Point pos)
CObject* obj = m_short->DetectShort(pos);
- std::string nameStr;
- if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, nameStr))
+ std::string interfaceTooltipName;
+ if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, interfaceTooltipName))
{
m_tooltipPos = pos;
- strcpy(m_tooltipName, nameStr.c_str());
+ m_tooltipName = interfaceTooltipName;
m_tooltipTime = 0.0f;
if (obj == nullptr) return;
}
@@ -3086,13 +3084,13 @@ void CRobotMain::HiliteObject(Math::Point pos)
}
}
- char name[100];
if (obj != nullptr)
{
- if (m_dialog->GetTooltip() && obj->GetTooltipName(name))
+ std::string objectTooltipName;
+ if (m_dialog->GetTooltip() && obj->GetTooltipName(objectTooltipName))
{
m_tooltipPos = pos;
- strcpy(m_tooltipName, name);
+ m_tooltipName = objectTooltipName;
m_tooltipTime = 0.0f;
}
@@ -3117,15 +3115,14 @@ void CRobotMain::HiliteFrame(float rTime)
ClearTooltip();
- if (m_tooltipTime >= 0.2f &&
- m_tooltipName[0] != 0)
+ if (m_tooltipTime >= 0.2f && !m_tooltipName.empty())
{
CreateTooltip(m_tooltipPos, m_tooltipName);
}
}
//! Creates a tooltip
-void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
+void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
{
Math::Point corner;
corner.x = pos.x+0.022f;
@@ -3515,7 +3512,7 @@ bool CRobotMain::EventFrame(const Event &event)
}
// Moves edition indicator.
- if (m_editLock || m_pause) // edition in progress?
+ if (m_editLock || m_pause->GetPause()) // edition in progress?
{
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
if (pc != nullptr)
@@ -3856,6 +3853,8 @@ void CRobotMain::ScenePerso()
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
m_dialog->SetSceneName("perso");
m_dialog->SetSceneRank(0);
@@ -3903,6 +3902,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_terrain->FlushMaterials();
m_audioTrack = "";
m_audioRepeat = true;
+ m_satcomTrack = "";
+ m_satcomRepeat = true;
+ m_editorTrack = "";
+ m_editorRepeat = true;
m_displayText->SetDelay(1.0f);
m_displayText->SetEnable(true);
m_immediatSatCom = false;
@@ -3949,7 +3952,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_dialog->BuildResumeName(m_title, base, rank);
m_dialog->BuildResumeName(m_resume, base, rank);
- GetResource(RES_TEXT, RT_SCRIPT_NEW, m_scriptName);
+ std::string scriptNameStr;
+ GetResource(RES_TEXT, RT_SCRIPT_NEW, scriptNameStr);
+ strcpy(m_scriptName, scriptNameStr.c_str());
m_scriptFile[0] = 0;
m_beginObject = false;
@@ -4006,8 +4011,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
}
- if (Cmd(line, "MissionFile") && !resetObject)
+ if (Cmd(line, "MissionFile") && !resetObject) {
m_version = OpInt(line, "version", 1);
+ continue;
+ }
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
@@ -4031,9 +4038,14 @@ 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
+ static const boost::regex titleCmdRe("Title\\.[A-Z]");
+ static const boost::regex resumeCmdRe("Resume\\.[A-Z]");
+ static const boost::regex scriptNameCmdRe("ScriptName\\.[A-Z]");
+
+ if (boost::regex_match(GetCmd(line), titleCmdRe)) continue; // Ignore
+ if (boost::regex_match(GetCmd(line), resumeCmdRe)) continue; // Ignore
+ if (boost::regex_match(GetCmd(line), scriptNameCmdRe)) continue; // Ignore
+
if (Cmd(line, "ScriptFile") && !resetObject)
{
@@ -4044,18 +4056,19 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "Instructions") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
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_app->GetSceneTestMode()) m_immediatSatCom = false;
continue;
}
if (Cmd(line, "Satellite") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_SAT], path.c_str());
continue;
}
@@ -4063,7 +4076,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "Loading") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_LOADING], path.c_str());
continue;
}
@@ -4071,14 +4084,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "HelpFile") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(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);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str());
continue;
}
@@ -4109,12 +4122,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
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].dist = OpFloat(line, "dist", 1000.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);
+ m_audioChange[i].powermin = OpFloat(line, "powermin", -1);
+ m_audioChange[i].powermax = OpFloat(line, "powermax", 100);
+ m_audioChange[i].tool = OpTool(line, "tool");
+ m_audioChange[i].drive = OpDrive(line, "drive");
OpString(line, "filename", m_audioChange[i].music);
m_audioChange[i].repeat = OpInt(line, "repeat", 1);
m_audioChange[i].changed = false;
@@ -4135,15 +4150,27 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
filenameStr << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg";
m_audioTrack = filenameStr.str();
}
+ m_audioRepeat = OpInt(line, "repeat", 1);
}
else
{
char trackname[100];
- OpString(line, "filename", trackname);
+
+ OpString(line, "main", trackname);
m_audioTrack = trackname;
+ m_audioRepeat = OpInt(line, "mainRepeat", 1);
+
+ OpString(line, "satcom", trackname);
+ m_satcomTrack = trackname;
+ m_satcomRepeat = OpInt(line, "satcomRepeat", 1);
+
+ OpString(line, "editor", trackname);
+ m_editorTrack = trackname;
+ m_editorRepeat = OpInt(line, "editorRepeat", 1);
}
- m_audioRepeat = OpInt(line, "repeat", 1);
if (m_audioTrack != "") m_sound->CacheMusic(m_audioTrack);
+ if (m_satcomTrack != "") m_sound->CacheMusic(m_satcomTrack);
+ if (m_editorTrack != "") m_sound->CacheMusic(m_editorTrack);
continue;
}
@@ -4325,6 +4352,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_terrain->LoadRelief(name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1));
continue;
}
+
+ if (Cmd(line, "TerrainRandomRelief") && !resetObject)
+ {
+ m_terrain->RandomizeRelief();
+ continue;
+ }
if (Cmd(line, "TerrainResource") && !resetObject)
{
@@ -4539,15 +4572,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "MissionController") && read[0] == 0 && m_version >= 2)
{
- /* TODO: ???
- 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 = CObjectManager::GetInstancePointer()->CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, OBJECT_CONTROLLER, 100.0f);
m_controller->SetMagnifyDamage(100.0f);
+ m_controller->SetIgnoreBuildCheck(true);
CBrain* brain = m_controller->GetBrain();
if (brain != nullptr)
{
@@ -4577,11 +4604,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
(type >= OBJECT_PLANT0 &&
type <= OBJECT_PLANT19 ) ||
(type >= OBJECT_TREE0 &&
- type <= OBJECT_TREE9 ) ||
+ type <= OBJECT_TREE5 ) ||
(type >= OBJECT_TEEN0 &&
- type <= OBJECT_TEEN49 ) ||
+ type <= OBJECT_TEEN44 ) ||
(type >= OBJECT_QUARTZ0 &&
- type <= OBJECT_QUARTZ9 ) ||
+ type <= OBJECT_QUARTZ3 ) ||
(type >= OBJECT_ROOT0 &&
type <= OBJECT_ROOT4 ) ) // not ROOT5!
{
@@ -4605,15 +4632,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
Math::Vector pos = OpPos(line, "pos")*g_unit;
float dirAngle = OpFloat(line, "dir", 0.0f)*Math::PI;
- bool trainer = OpInt(line, "trainer", 0);
- CObject* obj = CreateObject(pos, dirAngle,
- OpFloat(line, "z", 1.0f),
- OpFloat(line, "h", 0.0f),
+ bool trainer;
+ CObject* obj = CObjectManager::GetInstancePointer()->CreateObject(
+ pos, dirAngle,
type,
OpFloat(line, "power", 1.0f),
- trainer,
+ OpFloat(line, "z", 1.0f),
+ OpFloat(line, "h", 0.0f),
+ trainer = OpInt(line, "trainer", 0),
OpInt(line, "toy", 0),
OpInt(line, "option", 0));
+
+ if (m_fixScene && type == OBJECT_HUMAN)
+ {
+ CMotion* motion = obj->GetMotion();
+ if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f);
+ if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
+ }
if (obj != nullptr)
{
@@ -4667,6 +4702,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
bool selectable = OpInt(line, "selectable", 1);
obj->SetSelectable(selectable);
+ obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
obj->SetEnable(OpInt(line, "enable", 1));
obj->SetProxyActivate(OpInt(line, "proxyActivate", 0));
obj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit);
@@ -4709,9 +4745,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
{
sprintf(op, "script%d", i+1); // script1..script10
OpString(line, op, name);
-/* TODO: #if _SCHOOL
- if ( !m_dialog->GetSoluce4() && i == 3 ) continue;
-#endif*/
if (name[0] != 0)
brain->SetScriptName(i, name);
@@ -4910,19 +4943,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
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].dist = OpFloat(line, "dist", (m_version < 2 ? 8.0f : 100.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].powermin = OpFloat(line, "powermin", -1);
+ m_endTake[i].powermax = OpFloat(line, "powermax", 100);
+ m_endTake[i].tool = OpTool(line, "tool");
+ m_endTake[i].drive = OpDrive(line, "drive");
}
else
{
m_endTake[i].powermin = -1;
m_endTake[i].powermax = 100;
+ m_endTake[i].tool = TOOL_OTHER;
+ m_endTake[i].drive = DRIVE_OTHER;
}
m_endTake[i].lost = OpInt(line, "lost", -1);
m_endTake[i].immediat = OpInt(line, "immediat", 0);
@@ -5074,339 +5111,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_dialog->SetStackRead("");
RestoreNumericLocale();
-}
-
-//! Creates an object of decoration mobile or stationary
-CObject* CRobotMain::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 ||
- type == OBJECT_CONTROLLER )
- {
- object = new CObject();
- object->SetOption(option);
- object->CreateVehicle(pos, angle, type, power, trainer, toy);
- }
-
- if (m_fixScene && type == OBJECT_HUMAN)
- {
- CMotion* motion = object->GetMotion();
- if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f);
- if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
- }
-
- return object;
+
+ if(m_app->GetSceneTestMode())
+ m_eventQueue->AddEvent(Event(EVENT_WIN));
}
//! Creates a directional light
@@ -6014,7 +5721,9 @@ void CRobotMain::CompileScript(bool soluce)
char* name = brain->GetScriptName(j);
if (name[0] != 0)
{
- brain->ReadProgram(j, name);
+ if(! brain->ReadProgram(j, name)) {
+ CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name);
+ }
if (!brain->GetCompile(j)) nbError++;
}
}
@@ -6339,6 +6048,9 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
sprintf(name, " trainer=%d", obj->GetTrainer());
strcat(line, name);
+
+ sprintf(name, " ignoreBuildCheck=%d", obj->GetIgnoreBuildCheck());
+ strcat(line, name);
sprintf(name, " option=%d", obj->GetOption());
strcat(line, name);
@@ -6496,10 +6208,11 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
int toy = OpInt(line, "toy", 0);
int option = OpInt(line, "option", 0);
- CObject* obj = CreateObject(pos, dir.y, 1.0f, 0.0f, type, 0.0f, trainer, toy, option);
+ CObject* obj = CObjectManager::GetInstancePointer()->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option);
obj->SetDefRank(objRank);
obj->SetPosition(0, pos);
obj->SetAngle(0, dir);
+ obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
obj->SetID(id);
if (g_id < id) g_id = id;
@@ -6858,6 +6571,8 @@ void CRobotMain::ResetCreate()
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
@@ -6912,8 +6627,13 @@ void CRobotMain::UpdateAudio(bool frame)
{
type = OBJECT_SCRAP1;
}
+
+ ToolType tool = CObject::GetToolFromObject(type);
+ DriveType drive = CObject::GetDriveFromObject(type);
+ if (m_audioChange[t].tool != TOOL_OTHER) if(tool != m_audioChange[t].tool) continue;
+ if (m_audioChange[t].drive != DRIVE_OTHER) if(drive != m_audioChange[t].drive) continue;
- if (type != m_audioChange[t].type) continue;
+ if (m_audioChange[t].tool == TOOL_OTHER && m_audioChange[t].drive == DRIVE_OTHER) if (type != m_audioChange[t].type) continue;
float energyLevel = -1;
CObject* power = obj->GetPower();
@@ -6922,7 +6642,8 @@ void CRobotMain::UpdateAudio(bool frame)
energyLevel = power->GetEnergy();
if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100;
}
- if (energyLevel < m_audioChange[t].powermin || energyLevel > m_audioChange[t].powermax) continue;
+ if (energyLevel < m_audioChange[t].powermin || energyLevel > m_audioChange[t].powermax)
+ continue;
if (obj->GetTruck() == 0)
oPos = obj->GetPosition(0);
@@ -6938,8 +6659,7 @@ void CRobotMain::UpdateAudio(bool frame)
if (nb >= m_audioChange[t].min &&
nb <= m_audioChange[t].max)
{
- CLogger::GetInstancePointer()->Debug("Changing music...\n");
- m_sound->StopMusic();
+ CLogger::GetInstancePointer()->Info("Changing music to \"%s\"\n", m_audioChange[t].music);
m_sound->PlayMusic(std::string(m_audioChange[t].music), m_audioChange[t].repeat);
m_audioChange[t].changed = true;
}
@@ -7017,7 +6737,12 @@ Error CRobotMain::CheckEndMission(bool frame)
type = OBJECT_SCRAP1;
}
- if (type != m_endTake[t].type) continue;
+ ToolType tool = CObject::GetToolFromObject(type);
+ DriveType drive = CObject::GetDriveFromObject(type);
+ if (m_endTake[t].tool != TOOL_OTHER) if(tool != m_endTake[t].tool) continue;
+ if (m_endTake[t].drive != DRIVE_OTHER) if(drive != m_endTake[t].drive) continue;
+
+ if (m_endTake[t].tool == TOOL_OTHER && m_endTake[t].drive == DRIVE_OTHER) if (type != m_endTake[t].type) continue;
float energyLevel = -1;
CObject* power = obj->GetPower();
@@ -7318,14 +7043,16 @@ float CRobotMain::GetPersoAngle()
//! Changes on the pause mode
-void CRobotMain::ChangePause(bool pause)
+void CRobotMain::ChangePause(PauseType pause)
{
- m_pause = pause;
- m_engine->SetPause(m_pause);
+ if(pause != PAUSE_NONE)
+ m_pause->SetPause(pause);
+ else
+ m_pause->ClearPause();
- m_sound->MuteAll(m_pause);
+ m_sound->MuteAll(m_pause->GetPause());
CreateShortcuts();
- if (m_pause) HiliteClear();
+ if (m_pause->GetPause()) HiliteClear();
}
@@ -7495,8 +7222,27 @@ void CRobotMain::StartMusic()
CLogger::GetInstancePointer()->Debug("Starting music...\n");
if (m_audioTrack != "")
{
- m_sound->StopMusic();
- m_sound->PlayMusic(m_audioTrack, m_audioRepeat);
+ m_sound->PlayMusic(m_audioTrack, m_audioRepeat, 0.0f);
+ }
+}
+
+//! Starts pause music
+void CRobotMain::StartPauseMusic(PauseType pause)
+{
+ switch(pause) {
+ case PAUSE_EDITOR:
+ if(m_editorTrack != "")
+ m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
+ break;
+
+ case PAUSE_SATCOM:
+ if(m_satcomTrack != "")
+ m_sound->PlayPauseMusic(m_satcomTrack, m_satcomRepeat);
+ break;
+
+ default:
+ // Don't change music
+ break;
}
}
@@ -7504,7 +7250,7 @@ void CRobotMain::StartMusic()
void CRobotMain::ClearInterface()
{
HiliteClear(); // removes setting evidence
- m_tooltipName[0] = 0; // really removes the tooltip
+ m_tooltipName.clear(); // really removes the tooltip
}
void CRobotMain::SetNumericLocale()
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 035698c..71ad455 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -30,6 +30,8 @@
#include "object/object.h"
#include "object/mainmovie.h"
+#include "app/pausemanager.h"
+
#include <stdio.h>
enum Phase
@@ -44,7 +46,6 @@ enum Phase
PHASE_FREE,
PHASE_TEEN,
PHASE_USER,
- PHASE_PROTO,
PHASE_LOADING,
PHASE_SIMUL,
PHASE_MODEL,
@@ -104,6 +105,8 @@ struct EndTake
int lost; // lost if <=
float powermin; // wins if energy cell >=
float powermax; // wins if energy cell <=
+ ToolType tool;
+ DriveType drive;
bool immediat;
char message[100];
};
@@ -117,6 +120,8 @@ struct AudioChange
int max; // change if <
float powermin; // change if energy cell >=
float powermax; // change if energy cell <=
+ ToolType tool;
+ DriveType drive;
char music[100];
bool repeat;
bool changed;
@@ -250,7 +255,7 @@ public:
void SetTracePrecision(float factor);
float GetTracePrecision();
- void ChangePause(bool pause);
+ void ChangePause(PauseType pause);
void SetSpeed(float speed);
float GetSpeed();
@@ -335,6 +340,7 @@ public:
float GetPersoAngle();
void StartMusic();
+ void StartPauseMusic(PauseType pause);
void ClearInterface();
void ChangeColor();
@@ -391,14 +397,11 @@ protected:
void CreateScene(bool soluce, bool fixScene, bool resetObject);
Math::Vector LookatPoint(Math::Vector eye, float angleH, float angleV, float length);
- CObject* CreateObject(Math::Vector pos, float angle, float zoom,
- float height, ObjectType type, float power=1.0f,
- bool trainer=false, bool toy=false, int option=0);
int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear();
void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
- void CreateTooltip(Math::Point pos, const char* text);
+ void CreateTooltip(Math::Point pos, const std::string& text);
void ClearTooltip();
CObject* DetectObject(Math::Point pos);
void ChangeCamera();
@@ -440,6 +443,7 @@ protected:
Ui::CDisplayText* m_displayText;
Ui::CDisplayInfo* m_displayInfo;
CSoundInterface* m_sound;
+ CPauseManager* m_pause;
//! Bindings for user inputs
InputBinding m_inputBindings[INPUT_SLOT_MAX];
@@ -471,15 +475,19 @@ protected:
bool m_showSoluce;
bool m_showAll;
bool m_cheatRadar;
- bool m_audioRepeat;
bool m_shortCut;
std::string m_audioTrack;
+ bool m_audioRepeat;
+ std::string m_satcomTrack;
+ bool m_satcomRepeat;
+ std::string m_editorTrack;
+ bool m_editorRepeat;
int m_delayWriteMessage;
int m_movieInfoIndex;
CObject* m_controller;
- //Level Checker flags
+ // Level Checker flags
bool m_beginObject;
bool m_terrainGenerate;
bool m_terrainInitTextures;
@@ -495,7 +503,6 @@ protected:
bool m_satComLock; // call of SatCom is possible?
bool m_editLock; // edition in progress?
bool m_editFull; // edition in full screen?
- bool m_pause; // simulation paused
bool m_hilite;
bool m_trainerPilot; // remote trainer?
bool m_suspend;
@@ -506,7 +513,7 @@ protected:
char m_mapFilename[100];
Math::Point m_tooltipPos;
- char m_tooltipName[100];
+ std::string m_tooltipName;
float m_tooltipTime;
char m_infoFilename[SATCOM_MAX][100]; // names of text files
@@ -522,6 +529,8 @@ protected:
int m_endingWinRank;
int m_endingLostRank;
bool m_winTerminate;
+
+ bool m_exitAfterMission;
float m_fontSize;
Math::Point m_windowPos;
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index 4a62a4a..4dfd6fb 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -100,6 +100,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
if ( m_type == OBJECT_PARA ) m_buildingHeight = 68.0f;
if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f;
if ( m_type == OBJECT_DESTROYER) m_buildingHeight = 35.0f;
+ if ( m_type == OBJECT_HUSTON ) m_buildingHeight = 45.0f;
m_buildingHeight *= 0.25f;
m_buildingPos = m_building->GetPosition(0);
@@ -574,7 +575,7 @@ Error CTaskBuild::FlatFloor()
if ( m_type == OBJECT_PARA ) radius = 20.0f;
if ( m_type == OBJECT_INFO ) radius = 5.0f;
if ( m_type == OBJECT_DESTROYER) radius = 20.0f;
- if ( radius == 0.0f ) return ERR_GENERIC;
+ //if ( radius == 0.0f ) return ERR_GENERIC;
center = m_metal->GetPosition(0);
angle = m_terrain->GetFineSlope(center);
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
index 01ff38b..8070d13 100644
--- a/src/object/task/taskgoto.cpp
+++ b/src/object/task/taskgoto.cpp
@@ -1559,8 +1559,8 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
oType == OBJECT_BOMB ||
(oType >= OBJECT_PLANT0 &&
oType <= OBJECT_PLANT19 ) ||
- (oType >= OBJECT_MUSHROOM0 &&
- oType <= OBJECT_MUSHROOM9 ) ) continue;
+ (oType >= OBJECT_MUSHROOM1 &&
+ oType <= OBJECT_MUSHROOM2 ) ) continue;
}
addi = add;
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index 3373610..c9c8d30 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -26,6 +26,7 @@
CTaskGunGoal::CTaskGunGoal(CObject* object) : CTask(object)
{
+ m_aimImpossible = false;
}
// Object's destructor.
@@ -116,6 +117,12 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
m_progress = 0.0f;
+ // direction was constrainted, hence resulting in impossible move
+ if (dirV != m_finalDirV || dirH != m_finalDirH)
+ {
+ m_aimImpossible = true;
+ }
+
return ERR_OK;
}
@@ -126,12 +133,25 @@ Error CTaskGunGoal::IsEnded()
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_initialDirV == m_finalDirV &&
- m_initialDirH == m_finalDirH ) return ERR_STOP;
- if ( m_progress < 1.0f ) return ERR_CONTINUE;
+ m_initialDirH == m_finalDirH )
+ {
+ if ( m_aimImpossible )
+ return ERR_AIM_IMPOSSIBLE;
+ else
+ return ERR_STOP;
+ }
+
+ if ( m_progress < 1.0f ) return ERR_CONTINUE;
m_object->SetGunGoalV(m_finalDirV);
m_object->SetGunGoalH(m_finalDirH);
Abort();
+
+ if ( m_aimImpossible )
+ {
+ return ERR_AIM_IMPOSSIBLE;
+ }
+
return ERR_STOP;
}
diff --git a/src/object/task/taskgungoal.h b/src/object/task/taskgungoal.h
index c6f010b..9fc509d 100644
--- a/src/object/task/taskgungoal.h
+++ b/src/object/task/taskgungoal.h
@@ -44,5 +44,7 @@ protected:
float m_finalDirV; // direction to reach
float m_initialDirH; // initial direction
float m_finalDirH; // direction to reach
+
+ bool m_aimImpossible; // set to true if impossible aim was set
};
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index af84099..d8bbafd 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -105,9 +105,11 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( power != 0 )
{
energy = power->GetEnergy();
- power->SetEnergy(energy-ENERGY_RECOVER*event.rTime*m_speed);
+ energy -= event.rTime * ENERGY_RECOVER / power->GetCapacity() * m_speed;
+ power->SetEnergy(energy);
}
+
speed.x = (Math::Rand()-0.5f)*0.1f*m_progress;
speed.y = (Math::Rand()-0.5f)*0.1f*m_progress;
speed.z = (Math::Rand()-0.5f)*0.1f*m_progress;
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 096e5de..61ff045 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -76,15 +76,9 @@ bool CTaskTerraform::EventProcess(const Event &event)
{
if ( m_soundChannel == -1 )
{
-#if _TEEN
- m_soundChannel = m_sound->Play(SOUND_GGG, m_object->GetPosition(0), 1.0f, 0.5f, true);
- m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.0f, 1.5f, SOPER_CONTINUE);
- m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
-#else
m_soundChannel = m_sound->Play(SOUND_GGG, m_object->GetPosition(0), 1.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.0f, 4.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
-#endif
}
dir.x = 0.0f;
@@ -109,11 +103,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
if ( m_phase == TTP_DOWN )
{
pos.x = 9.0f;
-#if _TEEN
- pos.y = 4.0f-m_progress*4.0f;
-#else
pos.y = 4.0f-m_progress*5.8f;
-#endif
pos.z = 0.0f;
m_object->SetPosition(2, pos);
}
@@ -121,11 +111,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
if ( m_phase == TTP_UP )
{
pos.x = 9.0f;
-#if _TEEN
- pos.y = 4.0f-(1.0f-m_progress)*4.0f;
-#else
pos.y = 4.0f-(1.0f-m_progress)*5.8f;
-#endif
pos.z = 0.0f;
m_object->SetPosition(2, pos);
}
@@ -230,11 +216,7 @@ Error CTaskTerraform::Start()
m_phase = TTP_CHARGE;
m_progress = 0.0f;
-#if _TEEN
- m_speed = 1.0f/1.5f;
-#else
m_speed = 1.0f/4.0f;
-#endif
m_time = 0.0f;
m_bError = false; // ok
@@ -261,9 +243,6 @@ Error CTaskTerraform::IsEnded()
if ( m_phase == TTP_CHARGE )
{
-#if _TEEN
- Terraform(); // changes the terrain.
-#endif
m_phase = TTP_DOWN;
m_speed = 1.0f/0.2f;
@@ -272,9 +251,7 @@ Error CTaskTerraform::IsEnded()
if ( m_phase == TTP_DOWN )
{
-#if !_TEEN
Terraform(); // changes the terrain.
-#endif
m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetZoom(0, 1.0f);