summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-03-30 15:01:00 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-03-30 15:23:05 +0100
commite218dcfdf2c58f8841e7ebd220527d08e870a6d5 (patch)
treea567db04a8a51e2db87f80e259faf222a7d4becd /src
parentbfc701e286259d9a7aa2ff8240704eab2ba3a237 (diff)
parente607fed265070be8c518d4302d8b76f738421fb3 (diff)
downloadcolobot-e218dcfdf2c58f8841e7ebd220527d08e870a6d5.tar.gz
colobot-e218dcfdf2c58f8841e7ebd220527d08e870a6d5.tar.bz2
colobot-e218dcfdf2c58f8841e7ebd220527d08e870a6d5.zip
Merge branch 'dev'
Merging content from dev
Diffstat (limited to 'src')
-rw-r--r--src/CBot/CBotDll.h6
-rw-r--r--src/CBot/CBotToken.cpp2
-rw-r--r--src/CBot/CMakeLists.txt5
-rw-r--r--src/CBot/ClassFILE.cpp2
-rw-r--r--src/CBot/tests/CBot_console/CMakeLists.txt17
l---------src/CBot/tests/CBot_console/src/CBot1
-rw-r--r--src/CBot/tests/CBot_console/src/CMakeLists.txt32
-rw-r--r--src/CBot/tests/CBot_console/src/app/CBotConsole.cpp175
-rw-r--r--src/CBot/tests/CBot_console/src/app/CBotConsole.h44
-rw-r--r--src/CBot/tests/CBot_console/src/app/CBotDoc.cpp122
-rw-r--r--src/CBot/tests/CBot_console/src/app/CBotDoc.h39
-rw-r--r--src/CBot/tests/CBot_console/src/app/CClass.cpp97
-rw-r--r--src/CBot/tests/CBot_console/src/app/CClass.h18
-rw-r--r--src/CBot/tests/CBot_console/src/app/main.cpp45
-rw-r--r--src/CBot/tests/CBot_console/src/app/routines.cpp141
-rw-r--r--src/CBot/tests/TestCBot/CBotConsoleDlg.cpp221
-rw-r--r--src/CBot/tests/TestCBot/CBotConsoleDlg.h85
-rw-r--r--src/CBot/tests/TestCBot/ChildFrm.cpp74
-rw-r--r--src/CBot/tests/TestCBot/ChildFrm.h66
-rw-r--r--src/CBot/tests/TestCBot/MainFrm.cpp116
-rw-r--r--src/CBot/tests/TestCBot/MainFrm.h72
-rw-r--r--src/CBot/tests/TestCBot/PerformDlg.cpp177
-rw-r--r--src/CBot/tests/TestCBot/PerformDlg.h78
-rw-r--r--src/CBot/tests/TestCBot/Routines.cpp153
-rw-r--r--src/CBot/tests/TestCBot/StdAfx.h40
-rw-r--r--src/CBot/tests/TestCBot/TestCBot.clw316
-rw-r--r--src/CBot/tests/TestCBot/TestCBot.cpp267
-rw-r--r--src/CBot/tests/TestCBot/TestCBot.dsp201
-rw-r--r--src/CBot/tests/TestCBot/TestCBot.h78
-rw-r--r--src/CBot/tests/TestCBot/TestCBot.rc564
-rw-r--r--src/CBot/tests/TestCBot/TestCBotDoc.cpp697
-rw-r--r--src/CBot/tests/TestCBot/TestCBotDoc.h78
-rw-r--r--src/CBot/tests/TestCBot/TestCBotView.cpp142
-rw-r--r--src/CBot/tests/TestCBot/TestCBotView.h78
-rw-r--r--src/CBot/tests/TestCBot/a§1.txt~96
-rw-r--r--src/CBot/tests/TestCBot/res/TestCBot.icobin1078 -> 0 bytes
-rw-r--r--src/CBot/tests/TestCBot/res/TestCBot.rc213
-rw-r--r--src/CBot/tests/TestCBot/res/TestCBotDoc.icobin1078 -> 0 bytes
-rw-r--r--src/CBot/tests/TestCBot/res/Toolbar.bmpbin1198 -> 0 bytes
-rw-r--r--src/CBot/tests/TestCBot/resource.h44
-rw-r--r--src/CBot/tests/TestCBot/xTestCBot.clw245
-rw-r--r--src/CBot/tests/scenarios/B.txt18
-rw-r--r--src/CBot/tests/scenarios/BUG2.txt107
-rw-r--r--src/CBot/tests/scenarios/Deleted.txt23
-rw-r--r--src/CBot/tests/scenarios/MaClass.txt16
-rw-r--r--src/CBot/tests/scenarios/Mc2.txt4
-rw-r--r--src/CBot/tests/scenarios/Mon fichier.txt2
-rw-r--r--src/CBot/tests/scenarios/Nop.txt4
-rw-r--r--src/CBot/tests/scenarios/POS.txt14
-rw-r--r--src/CBot/tests/scenarios/T.txt4
-rw-r--r--src/CBot/tests/scenarios/TESTALL.txt161
-rw-r--r--src/CBot/tests/scenarios/TestCB1.txt18
-rw-r--r--src/CBot/tests/scenarios/TestCBot1.txt27
-rw-r--r--src/CBot/tests/scenarios/TestCBot3.txt24
-rw-r--r--src/CBot/tests/scenarios/TestNull.txt15
-rw-r--r--src/CBot/tests/scenarios/TestRestoreState.txt67
-rw-r--r--src/CBot/tests/scenarios/TestStatic.txt31
-rw-r--r--src/CBot/tests/scenarios/TestStr.txt17
-rw-r--r--src/CBot/tests/scenarios/Z.txt14
-rw-r--r--src/CBot/tests/scenarios/a1.txt96
-rw-r--r--src/CBot/tests/scenarios/array.txt24
-rw-r--r--src/CBot/tests/scenarios/až1.txt96
-rw-r--r--src/CBot/tests/scenarios/a§1.txt96
-rw-r--r--src/CBot/tests/scenarios/bug.txt12
-rw-r--r--src/CBot/tests/scenarios/bugmw.txt9
-rw-r--r--src/CBot/tests/scenarios/ccc.txt8
-rw-r--r--src/CBot/tests/scenarios/enum.txt9
-rw-r--r--src/CBot/tests/scenarios/fibo.txt25
-rw-r--r--src/CBot/tests/scenarios/file.txt70
-rw-r--r--src/CBot/tests/scenarios/h.txt5
-rw-r--r--src/CBot/tests/scenarios/include.txt27
-rw-r--r--src/CBot/tests/scenarios/intrinsic.txt16
-rw-r--r--src/CBot/tests/scenarios/methode1.txt57
-rw-r--r--src/CBot/tests/scenarios/methode2.txt50
-rw-r--r--src/CBot/tests/scenarios/mp1.txt25
-rw-r--r--src/CBot/tests/scenarios/mp2.txt28
-rw-r--r--src/CBot/tests/scenarios/mw.txt16
-rw-r--r--src/CBot/tests/scenarios/null.txt5
-rw-r--r--src/CBot/tests/scenarios/opnew.txt20
-rw-r--r--src/CBot/tests/scenarios/plante.txt25
-rw-r--r--src/CBot/tests/scenarios/pointer.txt41
-rw-r--r--src/CBot/tests/scenarios/postinc.txt7
-rw-r--r--src/CBot/tests/scenarios/radar.txt39
-rw-r--r--src/CBot/tests/scenarios/solution.txt13
-rw-r--r--src/CBot/tests/scenarios/test.txt8
-rw-r--r--src/CBot/tests/scenarios/test23.txt10
-rw-r--r--src/CBot/tests/scenarios/testmw.txt14
-rw-r--r--src/CBot/tests/scenarios/this.txt13
-rw-r--r--src/CBot/tests/scenarios/tt.txt12
-rw-r--r--src/CBot/tests/scenarios/tt2.txt5
-rw-r--r--src/CBot/tests/scenarios/vide.txt0
-rw-r--r--src/CBot/tests/scenarios/zz.txt6
-rw-r--r--src/CMakeLists.txt80
-rw-r--r--src/app/app.cpp518
-rw-r--r--src/app/app.h66
-rw-r--r--src/app/main.cpp39
-rw-r--r--src/app/system.cpp189
-rw-r--r--src/app/system.h96
-rw-r--r--src/app/system_linux.cpp150
-rw-r--r--src/app/system_linux.h76
-rw-r--r--src/app/system_other.cpp (renamed from src/CBot/tests/TestCBot/StdAfx.cpp)59
-rw-r--r--src/app/system_other.h119
-rw-r--r--src/app/system_windows.cpp148
-rw-r--r--src/app/system_windows.h105
-rw-r--r--src/common/config.h.cmake13
-rw-r--r--src/common/event.cpp7
-rw-r--r--src/common/event.h9
-rw-r--r--src/common/global.h1
-rw-r--r--src/common/image.cpp13
-rw-r--r--src/common/image.h3
-rw-r--r--src/common/iman.cpp15
-rw-r--r--src/common/iman.h67
-rw-r--r--src/common/key.h2
-rw-r--r--src/common/logger.cpp84
-rw-r--r--src/common/logger.h131
-rw-r--r--src/common/misc.cpp124
-rw-r--r--src/common/misc.h3
-rw-r--r--src/common/profile.cpp53
-rw-r--r--src/common/profile.h25
-rw-r--r--src/common/restext.cpp4
-rw-r--r--src/common/singleton.h77
-rw-r--r--src/common/test/CMakeLists.txt22
-rw-r--r--src/common/test/colobot.ini15
-rw-r--r--src/common/test/image_test.cpp57
-rw-r--r--src/common/test/profile_test.cpp44
-rw-r--r--src/desktop/CMakeLists.txt2
-rw-r--r--src/desktop/colobot.desktop.in1
-rw-r--r--src/desktop/colobot.pod2
-rw-r--r--src/desktop/po/colobot-desktop.pot4
-rw-r--r--src/desktop/po/fr.po6
-rw-r--r--src/graphics/core/color.h10
-rw-r--r--src/graphics/core/device.h60
-rw-r--r--src/graphics/core/vertex.h20
-rw-r--r--src/graphics/engine/camera.cpp31
-rw-r--r--src/graphics/engine/camera.h6
-rw-r--r--src/graphics/engine/cloud.cpp19
-rw-r--r--src/graphics/engine/cloud.h11
-rw-r--r--src/graphics/engine/engine.cpp2515
-rw-r--r--src/graphics/engine/engine.h425
-rw-r--r--src/graphics/engine/lightman.cpp109
-rw-r--r--src/graphics/engine/lightman.h24
-rw-r--r--src/graphics/engine/lightning.cpp22
-rw-r--r--src/graphics/engine/lightning.h4
-rw-r--r--src/graphics/engine/modelfile.cpp284
-rw-r--r--src/graphics/engine/modelfile.h60
-rw-r--r--src/graphics/engine/modelmanager.cpp191
-rw-r--r--src/graphics/engine/modelmanager.h97
-rw-r--r--src/graphics/engine/particle.cpp31
-rw-r--r--src/graphics/engine/particle.h4
-rw-r--r--src/graphics/engine/planet.cpp8
-rw-r--r--src/graphics/engine/planet.h5
-rw-r--r--src/graphics/engine/pyro.cpp81
-rw-r--r--src/graphics/engine/pyro.h4
-rw-r--r--src/graphics/engine/terrain.cpp53
-rw-r--r--src/graphics/engine/terrain.h10
-rw-r--r--src/graphics/engine/test/CMakeLists.txt1
-rw-r--r--src/graphics/engine/test/modelfile_test.cpp29
-rw-r--r--src/graphics/engine/text.cpp81
-rw-r--r--src/graphics/engine/text.h24
-rw-r--r--src/graphics/engine/water.cpp34
-rw-r--r--src/graphics/engine/water.h8
-rw-r--r--src/graphics/opengl/gldevice.cpp558
-rw-r--r--src/graphics/opengl/gldevice.h57
-rw-r--r--src/graphics/opengl/test/CMakeLists.txt90
-rw-r--r--src/graphics/opengl/test/README.txt9
-rw-r--r--src/graphics/opengl/test/light_test.cpp437
-rw-r--r--src/graphics/opengl/test/model_test.cpp377
-rw-r--r--src/graphics/opengl/test/tex1.pngbin151263 -> 0 bytes
-rw-r--r--src/graphics/opengl/test/tex2.pngbin57503 -> 0 bytes
-rw-r--r--src/graphics/opengl/test/texture_test.cpp193
-rw-r--r--src/graphics/opengl/test/transform_test.cpp339
-rw-r--r--src/math/geometry.h33
-rw-r--r--src/math/intpoint.h6
-rw-r--r--src/math/test/CMakeLists.txt26
-rw-r--r--src/math/test/gendata.m86
-rw-r--r--src/math/test/geometry_test.cpp359
-rw-r--r--src/math/test/matrix_test.cpp322
-rw-r--r--src/math/test/vector_test.cpp81
-rw-r--r--src/object/auto/auto.cpp54
-rw-r--r--src/object/auto/auto.h7
-rw-r--r--src/object/auto/autobase.cpp14
-rw-r--r--src/object/auto/autobase.h2
-rw-r--r--src/object/auto/autoconvert.cpp8
-rw-r--r--src/object/auto/autoconvert.h2
-rw-r--r--src/object/auto/autoderrick.cpp9
-rw-r--r--src/object/auto/autoderrick.h2
-rw-r--r--src/object/auto/autodestroyer.cpp97
-rw-r--r--src/object/auto/autodestroyer.h2
-rw-r--r--src/object/auto/autoegg.cpp11
-rw-r--r--src/object/auto/autoegg.h2
-rw-r--r--src/object/auto/autoenergy.cpp9
-rw-r--r--src/object/auto/autoenergy.h2
-rw-r--r--src/object/auto/autofactory.cpp10
-rw-r--r--src/object/auto/autofactory.h2
-rw-r--r--src/object/auto/autoflag.cpp3
-rw-r--r--src/object/auto/autoflag.h2
-rw-r--r--src/object/auto/autohuston.cpp3
-rw-r--r--src/object/auto/autohuston.h2
-rw-r--r--src/object/auto/autoinfo.cpp3
-rw-r--r--src/object/auto/autoinfo.h2
-rw-r--r--src/object/auto/autojostle.cpp3
-rw-r--r--src/object/auto/autojostle.h2
-rw-r--r--src/object/auto/autokid.cpp3
-rw-r--r--src/object/auto/autokid.h2
-rw-r--r--src/object/auto/autolabo.cpp11
-rw-r--r--src/object/auto/autolabo.h2
-rw-r--r--src/object/auto/automush.cpp4
-rw-r--r--src/object/auto/automush.h2
-rw-r--r--src/object/auto/autonest.cpp7
-rw-r--r--src/object/auto/autonest.h2
-rw-r--r--src/object/auto/autonuclear.cpp8
-rw-r--r--src/object/auto/autonuclear.h2
-rw-r--r--src/object/auto/autopara.cpp6
-rw-r--r--src/object/auto/autopara.h2
-rw-r--r--src/object/auto/autoportico.cpp11
-rw-r--r--src/object/auto/autoportico.h2
-rw-r--r--src/object/auto/autoradar.cpp5
-rw-r--r--src/object/auto/autoradar.h2
-rw-r--r--src/object/auto/autorepair.cpp6
-rw-r--r--src/object/auto/autorepair.h2
-rw-r--r--src/object/auto/autoresearch.cpp9
-rw-r--r--src/object/auto/autoresearch.h2
-rw-r--r--src/object/auto/autoroot.cpp4
-rw-r--r--src/object/auto/autoroot.h2
-rw-r--r--src/object/auto/autosafe.cpp7
-rw-r--r--src/object/auto/autosafe.h2
-rw-r--r--src/object/auto/autostation.cpp6
-rw-r--r--src/object/auto/autostation.h2
-rw-r--r--src/object/auto/autotower.cpp7
-rw-r--r--src/object/auto/autotower.h2
-rw-r--r--src/object/brain.cpp232
-rw-r--r--src/object/brain.h5
-rw-r--r--src/object/mainmovie.cpp15
-rw-r--r--src/object/mainmovie.h16
-rw-r--r--src/object/motion/motion.cpp23
-rw-r--r--src/object/motion/motion.h8
-rw-r--r--src/object/motion/motionant.cpp126
-rw-r--r--src/object/motion/motionant.h2
-rw-r--r--src/object/motion/motionbee.cpp86
-rw-r--r--src/object/motion/motionbee.h2
-rw-r--r--src/object/motion/motionhuman.cpp123
-rw-r--r--src/object/motion/motionhuman.h2
-rw-r--r--src/object/motion/motionmother.cpp77
-rw-r--r--src/object/motion/motionmother.h2
-rw-r--r--src/object/motion/motionspider.cpp39
-rw-r--r--src/object/motion/motionspider.h2
-rw-r--r--src/object/motion/motiontoto.cpp42
-rw-r--r--src/object/motion/motiontoto.h2
-rw-r--r--src/object/motion/motionvehicle.cpp528
-rw-r--r--src/object/motion/motionvehicle.h2
-rw-r--r--src/object/motion/motionworm.cpp23
-rw-r--r--src/object/motion/motionworm.h2
-rw-r--r--src/object/object.cpp921
-rw-r--r--src/object/object.h7
-rw-r--r--src/object/robotmain.cpp453
-rw-r--r--src/object/robotmain.h31
-rw-r--r--src/object/task/task.cpp31
-rw-r--r--src/object/task/task.h5
-rw-r--r--src/object/task/taskadvance.cpp5
-rw-r--r--src/object/task/taskadvance.h3
-rw-r--r--src/object/task/taskbuild.cpp45
-rw-r--r--src/object/task/taskbuild.h2
-rw-r--r--src/object/task/taskfire.cpp6
-rw-r--r--src/object/task/taskfire.h2
-rw-r--r--src/object/task/taskfireant.cpp7
-rw-r--r--src/object/task/taskfireant.h2
-rw-r--r--src/object/task/taskflag.cpp26
-rw-r--r--src/object/task/taskflag.h3
-rw-r--r--src/object/task/taskgoto.cpp38
-rw-r--r--src/object/task/taskgoto.h3
-rw-r--r--src/object/task/taskgungoal.cpp4
-rw-r--r--src/object/task/taskgungoal.h2
-rw-r--r--src/object/task/taskinfo.cpp10
-rw-r--r--src/object/task/taskinfo.h2
-rw-r--r--src/object/task/taskmanager.cpp48
-rw-r--r--src/object/task/taskmanager.h7
-rw-r--r--src/object/task/taskmanip.cpp30
-rw-r--r--src/object/task/taskmanip.h2
-rw-r--r--src/object/task/taskpen.cpp8
-rw-r--r--src/object/task/taskpen.h2
-rw-r--r--src/object/task/taskrecover.cpp17
-rw-r--r--src/object/task/taskrecover.h3
-rw-r--r--src/object/task/taskreset.cpp9
-rw-r--r--src/object/task/taskreset.h2
-rw-r--r--src/object/task/tasksearch.cpp16
-rw-r--r--src/object/task/tasksearch.h2
-rw-r--r--src/object/task/taskshield.cpp25
-rw-r--r--src/object/task/taskshield.h3
-rw-r--r--src/object/task/taskspiderexplo.cpp8
-rw-r--r--src/object/task/taskspiderexplo.h2
-rw-r--r--src/object/task/tasktake.cpp22
-rw-r--r--src/object/task/tasktake.h2
-rw-r--r--src/object/task/taskterraform.cpp19
-rw-r--r--src/object/task/taskterraform.h3
-rw-r--r--src/object/task/taskturn.cpp4
-rw-r--r--src/object/task/taskturn.h2
-rw-r--r--src/object/task/taskwait.cpp4
-rw-r--r--src/object/task/taskwait.h2
-rw-r--r--src/physics/physics.cpp51
-rw-r--r--src/physics/physics.h9
-rw-r--r--src/script/cbottoken.cpp395
-rw-r--r--src/script/cbottoken.h4
-rw-r--r--src/script/cmdtoken.cpp1
-rw-r--r--src/script/script.cpp379
-rw-r--r--src/script/script.h6
-rw-r--r--src/sound/oalsound/alsound.cpp200
-rw-r--r--src/sound/oalsound/alsound.h14
-rw-r--r--src/sound/oalsound/buffer.cpp44
-rw-r--r--src/sound/oalsound/buffer.h5
-rw-r--r--src/sound/oalsound/channel.cpp97
-rw-r--r--src/sound/oalsound/channel.h10
-rw-r--r--src/sound/sound.h26
-rw-r--r--src/tools/CMakeLists.txt3
-rw-r--r--src/tools/convert_model.cpp63
-rw-r--r--src/ui/button.cpp1
-rw-r--r--src/ui/button.h38
-rw-r--r--src/ui/check.cpp1
-rw-r--r--src/ui/check.h25
-rw-r--r--src/ui/color.cpp2
-rw-r--r--src/ui/color.h41
-rw-r--r--src/ui/compass.cpp3
-rw-r--r--src/ui/compass.h31
-rw-r--r--src/ui/control.cpp18
-rw-r--r--src/ui/control.h209
-rw-r--r--src/ui/displayinfo.cpp56
-rw-r--r--src/ui/displayinfo.h120
-rw-r--r--src/ui/displaytext.cpp33
-rw-r--r--src/ui/displaytext.h11
-rw-r--r--src/ui/edit.cpp237
-rw-r--r--src/ui/edit.h37
-rw-r--r--src/ui/editvalue.cpp7
-rw-r--r--src/ui/editvalue.h1
-rw-r--r--src/ui/gauge.cpp3
-rw-r--r--src/ui/gauge.h1
-rw-r--r--src/ui/group.cpp4
-rw-r--r--src/ui/group.h1
-rw-r--r--src/ui/image.cpp10
-rw-r--r--src/ui/image.h1
-rw-r--r--src/ui/interface.cpp44
-rw-r--r--src/ui/interface.h6
-rw-r--r--src/ui/key.cpp1
-rw-r--r--src/ui/key.h1
-rw-r--r--src/ui/label.cpp2
-rw-r--r--src/ui/list.cpp2
-rw-r--r--src/ui/maindialog.cpp184
-rw-r--r--src/ui/maindialog.h20
-rw-r--r--src/ui/mainmap.cpp13
-rw-r--r--src/ui/mainmap.h5
-rw-r--r--src/ui/mainshort.cpp22
-rw-r--r--src/ui/mainshort.h7
-rw-r--r--src/ui/map.cpp8
-rw-r--r--src/ui/map.h7
-rw-r--r--src/ui/scroll.cpp4
-rw-r--r--src/ui/scroll.h3
-rw-r--r--src/ui/shortcut.cpp4
-rw-r--r--src/ui/slider.cpp4
-rw-r--r--src/ui/studio.cpp182
-rw-r--r--src/ui/studio.h125
-rw-r--r--src/ui/target.cpp7
-rw-r--r--src/ui/target.h11
-rw-r--r--src/ui/test/CMakeLists.txt36
-rw-r--r--src/ui/test/edit_test.cpp73
-rw-r--r--src/ui/test/mocks/text_mock.h21
-rw-r--r--src/ui/test/stubs/app_stub.cpp26
-rw-r--r--src/ui/test/stubs/engine_stub.cpp79
-rw-r--r--src/ui/test/stubs/particle_stub.cpp291
-rw-r--r--src/ui/test/stubs/restext_stub.cpp11
-rw-r--r--src/ui/test/stubs/robotmain_stub.cpp17
-rw-r--r--src/ui/window.cpp15
-rw-r--r--src/ui/window.h6
370 files changed, 7652 insertions, 15130 deletions
diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h
index 7af63ca..b401528 100644
--- a/src/CBot/CBotDll.h
+++ b/src/CBot/CBotDll.h
@@ -15,14 +15,13 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
////////////////////////////////////////////////////////////////////////
-#pragma once
-#ifndef _CBOTDLL_H_
-#define _CBOTDLL_H_
/**
* \file CBotDll.h
* \brief Library for interpretation of CBOT language
*/
+#pragma once
+
#include <stdio.h>
#include "resource.h"
#include <map>
@@ -1114,5 +1113,4 @@ bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
}
#endif
-#endif //_CBOTDLL_H_
diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp
index c6e65e7..f03ca91 100644
--- a/src/CBot/CBotToken.cpp
+++ b/src/CBot/CBotToken.cpp
@@ -15,8 +15,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-//CBotToken.cpp
-
//////////////////////////////////////////////////////////////////
// Managing Tokens
// the text of a program is first transformed
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index daf08c6..fecd18e 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -16,5 +16,8 @@ if(${CBOT_STATIC})
add_library(CBot STATIC ${SOURCES})
else()
add_library(CBot SHARED ${SOURCES})
- install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR})
+ install(TARGETS CBot LIBRARY
+ DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
+ ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
+ RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
endif()
diff --git a/src/CBot/ClassFILE.cpp b/src/CBot/ClassFILE.cpp
index e5bc260..b0f7977 100644
--- a/src/CBot/ClassFILE.cpp
+++ b/src/CBot/ClassFILE.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// ClassFile.cpp
-//
// definition of methods for class FILE
diff --git a/src/CBot/tests/CBot_console/CMakeLists.txt b/src/CBot/tests/CBot_console/CMakeLists.txt
deleted file mode 100644
index f76dedf..0000000
--- a/src/CBot/tests/CBot_console/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-project(CBot_console C CXX)
-
-# Build with debugging symbols
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-
-# Global compile flags
-set(CMAKE_CXX_FLAGS_RELEASE "-O2")
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-# Include cmake directory
-SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
-
-add_subdirectory(src bin)
diff --git a/src/CBot/tests/CBot_console/src/CBot b/src/CBot/tests/CBot_console/src/CBot
deleted file mode 120000
index 2c91115..0000000
--- a/src/CBot/tests/CBot_console/src/CBot
+++ /dev/null
@@ -1 +0,0 @@
-../../../../CBot/ \ No newline at end of file
diff --git a/src/CBot/tests/CBot_console/src/CMakeLists.txt b/src/CBot/tests/CBot_console/src/CMakeLists.txt
deleted file mode 100644
index 3dbf711..0000000
--- a/src/CBot/tests/CBot_console/src/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# CBot shared library is built separately
-add_subdirectory(CBot)
-
-
-# Configure options
-option(DEBUG "Enable debug output" ON)
-
-set(PLATFORM_LIBS "")
-
-# Source files
-# Commented out files are still dependent on DirectX or WinAPI
-
-set(SOURCES
-app/CClass.cpp
-app/main.cpp
-#app/routines.cpp
-app/CBotDoc.cpp
-app/CBotConsole.cpp
-)
-
-set(LIBS
-CBot
-)
-
-include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
-
-add_executable(CBot_console ${SOURCES})
-
-target_link_libraries(CBot_console ${LIBS})
diff --git a/src/CBot/tests/CBot_console/src/app/CBotConsole.cpp b/src/CBot/tests/CBot_console/src/app/CBotConsole.cpp
deleted file mode 100644
index e9209d3..0000000
--- a/src/CBot/tests/CBot_console/src/app/CBotConsole.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * CBotConsole.cpp
- *
- * Created on: 08-08-2012
- * Author: michal
- */
-
-#include "CBotConsole.h"
-#include "CClass.h"
-#include <ctime>
-#include <iostream>
-
-CBotConsole::CBotConsole() {
- // TODO Auto-generated constructor stub
- m_pProg = NULL;
- m_threadinfo.m_bRun = false;
- m_code = 0;
-
-}
-
-CBotConsole::~CBotConsole() {
- // TODO Auto-generated destructor stub
-}
-
-uint ThreadProc(ThreadInfo *info)
-{
- time_t t0,t1;
- time(&t0);
-
- int Cpt = 0;
-
- info->m_pProg->Start("LaCommande");
- while ( !info->m_bStop && !info->m_pProg->Run() )
- {
-#if 0
- const char* FunctionName;
- const char* FN;
- int start, end;
-
- info->m_pProg->GetRunPos(FunctionName, start, end);
-
- if ( FunctionName != NULL )
- {
- info->m_pEditx->SetSel(start, end);
-
- char buffer[200];
- sprintf( buffer, "step %s, %d, %d",FunctionName, start, end);
- AfxMessageBox( buffer );
-
- int level = 0;
- do
- {
- CBotVar* t = info->m_pProg->GetStackVars(FN, level--);
- if ( FN != FunctionName ) break;
- if ( t != NULL )
- {
- CString s ;
- while ( t != NULL )
- {
- if (s.IsEmpty()) s+= "Stack -> ";
- else s+= " , ";
- s += t->GetValString();
- t = t->GetNext();
- }
- AfxMessageBox(s);
- }
- } while (TRUE);
- }
-#endif
- Cpt++;
- if ( Cpt%50 == 0 ) std::cout << ".";
- }
-
- if ( info->m_bStop )
- {
- std::cout << "\nInterrupt\n";
- }
- else if (info->m_pProg->GetError() == 0)
- {
- time(&t1);
- double prog_time = difftime(t0,t1);
-
- char buffer[200];
- sprintf( buffer, "\nExecution terminated in %f seconds.\nInterrupted %d time(s).\n",
- prog_time, Cpt);
-
- std::cout << buffer;
- }
-
-// info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
- return 0 ;
-}
-
-long CBotConsole::EndProg()
-{
- m_threadinfo.m_bRun = false;
-
- if (m_pProg->GetError(m_code, m_start, m_end))
- {
- CBotString TextError;
- TextError = CBotProgram::GetErrorText(m_code);
- std::cout << TextError;
- return 1;
- }
- delete m_pProg;
- m_pProg = NULL;
-
- return 0 ;
-}
-
-
-void CBotConsole::OnOK()
-{
- m_code = 0;
-
- std::string Commande;
- std::cin >> Commande;
-
- std::string s = "void LaCommande() { " + Commande + " ;}";
- m_pProg = new CBotProgram();
- CBotStringArray liste;
- m_pProg->Compile(s.c_str(), liste);
-
- int err, start, end;
- if ( m_pProg->GetError(err, start, end) )
- {
- CBotString TextError;
- TextError = CBotProgram::GetErrorText(err);
- std::cout << TextError;
- return;
- }
-
- std::cout << "\n" + Commande + " ->\n";
-
-// m_Edit2.SetWindowText("");
-// m_Edit1.SetFocus();
-// m_Edit2.EnableWindow(FALSE);
-// m_cOK.EnableWindow(FALSE);
-
- // lance un processus paralèle pour l'exécution
-// m_threadinfo.m_pWndMessage = this ;
-
-// m_threadinfo.m_pEdit1 = &m_Edit1;
-// m_threadinfo.m_pEditx = m_pEditx;
- m_threadinfo.m_pProg = m_pProg;
- m_threadinfo.m_bStop = false;
- m_threadinfo.m_bRun = true;
-
- ThreadProc(&m_threadinfo);
-
-// here program starts
-// AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
-}
-
-void CBotConsole::OnCancel()
-{
- m_threadinfo.m_bStop = true ;
-}
-
-bool CBotConsole::OnInitDialog()
-{
-// CDialog::OnInitDialog();
-
- std::cout << "Following functions are availible:\n";
- for ( int i = 0; i < m_pListe->GetSize(); i++ )
- {
- CBotString x = (*m_pListe)[i] + CBotString("\n");
- std::cout << x;
- }
- std::cout << "Enter a command:\n";
-
-
- return true; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
-}
diff --git a/src/CBot/tests/CBot_console/src/app/CBotConsole.h b/src/CBot/tests/CBot_console/src/app/CBotConsole.h
deleted file mode 100644
index a155399..0000000
--- a/src/CBot/tests/CBot_console/src/app/CBotConsole.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * CBotConsole.h
- *
- * Created on: 08-08-2012
- * Author: michal
- */
-
-#ifndef CBOTCONSOLE_H_
-#define CBOTCONSOLE_H_
-#include "CClass.h"
-
-struct ThreadInfo
-{
-// CEdit* m_pEdit1 ;
-// CEdit* m_pEditx ;
- CBotProgram* m_pProg;
-// CWnd* m_pWndMessage;
- bool m_bStop;
- bool m_bRun;
-};
-
-class CBotConsole {
-
-public:
- CBotConsole();
- virtual ~CBotConsole();
-
-// CEdit m_Edit1;
-
- CBotProgram* m_pProg;
- ThreadInfo m_threadinfo;
-
- CBotStringArray* m_pListe;
- int m_code, m_start, m_end;
-// CEdit* m_pEditx;
-
- // Implementation
- void OnOK();
- void OnCancel();
- bool OnInitDialog();
- long EndProg() ;
-};
-
-#endif /* CBOTCONSOLE_H_ */
diff --git a/src/CBot/tests/CBot_console/src/app/CBotDoc.cpp b/src/CBot/tests/CBot_console/src/app/CBotDoc.cpp
deleted file mode 100644
index 1c694c9..0000000
--- a/src/CBot/tests/CBot_console/src/app/CBotDoc.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * CBotDoc.cpp
- *
- * Created on: 08-08-2012
- * Author: michal
- */
-#include "CBotDoc.h"
-#include "CBotConsole.h"
-#include <iostream>
-
-CBotDoc::CBotDoc(std::string s) {
- // TODO Auto-generated constructor stub
- // TODO set m_DocText
-// m_pEdit = NULL;
- m_pProg = NULL;
-// m_bModified = FALSE;
- m_DocText = s;
- std::cout << s << std::endl;
-// std::cout << "Enter to continue..." << std::endl;
-// getchar();
-}
-
-CBotDoc::~CBotDoc() {
-
-// delete m_pEdit;
- delete m_pProg;
-}
-
-
-//static bool test = false;
-
-void CBotDoc::OnRun()
-{
-
-// m_pEdit->GetWindowText(m_DocText);
- CBotString s;
-
- std::string TextError;
- int code, start, end;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, NULL))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- TextError = CBotProgram::GetErrorText( code );
- std::cout << TextError << std::endl;
- return;
- }
-
- if( m_Liste.GetSize() == 0 )
- {
- std::cout << "No function marked \"extern\" !\n";
- return;
- }
-
- for ( int i = 0; i < m_Liste.GetSize(); i++ )
- {
- int start, stop;
- m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
- CBotString s(m_DocText.substr( start, stop-start ).c_str());
- m_Liste[i] = s;
- }
-// TODO
- CBotConsole dlg;
- dlg.m_pListe = &m_Liste;
-// dlg.m_pEditx = m_pEdit;
-
- dlg.OnInitDialog();
- dlg.OnOK();
- dlg.EndProg();
-// if ( dlg.m_code>0 )
-// {
-// std::string TextError;
-//
-// TextError = m_pProg->GetErrorText( dlg.m_code );
-//
-// std::cout <<TextError;
-// }
-
- return;
-}
-
-bool CBotDoc::Compile()
-{
-// m_pEdit->GetWindowText(m_DocText);
-
- std::string TextError;
- int code, start, end;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- char buffer[100];
- strcpy(buffer, "a pointer move to see");
-
- if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, static_cast<void*>(buffer)))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
-// m_pEdit->SetSel( start, end );
-// m_pEdit->SetFocus(); // higlights part of problem
-
- TextError = CBotProgram::GetErrorText( code );
- std::cout << TextError ;
-
- return false;
- }
-
-// if ( m_pProg->GetPosition( "TheTest", start, end) )
-// {
-// m_pEdit->SetSel( start, end );
-// m_pEdit->SetFocus(); // higlights part of problem
-// }
-
-// m_bModified = FALSE;
- return true;
-}
diff --git a/src/CBot/tests/CBot_console/src/app/CBotDoc.h b/src/CBot/tests/CBot_console/src/app/CBotDoc.h
deleted file mode 100644
index c0a3e1d..0000000
--- a/src/CBot/tests/CBot_console/src/app/CBotDoc.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * CBotDoc.h
- *
- * Created on: 08-08-2012
- * Author: michal
- */
-
-#pragma once
-#ifndef CBOTDOC_H_
-#define CBOTDOC_H_
-
-#include "CClass.h"
-#include <string>
-
-class CBotDoc {
-
-public:
- CBotDoc(std::string);
- virtual ~CBotDoc();
-
-// CEdit* m_pEdit; // to memorize the text, and display
- CBotProgram* m_pProg; // the compiled program
- std::string m_DocText;
- CBotStringArray m_Liste;
-
-// Operations
-
- bool Compile();
-
-// virtual bool OnNewDocument();
-
- void OnRun();
- void OnChangeEdit1();
- void OnTest();
-
-};
-
-
-#endif /* CBOTDOC_H_ */
diff --git a/src/CBot/tests/CBot_console/src/app/CClass.cpp b/src/CBot/tests/CBot_console/src/app/CClass.cpp
deleted file mode 100644
index 9b7c842..0000000
--- a/src/CBot/tests/CBot_console/src/app/CClass.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include "CClass.h"
-
-#include "routines.cpp"
-
-void rMajObject( CBotVar* pThis, void* pUser )
-{
- if (!pThis->IsElemOfClass("object"))
- return ;
- CBotVar* pPos = pThis->GetItem("position");
- CBotVar* pX = pPos->GetItem("x");
- CBotVar* pY = pPos->GetItem("y");
- CBotVar* pZ = pPos->GetItem("z");
-// CBotVar* pPt = pThis->GetItem("transport");
-
- CBotString p = pX->GetValString();
-
-// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
- pZ->SetValFloat( (float)0 );
- pY->SetValFloat( (float)-3.33 );
- pX->SetValFloat( pX->GetValFloat() + 10 ) ;
-
-// pX = pThis->GetItem( "xx" );
-// pX->SetValFloat( (float)22 );
-
- // crée une instance sur une classe object
-// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object");
-// pAutre->SetUserPtr( (void*)3 );
-// pPt->SetPointer( pAutre );
-// pPt->SetPointer( NULL );
-// delete pAutre;
-};
-
-CClass::CClass()
-{
- m_pClassPoint= NULL;
-}
-
-bool CClass::InitInstance()
-{
-//////////////////////////////////////////////
-// défini les mots clefs supplémentaires
-// -------------------------------------------
-
- CBotProgram::Init();
-
-//////////////////////////////////////////////
-// défini les fonctions "show()" et "print()"
-// -------------------------------------------
-
- //CBotProgram::AddFunction("show", rShow, cShow);
- CBotProgram::AddFunction("print", rPrint, cPrint);
- CBotProgram::AddFunction("println", rPrintLn, cPrint);
-
-
-///////////////////////////////////
-// définie la classe globale CPoint
-// --------------------------------
-
- m_pClassPoint = new CBotClass("CPoint", NULL);
- // ajoute le composant ".x"
- m_pClassPoint->AddItem("x", CBotTypFloat);
- // ajoute le composant ".y"
- m_pClassPoint->AddItem("y", CBotTypFloat);
-
- // ajoute le constructeur pour cette classe
- m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
-
- m_pClassPointIntr = new CBotClass("point", NULL, true);
- // ajoute le composant ".x"
- m_pClassPointIntr->AddItem("x", CBotTypFloat);
- // ajoute le composant ".y"
- m_pClassPointIntr->AddItem("y", CBotTypFloat);
- // ajoute le composant ".z"
- m_pClassPointIntr->AddItem("z", CBotTypFloat);
-
- // ajoute le constructeur pour cette classe
- m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);
-
- // défini la classe "object"
- CBotClass* pClassObject = new CBotClass( "object", NULL ) ;
- pClassObject->AddItem( "xx", CBotTypFloat );
- pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
- pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
- pClassObject->AddUpdateFunc( rMajObject );
-
- InitClassFILE();
-
- return true;
-}
-
-void CClass::ExitInstance()
-{
- delete m_pFuncFile;
-
- CBotProgram::Free();
-
-}
diff --git a/src/CBot/tests/CBot_console/src/app/CClass.h b/src/CBot/tests/CBot_console/src/app/CClass.h
deleted file mode 100644
index da2c46c..0000000
--- a/src/CBot/tests/CBot_console/src/app/CClass.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <CBot/CBot.h>
-#include <string>
-
-extern std::string s;
-
-class CClass
-{
-public:
- CClass();
-
- CBotClass* m_pClassPoint;
- CBotClass* m_pClassPointIntr;
-
- bool InitInstance();
- void ExitInstance();
-};
diff --git a/src/CBot/tests/CBot_console/src/app/main.cpp b/src/CBot/tests/CBot_console/src/app/main.cpp
deleted file mode 100644
index a2d3668..0000000
--- a/src/CBot/tests/CBot_console/src/app/main.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "CClass.h"
-#include "CBotDoc.h"
-#include <iostream>
-
-
-#include <fstream>
-
-std::string str;
-
-// routine to update the instance of the class Bot common
-
-int main(int argc, char* argv[])
-{
- CClass newclass;
- CBotDoc *botdoc;
- if (argc != 2)
- {
- std::cout << "Usage: "<<argv[0] << " <filename>" << std::endl;
- return 0;
- }
-
- std::ifstream in(argv[1]);
- std::cout << argv[1] << std::endl;
- if (!in.good())
- {
- std::cout << "Oh no, error!" << std::endl;
- return 1;
- }
-
- std::string contents((std::istreambuf_iterator<char>(in)),
- std::istreambuf_iterator<char>());
- str = contents;
-
- if(!newclass.InitInstance())
- {
- std::cerr << "Initialization not complete!" << std::endl;
- return 1;
- }
-
- botdoc = new CBotDoc(str);
-// std::cout << "Hello CBot!" << std::endl << s;
- botdoc->OnRun();
- delete botdoc;
- newclass.ExitInstance();
-}
diff --git a/src/CBot/tests/CBot_console/src/app/routines.cpp b/src/CBot/tests/CBot_console/src/app/routines.cpp
deleted file mode 100644
index 8b8a1d4..0000000
--- a/src/CBot/tests/CBot_console/src/app/routines.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-// * 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/.
-
-////////////////////////////////////////////////////////////////////
-// routine show()
-// utilisable depuis le programme écrit en CBot
-
-
-#include <iostream>
-#include <string>
-#include "CBot/ClassFILE.cpp"
-//std::string s;
-/*
-// execution
-bool rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- string::string s;
-
- while ( pVar != NULL )
- {
- string::string ss;
-
- ss.LoadString( TX_TYPENAMES + pVar->GetType() );
- s += ss + " ";
-
- ss = pVar->GetName();
- if (ss.IsEmpty()) ss = "<sans nom>";
- s += ss + " = ";
-
- s += pVar->GetValString();
- s += "\n";
- pVar = pVar->GetNext();
- }
-
- AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
-
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cShow( CBotVar* &pVar, void* pUser)
-{
- if ( pVar == NULL ) return CBotTypResult(5028);
- return CBotTypResult(0); // tous paramètres acceptés, void en retour
-}
-
-*/
-
-////////////////////////////////////////////////////////////////////
-// routine print()
-// utilisable depuis le programme écrit en CBot
-
-// exécution
-
-bool rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- std::string s;
- while ( pVar != NULL )
- {
- if ( !s.empty() ) s += " ";
- s += pVar->GetValString();
- pVar = pVar->GetNext();
- }
- s += "\n";
-
- std::cout << s;
- return true; // pas d'interruption
-}
-
-bool rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- std::string s;
- while ( pVar != NULL )
- {
- if ( !s.empty() ) s += " ";
- s += pVar->GetValString();
- pVar = pVar->GetNext();
- }
- s += " ";
- std::cout << s;
- return true; // pas d'interruption
-}
-
-CBotTypResult cPrint( CBotVar* &pVar, void* pUser)
-{
- return CBotTypResult(0); // tous paramètres acceptés, un entier en retour
-}
-
-
-//////////////////////////////////////////////////////////////////
-// class CPoint pour essayer
-
-// exécution
-bool rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
-{
- if ( pVar == NULL )return true; // constructor with no parameters is ok
-
- CBotVar* pX = pThis->GetItem("x");
- pX->SetValFloat( pVar->GetValFloat() );
- pVar = pVar->GetNext();
-
- CBotVar* pY = pThis->GetItem("y");
- pY->SetValFloat( pVar->GetValFloat() );
- pVar = pVar->GetNext();
-
- return true; // pas d'interruption
-}
-
-CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar)
-{
- // ok if no parameters!
- if ( pVar == NULL ) return CBotTypResult(0);
-
- // numeric type of parameter please
- if ( pVar->GetType() > CBotTypDouble ) return CBotTypResult(5011);
- pVar = pVar->GetNext();
-
- // there must be a second parameter
- if ( pVar == NULL ) return 5028;
- // also numeric
- if ( pVar->GetType() > CBotTypDouble )return CBotTypResult(5011);
- pVar = pVar->GetNext();
-
- // and not more than 2 parameters please
- if ( pVar != NULL ) return CBotTypResult(5026);
-
- return CBotTypResult(0); // This function returns void
-}
-
diff --git a/src/CBot/tests/TestCBot/CBotConsoleDlg.cpp b/src/CBot/tests/TestCBot/CBotConsoleDlg.cpp
deleted file mode 100644
index 55a271a..0000000
--- a/src/CBot/tests/TestCBot/CBotConsoleDlg.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-// * 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/.
-
-// CBotConsoleDlg.cpp : implementation file
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-#include "CBotConsoleDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CBotConsoleDlg dialog
-
-
-CBotConsoleDlg::CBotConsoleDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CBotConsoleDlg::IDD, pParent)
-{
- //{{AFX_DATA_INIT(CBotConsoleDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pProg = NULL;
- m_threadinfo.m_bRun = FALSE;
- m_code = 0;
-}
-
-
-void CBotConsoleDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBotConsoleDlg)
- DDX_Control(pDX, IDOK, m_cOK);
- DDX_Control(pDX, IDC_EDIT2, m_Edit2);
- DDX_Control(pDX, IDC_EDIT1, m_Edit1);
- //}}AFX_DATA_MAP
-}
-
-
-BEGIN_MESSAGE_MAP(CBotConsoleDlg, CDialog)
- //{{AFX_MSG_MAP(CBotConsoleDlg)
- ON_MESSAGE(WM_ENDPROG, EndProg)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CBotConsoleDlg message handlers
-
-UINT ThreadProc(ThreadInfo *info)
-{
- CTime t0 = CTime::GetCurrentTime();
- int Cpt = 0;
-
- info->m_pProg->Start("LaCommande");
- while ( !info->m_bStop && !info->m_pProg->Run() )
- {
-#if 0
- const char* FunctionName;
- const char* FN;
- int start, end;
-
- info->m_pProg->GetRunPos(FunctionName, start, end);
-
- if ( FunctionName != NULL )
- {
- info->m_pEditx->SetSel(start, end);
-
- char buffer[200];
- sprintf( buffer, "step %s, %d, %d",FunctionName, start, end);
- AfxMessageBox( buffer );
-
- int level = 0;
- do
- {
- CBotVar* t = info->m_pProg->GivStackVars(FN, level--);
- if ( FN != FunctionName ) break;
- if ( t != NULL )
- {
- CString s ;
- while ( t != NULL )
- {
- if (s.IsEmpty()) s+= "Stack -> ";
- else s+= " , ";
- s += t->GivValString();
- t = t->GivNext();
- }
- AfxMessageBox(s);
- }
- } while (TRUE);
- }
-#endif
- Cpt++;
- if ( Cpt%50 == 0 ) info->m_pEdit1->ReplaceSel(".");
- }
-
- if ( info->m_bStop )
- {
- info->m_pEdit1->ReplaceSel("\r\nInterrompu\r\n");
- }
- else if (info->m_pProg->GivError() == 0)
- {
- CTime t = CTime::GetCurrentTime();
- CTimeSpan ts = t - t0;
-
- char buffer[200];
- sprintf( buffer, "\r\nExécution terminée en %d secondes.\r\nInterrompue %d fois.\r\n",
- ts.GetTotalSeconds(), Cpt);
-
- info->m_pEdit1->ReplaceSel(buffer);
- }
-
- info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
- return 0 ;
-}
-
-LONG CBotConsoleDlg::EndProg(UINT wparam, LONG lparam)
-{
- m_threadinfo.m_bRun = FALSE;
-
- if (m_pProg->GetError(m_code, m_start, m_end))
- {
- CBotString TextError;
- TextError = CBotProgram::GivErrorText(m_code);
- AfxMessageBox(TextError);
- CDialog::OnCancel();
- return 1;
- }
- delete m_pProg;
- m_pProg = NULL;
-
- m_Edit2.EnableWindow(TRUE);
- m_cOK.EnableWindow(TRUE);
-
- m_Edit2.SetWindowText("");
- m_Edit2.SetFocus();
- return 0 ;
-}
-
-void CBotConsoleDlg::OnOK()
-{
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
- pApp->m_pConsole = &m_Edit1;
- m_code = 0;
-
- CString Commande;
- m_Edit2.GetWindowText(Commande);
-
- CString s = "void LaCommande() { " + Commande + " ;}";
- m_pProg = new CBotProgram();
- CBotStringArray liste;
- m_pProg->Compile(s, liste);
-
- int err, start, end;
- if ( m_pProg->GetError(err, start, end) )
- {
- CBotString TextError;
- TextError = CBotProgram::GivErrorText(err);
- AfxMessageBox(TextError);
- m_Edit2.SetSel(start-20, end-20);
- return;
- }
-
- m_Edit1.ReplaceSel("\r\n" + Commande + " ->\r\n");
-
- m_Edit2.SetWindowText("");
- m_Edit1.SetFocus();
- m_Edit2.EnableWindow(FALSE);
- m_cOK.EnableWindow(FALSE);
-
- // lance un processus paralèle pour l'exécution
- m_threadinfo.m_pWndMessage = this ;
-
- m_threadinfo.m_pEdit1 = &m_Edit1;
- m_threadinfo.m_pEditx = m_pEditx;
- m_threadinfo.m_pProg = m_pProg;
- m_threadinfo.m_bStop = FALSE;
- m_threadinfo.m_bRun = TRUE;
-
- AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
-}
-
-void CBotConsoleDlg::OnCancel()
-{
- if (!m_threadinfo.m_bRun) CDialog::OnCancel();
- m_threadinfo.m_bStop = TRUE ;
-}
-
-
-BOOL CBotConsoleDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- m_Edit1.ReplaceSel("Les fonctions suivantes sont disponibles:\r\n");
- for ( int i = 0; i < m_pListe->GivSize(); i++ )
- {
- CBotString x = (*m_pListe)[i] + CBotString("\r\n");
- m_Edit1.ReplaceSel(x);
- }
- m_Edit1.ReplaceSel("Entrez une commande ci-dessous.\r\n\r\n");
-
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
-}
diff --git a/src/CBot/tests/TestCBot/CBotConsoleDlg.h b/src/CBot/tests/TestCBot/CBotConsoleDlg.h
deleted file mode 100644
index f289a4d..0000000
--- a/src/CBot/tests/TestCBot/CBotConsoleDlg.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// * 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/.
-
-#if !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-// CBotConsoleDlg.h : header file
-//
-
-struct ThreadInfo
-{
- CEdit* m_pEdit1 ;
- CEdit* m_pEditx ;
- CBotProgram* m_pProg;
- CWnd* m_pWndMessage;
- BOOL m_bStop;
- BOOL m_bRun;
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CBotConsoleDlg dialog
-
-class CBotConsoleDlg : public CDialog
-{
-// Construction
-public:
- CBotConsoleDlg(CWnd* pParent = NULL); // standard constructor
-
-// Dialog Data
- //{{AFX_DATA(CBotConsoleDlg)
- enum { IDD = IDD_CONSOLE };
- CButton m_cOK;
- CEdit m_Edit2;
- CEdit m_Edit1;
- //}}AFX_DATA
-
- CBotProgram* m_pProg;
- ThreadInfo m_threadinfo;
-
- CBotStringArray*
- m_pListe;
- int m_code, m_start, m_end;
- CEdit* m_pEditx;
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CBotConsoleDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
-
- // Generated message map functions
- //{{AFX_MSG(CBotConsoleDlg)
- virtual void OnOK();
- virtual void OnCancel();
- virtual BOOL OnInitDialog();
- afx_msg LONG EndProg(UINT wparam, LONG lparam) ;
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/ChildFrm.cpp b/src/CBot/tests/TestCBot/ChildFrm.cpp
deleted file mode 100644
index 4c40f90..0000000
--- a/src/CBot/tests/TestCBot/ChildFrm.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-// * 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/.
-
-// ChildFrm.cpp : implementation of the CChildFrame class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "ChildFrm.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame
-
-IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
-
-BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
- //{{AFX_MSG_MAP(CChildFrame)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame construction/destruction
-
-CChildFrame::CChildFrame()
-{
-}
-
-CChildFrame::~CChildFrame()
-{
-}
-
-BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
-{
- return CMDIChildWnd::PreCreateWindow(cs);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame diagnostics
-
-#ifdef _DEBUG
-void CChildFrame::AssertValid() const
-{
- CMDIChildWnd::AssertValid();
-}
-
-void CChildFrame::Dump(CDumpContext& dc) const
-{
- CMDIChildWnd::Dump(dc);
-}
-
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame message handlers
diff --git a/src/CBot/tests/TestCBot/ChildFrm.h b/src/CBot/tests/TestCBot/ChildFrm.h
deleted file mode 100644
index 2ad57b6..0000000
--- a/src/CBot/tests/TestCBot/ChildFrm.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// * 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/.
-
-// ChildFrm.h : interface of the CChildFrame class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_CHILDFRM_H__4D1BB909_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_CHILDFRM_H__4D1BB909_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-class CChildFrame : public CMDIChildWnd
-{
- DECLARE_DYNCREATE(CChildFrame)
-public:
- CChildFrame();
-
-// Attributes
-public:
-
-// Operations
-public:
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CChildFrame)
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CChildFrame();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CChildFrame)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_CHILDFRM_H__4D1BB909_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/MainFrm.cpp b/src/CBot/tests/TestCBot/MainFrm.cpp
deleted file mode 100644
index 6669350..0000000
--- a/src/CBot/tests/TestCBot/MainFrm.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// * 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/.
-
-// MainFrm.cpp : implementation of the CMainFrame class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "MainFrm.h"
-#include "TestCBotDoc.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame
-
-IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
-
-BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-static UINT indicators[] =
-{
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
-};
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame construction/destruction
-
-CMainFrame::CMainFrame()
-{
-}
-
-CMainFrame::~CMainFrame()
-{
-}
-
-int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
-{
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbar\n");
- return -1; // fail to create
- }
-
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status bar\n");
- return -1; // fail to create
- }
-
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
-
- return 0;
-}
-
-BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
-{
- return CMDIFrameWnd::PreCreateWindow(cs);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame diagnostics
-
-#ifdef _DEBUG
-void CMainFrame::AssertValid() const
-{
- CMDIFrameWnd::AssertValid();
-}
-
-void CMainFrame::Dump(CDumpContext& dc) const
-{
- CMDIFrameWnd::Dump(dc);
-}
-
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame message handlers
-
-
diff --git a/src/CBot/tests/TestCBot/MainFrm.h b/src/CBot/tests/TestCBot/MainFrm.h
deleted file mode 100644
index a1d34f4..0000000
--- a/src/CBot/tests/TestCBot/MainFrm.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// * 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/.
-
-// MainFrm.h : interface of the CMainFrame class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_MAINFRM_H__4D1BB907_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_MAINFRM_H__4D1BB907_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-class CMainFrame : public CMDIFrameWnd
-{
- DECLARE_DYNAMIC(CMainFrame)
-public:
- CMainFrame();
-
-// Attributes
-public:
-
-// Operations
-public:
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CMainFrame)
- public:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CMainFrame();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-protected: // control bar embedded members
- CStatusBar m_wndStatusBar;
- CToolBar m_wndToolBar;
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CMainFrame)
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_MAINFRM_H__4D1BB907_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/PerformDlg.cpp b/src/CBot/tests/TestCBot/PerformDlg.cpp
deleted file mode 100644
index 8abbb4b..0000000
--- a/src/CBot/tests/TestCBot/PerformDlg.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-// * 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/.
-
-// PerformDlg.cpp : implementation file
-//
-
-#include "stdafx.h"
-#include "testcbot.h"
-#include "PerformDlg.h"
-
-//#include <stdio.h>
-#include <sys/timeb.h>
-//#include <time.h>
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CPerformDlg dialog
-
-
-CPerformDlg::CPerformDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CPerformDlg::IDD, pParent)
-{
- //{{AFX_DATA_INIT(CPerformDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
-}
-
-
-void CPerformDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPerformDlg)
- DDX_Control(pDX, IDC_EDIT3, m_Edit3);
- DDX_Control(pDX, IDC_EDIT1, m_Edit1);
- //}}AFX_DATA_MAP
-}
-
-
-BEGIN_MESSAGE_MAP(CPerformDlg, CDialog)
- //{{AFX_MSG_MAP(CPerformDlg)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CPerformDlg message handlers
-
-/* Pauses for a specified number of milliseconds. */
-
-/*void sleep( double waitseconds )
-{
- clock_t wait = (clock_t)(waitseconds * CLOCKS_PER_SEC);
- clock_t goal;
- goal = wait + clock();
- while( goal > clock() )
- ;
-}*/
-
-void sleep( clock_t wait )
-{
- clock_t goal;
- goal = wait + clock();
- while( goal > clock() )
- TRACE("%d \n", clock() );
-}
-
-void sleep2( clock_t wait )
-{
- struct _timeb timebuffer;
- char *timeline;
-
- _ftime( &timebuffer );
- timeline = ctime( & ( timebuffer.time ) );
- long x = timebuffer.millitm;
- while( x == timebuffer.millitm ) _ftime( &timebuffer );
-}
-
-#define NBLP 20
-
-UINT ThreadProc2(ThreadInfo2 *info)
-{
- int lp = NBLP;
- int i;
- clock_t start = clock();
-
- while ( !info->m_bStop )
- {
- for ( i = 0; i< info->m_nbscripts; i++ )
- {
- info->m_pProg[i]->Run();
- }
-
-#ifdef _DEBUG
- sleep2( 1 );
-#else
- CString s ( "xx" );
- for ( long z = 0x5000; z>0; z-- ) s = s.Left(1);
-#endif
- if ( --lp == 0 )
- {
- clock_t finish = clock();
- double n = (double)NBLP / (double)(finish-start) * CLOCKS_PER_SEC;
- char b[30];
- sprintf( b, "%f", n);
- info->m_pEdit->SetWindowText(b);
-
- n = n * 1100 / 200; // performances
- sprintf( b, "%f", n);
- info->m_pEdit3->SetWindowText(b);
- start = finish;
- lp = NBLP;
- }
- }
-
- return 0 ;
-}
-
-BOOL CPerformDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
-
- CBotStringArray liste;
- // crée les scripts pour les tests
- for ( int i = 0; i < 100; i++ )
- {
- m_pProg[i] = new CBotProgram();
- m_pProg[i]->Compile(m_Script, liste);
- m_pProg[i]->Start(liste[0]);
- }
-
- // lance un processus paralèle pour l'exécution
-// m_threadinfo2.m_pWndMessage = this ;
-
- m_threadinfo2.m_pEdit = &m_Edit1;
- m_threadinfo2.m_pEdit3 = &m_Edit3;
- m_threadinfo2.m_pProg = m_pProg;
- m_threadinfo2.m_bStop = FALSE;
- m_threadinfo2.m_nbscripts = 30;
-
-
- AfxBeginThread((AFX_THREADPROC)ThreadProc2, &m_threadinfo2) ;
- // TODO: Add extra initialization here
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
-}
-
-void CPerformDlg::OnCancel()
-{
- m_threadinfo2.m_bStop = TRUE;
- sleep ( 2000 );
-
- CDialog::OnCancel();
-
- for ( int i = 0; i < 100; i++ )
- {
- delete m_pProg[i];
- }
-}
diff --git a/src/CBot/tests/TestCBot/PerformDlg.h b/src/CBot/tests/TestCBot/PerformDlg.h
deleted file mode 100644
index 29d567f..0000000
--- a/src/CBot/tests/TestCBot/PerformDlg.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// * 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/.
-
-#if !defined(AFX_PERFORMDLG_H__EAF2D560_97D8_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_PERFORMDLG_H__EAF2D560_97D8_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-// PerformDlg.h : header file
-//
-
-struct ThreadInfo2
-{
- CEdit* m_pEdit ;
- CEdit* m_pEdit3 ;
-
- CBotProgram** m_pProg;
- BOOL m_bStop;
- int m_nbscripts;
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CPerformDlg dialog
-
-class CPerformDlg : public CDialog
-{
-// Construction
-public:
- CPerformDlg(CWnd* pParent = NULL); // standard constructor
-
-// Dialog Data
- //{{AFX_DATA(CPerformDlg)
- enum { IDD = IDD_DIALOG1 };
- CEdit m_Edit3;
- CEdit m_Edit1;
- //}}AFX_DATA
-
- CBotProgram* m_pProg[100];
- ThreadInfo2 m_threadinfo2;
- CString m_Script;
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CPerformDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
-
- // Generated message map functions
- //{{AFX_MSG(CPerformDlg)
- virtual BOOL OnInitDialog();
- virtual void OnCancel();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_PERFORMDLG_H__EAF2D560_97D8_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/Routines.cpp b/src/CBot/tests/TestCBot/Routines.cpp
deleted file mode 100644
index b37f027..0000000
--- a/src/CBot/tests/TestCBot/Routines.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-// * 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/.
-
-////////////////////////////////////////////////////////////////////
-// routine show()
-// utilisable depuis le programme écrit en CBot
-
-// exécution
-BOOL rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- CString s;
-
- while ( pVar != NULL )
- {
- CString ss;
- ss.LoadString( TX_TYPENAMES + pVar->GivType() );
- s += ss + " ";
-
- ss = pVar->GivName();
- if (ss.IsEmpty()) ss = "<sans nom>";
- s += ss + " = ";
-
- s += pVar->GivValString();
- s += "\n";
- pVar = pVar->GivNext();
- }
-
- AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
-
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cShow( CBotVar* &pVar, void* pUser)
-{
- if ( pVar == NULL ) return CBotTypResult(5028);
- return CBotTypResult(0); // tous paramètres acceptés, void en retour
-}
-
-
-////////////////////////////////////////////////////////////////////
-// routine print()
-// utilisable depuis le programme écrit en CBot
-
-// exécution
-BOOL rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- CString s;
-
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
- CEdit* pEdit = pApp->m_pConsole;
-
- if (pEdit == NULL) return TRUE;
- pEdit->GetWindowText(s);
-
- while ( pVar != NULL )
- {
- if ( !s.IsEmpty() ) s += " ";
- s += pVar->GivValString();
- pVar = pVar->GivNext();
- }
- s += "\r\n";
-
- pEdit->SetWindowText(s);
- pEdit->SetSel(s.GetLength(), s.GetLength());
- pEdit->SetFocus();
- return TRUE; // pas d'interruption
-}
-
-BOOL rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- CString s;
-
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
- CEdit* pEdit = pApp->m_pConsole;
-
- if (pEdit == NULL) return TRUE;
- pEdit->GetWindowText(s);
-
- while ( pVar != NULL )
- {
- if ( !s.IsEmpty() ) s += " ";
- s += pVar->GivValString();
- pVar = pVar->GivNext();
- }
-
- pEdit->SetWindowText(s);
- pEdit->SetSel(s.GetLength(), s.GetLength());
- pEdit->SetFocus();
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cPrint( CBotVar* &pVar, void* pUser)
-{
- return CBotTypResult(0); // tous paramètres acceptés, un entier en retour
-}
-
-
-//////////////////////////////////////////////////////////////////
-// class CPoint pour essayer
-
-// exécution
-BOOL rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
-{
- CString s;
-
- if ( pVar == NULL )return TRUE; // constructeur sans paramètres est ok
-
- CBotVar* pX = pThis->GivItem("x");
- pX->SetValFloat( pVar->GivValFloat() );
- pVar = pVar->GivNext();
-
- CBotVar* pY = pThis->GivItem("y");
- pY->SetValFloat( pVar->GivValFloat() );
- pVar = pVar->GivNext();
-
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar)
-{
- // ok si aucun paramètres !
- if ( pVar == NULL ) return CBotTypResult(0);
-
- // paramètre de type numérique svp
- if ( pVar->GivType() > CBotTypDouble ) return CBotTypResult(5011);
- pVar = pVar->GivNext();
-
- // il doit y avoir un second paramètre
- if ( pVar == NULL ) return 5028;
- // également de type numérique
- if ( pVar->GivType() > CBotTypDouble )return CBotTypResult(5011);
- pVar = pVar->GivNext();
-
- // et pas plus de 2 paramètres svp
- if ( pVar != NULL ) return CBotTypResult(5026);
-
- return CBotTypResult(0); // cette fonction retourne void
-}
-
-
diff --git a/src/CBot/tests/TestCBot/StdAfx.h b/src/CBot/tests/TestCBot/StdAfx.h
deleted file mode 100644
index c3659fb..0000000
--- a/src/CBot/tests/TestCBot/StdAfx.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// * 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/.// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#if !defined(AFX_STDAFX_H__4D1BB905_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_STDAFX_H__4D1BB905_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
-
-#include <afxwin.h> // MFC core and standard components
-#include <afxext.h> // MFC extensions
-#include <afxdisp.h> // MFC OLE automation classes
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__4D1BB905_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/TestCBot.clw b/src/CBot/tests/TestCBot/TestCBot.clw
deleted file mode 100644
index 13f20f4..0000000
--- a/src/CBot/tests/TestCBot/TestCBot.clw
+++ /dev/null
@@ -1,316 +0,0 @@
-; CLW file contains information for the MFC ClassWizard
-
-[General Info]
-Version=1
-LastClass=CPerformDlg
-LastTemplate=CDialog
-NewFileInclude1=#include "stdafx.h"
-NewFileInclude2=#include "testcbot.h"
-LastPage=0
-
-ClassCount=8
-Class1=CBotConsoleDlg
-Class2=CChildFrame
-Class3=CMainFrame
-Class4=CTestCBotApp
-Class5=CAboutDlg
-Class6=CTestCBotDoc
-Class7=CTestCBotView
-
-ResourceCount=12
-Resource1=IDD_CONSOLE
-Resource2=IDR_TESTCBTYPE (French (France))
-Resource3=IDD_ABOUTBOX (French (France))
-Resource4=IDR_MAINFRAME (French (France))
-Resource5=IDR_MAINFRAME
-Resource6=IDR_TESTCBTYPE
-Resource7=IDD_ABOUTBOX
-Resource8=IDD_CONSOLE (French (Switzerland))
-Class8=CPerformDlg
-Resource9=IDD_DIALOG1
-Resource10=IDD_DIALOG2
-Resource11=IDD_DIALOG1 (French (Switzerland))
-Resource12=IDD_DIALOG2 (French (France))
-
-[CLS:CBotConsoleDlg]
-Type=0
-BaseClass=CDialog
-HeaderFile=CBotConsoleDlg.h
-ImplementationFile=CBotConsoleDlg.cpp
-LastObject=IDC_EDIT1
-
-[CLS:CChildFrame]
-Type=0
-BaseClass=CMDIChildWnd
-HeaderFile=ChildFrm.h
-ImplementationFile=ChildFrm.cpp
-
-[CLS:CMainFrame]
-Type=0
-BaseClass=CMDIFrameWnd
-HeaderFile=MainFrm.h
-ImplementationFile=MainFrm.cpp
-Filter=T
-VirtualFilter=fWC
-LastObject=CMainFrame
-
-[CLS:CTestCBotApp]
-Type=0
-BaseClass=CWinApp
-HeaderFile=TestCBot.h
-ImplementationFile=TestCBot.cpp
-Filter=N
-VirtualFilter=AC
-LastObject=ID_TEST
-
-[CLS:CAboutDlg]
-Type=0
-BaseClass=CDialog
-HeaderFile=TestCBot.cpp
-ImplementationFile=TestCBot.cpp
-LastObject=CAboutDlg
-
-[CLS:CTestCBotDoc]
-Type=0
-BaseClass=CDocument
-HeaderFile=TestCBotDoc.h
-ImplementationFile=TestCBotDoc.cpp
-LastObject=CTestCBotDoc
-Filter=N
-VirtualFilter=DC
-
-[CLS:CTestCBotView]
-Type=0
-BaseClass=CView
-HeaderFile=TestCBotView.h
-ImplementationFile=TestCBotView.cpp
-LastObject=CTestCBotView
-Filter=C
-VirtualFilter=VWC
-
-[DLG:IDD_CONSOLE]
-Type=1
-Class=CBotConsoleDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT2,edit,1350631552
-Control3=IDOK,button,1342242817
-Control4=IDC_EDIT1,edit,1352734724
-
-[DLG:IDD_ABOUTBOX]
-Type=1
-Class=CAboutDlg
-ControlCount=7
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308480
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-Control5=IDC_STATIC,static,1342308352
-Control6=IDC_STATIC,static,1342308352
-Control7=IDC_STATIC,static,1342308352
-
-[TB:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-Command8=ID_RUN
-Command9=ID_APP_ABOUT
-CommandCount=9
-
-[MNU:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_MRU_FILE1
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-
-[MNU:IDR_TESTCBTYPE (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-CommandCount=18
-
-[ACL:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_EDIT_COPY
-Command2=ID_FILE_NEW
-Command3=ID_FILE_OPEN
-Command4=ID_FILE_SAVE
-Command5=ID_EDIT_PASTE
-Command6=ID_EDIT_UNDO
-Command7=ID_EDIT_CUT
-Command8=ID_RUN
-Command9=ID_NEXT_PANE
-Command10=ID_PREV_PANE
-Command11=ID_RUN
-Command12=ID_TEST
-Command13=ID_EDIT_COPY
-Command14=ID_EDIT_PASTE
-Command15=ID_EDIT_CUT
-Command16=ID_EDIT_UNDO
-CommandCount=16
-
-[DLG:IDD_ABOUTBOX (French (France))]
-Type=1
-Class=CAboutDlg
-ControlCount=7
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308480
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-Control5=IDC_STATIC,static,1342308352
-Control6=IDC_STATIC,static,1342308352
-Control7=IDC_STATIC,static,1342308352
-
-[ACL:IDR_MAINFRAME]
-Type=1
-Command1=ID_EDIT_COPY
-Command2=ID_FILE_NEW
-Command3=ID_FILE_OPEN
-Command4=ID_FILE_SAVE
-Command5=ID_EDIT_PASTE
-Command6=ID_EDIT_UNDO
-Command7=ID_EDIT_CUT
-Command8=ID_RUN
-Command9=ID_NEXT_PANE
-Command10=ID_PREV_PANE
-Command11=ID_RUN
-Command12=ID_TEST
-Command13=ID_EDIT_COPY
-Command14=ID_EDIT_PASTE
-Command15=ID_EDIT_CUT
-Command16=ID_EDIT_UNDO
-CommandCount=16
-
-[TB:IDR_MAINFRAME]
-Type=1
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-Command8=ID_RUN
-Command9=ID_APP_ABOUT
-CommandCount=9
-
-[MNU:IDR_MAINFRAME]
-Type=1
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_MRU_FILE1
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-
-[MNU:IDR_TESTCBTYPE]
-Type=1
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-CommandCount=18
-
-[DLG:IDD_CONSOLE (French (Switzerland))]
-Type=1
-Class=CBotConsoleDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT2,edit,1350631552
-Control3=IDOK,button,1342242817
-Control4=IDC_EDIT1,edit,1352734724
-
-[DLG:IDD_DIALOG1]
-Type=1
-Class=CPerformDlg
-ControlCount=9
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT1,edit,1350633600
-Control3=IDC_STATIC,static,1342308352
-Control4=IDC_EDIT2,edit,1350631552
-Control5=IDC_SPIN1,msctls_updown32,1342177312
-Control6=IDC_COMBO1,combobox,1344339971
-Control7=IDC_STATIC,static,1342308352
-Control8=IDC_STATIC,static,1342308352
-Control9=IDC_EDIT3,edit,1350633600
-
-[CLS:CPerformDlg]
-Type=0
-HeaderFile=PerformDlg.h
-ImplementationFile=PerformDlg.cpp
-BaseClass=CDialog
-Filter=D
-VirtualFilter=dWC
-LastObject=IDC_EDIT3
-
-[DLG:IDD_DIALOG2]
-Type=1
-ControlCount=2
-Control1=IDOK,button,1342242817
-Control2=IDCANCEL,button,1342242816
-
-[DLG:IDD_DIALOG1 (French (Switzerland))]
-Type=1
-ControlCount=9
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT1,edit,1350633600
-Control3=IDC_STATIC,static,1342308352
-Control4=IDC_EDIT2,edit,1350631552
-Control5=IDC_SPIN1,msctls_updown32,1342177312
-Control6=IDC_COMBO1,combobox,1344339971
-Control7=IDC_STATIC,static,1342308352
-Control8=IDC_STATIC,static,1342308352
-Control9=IDC_EDIT3,edit,1350633600
-
-[DLG:IDD_DIALOG2 (French (France))]
-Type=1
-ControlCount=2
-Control1=IDOK,button,1342242817
-Control2=IDCANCEL,button,1342242816
-
diff --git a/src/CBot/tests/TestCBot/TestCBot.cpp b/src/CBot/tests/TestCBot/TestCBot.cpp
deleted file mode 100644
index a76040a..0000000
--- a/src/CBot/tests/TestCBot/TestCBot.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-// * 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/.// TestCBot.cpp : Defines the class behaviors for the application.
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "MainFrm.h"
-#include "ChildFrm.h"
-#include "TestCBotDoc.h"
-#include "TestCBotView.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp
-
-BEGIN_MESSAGE_MAP(CTestCBotApp, CWinApp)
- //{{AFX_MSG_MAP(CTestCBotApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp construction
-
-CTestCBotApp::CTestCBotApp()
-{
- m_pConsole = NULL;
- m_LastActive = NULL;
- m_pClassPoint= NULL;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// The one and only CTestCBotApp object
-
-CTestCBotApp theApp;
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp initialization
-
-#include "Routines.cpp"
-
-
-static char BASED_CODE szSection[] = "Recent File List";
-static char BASED_CODE szFilename[] = "File1";
-
-
-#include "../ClassFILE.cpp"
-
-// routine pour mettre à jour l'instance de la classe Bot courante
-void rMajObject( CBotVar* pThis, void* pUser )
-{
- if (!pThis->IsElemOfClass("object"))
- return ;
- CBotVar* pPos = pThis->GivItem("position");
- CBotVar* pX = pPos->GivItem("x");
- CBotVar* pY = pPos->GivItem("y");
- CBotVar* pZ = pPos->GivItem("z");
-// CBotVar* pPt = pThis->GivItem("transport");
-
- CBotString p = pX->GivValString();
-
-// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
- pZ->SetValFloat( (float)0 );
- pY->SetValFloat( (float)-3.33 );
- pX->SetValFloat( pX->GivValFloat() + 10 ) ;
-
-// pX = pThis->GivItem( "xx" );
-// pX->SetValFloat( (float)22 );
-
- // crée une instance sur une classe object
-// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object");
-// pAutre->SetUserPtr( (void*)3 );
-// pPt->SetPointer( pAutre );
-// pPt->SetPointer( NULL );
-// delete pAutre;
-}
-
-
-BOOL CTestCBotApp::InitInstance()
-{
-//////////////////////////////////////////////
-// défini les mots clefs supplémentaires
-// -------------------------------------------
-
- CBotProgram::Init();
-
-//////////////////////////////////////////////
-// défini les fonctions "show()" et "print()"
-// -------------------------------------------
-
- CBotProgram::AddFunction("show", rShow, cShow);
- CBotProgram::AddFunction("print", rPrint, cPrint);
- CBotProgram::AddFunction("println", rPrintLn, cPrint);
-
-
-///////////////////////////////////
-// définie la classe globale CPoint
-// --------------------------------
-
- m_pClassPoint = new CBotClass("CPoint", NULL);
- // ajoute le composant ".x"
- m_pClassPoint->AddItem("x", CBotTypFloat);
- // ajoute le composant ".y"
- m_pClassPoint->AddItem("y", CBotTypFloat);
-
- // ajoute le constructeur pour cette classe
- m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
-
- m_pClassPointIntr = new CBotClass("point", NULL, TRUE);
- // ajoute le composant ".x"
- m_pClassPointIntr->AddItem("x", CBotTypFloat);
- // ajoute le composant ".y"
- m_pClassPointIntr->AddItem("y", CBotTypFloat);
- // ajoute le composant ".z"
- m_pClassPointIntr->AddItem("z", CBotTypFloat);
-
- // ajoute le constructeur pour cette classe
- m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);
-
- // défini la classe "object"
- CBotClass* pClassObject = new CBotClass( "object", NULL ) ;
- pClassObject->AddItem( "xx", CBotTypFloat );
- pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
- pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
- pClassObject->AddUpdateFunc( rMajObject );
-
- InitClassFILE();
-
- AfxEnableControlContainer();
-
- // Standard initialization
-
-#ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
-#else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
-#endif
-
- // Change the registry key under which our settings are stored.
- SetRegistryKey(_T("Local AppWizard-Generated Applications"));
-
- LoadStdProfileSettings(); // Load standard INI file options (including MRU)
-
- // Register document templates
-
- CMultiDocTemplate* pDocTemplate;
- pDocTemplate = new CMultiDocTemplate(
- IDR_TESTCBTYPE,
- RUNTIME_CLASS(CTestCBotDoc),
- RUNTIME_CLASS(CChildFrame), // custom MDI child frame
- RUNTIME_CLASS(CTestCBotView));
- AddDocTemplate(pDocTemplate);
-
- // create main MDI Frame window
- CMainFrame* pMainFrame = new CMainFrame;
- if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
- return FALSE;
- m_pMainWnd = pMainFrame;
-
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
- if (m_lpCmdLine[0] == 0)
- {
- CString Filename = GetProfileString(szSection, szFilename);
- if (Filename.IsEmpty()) Filename = "TstCbot.txt";
- else OpenDocumentFile(Filename);
- }
- else
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
- pMainFrame->ShowWindow(m_nCmdShow);
- pMainFrame->UpdateWindow();
-
-
- return TRUE;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CAboutDlg dialog used for App About
-
-class CAboutDlg : public CDialog
-{
-public:
- CAboutDlg();
-
-// Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
-{
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
-}
-
-void CAboutDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
-}
-
-BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-// App command to run the dialog
-void CTestCBotApp::OnAppAbout()
-{
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp commands
-
-int CTestCBotApp::ExitInstance()
-{
- delete m_pFuncFile;
-
- CBotProgram::Free();
- return CWinApp::ExitInstance();
-}
diff --git a/src/CBot/tests/TestCBot/TestCBot.dsp b/src/CBot/tests/TestCBot/TestCBot.dsp
deleted file mode 100644
index 8ed9b11..0000000
--- a/src/CBot/tests/TestCBot/TestCBot.dsp
+++ /dev/null
@@ -1,201 +0,0 @@
-# Microsoft Developer Studio Project File - Name="TestCBot" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=TestCBot - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TestCBot.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TestCBot.mak" CFG="TestCBot - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TestCBot - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "TestCBot - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TestCBot - Win32 Release"
-
-# PROP BASE Use_MFC 5
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 5
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /Yu"stdafx.h" /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x100c /d "NDEBUG"
-# ADD RSC /l 0x100c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
-# ADD LINK32 /nologo /subsystem:windows /machine:I386
-
-!ELSEIF "$(CFG)" == "TestCBot - Win32 Debug"
-
-# PROP BASE Use_MFC 5
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 5
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /Yu"stdafx.h" /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x100c /d "_DEBUG"
-# ADD RSC /l 0x100c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /stack:0x7010 /subsystem:windows /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "TestCBot - Win32 Release"
-# Name "TestCBot - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\CBotConsoleDlg.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ChildFrm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MainFrm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PerformDlg.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.cpp
-# ADD CPP /Yc"stdafx.h"
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBot.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBot.rc
-
-!IF "$(CFG)" == "TestCBot - Win32 Release"
-
-!ELSEIF "$(CFG)" == "TestCBot - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotDoc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotView.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\CBotConsoleDlg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ChildFrm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MainFrm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PerformDlg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBot.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotDoc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotView.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\res\TestCBot.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\TestCBot.rc2
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\TestCBotDoc.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\Toolbar.bmp
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\Debug\CBot.lib
-# End Source File
-# End Target
-# End Project
diff --git a/src/CBot/tests/TestCBot/TestCBot.h b/src/CBot/tests/TestCBot/TestCBot.h
deleted file mode 100644
index c2595b6..0000000
--- a/src/CBot/tests/TestCBot/TestCBot.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// * 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/.// TestCBot.h : main header file for the TESTCBOT application
-//
-
-#if !defined(AFX_TESTCBOT_H__4D1BB903_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_TESTCBOT_H__4D1BB903_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-#ifndef __AFXWIN_H__
- #error include 'stdafx.h' before including this file for PCH
-#endif
-
-#include "resource.h" // main symbols
-//#include "../CbotDll.h" // librairie CBot
-#include "../Cbot.h" // complet pour Browse
-
-class CTestCBotView;
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp:
-// See TestCBot.cpp for the implementation of this class
-//
-
-class CTestCBotApp : public CWinApp
-{
-public:
- CTestCBotApp();
-
- CEdit* m_pConsole;
- CTestCBotView* m_LastActive;
- CBotClass* m_pClassPoint;
- CBotClass* m_pClassPointIntr;
-
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CTestCBotApp)
- public:
- virtual BOOL InitInstance();
- virtual int ExitInstance();
- //}}AFX_VIRTUAL
-
-// Implementation
-
- //{{AFX_MSG(CTestCBotApp)
- afx_msg void OnAppAbout();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_TESTCBOT_H__4D1BB903_8E74_11D4_A439_00D059085115__INCLUDED_)
-
-
-#define WM_STARTPROG WM_APP + 0
-#define WM_ENDPROG WM_APP + 1
-#define WM_ACTWINDOW WM_APP + 2
diff --git a/src/CBot/tests/TestCBot/TestCBot.rc b/src/CBot/tests/TestCBot/TestCBot.rc
deleted file mode 100644
index 137458c..0000000
--- a/src/CBot/tests/TestCBot/TestCBot.rc
+++ /dev/null
@@ -1,564 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// French (France) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
-#ifdef _WIN32
-LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDR_MAINFRAME ICON DISCARDABLE "res\\TestCBot.ico"
-IDR_TESTCBTYPE ICON DISCARDABLE "res\\TestCBotDoc.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Toolbar
-//
-
-IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
-BEGIN
- BUTTON ID_FILE_NEW
- BUTTON ID_FILE_OPEN
- BUTTON ID_FILE_SAVE
- SEPARATOR
- BUTTON ID_EDIT_CUT
- BUTTON ID_EDIT_COPY
- BUTTON ID_EDIT_PASTE
- SEPARATOR
- BUTTON ID_FILE_PRINT
- BUTTON ID_RUN
- SEPARATOR
- BUTTON ID_APP_ABOUT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_MAINFRAME MENU PRELOAD DISCARDABLE
-BEGIN
- POPUP "&Fichier"
- BEGIN
- MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW
- MENUITEM "&Ouvrir...\tCtrl+O", ID_FILE_OPEN
- MENUITEM SEPARATOR
- MENUITEM "Fichier récent", ID_FILE_MRU_FILE1, GRAYED
- MENUITEM SEPARATOR
- MENUITEM "&Quitter", ID_APP_EXIT
- END
- POPUP "&Affichage"
- BEGIN
- MENUITEM "&Barre d'outils", ID_VIEW_TOOLBAR
- MENUITEM "Barre d'é&tat", ID_VIEW_STATUS_BAR
- END
- POPUP "&?"
- BEGIN
- MENUITEM "&A propos de TestCBot...", ID_APP_ABOUT
- END
-END
-
-IDR_TESTCBTYPE MENU PRELOAD DISCARDABLE
-BEGIN
- POPUP "&Fichier"
- BEGIN
- MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW
- MENUITEM "&Ouvrir...\tCtrl+O", ID_FILE_OPEN
- MENUITEM "&Fermer", ID_FILE_CLOSE
- MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE
- MENUITEM "En&registrer sous...", ID_FILE_SAVE_AS
- MENUITEM SEPARATOR
- MENUITEM "Fichier récent", ID_FILE_MRU_FILE1, GRAYED
- MENUITEM SEPARATOR
- MENUITEM "&Quitter", ID_APP_EXIT
- END
- POPUP "&Edition"
- BEGIN
- MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO
- MENUITEM SEPARATOR
- MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT
- MENUITEM "&Copier\tCtrl+C", ID_EDIT_COPY
- MENUITEM "C&oller\tCtrl+V", ID_EDIT_PASTE
- END
- POPUP "&Affichage"
- BEGIN
- MENUITEM "&Barre d'outils", ID_VIEW_TOOLBAR
- MENUITEM "Barre d'é&tat", ID_VIEW_STATUS_BAR
- END
- POPUP "Fe&nêtre"
- BEGIN
- MENUITEM "&Nouvelle fenêtre", ID_WINDOW_NEW
- MENUITEM "&Cascade", ID_WINDOW_CASCADE
- MENUITEM "&Mosaïque", ID_WINDOW_TILE_HORZ
- MENUITEM "&Réorganiser les icônes", ID_WINDOW_ARRANGE
- END
- POPUP "&?"
- BEGIN
- MENUITEM "&A propos de TestCBot...", ID_APP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
-BEGIN
- "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
- "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
- "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
- "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
- "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
- VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
- VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
- VK_F5, ID_RUN, VIRTKEY, NOINVERT
- VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT
- VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT
- VK_F7, ID_RUN, VIRTKEY, NOINVERT
- VK_F9, ID_TEST, VIRTKEY, NOINVERT
- VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
- VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
- "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
- "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 265, 206
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "A propos de TestCBot"
-FONT 8, "MS Sans Serif"
-BEGIN
- ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20
- LTEXT "TestCBot version 1.0",IDC_STATIC,40,10,119,8,
- SS_NOPREFIX
- LTEXT "Copyright D. Dumoulin (C) 2000",IDC_STATIC,40,25,119,8
- DEFPUSHBUTTON "OK",IDOK,226,7,32,14,WS_GROUP
- LTEXT "Programme de test pour la librairie CBot\n\nLes fonctions doivent être déclarées comme ""extern"" pour apparaître dans la liste lors de l'exécution.\n\n",
- IDC_STATIC,39,43,191,41
- LTEXT "Mais en fait, on peut accèder à toutes les fonctions marquées ""public"" quelles soient dans la fenêtre active ou non.",
- IDC_STATIC,39,89,187,36
- LTEXT "Les fonctions print( ... ) et println( ...) permettent d'afficher des résultats dans la console.\n\nLa fonction show( ... ) affiche les paramètres dans un dialogue, et suspend donc l'exécution.",
- IDC_STATIC,39,130,187,54
-END
-
-IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 186, 95
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
-FONT 8, "MS Sans Serif"
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,129,7,50,14
- PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
-END
-
-
-#ifndef _MAC
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,1
- PRODUCTVERSION 1,0,0,1
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040C04B0"
- BEGIN
- VALUE "CompanyName", "\0"
- VALUE "FileDescription", "Application MFC TestCBot\0"
- VALUE "FileVersion", "1, 0, 0, 1\0"
- VALUE "InternalName", "TestCBot\0"
- VALUE "LegalCopyright", "Copyright (C) 1900\0"
- VALUE "LegalTrademarks", "\0"
- VALUE "OriginalFilename", "TestCBot.EXE\0"
- VALUE "ProductName", "Application TestCBot\0"
- VALUE "ProductVersion", "1, 0, 0, 1\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Traduction", 0x40c, 1200
- END
-END
-
-#endif // !_MAC
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
-BEGIN
- IDD_ABOUTBOX, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 258
- TOPMARGIN, 7
- BOTTOMMARGIN, 199
- END
-
- IDD_DIALOG2, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 179
- TOPMARGIN, 7
- BOTTOMMARGIN, 88
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE PRELOAD DISCARDABLE
-BEGIN
- IDR_MAINFRAME "TestCBot"
- IDR_TESTCBTYPE "\nTestCBot\nTestCBot\nCBot (*.txt)\n.txt\nTestCBot.Document\nTestCB Document"
-END
-
-STRINGTABLE PRELOAD DISCARDABLE
-BEGIN
- AFX_IDS_APP_TITLE "TestCBot"
- AFX_IDS_IDLEMESSAGE "Prêt"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_INDICATOR_EXT "EXT"
- ID_INDICATOR_CAPS "MAJ"
- ID_INDICATOR_NUM "NUM"
- ID_INDICATOR_SCRL "DEF"
- ID_INDICATOR_OVR "ECR"
- ID_INDICATOR_REC "ENR"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_FILE_NEW "Crée un nouveau document\nNouveau"
- ID_FILE_OPEN "Ouvre un document existant\nOuvrir"
- ID_FILE_CLOSE "Ferme le document actif\nFermer"
- ID_FILE_SAVE "Enregistre le document actif\nEnregistrer"
- ID_FILE_SAVE_AS "Enregistre le document actif sous un nouveau nom\nEnregistrer sous"
- ID_FILE_PRINT "Imprime le document\nImprime"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_APP_ABOUT "Affiche des informations sur le programme\nA propos de"
- ID_APP_EXIT "Ferme l'application ; propose d'enregistrer les documents\nQuitter"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_FILE_MRU_FILE1 "Ouvre ce document"
- ID_FILE_MRU_FILE2 "Ouvre ce document"
- ID_FILE_MRU_FILE3 "Ouvre ce document"
- ID_FILE_MRU_FILE4 "Ouvre ce document"
- ID_FILE_MRU_FILE5 "Ouvre ce document"
- ID_FILE_MRU_FILE6 "Ouvre ce document"
- ID_FILE_MRU_FILE7 "Ouvre ce document"
- ID_FILE_MRU_FILE8 "Ouvre ce document"
- ID_FILE_MRU_FILE9 "Ouvre ce document"
- ID_FILE_MRU_FILE10 "Ouvre ce document"
- ID_FILE_MRU_FILE11 "Ouvre ce document"
- ID_FILE_MRU_FILE12 "Ouvre ce document"
- ID_FILE_MRU_FILE13 "Ouvre ce document"
- ID_FILE_MRU_FILE14 "Ouvre ce document"
- ID_FILE_MRU_FILE15 "Ouvre ce document"
- ID_FILE_MRU_FILE16 "Ouvre ce document"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_NEXT_PANE "Passe au volet de fenêtre suivant\nVolet suivant"
- ID_PREV_PANE "Revient au volet précédent\nVolet précédent"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_WINDOW_NEW "Ouvre une nouvelle fenêtre pour le document actif\nNouvelle fenêtre"
- ID_WINDOW_ARRANGE "Réorganise les icônes en bas de la fenêtre\nRéorganise les icônes"
- ID_WINDOW_CASCADE "Réorganise les fenêtres en cascade\nCascade"
- ID_WINDOW_TILE_HORZ "Réorganise les fenêtres en une mosaïque\nMosaïque"
- ID_WINDOW_TILE_VERT "Réorganise les fenêtres en une mosaïque\nMosaïque"
- ID_WINDOW_SPLIT "Fractionne la fenêtre active en deux volets\nFractionner"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_EDIT_CLEAR "Efface la sélection\nEffacer"
- ID_EDIT_CLEAR_ALL "Efface tout\nEffacer tout"
- ID_EDIT_COPY "Copie la sélection et la place dans le Presse-papiers\nCopier"
- ID_EDIT_CUT "Supprime la sélection et la place dans le Presse-papiers\nCopier"
- ID_EDIT_FIND "Recherche le texte spécifié\nRechercher"
- ID_EDIT_PASTE "Insère le contenu du Presse-papiers\nColler"
- ID_EDIT_REPEAT "Répète la dernière action\nRépéter"
- ID_EDIT_REPLACE "Remplace le texte spécifique par un texte différent\nRemplacer"
- ID_EDIT_SELECT_ALL "Sélectionne le document entier\nSélectionner tout"
- ID_EDIT_UNDO "Annule la dernière action\nAnnuler"
- ID_EDIT_REDO "Rétablit l'action précédemment annulée\nRétablir"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_VIEW_TOOLBAR "Affiche ou masque la barre d'outils\nBarre d'outils"
- ID_VIEW_STATUS_BAR "Affiche ou masque la barre d'état\nBarre d'état"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- AFX_IDS_SCSIZE "Change la taille de la fenêtre"
- AFX_IDS_SCMOVE "Change la position de la fenêtre"
- AFX_IDS_SCMINIMIZE "Réduit la fenêtre en icône"
- AFX_IDS_SCMAXIMIZE "Agrandit la fenêtre au format de l'écran"
- AFX_IDS_SCNEXTWINDOW "Passe à la fenêtre de document suivante"
- AFX_IDS_SCPREVWINDOW "Passe à la fenêtre de document précédente"
- AFX_IDS_SCCLOSE "Ferme la fenêtre active et propose l'enregistrement des documents"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- AFX_IDS_SCRESTORE "Restaure la fenêtre à sa taille d'origine"
- AFX_IDS_SCTASKLIST "Active la liste des tâches"
- AFX_IDS_MDICHILD "Active cette fenêtre"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_RUN "Execute le programme CBot\nExecute (F5)"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- TX_TYPENAMES "les différents types"
- 1001 "Byte"
- 1002 "Short"
- 1003 "Char"
- 1004 "Int"
- 1005 "Long"
- 1006 "Real"
- 1007 "Double"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- 1008 "Boolean"
- 1009 "String"
- 1010 "Array"
- 1011 "Arraybody"
- 1012 "Pointer"
- 1013 "Nullpointer"
- 1014 "nop"
- 1015 "Class"
- 1016 "Intrinsic"
-END
-
-#endif // French (France) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// French (Switzerland) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRS)
-#ifdef _WIN32
-LANGUAGE LANG_FRENCH, SUBLANG_FRENCH_SWISS
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_CONSOLE DIALOG DISCARDABLE 0, 0, 401, 210
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "CBot Console"
-FONT 8, "MS Sans Serif"
-BEGIN
- LTEXT "Commande :",IDC_STATIC,7,177,40,8
- EDITTEXT IDC_EDIT2,7,189,329,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "Exécute",IDOK,344,189,50,14
- EDITTEXT IDC_EDIT1,7,7,387,167,ES_MULTILINE | ES_READONLY |
- ES_WANTRETURN | WS_VSCROLL
-END
-
-IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 177, 100
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Test performances"
-FONT 8, "MS Sans Serif"
-BEGIN
- LTEXT "Boucles par seconde",IDC_STATIC,7,9,68,8
- EDITTEXT IDC_EDIT1,111,7,51,14,ES_AUTOHSCROLL | ES_READONLY
- LTEXT "Nombre de scripts",IDC_STATIC,7,55,58,8
- EDITTEXT IDC_EDIT2,111,52,40,14,ES_AUTOHSCROLL
- CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,152,52,
- 10,14
- COMBOBOX IDC_COMBO1,111,74,52,111,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- LTEXT "Timer",IDC_STATIC,7,77,18,8
- LTEXT "Performance %",IDC_STATIC,7,28,48,8
- EDITTEXT IDC_EDIT3,111,25,51,14,ES_AUTOHSCROLL | ES_READONLY
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
-BEGIN
- IDD_CONSOLE, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 394
- TOPMARGIN, 7
- BOTTOMMARGIN, 203
- END
-
- IDD_DIALOG1, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 170
- TOPMARGIN, 7
- BOTTOMMARGIN, 93
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
- "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
- "#define _AFX_NO_OLE_RESOURCES\r\n"
- "#define _AFX_NO_TRACKER_RESOURCES\r\n"
- "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
- "\r\n"
- "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n"
- "#ifdef _WIN32\r\n"
- "LANGUAGE 12, 1\r\n"
- "#pragma code_page(1252)\r\n"
- "#endif\r\n"
- "#include ""res\\TestCBot.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
- "#include ""l.fra\\afxres.rc"" // Standard components\r\n"
- "#endif\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog Info
-//
-
-IDD_DIALOG1 DLGINIT
-BEGIN
- IDC_COMBO1, 0x403, 2, 0
-0x0031,
- IDC_COMBO1, 0x403, 3, 0
-0x3031, "\000"
- IDC_COMBO1, 0x403, 4, 0
-0x3031, 0x0030,
- IDC_COMBO1, 0x403, 5, 0
-0x3031, 0x3030, "\000"
- 0
-END
-
-#endif // French (Switzerland) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-#define _AFX_NO_SPLITTER_RESOURCES
-#define _AFX_NO_OLE_RESOURCES
-#define _AFX_NO_TRACKER_RESOURCES
-#define _AFX_NO_PROPERTY_RESOURCES
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
-#ifdef _WIN32
-LANGUAGE 12, 1
-#pragma code_page(1252)
-#endif
-#include "res\TestCBot.rc2" // non-Microsoft Visual C++ edited resources
-#include "l.fra\afxres.rc" // Standard components
-#endif
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/CBot/tests/TestCBot/TestCBotDoc.cpp b/src/CBot/tests/TestCBot/TestCBotDoc.cpp
deleted file mode 100644
index 8880c57..0000000
--- a/src/CBot/tests/TestCBot/TestCBotDoc.cpp
+++ /dev/null
@@ -1,697 +0,0 @@
-// * 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/.// TestCBotDoc.cpp : implementation of the CTestCBotDoc class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "TestCBotDoc.h"
-#include "TestCBotView.h"
-#include "CBotConsoleDlg.h"
-#include "PerformDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc
-
-IMPLEMENT_DYNCREATE(CTestCBotDoc, CDocument)
-
-BEGIN_MESSAGE_MAP(CTestCBotDoc, CDocument)
- //{{AFX_MSG_MAP(CTestCBotDoc)
- ON_COMMAND(ID_RUN, OnRun)
- ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
- ON_COMMAND(ID_TEST, OnTest)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc construction/destruction
-
-static BOOL test = FALSE;
-
-
-CTestCBotDoc::CTestCBotDoc()
-{
- m_pEdit = NULL;
- m_pProg = NULL;
- m_bModified = FALSE;
-}
-
-CTestCBotDoc::~CTestCBotDoc()
-{
- delete m_pEdit;
- delete m_pProg;
-}
-
-BOOL CTestCBotDoc::OnNewDocument()
-{
- if (!CDocument::OnNewDocument())
- return FALSE;
-
- return TRUE;
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc serialization
-
-void CTestCBotDoc::Serialize(CArchive& ar)
-{
- if (ar.IsStoring())
- {
- m_pEdit->GetWindowText(m_DocText);
- int w = m_DocText.GetLength();
- ar.Write((LPCTSTR)m_DocText, w);
- }
- else
- {
- int r;
- char buf[10001];
-
- r = ar.Read(buf, 10000);
- buf[r] = 0;
- m_DocText = buf;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- if (!m_pProg->Compile(m_DocText, m_Liste, NULL))
- {
- delete m_pProg;
- m_pProg = NULL;
- }
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc diagnostics
-
-#ifdef _DEBUG
-void CTestCBotDoc::AssertValid() const
-{
- CDocument::AssertValid();
-}
-
-void CTestCBotDoc::Dump(CDumpContext& dc) const
-{
- CDocument::Dump(dc);
-}
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc commands
-
-void CTestCBotDoc::OnRun()
-{
- OnFileSave();
-
- m_pEdit->GetWindowText(m_DocText);
-
- CString TextError;
- int code, start, end;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
-
- if (!m_pProg->Compile(m_DocText, m_Liste, NULL))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- return;
- }
-
- if( m_Liste.GivSize() == 0 )
- {
- AfxMessageBox("Aucune fonction marquée \"extern\" !");
- return;
- }
-
- for ( int i = 0; i < m_Liste.GivSize(); i++ )
- {
- int start, stop;
- m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
- m_Liste[i] = m_DocText.Mid( start, stop-start );
- }
-
- CBotConsoleDlg dlg;
- dlg.m_pListe = &m_Liste;
- dlg.m_pEditx = m_pEdit;
-
- dlg.DoModal(); // dialogue pour faire la console
-
- if ( dlg.m_code>0 )
- {
- CString TextError;
-
- TextError = m_pProg->GivErrorText( dlg.m_code );
-
- m_pEdit->SetSel( dlg.m_start, dlg.m_end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- AfxMessageBox(TextError);
- }
-
- m_pEdit->SetFocus();
-
- return;
-}
-
-
-void CTestCBotDoc::OnChangeEdit1()
-{
- SetModifiedFlag();
- m_bModified = TRUE;
-}
-
-BOOL CTestCBotDoc::Compile()
-{
- m_pEdit->GetWindowText(m_DocText);
-
- CString TextError;
- int code, start, end;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- char buffer[100];
- strcpy(buffer, "le pointeur à passer pour voir");
-
- if (m_bModified && !m_pProg->Compile(m_DocText, m_Liste, (void*)buffer))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- m_bModified = FALSE;
- return FALSE;
- }
-
- if ( m_pProg->GetPosition( "TheTest", start, end) )
- {
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
- }
-
- m_bModified = FALSE;
- return TRUE;
-}
-
-
-
-static int compt = 0;
-// routine retournant le "pointeur" à un autre object
-BOOL rRetObject( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- pResult->SetPointer( NULL );
- compt+=45671;
- if (compt&0x11) return TRUE;
-
- CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
- pAutre->SetUserPtr( (void*)2 );
- pResult->SetPointer( pAutre );
-
- if (!pResult->IsElemOfClass("object"))
- return TRUE;
-
- delete pAutre;
- return TRUE;
-}
-
-CBotTypResult cRetObject( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( CBotTypPointer, "object");
-}
-
-BOOL roRadar( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
-{
- pResult->SetPointer( NULL );
- compt+=45671;
- if (compt&0x11) return TRUE;
-
- CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
- pAutre->SetUserPtr( (void*)2 );
- pResult->SetPointer( pAutre );
-
- if (!pResult->IsElemOfClass("object"))
- return TRUE;
-
- delete pAutre;
- return TRUE;
-}
-
-CBotTypResult coRadar( CBotVar* pThis, CBotVar* &pVar )
-{
- void* pUser = pThis->GivUserPtr();
- return CBotTypResult( CBotTypPointer, "object");
-}
-
-BOOL rMove( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- if ( test < 12 )
- {
- test++;
- return FALSE;
- }
- return TRUE;
-}
-
-CBotTypResult cMove( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( 0 );
-}
-
-BOOL rTurn( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- return TRUE;
-}
-
-CBotTypResult cTurn( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( 0 );
-}
-
-BOOL rRadar( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- pResult->SetPointer( NULL );
-
- if ( pVar ) pVar->debug();
-
- compt+=45671;
- if (compt&0x11)
- {
- return FALSE; // TRUE;
- }
-
- CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
- pAutre->SetUserPtr( (void*)2 );
- pResult->SetPointer( pAutre );
-
- if (!pResult->IsElemOfClass("object"))
- return TRUE;
-
- delete pAutre;
- return TRUE;
-}
-
-CBotTypResult cRadar( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( CBotTypPointer, "object");
-}
-
-// routine retournant le "pointeur" à un autre object
-BOOL rTEST( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- test = 1 ;
- if ( pVar == NULL ) return TRUE;
-
- test = pVar->GivValInt();
- if ( test == 5 )
- {
- pVar = pVar->GivNext();
- pVar->SetUserPtr( OBJECTDELETED );
- }
- return TRUE;
-}
-
-CBotTypResult cTEST( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( 0 );
-}
-
-// routine retournant le "pointeur" à un autre object
-BOOL rF( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- if ( pResult == NULL ) return TRUE;
- pResult->SetValInt(3);
- return TRUE;
-}
-
-CBotTypResult cF( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( CBotTypFloat );
-}
-
-/////////////////////////////////////////////////////////////////
-
-// Compilation d'une procédure avec un "point".
-
-CBotTypResult cPoint(CBotVar* &var, void* user)
-{
- if ( var == 0 ) return CBotTypResult( CBotErrLowParam );
-
- if ( var->GivType() <= CBotTypDouble )
- {
- var = var->GivNext();
- if ( var == 0 ) return CBotTypResult( CBotErrLowParam );
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
- if ( var == 0 ) return CBotTypResult( CBotErrLowParam );
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
- return CBotTypResult( 0 );
- }
-
- if ( var->GivType() == CBotTypClass )
- {
- if ( !var->IsElemOfClass("point") ) return CBotTypResult( CBotErrBadParam );
- var = var->GivNext();
- return CBotTypResult( 0 );
- }
-
- return CBotTypResult( CBotErrBadParam );
-}
-
-// Donne un paramètre de type "point".
-#define UNIT 1
-
-
-CBotTypResult cSpace(CBotVar* &var, void* user)
-{
- CBotTypResult ret;
-
- if ( var == 0 ) return CBotTypResult( CBotTypIntrinsic, "point" );
- ret = cPoint(var, user);
- if ( !ret.Eq(0) ) return ret;
-
- if ( var == 0 ) return CBotTypIntrinsic;
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
-
- if ( var == 0 ) return CBotTypIntrinsic;
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
-
- if ( var == 0 ) return CBotTypIntrinsic;
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
-
- if ( var != 0 ) return CBotErrOverParam;
- return CBotTypResult( CBotTypIntrinsic, "point" );
-}
-
-// Instruction "space(center, rMin, rMax, dist)".
-
-BOOL rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
-{
- CBotVar* pSub;
- float rMin, rMax, dist;
-
- rMin = 5.0f*UNIT;
- rMax = 50.0f*UNIT;
- dist = 4.0f*UNIT;
-
- if ( var == 0 )
- {
-// center = pThis->RetPosition(0);
- }
- else
- {
- if ( var != 0 )
- {
- rMin = var->GivValFloat()*UNIT;
- var = var->GivNext();
-
- if ( var != 0 )
- {
- rMax = var->GivValFloat()*UNIT;
- var = var->GivNext();
-
- if ( var != 0 )
- {
- dist = var->GivValFloat()*UNIT;
- var = var->GivNext();
- }
- }
- }
- }
-
- if ( result != 0 )
- {
- pSub = result->GivItemList();
- if ( pSub != 0 )
- {
- pSub->SetValFloat(1);
- pSub = pSub->GivNext(); // "y"
- pSub->SetValFloat(2);
- pSub = pSub->GivNext(); // "z"
-// pSub->SetValFloat(3);
- }
- }
- return TRUE;
-}
-//////////////////////////////////////////////////////////////
-
-
-void CTestCBotDoc::OnTest()
-{
- CBotProgram::DefineNum("WingedGrabber", 1);
- CBotProgram::DefineNum("TrackedGrabber", 2);
- CBotProgram::DefineNum("WheeledGrabber", 3);
- CBotProgram::DefineNum("LeggedGrabber", 4);
- CBotProgram::DefineNum("WingedShooter", 5);
- CBotProgram::DefineNum("TrackedShooter", 6);
- CBotProgram::DefineNum("WheeledShooter", 7);
- CBotProgram::DefineNum("LeggedShooter", 8);
- CBotProgram::DefineNum("WingedOrgaShooter", 9);
- CBotProgram::DefineNum("TrackedOrgaShooter", 10);
- CBotProgram::DefineNum("WheeledOrgaShooter", 11);
- CBotProgram::DefineNum("LeggedOrgaShooter", 12);
- CBotProgram::DefineNum("WingedSniffer", 13);
- CBotProgram::DefineNum("TrackedSniffer", 14);
- CBotProgram::DefineNum("WheeledSniffer", 14);
- CBotProgram::DefineNum("LeggedSniffer", 15);
- CBotProgram::DefineNum("Thumper", 16);
- CBotProgram::DefineNum("PhazerShooter", 17);
- CBotProgram::DefineNum("Recycler", 18);
- CBotProgram::DefineNum("Shielder", 19);
- CBotProgram::DefineNum("Subber", 20);
- CBotProgram::DefineNum("Me", 21);
-
- CBotProgram::DefineNum("TypeMarkPath", 111);
-
- OnFileSave();
-
-// CPerformDlg dlg;
-// dlg.m_Script = m_DocText;
-// dlg.DoModal();
-
- // défini la routine RetObject
- CBotProgram::AddFunction( "Radar", rRetObject, cRetObject );
-
- // ajoute une routine pour cette classe
- CBotProgram::AddFunction("Space", rSpace, cSpace);
-
- // défini la routine Test
- CBotProgram::AddFunction( "TEST", rTEST, cTEST );
- CBotProgram::AddFunction( "F", rF, cF );
-
- CBotProgram::AddFunction( "goto", rMove, cMove );
- CBotProgram::AddFunction( "fire", rTurn, cTurn );
- CBotProgram::AddFunction( "radar", rRadar, cRadar );
-
- // crée une instance de la classe "Bot" pour ce robot
- CBotVar* pThisRobot = CBotVar::Create( "", CBotTypResult(CBotTypClass, "object") );
- pThisRobot->SetUserPtr( (void*)1 );
- pThisRobot->SetIdent( 1234 );
-
- delete m_pProg;
- // crée un objet programme associé à cette instance
- m_pProg = new CBotProgram(pThisRobot);
-
- // compile le programme
- CString TextError;
- int code, start, end;
-
- m_pEdit->GetWindowText(m_DocText);
- if (!m_pProg->Compile(m_DocText, m_Liste, (void*) 44))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- delete pThisRobot;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- return;
- }
-
- // exécute pour voir
- m_pProg->Start(m_Liste[0]);
-
- int mode = -1;
-
- if ( mode >= 0 ) {
-
- // sauve et restore à chaque pas possible
- while (!m_pProg->Run(NULL, 1))
- {
- const char* FunctionName;
- int start1, end1;
- m_pProg->GetRunPos(FunctionName, start1, end1);
- if ( end1 <= 0 )
- m_pProg->GetRunPos(FunctionName, start1, end1);
- m_pEdit->SetSel(start1, end1);
-
-if ( mode == 0 ) continue;
-
- FILE* pf;
- pf = fOpen( "TEST.CBO", "wb" );
- CBotClass::SaveStaticState(pf);
- m_pProg->SaveState(pf);
- fClose(pf);
-
-if ( mode == 2 ) if (!m_pProg->Compile(m_DocText, m_Liste, (void*) 44))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- delete pThisRobot;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- return;
- }
-
- pf = fOpen( "TEST.CBO", "rb" );
- CBotClass::RestoreStaticState(pf);
- m_pProg->RestoreState(pf);
- fClose(pf);
-
- int start2, end2;
- m_pProg->GetRunPos(FunctionName, start2, end2);
- if ( end2 <= 0 )
- m_pProg->GetRunPos(FunctionName, start2, end2);
-
- if ( start1 != start2 || end1 != end2 )
- m_pProg->GetRunPos(FunctionName, start2, end2);
- m_pEdit->SetSel(start2, end2);
- }
-
- if (m_pProg->GetError(code, start, end))
- {
- m_pEdit->SetSel(start, end);
- TextError = CBotProgram::GivErrorText(code);
- AfxMessageBox(TextError);
- }
- return;}
-
- while (!m_pProg->Run(NULL, 0))
- {
- const char* FunctionName;
- int start, end;
- m_pProg->GetRunPos(FunctionName, start, end);
- m_pEdit->SetSel(start, end);
-
- if ( FunctionName == NULL ) continue;
- CString info (FunctionName);
- CString sep (":\n");
-
- int level = 0;
- const char* Name;
- while ( TRUE )
- {
- CBotVar* pVar = m_pProg->GivStackVars(Name, level--);
- if ( Name != FunctionName ) break;
- if ( pVar == NULL ) continue;
-// pVar->Maj(NULL, FALSE);
- while ( pVar != NULL )
- {
- info += sep;
- info += pVar->GivName() + CBotString(" = ") + pVar->GivValString();
- sep = ", ";
- pVar = pVar->GivNext();
- }
- sep = "\n";
- }
- if ( IDOK != AfxMessageBox(info, MB_OKCANCEL) ) break;
-
- if ( test == 1 )
- {
- test = 0;
- FILE* pf;
- pf = fOpen( "TEST.CBO", "wb" );
- m_pProg->SaveState(pf);
- fClose(pf);
- }
-
- if ( test == 2 )
- {
- test = 0;
- FILE* pf;
- pf = fOpen( "TEST.CBO", "rb" );
- m_pProg->RestoreState(pf);
- fClose(pf);
- }
-
- if ( test == 12 )
- {
- test = 0;
- FILE* pf;
- pf = fOpen( "TEST.CBO", "wb" );
- m_pProg->SaveState(pf);
- fClose(pf);
-
- pf = fOpen( "TEST.CBO", "rb" );
- m_pProg->RestoreState(pf);
- fClose(pf);
-
- test = 13;
- }
- }
-
- if (m_pProg->GetError(code, start, end))
- {
- m_pEdit->SetSel(start, end);
- TextError = CBotProgram::GivErrorText(code);
- AfxMessageBox(TextError);
- }
-
- delete pThisRobot;
-}
-
diff --git a/src/CBot/tests/TestCBot/TestCBotDoc.h b/src/CBot/tests/TestCBot/TestCBotDoc.h
deleted file mode 100644
index 548607f..0000000
--- a/src/CBot/tests/TestCBot/TestCBotDoc.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// * 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/.// TestCBotDoc.h : interface of the CTestCBotDoc class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_TESTCBOTDOC_H__4D1BB90B_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_TESTCBOTDOC_H__4D1BB90B_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-
-class CTestCBotDoc : public CDocument
-{
-protected: // create from serialization only
- CTestCBotDoc();
- DECLARE_DYNCREATE(CTestCBotDoc)
-
-// Attributes
-public:
- CEdit* m_pEdit; // pour mémoriser le texte, et l'afficher
- CBotProgram* m_pProg; // le programme compilé
- CString m_DocText;
- CBotStringArray m_Liste;
- BOOL m_bModified;
-
-// Operations
-public:
- BOOL Compile();
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CTestCBotDoc)
- public:
- virtual BOOL OnNewDocument();
- virtual void Serialize(CArchive& ar);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CTestCBotDoc();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-protected:
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CTestCBotDoc)
- afx_msg void OnRun();
- afx_msg void OnChangeEdit1();
- afx_msg void OnTest();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_TESTCBOTDOC_H__4D1BB90B_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/TestCBotView.cpp b/src/CBot/tests/TestCBot/TestCBotView.cpp
deleted file mode 100644
index bca3c56..0000000
--- a/src/CBot/tests/TestCBot/TestCBotView.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// * 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/.
-
-// TestCBotView.cpp : implementation of the CTestCBotView class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "TestCBotDoc.h"
-#include "TestCBotView.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView
-
-IMPLEMENT_DYNCREATE(CTestCBotView, CView)
-
-BEGIN_MESSAGE_MAP(CTestCBotView, CView)
- //{{AFX_MSG_MAP(CTestCBotView)
- ON_WM_SIZE()
- ON_MESSAGE(WM_ACTWINDOW, ActWindow)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView construction/destruction
-
-CTestCBotView::CTestCBotView()
-{
-}
-
-CTestCBotView::~CTestCBotView()
-{
-}
-
-BOOL CTestCBotView::PreCreateWindow(CREATESTRUCT& cs)
-{
- return CView::PreCreateWindow(cs);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView drawing
-
-void CTestCBotView::OnDraw(CDC* pDC)
-{
- CTestCBotDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView diagnostics
-
-#ifdef _DEBUG
-void CTestCBotView::AssertValid() const
-{
- CView::AssertValid();
-}
-
-void CTestCBotView::Dump(CDumpContext& dc) const
-{
- CView::Dump(dc);
-}
-
-CTestCBotDoc* CTestCBotView::GetDocument() // non-debug version is inline
-{
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestCBotDoc)));
- return (CTestCBotDoc*)m_pDocument;
-}
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView message handlers
-
-void CTestCBotView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
-{
- CTestCBotDoc* pDoc = GetDocument();
-// CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
-
- if ( pDoc->m_pEdit == NULL)
- {
- pDoc->m_pEdit = new CEdit();
- CRect rect;
- GetClientRect( rect );
-
- pDoc->m_pEdit->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN|ES_NOHIDESEL|ES_AUTOVSCROLL,
- rect, this, IDC_EDIT1 );
- pDoc->m_pEdit->SetTabStops(12);
- pDoc->m_pEdit->SetWindowText(pDoc->m_DocText);
- }
-
- if ( !bActivate && !pDoc->Compile() )
- {
-// comment faire pour réactiver l'ancien document
- }
-
- CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
-
- if ( bActivate ) pDoc->m_pEdit->SetFocus();
-}
-
-
-void CTestCBotView::OnSize(UINT nType, int cx, int cy)
-{
- CView::OnSize(nType, cx, cy);
-
- CTestCBotDoc* pDoc = GetDocument();
- if ( pDoc->m_pEdit != NULL )
- {
- CRect rect;
- GetClientRect( rect );
- pDoc->m_pEdit->MoveWindow( rect );
- pDoc->m_pEdit->SetFocus();
- }
-}
-
-
-
-LONG CTestCBotView::ActWindow(UINT wparam, LONG lparam)
-{
-// GetParentFrame()->SetActiveView( this, TRUE );
-// CMDIChildWnd::OnMDIActivate(1, this, this)
- return 0;
-}
diff --git a/src/CBot/tests/TestCBot/TestCBotView.h b/src/CBot/tests/TestCBot/TestCBotView.h
deleted file mode 100644
index 065ee08..0000000
--- a/src/CBot/tests/TestCBot/TestCBotView.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// * 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/.// TestCBotView.h : interface of the CTestCBotView class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_TESTCBOTVIEW_H__4D1BB90D_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_TESTCBOTVIEW_H__4D1BB90D_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-class CTestCBotView : public CView
-{
-protected: // create from serialization only
- CTestCBotView();
- DECLARE_DYNCREATE(CTestCBotView)
-
-// Attributes
-public:
- CTestCBotDoc* GetDocument();
-
-// Operations
-public:
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CTestCBotView)
- public:
- virtual void OnDraw(CDC* pDC); // overridden to draw this view
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- protected:
- virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CTestCBotView();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-protected:
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CTestCBotView)
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg LONG ActWindow(UINT wparam, LONG lparam) ;
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-#ifndef _DEBUG // debug version in TestCBotView.cpp
-inline CTestCBotDoc* CTestCBotView::GetDocument()
- { return (CTestCBotDoc*)m_pDocument; }
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_TESTCBOTVIEW_H__4D1BB90D_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/a§1.txt~ b/src/CBot/tests/TestCBot/a§1.txt~
deleted file mode 100644
index 0c57950..0000000
--- a/src/CBot/tests/TestCBot/a§1.txt~
+++ /dev/null
@@ -1,96 +0,0 @@
-object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/TestCBot/res/TestCBot.ico b/src/CBot/tests/TestCBot/res/TestCBot.ico
deleted file mode 100644
index 06a649d..0000000
--- a/src/CBot/tests/TestCBot/res/TestCBot.ico
+++ /dev/null
Binary files differ
diff --git a/src/CBot/tests/TestCBot/res/TestCBot.rc2 b/src/CBot/tests/TestCBot/res/TestCBot.rc2
deleted file mode 100644
index b55f0d9..0000000
--- a/src/CBot/tests/TestCBot/res/TestCBot.rc2
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// TESTCBOT.RC2 - resources Microsoft Visual C++ does not edit directly
-//
-
-#ifdef APSTUDIO_INVOKED
- #error this file is not editable by Microsoft Visual C++
-#endif //APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Add manually edited resources here...
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/src/CBot/tests/TestCBot/res/TestCBotDoc.ico b/src/CBot/tests/TestCBot/res/TestCBotDoc.ico
deleted file mode 100644
index 3545614..0000000
--- a/src/CBot/tests/TestCBot/res/TestCBotDoc.ico
+++ /dev/null
Binary files differ
diff --git a/src/CBot/tests/TestCBot/res/Toolbar.bmp b/src/CBot/tests/TestCBot/res/Toolbar.bmp
deleted file mode 100644
index 04a71af..0000000
--- a/src/CBot/tests/TestCBot/res/Toolbar.bmp
+++ /dev/null
Binary files differ
diff --git a/src/CBot/tests/TestCBot/resource.h b/src/CBot/tests/TestCBot/resource.h
deleted file mode 100644
index d661201..0000000
--- a/src/CBot/tests/TestCBot/resource.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// * 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/.//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by TestCBot.rc
-//
-#define IDD_ABOUTBOX 100
-#define IDR_MAINFRAME 128
-#define IDR_TESTCBTYPE 129
-#define IDD_DIALOG1 130
-#define IDD_CONSOLE 131
-#define IDD_DIALOG2 133
-#define IDC_EDIT1 1000
-#define TX_TYPENAMES 1000
-#define IDC_SPIN1 1001
-#define IDC_EDIT2 1002
-#define IDC_COMBO1 1003
-#define IDC_EDIT3 1004
-#define ID_RUN 32771
-#define ID_TEST 32772
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_3D_CONTROLS 1
-#define _APS_NEXT_RESOURCE_VALUE 135
-#define _APS_NEXT_COMMAND_VALUE 32773
-#define _APS_NEXT_CONTROL_VALUE 1004
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/CBot/tests/TestCBot/xTestCBot.clw b/src/CBot/tests/TestCBot/xTestCBot.clw
deleted file mode 100644
index 5b84c16..0000000
--- a/src/CBot/tests/TestCBot/xTestCBot.clw
+++ /dev/null
@@ -1,245 +0,0 @@
-; CLW file contains information for the MFC ClassWizard
-
-[General Info]
-Version=1
-LastClass=CBotConsoleDlg
-LastTemplate=CDialog
-NewFileInclude1=#include "stdafx.h"
-NewFileInclude2=#include "TestCBot.h"
-LastPage=0
-
-ClassCount=7
-Class1=CTestCBotApp
-Class2=CTestCBotDoc
-Class3=CTestCBotView
-Class4=CMainFrame
-
-ResourceCount=7
-Resource1=IDD_ABOUTBOX
-Resource2=IDR_MAINFRAME
-Resource3=IDR_TESTCBTYPE
-Class5=CAboutDlg
-Class6=CChildFrame
-Resource4=IDD_ABOUTBOX (French (France))
-Resource5=IDR_TESTCBTYPE (French (France))
-Resource6=IDD_CONSOLE
-Class7=CBotConsoleDlg
-Resource7=IDR_MAINFRAME (French (France))
-
-[CLS:CTestCBotApp]
-Type=0
-HeaderFile=TestCBot.h
-ImplementationFile=TestCBot.cpp
-Filter=N
-
-[CLS:CTestCBotDoc]
-Type=0
-HeaderFile=TestCBotDoc.h
-ImplementationFile=TestCBotDoc.cpp
-Filter=N
-BaseClass=CDocument
-VirtualFilter=DC
-LastObject=IDC_EDIT2
-
-[CLS:CTestCBotView]
-Type=0
-HeaderFile=TestCBotView.h
-ImplementationFile=TestCBotView.cpp
-Filter=C
-BaseClass=CView
-VirtualFilter=VWC
-LastObject=CTestCBotView
-
-[CLS:CMainFrame]
-Type=0
-HeaderFile=MainFrm.h
-ImplementationFile=MainFrm.cpp
-Filter=T
-BaseClass=CMDIFrameWnd
-VirtualFilter=fWC
-LastObject=CMainFrame
-
-
-[CLS:CChildFrame]
-Type=0
-HeaderFile=ChildFrm.h
-ImplementationFile=ChildFrm.cpp
-Filter=M
-
-[CLS:CAboutDlg]
-Type=0
-HeaderFile=TestCBot.cpp
-ImplementationFile=TestCBot.cpp
-Filter=D
-
-[DLG:IDD_ABOUTBOX]
-Type=1
-ControlCount=4
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308352
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-Class=CAboutDlg
-
-[MNU:IDR_MAINFRAME]
-Type=1
-Class=CMainFrame
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-Command3=ID_FILE_MRU_FILE1
-
-[TB:IDR_MAINFRAME]
-Type=1
-Class=CMainFrame
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-CommandCount=8
-Command8=ID_APP_ABOUT
-
-[MNU:IDR_TESTCBTYPE]
-Type=1
-Class=CTestCBotView
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-CommandCount=18
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-
-[ACL:IDR_MAINFRAME]
-Type=1
-Class=CMainFrame
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command5=ID_EDIT_CUT
-Command6=ID_EDIT_COPY
-Command7=ID_EDIT_PASTE
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_NEXT_PANE
-CommandCount=13
-Command4=ID_EDIT_UNDO
-Command13=ID_PREV_PANE
-
-
-[TB:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-Command8=ID_RUN
-Command9=ID_APP_ABOUT
-CommandCount=9
-
-[MNU:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_MRU_FILE1
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-
-[MNU:IDR_TESTCBTYPE (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-CommandCount=18
-
-[ACL:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_EDIT_COPY
-Command2=ID_FILE_NEW
-Command3=ID_FILE_OPEN
-Command4=ID_FILE_SAVE
-Command5=ID_EDIT_PASTE
-Command6=ID_EDIT_UNDO
-Command7=ID_EDIT_CUT
-Command8=ID_RUN
-Command9=ID_NEXT_PANE
-Command10=ID_PREV_PANE
-Command11=ID_RUN
-Command12=ID_EDIT_COPY
-Command13=ID_EDIT_PASTE
-Command14=ID_EDIT_CUT
-Command15=ID_EDIT_UNDO
-CommandCount=15
-
-[DLG:IDD_ABOUTBOX (French (France))]
-Type=1
-Class=CAboutDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308480
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-
-[DLG:IDD_CONSOLE]
-Type=1
-Class=CBotConsoleDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT2,edit,1350631552
-Control3=IDOK,button,1342242817
-Control4=IDC_EDIT1,edit,1352734724
-
-[CLS:CBotConsoleDlg]
-Type=0
-HeaderFile=CBotConsoleDlg.h
-ImplementationFile=CBotConsoleDlg.cpp
-BaseClass=CDialog
-Filter=D
-VirtualFilter=dWC
-
diff --git a/src/CBot/tests/scenarios/B.txt b/src/CBot/tests/scenarios/B.txt
deleted file mode 100644
index 53715f8..0000000
--- a/src/CBot/tests/scenarios/B.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-
- float [ ] TEST2 ( int [ ] param )
- {
- float [ ] z;
- for ( int i = 0 ; i < sizeof( param ) ; i++ ) try { z [i] = param [i] / 3; }
- return z;
- }
-
-extern public void T()
-{
- int a [4];
- for ( int i = 0 ; i < 3 ; i++ ) a[i] = 4*i;
- a [2] = 22;
-
- float [] b ;
- b = TEST2 ( a ) ;
- show ( a, b );
-}
diff --git a/src/CBot/tests/scenarios/BUG2.txt b/src/CBot/tests/scenarios/BUG2.txt
deleted file mode 100644
index 44de05a..0000000
--- a/src/CBot/tests/scenarios/BUG2.txt
+++ /dev/null
@@ -1,107 +0,0 @@
-object object :: TT ( int n )
-{
- object XX = radar();
- if ( n == 0 ) return null;
-
- while ( null == XX ) XX = radar();
- return XX;
-}
-
-extern void object::Attack( )
-{
- show ( TT ( 0 ) ) ;
- show ( TT ( 1 ) ) ;
- return;
-
- int list[];
- int i;
- object p;
- float dist, prox;
- point dest;
- boolean advance = true;
-
- TEST(0); // ne stoppe pas si erreur
-// while ( F () != 0 ) F(1);
-
- i = 0;
- list[i++] = WingedGrabber;
- list[i++] = TrackedGrabber;
- list[i++] = WheeledGrabber;
- list[i++] = LeggedGrabber;
- list[i++] = WingedShooter;
- list[i++] = TrackedShooter;
- list[i++] = WheeledShooter;
- list[i++] = LeggedShooter;
- list[i++] = WingedOrgaShooter;
- list[i++] = TrackedOrgaShooter;
- list[i++] = WheeledOrgaShooter;
- list[i++] = LeggedOrgaShooter;
- list[i++] = WingedSniffer;
- list[i++] = TrackedSniffer;
- list[i++] = WheeledSniffer;
- list[i++] = LeggedSniffer;
- list[i++] = Thumper;
- list[i++] = PhazerShooter;
- list[i++] = Recycler;
- list[i++] = Shielder;
- list[i++] = Subber;
- list[i++] = Me;
- list[i++] = 3333;
- list[i++] = 3334;
- list[i++] = 3335;
- list[i++] = 3336;
- list[i++] = 3337;
- list[i++] = 3338;
- list[i++] = 3339;
- list[i++] = 3331;
- list[i++] = 3332;
- list[i++] = 3330;
- list[i++] = 1111;
- list[i++] = 1112;
-
- F(F(0));
-
- while ( true )
- {
- p = radar(list, 0, 360, 0, 1000);
- if ( p == null )
- {
- F(2);
- }
- else
- {
- dist = F(p.position, position);
- if ( dist <= 40 && !advance )
- {
- fire(p.position);
- advance = true;
- }
- else
- {
-//? if ( RetBaseDistance() > 20 )
- {
- prox = dist-(5+F()*5);
- if ( prox < 5 ) prox = 5;
- dest.x = (position.x-p.position.x)*prox/dist + p.position.x;
- dest.y = (position.y-p.position.y)*prox/dist + p.position.y;
- dest.z = (position.z-p.position.z)*prox/dist + p.position.z;
- goto(dest);
- advance = false;
- }
- }
- }
- }
-}
-
-// Calcule la distance jusqu'à la base.
-
-float object::RetBaseDistance()
-{
- object p;
- float dist;
-
- p = radar(4444, 0, 360, 0, 1000);
- if ( p == null ) return 1000;
- dist = F(p.position, position);
- return dist;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/Deleted.txt b/src/CBot/tests/scenarios/Deleted.txt
deleted file mode 100644
index 469a624..0000000
--- a/src/CBot/tests/scenarios/Deleted.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-public extern void object :: ESSAI()
-{
- while(true)
- {
- if ( true )
- {
- goto(12);
- break;
- }
- }
- object x = null ;
-
- while ( x == null ) x = radar();
-
- show ( x.position ) ;
-
- TEST(5, x);
-
- if ( x == null ) show ( "DELETED" );
-
- show ( x.position ) ;
-
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/MaClass.txt b/src/CBot/tests/scenarios/MaClass.txt
deleted file mode 100644
index ac472b4..0000000
--- a/src/CBot/tests/scenarios/MaClass.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-
-class MaClass
-{
- int a = 1 ;
- MaClass pointeur ;
- MaClass next = null ;
- CPoint autre = new CPoint( 1 , 1 ) ;
-}
-
-extern public void Test ( )
-{
- MaClass x () ;
- x.next = new MaClass ( ) ;
- println ( x ) ;
-}
-
diff --git a/src/CBot/tests/scenarios/Mc2.txt b/src/CBot/tests/scenarios/Mc2.txt
deleted file mode 100644
index 172c259..0000000
--- a/src/CBot/tests/scenarios/Mc2.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-class MaClass
-{
- int t = 12;
-}
diff --git a/src/CBot/tests/scenarios/Mon fichier.txt b/src/CBot/tests/scenarios/Mon fichier.txt
deleted file mode 100644
index 6b35bf8..0000000
--- a/src/CBot/tests/scenarios/Mon fichier.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Voici encore du texte
-et une seconde ligne
diff --git a/src/CBot/tests/scenarios/Nop.txt b/src/CBot/tests/scenarios/Nop.txt
deleted file mode 100644
index 6a66f6f..0000000
--- a/src/CBot/tests/scenarios/Nop.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-public extern void Nop()
-{
- while ( true ) {}
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/POS.txt b/src/CBot/tests/scenarios/POS.txt
deleted file mode 100644
index 688e4fb..0000000
--- a/src/CBot/tests/scenarios/POS.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-void object :: T ( )
-{
- show ( position ) ;
-}
-
-public extern void object :: POS()
-{
- for ( int i = 0; i < 10 ; i++ )
- {
- if ( i == 2 ) TEST ( 12 ) ;
-// show ( position );
- T ( ) ;
- }
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/T.txt b/src/CBot/tests/scenarios/T.txt
deleted file mode 100644
index 50a792b..0000000
--- a/src/CBot/tests/scenarios/T.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-public extern int T ( float n )
-{
- return n * 1.1;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/TESTALL.txt b/src/CBot/tests/scenarios/TESTALL.txt
deleted file mode 100644
index 82247a0..0000000
--- a/src/CBot/tests/scenarios/TESTALL.txt
+++ /dev/null
@@ -1,161 +0,0 @@
-int T ( int z )
-{
- return 45 + z ;
-}
-
-class toto
-{
- int val = 3 ;
- int x = 3 * 3 ;
- void toto( int n )
- { val = n + 3 ; }
- int retval ( int param )
- { int r = val + param + x ;
- val = param ;
- return r ; }
-}
-
-public extern void object :: Chose( )
-{
- int z [ 6 ];
- for ( int i = 0 ; i < 6 ; ) z [ i++ ] = 3 - i ;
- show ( z ) ;
- return;
-
- // test des tableaux
- int [ ] a [ 3 ] ;
-// a = null;
- if ( a == null ) show ( "NULL" );
-
- a [ 2 / 2 ] [ 2 ]= 5 ;
- int [ ] b ; b = a [1] ;
- b [ 0 ] = -4;
- a [ 4 / 2 ] [ 1 ]= 1 ;
- show ( a , b ) ;
- return ;
- {
- toto chose = new toto (5 ) ;
- toto truc = chose ;
- show ( chose, chose.retval( 100 ) ,
- truc, truc.retval (40 ) ) ;
-
- return;
- }
- {
- point A = new
- point ( 4 * 4 , 2 ) ;
- show ( A ) ;
- return;
- }
- {
- show ( T ( 1 ) , T ( 3.7 ) ) ;
- return;
- }
-
- {
- point A ( 3, 4 ) ,
- B = A ;
-
- int n = -4;
- show ( n );
-
- show ( A, B ) ;
-
- boolean a = false;
- boolean b = a or true;
- if ( not a and b ) ;
- return;
- }
- {
- // test try
- float x = nan ; int z = 0 ;
- try {
-// throw ( 3 * 4 + 33 ) ;
- int zz ; goto ( 12 ) ; z = 1 ; z = 0 / 0 ; z = 2 ;
- }
- catch ( 45 + 0 * 6000 )
- {
- show( "Exception 6000", z ) ;
- }
- catch ( x == 0 ) { show( "x nul" ) ; }
- finally { show ( "fini" ) ; }
- show ( "continue" );
- return;
- }
- {
- // test des if
- int a = 3;
- if ( a == 3 ) show ( "33");
- else show ( "44");
- if ( a != 3 ) show ( "333");
- else show ( "444");
- return;
- }
- {
- int a = 0;
- // test break
-un:
- while ( true )
- {
-deux:
- while ( true )
- {
- a++;
- if ( a == 2 ) continue;
- if ( a == 3 ) break deux;
- show ( a ) ;
- if ( a == 5 ) break un;
- }
- show ( "DEUX" );
- }
- return;
- }
- {
- // test switch
- int a = 0;
-
- switch ( a )
- {
- case 1 : show( "un" ) ; break;
- case 2 : show( "deux" ) ; // break;
- case 3 : show( "trois" ) ; break;
- case 4 : show( "quatre" ) ; // break;
- default : show( "par défaut" ) ;
- }
- return;
- }
- {
- // test boucle while
- float z = 3.3;
- while ( z > 0 )
- { show ( z-- ) ; }
- return;
- }
-
- {
- // test boucle do
- float y = 3.3;
- do { int x = 0; show(y); y++; } while ( y < 7 ) ;
- return;
- }
- // test boucle for
- int j = -7; show ( j );
- for ( int ii = 3, j = 31; ii < 6 ; ++ii, j = j -3 )
- {
- j = 10 * j;
- show ( ii, j );
- }
- return;
-{
- // déclarations de variables
- int a; int b = 3; int c = 4*b, d = 1, e;
- float x; float y = 3.3; float z = y / 2, u = 1, v;
- boolean t; boolean tt = true or false; boolean ttt = false, tttt = true, t5;
- string s; string ss = "hello"; string s2 = ss + " plus", s3 = "s3", s4;
-
- show( b, c, d );
- show( y, z, u );
- show( tt, ttt, tttt );
- show( ss, s2, s3 );
-}
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/TestCB1.txt b/src/CBot/tests/scenarios/TestCB1.txt
deleted file mode 100644
index 516db47..0000000
--- a/src/CBot/tests/scenarios/TestCB1.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-extern public void toto()
-{
- print( "hello" ) ;
- print( fac(5) );
- print( t() ) ;
-}
-
-public int fac(int n)
-{
- if ( n<2 ) return 1;
- return n * fac(n-1);
-}
-
-point t()
-{
- point a(1,2);
- return a;
-}
diff --git a/src/CBot/tests/scenarios/TestCBot1.txt b/src/CBot/tests/scenarios/TestCBot1.txt
deleted file mode 100644
index d27b4f8..0000000
--- a/src/CBot/tests/scenarios/TestCBot1.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-
-class CPoint2
-{
- float x, y;
- void CPoint2(float x, float y)
- {
- this.x = x;
- this.y = y;
- }
-}
-
-public extern void T ( )
-{
- CPoint2 X( 12, 33 ), Y ( -4, 4/3 );
- print ( X, Y ) ;
-}
-
-public extern void Hello ( )
-
-{
- println ( "Hello" );
-}
-
-public extern void test ( int n )
-{
- for ( int i = n; i>0 ; i--) print (i);
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/TestCBot3.txt b/src/CBot/tests/scenarios/TestCBot3.txt
deleted file mode 100644
index b915f96..0000000
--- a/src/CBot/tests/scenarios/TestCBot3.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-public extern void Test ()
-{
- for ( int x = 100000; x>0 ; x-- ) { }
-}
-
-float MaRoutine( CPoint A, CPoint B )
-{
- A.x -= B.x ; // distance en x
- A.y -= B.y ; // distance en y
- A.x *= A.x; // carré de la distance
- A.y += A.y; // carré de la distance
- println ( A, B ) ;
- return ( A.x + A.y ) ;
-}
-
-public extern void TestAB ( )
-{
- CPoint A(3, 5) ;
- CPoint B(4, -2);
- println ( A, B ) ;
- MaRoutine( A, B ) ;
- println ( A, B ) ;
-}
-
diff --git a/src/CBot/tests/scenarios/TestNull.txt b/src/CBot/tests/scenarios/TestNull.txt
deleted file mode 100644
index f447245..0000000
--- a/src/CBot/tests/scenarios/TestNull.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-extern public void TestNull ()
-{
- CPoint pointeur = null;
-
- try {
- pointeur.x = 4; }
- catch ( 6007 ) {}
-
- pointeur = new CPoint(1,2);
-
- print ( pointeur.x, pointeur.y,
- pointeur );
-
- pointeur.x = 5;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/TestRestoreState.txt b/src/CBot/tests/scenarios/TestRestoreState.txt
deleted file mode 100644
index 1e49e37..0000000
--- a/src/CBot/tests/scenarios/TestRestoreState.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-// routine de Daniel qui plante après RestoreState
-
-extern void object::Attack( )
-{
- int list[], i;
- object p;
- float dist, prox;
- point nav1, nav2, dest;
- boolean advance = true;
-
- i = 0;
- list[i++] = WingedGrabber;
- list[i++] = TrackedGrabber;
- list[i++] = WheeledGrabber;
- list[i++] = LeggedGrabber;
- list[i++] = WingedShooter;
- list[i++] = TrackedShooter;
- list[i++] = WheeledShooter;
- list[i++] = LeggedShooter;
- list[i++] = WingedOrgaShooter;
- list[i++] = TrackedOrgaShooter;
- list[i++] = WheeledOrgaShooter;
- list[i++] = LeggedOrgaShooter;
- list[i++] = WingedSniffer;
- list[i++] = TrackedSniffer;
- list[i++] = WheeledSniffer;
- list[i++] = LeggedSniffer;
- list[i++] = Thumper;
- list[i++] = PhazerShooter;
- list[i++] = Recycler;
- list[i++] = Shielder;
- list[i++] = Subber;
- list[i++] = Me;
-
- nav1.x = 1;//cmdline(0);
- nav1.y = 1;//cmdline(1);
- nav2.x = 2;//cmdline(2);
- nav2.y = 2;//cmdline(3);
-
- while ( true )
- {
- while ( true )
- {
- // ennemi à proximité ?
- p = radar(list, 0, 360, 0, 40);
- if ( p == null ) break;
- // lui tire dessus
- fire(p.position);
- }
-
- // se promène vers le point A
- goto(nav1);
-
- while ( true )
- {
- // ennemi à proximité ?
- p = radar(list, 0, 360, 0, 40);
- if ( p == null ) break;
- // lui tire dessus
- fire(p.position);
- }
-
- // se promène vers le point B
- goto(nav2);
- }
-}
-
diff --git a/src/CBot/tests/scenarios/TestStatic.txt b/src/CBot/tests/scenarios/TestStatic.txt
deleted file mode 100644
index f501aa5..0000000
--- a/src/CBot/tests/scenarios/TestStatic.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-class ESSAI
-{
- int x = 0;
- static int nb = 3;
- static int [ ] array ;
-
- void Put( int val)
- {
-show(nb);
- array[ nb ] = val;
-// this.nb++;
- this.nb = this.nb + 1;
-show(nb, array);
- }
- int Get( )
- {
- nb--;
-show("out", nb, array);
- return array[ nb ] ;
- }
-}
-
-extern public void T()
-{
- ESSAI t1 ( ) ;
- ESSAI t2 ( ) ;
- t1.nb++;
- t1.Put( 11 ); t1.Put( 12 ); t2.Put( 13 );
-
- show ( t1.Get(), t2.Get(), t2.Get() ) ;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/TestStr.txt b/src/CBot/tests/scenarios/TestStr.txt
deleted file mode 100644
index 683ec1b..0000000
--- a/src/CBot/tests/scenarios/TestStr.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-extern public void TSTR()
-{
- string s = "C'est un essai";
-
- print ( s, strlen(s), strleft(s, 3), strright(s,3), strmid(s, 2), strmid(s,2,3), strfind(s, "un"), strfind(s, "sdgfld") );
-
- show ( strupper(s), strlower(s) );
-
- s = "123.45" ;
- print ( strval(s) );
-
-
- string sub = strright("abcdef", 2); // sub vaut "ef###", # étant un caractère bizarre quelconque
- show (sub);
- int pos = strfind("abcdef", "xy"); // pos vaut -1. Pourquoi pas nan ?
- show(pos);
-}
diff --git a/src/CBot/tests/scenarios/Z.txt b/src/CBot/tests/scenarios/Z.txt
deleted file mode 100644
index 714119b..0000000
--- a/src/CBot/tests/scenarios/Z.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-public extern void tp()
-{
- int a [4], b[];
- a [ 0 ] = 8 ;
-
- b = T ( a ) ;
- show ( a, b );
-}
-
-int[] T ( int[] Z )
-{
- for ( int i = 0; i < 4 ; i++ ) Z[ i ] = i * i ;
- return Z;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/a1.txt b/src/CBot/tests/scenarios/a1.txt
deleted file mode 100644
index 165bc95..0000000
--- a/src/CBot/tests/scenarios/a1.txt
+++ /dev/null
@@ -1,96 +0,0 @@
-object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/scenarios/array.txt b/src/CBot/tests/scenarios/array.txt
deleted file mode 100644
index 081b60e..0000000
--- a/src/CBot/tests/scenarios/array.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-
-public extern void TestTableau ()
-{
- int tableau [ 12 ] ;
-
- point array[ 12 ] [ 14 ] ;
-
- point zéro ( 1, 2 ) ;
- point a = zéro ;
-
- for ( int i = 0 ; i < 10 ; i++ ) array[ i ] [ i ]= zéro ;
-
- array[ 5 ] [3 ] . x =1.5 ;
-
- array[ 2 ] [ 2 ] . y = array[ 5 ] [ 5 ] . x ;
-
- array[ 4 ] = array [ 2 ] ;
-
- for ( int i = 0 ; i < 10 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) println ( i, j, array [ i ] [ j ] ) ;
-
- show( zéro, a, array );
-
-}
-
diff --git a/src/CBot/tests/scenarios/až1.txt b/src/CBot/tests/scenarios/až1.txt
deleted file mode 100644
index 165bc95..0000000
--- a/src/CBot/tests/scenarios/až1.txt
+++ /dev/null
@@ -1,96 +0,0 @@
-object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/scenarios/a§1.txt b/src/CBot/tests/scenarios/a§1.txt
deleted file mode 100644
index 0c57950..0000000
--- a/src/CBot/tests/scenarios/a§1.txt
+++ /dev/null
@@ -1,96 +0,0 @@
-object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/scenarios/bug.txt b/src/CBot/tests/scenarios/bug.txt
deleted file mode 100644
index 4ec6eb3..0000000
--- a/src/CBot/tests/scenarios/bug.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-public extern void object::Bug()
-{
- point a;
- a = position;
- TEST();
- float d=dist(a, position);
-}
-
-float dist(point a, point b)
-{
- return a.x-b.x;
-}
diff --git a/src/CBot/tests/scenarios/bugmw.txt b/src/CBot/tests/scenarios/bugmw.txt
deleted file mode 100644
index 284ee43..0000000
--- a/src/CBot/tests/scenarios/bugmw.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-extern public void main()
-{
- show(fact(30)) ;
-}
-
-public int fact(int n)
-{
- return (fact(n-1)*n) ;
-}
diff --git a/src/CBot/tests/scenarios/ccc.txt b/src/CBot/tests/scenarios/ccc.txt
deleted file mode 100644
index dbcd1d5..0000000
--- a/src/CBot/tests/scenarios/ccc.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-public extern void ccc()
-{
- int a;
- a = 0 ;
-
- if ( a == 0 );
-
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/enum.txt b/src/CBot/tests/scenarios/enum.txt
deleted file mode 100644
index a592a7f..0000000
--- a/src/CBot/tests/scenarios/enum.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-
-enum JourDeLaSemaine {
- lundi = 1,
- mardi,
- mercredi,
- jeudi,
- vendredi,
- samedi,
- dimanche = 0 } \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/fibo.txt b/src/CBot/tests/scenarios/fibo.txt
deleted file mode 100644
index 88f5357..0000000
--- a/src/CBot/tests/scenarios/fibo.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-
-extern public int Fibo( int n, boolean b )
-{
- if ( n < 2 ) return n;
- int a = Fibo(n-1, b) + Fibo(n-2, false);
- if ( b ) print (n + "=" + a);
- return a;
-}
-
-extern public void t()
-{
- Fibo( 23, true);
-}
-
-extern public void tt()
-{
- t();
-}
-
-// cette routine n'est évidemment pas du tout obtimisée
-// c'est même un très mauvais exemple de programmation récursive
-
-// pour un test de durée, Fibo(23, true) prend
-// en mode Debug 67 secondes
-// en mode Release 8 secondes
diff --git a/src/CBot/tests/scenarios/file.txt b/src/CBot/tests/scenarios/file.txt
deleted file mode 100644
index 2a22dd9..0000000
--- a/src/CBot/tests/scenarios/file.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-class CLASS22
-{
- static int nb = 2;
- void T22 ( ) { nb = nb / 0 ; }
-}
-
-public extern void object :: TEST()
-{
- switch ( 1 )
- {
- case 1:
- {
- file h();
- h.open("Mon Fichier.txt", "r");
-show ( h.filename, h.handle );
-h.filename = "xx";
-h.handle = 1 ;
- h.readln();
- h.close();
- }
- case 2:
- {
- file h("Mon Fichier.txt");
- h.open("r");
- h.readln();
- h.close();
- }
- case 3:
- {
- file h("Mon Fichier.txt", "r");
- h.readln();
- h.close();
- }
- case 4:
- {
- file h();
- h.filename = "Mon Fichier.txt";
- h.open("r");
- h.readln();
- h.close();
- }
- case 5:
- {
- file h = fileopen( "Mon 2Fichier.txt", "r" );
- h.readln();
- h.close();
- }
- }
-{
- file h( ) ;
- h.filename = "Test.h";
- h.open ( "r" );
-
-
- file pf ( "Mon Fichier.txt" ) ;
- pf . open ( "w" ) ;
- pf . writeln ( "Voici encore du texte" ) ;
- pf . writeln ( "et une seconde ligne" ) ;
- pf . close( );
-
- pf . open ( "r" ) ;
-
- while ( not pf . eof( ) )
- {
- string s = pf . readln ( );
- show ( s );
- }
- pf.close( );
-}
-}
diff --git a/src/CBot/tests/scenarios/h.txt b/src/CBot/tests/scenarios/h.txt
deleted file mode 100644
index c395319..0000000
--- a/src/CBot/tests/scenarios/h.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-void tf()
-{
- file h;
- h.handle += 1 ;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/include.txt b/src/CBot/tests/scenarios/include.txt
deleted file mode 100644
index e8f8cc9..0000000
--- a/src/CBot/tests/scenarios/include.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-class Z
-{
- static int x = 0;
- private int y;
-
- void T( )
- {
- // autorisé ici
- y = x ;
- this.y = this.x ;
- x = y ;
- this.x = this.y ;
- }
-}
-
-extern public void test()
-{
- Z a();
- 3 * a.x; // autorisé
-//vu 3 * a.y; // interdit
-//vu a.y = 3; // interdit ici
- a.x = 1; // autorisé
-
- show ( a );
- a.T();
- show ( a );
-}
diff --git a/src/CBot/tests/scenarios/intrinsic.txt b/src/CBot/tests/scenarios/intrinsic.txt
deleted file mode 100644
index f215791..0000000
--- a/src/CBot/tests/scenarios/intrinsic.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-public extern void TestIntrinsic()
-{
- point a ( 1, 2 );
- print (a);
-
- a.x = 3;
- a.y = 4;
-
- point b = a;
-
- println ( b.x, b.y, b ) ;
- if ( b == a ) b.y = 0;
- println (a,b);
- if ( b != a ) b.y = a.y;
- println(a,b);
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/methode1.txt b/src/CBot/tests/scenarios/methode1.txt
deleted file mode 100644
index 080bba2..0000000
--- a/src/CBot/tests/scenarios/methode1.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-class t {
- point p;
-}
-
-void object :: toto()
-{
- show ( Position ) ;
-}
-
-extern public void object :: XX()
-{
- int test [];
- test [ 9999 ] = 3;
-
- toto () ;
-/*
- Radar();
-
- object test ;
- test = this. Radar();
-
- do {
- test = this.Radar();
- } while ( test == null );
-
-/*
- t test [ 4 ];
- for ( int i = 0 ; i < 4 ; i++ ) test [ i ] = new t();
- test [ 3 ] .p.x = 2;
- show ( test );
-/*
- int a = nan;
- show ( a ) ;
-
- a = TypeMarkPath;
- show ( a, a++, --a ) ;
-
- if ( a != nan ) a += 1 ;
-
- a = TypeMarkPath;
- float q = a ;
- show ( a, q ) ;
-
-return;
-
- a += ++a;
- show ( a ) ;
-
- boolean i = false;
-
- if ( i == true ) {}
-
- object p;
- if ( p == null) { p = p ; }
-*/
-}
-
diff --git a/src/CBot/tests/scenarios/methode2.txt b/src/CBot/tests/scenarios/methode2.txt
deleted file mode 100644
index 76ce7f4..0000000
--- a/src/CBot/tests/scenarios/methode2.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-
-extern void Toto()
-{
- TEST(12);
-
- for ( int i = 0 ; i<1000; i++)
- {
- int j = 1;
- if (i==55) TEST(12);
- }
-
- TEST(2);
-
-
-// Nouveau();
- int toto[4];
- point Z[3];
-
- Z[1].x = 11; Z[1].y = 12;
-
- toto[2] = 12;
- toto[1] = nan;
-
-// point test, autre(2,3) ;
-// object titi = Radar();
-
- TEST ( 1 ) ;
-
- toto[0] = 11;
-
- TEST ( 2 ) ;
-
- toto[6] = 0;
-}
-
-extern void object::Nouveau()
-{
- point a;
- a = np(Position);
-}
-
-point np(point b)
-{
- point c;
- c.x = b.y;
- c.y = b.x;
- return c ;
-}
-
-
diff --git a/src/CBot/tests/scenarios/mp1.txt b/src/CBot/tests/scenarios/mp1.txt
deleted file mode 100644
index 599cfc4..0000000
--- a/src/CBot/tests/scenarios/mp1.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-class Guepet
-{
-
- float a;
- float b;
-
- void init()
- {
- a = 12.34;
- b = 56.78;
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe =new Guepet();
-
- guepe.init();
-
-
- show("test "+guepe.a+" "+guepe.b);
-
-}
diff --git a/src/CBot/tests/scenarios/mp2.txt b/src/CBot/tests/scenarios/mp2.txt
deleted file mode 100644
index 1c2972c..0000000
--- a/src/CBot/tests/scenarios/mp2.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-class Guepet
-{
-
- float a;
- float b;
-
- void init()
- {
- a = 12.34;
- b = 56.78;
-
- object x = radar(123);
- show("radar "+x.position.x);
- show("C'est fait");
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe=new Guepet();
-
- guepe.init();
-
- show("test "+guepe.a+" "+guepe.b);
-
-}
diff --git a/src/CBot/tests/scenarios/mw.txt b/src/CBot/tests/scenarios/mw.txt
deleted file mode 100644
index c237670..0000000
--- a/src/CBot/tests/scenarios/mw.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-extern public void main()
-{
-// goto( 3, 4 );
-
- while( true )
- {
- try { goto (12) ; }
- catch( FF( ) )
- { show( "ko"); }
- }
-}
-
-boolean FF()
-{
- return false;
-}
diff --git a/src/CBot/tests/scenarios/null.txt b/src/CBot/tests/scenarios/null.txt
deleted file mode 100644
index ae76b74..0000000
--- a/src/CBot/tests/scenarios/null.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-extern public void xxx ()
-{
- CPoint test = null ;
- if ( test == null ) show ( "NULL" );
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/opnew.txt b/src/CBot/tests/scenarios/opnew.txt
deleted file mode 100644
index 7d6838c..0000000
--- a/src/CBot/tests/scenarios/opnew.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-extern public void xx ()
-{
- CPoint pointeur, test = null ;
- pointeur = new CPoint ( 3, 4 );
-
- if ( test == null ) show ( "NULL" );
-
- CPoint pp = pointeur;
-
-show( pointeur , pp );
-
- pp.x = 33.3;
- if ( pointeur.x != pp.x ) 0/0;
-
- pp = new CPoint();
-// pointeur = pp;
-
-show( pointeur , pp );
-
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/plante.txt b/src/CBot/tests/scenarios/plante.txt
deleted file mode 100644
index 363461b..0000000
--- a/src/CBot/tests/scenarios/plante.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-class Guepet
-{
-
- point pos;
- float t = 0.1;
-
- void init()
- {
- pos.x = 12.123;
- pos.y = 34.345;
-
- F(t);
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe=new Guepet();
-
- guepe.init();
-
- show ( guepe );
-}
diff --git a/src/CBot/tests/scenarios/pointer.txt b/src/CBot/tests/scenarios/pointer.txt
deleted file mode 100644
index 2d4d907..0000000
--- a/src/CBot/tests/scenarios/pointer.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-extern public void x ()
-{
- show ( 3 ** 4 );
- float z = 1e-3;
- show ( z );
-
- CPoint b ( 4,5 );
- show ( b );
-
- CPoint a ( ) ;
- a.x = 21; a.y = 12;
- show ( a ) ;
-
- CPoint test = new CPoint ( 1,1 );
- test = new CPoint ( 2, 2 );
- show ( test );
-}
-
-// crée un objet et retourne son pointeur
-CPoint newcpoint()
-{
- CPoint p = new CPoint ( 3, 3 );
- return p;
-}
-
-extern public void y ()
-{
- CPoint test = newcpoint();
- println ( test );
- dontmodif( test );
- println ( test );
-}
-
-// ne doit pas modifier l'objet en paramètre
-void dontmodif ( CPoint pp )
-{
- pp.x = 5;
- pp.y = 2;
- println ( pp, pp.x, pp.y );
-}
-
diff --git a/src/CBot/tests/scenarios/postinc.txt b/src/CBot/tests/scenarios/postinc.txt
deleted file mode 100644
index cdf6ab5..0000000
--- a/src/CBot/tests/scenarios/postinc.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-extern public void X()
-{
- point A [ ] ;
- A[5] = new point (2,3);
- int val = A[5].x++ + --A[5].y;
- show ( A, val );
-}
diff --git a/src/CBot/tests/scenarios/radar.txt b/src/CBot/tests/scenarios/radar.txt
deleted file mode 100644
index 09d84a2..0000000
--- a/src/CBot/tests/scenarios/radar.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-extern void object::Bug( )
-{
- try{ int a = 44 ; a = 12 / 0 ; }
- catch(6000) { int b = 4 ; }
- finally { int z = 1 ; }
-
-// tp ( A, B );
-
-/* int a = 4, b = 2, c = nan;
- float x, y = 3/2, z = nan;
- boolean i, j = false, k = true;
-
- string s, ss = "xyz";
-
- while ( false )
- {
- object left, right;
-
- left = Radar(TypeMarkPath, -45, 120, 100);
- right = Radar(TypeMarkPath, 45, 120, 100);
-
- if ( left == null && right == null )
- {
- }
- }
- int t = fact ( 4 ) ;*/
-}
-
-void tp( point a , point b )
-{
- a.x += b.x;
-}
-
-
-int fact( int n )
-{
- if ( n < 2 ) return n;
- return n * fact ( n - 1 ) ;
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/solution.txt b/src/CBot/tests/scenarios/solution.txt
deleted file mode 100644
index f78cf12..0000000
--- a/src/CBot/tests/scenarios/solution.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-extern void object::Solution( )
-{
-show ( "Solution " + Position );
- Carré(15);
- Carré(25);
-}
-
-void object::Carré(float côté)
-{
-show ( "Carré " + Position );
- Move(côté);
- Turn(-90);
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/test.txt b/src/CBot/tests/scenarios/test.txt
deleted file mode 100644
index 0693994..0000000
--- a/src/CBot/tests/scenarios/test.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-extern public void x()
-{
- float a= 1, b = 2;
- a = b * ( 2 + 2 );
- print (a);
- a += 4;
- print (a);
-}
diff --git a/src/CBot/tests/scenarios/test23.txt b/src/CBot/tests/scenarios/test23.txt
deleted file mode 100644
index d6e1ddd..0000000
--- a/src/CBot/tests/scenarios/test23.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-extern public void object::TEST23()
-{
- CLASS22 T;
- T.T22( ) ;
-
- show( position );
- show( this.position );
-
-// T22();
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/testmw.txt b/src/CBot/tests/scenarios/testmw.txt
deleted file mode 100644
index 6570f6d..0000000
--- a/src/CBot/tests/scenarios/testmw.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-extern public int testmw( int a)
-{
- boolean b = true ;
-
- if (b)
- return 1 ;
- else
- return a ; 0 * testmw(a-1) ;
-}
-
-public int Fibo2 ( int n )
-{
- print ( " bof " );
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/this.txt b/src/CBot/tests/scenarios/this.txt
deleted file mode 100644
index b8a9e04..0000000
--- a/src/CBot/tests/scenarios/this.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-extern void object :: TEST22 ( )
-{
- show( position );
- show( this.position );
-
- T();
-}
-
-public void object :: T22()
-{
- show( position );
- show( this.position );
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/tt.txt b/src/CBot/tests/scenarios/tt.txt
deleted file mode 100644
index cd13c9d..0000000
--- a/src/CBot/tests/scenarios/tt.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-extern public void T() { T1(); }
-
-public void T1()
-{
- show( "T1" );
- T2();
-}
-
-public void T2()
-{
- show( "T2" );
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/tt2.txt b/src/CBot/tests/scenarios/tt2.txt
deleted file mode 100644
index ad9dc1d..0000000
--- a/src/CBot/tests/scenarios/tt2.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-extern public void TT()
-{
- T1();
- T2();
-} \ No newline at end of file
diff --git a/src/CBot/tests/scenarios/vide.txt b/src/CBot/tests/scenarios/vide.txt
deleted file mode 100644
index e69de29..0000000
--- a/src/CBot/tests/scenarios/vide.txt
+++ /dev/null
diff --git a/src/CBot/tests/scenarios/zz.txt b/src/CBot/tests/scenarios/zz.txt
deleted file mode 100644
index da764ac..0000000
--- a/src/CBot/tests/scenarios/zz.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-extern public void zz()
-{
- MaClass TOTO ();
-
- show (TOTO);
-} \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 74de412..de60ef3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,50 +1,32 @@
-# CBot library is built separately
+# Compile flags as defined in global CMakeLists
+set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS} ${MXE_CFLAGS}")
+set(CMAKE_CXX_FLAGS_RELEASE ${COLOBOT_CXX_FLAGS_RELEASE})
+set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG})
+
+
+# Subdirectories
+
add_subdirectory(CBot)
-# Tools directory is built separately
add_subdirectory(tools)
add_subdirectory(po)
-add_subdirectory(desktop)
-
-# Tests
-if(${TESTS})
- add_subdirectory(common/test)
- add_subdirectory(graphics/engine/test)
- add_subdirectory(ui/test)
- add_subdirectory(math/test)
+if(${DESKTOP})
+ add_subdirectory(desktop)
endif()
# Optional libraries
set(OPTIONAL_LIBS "")
-set(OPTIONAL_INCLUDE_DIRS "")
-
-if(${USE_GLEW} AND NOT ${MXE})
- set(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${GLEW_LIBRARY})
- set(OPTIONAL_INCLUDE_DIRS ${OPTIONAL_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH})
-endif()
-
-
-# Additional libraries per platform
-set(PLATFORM_LIBS "")
-set(OPENAL_LIBS "")
+set(OPTIONAL_INCLUDES "")
if (${OPENAL_SOUND})
- if (${MXE})
- set(OPENAL_LIBS
- ${CMAKE_FIND_ROOT_PATH}/lib/libOpenAL32.a
- ${CMAKE_FIND_ROOT_PATH}/lib/libalut.a
- )
- else()
- set(OPENAL_LIBS
- openal
- alut
- )
- endif()
+ set(OPTIONAL_LIBS ${OPENAL_LIBRARY})
+ set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR})
endif()
+# Additional libraries per platform
if (${MXE}) # MXE requires special treatment
set(PLATFORM_LIBS ${MXE_LIBS})
elseif (${PLATFORM_WINDOWS})
@@ -63,17 +45,27 @@ set(OPENAL_SRC "")
if (${OPENAL_SOUND})
set(OPENAL_SRC
- sound/oalsound/alsound.cpp
- sound/oalsound/buffer.cpp
- sound/oalsound/channel.cpp
+ sound/oalsound/alsound.cpp
+ sound/oalsound/buffer.cpp
+ sound/oalsound/channel.cpp
)
endif()
+# Platform-dependent implementation of system.h
+if (${PLATFORM_WINDOWS})
+ set(SYSTEM_CPP_MODULE "system_windows.cpp")
+elseif(${PLATFORM_LINUX})
+ set(SYSTEM_CPP_MODULE "system_linux.cpp")
+else()
+ set(SYSTEM_CPP_MODULE "system_other.cpp")
+endif()
+
# Source files
set(SOURCES
app/app.cpp
app/main.cpp
app/system.cpp
+app/${SYSTEM_CPP_MODULE}
common/event.cpp
common/image.cpp
common/iman.cpp
@@ -89,6 +81,7 @@ graphics/engine/engine.cpp
graphics/engine/lightman.cpp
graphics/engine/lightning.cpp
graphics/engine/modelfile.cpp
+graphics/engine/modelmanager.cpp
graphics/engine/particle.cpp
graphics/engine/planet.cpp
graphics/engine/pyro.cpp
@@ -191,28 +184,37 @@ ${OPENAL_SRC}
set(LIBS
+CBot
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
${SDLTTF_LIBRARY}
${OPENGL_LIBRARY}
${PNG_LIBRARIES}
+${GLEW_LIBRARY}
+${Boost_LIBRARIES}
+${LIBSNDFILE_LIBRARY}
${OPTIONAL_LIBS}
${PLATFORM_LIBS}
-${Boost_LIBRARIES}
-CBot
-${OPENAL_LIBS}
)
+# Local
include_directories(
.
..
${CMAKE_CURRENT_BINARY_DIR}
+)
+
+# System
+include_directories(
+SYSTEM
${SDL_INCLUDE_DIR}
${SDLIMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS}
-${OPTIONAL_INCLUDE_DIRS}
+${GLEW_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
+${LIBSNDFILE_INCLUDE_DIR}
+${OPTIONAL_INCLUDE_DIRS}
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 6930920..59a04f4 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -26,18 +26,20 @@
#include "common/image.h"
#include "common/key.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/opengl/gldevice.h"
#include "object/robotmain.h"
#include <boost/filesystem.hpp>
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
+#include <SDL.h>
+#include <SDL_image.h>
#include <stdlib.h>
#include <libintl.h>
#include <unistd.h>
+#include <getopt.h>
#ifdef OPENAL_SOUND
@@ -45,7 +47,7 @@
#endif
-template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
+template<> CApplication* CSingleton<CApplication>::m_instance = nullptr;
//! Static buffer for putenv locale
static char S_LANGUAGE[50] = { 0 };
@@ -93,11 +95,12 @@ CApplication::CApplication()
{
m_private = new ApplicationPrivate();
m_iMan = new CInstanceManager();
- m_eventQueue = new CEventQueue(m_iMan);
+ m_eventQueue = new CEventQueue();
m_profile = new CProfile();
m_engine = nullptr;
m_device = nullptr;
+ m_modelManager = nullptr;
m_robotMain = nullptr;
m_sound = nullptr;
@@ -122,9 +125,15 @@ CApplication::CApplication()
m_absTime = 0.0f;
m_relTime = 0.0f;
- m_baseTimeStamp = CreateTimeStamp();
- m_curTimeStamp = CreateTimeStamp();
- m_lastTimeStamp = CreateTimeStamp();
+ m_baseTimeStamp = GetSystemUtils()->CreateTimeStamp();
+ m_curTimeStamp = GetSystemUtils()->CreateTimeStamp();
+ m_lastTimeStamp = GetSystemUtils()->CreateTimeStamp();
+
+ for (int i = 0; i < PCNT_MAX; ++i)
+ {
+ m_performanceCounters[i][0] = GetSystemUtils()->CreateTimeStamp();
+ m_performanceCounters[i][1] = GetSystemUtils()->CreateTimeStamp();
+ }
m_joystickEnabled = false;
@@ -135,6 +144,7 @@ CApplication::CApplication()
m_trackedKeys = 0;
m_dataPath = COLOBOT_DEFAULT_DATADIR;
+ m_langPath = COLOBOT_I18N_DIR;
m_language = LANGUAGE_ENV;
@@ -168,105 +178,159 @@ CApplication::~CApplication()
delete m_iMan;
m_iMan = nullptr;
- DestroyTimeStamp(m_baseTimeStamp);
- DestroyTimeStamp(m_curTimeStamp);
- DestroyTimeStamp(m_lastTimeStamp);
+ GetSystemUtils()->DestroyTimeStamp(m_baseTimeStamp);
+ GetSystemUtils()->DestroyTimeStamp(m_curTimeStamp);
+ GetSystemUtils()->DestroyTimeStamp(m_lastTimeStamp);
+
+ for (int i = 0; i < PCNT_MAX; ++i)
+ {
+ GetSystemUtils()->DestroyTimeStamp(m_performanceCounters[i][0]);
+ GetSystemUtils()->DestroyTimeStamp(m_performanceCounters[i][1]);
+ }
}
-ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
+CEventQueue* CApplication::GetEventQueue()
{
- bool waitDataDir = false;
- bool waitLogLevel = false;
- bool waitLanguage = false;
+ return m_eventQueue;
+}
- for (int i = 1; i < argc; ++i)
- {
- std::string arg = argv[i];
+CSoundInterface* CApplication::GetSound()
+{
+ return m_sound;
- if (waitDataDir)
- {
- waitDataDir = false;
- m_dataPath = arg;
- GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str());
- continue;
- }
+ for (int i = 0; i < PCNT_MAX; ++i)
+ {
+ GetSystemUtils()->DestroyTimeStamp(m_performanceCounters[i][0]);
+ GetSystemUtils()->DestroyTimeStamp(m_performanceCounters[i][1]);
+ }
+}
- if (waitLogLevel)
+ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
+{
+ enum OptionType
+ {
+ OPT_HELP = 1,
+ OPT_DEBUG,
+ OPT_DATADIR,
+ OPT_LOGLEVEL,
+ OPT_LANGUAGE,
+ OPT_LANGDIR,
+ OPT_VBO
+ };
+
+ option options[] =
+ {
+ { "help", no_argument, nullptr, OPT_HELP },
+ { "debug", no_argument, nullptr, OPT_DEBUG },
+ { "datadir", required_argument, nullptr, OPT_DATADIR },
+ { "loglevel", required_argument, nullptr, OPT_LOGLEVEL },
+ { "language", required_argument, nullptr, OPT_LANGUAGE },
+ { "langdir", required_argument, nullptr, OPT_LANGDIR },
+ { "vbo", required_argument, nullptr, OPT_VBO }
+ };
+
+ opterr = 0;
+
+ int c = 0;
+ int index = -1;
+ while ((c = getopt_long_only(argc, argv, "", options, &index)) != -1)
+ {
+ if (c == '?')
{
- waitLogLevel = false;
- if (arg == "trace")
- GetLogger()->SetLogLevel(LOG_TRACE);
- else if (arg == "debug")
- GetLogger()->SetLogLevel(LOG_DEBUG);
- else if (arg == "info")
- GetLogger()->SetLogLevel(LOG_INFO);
- else if (arg == "warn")
- GetLogger()->SetLogLevel(LOG_WARN);
- else if (arg == "error")
- GetLogger()->SetLogLevel(LOG_ERROR);
- else if (arg == "none")
- GetLogger()->SetLogLevel(LOG_NONE);
+ if (optopt == 0)
+ GetLogger()->Error("Invalid argument: %s\n", argv[optind-1]);
else
- return PARSE_ARGS_FAIL;
- continue;
- }
+ GetLogger()->Error("Expected argument for option: %s\n", argv[optind-1]);
- if (waitLanguage)
- {
- waitLanguage = false;
- if (arg == "en")
- m_language = LANGUAGE_ENGLISH;
- else if (arg == "de")
- m_language = LANGUAGE_GERMAN;
- else if (arg == "fr")
- m_language = LANGUAGE_FRENCH;
- else if (arg == "pl")
- m_language = LANGUAGE_POLISH;
- else
- return PARSE_ARGS_FAIL;
- continue;
+ m_exitCode = 1;
+ return PARSE_ARGS_FAIL;
}
- if (arg == "-debug")
- {
- SetDebugMode(true);
- }
- else if (arg == "-loglevel")
- {
- waitLogLevel = true;
- }
- else if (arg == "-datadir")
- {
- waitDataDir = true;
- }
- else if (arg == "-language")
- {
- waitLanguage = true;
- }
- else if (arg == "-help")
- {
- GetLogger()->Message("\n");
- GetLogger()->Message("Colobot %s (%s)\n",COLOBOT_CODENAME,COLOBOT_VERSION);
- GetLogger()->Message("\n");
- GetLogger()->Message("List of available options:\n");
- GetLogger()->Message(" -help this help\n");
- GetLogger()->Message(" -datadir path set custom data directory path\n");
- GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n");
- GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
- GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
- return PARSE_ARGS_HELP;
- }
- else
+ index = -1;
+
+ switch (c)
{
- m_exitCode = 1;
- return PARSE_ARGS_FAIL;
+ case OPT_HELP:
+ {
+ GetLogger()->Message("\n");
+ GetLogger()->Message("Colobot %s (%s)\n", COLOBOT_CODENAME, COLOBOT_VERSION);
+ GetLogger()->Message("\n");
+ GetLogger()->Message("List of available options:\n");
+ GetLogger()->Message(" -help this help\n");
+ GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n");
+ GetLogger()->Message(" -datadir path set custom data directory path\n");
+ GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
+ GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
+ GetLogger()->Message(" -langdir path set custom language directory path\n");
+ GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n");
+ return PARSE_ARGS_HELP;
+ }
+ case OPT_DEBUG:
+ {
+ SetDebugMode(true);
+ break;
+ }
+ case OPT_DATADIR:
+ {
+ m_dataPath = optarg;
+ GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str());
+ break;
+ }
+ case OPT_LOGLEVEL:
+ {
+ LogLevel logLevel;
+ if (! CLogger::ParseLogLevel(optarg, logLevel))
+ {
+ GetLogger()->Error("Invalid log level: \"%s\"\n", optarg);
+ return PARSE_ARGS_FAIL;
+ }
+
+ GetLogger()->Message("[*****] Log level changed to %s\n", optarg);
+ GetLogger()->SetLogLevel(logLevel);
+ break;
+ }
+ case OPT_LANGUAGE:
+ {
+ Language language;
+ if (! ParseLanguage(optarg, language))
+ {
+ GetLogger()->Error("Invalid language: \"%s\"\n", optarg);
+ return PARSE_ARGS_FAIL;
+ }
+
+ GetLogger()->Info("Using language %s\n", optarg);
+ m_language = language;
+ break;
+ }
+ case OPT_LANGDIR:
+ {
+ m_langPath = optarg;
+ GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str());
+ break;
+ }
+ case OPT_VBO:
+ {
+ std::string vbo;
+ vbo = optarg;
+ if (vbo == "auto")
+ m_deviceConfig.vboMode = Gfx::VBO_MODE_AUTO;
+ else if (vbo == "enable")
+ m_deviceConfig.vboMode = Gfx::VBO_MODE_ENABLE;
+ else if (vbo == "disable")
+ m_deviceConfig.vboMode = Gfx::VBO_MODE_DISABLE;
+ else
+ {
+ GetLogger()->Error("Invalid vbo mode: \"%s\"\n", optarg);
+ return PARSE_ARGS_FAIL;
+ }
+
+ break;
+ }
+ default:
+ assert(false); // should never get here
}
}
- // Args not given?
- if (waitDataDir || waitLogLevel || waitLanguage)
- return PARSE_ARGS_FAIL;
-
return PARSE_ARGS_OK;
}
@@ -307,10 +371,17 @@ bool CApplication::Create()
#endif
m_sound->Create(true);
- if (GetProfile().GetLocalProfileString("Resources", "Sound", path))
+ if (GetProfile().GetLocalProfileString("Resources", "Sound", path)) {
m_sound->CacheAll(path);
- else
+ } else {
m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
+ }
+
+ if (GetProfile().GetLocalProfileString("Resources", "Music", path)) {
+ m_sound->AddMusicFiles(path);
+ } else {
+ m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC));
+ }
}
std::string standardInfoMessage =
@@ -345,20 +416,22 @@ bool CApplication::Create()
m_exitCode = 3;
return false;
}
-
+
// load settings from profile
int iValue;
- if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) {
- std::vector<Math::IntPoint> modes;
- GetVideoResolutionList(modes, true, true);
- if (static_cast<unsigned int>(iValue) < modes.size())
- m_deviceConfig.size = modes.at(iValue);
+ if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) )
+ {
+ std::vector<Math::IntPoint> modes;
+ GetVideoResolutionList(modes, true, true);
+ if (static_cast<unsigned int>(iValue) < modes.size())
+ m_deviceConfig.size = modes.at(iValue);
}
-
- if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) {
- m_deviceConfig.fullScreen = (iValue == 1);
+
+ if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) )
+ {
+ m_deviceConfig.fullScreen = (iValue == 1);
}
-
+
if (! CreateVideoSurface())
return false; // dialog is in function
@@ -378,7 +451,7 @@ bool CApplication::Create()
// Don't generate joystick events
SDL_JoystickEventState(SDL_IGNORE);
-
+
// The video is ready, we can create and initalize the graphics device
m_device = new Gfx::CGLDevice(m_deviceConfig);
if (! m_device->Create() )
@@ -389,7 +462,7 @@ bool CApplication::Create()
}
// Create the 3D engine
- m_engine = new Gfx::CEngine(m_iMan, this);
+ m_engine = new Gfx::CEngine(this);
m_engine->SetDevice(m_device);
@@ -400,8 +473,11 @@ bool CApplication::Create()
return false;
}
+ // Create model manager
+ m_modelManager = new Gfx::CModelManager(m_engine);
+
// Create the robot application.
- m_robotMain = new CRobotMain(m_iMan, this);
+ m_robotMain = new CRobotMain(this);
m_robotMain->ChangePhase(PHASE_WELCOME1);
@@ -427,8 +503,6 @@ bool CApplication::CreateVideoSurface()
// Use hardware surface if available
if (videoInfo->hw_available)
videoFlags |= SDL_HWSURFACE;
- else
- videoFlags |= SDL_SWSURFACE;
// Enable hardware blit if available
if (videoInfo->blit_hw)
@@ -479,6 +553,12 @@ void CApplication::Destroy()
m_sound = nullptr;
}
+ if (m_modelManager != nullptr)
+ {
+ delete m_modelManager;
+ m_modelManager = nullptr;
+ }
+
if (m_engine != nullptr)
{
m_engine->Destroy();
@@ -537,7 +617,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
std::string(SDL_GetError()) + std::string("\n") +
std::string("Previous mode will be restored");
GetLogger()->Error(error.c_str());
- SystemDialog( SDT_ERROR, "COLOBT - Error", error);
+ GetSystemUtils()->SystemDialog( SDT_ERROR, "COLOBT - Error", error);
restore = true;
ChangeVideoConfig(m_lastDeviceConfig);
@@ -550,7 +630,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
std::string error = std::string("SDL error while restoring previous video mode:\n") +
std::string(SDL_GetError());
GetLogger()->Error(error.c_str());
- SystemDialog( SDT_ERROR, "COLOBT - Fatal Error", error);
+ GetSystemUtils()->SystemDialog( SDT_ERROR, "COLOBT - Fatal Error", error);
// Fatal error, so post the quit event
@@ -685,14 +765,22 @@ int CApplication::Run()
{
m_active = true;
- GetCurrentTimeStamp(m_baseTimeStamp);
- GetCurrentTimeStamp(m_lastTimeStamp);
- GetCurrentTimeStamp(m_curTimeStamp);
+ GetSystemUtils()->GetCurrentTimeStamp(m_baseTimeStamp);
+ GetSystemUtils()->GetCurrentTimeStamp(m_lastTimeStamp);
+ GetSystemUtils()->GetCurrentTimeStamp(m_curTimeStamp);
MoveMouse(Math::Point(0.5f, 0.5f)); // center mouse on start
while (true)
{
+ ResetPerformanceCounters();
+
+ if (m_active)
+ {
+ StartPerformanceCounter(PCNT_ALL);
+ StartPerformanceCounter(PCNT_EVENT_PROCESSING);
+ }
+
// To be sure no old event remains
m_private->currentEvent.type = SDL_NOEVENT;
@@ -804,15 +892,38 @@ int CApplication::Run()
m_robotMain->EventProcess(event);
}
+ StopPerformanceCounter(PCNT_EVENT_PROCESSING);
+
+ StartPerformanceCounter(PCNT_UPDATE_ALL);
+
+ // Prepare and process step simulation event
+ event = CreateUpdateEvent();
+ if (event.type != EVENT_NULL && m_robotMain != nullptr)
+ {
+ StartPerformanceCounter(PCNT_UPDATE_ENGINE);
+ m_engine->FrameUpdate();
+ StopPerformanceCounter(PCNT_UPDATE_ENGINE);
+
+ m_sound->FrameMove(m_relTime);
+
+ StartPerformanceCounter(PCNT_UPDATE_GAME);
+ m_robotMain->EventProcess(event);
+ StopPerformanceCounter(PCNT_UPDATE_GAME);
+ }
+
+ StopPerformanceCounter(PCNT_UPDATE_ALL);
+
/* Update mouse position explicitly right before rendering
* because mouse events are usually way behind */
UpdateMouse();
- // Update game and render a frame during idle time (no messages are waiting)
+ StartPerformanceCounter(PCNT_RENDER_ALL);
Render();
+ StopPerformanceCounter(PCNT_RENDER_ALL);
- // Update simulation state
- StepSimulation();
+ StopPerformanceCounter(PCNT_ALL);
+
+ UpdatePerformanceCountersData();
if (m_lowCPU)
{
@@ -848,14 +959,14 @@ Event CApplication::ProcessSystemEvent()
{
event.type = EVENT_QUIT;
}
- /*else if (m_private->currentEvent.type == SDL_VIDEORESIZE)
+ else if (m_private->currentEvent.type == SDL_VIDEORESIZE)
{
Gfx::GLDeviceConfig newConfig = m_deviceConfig;
newConfig.size.x = m_private->currentEvent.resize.w;
newConfig.size.y = m_private->currentEvent.resize.h;
if (newConfig.size != m_deviceConfig.size)
ChangeVideoConfig(newConfig);
- }*/
+ }
else if ( (m_private->currentEvent.type == SDL_KEYDOWN) ||
(m_private->currentEvent.type == SDL_KEYUP) )
{
@@ -1008,49 +1119,49 @@ bool CApplication::ProcessEvent(const Event &event)
{
case EVENT_KEY_DOWN:
case EVENT_KEY_UP:
- l->Info("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
- l->Info(" virt = %s\n", (event.key.virt) ? "true" : "false");
- l->Info(" key = %d\n", event.key.key);
- l->Info(" unicode = 0x%04x\n", event.key.unicode);
+ l->Trace("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
+ l->Trace(" virt = %s\n", (event.key.virt) ? "true" : "false");
+ l->Trace(" key = %d\n", event.key.key);
+ l->Trace(" unicode = 0x%04x\n", event.key.unicode);
break;
case EVENT_MOUSE_MOVE:
- l->Info("EVENT_MOUSE_MOVE:\n");
+ l->Trace("EVENT_MOUSE_MOVE:\n");
break;
case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP:
- l->Info("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP");
- l->Info(" button = %d\n", event.mouseButton.button);
+ l->Trace("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP");
+ l->Trace(" button = %d\n", event.mouseButton.button);
break;
case EVENT_MOUSE_WHEEL:
- l->Info("EVENT_MOUSE_WHEEL:\n");
- l->Info(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
+ l->Trace("EVENT_MOUSE_WHEEL:\n");
+ l->Trace(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
break;
case EVENT_JOY_AXIS:
- l->Info("EVENT_JOY_AXIS:\n");
- l->Info(" axis = %d\n", event.joyAxis.axis);
- l->Info(" value = %d\n", event.joyAxis.value);
+ l->Trace("EVENT_JOY_AXIS:\n");
+ l->Trace(" axis = %d\n", event.joyAxis.axis);
+ l->Trace(" value = %d\n", event.joyAxis.value);
break;
case EVENT_JOY_BUTTON_DOWN:
case EVENT_JOY_BUTTON_UP:
- l->Info("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP");
- l->Info(" button = %d\n", event.joyButton.button);
+ l->Trace("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP");
+ l->Trace(" button = %d\n", event.joyButton.button);
break;
case EVENT_ACTIVE:
- l->Info("EVENT_ACTIVE:\n");
- l->Info(" flags = 0x%x\n", event.active.flags);
- l->Info(" gain = %s\n", event.active.gain ? "true" : "false");
+ l->Trace("EVENT_ACTIVE:\n");
+ l->Trace(" flags = 0x%x\n", event.active.flags);
+ l->Trace(" gain = %s\n", event.active.gain ? "true" : "false");
break;
default:
- l->Info("Event type = %d:\n", static_cast<int>(event.type));
+ l->Trace("Event type = %d:\n", static_cast<int>(event.type));
break;
}
- l->Info(" systemEvent = %s\n", event.systemEvent ? "true" : "false");
- l->Info(" rTime = %f\n", event.rTime);
- l->Info(" kmodState = %04x\n", event.kmodState);
- l->Info(" trackedKeysState = %04x\n", event.trackedKeysState);
- l->Info(" mousePos = %f, %f\n", event.mousePos.x, event.mousePos.y);
- l->Info(" mouseButtonsState = %02x\n", event.mouseButtonsState);
+ l->Trace(" systemEvent = %s\n", event.systemEvent ? "true" : "false");
+ l->Trace(" rTime = %f\n", event.rTime);
+ l->Trace(" kmodState = %04x\n", event.kmodState);
+ l->Trace(" trackedKeysState = %04x\n", event.trackedKeysState);
+ l->Trace(" mousePos = %f, %f\n", event.mousePos.x, event.mousePos.y);
+ l->Trace(" mouseButtonsState = %02x\n", event.mouseButtonsState);
}
// By default, pass on all events
@@ -1118,8 +1229,8 @@ void CApplication::ResumeSimulation()
{
m_simulationSuspended = false;
- GetCurrentTimeStamp(m_baseTimeStamp);
- CopyTimeStamp(m_curTimeStamp, m_baseTimeStamp);
+ GetSystemUtils()->GetCurrentTimeStamp(m_baseTimeStamp);
+ GetSystemUtils()->CopyTimeStamp(m_curTimeStamp, m_baseTimeStamp);
m_realAbsTimeBase = m_realAbsTime;
m_absTimeBase = m_exactAbsTime;
@@ -1135,35 +1246,43 @@ void CApplication::SetSimulationSpeed(float speed)
{
m_simulationSpeed = speed;
- GetCurrentTimeStamp(m_baseTimeStamp);
+ GetSystemUtils()->GetCurrentTimeStamp(m_baseTimeStamp);
m_realAbsTimeBase = m_realAbsTime;
m_absTimeBase = m_exactAbsTime;
GetLogger()->Info("Simulation speed = %.2f\n", speed);
}
-void CApplication::StepSimulation()
+Event CApplication::CreateUpdateEvent()
{
if (m_simulationSuspended)
- return;
-
- CopyTimeStamp(m_lastTimeStamp, m_curTimeStamp);
- GetCurrentTimeStamp(m_curTimeStamp);
-
- long long absDiff = TimeStampExactDiff(m_baseTimeStamp, m_curTimeStamp);
- m_realAbsTime = m_realAbsTimeBase + absDiff;
- // m_baseTimeStamp is updated on simulation speed change, so this is OK
- m_exactAbsTime = m_absTimeBase + m_simulationSpeed * absDiff;
- m_absTime = (m_absTimeBase + m_simulationSpeed * absDiff) / 1e9f;
+ return Event(EVENT_NULL);
- m_realRelTime = TimeStampExactDiff(m_lastTimeStamp, m_curTimeStamp);
- m_exactRelTime = m_simulationSpeed * m_realRelTime;
- m_relTime = (m_simulationSpeed * m_realRelTime) / 1e9f;
+ GetSystemUtils()->CopyTimeStamp(m_lastTimeStamp, m_curTimeStamp);
+ GetSystemUtils()->GetCurrentTimeStamp(m_curTimeStamp);
+ long long absDiff = GetSystemUtils()->TimeStampExactDiff(m_baseTimeStamp, m_curTimeStamp);
+ long long newRealAbsTime = m_realAbsTimeBase + absDiff;
+ long long newRealRelTime = GetSystemUtils()->TimeStampExactDiff(m_lastTimeStamp, m_curTimeStamp);
- m_engine->FrameUpdate();
- m_sound->FrameMove(m_relTime);
-
+ if (newRealAbsTime < m_realAbsTime || newRealRelTime < 0)
+ {
+ GetLogger()->Error("Fatal error: got negative system counter difference!\n");
+ GetLogger()->Error("This should never happen. Please report this error.\n");
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
+ return Event(EVENT_NULL);
+ }
+ else
+ {
+ m_realAbsTime = newRealAbsTime;
+ // m_baseTimeStamp is updated on simulation speed change, so this is OK
+ m_exactAbsTime = m_absTimeBase + m_simulationSpeed * absDiff;
+ m_absTime = (m_absTimeBase + m_simulationSpeed * absDiff) / 1e9f;
+
+ m_realRelTime = newRealRelTime;
+ m_exactRelTime = m_simulationSpeed * m_realRelTime;
+ m_relTime = (m_simulationSpeed * m_realRelTime) / 1e9f;
+ }
Event frameEvent(EVENT_FRAME);
frameEvent.systemEvent = true;
@@ -1172,7 +1291,8 @@ void CApplication::StepSimulation()
frameEvent.mousePos = m_mousePos;
frameEvent.mouseButtonsState = m_mouseButtonsState;
frameEvent.rTime = m_relTime;
- m_eventQueue->AddEvent(frameEvent);
+
+ return frameEvent;
}
float CApplication::GetSimulationSpeed()
@@ -1402,6 +1522,10 @@ std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& sub
str << m_dataPath;
str << "/";
str << m_dataDirs[index];
+ if (stdDir == DIR_HELP) {
+ str << "/";
+ str << GetLanguageChar();
+ }
str << "/";
str << subpath;
return str.str();
@@ -1438,6 +1562,32 @@ char CApplication::GetLanguageChar()
return langChar;
}
+bool CApplication::ParseLanguage(const std::string& str, Language& language)
+{
+ if (str == "en")
+ {
+ language = LANGUAGE_ENGLISH;
+ return true;
+ }
+ else if (str == "de")
+ {
+ language = LANGUAGE_GERMAN;
+ return true;
+ }
+ else if (str == "fr")
+ {
+ language = LANGUAGE_FRENCH;
+ return true;
+ }
+ else if (str == "pl")
+ {
+ language = LANGUAGE_POLISH;
+ return true;
+ }
+
+ return false;
+}
+
void CApplication::SetLanguage(Language language)
{
m_language = language;
@@ -1509,7 +1659,7 @@ void CApplication::SetLanguage(Language language)
}
setlocale(LC_ALL, "");
- bindtextdomain("colobot", COLOBOT_I18N_DIR);
+ bindtextdomain("colobot", m_langPath.c_str());
bind_textdomain_codeset("colobot", "UTF-8");
textdomain("colobot");
@@ -1525,3 +1675,43 @@ bool CApplication::GetLowCPU()
{
return m_lowCPU;
}
+
+void CApplication::StartPerformanceCounter(PerformanceCounter counter)
+{
+ GetSystemUtils()->GetCurrentTimeStamp(m_performanceCounters[counter][0]);
+}
+
+void CApplication::StopPerformanceCounter(PerformanceCounter counter)
+{
+ GetSystemUtils()->GetCurrentTimeStamp(m_performanceCounters[counter][1]);
+}
+
+float CApplication::GetPerformanceCounterData(PerformanceCounter counter)
+{
+ return m_performanceCountersData[counter];
+}
+
+void CApplication::ResetPerformanceCounters()
+{
+ for (int i = 0; i < PCNT_MAX; ++i)
+ {
+ StartPerformanceCounter(static_cast<PerformanceCounter>(i));
+ StopPerformanceCounter(static_cast<PerformanceCounter>(i));
+ }
+}
+
+void CApplication::UpdatePerformanceCountersData()
+{
+ long long sum = GetSystemUtils()->TimeStampExactDiff(m_performanceCounters[PCNT_ALL][0],
+ m_performanceCounters[PCNT_ALL][1]);
+
+ for (int i = 0; i < PCNT_MAX; ++i)
+ {
+ long long diff = GetSystemUtils()->TimeStampExactDiff(m_performanceCounters[i][0],
+ m_performanceCounters[i][1]);
+
+ m_performanceCountersData[static_cast<PerformanceCounter>(i)] =
+ static_cast<float>(diff) / static_cast<float>(sum);
+ }
+}
+
diff --git a/src/app/app.h b/src/app/app.h
index 2da20d3..dcc90e0 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -41,6 +41,10 @@ class CEventQueue;
class CRobotMain;
class CSoundInterface;
+namespace Gfx {
+class CModelManager;
+}
+
/**
* \struct JoystickDevice
* \brief Information about a joystick device
@@ -112,6 +116,31 @@ enum MouseMode
MOUSE_NONE, //! < no cursor visible
};
+/**
+ * \enum PerformanceCounter
+ * \brief Type of counter testing performance
+ */
+enum PerformanceCounter
+{
+ PCNT_EVENT_PROCESSING, //! < event processing (except update events)
+
+ PCNT_UPDATE_ALL, //! < the whole frame update process
+ PCNT_UPDATE_ENGINE, //! < frame update in CEngine
+ PCNT_UPDATE_PARTICLE, //! < frame update in CParticle
+ PCNT_UPDATE_GAME, //! < frame update in CRobotMain
+
+ PCNT_RENDER_ALL, //! < the whole rendering process
+ PCNT_RENDER_PARTICLE, //! < rendering the particles in 3D
+ PCNT_RENDER_WATER, //! < rendering the water
+ PCNT_RENDER_TERRAIN, //! < rendering the terrain
+ PCNT_RENDER_OBJECTS, //! < rendering the 3D objects
+ PCNT_RENDER_INTERFACE, //! < rendering 2D interface
+
+ PCNT_ALL, //! < all counters together
+
+ PCNT_MAX
+};
+
struct ApplicationPrivate;
/**
@@ -165,6 +194,11 @@ public:
//! Destructor
~CApplication();
+ //! Returns the application's event queue
+ CEventQueue* GetEventQueue();
+ //! Returns the sound subsystem
+ CSoundInterface* GetSound();
+
public:
//! Parses commandline arguments
ParseArgsStatus ParseArguments(int argc, char *argv[]);
@@ -198,9 +232,6 @@ public:
//! Returns whether simulation is suspended
bool GetSimulationSuspended();
- //! Updates the simulation state
- void StepSimulation();
-
//@{
//! Management of simulation speed
void SetSimulationSpeed(float speed);
@@ -296,6 +327,7 @@ public:
Language GetLanguage();
char GetLanguageChar();
void SetLanguage(Language language);
+ static bool ParseLanguage(const std::string& str, Language& language);
//@}
//! Management of sleep in main loop (lowers CPU usage)
@@ -304,6 +336,13 @@ public:
bool GetLowCPU();
//@}
+ //! Management of performance counters
+ //@{
+ void StartPerformanceCounter(PerformanceCounter counter);
+ void StopPerformanceCounter(PerformanceCounter counter);
+ float GetPerformanceCounterData(PerformanceCounter counter);
+ //@}
+
protected:
//! Creates the window's SDL_Surface
bool CreateVideoSurface();
@@ -312,6 +351,8 @@ protected:
Event ProcessSystemEvent();
//! If applicable, creates a virtual event to match the changed state as of new event
Event CreateVirtualEvent(const Event& sourceEvent);
+ //! Prepares a simulation update event
+ TEST_VIRTUAL Event CreateUpdateEvent();
//! Handles some incoming events
bool ProcessEvent(const Event& event);
//! Renders the image in window
@@ -322,21 +363,30 @@ protected:
//! Closes the joystick device
void CloseJoystick();
+ //! Resets all performance counters to zero
+ void ResetPerformanceCounters();
+ //! Updates performance counters from gathered timer data
+ void UpdatePerformanceCountersData();
+
protected:
- //! Instance manager
- CInstanceManager* m_iMan;
//! Private (SDL-dependent data)
ApplicationPrivate* m_private;
+ //! Instance manager
+ // TODO: to be removed
+ CInstanceManager* m_iMan;
//! Global event queue
CEventQueue* m_eventQueue;
//! Graphics engine
Gfx::CEngine* m_engine;
//! Graphics device
Gfx::CDevice* m_device;
+ //! 3D models manager
+ Gfx::CModelManager* m_modelManager;
//! Sound subsystem
CSoundInterface* m_sound;
//! Main class of the proper game engine
CRobotMain* m_robotMain;
+ //! Profile (INI) reader/writer
CProfile* m_profile;
//! Code to return at exit
@@ -363,6 +413,9 @@ protected:
SystemTimeStamp* m_lastTimeStamp;
SystemTimeStamp* m_curTimeStamp;
+ SystemTimeStamp* m_performanceCounters[PCNT_MAX][2];
+ float m_performanceCountersData[PCNT_MAX];
+
long long m_realAbsTimeBase;
long long m_realAbsTime;
long long m_realRelTime;
@@ -402,6 +455,9 @@ protected:
//! Path to directory with data files
std::string m_dataPath;
+ //! Path to directory with language files
+ std::string m_langPath;
+
const char* m_dataDirs[DIR_MAX];
//! Application language
diff --git a/src/app/main.cpp b/src/app/main.cpp
index e621065..edb5828 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -23,6 +23,7 @@
#include "app/app.h"
#include "app/system.h"
+#include "common/config.h"
#include "common/logger.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -70,44 +71,54 @@ The current layout is the following:
//! Entry point to the program
-int main(int argc, char *argv[])
+extern "C"
{
- CLogger logger; // Create the logger
- InitializeRestext(); // Initialize translation strings
+int SDL_MAIN_FUNC(int argc, char *argv[])
+{
+ CLogger logger; // single istance of logger
+
+ InitializeRestext(); // init static translation strings
+
+ CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
+ systemUtils->Init();
logger.Info("Colobot starting\n");
- CApplication app; // single instance of the application
+ CApplication* app = new CApplication(); // single instance of the application
- ParseArgsStatus status = app.ParseArguments(argc, argv);
+ ParseArgsStatus status = app->ParseArguments(argc, argv);
if (status == PARSE_ARGS_FAIL)
{
- SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
- return app.GetExitCode();
+ systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
+ return app->GetExitCode();
}
else if (status == PARSE_ARGS_HELP)
{
- return app.GetExitCode();
+ return app->GetExitCode();
}
int code = 0;
- if (! app.Create())
+ if (! app->Create())
{
- app.Destroy(); // ensure a clean exit
- code = app.GetExitCode();
- if ( code != 0 && !app.GetErrorMessage().empty() )
+ app->Destroy(); // ensure a clean exit
+ code = app->GetExitCode();
+ if ( code != 0 && !app->GetErrorMessage().empty() )
{
- SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app.GetErrorMessage());
+ systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage());
}
logger.Info("Didn't run main loop. Exiting with code %d\n", code);
return code;
}
- code = app.Run();
+ code = app->Run();
+
+ delete app;
+ delete systemUtils;
logger.Info("Exiting with code %d\n", code);
return code;
}
+} // extern "C"
diff --git a/src/app/system.cpp b/src/app/system.cpp
index 73614aa..743ed96 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -22,75 +22,142 @@
#if defined(PLATFORM_WINDOWS)
-#include "app/system_windows.h"
-
+ #include "app/system_windows.h"
#elif defined(PLATFORM_LINUX)
-#include "app/system_linux.h"
-
+ #include "app/system_linux.h"
#else
-#include "app/system_other.h"
-
+ #include "app/system_other.h"
#endif
-
#include <cassert>
+#include <iostream>
+
+
+template<>
+CSystemUtils* CSingleton<CSystemUtils>::m_instance = nullptr;
-/**
- * Displays a system dialog with info, error, question etc. message.
- *
- * \param type type of dialog
- * \param message text of message (in UTF-8)
- * \param title dialog title (in UTF-8)
- * \returns result (which button was clicked)
- */
-SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message)
+CSystemUtils::CSystemUtils()
{
+}
+
+CSystemUtils* CSystemUtils::Create()
+{
+ assert(m_instance == nullptr);
#if defined(PLATFORM_WINDOWS)
- return SystemDialog_Windows(type, title, message);
+ m_instance = new CSystemUtilsWindows();
#elif defined(PLATFORM_LINUX)
- return SystemDialog_Linux(type, title, message);
+ m_instance = new CSystemUtilsLinux();
#else
- return SystemDialog_Other(type, title, message);
+ m_instance = new CSystemUtilsOther();
#endif
+ return m_instance;
}
-SystemTimeStamp* CreateTimeStamp()
+SystemDialogResult CSystemUtils::ConsoleSystemDialog(SystemDialogType type, const std::string& title, const std::string& message)
{
- return new SystemTimeStamp();
+ switch (type)
+ {
+ case SDT_INFO:
+ std::cout << "INFO: ";
+ break;
+ case SDT_WARNING:
+ std::cout << "WARNING:";
+ break;
+ case SDT_ERROR:
+ std::cout << "ERROR: ";
+ break;
+ case SDT_YES_NO:
+ case SDT_OK_CANCEL:
+ std::cout << "QUESTION: ";
+ break;
+ }
+
+ std::cout << message << std::endl;
+
+ std::string line;
+
+ SystemDialogResult result = SDR_OK;
+
+ bool done = false;
+ while (!done)
+ {
+ switch (type)
+ {
+ case SDT_INFO:
+ case SDT_WARNING:
+ case SDT_ERROR:
+ std::cout << "Press ENTER to continue";
+ break;
+
+ case SDT_YES_NO:
+ std::cout << "Type 'Y' for Yes or 'N' for No";
+ break;
+
+ case SDT_OK_CANCEL:
+ std::cout << "Type 'O' for OK or 'C' for Cancel";
+ break;
+ }
+
+ std::getline(std::cin, line);
+
+ switch (type)
+ {
+ case SDT_INFO:
+ case SDT_WARNING:
+ case SDT_ERROR:
+ done = true;
+ break;
+
+ case SDT_YES_NO:
+ if (line == "Y" || line == "y")
+ {
+ result = SDR_YES;
+ done = true;
+ }
+ else if (line == "N" || line == "n")
+ {
+ result = SDR_NO;
+ done = true;
+ }
+ break;
+
+ case SDT_OK_CANCEL:
+ if (line == "O" || line == "o")
+ {
+ done = true;
+ result = SDR_OK;
+ }
+ else if (line == "C" || line == "c")
+ {
+ done = true;
+ result = SDR_CANCEL;
+ }
+ break;
+ }
+ }
+
+ return result;
}
-void DestroyTimeStamp(SystemTimeStamp *stamp)
+SystemTimeStamp* CSystemUtils::CreateTimeStamp()
{
- delete stamp;
+ return new SystemTimeStamp();
}
-void CopyTimeStamp(SystemTimeStamp *dst, SystemTimeStamp *src)
+void CSystemUtils::DestroyTimeStamp(SystemTimeStamp *stamp)
{
- *dst = *src;
+ delete stamp;
}
-void GetCurrentTimeStamp(SystemTimeStamp *stamp)
+void CSystemUtils::CopyTimeStamp(SystemTimeStamp *dst, SystemTimeStamp *src)
{
-#if defined(PLATFORM_WINDOWS)
- GetCurrentTimeStamp_Windows(stamp);
-#elif defined(PLATFORM_LINUX)
- GetCurrentTimeStamp_Linux(stamp);
-#else
- GetCurrentTimeStamp_Other(stamp);
-#endif
+ *dst = *src;
}
-float GetTimeStampResolution(SystemTimeUnit unit)
+float CSystemUtils::GetTimeStampResolution(SystemTimeUnit unit)
{
- unsigned long long exact = 0;
-#if defined(PLATFORM_WINDOWS)
- exact = GetTimeStampExactResolution_Windows();
-#elif defined(PLATFORM_LINUX)
- exact = GetTimeStampExactResolution_Linux();
-#else
- exact = GetTimeStampExactResolution_Other();
-#endif
+ unsigned long long exact = GetTimeStampExactResolution();
float result = 0.0f;
if (unit == STU_SEC)
result = exact * 1e-9;
@@ -100,30 +167,14 @@ float GetTimeStampResolution(SystemTimeUnit unit)
result = exact * 1e-3;
else
assert(false);
+
return result;
}
-long long GetTimeStampExactResolution()
+float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeUnit unit)
{
-#if defined(PLATFORM_WINDOWS)
- return GetTimeStampExactResolution_Windows();
-#elif defined(PLATFORM_LINUX)
- return GetTimeStampExactResolution_Linux();
-#else
- return GetTimeStampExactResolution_Other();
-#endif
-}
+ long long exact = TimeStampExactDiff(before, after);
-float TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeUnit unit)
-{
- long long exact = 0;
-#if defined(PLATFORM_WINDOWS)
- exact = TimeStampExactDiff_Windows(before, after);
-#elif defined(PLATFORM_LINUX)
- exact = TimeStampExactDiff_Linux(before, after);
-#else
- exact = TimeStampExactDiff_Other(before, after);
-#endif
float result = 0.0f;
if (unit == STU_SEC)
result = exact * 1e-9;
@@ -133,16 +184,16 @@ float TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeU
result = exact * 1e-3;
else
assert(false);
+
return result;
}
-long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after)
+std::string CSystemUtils::profileFileLocation()
{
-#if defined(PLATFORM_WINDOWS)
- return TimeStampExactDiff_Windows(before, after);
-#elif defined(PLATFORM_LINUX)
- return TimeStampExactDiff_Linux(before, after);
-#else
- return TimeStampExactDiff_Other(before, after);
-#endif
+ return std::string("colobot.ini");
+}
+
+std::string CSystemUtils::savegameDirectoryLocation()
+{
+ return std::string("savegame");
}
diff --git a/src/app/system.h b/src/app/system.h
index e216842..6ae05d6 100644
--- a/src/app/system.h
+++ b/src/app/system.h
@@ -22,12 +22,10 @@
#pragma once
+#include "common/singleton.h"
#include <string>
-
-/* Dialog utils */
-
/**
* \enum SystemDialogType
* \brief Type of system dialog
@@ -60,12 +58,10 @@ enum SystemDialogResult
SDR_NO
};
-//! Displays a system dialog
-SystemDialogResult SystemDialog(SystemDialogType, const std::string &title, const std::string &message);
-
-
-/* Time utils */
-
+/**
+ * \enum SystemTimeUnit
+ * \brief Time unit
+ */
enum SystemTimeUnit
{
//! seconds
@@ -76,33 +72,73 @@ enum SystemTimeUnit
STU_USEC
};
-/* Forward declaration of time stamp struct
- * SystemTimeStamp should be used in a pointer context.
- * The implementation details are hidden because of platform dependence. */
+/*
+ * Forward declaration of time stamp struct
+ * SystemTimeStamp should only be used in a pointer context.
+ * The implementation details are hidden because of platform dependence.
+ */
struct SystemTimeStamp;
-//! Creates a new time stamp object
-SystemTimeStamp* CreateTimeStamp();
+/**
+ * \class CSystemUtils
+ * \brief Platform-specific utils
+ *
+ * This class provides system-specific utilities like displaying user dialogs and
+ * querying system timers for exact timestamps.
+ */
+class CSystemUtils : public CSingleton<CSystemUtils>
+{
+protected:
+ CSystemUtils();
+
+public:
+ //! Creates system utils for specific platform
+ static CSystemUtils* Create();
+
+ //! Performs platform-specific initialization
+ virtual void Init() = 0;
+
+ //! Displays a system dialog
+ virtual SystemDialogResult SystemDialog(SystemDialogType, const std::string &title, const std::string &message) = 0;
+
+ //! Displays a fallback system dialog using console
+ TEST_VIRTUAL SystemDialogResult ConsoleSystemDialog(SystemDialogType type, const std::string& title, const std::string& message);
+
+ //! Creates a new time stamp object
+ TEST_VIRTUAL SystemTimeStamp* CreateTimeStamp();
-//! Destroys a time stamp object
-void DestroyTimeStamp(SystemTimeStamp *stamp);
+ //! Destroys a time stamp object
+ TEST_VIRTUAL void DestroyTimeStamp(SystemTimeStamp *stamp);
-//! Copies the time stamp from \a src to \a dst
-void CopyTimeStamp(SystemTimeStamp *dst, SystemTimeStamp *src);
+ //! Copies the time stamp from \a src to \a dst
+ TEST_VIRTUAL void CopyTimeStamp(SystemTimeStamp *dst, SystemTimeStamp *src);
-//! Returns a time stamp associated with current time
-void GetCurrentTimeStamp(SystemTimeStamp *stamp);
+ //! Returns a time stamp associated with current time
+ virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) = 0;
-//! Returns the platform's expected time stamp resolution
-float GetTimeStampResolution(SystemTimeUnit unit = STU_SEC);
+ //! Returns the platform's expected time stamp resolution
+ TEST_VIRTUAL float GetTimeStampResolution(SystemTimeUnit unit = STU_SEC);
-//! Returns the platform's exact (in nanosecond units) expected time stamp resolution
-long long GetTimeStampExactResolution();
+ //! Returns the platform's exact (in nanosecond units) expected time stamp resolution
+ virtual long long GetTimeStampExactResolution() = 0;
-//! Returns a difference between two timestamps in given time unit
-/** The difference is \a after - \a before. */
-float TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeUnit unit = STU_SEC);
+ //! Returns a difference between two timestamps in given time unit
+ /** The difference is \a after - \a before. */
+ TEST_VIRTUAL float TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeUnit unit = STU_SEC);
-//! Returns the exact (in nanosecond units) difference between two timestamps
-/** The difference is \a after - \a before. */
-long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after);
+ //! Returns the exact (in nanosecond units) difference between two timestamps
+ /** The difference is \a after - \a before. */
+ virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0;
+
+ //! Returns the profile (colobot.ini) file location
+ virtual std::string profileFileLocation();
+
+ //! Returns the savegame directory location
+ virtual std::string savegameDirectoryLocation();
+};
+
+//! Global function to get CSystemUtils instance
+inline CSystemUtils* GetSystemUtils()
+{
+ return CSystemUtils::GetInstancePointer();
+}
diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp
new file mode 100644
index 0000000..01dd850
--- /dev/null
+++ b/src/app/system_linux.cpp
@@ -0,0 +1,150 @@
+// * 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
+// * 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 "app/system_linux.h"
+
+#include "common/logger.h"
+
+#include <stdlib.h>
+
+
+void CSystemUtilsLinux::Init()
+{
+ m_zenityAvailable = true;
+ if (system("zenity --version") != 0)
+ {
+ m_zenityAvailable = false;
+ GetLogger()->Warn("Zenity not available, will fallback to console users dialogs.\n");
+ }
+}
+
+SystemDialogResult CSystemUtilsLinux::SystemDialog(SystemDialogType type, const std::string& title, const std::string& message)
+{
+ if (!m_zenityAvailable)
+ {
+ return ConsoleSystemDialog(type, title, message);
+ }
+
+ std::string options = "";
+ switch (type)
+ {
+ case SDT_INFO:
+ default:
+ options = "--info";
+ break;
+ case SDT_WARNING:
+ options = "--warning";
+ break;
+ case SDT_ERROR:
+ options = "--error";
+ break;
+ case SDT_YES_NO:
+ options = "--question --ok-label=\"Yes\" --cancel-label=\"No\"";
+ break;
+ case SDT_OK_CANCEL:
+ options = "--question --ok-label=\"OK\" --cancel-label=\"Cancel\"";
+ break;
+ }
+
+ std::string command = "zenity " + options + " --text=\"" + message + "\" --title=\"" + title + "\"";
+ int code = system(command.c_str());
+
+ SystemDialogResult result = SDR_OK;
+ switch (type)
+ {
+ case SDT_YES_NO:
+ result = code ? SDR_NO : SDR_YES;
+ break;
+ case SDT_OK_CANCEL:
+ result = code ? SDR_CANCEL : SDR_OK;
+ break;
+ default:
+ break;
+ }
+
+ return result;
+}
+
+void CSystemUtilsLinux::GetCurrentTimeStamp(SystemTimeStamp *stamp)
+{
+ clock_gettime(CLOCK_MONOTONIC_RAW, &stamp->clockTime);
+}
+
+long long CSystemUtilsLinux::GetTimeStampExactResolution()
+{
+ return 1ll;
+}
+
+long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after)
+{
+ return (after->clockTime.tv_nsec - before->clockTime.tv_nsec) +
+ (after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll;
+}
+
+std::string CSystemUtilsLinux::profileFileLocation()
+{
+ std::string m_profileFile;
+
+ // Determine profileFile according to XDG Base Directory Specification
+ char* envXDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME");
+ if (envXDG_CONFIG_HOME == NULL)
+ {
+ char *envHOME = getenv("HOME");
+ if (envHOME == NULL)
+ {
+ m_profileFile = "colobot.ini";
+ }
+ else
+ {
+ m_profileFile = std::string(envHOME) + "/.config/colobot.ini";
+ }
+ }
+ else
+ {
+ m_profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini";
+ }
+ GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str());
+
+ return m_profileFile;
+}
+
+std::string CSystemUtilsLinux::savegameDirectoryLocation()
+{
+ std::string m_savegameDir;
+
+ // Determine savegame dir according to XDG Base Directory Specification
+ char *envXDG_DATA_HOME = getenv("XDG_CONFIG_DATA");
+ if (envXDG_DATA_HOME == NULL)
+ {
+ char *envHOME = getenv("HOME");
+ if (envHOME == NULL)
+ {
+ m_savegameDir = "/tmp/colobot-savegame";
+ }
+ else
+ {
+ m_savegameDir = std::string(envHOME) + "/.local/share/colobot";
+ }
+ }
+ else
+ {
+ m_savegameDir = std::string(envXDG_DATA_HOME) + "/colobot";
+ }
+ GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str());
+
+ return m_savegameDir;
+}
diff --git a/src/app/system_linux.h b/src/app/system_linux.h
index 69893de..a9a5a52 100644
--- a/src/app/system_linux.h
+++ b/src/app/system_linux.h
@@ -20,20 +20,11 @@
* \brief Linux-specific implementation of system functions
*/
-/* NOTE: code is contained in this header;
- * there is no separate .cpp module for simplicity */
+#include "app/system.h"
#include <sys/time.h>
-#include <time.h>
-#include <stdlib.h>
-SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message);
-
-void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp);
-long long GetTimeStampExactResolution_Linux();
-long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after);
-
struct SystemTimeStamp
{
timespec clockTime;
@@ -44,61 +35,20 @@ struct SystemTimeStamp
}
};
-
-SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message)
+class CSystemUtilsLinux : public CSystemUtils
{
- std::string options = "";
- switch (type)
- {
- case SDT_INFO:
- default:
- options = "--info";
- break;
- case SDT_WARNING:
- options = "--warning";
- break;
- case SDT_ERROR:
- options = "--error";
- break;
- case SDT_YES_NO:
- options = "--question --ok-label=\"Yes\" --cancel-label=\"No\"";
- break;
- case SDT_OK_CANCEL:
- options = "--question --ok-label=\"OK\" --cancel-label=\"Cancel\"";
- break;
- }
+public:
+ virtual void Init() override;
- std::string command = "zenity " + options + " --text=\"" + message + "\" --title=\"" + title + "\"";
- int code = system(command.c_str());
+ virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
- SystemDialogResult result = SDR_OK;
- switch (type)
- {
- case SDT_YES_NO:
- result = code ? SDR_NO : SDR_YES;
- break;
- case SDT_OK_CANCEL:
- result = code ? SDR_CANCEL : SDR_OK;
- break;
- default:
- break;
- }
+ virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
+ virtual long long GetTimeStampExactResolution() override;
+ virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
- return result;
-}
+ virtual std::string profileFileLocation() override;
+ virtual std::string savegameDirectoryLocation() override;
-void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp)
-{
- clock_gettime(CLOCK_MONOTONIC, &stamp->clockTime);
-}
-
-long long GetTimeStampExactResolution_Linux()
-{
- return 1ll;
-}
-
-long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after)
-{
- return (after->clockTime.tv_nsec - before->clockTime.tv_nsec) +
- (after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll;
-}
+private:
+ bool m_zenityAvailable;
+};
diff --git a/src/CBot/tests/TestCBot/StdAfx.cpp b/src/app/system_other.cpp
index 7dd0f00..9fc1f95 100644
--- a/src/CBot/tests/TestCBot/StdAfx.cpp
+++ b/src/app/system_other.cpp
@@ -1,20 +1,39 @@
-// * 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/.// stdafx.cpp : source file that includes just the standard includes
-// TestCBot.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
+// * 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
+// * 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 "app/system_other.h"
+
+
+SystemDialogResult CSystemUtilsOther::SystemDialog(SystemDialogType type, const std::string& title, const std::string& message)
+{
+ return ConsoleSystemDialog(type, title, message);
+}
+
+void CSystemUtilsOther::GetCurrentTimeStamp(SystemTimeStamp* stamp)
+{
+ stamp->sdlTicks = SDL_GetTicks();
+}
+
+long long int CSystemUtilsOther::GetTimeStampExactResolution()
+{
+ return 1000000ll;
+}
+
+long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after) const
+{
+ return (after->sdlTicks - before->sdlTicks) * 1000000ll;
+}
diff --git a/src/app/system_other.h b/src/app/system_other.h
index eff0c8a..bf16c80 100644
--- a/src/app/system_other.h
+++ b/src/app/system_other.h
@@ -20,20 +20,13 @@
* \brief Fallback code for other systems
*/
-/* NOTE: code is contained in this header;
- * there is no separate .cpp module for simplicity */
+#include "app/system.h"
-#include <SDL/SDL.h>
+#include <SDL.h>
#include <iostream>
-SystemDialogResult SystemDialog_Other(SystemDialogType type, const std::string& title, const std::string& message);
-
-void GetCurrentTimeStamp_Other(SystemTimeStamp *stamp);
-long long GetTimeStampExactResolution_Other();
-long long TimeStampExactDiff_Other(SystemTimeStamp *before, SystemTimeStamp *after);
-
struct SystemTimeStamp
{
Uint32 sdlTicks;
@@ -44,106 +37,12 @@ struct SystemTimeStamp
}
};
-
-SystemDialogResult SystemDialog_Other(SystemDialogType type, const std::string& title, const std::string& message)
-{
- switch (type)
- {
- case SDT_INFO:
- std::cout << "INFO: ";
- break;
- case SDT_WARNING:
- std::cout << "WARNING:";
- break;
- case SDT_ERROR:
- std::cout << "ERROR: ";
- break;
- case SDT_YES_NO:
- case SDT_OK_CANCEL:
- std::cout << "QUESTION: ";
- break;
- }
-
- std::cout << message << std::endl;
-
- std::string line;
-
- SystemDialogResult result = SDR_OK;
-
- bool done = false;
- while (!done)
- {
- switch (type)
- {
- case SDT_INFO:
- case SDT_WARNING:
- case SDT_ERROR:
- std::cout << "Press ENTER to continue";
- break;
-
- case SDT_YES_NO:
- std::cout << "Type 'Y' for Yes or 'N' for No";
- break;
-
- case SDT_OK_CANCEL:
- std::cout << "Type 'O' for OK or 'C' for Cancel";
- break;
- }
-
- std::getline(std::cin, line);
-
- switch (type)
- {
- case SDT_INFO:
- case SDT_WARNING:
- case SDT_ERROR:
- done = true;
- break;
-
- case SDT_YES_NO:
- if (line == "Y" || line == "y")
- {
- result = SDR_YES;
- done = true;
- }
- else if (line == "N" || line == "n")
- {
- result = SDR_NO;
- done = true;
- }
- break;
-
- case SDT_OK_CANCEL:
- if (line == "O" || line == "o")
- {
- done = true;
- result = SDR_OK;
- }
- else if (line == "C" || line == "c")
- {
- done = true;
- result = SDR_CANCEL;
- }
- break;
- }
- }
-
- return result;
-}
-
-
-
-void GetCurrentTimeStamp_Other(SystemTimeStamp *stamp)
-{
- stamp->sdlTicks = SDL_GetTicks();
-}
-
-long long GetTimeStampExactResolution_Other()
+class CSystemUtilsOther : public CSystemUtils
{
- return 1000000ll;
-}
+public:
+ virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
-long long TimeStampExactDiff_Other(SystemTimeStamp *before, SystemTimeStamp *after)
-{
- return (after->sdlTicks - before->sdlTicks) * 1000000ll;
-}
+ virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
+ virtual long long GetTimeStampExactResolution() override;
+ virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
+};
diff --git a/src/app/system_windows.cpp b/src/app/system_windows.cpp
new file mode 100644
index 0000000..870683f
--- /dev/null
+++ b/src/app/system_windows.cpp
@@ -0,0 +1,148 @@
+// * 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
+// * 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 "app/system_windows.h"
+
+#include "common/logger.h"
+
+#include <windows.h>
+
+
+void CSystemUtilsWindows::Init()
+{
+ LARGE_INTEGER freq;
+ QueryPerformanceFrequency(&freq);
+ m_counterFrequency = freq.QuadPart;
+
+ assert(m_counterFrequency != 0);
+}
+
+SystemDialogResult CSystemUtilsWindows::SystemDialog(SystemDialogType type, const std::string& title, const std::string& message)
+{
+ unsigned int windowsType = 0;
+ std::wstring windowsMessage = UTF8_Decode(message);
+ std::wstring windowsTitle = UTF8_Decode(title);
+
+ switch (type)
+ {
+ case SDT_INFO:
+ default:
+ windowsType = MB_ICONINFORMATION|MB_OK;
+ break;
+ case SDT_WARNING:
+ windowsType = MB_ICONWARNING|MB_OK;
+ break;
+ case SDT_ERROR:
+ windowsType = MB_ICONERROR|MB_OK;
+ break;
+ case SDT_YES_NO:
+ windowsType = MB_ICONQUESTION|MB_YESNO;
+ break;
+ case SDT_OK_CANCEL:
+ windowsType = MB_ICONWARNING|MB_OKCANCEL;
+ break;
+ }
+
+ switch (MessageBoxW(NULL, windowsMessage.c_str(), windowsTitle.c_str(), windowsType))
+ {
+ case IDOK:
+ return SDR_OK;
+ case IDCANCEL:
+ return SDR_CANCEL;
+ case IDYES:
+ return SDR_YES;
+ case IDNO:
+ return SDR_NO;
+ default:
+ break;
+ }
+
+ return SDR_OK;
+}
+
+void CSystemUtilsWindows::GetCurrentTimeStamp(SystemTimeStamp* stamp)
+{
+ LARGE_INTEGER value;
+ QueryPerformanceCounter(&value);
+ stamp->counterValue = value.QuadPart;
+}
+
+long long int CSystemUtilsWindows::GetTimeStampExactResolution()
+{
+ return 1000000000ll / m_counterFrequency;
+}
+
+long long int CSystemUtilsWindows::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after)
+{
+ float floatValue = static_cast<double>(after->counterValue - before->counterValue) * (1e9 / static_cast<double>(m_counterFrequency));
+ return static_cast<long long>(floatValue);
+}
+
+//! Converts a wide Unicode string to an UTF8 string
+std::string CSystemUtilsWindows::UTF8_Encode(const std::wstring& wstr)
+{
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), NULL, 0, NULL, NULL);
+ std::string strTo(size_needed, 0);
+ WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), &strTo[0], size_needed, NULL, NULL);
+ return strTo;
+}
+
+//! Converts an UTF8 string to a wide Unicode String
+std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
+{
+ int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), NULL, 0);
+ std::wstring wstrTo(size_needed, 0);
+ MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), &wstrTo[0], size_needed);
+ return wstrTo;
+
+}
+
+std::string CSystemUtilsWindows::profileFileLocation()
+{
+ std::string m_profileFile;
+
+ char* envUSERPROFILE = getenv("USERPROFILE");
+ if (envUSERPROFILE == NULL)
+ {
+ m_profileFile = "colobot.ini";
+ }
+ else
+ {
+ m_profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini";
+ }
+ GetLogger()->Trace("Profile configuration is %s\n", m_profileFile.c_str());
+
+ return m_profileFile;
+}
+
+std::string CSystemUtilsWindows::savegameDirectoryLocation()
+{
+ std::string m_savegameDir;
+
+ char* envUSERPROFILE = getenv("USERPROFILE");
+ if (envUSERPROFILE == NULL)
+ {
+ m_savegameDir = "savegame";
+ }
+ else
+ {
+ m_savegameDir = std::string(envUSERPROFILE) + "\\colobot\\savegame";
+ }
+ GetLogger()->Trace("Saved game files are going to %s\n", m_savegameDir.c_str());
+
+ return m_savegameDir;
+} \ No newline at end of file
diff --git a/src/app/system_windows.h b/src/app/system_windows.h
index c9743e6..88e7507 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -20,106 +20,37 @@
* \brief Windows-specific implementation of system functions
*/
-/* NOTE: code is contained in this header;
- * there is no separate .cpp module for simplicity */
+#include "app/system.h"
-#include <windows.h>
-
-
-std::string UTF8_Encode_Windows(const std::wstring &wstr);
-std::wstring UTF8_Decode_Windows(const std::string &str);
-SystemDialogResult SystemDialog_Windows(SystemDialogType type, const std::string& title, const std::string& message);
-
-void GetCurrentTimeStamp_Windows(SystemTimeStamp *stamp);
-long long GetTimeStampExactResolution_Windows();
-long long TimeStampExactDiff_Windows(SystemTimeStamp *before, SystemTimeStamp *after);
struct SystemTimeStamp
{
- FILETIME fileTime;
+ long long counterValue;
SystemTimeStamp()
{
- fileTime.dwHighDateTime = fileTime.dwLowDateTime = 0;
+ counterValue = 0;
}
};
-
-// Convert a wide Unicode string to an UTF8 string
-std::string UTF8_Encode_Windows(const std::wstring &wstr)
+class CSystemUtilsWindows : public CSystemUtils
{
- int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), NULL, 0, NULL, NULL);
- std::string strTo(size_needed, 0);
- WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), &strTo[0], size_needed, NULL, NULL);
- return strTo;
-}
-
-// Convert an UTF8 string to a wide Unicode String
-std::wstring UTF8_Decode_Windows(const std::string &str)
-{
- int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), NULL, 0);
- std::wstring wstrTo(size_needed, 0);
- MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), &wstrTo[0], size_needed);
- return wstrTo;
-}
-
-SystemDialogResult SystemDialog_Windows(SystemDialogType type, const std::string& title, const std::string& message)
-{
- unsigned int windowsType = 0;
- std::wstring windowsMessage = UTF8_Decode_Windows(message);
- std::wstring windowsTitle = UTF8_Decode_Windows(title);
-
- switch (type)
- {
- case SDT_INFO:
- default:
- windowsType = MB_ICONINFORMATION|MB_OK;
- break;
- case SDT_WARNING:
- windowsType = MB_ICONWARNING|MB_OK;
- break;
- case SDT_ERROR:
- windowsType = MB_ICONERROR|MB_OK;
- break;
- case SDT_YES_NO:
- windowsType = MB_ICONQUESTION|MB_YESNO;
- break;
- case SDT_OK_CANCEL:
- windowsType = MB_ICONWARNING|MB_OKCANCEL;
- break;
- }
+public:
+ virtual void Init() override;
- switch (MessageBoxW(NULL, windowsMessage.c_str(), windowsTitle.c_str(), windowsType))
- {
- case IDOK:
- return SDR_OK;
- case IDCANCEL:
- return SDR_CANCEL;
- case IDYES:
- return SDR_YES;
- case IDNO:
- return SDR_NO;
- default:
- break;
- }
+ virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
- return SDR_OK;
-}
+ virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
+ virtual long long GetTimeStampExactResolution() override;
+ virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
+ virtual std::string profileFileLocation() override;
+ virtual std::string savegameDirectoryLocation() override;
-void GetCurrentTimeStamp_Windows(SystemTimeStamp *stamp)
-{
- GetSystemTimeAsFileTime(&stamp->fileTime);
-}
+private:
+ std::string UTF8_Encode(const std::wstring &wstr);
+ std::wstring UTF8_Decode(const std::string &str);
-long long GetTimeStampExactResolution_Windows()
-{
- return 100ll;
-}
-
-long long TimeStampExactDiff_Windows(SystemTimeStamp *before, SystemTimeStamp *after)
-{
- long long tH = (1ll << 32) * (after->fileTime.dwHighDateTime - before->fileTime.dwHighDateTime);
- long long tL = after->fileTime.dwLowDateTime - before->fileTime.dwLowDateTime;
- return (tH + tL) * 100ll;
-}
+protected:
+ long long m_counterFrequency;
+};
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 022bb69..d5a03b4 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -5,14 +5,21 @@
#cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
-#cmakedefine USE_GLEW @USE_GLEW@
#cmakedefine GLEW_STATIC
+#cmakedefine OPENAL_SOUND
+
+#cmakedefine USE_SDL_MAIN @USE_SDL_MAIN@
+
+#ifdef USE_SDL_MAIN
+#define SDL_MAIN_FUNC SDL_main
+#else
+#define SDL_MAIN_FUNC main
+#endif
+
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
#define COLOBOT_CODENAME "@COLOBOT_VERSION_CODENAME@"
#define COLOBOT_FULLNAME "Colobot @COLOBOT_VERSION_CODENAME@"
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
-
-#cmakedefine OPENAL_SOUND
diff --git a/src/common/event.cpp b/src/common/event.cpp
index b078dc5..ff3fbc7 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -17,12 +17,12 @@
#include "common/event.h"
-#include "common/iman.h"
#include "common/logger.h"
static EventType g_uniqueEventType = EVENT_USER;
+
EventType GetUniqueEventType()
{
int i = static_cast<int>(g_uniqueEventType+1);
@@ -32,11 +32,8 @@ EventType GetUniqueEventType()
-CEventQueue::CEventQueue(CInstanceManager* iMan)
+CEventQueue::CEventQueue()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_EVENT, this);
-
Flush();
}
diff --git a/src/common/event.h b/src/common/event.h
index 169f0d0..153b732 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -27,8 +27,6 @@
#include "math/point.h"
#include "math/vector.h"
-class CInstanceManager;
-
/**
\enum EventType
@@ -411,7 +409,8 @@ enum EventType
EVENT_OBJECT_BNUCLEAR = 1060,
EVENT_OBJECT_BPARA = 1061,
EVENT_OBJECT_BINFO = 1062,
- EVENT_OBJECT_BXXXX = 1063,
+ EVENT_OBJECT_BDESTROYER = 1063,
+ //EVENT_OBJECT_BXXXX = 1063,
EVENT_OBJECT_GFLAT = 1070,
EVENT_OBJECT_FCREATE = 1071,
EVENT_OBJECT_FDELETE = 1072,
@@ -445,6 +444,7 @@ enum EventType
EVENT_OBJECT_TERRAFORM = 1201,
EVENT_OBJECT_FIRE = 1202,
EVENT_OBJECT_FIREANT = 1203,
+ EVENT_OBJECT_SPIDEREXPLO= 1204,
EVENT_OBJECT_RECOVER = 1220,
EVENT_OBJECT_BEGSHIELD = 1221,
EVENT_OBJECT_ENDSHIELD = 1222,
@@ -761,7 +761,7 @@ public:
public:
//! Object's constructor
- CEventQueue(CInstanceManager* iMan);
+ CEventQueue();
//! Object's destructor
~CEventQueue();
@@ -773,7 +773,6 @@ public:
bool GetEvent(Event &event);
protected:
- CInstanceManager* m_iMan;
Event m_fifo[MAX_EVENT_QUEUE];
int m_head;
int m_tail;
diff --git a/src/common/global.h b/src/common/global.h
index 0b2d8ec..7a5fdfd 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -213,6 +213,7 @@ enum BuildType
BUILD_LABO = (1<<10), //! < laboratory
BUILD_PARA = (1<<11), //! < lightning protection
BUILD_INFO = (1<<12), //! < information terminal
+ BUILD_DESTROYER = (1<<13), //! < Destroyer
BUILD_GFLAT = (1<<16), //! < flat floor
BUILD_FLAG = (1<<17) //! < puts / removes colored flag
};
diff --git a/src/common/image.cpp b/src/common/image.cpp
index ef8097e..db14797 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -22,8 +22,8 @@
#include <string.h>
#include <assert.h>
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
+#include <SDL.h>
+#include <SDL_image.h>
#include <png.h>
@@ -190,6 +190,15 @@ Math::IntPoint CImage::GetSize() const
return Math::IntPoint(m_data->surface->w, m_data->surface->h);
}
+/** Image must be valid. */
+void CImage::Fill(Gfx::IntColor color)
+{
+ assert(m_data != nullptr);
+
+ Uint32 c = SDL_MapRGBA(m_data->surface->format, color.r, color.g, color.b, color.a);
+ SDL_FillRect(m_data->surface, nullptr, c);
+}
+
/**
* Image must be valid and pixel coords in valid range.
*
diff --git a/src/common/image.h b/src/common/image.h
index d23a6fa..d9da75b 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -79,6 +79,9 @@ public:
//! Returns the image size
Math::IntPoint GetSize() const;
+ //! Fills the whole image with given color
+ void Fill(Gfx::IntColor color);
+
//! Sets the color at given pixel
void SetPixel(Math::IntPoint pixel, Gfx::Color color);
diff --git a/src/common/iman.cpp b/src/common/iman.cpp
index 6a0a9eb..e1400fd 100644
--- a/src/common/iman.cpp
+++ b/src/common/iman.cpp
@@ -20,22 +20,9 @@
#include <cassert>
-template<> CInstanceManager* CSingleton<CInstanceManager>::mInstance = nullptr;
+template<> CInstanceManager* CSingleton<CInstanceManager>::m_instance = nullptr;
-CInstanceManager& CInstanceManager::GetInstance()
-{
- assert(mInstance);
- return *mInstance;
-}
-
-
-CInstanceManager* CInstanceManager::GetInstancePointer()
-{
- assert(mInstance);
- return mInstance;
-}
-
CInstanceManager::CInstanceManager()
{
for (int i = 0; i < CLASS_MAX; i++)
diff --git a/src/common/iman.h b/src/common/iman.h
index 53caed7..faabd0c 100644
--- a/src/common/iman.h
+++ b/src/common/iman.h
@@ -30,67 +30,23 @@
* \brief Type of class managed by CInstanceManager
*/
-// TODO: remove unnecessary, refactor to singletons, move to CRobotMain, keep others?
-
+/*
+ * TODO: Non-unique classes have already been removed.
+ * The other class instances along with CInstanceManager will be removed in due course.
+ */
enum ManagedClassType
{
- //! CEventQueue
- CLASS_EVENT = 1,
- //! Ui::CInterface
- CLASS_INTERFACE = 2,
- //! CRobotMain
- CLASS_MAIN = 3,
- //! Gfx::CEngine
- CLASS_ENGINE = 4,
- //! Gfx::CTerrain
- CLASS_TERRAIN = 5,
//! CObject
- CLASS_OBJECT = 6,
+ CLASS_OBJECT = 0,
//! CPhysics
- CLASS_PHYSICS = 7,
+ CLASS_PHYSICS = 1,
//! CBrain
- CLASS_BRAIN = 8,
- //! Gfx::CCamera
- CLASS_CAMERA = 9,
- //! Gfx::CLightManager
- CLASS_LIGHT = 10,
- //! Gfx::CParticle
- CLASS_PARTICULE = 11,
- //! CAuto; TODO: remove (unused)
- CLASS_AUTO = 12,
- //! Ui::CDisplayText
- CLASS_DISPLAYTEXT = 13,
+ CLASS_BRAIN = 2,
//! Gfx::CPyro
- CLASS_PYRO = 14,
- //! Ui::CScript; TODO: remove (unused)
- CLASS_SCRIPT = 15,
- //! Gfx::CText
- CLASS_TEXT = 16,
- //! Ui::CStudio, Ui::CDisplayText; TODO: remove (unused)
- CLASS_STUDIO = 17,
- //! Gfx::CWater
- CLASS_WATER = 18,
- //! Gfx::CCloud; TODO: remove (unused)
- CLASS_CLOUD = 19,
- //! CMotion; TODO: remove (unused)
- CLASS_MOTION = 20,
- //! CSoundInterface
- CLASS_SOUND = 21,
- //! Gfx::CPlanet
- CLASS_PLANET = 22,
- //! CTaskManager; TODO: remove (unused)
- CLASS_TASKMANAGER = 23,
- //! Ui::CMainDialog; TODO: remove (unused)
- CLASS_DIALOG = 24,
- //! Ui::CMainMap; TODO: remove (unused)
- CLASS_MAP = 25,
- //! Ui::CMainShort, CMainMovie; TODO: remove (unused)
- CLASS_SHORT = 26,
- //! Gfx::CLightning; TODO: remove (unused)
- CLASS_BLITZ = 27,
+ CLASS_PYRO = 3,
//! Maximum (number of managed classes)
- CLASS_MAX = 30
+ CLASS_MAX = 4
};
@@ -116,7 +72,7 @@ class CInstanceManager : public CSingleton<CInstanceManager>
{
public:
CInstanceManager();
- ~CInstanceManager();
+ virtual ~CInstanceManager();
//! Remove all managed instances
void Flush();
@@ -129,9 +85,6 @@ public:
//! Seeks a class instance of given type
void* SearchInstance(ManagedClassType classType, int rank=0);
- static CInstanceManager& GetInstance();
- static CInstanceManager* GetInstancePointer();
-
protected:
//! Fills holes in instance table
void Compress(ManagedClassType classType);
diff --git a/src/common/key.h b/src/common/key.h
index 196f66d..84ee618 100644
--- a/src/common/key.h
+++ b/src/common/key.h
@@ -22,7 +22,7 @@
#pragma once
-#include "SDL/SDL_keysym.h"
+#include <SDL_keysym.h>
/* Key definitions are specially defined here so that it is clear in other parts of the code
that these are used. It is to avoid having SDL-related enum values or #defines lying around
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
index 5a78433..8bc4cef 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
@@ -20,7 +20,7 @@
#include <stdio.h>
-template<> CLogger* CSingleton<CLogger>::mInstance = nullptr;
+template<> CLogger* CSingleton<CLogger>::m_instance = nullptr;
CLogger::CLogger()
@@ -36,25 +36,37 @@ CLogger::~CLogger()
}
-void CLogger::Log(LogType type, const char *str, va_list args)
+void CLogger::Log(LogLevel type, const char* str, va_list args)
{
if (type < mLogLevel)
return;
- switch (type) {
- case LOG_TRACE: fprintf(IsOpened() ? mFile : stderr, "[TRACE]: "); break;
- case LOG_DEBUG: fprintf(IsOpened() ? mFile : stderr, "[DEBUG]: "); break;
- case LOG_WARN: fprintf(IsOpened() ? mFile : stderr, "[WARN]: "); break;
- case LOG_INFO: fprintf(IsOpened() ? mFile : stderr, "[INFO]: "); break;
- case LOG_ERROR: fprintf(IsOpened() ? mFile : stderr, "[ERROR]: "); break;
- default: break;
+ switch (type)
+ {
+ case LOG_TRACE:
+ fprintf(IsOpened() ? mFile : stderr, "[TRACE]: ");
+ break;
+ case LOG_DEBUG:
+ fprintf(IsOpened() ? mFile : stderr, "[DEBUG]: ");
+ break;
+ case LOG_WARN:
+ fprintf(IsOpened() ? mFile : stderr, "[WARN]: ");
+ break;
+ case LOG_INFO:
+ fprintf(IsOpened() ? mFile : stderr, "[INFO]: ");
+ break;
+ case LOG_ERROR:
+ fprintf(IsOpened() ? mFile : stderr, "[ERROR]: ");
+ break;
+ default:
+ break;
}
vfprintf(IsOpened() ? mFile : stderr, str, args);
}
-void CLogger::Trace(const char *str, ...)
+void CLogger::Trace(const char* str, ...)
{
va_list args;
va_start(args, str);
@@ -63,7 +75,7 @@ void CLogger::Trace(const char *str, ...)
}
-void CLogger::Debug(const char *str, ...)
+void CLogger::Debug(const char* str, ...)
{
va_list args;
va_start(args, str);
@@ -72,7 +84,7 @@ void CLogger::Debug(const char *str, ...)
}
-void CLogger::Info(const char *str, ...)
+void CLogger::Info(const char* str, ...)
{
va_list args;
va_start(args, str);
@@ -81,7 +93,7 @@ void CLogger::Info(const char *str, ...)
}
-void CLogger::Warn(const char *str, ...)
+void CLogger::Warn(const char* str, ...)
{
va_list args;
va_start(args, str);
@@ -90,7 +102,7 @@ void CLogger::Warn(const char *str, ...)
}
-void CLogger::Error(const char *str, ...)
+void CLogger::Error(const char* str, ...)
{
va_list args;
va_start(args, str);
@@ -99,7 +111,7 @@ void CLogger::Error(const char *str, ...)
}
-void CLogger::Message(const char *str, ...)
+void CLogger::Message(const char* str, ...)
{
va_list args;
va_start(args, str);
@@ -118,6 +130,7 @@ void CLogger::SetOutputFile(std::string filename)
void CLogger::Open()
{
mFile = fopen(mFilename.c_str(), "w");
+
if (mFile == NULL)
fprintf(stderr, "Could not create file %s\n", mFilename.c_str());
}
@@ -136,6 +149,45 @@ bool CLogger::IsOpened()
}
-void CLogger::SetLogLevel(LogType type) {
+void CLogger::SetLogLevel(LogLevel type)
+{
mLogLevel = type;
}
+
+
+bool CLogger::ParseLogLevel(const std::string& str, LogLevel& logLevel)
+{
+ if (str == "trace")
+ {
+ logLevel = LOG_TRACE;
+ return true;
+ }
+ else if (str == "debug")
+ {
+ logLevel = LOG_DEBUG;
+ return true;
+ }
+ else if (str == "info")
+ {
+ logLevel = LOG_INFO;
+ return true;
+ }
+ else if (str == "warn")
+ {
+ logLevel = LOG_WARN;
+ return true;
+ }
+ else if (str == "error")
+ {
+ logLevel = LOG_ERROR;
+ return true;
+ }
+ else if (str == "none")
+ {
+ logLevel = LOG_NONE;
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/src/common/logger.h b/src/common/logger.h
index 198e5e5..769f548 100644
--- a/src/common/logger.h
+++ b/src/common/logger.h
@@ -31,10 +31,10 @@
/**
* \public
- * \enum LogType common/logger.h
+ * \enum LogLevel common/logger.h
* \brief Enum representing log level
**/
-enum LogType
+enum LogLevel
{
LOG_TRACE = 1, /*!< lowest level, execution tracing */
LOG_DEBUG = 2, /*!< debugging messages */
@@ -53,65 +53,74 @@ enum LogType
*/
class CLogger : public CSingleton<CLogger>
{
- public:
- CLogger();
- ~CLogger();
-
- /** Write message to console or file
- * \param str - message to write
- * \param ... - additional arguments
- */
- void Message(const char *str, ...);
-
- /** Write message to console or file with LOG_TRACE level
- * \param str - message to write
- * \param ... - additional arguments
- */
- void Trace(const char *str, ...);
-
- /** Write message to console or file with LOG_DEBUG level
- * \param str - message to write
- * \param ... - additional arguments
- */
- void Debug(const char *str, ...);
-
- /** Write message to console or file with LOG_INFO level
- * \param str - message to write
- * \param ... - additional arguments
- */
- void Info(const char *str, ...);
-
- /** Write message to console or file with LOG_WARN level
- * \param str - message to write
- * \param ... - additional arguments
- */
- void Warn(const char *str, ...);
-
- /** Write message to console or file with LOG_ERROR level
- * \param str - message to write
- * \param ... - additional arguments
- */
- void Error(const char *str, ...);
-
- /** Set output file to write logs to
- * \param filename - output file to write to
- */
- void SetOutputFile(std::string filename);
-
- /** Set log level. Logs with level below will not be shown
- * \param level - minimum log level to write
- */
- void SetLogLevel(LogType level);
-
- private:
- std::string mFilename;
- FILE *mFile;
- LogType mLogLevel;
-
- void Open();
- void Close();
- bool IsOpened();
- void Log(LogType type, const char* str, va_list args);
+public:
+ CLogger();
+ ~CLogger();
+
+ /** Write message to console or file
+ * \param str - message to write
+ * \param ... - additional arguments
+ */
+ void Message(const char *str, ...);
+
+ /** Write message to console or file with LOG_TRACE level
+ * \param str - message to write
+ * \param ... - additional arguments
+ */
+ void Trace(const char *str, ...);
+
+ /** Write message to console or file with LOG_DEBUG level
+ * \param str - message to write
+ * \param ... - additional arguments
+ */
+ void Debug(const char *str, ...);
+
+ /** Write message to console or file with LOG_INFO level
+ * \param str - message to write
+ * \param ... - additional arguments
+ */
+ void Info(const char *str, ...);
+
+ /** Write message to console or file with LOG_WARN level
+ * \param str - message to write
+ * \param ... - additional arguments
+ */
+ void Warn(const char *str, ...);
+
+ /** Write message to console or file with LOG_ERROR level
+ * \param str - message to write
+ * \param ... - additional arguments
+ */
+ void Error(const char *str, ...);
+
+ /** Set output file to write logs to
+ * \param filename - output file to write to
+ */
+ void SetOutputFile(std::string filename);
+
+ /** Set log level. Logs with level below will not be shown
+ * \param level - minimum log level to write
+ */
+ void SetLogLevel(LogLevel level);
+
+ /** Parses string as a log level
+ * \param str string to parse
+ * \param logLevel result log level
+ *
+ * Valid values are "trace", "debug", "info", "warn", "error" and "none".
+ * On invalid value, returns \c false.
+ */
+ static bool ParseLogLevel(const std::string& str, LogLevel& logLevel);
+
+private:
+ std::string mFilename;
+ FILE *mFile;
+ LogLevel mLogLevel;
+
+ void Open();
+ void Close();
+ bool IsOpened();
+ void Log(LogLevel type, const char* str, va_list args);
};
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 2bce3b8..b96abca 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -25,10 +25,6 @@
#include <time.h>
-static bool g_bUserDir = false;
-static char g_userDir[100] = "";
-
-
// Returns a non-accented letter.
char GetNoAccent(char letter)
@@ -234,72 +230,11 @@ void TimeToAscii(time_t time, char *buffer)
#endif*/
}
-
-// Makes a copy of a file.
-
-bool Xfer(char* src, char* dst)
-{
- FILE *fs, *fd;
- char *buffer;
- int len;
-
- fs = fopen(src, "rb");
- if ( fs == 0 )
- {
- return false;
- }
-
- fd = fopen(dst, "wb");
- if ( fd == 0 )
- {
- fclose(fs);
- return false;
- }
-
- buffer = static_cast<char*>(malloc(10000));
-
- while ( true )
- {
- len = fread(buffer, 1, 10000, fs);
- if ( len == 0 ) break;
- fwrite(buffer, 1, len, fd);
- }
-
- free(buffer);
- fclose(fs);
- fclose(fd);
- return true;
-}
-
-// Copy a file into the temporary folder.
-
-bool CopyFileToTemp(char* filename)
-{
- char src[100];
- char dst[100];
- char save[100];
-
- UserDir(src, filename, "textures");
-
- strcpy(save, g_userDir);
- strcpy(g_userDir, "temp");
- UserDir(dst, filename, "textures");
- strcpy(g_userDir, save);
-
- //_mkdir("temp");
- system("mkdir temp");
-
- if ( !Xfer(src, dst) ) return false;
-
- strcpy(filename, dst);
- return true;
-}
-
// Copy a list of numbered files into the temporary folder.
bool CopyFileListToTemp(char* filename, int* list, int total)
{
- char name[100];
+ /*char name[100];
char ext[10];
char file[100];
char save[100];
@@ -329,8 +264,8 @@ bool CopyFileListToTemp(char* filename, int* list, int total)
UserDir(file, filename, "textures");
strcpy(filename, file);
strcpy(g_userDir, save);
-
- return true;
+*/
+ return false;
}
@@ -342,56 +277,3 @@ void AddExt(char* filename, const char* ext)
strcat(filename, ext);
}
-
-// Specifies the user folder.
-
-void UserDir(bool bUser, const char* dir)
-{
- g_bUserDir = bUser;
- strcpy(g_userDir, dir);
-}
-
-// Replaces the string %user% by the user folder.
-// in: dir = "%user%toto.txt"
-// def = "abc\"
-// out: buffer = "abc\toto.txt"
-
-void UserDir(char* buffer, const char* dir, const char* def)
-{
- char ddir[100];
- const char* add;
-
- if ( strstr(dir, "\\") == 0 && def[0] != 0 )
- {
- sprintf(ddir, "%s\\%s", def, dir);
- }
- else
- {
- strcpy(ddir, dir);
- }
- dir = ddir;
-
- while ( *dir != 0 )
- {
- if ( dir[0] == '%' &&
- dir[1] == 'u' &&
- dir[2] == 's' &&
- dir[3] == 'e' &&
- dir[4] == 'r' &&
- dir[5] == '%' ) // %user% ?
- {
- if ( g_bUserDir ) add = g_userDir;
- else add = def;
-
- while ( *add != 0 )
- {
- *buffer++ = *add++;
- }
- dir += 6; // jumps to %user%
- continue;
- }
-
- *buffer++ = *dir++;
- }
- *buffer = 0;
-}
diff --git a/src/common/misc.h b/src/common/misc.h
index f210706..e2ddc44 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -29,8 +29,5 @@ extern char GetToLower(char letter);
extern void TimeToAscii(time_t time, char *buffer);
-extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, const char* ext);
-extern void UserDir(bool bUser, const char* dir);
-extern void UserDir(char* buffer, const char* dir, const char* def);
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 5432489..654648d 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -19,13 +19,15 @@
#include "common/logger.h"
+#include "app/system.h"
+
#include <utility>
#include <cstring>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/regex.hpp>
-template<> CProfile* CSingleton<CProfile>::mInstance = nullptr;
+template<> CProfile* CSingleton<CProfile>::m_instance = nullptr;
namespace bp = boost::property_tree;
@@ -41,7 +43,7 @@ CProfile::~CProfile()
{
try
{
- bp::ini_parser::write_ini("colobot.ini", m_propertyTree);
+ bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree);
}
catch (std::exception & e)
{
@@ -55,7 +57,7 @@ bool CProfile::InitCurrentDirectory()
{
try
{
- bp::ini_parser::read_ini("colobot.ini", m_propertyTree);
+ bp::ini_parser::read_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree);
}
catch (std::exception & e)
{
@@ -182,3 +184,48 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section,
return ret_list;
}
+
+
+void CProfile::SetUserDir(std::string dir)
+{
+ m_userDirectory = dir;
+}
+
+
+std::string CProfile::GetUserBasedPath(std::string dir, std::string default_dir)
+{
+ std::string path = dir;
+ boost::replace_all(path, "\\", "/");
+ if (dir.find("/") == std::string::npos) {
+ path = default_dir + "/" + dir;
+ }
+
+ if (m_userDirectory.length() > 0) {
+ boost::replace_all(path, "%user%", m_userDirectory);
+ } else {
+ boost::replace_all(path, "%user%", default_dir);
+ }
+
+ return fs::path(path).make_preferred().string();
+}
+
+
+bool CProfile::CopyFileToTemp(std::string filename)
+{
+ std::string src, dst;
+ std::string tmp_user_dir = m_userDirectory;
+
+ src = GetUserBasedPath(filename, "textures");
+ SetUserDir("temp");
+ dst = GetUserBasedPath(filename, "textures");
+ SetUserDir(tmp_user_dir);
+
+ fs::create_directory(fs::path(dst).parent_path().make_preferred().string());
+ fs::copy_file(src, dst, fs::copy_option::overwrite_if_exists);
+ if (fs::exists(dst)) {
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/src/common/profile.h b/src/common/profile.h
index 9bc6c37..7f99d81 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -21,14 +21,17 @@
#pragma once
-
#include "common/singleton.h"
#include <boost/property_tree/ptree.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string/replace.hpp>
#include <string>
#include <vector>
+namespace fs = boost::filesystem;
+
/**
* \class CProfile
@@ -101,10 +104,30 @@ class CProfile : public CSingleton<CProfile>
* \return vector of values
*/
std::vector< std::string > GetLocalProfileSection(std::string section, std::string key);
+
+ /** Sets current user directory
+ * \param dir
+ */
+ void SetUserDir(std::string dir);
+
+ /** Returns path based on current user. Replaces %user% in path with current user dir or
+ * uses default_dir param if no user dir is specified
+ * \param dir
+ * \param default_dir
+ * \return path
+ */
+ std::string GetUserBasedPath(std::string dir, std::string default_dir);
+
+ /** opy a file into the temporary folder.
+ * \param filename
+ * \return true on success
+ */
+ bool CopyFileToTemp(std::string filename);
private:
boost::property_tree::ptree m_propertyTree;
bool m_profileNeedSave;
+ std::string m_userDirectory;
};
//! Global function to get profile instance
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 4c56ae5..729a883 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -30,7 +30,7 @@
#include "object/robotmain.h"
#include <libintl.h>
-#include <SDL/SDL_keyboard.h>
+#include <SDL_keyboard.h>
const char* stringsText[RT_MAX] = { nullptr };
const char* stringsEvent[EVENT_STD_MAX] = { nullptr };
@@ -308,6 +308,7 @@ void InitializeRestext()
stringsEvent[EVENT_OBJECT_BNUCLEAR] = "Build a nuclear power plant";
stringsEvent[EVENT_OBJECT_BPARA] = "Build a lightning conductor";
stringsEvent[EVENT_OBJECT_BINFO] = "Build a exchange post";
+ stringsEvent[EVENT_OBJECT_BDESTROYER] = "Build a destroyer";
stringsEvent[EVENT_OBJECT_GFLAT] = "Show if the ground is flat";
stringsEvent[EVENT_OBJECT_FCREATE] = "Plant a flag";
stringsEvent[EVENT_OBJECT_FDELETE] = "Remove a flag";
@@ -351,6 +352,7 @@ void InitializeRestext()
stringsEvent[EVENT_OBJECT_SEARCH] = "Sniff (\\key action;)";
stringsEvent[EVENT_OBJECT_TERRAFORM] = "Thump (\\key action;)";
stringsEvent[EVENT_OBJECT_FIRE] = "Shoot (\\key action;)";
+ stringsEvent[EVENT_OBJECT_SPIDEREXPLO] = "Explode (\\key action;)";
stringsEvent[EVENT_OBJECT_RECOVER] = "Recycle (\\key action;)";
stringsEvent[EVENT_OBJECT_BEGSHIELD] = "Extend shield (\\key action;)";
stringsEvent[EVENT_OBJECT_ENDSHIELD] = "Withdraw shield (\\key action;)";
diff --git a/src/common/singleton.h b/src/common/singleton.h
index c1b28d9..25e1648 100644
--- a/src/common/singleton.h
+++ b/src/common/singleton.h
@@ -26,34 +26,51 @@
template<typename T> class CSingleton
{
- protected:
- static T* mInstance;
-
- public:
- static T& GetInstance() {
- assert(mInstance != nullptr);
- return *mInstance;
- }
-
- static T* GetInstancePointer() {
- assert(mInstance != nullptr);
- return mInstance;
- }
-
- static bool IsCreated() {
- return mInstance != nullptr;
- }
-
- CSingleton() {
- assert(mInstance == nullptr);
- mInstance = static_cast<T *>(this);
- }
-
- virtual ~CSingleton() {
- mInstance = nullptr;
- }
-
- private:
- CSingleton& operator=(const CSingleton<T> &);
- CSingleton(const CSingleton<T> &);
+protected:
+ static T* m_instance;
+
+public:
+ static T& GetInstance()
+ {
+ assert(m_instance != nullptr);
+ return *m_instance;
+ }
+
+ static T* GetInstancePointer()
+ {
+ assert(m_instance != nullptr);
+ return m_instance;
+ }
+
+ static bool IsCreated()
+ {
+ return m_instance != nullptr;
+ }
+
+ CSingleton()
+ {
+ assert(m_instance == nullptr);
+ m_instance = static_cast<T *>(this);
+ }
+
+ virtual ~CSingleton()
+ {
+ m_instance = nullptr;
+ }
+
+ #ifdef TESTS
+ static void ReplaceInstance(T* newInstance)
+ {
+ assert(newInstance != nullptr);
+
+ if (m_instance != nullptr)
+ delete m_instance;
+
+ m_instance = newInstance;
+ }
+ #endif
+
+private:
+ CSingleton& operator=(const CSingleton<T> &);
+ CSingleton(const CSingleton<T> &);
};
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt
deleted file mode 100644
index 70dac1f..0000000
--- a/src/common/test/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-include_directories(
-.
-../..
-../../..
-${GTEST_INCLUDE_DIR}
-)
-
-
-add_executable(image_test ../image.cpp image_test.cpp)
-target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES})
-
-#add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp)
-#target_link_libraries(profile_test gtest ${Boost_LIBRARIES})
-
-#add_test(profile_test ./profile_test)
diff --git a/src/common/test/colobot.ini b/src/common/test/colobot.ini
deleted file mode 100644
index 2ca37ee..0000000
--- a/src/common/test/colobot.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[test_float]
-float_value=1.5
-
-[test_string]
-string_value=Hello world
-
-[test_int]
-int_value=42
-
-[test_multi]
-entry1=1
-entry2=2
-entry3=3
-entry4=4
-entry5=5
diff --git a/src/common/test/image_test.cpp b/src/common/test/image_test.cpp
deleted file mode 100644
index a98c9cc..0000000
--- a/src/common/test/image_test.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "../image.h"
-
-#include <SDL/SDL.h>
-#include <stdio.h>
-
-/* For now, just a simple test: loading a file from image
- * and saving it to another in PNG. */
-
-int main(int argc, char *argv[])
-{
- if (argc != 3)
- {
- printf("Usage: %s in_image out_image\n", argv[0]);
- return 0;
- }
-
- CImage image;
-
- if (! image.Load(argv[1]))
- {
- std::string err = image.GetError();
- printf("Error loading '%s': %s\n", err.c_str());
- return 1;
- }
- Gfx::Color color;
- std::string str;
-
- color = image.GetPixel(Math::IntPoint(0, 0));
- str = color.ToString();
- printf("pixel @ (0,0): %s\n", str.c_str());
-
- color = image.GetPixel(Math::IntPoint(0, 1));
- str = color.ToString();
- printf("pixel @ (0,1): %s\n", str.c_str());
-
- color = image.GetPixel(Math::IntPoint(1, 0));
- str = color.ToString();
- printf("pixel @ (1,0): %s\n", str.c_str());
-
- color = image.GetPixel(Math::IntPoint(1, 1));
- str = color.ToString();
- printf("pixel @ (1,1): %s\n", str.c_str());
-
- image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f));
- image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f));
- image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f));
- image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f));
-
- if (! image.SavePNG(argv[2]))
- {
- std::string err = image.GetError();
- printf("Error saving PNG '%s': %s\n", err.c_str());
- return 2;
- }
-
- return 0;
-}
diff --git a/src/common/test/profile_test.cpp b/src/common/test/profile_test.cpp
deleted file mode 100644
index 6236083..0000000
--- a/src/common/test/profile_test.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "../profile.h"
-#include "../logger.h"
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <gtest/gtest.h>
-
-
-class CProfileTest : public testing::Test
-{
-protected:
- CLogger m_logger;
- CProfile m_profile;
-
-};
-
-TEST_F(CProfileTest, ReadTest)
-{
- ASSERT_TRUE(m_profile.InitCurrentDirectory()); // load colobot.ini file
-
- std::string result;
- ASSERT_TRUE(m_profile.GetLocalProfileString("test_string", "string_value", result));
- ASSERT_STREQ("Hello world", result.c_str());
-
- int int_value;
- ASSERT_TRUE(m_profile.GetLocalProfileInt("test_int", "int_value", int_value));
- ASSERT_EQ(42, int_value);
-
- float float_value;
- ASSERT_TRUE(m_profile.GetLocalProfileFloat("test_float", "float_value", float_value));
- ASSERT_FLOAT_EQ(1.5, float_value);
-
- std::vector<std::string> list;
- list = m_profile.GetLocalProfileSection("test_multi", "entry");
- ASSERT_EQ(5u, list.size());
-}
-
-int main(int argc, char *argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
diff --git a/src/desktop/CMakeLists.txt b/src/desktop/CMakeLists.txt
index ce4f48d..9a00dd4 100644
--- a/src/desktop/CMakeLists.txt
+++ b/src/desktop/CMakeLists.txt
@@ -39,7 +39,7 @@ endif()
# Create manpage from pod-formatted file
find_program(POD2MAN pod2man)
-if(POD2MAN)
+if(POD2MAN AND (NOT MSYS))
set(COLOBOT_MANPAGE_SECTION 6)
macro(podman)
diff --git a/src/desktop/colobot.desktop.in b/src/desktop/colobot.desktop.in
index 74378fd..9b09803 100644
--- a/src/desktop/colobot.desktop.in
+++ b/src/desktop/colobot.desktop.in
@@ -3,3 +3,4 @@ Version=1.0
Type=Application
Exec=colobot
Icon=colobot
+Categories=Education;Robotics;Game;AdventureGame;StrategyGame;
diff --git a/src/desktop/colobot.pod b/src/desktop/colobot.pod
index 2fc3a00..ae67e72 100644
--- a/src/desktop/colobot.pod
+++ b/src/desktop/colobot.pod
@@ -1,6 +1,6 @@
=encoding utf8
-=head1 COLOBOT
+=head1 NAME
colobot - educational programming strategy game
diff --git a/src/desktop/po/colobot-desktop.pot b/src/desktop/po/colobot-desktop.pot
index 17e60c3..94eb85a 100644
--- a/src/desktop/po/colobot-desktop.pot
+++ b/src/desktop/po/colobot-desktop.pot
@@ -7,7 +7,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-12-27 10:59+0100\n"
+"POT-Creation-Date: 2013-01-20 14:26+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -33,7 +33,7 @@ msgstr ""
#. type: =head1
#: colobot.pod:3
-msgid "COLOBOT"
+msgid "NAME"
msgstr ""
#. type: textblock
diff --git a/src/desktop/po/fr.po b/src/desktop/po/fr.po
index 4709d49..40fa9e1 100644
--- a/src/desktop/po/fr.po
+++ b/src/desktop/po/fr.po
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-12-27 10:55+0100\n"
+"POT-Creation-Date: 2013-01-20 14:26+0100\n"
"PO-Revision-Date: 2012-12-27 11:00+0100\n"
"Last-Translator: Didier Raboud <odyx@debian.org>\n"
"Language-Team: none\n"
@@ -33,8 +33,8 @@ msgstr "Colonise avec des roBots"
#. type: =head1
#: colobot.pod:3
-msgid "COLOBOT"
-msgstr "COLOBOT"
+msgid "NAME"
+msgstr "NOM"
#. type: textblock
#: colobot.pod:5
diff --git a/src/graphics/core/color.h b/src/graphics/core/color.h
index 7cbd175..5d059e5 100644
--- a/src/graphics/core/color.h
+++ b/src/graphics/core/color.h
@@ -76,6 +76,16 @@ struct Color
{
return ! this->operator==(other);
}
+
+ inline Color operator*(float scale) const
+ {
+ Color c = *this;
+ c.r *= scale;
+ c.g *= scale;
+ c.b *= scale;
+ c.a *= scale;
+ return c;
+ }
};
/**
diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h
index b6dd138..41d7796 100644
--- a/src/graphics/core/device.h
+++ b/src/graphics/core/device.h
@@ -104,8 +104,7 @@ enum RenderState
RENDER_STATE_DEPTH_TEST,
RENDER_STATE_DEPTH_WRITE,
RENDER_STATE_ALPHA_TEST,
- RENDER_STATE_CULLING,
- RENDER_STATE_DITHERING
+ RENDER_STATE_CULLING
};
/**
@@ -204,22 +203,22 @@ enum PrimitiveType
};
/**
- * \enum IntersectPlane
- * \brief Intersection plane of projection volume
+ * \enum FrustumPlane
+ * \brief Planes of frustum space
*
- * These flags can be OR'd together.
+ * Bitset of flags - can be OR'd together.
*/
-enum IntersectPlane
+enum FrustumPlane
{
- INTERSECT_PLANE_LEFT = 0x01,
- INTERSECT_PLANE_RIGHT = 0x02,
- INTERSECT_PLANE_TOP = 0x04,
- INTERSECT_PLANE_BOTTOM = 0x08,
- INTERSECT_PLANE_FRONT = 0x10,
- INTERSECT_PLANE_BACK = 0x20,
- INTERSECT_PLANE_ALL = INTERSECT_PLANE_LEFT | INTERSECT_PLANE_RIGHT |
- INTERSECT_PLANE_TOP | INTERSECT_PLANE_BOTTOM |
- INTERSECT_PLANE_FRONT | INTERSECT_PLANE_BACK
+ FRUSTUM_PLANE_LEFT = 0x01,
+ FRUSTUM_PLANE_RIGHT = 0x02,
+ FRUSTUM_PLANE_TOP = 0x04,
+ FRUSTUM_PLANE_BOTTOM = 0x08,
+ FRUSTUM_PLANE_FRONT = 0x10,
+ FRUSTUM_PLANE_BACK = 0x20,
+ FRUSTUM_PLANE_ALL = FRUSTUM_PLANE_LEFT | FRUSTUM_PLANE_RIGHT |
+ FRUSTUM_PLANE_TOP | FRUSTUM_PLANE_BOTTOM |
+ FRUSTUM_PLANE_FRONT | FRUSTUM_PLANE_BACK
};
/**
@@ -287,7 +286,7 @@ public:
virtual void DestroyAllTextures() = 0;
//! Returns the maximum number of multitexture stages
- virtual int GetMaxTextureCount() = 0;
+ virtual int GetMaxTextureStageCount() = 0;
//! Sets the texture at given texture stage
virtual void SetTexture(int index, const Texture &texture) = 0;
//! Sets the texture image by ID at given texture stage
@@ -313,10 +312,35 @@ public:
//! Renders primitive composed of vertices with multitexturing (2 textures)
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
- //! Renders primitive composed of vertices with color information
+ //! Renders primitive composed of vertices with solid color
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount) = 0;
- //! Tests whether a sphere intersects the 6 clipping planes of projection volume
+ //! Creates a static buffer composed of given primitives with single texture vertices
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
+
+ //! Creates a static buffer composed of given primitives with multitexturing
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
+
+ //! Creates a static buffer composed of given primitives with solid color
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
+
+ //! Updates the static buffer composed of given primitives with single texture vertices
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) = 0;
+
+ //! Updates the static buffer composed of given primitives with multitexturing
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) = 0;
+
+ //! Updates the static buffer composed of given primitives with solid color
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) = 0;
+
+ //! Draws a static buffer
+ virtual void DrawStaticBuffer(unsigned int bufferId) = 0;
+
+ //! Deletes a static buffer
+ virtual void DestroyStaticBuffer(unsigned int bufferId) = 0;
+
+ //! Tests whether a sphere is (partially) within the frustum volume
+ //! Returns a mask of frustum planes for which the test is positive
virtual int ComputeSphereVisibility(const Math::Vector &center, float radius) = 0;
//! Enables/disables the given render state
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index 2ee6be4..66e1503 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -44,23 +44,18 @@ namespace Gfx {
* - vertex coordinates (x,y,z) as Math::Vector,
* - normal coordinates (nx,ny,nz) as Math::Vector
* - texture coordinates (u,v) as Math::Point.
- *
- * Additional padding is provided to align to even multiplies of 4 floats for faster access.
*/
struct Vertex
{
Math::Vector coord;
- float pad1;
Math::Vector normal;
- float pad2;
Math::Point texCoord;
- float pad3, pad4;
explicit Vertex(Math::Vector aCoord = Math::Vector(),
Math::Vector aNormal = Math::Vector(),
Math::Point aTexCoord = Math::Point())
- : coord(aCoord), pad1(0.0f), normal(aNormal),
- pad2(0.0f),texCoord(aTexCoord), pad3(0.0f), pad4(0.0f) {}
+ : coord(aCoord), normal(aNormal),
+ texCoord(aTexCoord) {}
//! Returns a string "(c: [...], n: [...], tc: [...])"
@@ -81,18 +76,15 @@ struct Vertex
* It contains:
* - vertex coordinates (x,y,z) as Math::Vector,
* - RGBA color as Color
- *
- * Additional padding is provided to align to even multiplies of 4 floats for faster access.
*/
struct VertexCol
{
Math::Vector coord;
- float pad;
Color color;
explicit VertexCol(Math::Vector aCoord = Math::Vector(),
Color aColor = Color())
- : coord(aCoord), pad(0.0f), color(aColor) {}
+ : coord(aCoord), color(aColor) {}
//! Returns a string "(c: [...], col: [...])"
inline std::string ToString() const
@@ -111,15 +103,11 @@ struct VertexCol
*
* In addition to fields from Vector, it contains
* secondary texture coordinates (u2, v2) as Math::Point
- *
- * Additional padding is provided to align to even multiplies of 4 floats for faster access.
*/
struct VertexTex2
{
Math::Vector coord;
- float pad1;
Math::Vector normal;
- float pad2;
Math::Point texCoord;
Math::Point texCoord2;
@@ -127,7 +115,7 @@ struct VertexTex2
Math::Vector aNormal = Math::Vector(),
Math::Point aTexCoord = Math::Point(),
Math::Point aTexCoord2 = Math::Point())
- : coord(aCoord), pad1(0.0f), normal(aNormal), pad2(0.0f),
+ : coord(aCoord), normal(aNormal),
texCoord(aTexCoord), texCoord2(aTexCoord2) {}
//! Sets the fields from Vertex with texCoord2 = (0,0)
diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp
index d85194e..f65a59a 100644
--- a/src/graphics/engine/camera.cpp
+++ b/src/graphics/engine/camera.cpp
@@ -30,6 +30,7 @@
#include "math/geometry.h"
#include "object/object.h"
+#include "object/robotmain.h"
#include "physics/physics.h"
@@ -54,14 +55,13 @@ void SetTransparency(CObject* obj, float value)
-CCamera::CCamera(CInstanceManager* iMan)
+CCamera::CCamera()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_CAMERA, this);
+ m_engine = CEngine::GetInstancePointer();
+ m_water = m_engine->GetWater();
- m_engine = static_cast<CEngine*> ( m_iMan->SearchInstance(CLASS_ENGINE) );
- m_terrain = static_cast<CTerrain*>( m_iMan->SearchInstance(CLASS_TERRAIN) );
- m_water = static_cast<CWater*> ( m_iMan->SearchInstance(CLASS_WATER) );
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
m_type = CAM_TYPE_FREE;
m_smooth = CAM_SMOOTH_NORM;
@@ -227,11 +227,13 @@ void CCamera::SetType(CameraType type)
m_remotePan = 0.0f;
m_remoteZoom = 0.0f;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
{
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL)
break;
@@ -315,6 +317,7 @@ void CCamera::SetType(CameraType type)
if ( oType == OBJECT_PARA ) m_backDist = 180.0f;
if ( oType == OBJECT_SAFE ) m_backDist = 50.0f;
if ( oType == OBJECT_HUSTON ) m_backDist = 120.0f;
+ if ( oType == OBJECT_MOTHER ) m_backDist = 55.0f;
m_backMin = m_backDist/3.0f;
if ( oType == OBJECT_HUMAN ) m_backMin = 10.0f;
@@ -327,8 +330,8 @@ void CCamera::SetType(CameraType type)
if ( oType == OBJECT_HUSTON ) m_backMin = 80.0f;
}
- if ( type != CAM_TYPE_ONBOARD && m_cameraObj != 0 )
- m_cameraObj->SetGunGoalH(0.0f); // puts the cannon right
+ //if ( type != CAM_TYPE_ONBOARD && m_cameraObj != 0 )
+ // m_cameraObj->SetGunGoalH(0.0f); // puts the cannon right
if ( type == CAM_TYPE_ONBOARD )
m_focus = 1.50f; // Wide
@@ -880,9 +883,11 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
m_transparency = false;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0 ;i < 1000000; i++)
{
- CObject *obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject *obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL) break;
if (obj->GetTruck()) continue; // battery or cargo?
@@ -957,9 +962,11 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject *obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject *obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL) break;
if (obj == m_cameraObj) continue;
@@ -1649,7 +1656,7 @@ Math::Vector CCamera::ExcludeObject(Math::Vector eye, Math::Vector lookat,
/*
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == NULL)
break;
diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h
index 20d252d..0ffc2c2 100644
--- a/src/graphics/engine/camera.h
+++ b/src/graphics/engine/camera.h
@@ -28,8 +28,8 @@
#include "graphics/engine/engine.h"
-class CInstanceManager;
class CObject;
+class CRobotMain;
// Graphics module namespace
@@ -130,7 +130,7 @@ enum CameraOverEffect
class CCamera {
public:
- CCamera(CInstanceManager* iMan);
+ CCamera();
~CCamera();
//! Management of an event
@@ -258,8 +258,8 @@ protected:
void OverFrame(const Event &event);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
+ CRobotMain* m_main;
CTerrain* m_terrain;
CWater* m_water;
diff --git a/src/graphics/engine/cloud.cpp b/src/graphics/engine/cloud.cpp
index 0df0d12..d9ebf5a 100644
--- a/src/graphics/engine/cloud.cpp
+++ b/src/graphics/engine/cloud.cpp
@@ -18,12 +18,12 @@
#include "graphics/engine/cloud.h"
-#include "common/iman.h"
-
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
#include "graphics/engine/terrain.h"
+#include "object/robotmain.h"
+
#include "math/geometry.h"
@@ -37,11 +37,8 @@ const int CLOUD_LINE_PREALLOCATE_COUNT = 100;
const int CLOUD_SIZE_EXPAND = 4;
-CCloud::CCloud(CInstanceManager* iMan, CEngine* engine)
+CCloud::CCloud(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_CLOUD, this);
-
m_engine = engine;
m_terrain = nullptr;
@@ -55,7 +52,6 @@ CCloud::CCloud(CInstanceManager* iMan, CEngine* engine)
CCloud::~CCloud()
{
- m_iMan = nullptr;
m_engine = nullptr;
m_terrain = nullptr;
}
@@ -84,7 +80,7 @@ bool CCloud::EventFrame(const Event &event)
}
void CCloud::AdjustLevel(Math::Vector& pos, Math::Vector& eye, float deep,
- Math::Point& uv1, Math::Point& uv2)
+ Math::Point& uv1, Math::Point& uv2)
{
uv1.x = (pos.x+20000.0f)/1280.0f;
uv1.y = (pos.z+20000.0f)/1280.0f;
@@ -211,8 +207,8 @@ void CCloud::CreateLine(int x, int y, int len)
}
void CCloud::Create(const std::string& fileName,
- const Color& diffuse, const Color& ambient,
- float level)
+ const Color& diffuse, const Color& ambient,
+ float level)
{
m_diffuse = diffuse;
m_ambient = ambient;
@@ -225,7 +221,7 @@ void CCloud::Create(const std::string& fileName,
m_engine->LoadTexture(m_fileName);
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
m_wind = m_terrain->GetWind();
@@ -250,7 +246,6 @@ void CCloud::Flush()
m_level = 0.0f;
}
-
void CCloud::SetLevel(float level)
{
m_level = level;
diff --git a/src/graphics/engine/cloud.h b/src/graphics/engine/cloud.h
index 6f6985f..8f644f0 100644
--- a/src/graphics/engine/cloud.h
+++ b/src/graphics/engine/cloud.h
@@ -34,9 +34,6 @@
#include <string>
-class CInstanceManager;
-
-
// Graphics module namespace
namespace Gfx {
@@ -79,12 +76,13 @@ struct CloudLine
class CCloud
{
public:
- CCloud(CInstanceManager* iMan, CEngine* engine);
+ CCloud(CEngine* engine);
~CCloud();
bool EventProcess(const Event& event);
//! Removes all the clouds
void Flush();
+
//! Creates all areas of cloud
void Create(const std::string& fileName, const Color& diffuse, const Color& ambient, float level);
//! Draw the clouds
@@ -112,9 +110,8 @@ protected:
void CreateLine(int x, int y, int len);
protected:
- CInstanceManager* m_iMan;
- CEngine* m_engine;
- CTerrain* m_terrain;
+ CEngine* m_engine;
+ CTerrain* m_terrain;
bool m_enabled;
//! Overall level
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 3365b24..e2ef569 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -20,7 +20,6 @@
#include "app/app.h"
-#include "common/iman.h"
#include "common/image.h"
#include "common/key.h"
#include "common/logger.h"
@@ -43,69 +42,16 @@
#include "ui/interface.h"
+template<> Gfx::CEngine* CSingleton<Gfx::CEngine>::m_instance = nullptr;
// Graphics module namespace
namespace Gfx {
-
-// Initial size of various vectors
-const int OBJECT_PREALLOCATE_COUNT = 1200;
-const int SHADOW_PREALLOCATE_COUNT = 500;
-const int GROUNDSPOT_PREALLOCATE_COUNT = 100;
-
-const int LEVEL1_PREALLOCATE_COUNT = 50;
-const int LEVEL2_PREALLOCATE_COUNT = 100;
-const int LEVEL3_PREALLOCATE_COUNT = 5;
-const int LEVEL4_PREALLOCATE_COUNT = 100;
-const int LEVEL4_VERTEX_PREALLOCATE_COUNT = 200;
-
-
-EngineObjLevel1::EngineObjLevel1(bool used, const std::string& tex1Name, const std::string& tex2Name)
-{
- this->used = used;
- this->tex1Name = tex1Name;
- this->tex2Name = tex2Name;
-
- next.reserve(LEVEL2_PREALLOCATE_COUNT);
-}
-
-EngineObjLevel2::EngineObjLevel2(bool used, int objRank)
-{
- this->used = used;
- this->objRank = objRank;
-
- next.reserve(LEVEL3_PREALLOCATE_COUNT);
-}
-
-EngineObjLevel3::EngineObjLevel3(bool used, float min, float max)
-{
- this->used = used;
- this->min = min;
- this->max = max;
-
- next.reserve(LEVEL4_PREALLOCATE_COUNT);
-}
-
-EngineObjLevel4::EngineObjLevel4(bool used, EngineTriangleType type, const Material& material, int state)
-{
- this->used = used;
- this->type = type;
- this->material = material;
- this->state = state;
-
- vertices.reserve(LEVEL4_VERTEX_PREALLOCATE_COUNT);
-}
-
-CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
+CEngine::CEngine(CApplication *app)
{
- m_iMan = iMan;
m_app = app;
m_device = nullptr;
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_ENGINE, this);
- m_app = app;
-
m_lightMan = nullptr;
m_text = nullptr;
m_particle = nullptr;
@@ -158,13 +104,9 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_lookatPt = Math::Vector(0.0f, 0.0f, 1.0f);
m_drawWorld = true;
m_drawFront = false;
- m_limitLOD[0] = 100.0f;
- m_limitLOD[1] = 200.0f;
m_particleDensity = 1.0f;
- m_clippingDistance = 1.0f;
m_lastClippingDistance = m_clippingDistance = 1.0f;
m_objectDetail = 1.0f;
- m_lastObjectDetail = m_objectDetail;
m_terrainVision = 1000.0f;
m_gadgetQuantity = 1.0f;
m_textureQuality = 1;
@@ -179,9 +121,9 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_editIndentValue = 4;
m_tracePrecision = 1.0f;
- m_alphaMode = 1;
m_updateGeometry = false;
+ m_updateStaticBuffers = false;
m_interfaceMode = false;
@@ -206,8 +148,8 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_mouseType = ENG_MOUSE_NORM;
m_fpsCounter = 0;
- m_lastFrameTime = CreateTimeStamp();
- m_currentFrameTime = CreateTimeStamp();
+ m_lastFrameTime = GetSystemUtils()->CreateTimeStamp();
+ m_currentFrameTime = GetSystemUtils()->CreateTimeStamp();
m_defaultTexParams.format = TEX_IMG_AUTO;
m_defaultTexParams.mipmap = true;
@@ -218,24 +160,25 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_terrainTexParams.mipmap = false;
m_terrainTexParams.minFilter = TEX_MIN_FILTER_LINEAR;
m_terrainTexParams.magFilter = TEX_MAG_FILTER_LINEAR;
-
- m_objectTree.reserve(LEVEL1_PREALLOCATE_COUNT);
- m_objects.reserve(OBJECT_PREALLOCATE_COUNT);
- m_shadows.reserve(SHADOW_PREALLOCATE_COUNT);
- m_groundSpots.reserve(GROUNDSPOT_PREALLOCATE_COUNT);
}
CEngine::~CEngine()
{
- m_iMan = nullptr;
- m_app = nullptr;
- m_device = nullptr;
- m_sound = nullptr;
- m_terrain = nullptr;
+ m_app = nullptr;
+ m_sound = nullptr;
+ m_device = nullptr;
+ m_text = nullptr;
+ m_lightMan = nullptr;
+ m_particle = nullptr;
+ m_water = nullptr;
+ m_cloud = nullptr;
+ m_lightning = nullptr;
+ m_planet = nullptr;
+ m_terrain = nullptr;
- DestroyTimeStamp(m_lastFrameTime);
+ GetSystemUtils()->DestroyTimeStamp(m_lastFrameTime);
m_lastFrameTime = nullptr;
- DestroyTimeStamp(m_currentFrameTime);
+ GetSystemUtils()->DestroyTimeStamp(m_currentFrameTime);
m_currentFrameTime = nullptr;
}
@@ -249,27 +192,63 @@ CDevice* CEngine::GetDevice()
return m_device;
}
-void CEngine::SetTerrain(CTerrain* terrain)
+CText* CEngine::GetText()
{
- m_terrain = terrain;
+ return m_text;
}
-CText* CEngine::GetText()
+CLightManager* CEngine::GetLightManager()
{
- return m_text;
+ return m_lightMan;
}
+CParticle* CEngine::GetParticle()
+{
+ return m_particle;
+}
+
+CTerrain* CEngine::GetTerrain()
+{
+ return m_terrain;
+}
+
+CWater* CEngine::GetWater()
+{
+ return m_water;
+}
+
+CLightning* CEngine::GetLightning()
+{
+ return m_lightning;
+}
+
+CPlanet* CEngine::GetPlanet()
+{
+ return m_planet;
+}
+
+CCloud* CEngine::GetCloud()
+{
+ return m_cloud;
+}
+
+void CEngine::SetTerrain(CTerrain* terrain)
+{
+ m_terrain = terrain;
+}
+
+
bool CEngine::Create()
{
- m_size = m_lastSize = m_app->GetVideoConfig().size;
+ m_size = m_app->GetVideoConfig().size;
- m_lightMan = new CLightManager(m_iMan, this);
- m_text = new CText(m_iMan, this);
- m_particle = new CParticle(m_iMan, this);
- m_water = new CWater(m_iMan, this);
- m_cloud = new CCloud(m_iMan, this);
- m_lightning = new CLightning(m_iMan, this);
- m_planet = new CPlanet(m_iMan, this);
+ m_lightMan = new CLightManager(this);
+ m_text = new CText(this);
+ m_particle = new CParticle(this);
+ m_water = new CWater(this);
+ m_cloud = new CCloud(this);
+ m_lightning = new CLightning(this);
+ m_planet = new CPlanet(this);
m_lightMan->SetDevice(m_device);
m_particle->SetDevice(m_device);
@@ -300,8 +279,8 @@ bool CEngine::Create()
params.mipmap = false;
m_miceTexture = LoadTexture("mouse.png", params);
- GetCurrentTimeStamp(m_currentFrameTime);
- GetCurrentTimeStamp(m_lastFrameTime);
+ GetSystemUtils()->GetCurrentTimeStamp(m_currentFrameTime);
+ GetSystemUtils()->GetCurrentTimeStamp(m_lastFrameTime);
return true;
}
@@ -334,6 +313,8 @@ void CEngine::Destroy()
void CEngine::ResetAfterDeviceChanged()
{
+ m_size = m_app->GetVideoConfig().size;;
+
m_text->FlushCache();
// TODO reload textures, reset device state, etc.
@@ -355,11 +336,11 @@ void CEngine::FrameUpdate()
{
m_fpsCounter++;
- GetCurrentTimeStamp(m_currentFrameTime);
- float diff = TimeStampDiff(m_lastFrameTime, m_currentFrameTime, STU_SEC);
+ GetSystemUtils()->GetCurrentTimeStamp(m_currentFrameTime);
+ float diff = GetSystemUtils()->TimeStampDiff(m_lastFrameTime, m_currentFrameTime, STU_SEC);
if (diff > 1.0f)
{
- CopyTimeStamp(m_lastFrameTime, m_currentFrameTime);
+ GetSystemUtils()->CopyTimeStamp(m_lastFrameTime, m_currentFrameTime);
m_fps = m_fpsCounter / diff;
m_fpsCounter = 0;
@@ -378,9 +359,14 @@ void CEngine::FrameUpdate()
float rTime = m_app->GetRelTime();
m_lightMan->UpdateProgression(rTime);
+
+ m_app->StartPerformanceCounter(PCNT_UPDATE_PARTICLE);
m_particle->FrameParticle(rTime);
+ m_app->StopPerformanceCounter(PCNT_UPDATE_PARTICLE);
+
ComputeDistance();
UpdateGeometry();
+ UpdateStaticBuffers();
m_highlightTime = m_app->GetAbsTime();
@@ -409,7 +395,7 @@ void CEngine::FrameUpdate()
{
m_groundMark.intensity = 0.0f;
m_groundMark.phase = ENG_GR_MARK_PHASE_NULL;
- m_groundMark.draw = false;
+ m_groundMark.draw = false;
}
}
}
@@ -422,18 +408,6 @@ bool CEngine::WriteScreenShot(const std::string& fileName, int width, int height
return true;
}
-bool CEngine::ReadSettings()
-{
- // TODO: when INI reading is completed
- return true;
-}
-
-bool CEngine::WriteSettings()
-{
- // TODO: when INI writing is completed
- return true;
-}
-
void CEngine::SetPause(bool pause)
{
m_pause = pause;
@@ -474,11 +448,6 @@ Math::IntPoint CEngine::GetWindowSize()
return m_size;
}
-Math::IntPoint CEngine::GetLastWindowSize()
-{
- return m_lastSize;
-}
-
Math::Point CEngine::WindowToInterfaceCoords(Math::IntPoint pos)
{
return Math::Point( static_cast<float>(pos.x) / static_cast<float>(m_size.x),
@@ -500,7 +469,7 @@ Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size)
Math::IntPoint CEngine::InterfaceToWindowSize(Math::Point size)
{
return Math::IntPoint(static_cast<int>(size.x * m_size.x),
- static_cast<int>(size.y * m_size.y));
+ static_cast<int>(size.y * m_size.y));
}
void CEngine::AddStatisticTriangle(int count)
@@ -519,480 +488,373 @@ int CEngine::GetStatisticTriangle()
Object management
*******************************************************/
+EngineBaseObjTexTier& CEngine::AddLevel2(EngineBaseObject& p1, const std::string& tex1Name, const std::string& tex2Name)
+{
+ for (int i = 0; i < static_cast<int>( p1.next.size() ); i++)
+ {
+ if (p1.next[i].tex1Name == tex1Name && p1.next[i].tex2Name == tex2Name)
+ return p1.next[i];
+ }
+
+ p1.next.push_back(EngineBaseObjTexTier(tex1Name, tex2Name));
+ return p1.next.back();
+}
+EngineBaseObjLODTier& CEngine::AddLevel3(EngineBaseObjTexTier& p2, LODLevel lodLevel)
+{
+ for (int i = 0; i < static_cast<int>( p2.next.size() ); i++)
+ {
+ if (p2.next[i].lodLevel == lodLevel)
+ return p2.next[i];
+ }
-int CEngine::CreateObject()
+ p2.next.push_back(EngineBaseObjLODTier(lodLevel));
+ return p2.next.back();
+}
+
+EngineBaseObjDataTier& CEngine::AddLevel4(EngineBaseObjLODTier& p3, EngineTriangleType type,
+ const Material& material, int state)
{
- int i = 0;
- for ( ; i < static_cast<int>( m_objects.size() ); i++)
+ for (int i = 0; i < static_cast<int>( p3.next.size() ); i++)
{
- if (! m_objects[i].used)
+ if ( (p3.next[i].type == type) && (p3.next[i].material == material) && (p3.next[i].state == state) )
+ return p3.next[i];
+ }
+
+ p3.next.push_back(EngineBaseObjDataTier(type, material, state));
+ return p3.next.back();
+}
+
+int CEngine::CreateBaseObject()
+{
+ int baseObjRank = 0;
+ for ( ; baseObjRank < static_cast<int>( m_baseObjects.size() ); baseObjRank++)
+ {
+ if (! m_baseObjects[baseObjRank].used)
{
- m_objects[i].LoadDefault();
+ m_baseObjects[baseObjRank].LoadDefault();
break;
}
}
- if (i == static_cast<int>( m_objects.size() ))
- m_objects.push_back(EngineObject());
+ if (baseObjRank == static_cast<int>( m_baseObjects.size() ))
+ m_baseObjects.push_back(EngineBaseObject());
+ else
+ m_baseObjects[baseObjRank].LoadDefault();
- m_objects[i].used = true;
+ m_baseObjects[baseObjRank].used = true;
- Math::Matrix mat;
- mat.LoadIdentity();
- SetObjectTransform(i, mat);
-
- m_objects[i].drawWorld = true;
- m_objects[i].distance = 0.0f;
- m_objects[i].bboxMin = Math::Vector(0.0f, 0.0f, 0.0f);
- m_objects[i].bboxMax = Math::Vector(0.0f, 0.0f, 0.0f);
- m_objects[i].shadowRank = -1;
-
- return i;
+ return baseObjRank;
}
-void CEngine::FlushObject()
+void CEngine::DeleteBaseObject(int baseObjRank)
{
- m_objectTree.clear();
- m_objects.clear();
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- m_shadows.clear();
-
- FlushGroundSpot();
-}
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
-bool CEngine::DeleteObject(int objRank)
-{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ if (! p1.used)
+ return;
- // Delete object's triangles
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ EngineBaseObjTexTier& p2 = p1.next[l2];
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if (p2.objRank == objRank)
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- p2.used = false;
- p2.next.clear();
+ EngineBaseObjDataTier& p4 = p3.next[l4];
+
+ m_device->DestroyStaticBuffer(p4.staticBufferId);
+ p4.staticBufferId = 0;
}
}
}
- // Mark object as deleted
- m_objects[objRank].used = false;
+ p1.next.clear();
- // Delete associated shadows
- DeleteShadow(objRank);
-
- return true;
+ p1.used = false;
}
-bool CEngine::SetObjectType(int objRank, EngineObjectType type)
+void CEngine::DeleteAllBaseObjects()
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
-
- m_objects[objRank].type = type;
- return true;
+ m_baseObjects.clear();
}
-EngineObjectType CEngine::GetObjectType(int objRank)
+void CEngine::CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return ENG_OBJTYPE_NULL;
+ assert(sourceBaseObjRank >= 0 && sourceBaseObjRank < static_cast<int>( m_baseObjects.size() ));
+ assert(destBaseObjRank >= 0 && destBaseObjRank < static_cast<int>( m_baseObjects.size() ));
- return m_objects[objRank].type;
+ m_baseObjects[destBaseObjRank] = m_baseObjects[sourceBaseObjRank];
}
-
-bool CEngine::SetObjectTransform(int objRank, const Math::Matrix& transform)
+void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<VertexTex2>& vertices,
+ EngineTriangleType triangleType,
+ const Material& material, int state,
+ std::string tex1Name, std::string tex2Name,
+ LODLevel lodLevel, bool globalUpdate)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
-
- m_objects[objRank].transform = transform;
- return true;
-}
-
-bool CEngine::GetObjectTransform(int objRank, Math::Matrix& transform)
-{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- transform = m_objects[objRank].transform;
- return true;
-}
-
-bool CEngine::SetObjectDrawWorld(int objRank, bool draw)
-{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ EngineBaseObjTexTier& p2 = AddLevel2(p1, tex1Name, tex2Name);
+ EngineBaseObjLODTier& p3 = AddLevel3(p2, lodLevel);
+ EngineBaseObjDataTier& p4 = AddLevel4(p3, triangleType, material, state);
- m_objects[objRank].drawWorld = draw;
- return true;
-}
+ p4.vertices.insert(p4.vertices.end(), vertices.begin(), vertices.end());
-bool CEngine::SetObjectDrawFront(int objRank, bool draw)
-{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ p4.updateStaticBuffer = true;
+ m_updateStaticBuffers = true;
- m_objects[objRank].drawFront = draw;
- return true;
-}
+ if (globalUpdate)
+ {
+ m_updateGeometry = true;
+ }
+ else
+ {
+ for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
+ {
+ p1.bboxMin.x = Math::Min(vertices[i].coord.x, p1.bboxMin.x);
+ p1.bboxMin.y = Math::Min(vertices[i].coord.y, p1.bboxMin.y);
+ p1.bboxMin.z = Math::Min(vertices[i].coord.z, p1.bboxMin.z);
+ p1.bboxMax.x = Math::Max(vertices[i].coord.x, p1.bboxMax.x);
+ p1.bboxMax.y = Math::Max(vertices[i].coord.y, p1.bboxMax.y);
+ p1.bboxMax.z = Math::Max(vertices[i].coord.z, p1.bboxMax.z);
+ }
-bool CEngine::SetObjectTransparency(int objRank, float value)
-{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ p1.radius = Math::Max(p1.bboxMin.Length(), p1.bboxMax.Length());
+ }
- m_objects[objRank].transparency = value;
- return true;
+ if (triangleType == ENG_TRIANGLE_TYPE_TRIANGLES)
+ p1.totalTriangles += vertices.size() / 3;
+ else
+ p1.totalTriangles += vertices.size() - 2;
}
-bool CEngine::GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max)
+void CEngine::AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buffer,
+ std::string tex1Name, std::string tex2Name,
+ LODLevel lodLevel, bool globalUpdate)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return 0;
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- min = m_objects[objRank].bboxMin;
- max = m_objects[objRank].bboxMax;
- return true;
-}
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ EngineBaseObjTexTier& p2 = AddLevel2(p1, tex1Name, tex2Name);
+ EngineBaseObjLODTier& p3 = AddLevel3(p2, lodLevel);
+ p3.next.push_back(buffer);
-int CEngine::GetObjectTotalTriangles(int objRank)
-{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return 0;
-
- return m_objects[objRank].totalTriangles;
-}
+ EngineBaseObjDataTier& p4 = p3.next.back();
+ UpdateStaticBuffer(p4);
-EngineObjLevel1& CEngine::AddLevel1(const std::string& tex1Name, const std::string& tex2Name)
-{
- bool unusedPresent = false;
- for (int i = 0; i < static_cast<int>( m_objectTree.size() ); i++)
+ if (globalUpdate)
{
- if (! m_objectTree[i].used)
- {
- unusedPresent = true;
- continue;
- }
-
- if (m_objectTree[i].tex1Name == tex1Name && m_objectTree[i].tex2Name == tex2Name)
- return m_objectTree[i];
+ m_updateGeometry = true;
}
-
- if (unusedPresent)
+ else
{
- for (int i = 0; i < static_cast<int>( m_objectTree.size() ); i++)
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i++)
{
- if (! m_objectTree[i].used)
- {
- m_objectTree[i].used = true;
- m_objectTree[i].tex1Name = tex1Name;
- m_objectTree[i].tex2Name = tex2Name;
- return m_objectTree[i];
- }
+ p1.bboxMin.x = Math::Min(p4.vertices[i].coord.x, p1.bboxMin.x);
+ p1.bboxMin.y = Math::Min(p4.vertices[i].coord.y, p1.bboxMin.y);
+ p1.bboxMin.z = Math::Min(p4.vertices[i].coord.z, p1.bboxMin.z);
+ p1.bboxMax.x = Math::Max(p4.vertices[i].coord.x, p1.bboxMax.x);
+ p1.bboxMax.y = Math::Max(p4.vertices[i].coord.y, p1.bboxMax.y);
+ p1.bboxMax.z = Math::Max(p4.vertices[i].coord.z, p1.bboxMax.z);
}
+
+ p1.radius = Math::Max(p1.bboxMin.Length(), p1.bboxMax.Length());
}
- m_objectTree.push_back(EngineObjLevel1(true, tex1Name, tex2Name));
- return m_objectTree.back();
+ if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
+ p1.totalTriangles += p4.vertices.size() / 3;
+ else if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
+ p1.totalTriangles += p4.vertices.size() - 2;
}
-EngineObjLevel2& CEngine::AddLevel2(EngineObjLevel1& p1, int objRank)
+
+int CEngine::CreateObject()
{
- bool unusedPresent = false;
- for (int i = 0; i < static_cast<int>( p1.next.size() ); i++)
+ int objRank = 0;
+ for ( ; objRank < static_cast<int>( m_objects.size() ); objRank++)
{
- if (! p1.next[i].used)
+ if (! m_objects[objRank].used)
{
- unusedPresent = true;
- continue;
+ m_objects[objRank].LoadDefault();
+ break;
}
-
- if (p1.next[i].objRank == objRank)
- return p1.next[i];
}
- if (unusedPresent)
- {
- for (int i = 0; i < static_cast<int>( p1.next.size() ); i++)
- {
- if (! p1.next[i].used)
- {
- p1.next[i].used = true;
- p1.next[i].objRank = objRank;
- return p1.next[i];
- }
- }
- }
+ if (objRank == static_cast<int>( m_objects.size() ))
+ m_objects.push_back(EngineObject());
- p1.next.push_back(EngineObjLevel2(true, objRank));
- return p1.next.back();
+
+ m_objects[objRank].used = true;
+
+ Math::Matrix mat;
+ mat.LoadIdentity();
+ SetObjectTransform(objRank, mat);
+
+ m_objects[objRank].drawWorld = true;
+ m_objects[objRank].distance = 0.0f;
+ m_objects[objRank].shadowRank = -1;
+
+ return objRank;
}
-EngineObjLevel3& CEngine::AddLevel3(EngineObjLevel2& p2, float min, float max)
+void CEngine::DeleteAllObjects()
{
- bool unusedPresent = false;
- for (int i = 0; i < static_cast<int>( p2.next.size() ); i++)
- {
- if (! p2.next[i].used)
- {
- unusedPresent = true;
- continue;
- }
+ m_objects.clear();
+ m_shadows.clear();
- if ( (p2.next[i].min == min) && (p2.next[i].max == max) )
- return p2.next[i];
- }
+ DeleteAllGroundSpots();
+}
- if (unusedPresent)
- {
- for (int i = 0; i < static_cast<int>( p2.next.size() ); i++)
- {
- if (! p2.next[i].used)
- {
- p2.next[i].used = true;
- p2.next[i].min = min;
- p2.next[i].max = max;
- return p2.next[i];
- }
- }
- }
+void CEngine::DeleteObject(int objRank)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- p2.next.push_back(EngineObjLevel3(true, min, max));
- return p2.next.back();
+ // Mark object as deleted
+ m_objects[objRank].used = false;
+
+ // Delete associated shadows
+ DeleteShadow(objRank);
}
-EngineObjLevel4& CEngine::AddLevel4(EngineObjLevel3& p3, EngineTriangleType type,
- const Material& material, int state)
+void CEngine::SetObjectBaseRank(int objRank, int baseObjRank)
{
- bool unusedPresent = false;
- for (int i = 0; i < static_cast<int>( p3.next.size() ); i++)
- {
- if (! p3.next[i].used)
- {
- unusedPresent = true;
- continue;
- }
+ assert(objRank == -1 || (objRank >= 0 && objRank < static_cast<int>( m_objects.size() )));
- if ( (p3.next[i].type == type) && (p3.next[i].material == material) && (p3.next[i].state == state) )
- return p3.next[i];
- }
+ m_objects[objRank].baseObjRank = baseObjRank;
+}
- if (unusedPresent)
- {
- for (int i = 0; i < static_cast<int>( p3.next.size() ); i++)
- {
- if (! p3.next[i].used)
- {
- p3.next[i].used = true;
- p3.next[i].type = type;
- p3.next[i].material = material;
- p3.next[i].state = state;
- return p3.next[i];
- }
- }
- }
+int CEngine::GetObjectBaseRank(int objRank)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- p3.next.push_back(EngineObjLevel4(true, type, material, state));
- return p3.next.back();
+ return m_objects[objRank].baseObjRank;
}
-bool CEngine::AddTriangles(int objRank, const std::vector<VertexTex2>& vertices,
- const Material& material, int state,
- std::string tex1Name, std::string tex2Name,
- float min, float max, bool globalUpdate)
+void CEngine::SetObjectType(int objRank, EngineObjectType type)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- {
- GetLogger()->Error("AddTriangle(): invalid object rank %d\n", objRank);
- return false;
- }
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- m_lastSize = m_size;
- m_lastObjectDetail = m_objectDetail;
- m_lastClippingDistance = m_clippingDistance;
-
- EngineObjLevel1& p1 = AddLevel1(tex1Name, tex2Name);
- EngineObjLevel2& p2 = AddLevel2(p1, objRank);
- EngineObjLevel3& p3 = AddLevel3(p2, min, max);
- EngineObjLevel4& p4 = AddLevel4(p3, ENG_TRIANGLE_TYPE_TRIANGLES, material, state);
+ m_objects[objRank].type = type;
+}
- p4.vertices.insert(p4.vertices.end(), vertices.begin(), vertices.end());
+EngineObjectType CEngine::GetObjectType(int objRank)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- if (globalUpdate)
- {
- m_updateGeometry = true;
- }
- else
- {
- for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
- {
- m_objects[objRank].bboxMin.x = Math::Min(vertices[i].coord.x, m_objects[objRank].bboxMin.x);
- m_objects[objRank].bboxMin.y = Math::Min(vertices[i].coord.y, m_objects[objRank].bboxMin.y);
- m_objects[objRank].bboxMin.z = Math::Min(vertices[i].coord.z, m_objects[objRank].bboxMin.z);
- m_objects[objRank].bboxMax.x = Math::Max(vertices[i].coord.x, m_objects[objRank].bboxMax.x);
- m_objects[objRank].bboxMax.y = Math::Max(vertices[i].coord.y, m_objects[objRank].bboxMax.y);
- m_objects[objRank].bboxMax.z = Math::Max(vertices[i].coord.z, m_objects[objRank].bboxMax.z);
- }
+ return m_objects[objRank].type;
+}
- m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
- m_objects[objRank].bboxMax.Length());
- }
- m_objects[objRank].totalTriangles += vertices.size() / 3;
+void CEngine::SetObjectTransform(int objRank, const Math::Matrix& transform)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- return true;
+ m_objects[objRank].transform = transform;
}
-bool CEngine::AddSurface(int objRank, const std::vector<VertexTex2>& vertices,
- const Material& material, int state,
- std::string tex1Name, std::string tex2Name,
- float min, float max, bool globalUpdate)
+void CEngine::GetObjectTransform(int objRank, Math::Matrix& transform)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- {
- GetLogger()->Error("AddSurface(): invalid object rank %d\n", objRank);
- return false;
- }
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- m_lastSize = m_size;
- m_lastObjectDetail = m_objectDetail;
- m_lastClippingDistance = m_clippingDistance;
+ transform = m_objects[objRank].transform;
+}
- EngineObjLevel1& p1 = AddLevel1(tex1Name, tex2Name);
- EngineObjLevel2& p2 = AddLevel2(p1, objRank);
- EngineObjLevel3& p3 = AddLevel3(p2, min, max);
- EngineObjLevel4& p4 = AddLevel4(p3, ENG_TRIANGLE_TYPE_SURFACE, material, state);
+void CEngine::SetObjectDrawWorld(int objRank, bool draw)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- p4.vertices.insert(p4.vertices.end(), vertices.begin(), vertices.end());
+ m_objects[objRank].drawWorld = draw;
+}
- if (globalUpdate)
- {
- m_updateGeometry = true;
- }
- else
- {
- for (int i = 0; i < static_cast<int>( vertices.size() ); i++)
- {
- m_objects[objRank].bboxMin.x = Math::Min(vertices[i].coord.x, m_objects[objRank].bboxMin.x);
- m_objects[objRank].bboxMin.y = Math::Min(vertices[i].coord.y, m_objects[objRank].bboxMin.y);
- m_objects[objRank].bboxMin.z = Math::Min(vertices[i].coord.z, m_objects[objRank].bboxMin.z);
- m_objects[objRank].bboxMax.x = Math::Max(vertices[i].coord.x, m_objects[objRank].bboxMax.x);
- m_objects[objRank].bboxMax.y = Math::Max(vertices[i].coord.y, m_objects[objRank].bboxMax.y);
- m_objects[objRank].bboxMax.z = Math::Max(vertices[i].coord.z, m_objects[objRank].bboxMax.z);
- }
+void CEngine::SetObjectDrawFront(int objRank, bool draw)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
- m_objects[objRank].bboxMax.Length());
- }
+ m_objects[objRank].drawFront = draw;
+}
- m_objects[objRank].totalTriangles += vertices.size() - 2;
+void CEngine::SetObjectTransparency(int objRank, float value)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- return true;
+ m_objects[objRank].transparency = value;
}
-bool CEngine::AddQuick(int objRank, const EngineObjLevel4& buffer,
- std::string tex1Name, std::string tex2Name,
- float min, float max, bool globalUpdate)
+void CEngine::GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- {
- GetLogger()->Error("AddQuick(): invalid object rank %d\n", objRank);
- return false;
- }
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- EngineObjLevel1& p1 = AddLevel1(tex1Name, tex2Name);
- EngineObjLevel2& p2 = AddLevel2(p1, objRank);
- EngineObjLevel3& p3 = AddLevel3(p2, min, max);
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ return;
- p3.next.push_back(buffer);
- p3.next.back().used = true; // ensure that it is used
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>(m_baseObjects.size()));
- if (globalUpdate)
- {
- m_updateGeometry = true;
- }
- else
- {
- for (int i = 0; i < static_cast<int>( buffer.vertices.size() ); i++)
- {
- m_objects[objRank].bboxMin.x = Math::Min(buffer.vertices[i].coord.x, m_objects[objRank].bboxMin.x);
- m_objects[objRank].bboxMin.y = Math::Min(buffer.vertices[i].coord.y, m_objects[objRank].bboxMin.y);
- m_objects[objRank].bboxMin.z = Math::Min(buffer.vertices[i].coord.z, m_objects[objRank].bboxMin.z);
- m_objects[objRank].bboxMax.x = Math::Max(buffer.vertices[i].coord.x, m_objects[objRank].bboxMax.x);
- m_objects[objRank].bboxMax.y = Math::Max(buffer.vertices[i].coord.y, m_objects[objRank].bboxMax.y);
- m_objects[objRank].bboxMax.z = Math::Max(buffer.vertices[i].coord.z, m_objects[objRank].bboxMax.z);
- }
+ min = m_baseObjects[baseObjRank].bboxMin;
+ max = m_baseObjects[baseObjRank].bboxMax;
+}
- m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
- m_objects[objRank].bboxMax.Length());
- }
- if (buffer.type == ENG_TRIANGLE_TYPE_TRIANGLES)
- m_objects[objRank].totalTriangles += buffer.vertices.size() / 3;
- else if (buffer.type == ENG_TRIANGLE_TYPE_SURFACE)
- m_objects[objRank].totalTriangles += buffer.vertices.size() - 2;
+int CEngine::GetObjectTotalTriangles(int objRank)
+{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
+
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ return 0;
+
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- return true;
+ return m_baseObjects[baseObjRank].totalTriangles;
}
-EngineObjLevel4* CEngine::FindTriangles(int objRank, const Material& material,
- int state, std::string tex1Name,
- std::string tex2Name, float min, float max)
+EngineBaseObjDataTier* CEngine::FindTriangles(int objRank, const Material& material,
+ int state, std::string tex1Name,
+ std::string tex2Name, int lodLevelMask)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- {
- GetLogger()->Error("FindTriangles(): invalid object rank %d\n", objRank);
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
+
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
return nullptr;
- }
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
+
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ EngineBaseObjTexTier& p2 = p1.next[l2];
- if (p1.tex1Name != tex1Name) continue;
- // TODO: tex2Name compare?
+ if (p2.tex1Name != tex1Name)
+ continue;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if (p2.objRank != objRank) continue;
+ if ((p3.lodLevel & lodLevelMask) == 0)
+ continue;
- for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
- if (p3.min != min || p3.max != max) continue;
-
- for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
- {
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
-
- if ( (p4.state & (~(ENG_RSTATE_DUAL_BLACK|ENG_RSTATE_DUAL_WHITE))) != state ||
- p4.material != material )
- continue;
+ if ( (p4.state & (~(ENG_RSTATE_DUAL_BLACK|ENG_RSTATE_DUAL_WHITE))) != state ||
+ p4.material != material )
+ continue;
- return &p4;
- }
+ return &p4;
}
}
}
@@ -1000,92 +862,86 @@ EngineObjLevel4* CEngine::FindTriangles(int objRank, const Material& material,
return nullptr;
}
-int CEngine::GetPartialTriangles(int objRank, float min, float max, float percent, int maxCount,
- std::vector<EngineTriangle>& triangles)
+int CEngine::GetPartialTriangles(int objRank, int lodLevelMask, float percent, int maxCount,
+ std::vector<EngineTriangle>& triangles)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- {
- GetLogger()->Error("GetPartialTriangles(): invalid object rank %d\n", objRank);
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
+
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
return 0;
- }
- int total = m_objects[objRank].totalTriangles;
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
+
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+
+ int total = p1.totalTriangles;
int expectedCount = static_cast<int>(percent * total);
triangles.reserve(Math::Min(maxCount, expectedCount));
int actualCount = 0;
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ EngineBaseObjTexTier& p2 = p1.next[l2];
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if (p2.objRank != objRank) continue;
+ if ((p3.lodLevel & lodLevelMask) == 0)
+ continue;
- for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
-
- if (p3.min != min || p3.max != max) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
- for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
-
- if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 3)
{
- for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 3)
- {
- if (static_cast<float>(actualCount) / total >= percent)
- break;
+ if (static_cast<float>(actualCount) / total >= percent)
+ break;
- if (actualCount >= maxCount)
- break;
+ if (actualCount >= maxCount)
+ break;
- EngineTriangle t;
- t.triangle[0] = p4.vertices[i];
- t.triangle[1] = p4.vertices[i+1];
- t.triangle[2] = p4.vertices[i+2];
- t.material = p4.material;
- t.state = p4.state;
- t.tex1Name = p1.tex1Name;
- t.tex2Name = p1.tex2Name;
+ EngineTriangle t;
+ t.triangle[0] = p4.vertices[i];
+ t.triangle[1] = p4.vertices[i+1];
+ t.triangle[2] = p4.vertices[i+2];
+ t.material = p4.material;
+ t.state = p4.state;
+ t.tex1Name = p2.tex1Name;
+ t.tex2Name = p2.tex2Name;
- triangles.push_back(t);
+ triangles.push_back(t);
- ++actualCount;
- }
+ ++actualCount;
}
- else if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
+ }
+ else if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
+ {
+ for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 1)
{
- for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 1)
- {
- if (static_cast<float>(actualCount) / total >= percent)
- break;
+ if (static_cast<float>(actualCount) / total >= percent)
+ break;
- if (actualCount >= maxCount)
- break;
+ if (actualCount >= maxCount)
+ break;
- EngineTriangle t;
- t.triangle[0] = p4.vertices[i];
- t.triangle[1] = p4.vertices[i+1];
- t.triangle[2] = p4.vertices[i+2];
- t.material = p4.material;
- t.state = p4.state;
- t.tex1Name = p1.tex1Name;
- t.tex2Name = p1.tex2Name;
+ EngineTriangle t;
+ t.triangle[0] = p4.vertices[i];
+ t.triangle[1] = p4.vertices[i+1];
+ t.triangle[2] = p4.vertices[i+2];
+ t.material = p4.material;
+ t.state = p4.state;
+ t.tex1Name = p2.tex1Name;
+ t.tex2Name = p2.tex2Name;
- triangles.push_back(t);
+ triangles.push_back(t);
- ++actualCount;
- }
+ ++actualCount;
}
}
}
@@ -1095,105 +951,40 @@ int CEngine::GetPartialTriangles(int objRank, float min, float max, float percen
return actualCount;
}
-void CEngine::ChangeLOD()
+void CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name)
{
- float oldLimit[2] =
- {
- GetLimitLOD(0, true),
- GetLimitLOD(1, true)
- };
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- float newLimit[2] =
- {
- GetLimitLOD(0, false),
- GetLimitLOD(1, false)
- };
-
- float oldTerrain = m_terrainVision * m_lastClippingDistance;
- float newTerrain = m_terrainVision * m_clippingDistance;
-
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
- {
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
-
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ return;
- for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
- {
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- if ( Math::IsEqual(p3.min, 0.0f ) &&
- Math::IsEqual(p3.max, oldLimit[0]) )
- {
- p3.max = newLimit[0];
- }
- else if ( Math::IsEqual(p3.min, oldLimit[0]) &&
- Math::IsEqual(p3.max, oldLimit[1]) )
- {
- p3.min = newLimit[0];
- p3.max = newLimit[1];
- }
- else if ( Math::IsEqual(p3.min, oldLimit[1]) &&
- Math::IsEqual(p3.max, 1000000.0f ) )
- {
- p3.min = newLimit[1];
- }
- else if ( Math::IsEqual(p3.min, 0.0f ) &&
- Math::IsEqual(p3.max, oldTerrain) )
- {
- p3.max = newTerrain;
- }
- }
- }
- }
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
- m_lastSize = m_size;
- m_lastObjectDetail = m_objectDetail;
- m_lastClippingDistance = m_clippingDistance;
-}
-
-bool CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name)
-{
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
-
- if (p1.tex2Name == tex2Name) continue; // already new
-
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
-
- if (p2.objRank != objRank) continue;
-
- EngineObjLevel1& newP1 = AddLevel1(p1.tex1Name, tex2Name);
+ EngineBaseObjTexTier& p2 = p1.next[l2];
- newP1.next.push_back(EngineObjLevel2(true, objRank));
+ if (p2.tex2Name == tex2Name)
+ continue; // already new
- EngineObjLevel2& newP2 = newP1.next.back();
- newP2.next.swap(p2.next);
-
- p2.used = false;
- }
+ EngineBaseObjTexTier& newP2 = AddLevel2(p1, p2.tex1Name, tex2Name);
+ newP2.next.swap(p2.next);
}
- return true;
}
-bool CEngine::ChangeTextureMapping(int objRank, const Material& mat, int state,
- const std::string& tex1Name, const std::string& tex2Name,
- float min, float max, EngineTextureMapping mode,
- float au, float bu, float av, float bv)
+void CEngine::ChangeTextureMapping(int objRank, const Material& mat, int state,
+ const std::string& tex1Name, const std::string& tex2Name,
+ int lodLevelMask, EngineTextureMapping mode,
+ float au, float bu, float av, float bv)
{
- EngineObjLevel4* p4 = FindTriangles(objRank, mat, state, tex1Name, tex2Name, min, max);
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
+
+ EngineBaseObjDataTier* p4 = FindTriangles(objRank, mat, state, tex1Name, tex2Name, lodLevelMask);
if (p4 == nullptr)
- return false;
+ return;
int nb = p4->vertices.size();
@@ -1243,27 +1034,113 @@ bool CEngine::ChangeTextureMapping(int objRank, const Material& mat, int state,
}
}
- return true;
+ UpdateStaticBuffer(*p4);
}
-bool CEngine::TrackTextureMapping(int objRank, const Material& mat, int state,
- const std::string& tex1Name, const std::string& tex2Name,
- float min, float max, EngineTextureMapping mode,
- float pos, float factor, float tl, float ts, float tt)
+void CEngine::TrackTextureMapping(int objRank, const Material& mat, int state,
+ const std::string& tex1Name, const std::string& tex2Name,
+ int lodLevelMask, EngineTextureMapping mode,
+ float pos, float factor, float tl, float ts, float tt)
{
- // TODO track texture mapping: pretty complex code, so leaving it for now
- GetLogger()->Trace("CEngine::TrackTextureMapping(): stub!\n");
- return true;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
+
+ EngineBaseObjDataTier* p4 = FindTriangles(objRank, mat, state, tex1Name, tex2Name, lodLevelMask);
+ if (p4 == nullptr)
+ return;
+
+ int tNum = p4->vertices.size();
+ if (tNum < 12 || tNum % 6 != 0)
+ return;
+
+ std::vector<Gfx::VertexTex2>& vs = p4->vertices;
+
+ while (pos < 0.0f)
+ pos += 1.0f; // never negative!
+
+ Math::Vector current;
+
+ for (int i = 0; i < 6; i++)
+ {
+ for (int j = 0; j < 6; j++)
+ {
+ if (Math::IsEqual(vs[i].coord.x, vs[j+6].coord.x) &&
+ Math::IsEqual(vs[i].coord.y, vs[j+6].coord.y))
+ {
+ current.x = vs[i].coord.x; // position end link
+ current.y = vs[i].coord.y;
+ break;
+ }
+ }
+ }
+
+ float ps = 0.0f; // start position on the periphery
+ float pe = 0.0f;
+ int is[6] = { 0 }, ie[6] = { 0 };
+
+ int tBase = 0;
+ for (int ti = 0; ti < tNum / 6; ti++)
+ {
+ int s = 0;
+ int e = 0;
+
+ for (int i = 0; i < 6; i++)
+ {
+ if (Math::IsEqual(vs[tBase + i].coord.x, current.x, 0.0001f) &&
+ Math::IsEqual(vs[tBase + i].coord.y, current.y, 0.0001f))
+ {
+ ie[e++] = i;
+ }
+ else
+ {
+ is[s++] = i;
+ }
+ }
+ if (s == 3 && e == 3)
+ {
+ pe = ps + Math::Point(vs[tBase + is[0]].coord.x - vs[tBase + ie[0]].coord.x,
+ vs[tBase + is[0]].coord.y - vs[tBase + ie[0]].coord.y).Length() / factor; // end position on the periphery
+
+ float pps = ps + pos;
+ float ppe = pe + pos;
+ int offset = static_cast<int>(pps);
+ ppe -= offset;
+ pps -= offset;
+
+ for (int i = 0; i < 3; i++)
+ {
+ vs[tBase + is[i]].texCoord.x = ((pps * tl) + ts) / tt;
+ vs[tBase + ie[i]].texCoord.x = ((ppe * tl) + ts) / tt;
+ }
+ }
+
+ if (ti >= (tNum / 6) - 1)
+ break;
+
+ for (int i = 0; i < 6; i++)
+ {
+ if (!Math::IsEqual(vs[tBase + i+6].coord.x, current.x, 0.0001f) ||
+ !Math::IsEqual(vs[tBase + i+6].coord.y, current.y, 0.0001f))
+ {
+ current.x = vs[tBase + i+6].coord.x; // end next link
+ current.y = vs[tBase + i+6].coord.y;
+ break;
+ }
+ }
+ ps = pe; // following start position on the periphery
+ tBase += 6;
+ }
+
+ UpdateStaticBuffer(*p4);
}
-bool CEngine::CreateShadow(int objRank)
+void CEngine::CreateShadow(int objRank)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
// Already allocated?
- if (m_objects[objRank].shadowRank != -1) return true;
+ if (m_objects[objRank].shadowRank != -1)
+ return;
int index = 0;
for ( ; index < static_cast<int>( m_shadows.size() ); index++)
@@ -1275,146 +1152,147 @@ bool CEngine::CreateShadow(int objRank)
}
}
- m_shadows.push_back(EngineShadow());
+ if (index == static_cast<int>( m_shadows.size() ))
+ m_shadows.push_back(EngineShadow());
m_shadows[index].used = true;
m_shadows[index].objRank = objRank;
m_shadows[index].height = 0.0f;
m_objects[objRank].shadowRank = index;
-
- return true;
}
void CEngine::DeleteShadow(int objRank)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
return;
- m_shadows[i].used = false;
- m_shadows[i].objRank = -1;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].used = false;
+ m_shadows[shadowRank].objRank = -1;
m_objects[objRank].shadowRank = -1;
}
-bool CEngine::SetObjectShadowHide(int objRank, bool hide)
+void CEngine::SetObjectShadowHide(int objRank, bool hide)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].hide = hide;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].hide = hide;
}
-bool CEngine::SetObjectShadowType(int objRank, EngineShadowType type)
+void CEngine::SetObjectShadowType(int objRank, EngineShadowType type)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].type = type;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].type = type;
}
-bool CEngine::SetObjectShadowPos(int objRank, const Math::Vector& pos)
+void CEngine::SetObjectShadowPos(int objRank, const Math::Vector& pos)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].pos = pos;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].pos = pos;
}
-bool CEngine::SetObjectShadowNormal(int objRank, const Math::Vector& normal)
+void CEngine::SetObjectShadowNormal(int objRank, const Math::Vector& normal)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].normal = normal;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].normal = normal;
}
-bool CEngine::SetObjectShadowAngle(int objRank, float angle)
+void CEngine::SetObjectShadowAngle(int objRank, float angle)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].angle = angle;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].angle = angle;
}
-bool CEngine::SetObjectShadowRadius(int objRank, float radius)
+void CEngine::SetObjectShadowRadius(int objRank, float radius)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].radius = radius;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].radius = radius;
}
-bool CEngine::SetObjectShadowIntensity(int objRank, float intensity)
+void CEngine::SetObjectShadowIntensity(int objRank, float intensity)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].intensity = intensity;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].intensity = intensity;
}
-bool CEngine::SetObjectShadowHeight(int objRank, float height)
+void CEngine::SetObjectShadowHeight(int objRank, float height)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return false;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
- return false;
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
+ return;
- m_shadows[i].height = height;
- return true;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ m_shadows[shadowRank].height = height;
}
float CEngine::GetObjectShadowRadius(int objRank)
{
- if ( objRank < 0 || objRank >= static_cast<int>( m_objects.size() ) )
- return 0.0f;
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
- int i = m_objects[objRank].shadowRank;
- if (i == -1)
+ int shadowRank = m_objects[objRank].shadowRank;
+ if (shadowRank == -1)
return 0.0f;
- return m_shadows[i].radius;
+ assert(shadowRank >= 0 && shadowRank < static_cast<int>( m_shadows.size() ));
+
+ return m_shadows[shadowRank].radius;
}
bool CEngine::GetHighlight(Math::Point &p1, Math::Point &p2)
@@ -1436,21 +1314,31 @@ void CEngine::SetHighlightRank(int *rankList)
bool CEngine::GetBBox2D(int objRank, Math::Point &min, Math::Point &max)
{
+ assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
+
min.x = 1000000.0f;
min.y = 1000000.0f;
max.x = -1000000.0f;
max.y = -1000000.0f;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ return false;
+
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
+
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+
for (int i = 0; i < 8; i++)
{
Math::Vector p;
- if ( i & (1<<0) ) p.x = m_objects[objRank].bboxMin.x;
- else p.x = m_objects[objRank].bboxMax.x;
- if ( i & (1<<1) ) p.y = m_objects[objRank].bboxMin.y;
- else p.y = m_objects[objRank].bboxMax.y;
- if ( i & (1<<2) ) p.z = m_objects[objRank].bboxMin.z;
- else p.z = m_objects[objRank].bboxMax.z;
+ if ( i & (1<<0) ) p.x = p1.bboxMin.x;
+ else p.x = p1.bboxMax.x;
+ if ( i & (1<<1) ) p.y = p1.bboxMin.y;
+ else p.y = p1.bboxMax.y;
+ if ( i & (1<<2) ) p.z = p1.bboxMin.z;
+ else p.z = p1.bboxMax.z;
Math::Vector pp;
if (TransformPoint(pp, objRank, p))
@@ -1462,20 +1350,36 @@ bool CEngine::GetBBox2D(int objRank, Math::Point &min, Math::Point &max)
}
}
- if ( min.x == 1000000.0f ||
- min.y == 1000000.0f ||
- max.x == -1000000.0f ||
- max.y == -1000000.0f ) return false;
+ if (min.x == 1000000.0f ||
+ min.y == 1000000.0f ||
+ max.x == -1000000.0f ||
+ max.y == -1000000.0f)
+ return false;
return true;
}
-void CEngine::FlushGroundSpot()
+void CEngine::DeleteAllGroundSpots()
{
m_groundSpots.clear();
m_firstGroundSpot = true;
- // TODO: blank all shadow textures
+ for (int s = 0; s < 16; s++)
+ {
+ CImage shadowImg(Math::IntPoint(256, 256));
+ shadowImg.Fill(Gfx::IntColor(255, 255, 255, 255));
+
+ std::stringstream str;
+ str << "shadow" << std::setfill('0') << std::setw(2) << s << ".png";
+ std::string texName = str.str();
+
+ DeleteTexture(texName);
+
+ Gfx::Texture tex = m_device->CreateTexture(&shadowImg, m_defaultTexParams);
+
+ m_texNameMap[texName] = tex;
+ m_revTexNameMap[tex] = texName;
+ }
}
int CEngine::CreateGroundSpot()
@@ -1500,54 +1404,46 @@ int CEngine::CreateGroundSpot()
void CEngine::DeleteGroundSpot(int rank)
{
+ assert(rank >= 0 && rank < static_cast<int>( m_groundSpots.size() ));
+
m_groundSpots[rank].used = false;
m_groundSpots[rank].pos = Math::Vector(0.0f, 0.0f, 0.0f);
}
-bool CEngine::SetObjectGroundSpotPos(int rank, const Math::Vector& pos)
+void CEngine::SetObjectGroundSpotPos(int rank, const Math::Vector& pos)
{
- if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
- return 0.0f;
+ assert(rank >= 0 && rank < static_cast<int>( m_groundSpots.size() ));
m_groundSpots[rank].pos = pos;
- return true;
}
-bool CEngine::SetObjectGroundSpotRadius(int rank, float radius)
+void CEngine::SetObjectGroundSpotRadius(int rank, float radius)
{
- if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
- return 0.0f;
+ assert(rank >= 0 && rank < static_cast<int>( m_groundSpots.size() ));
m_groundSpots[rank].radius = radius;
- return true;
}
-bool CEngine::SetObjectGroundSpotColor(int rank, const Color& color)
+void CEngine::SetObjectGroundSpotColor(int rank, const Color& color)
{
- if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
- return 0.0f;
+ assert(rank >= 0 && rank < static_cast<int>( m_groundSpots.size() ));
m_groundSpots[rank].color = color;
- return true;
}
-bool CEngine::SetObjectGroundSpotMinMax(int rank, float min, float max)
+void CEngine::SetObjectGroundSpotMinMax(int rank, float min, float max)
{
- if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
- return 0.0f;
+ assert(rank >= 0 && rank < static_cast<int>( m_groundSpots.size() ));
m_groundSpots[rank].min = min;
m_groundSpots[rank].max = max;
- return true;
}
-bool CEngine::SetObjectGroundSpotSmooth(int rank, float smooth)
+void CEngine::SetObjectGroundSpotSmooth(int rank, float smooth)
{
- if ( rank < 0 || rank >= static_cast<int>( m_groundSpots.size() ) )
- return 0.0f;
+ assert(rank >= 0 && rank < static_cast<int>( m_groundSpots.size() ));
m_groundSpots[rank].smooth = smooth;
- return true;
}
void CEngine::CreateGroundMark(Math::Vector pos, float radius,
@@ -1556,6 +1452,7 @@ void CEngine::CreateGroundMark(Math::Vector pos, float radius,
{
m_groundMark.LoadDefault();
+ m_groundMark.draw = true;
m_groundMark.phase = ENG_GR_MARK_PHASE_INC;
m_groundMark.delay[0] = delay1;
m_groundMark.delay[1] = delay2;
@@ -1575,8 +1472,6 @@ void CEngine::DeleteGroundMark(int rank)
void CEngine::ComputeDistance()
{
- // TODO: s_resol???
-
for (int i = 0; i < static_cast<int>( m_objects.size() ); i++)
{
if (! m_objects[i].used)
@@ -1595,51 +1490,39 @@ void CEngine::UpdateGeometry()
if (! m_updateGeometry)
return;
- for (int i = 0; i < static_cast<int>( m_objects.size() ); i++)
+ for (int baseObjRank = 0; baseObjRank < static_cast<int>( m_baseObjects.size() ); baseObjRank++)
{
- m_objects[i].bboxMin.x = 0;
- m_objects[i].bboxMin.y = 0;
- m_objects[i].bboxMin.z = 0;
- m_objects[i].bboxMax.x = 0;
- m_objects[i].bboxMax.y = 0;
- m_objects[i].bboxMax.z = 0;
- m_objects[i].radius = 0;
- }
+ EngineBaseObject &p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
- {
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ p1.bboxMin.LoadZero();
+ p1.bboxMax.LoadZero();
+ p1.radius = 0;
for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
{
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ EngineBaseObjTexTier& p2 = p1.next[l2];
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
-
- int objRank = p2.objRank;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i++)
{
- m_objects[objRank].bboxMin.x = Math::Min(p4.vertices[i].coord.x, m_objects[objRank].bboxMin.x);
- m_objects[objRank].bboxMin.y = Math::Min(p4.vertices[i].coord.y, m_objects[objRank].bboxMin.y);
- m_objects[objRank].bboxMin.z = Math::Min(p4.vertices[i].coord.z, m_objects[objRank].bboxMin.z);
- m_objects[objRank].bboxMax.x = Math::Max(p4.vertices[i].coord.x, m_objects[objRank].bboxMax.x);
- m_objects[objRank].bboxMax.y = Math::Max(p4.vertices[i].coord.y, m_objects[objRank].bboxMax.y);
- m_objects[objRank].bboxMax.z = Math::Max(p4.vertices[i].coord.z, m_objects[objRank].bboxMax.z);
+ p1.bboxMin.x = Math::Min(p4.vertices[i].coord.x, p1.bboxMin.x);
+ p1.bboxMin.y = Math::Min(p4.vertices[i].coord.y, p1.bboxMin.y);
+ p1.bboxMin.z = Math::Min(p4.vertices[i].coord.z, p1.bboxMin.z);
+ p1.bboxMax.x = Math::Max(p4.vertices[i].coord.x, p1.bboxMax.x);
+ p1.bboxMax.y = Math::Max(p4.vertices[i].coord.y, p1.bboxMax.y);
+ p1.bboxMax.z = Math::Max(p4.vertices[i].coord.z, p1.bboxMax.z);
}
- m_objects[objRank].radius = Math::Max(m_objects[objRank].bboxMin.Length(),
- m_objects[objRank].bboxMax.Length());
+ p1.radius = Math::Max(p1.bboxMin.Length(), p1.bboxMax.Length());
}
}
}
@@ -1648,14 +1531,76 @@ void CEngine::UpdateGeometry()
m_updateGeometry = false;
}
+void CEngine::UpdateStaticBuffer(EngineBaseObjDataTier& p4)
+{
+ PrimitiveType type;
+ if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
+ type = PRIMITIVE_TRIANGLES;
+ else
+ type = PRIMITIVE_TRIANGLE_STRIP;
+
+ if (p4.staticBufferId == 0)
+ p4.staticBufferId = m_device->CreateStaticBuffer(type, &p4.vertices[0], p4.vertices.size());
+ else
+ m_device->UpdateStaticBuffer(p4.staticBufferId, type, &p4.vertices[0], p4.vertices.size());
+
+ p4.updateStaticBuffer = false;
+}
+
+void CEngine::UpdateStaticBuffers()
+{
+ if (!m_updateStaticBuffers)
+ return;
+
+ m_updateStaticBuffers = false;
+
+ for (int baseObjRank = 0; baseObjRank < static_cast<int>( m_baseObjects.size() ); baseObjRank++)
+ {
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ EngineBaseObjLODTier& p3 = p2.next[l3];
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ EngineBaseObjDataTier& p4 = p3.next[l4];
+
+ if (! p4.updateStaticBuffer)
+ continue;
+
+ UpdateStaticBuffer(p4);
+ }
+ }
+ }
+ }
+}
+
void CEngine::Update()
{
ComputeDistance();
UpdateGeometry();
+ UpdateStaticBuffers();
}
bool CEngine::DetectBBox(int objRank, Math::Point mouse)
{
+ assert(objRank >= 0 && objRank < static_cast<int>(m_objects.size()));
+
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ return false;
+
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>(m_baseObjects.size()));
+
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+
Math::Point min, max;
min.x = 1000000.0f;
min.y = 1000000.0f;
@@ -1666,12 +1611,12 @@ bool CEngine::DetectBBox(int objRank, Math::Point mouse)
{
Math::Vector p;
- if ( i & (1<<0) ) p.x = m_objects[objRank].bboxMin.x;
- else p.x = m_objects[objRank].bboxMax.x;
- if ( i & (1<<1) ) p.y = m_objects[objRank].bboxMin.y;
- else p.y = m_objects[objRank].bboxMax.y;
- if ( i & (1<<2) ) p.z = m_objects[objRank].bboxMin.z;
- else p.z = m_objects[objRank].bboxMax.z;
+ if ( i & (1<<0) ) p.x = p1.bboxMin.x;
+ else p.x = p1.bboxMax.x;
+ if ( i & (1<<1) ) p.y = p1.bboxMin.y;
+ else p.y = p1.bboxMax.y;
+ if ( i & (1<<2) ) p.z = p1.bboxMin.z;
+ else p.z = p1.bboxMax.z;
Math::Vector pp;
if ( TransformPoint(pp, objRank, p) )
@@ -1694,41 +1639,51 @@ int CEngine::DetectObject(Math::Point mouse)
float min = 1000000.0f;
int nearest = -1;
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int objRank = 0; objRank < static_cast<int>( m_objects.size() ); objRank++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ if (! m_objects[objRank].used)
+ continue;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ if (m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
+ continue;
+
+ if (! DetectBBox(objRank, mouse))
+ continue;
- if (m_objects[p2.objRank].type == ENG_OBJTYPE_TERRAIN) continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ continue;
+
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>(m_baseObjects.size()));
- if (! DetectBBox(p2.objRank, mouse)) continue;
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if (p3.min != 0.0f) continue; // LOD B or C?
+ if (p3.lodLevel != LOD_Constant && p3.lodLevel != LOD_High)
+ continue;
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
{
for (int i = 0; i < static_cast<int>( p4.vertices.size() ); i += 3)
{
float dist = 0.0f;
- if (DetectTriangle(mouse, &p4.vertices[i], p2.objRank, dist) && dist < min)
+ if (DetectTriangle(mouse, &p4.vertices[i], objRank, dist) && dist < min)
{
min = dist;
- nearest = p2.objRank;
+ nearest = objRank;
}
}
}
@@ -1737,10 +1692,10 @@ int CEngine::DetectObject(Math::Point mouse)
for (int i = 0; i < static_cast<int>( p4.vertices.size() ) - 2; i += 1)
{
float dist = 0.0f;
- if (DetectTriangle(mouse, &p4.vertices[i], p2.objRank, dist) && dist < min)
+ if (DetectTriangle(mouse, &p4.vertices[i], objRank, dist) && dist < min)
{
min = dist;
- nearest = p2.objRank;
+ nearest = objRank;
}
}
}
@@ -1754,6 +1709,8 @@ int CEngine::DetectObject(Math::Point mouse)
bool CEngine::DetectTriangle(Math::Point mouse, VertexTex2* triangle, int objRank, float& dist)
{
+ assert(objRank >= 0 && objRank < static_cast<int>(m_objects.size()));
+
Math::Vector p2D[3], p3D;
for (int i = 0; i < 3; i++)
@@ -1766,18 +1723,25 @@ bool CEngine::DetectTriangle(Math::Point mouse, VertexTex2* triangle, int objRan
return false;
}
- if ( mouse.x < p2D[0].x &&
- mouse.x < p2D[1].x &&
- mouse.x < p2D[2].x ) return false;
- if ( mouse.x > p2D[0].x &&
- mouse.x > p2D[1].x &&
- mouse.x > p2D[2].x ) return false;
- if ( mouse.y < p2D[0].y &&
- mouse.y < p2D[1].y &&
- mouse.y < p2D[2].y ) return false;
- if ( mouse.y > p2D[0].y &&
- mouse.y > p2D[1].y &&
- mouse.y > p2D[2].y ) return false;
+ if (mouse.x < p2D[0].x &&
+ mouse.x < p2D[1].x &&
+ mouse.x < p2D[2].x)
+ return false;
+
+ if (mouse.x > p2D[0].x &&
+ mouse.x > p2D[1].x &&
+ mouse.x > p2D[2].x)
+ return false;
+
+ if (mouse.y < p2D[0].y &&
+ mouse.y < p2D[1].y &&
+ mouse.y < p2D[2].y)
+ return false;
+
+ if (mouse.y > p2D[0].y &&
+ mouse.y > p2D[1].y &&
+ mouse.y > p2D[2].y)
+ return false;
Math::Point a, b, c;
a.x = p2D[0].x;
@@ -1794,18 +1758,75 @@ bool CEngine::DetectTriangle(Math::Point mouse, VertexTex2* triangle, int objRan
return true;
}
+//! Use only after world transform already set
bool CEngine::IsVisible(int objRank)
{
- // TODO: use ComputeSphereVisiblity() after tested OK
- return true;
+ assert(objRank >= 0 && objRank < static_cast<int>(m_objects.size()));
+
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ return false;
+
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>(m_baseObjects.size()));
+
+ float radius = m_baseObjects[baseObjRank].radius;
+ Math::Vector center(0.0f, 0.0f, 0.0f);
+ if (m_device->ComputeSphereVisibility(center, radius) == Gfx::FRUSTUM_PLANE_ALL)
+ {
+ m_objects[objRank].visible = true;
+ return true;
+ }
+
+ m_objects[objRank].visible = false;
+ return false;
+}
+
+bool CEngine::IsWithinLODLimit(float distance, LODLevel lodLevel)
+{
+ float min = 0.0f, max = 0.0f;
+
+ if (lodLevel == LOD_Constant)
+ {
+ min = 0.0f;
+ max = m_terrainVision * m_clippingDistance;
+ }
+ else
+ {
+ if (lodLevel == LOD_High)
+ {
+ min = 0.0f;
+ max = 100.0f;
+ }
+ else if (lodLevel == LOD_Medium)
+ {
+ min = 100.0f;
+ max = 200.0f;
+ }
+ else if (lodLevel == LOD_Low)
+ {
+ min = 100.0f;
+ max = 1000000.0f;
+ }
+
+ min *= m_size.x / 640.0f;
+ min *= m_objectDetail*2.0f;
+
+ max *= m_size.x / 640.0f;
+ max *= m_objectDetail*2.0f;
+ }
+
+ return distance >= min && distance < max;
}
bool CEngine::TransformPoint(Math::Vector& p2D, int objRank, Math::Vector p3D)
{
+ assert(objRank >= 0 && objRank < static_cast<int>(m_objects.size()));
+
p3D = Math::Transform(m_objects[objRank].transform, p3D);
p3D = Math::Transform(m_matView, p3D);
- if (p3D.z < 2.0f) return false; // behind?
+ if (p3D.z < 2.0f)
+ return false; // behind?
p2D.x = (p3D.x/p3D.z)*m_matProj.Get(1,1);
p2D.y = (p3D.y/p3D.z)*m_matProj.Get(2,2);
@@ -1833,15 +1854,6 @@ void CEngine::SetState(int state, const Color& color)
m_lastState = state;
m_lastColor = color;
- if (m_alphaMode != 1 && (state & ENG_RSTATE_ALPHA))
- {
- state &= ~ENG_RSTATE_ALPHA;
-
- if (m_alphaMode == 2)
- state |= ENG_RSTATE_TTEXTURE_BLACK;
- }
-
-
if (state & ENG_RSTATE_TTEXTURE_BLACK) // transparent black texture?
{
m_device->SetRenderState(RENDER_STATE_FOG, false);
@@ -1855,7 +1867,7 @@ void CEngine::SetState(int state, const Color& color)
params.colorOperation = TEX_MIX_OPER_MODULATE;
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
params.colorArg2 = TEX_MIX_ARG_FACTOR;
- params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
+ params.alphaOperation = TEX_MIX_OPER_DEFAULT;
params.factor = color;
m_device->SetTextureEnabled(0, true);
@@ -1874,7 +1886,7 @@ void CEngine::SetState(int state, const Color& color)
params.colorOperation = TEX_MIX_OPER_ADD;
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
params.colorArg2 = TEX_MIX_ARG_FACTOR;
- params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
+ params.alphaOperation = TEX_MIX_OPER_DEFAULT;
params.factor = color.Inverse();
m_device->SetTextureEnabled(0, true);
@@ -1914,7 +1926,7 @@ void CEngine::SetState(int state, const Color& color)
TextureStageParams params;
params.colorOperation = TEX_MIX_OPER_REPLACE;
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
- params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
+ params.alphaOperation = TEX_MIX_OPER_DEFAULT;
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, params);
@@ -1982,7 +1994,7 @@ void CEngine::SetState(int state, const Color& color)
TextureStageParams params;
params.colorOperation = TEX_MIX_OPER_DEFAULT; // default modulate
- params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
+ params.alphaOperation = TEX_MIX_OPER_DEFAULT;
m_device->SetTextureEnabled(0, true);
m_device->SetTextureStageParams(0, params);
@@ -2003,7 +2015,7 @@ void CEngine::SetState(int state, const Color& color)
params.colorOperation = TEX_MIX_OPER_MODULATE;
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
params.colorArg2 = TEX_MIX_ARG_COMPUTED_COLOR;
- params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: ???
+ params.alphaOperation = TEX_MIX_OPER_DEFAULT;
m_device->SetTextureEnabled(1, true);
m_device->SetTextureStageParams(1, params);
}
@@ -2013,7 +2025,7 @@ void CEngine::SetState(int state, const Color& color)
params.colorOperation = TEX_MIX_OPER_ADD;
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
params.colorArg2 = TEX_MIX_ARG_COMPUTED_COLOR;
- params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: ???
+ params.alphaOperation = TEX_MIX_OPER_DEFAULT;
m_device->SetTextureEnabled(1, true);
m_device->SetTextureStageParams(1, params);
}
@@ -2071,7 +2083,7 @@ void CEngine::SetViewParams(const Math::Vector& eyePt, const Math::Vector& looka
Math::LoadViewMatrix(m_matView, eyePt, lookatPt, upVec);
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>( m_iMan->SearchInstance(CLASS_SOUND) );
+ m_sound = m_app->GetSound();
if (m_sound != nullptr)
m_sound->SetListener(eyePt, lookatPt);
@@ -2168,42 +2180,50 @@ bool CEngine::LoadAllTextures()
bool ok = true;
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int objRank = 0; objRank < static_cast<int>( m_objects.size() ); objRank++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ if (! m_objects[objRank].used)
+ continue;
bool terrain = false;
+ if (m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
+ terrain = true;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ continue;
- if (m_objects[p2.objRank].type == ENG_OBJTYPE_TERRAIN)
- terrain = true;
- }
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
+
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
- if (! p1.tex1Name.empty())
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
{
- if (terrain)
- p1.tex1 = LoadTexture(p1.tex1Name, m_terrainTexParams);
- else
- p1.tex1 = LoadTexture(p1.tex1Name);
+ EngineBaseObjTexTier& p2 = p1.next[l2];
- if (! p1.tex1.Valid())
- ok = false;
- }
+ if (! p2.tex1Name.empty())
+ {
+ if (terrain)
+ p2.tex1 = LoadTexture(p2.tex1Name, m_terrainTexParams);
+ else
+ p2.tex1 = LoadTexture(p2.tex1Name);
- if (! p1.tex2Name.empty())
- {
- if (terrain)
- p1.tex2 = LoadTexture(p1.tex2Name, m_terrainTexParams);
- else
- p1.tex2 = LoadTexture(p1.tex2Name);
+ if (! p2.tex1.Valid())
+ ok = false;
+ }
- if (! p1.tex2.Valid())
- ok = false;
+ if (! p2.tex2Name.empty())
+ {
+ if (terrain)
+ p2.tex2 = LoadTexture(p2.tex2Name, m_terrainTexParams);
+ else
+ p2.tex2 = LoadTexture(p2.tex2Name);
+
+ if (! p2.tex2.Valid())
+ ok = false;
+ }
}
}
@@ -2219,7 +2239,8 @@ bool IsExcludeColor(Math::Point *exclude, int x, int y)
if ( x >= static_cast<int>(exclude[i+0].x*256.0f) &&
x < static_cast<int>(exclude[i+1].x*256.0f) &&
y >= static_cast<int>(exclude[i+0].y*256.0f) &&
- y < static_cast<int>(exclude[i+1].y*256.0f) ) return true; // exclude
+ y < static_cast<int>(exclude[i+1].y*256.0f) )
+ return true; // exclude
i += 2;
}
@@ -2235,12 +2256,13 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
Math::Point ts, Math::Point ti,
Math::Point *exclude, float shift, bool hsv)
{
- if ( colorRef1.r == colorNew1.r &&
- colorRef1.g == colorNew1.g &&
- colorRef1.b == colorNew1.b &&
- colorRef2.r == colorNew2.r &&
- colorRef2.g == colorNew2.g &&
- colorRef2.b == colorNew2.b ) return true;
+ if (colorRef1.r == colorNew1.r &&
+ colorRef1.g == colorNew1.g &&
+ colorRef1.b == colorNew1.b &&
+ colorRef2.r == colorNew2.r &&
+ colorRef2.g == colorNew2.g &&
+ colorRef2.b == colorNew2.b)
+ return true;
DeleteTexture(texName);
@@ -2275,7 +2297,8 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
{
for (int x = sx; x < ex; x++)
{
- if (exclude != nullptr && IsExcludeColor(exclude, x,y) ) continue;
+ if (exclude != nullptr && IsExcludeColor(exclude, x,y) )
+ continue;
Color color = img.GetPixel(Math::IntPoint(x, y));
@@ -2413,33 +2436,6 @@ void CEngine::SetTexture(const Texture& tex, int stage)
m_device->SetTexture(stage, tex);
}
-void CEngine::SetLimitLOD(int rank, float limit)
-{
- m_limitLOD[rank] = limit;
-}
-
-float CEngine::GetLimitLOD(int rank, bool last)
-{
- float limit = 0.0f;
-
- if (last)
- {
- limit = m_limitLOD[rank];
- limit *= m_lastSize.x/640.0f; // limit further if large window!
- limit += m_limitLOD[0]*(m_lastObjectDetail*2.0f);
- }
- else
- {
- limit = m_limitLOD[rank];
- limit *= m_size.x/640.0f; // limit further if large window!
- limit += m_limitLOD[0]*(m_objectDetail*2.0f);
- }
-
- if (limit < 0.0f) limit = 0.0f;
-
- return limit;
-}
-
void CEngine::SetTerrainVision(float vision)
{
m_terrainVision = vision;
@@ -2675,6 +2671,7 @@ void CEngine::SetClippingDistance(float value)
{
if (value < 0.5f) value = 0.5f;
if (value > 2.0f) value = 2.0f;
+ m_lastClippingDistance = m_clippingDistance;
m_clippingDistance = value;
}
@@ -2886,7 +2883,6 @@ void CEngine::ApplyChange()
m_deepView[1] /= m_lastClippingDistance;
SetFocus(m_focus);
- ChangeLOD();
m_deepView[0] *= m_clippingDistance;
m_deepView[1] *= m_clippingDistance;
@@ -2905,7 +2901,8 @@ void CEngine::ApplyChange()
viewport, and renders the scene. */
void CEngine::Render()
{
- if (! m_render) return;
+ if (! m_render)
+ return;
m_statisticTriangle = 0;
m_lastState = -1;
@@ -2928,7 +2925,9 @@ void CEngine::Render()
if (m_drawWorld)
Draw3DScene();
+ m_app->StartPerformanceCounter(PCNT_RENDER_INTERFACE);
DrawInterface();
+ m_app->StopPerformanceCounter(PCNT_RENDER_INTERFACE);
// End the scene
m_device->EndScene();
@@ -2959,68 +2958,61 @@ void CEngine::Draw3DScene()
if (m_waterMode) m_water->DrawBack(); // draws water background
+ m_app->StartPerformanceCounter(PCNT_RENDER_TERRAIN);
+
+ // Draw terrain with shadows, if shadows enabled
if (m_shadowVisible)
{
m_lightMan->UpdateDeviceLights(ENG_OBJTYPE_TERRAIN);
- // Draw the terrain
-
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int objRank = 0; objRank < static_cast<int>(m_objects.size()); objRank++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ if (! m_objects[objRank].used)
+ continue;
- // Should be loaded by now
- SetTexture(p1.tex1, 0);
- SetTexture(p1.tex2, 1);
+ if (m_objects[objRank].type != ENG_OBJTYPE_TERRAIN)
+ continue;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ if (! m_objects[objRank].drawWorld)
+ continue;
- int objRank = p2.objRank;
- if (m_objects[objRank].type != ENG_OBJTYPE_TERRAIN)
- continue;
- if (! m_objects[objRank].drawWorld)
- continue;
+ m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
- m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
+ if (! IsVisible(objRank))
+ continue;
- if (! IsVisible(objRank))
- continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ continue;
+
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
+
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
+
+ SetTexture(p2.tex1, 0);
+ SetTexture(p2.tex2, 1);
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if ( m_objects[objRank].distance < p3.min ||
- m_objects[objRank].distance >= p3.max )
+ if (! IsWithinLODLimit(m_objects[objRank].distance, p3.lodLevel))
continue;
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
SetMaterial(p4.material);
SetState(p4.state);
- if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLES,
- &p4.vertices[0],
- p4.vertices.size() );
- m_statisticTriangle += p4.vertices.size() / 3;
- }
- if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLE_STRIP,
- &p4.vertices[0],
- p4.vertices.size() );
- m_statisticTriangle += p4.vertices.size() - 2;
- }
+ DrawObject(p4);
}
}
}
@@ -3030,51 +3022,59 @@ void CEngine::Draw3DScene()
DrawShadow();
}
- // Draw objects (non-terrain)
+ m_app->StopPerformanceCounter(PCNT_RENDER_TERRAIN);
+
+ // Draw other objects (and if shadows disabled, also terrain)
+
+ m_app->StartPerformanceCounter(PCNT_RENDER_OBJECTS);
bool transparent = false;
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int objRank = 0; objRank < static_cast<int>(m_objects.size()); objRank++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ if (! m_objects[objRank].used)
+ continue;
+
+ if (m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
+ continue;
- // Should be loaded by now
- SetTexture(p1.tex1, 0);
- SetTexture(p1.tex2, 1);
+ if (! m_objects[objRank].drawWorld)
+ continue;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
- int objRank = p2.objRank;
+ if (! IsVisible(objRank))
+ continue;
- if (m_shadowVisible && m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
- continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ continue;
- if (! m_objects[objRank].drawWorld)
- continue;
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
- if (! IsVisible(objRank))
- continue;
+ m_lightMan->UpdateDeviceLights(m_objects[objRank].type);
- m_lightMan->UpdateDeviceLights(m_objects[objRank].type);
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
+
+ SetTexture(p2.tex1, 0);
+ SetTexture(p2.tex2, 1);
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if ( m_objects[objRank].distance < p3.min ||
- m_objects[objRank].distance >= p3.max ) continue;
+ if (! IsWithinLODLimit(m_objects[objRank].distance, p3.lodLevel))
+ continue;
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
if (m_objects[objRank].transparency != 0.0f) // transparent ?
{
@@ -3085,22 +3085,7 @@ void CEngine::Draw3DScene()
SetMaterial(p4.material);
SetState(p4.state);
- if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLES,
- &p4.vertices[0],
- p4.vertices.size() );
-
- m_statisticTriangle += p4.vertices.size() / 3;
- }
- else if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLE_STRIP,
- &p4.vertices[0],
- p4.vertices.size() );
-
- m_statisticTriangle += p4.vertices.size() - 2;
- }
+ DrawObject(p4);
}
}
}
@@ -3113,47 +3098,51 @@ void CEngine::Draw3DScene()
int tState = ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_2FACE;
Color tColor = Color(68.0f / 255.0f, 68.0f / 255.0f, 68.0f / 255.0f, 68.0f / 255.0f);
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int objRank = 0; objRank < static_cast<int>(m_objects.size()); objRank++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ if (! m_objects[objRank].used)
+ continue;
+
+ if (m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
+ continue;
- // Should be loaded by now
- SetTexture(p1.tex1, 0);
- SetTexture(p1.tex2, 1);
+ if (! m_objects[objRank].drawWorld)
+ continue;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
- int objRank = p2.objRank;
+ if (! IsVisible(objRank))
+ continue;
- if (m_shadowVisible && m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
- continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ continue;
- if (! m_objects[objRank].drawWorld)
- continue;
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
- if (! IsVisible(objRank))
- continue;
+ m_lightMan->UpdateDeviceLights(m_objects[objRank].type);
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
- m_lightMan->UpdateDeviceLights(m_objects[objRank].type);
+ SetTexture(p2.tex1, 0);
+ SetTexture(p2.tex2, 1);
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if ( m_objects[objRank].distance < p3.min ||
- m_objects[objRank].distance >= p3.max ) continue;
+ if (! IsWithinLODLimit(m_objects[objRank].distance, p3.lodLevel))
+ continue;
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
if (m_objects[objRank].transparency == 0.0f)
continue;
@@ -3161,40 +3150,61 @@ void CEngine::Draw3DScene()
SetMaterial(p4.material);
SetState(tState, tColor);
- if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLES,
- &p4.vertices[0],
- p4.vertices.size() );
-
- m_statisticTriangle += p4.vertices.size() / 3;
- }
- else if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLE_STRIP,
- &p4.vertices[0],
- p4.vertices.size() );
- m_statisticTriangle += p4.vertices.size() - 2;
- }
+ DrawObject(p4);
}
}
}
}
}
+ m_app->StopPerformanceCounter(PCNT_RENDER_OBJECTS);
+
m_lightMan->UpdateDeviceLights(ENG_OBJTYPE_TERRAIN);
- if (m_waterMode) m_water->DrawSurf(); // draws water surface
+ if (m_waterMode)
+ {
+ m_app->StartPerformanceCounter(PCNT_RENDER_WATER);
+ m_water->DrawSurf(); // draws water surface
+ m_app->StopPerformanceCounter(PCNT_RENDER_WATER);
+ }
+ m_app->StartPerformanceCounter(PCNT_RENDER_PARTICLE);
m_particle->DrawParticle(SH_WORLD); // draws the particles of the 3D world
+ m_app->StopPerformanceCounter(PCNT_RENDER_PARTICLE);
+
m_lightning->Draw(); // draws lightning
- // TODO: fix white screen error; commenting out temporarily
- // if (m_lensMode) DrawForegroundImage(); // draws the foreground
+ if (m_lensMode) DrawForegroundImage(); // draws the foreground
if (! m_overFront) DrawOverColor(); // draws the foreground color
}
+void CEngine::DrawObject(const EngineBaseObjDataTier& p4)
+{
+ if (p4.staticBufferId != 0)
+ {
+ m_device->DrawStaticBuffer(p4.staticBufferId);
+
+ if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
+ m_statisticTriangle += p4.vertices.size() / 3;
+ else
+ m_statisticTriangle += p4.vertices.size() - 2;
+ }
+ else
+ {
+ if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
+ {
+ m_device->DrawPrimitive(PRIMITIVE_TRIANGLES, &p4.vertices[0], p4.vertices.size());
+ m_statisticTriangle += p4.vertices.size() / 3;
+ }
+ else
+ {
+ m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, &p4.vertices[0], p4.vertices.size() );
+ m_statisticTriangle += p4.vertices.size() - 2;
+ }
+ }
+}
+
void CEngine::DrawInterface()
{
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, false);
@@ -3211,9 +3221,11 @@ void CEngine::DrawInterface()
SetState(Gfx::ENG_RSTATE_NORMAL);
// Draw the entire interface
- Ui::CInterface* interface = static_cast<Ui::CInterface*>( m_iMan->SearchInstance(CLASS_INTERFACE) );
+ Ui::CInterface* interface = CRobotMain::GetInstancePointer()->GetInterface();
if (interface != nullptr)
+ {
interface->Draw();
+ }
m_interfaceMode = false;
m_lastState = -1;
@@ -3240,66 +3252,56 @@ void CEngine::DrawInterface()
m_device->SetTransform(TRANSFORM_VIEW, m_matView);
- for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
+ for (int objRank = 0; objRank < static_cast<int>(m_objects.size()); objRank++)
{
- EngineObjLevel1& p1 = m_objectTree[l1];
- if (! p1.used) continue;
+ if (! m_objects[objRank].used)
+ continue;
- // Should be loaded by now
- SetTexture(p1.tex1, 0);
- SetTexture(p1.tex2, 1);
+ if (m_shadowVisible && m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
+ continue;
- for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
- {
- EngineObjLevel2& p2 = p1.next[l2];
- if (! p2.used) continue;
+ if (! m_objects[objRank].drawFront)
+ continue;
- int objRank = p2.objRank;
+ m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
- if (m_shadowVisible && m_objects[objRank].type == ENG_OBJTYPE_TERRAIN)
- continue;
+ if (! IsVisible(objRank))
+ continue;
- if (! m_objects[objRank].drawFront)
- continue;
+ int baseObjRank = m_objects[objRank].baseObjRank;
+ if (baseObjRank == -1)
+ continue;
- m_device->SetTransform(TRANSFORM_WORLD, m_objects[objRank].transform);
+ assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
- if (! IsVisible(objRank))
- continue;
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
- m_lightMan->UpdateDeviceLights(m_objects[objRank].type);
+ m_lightMan->UpdateDeviceLights(m_objects[objRank].type);
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
+
+ SetTexture(p2.tex1, 0);
+ SetTexture(p2.tex2, 1);
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
{
- EngineObjLevel3& p3 = p2.next[l3];
- if (! p3.used) continue;
+ EngineBaseObjLODTier& p3 = p2.next[l3];
- if ( m_objects[objRank].distance < p3.min ||
- m_objects[objRank].distance >= p3.max ) continue;
+ if (! IsWithinLODLimit(m_objects[objRank].distance, p3.lodLevel))
+ continue;
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
{
- EngineObjLevel4& p4 = p3.next[l4];
- if (! p4.used) continue;
+ EngineBaseObjDataTier& p4 = p3.next[l4];
SetMaterial(p4.material);
SetState(p4.state);
- if (p4.type == ENG_TRIANGLE_TYPE_TRIANGLES)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLES,
- &p4.vertices[0],
- p4.vertices.size() );
-
- m_statisticTriangle += p4.vertices.size() / 3;
- }
- else if (p4.type == ENG_TRIANGLE_TYPE_SURFACE)
- {
- m_device->DrawPrimitive( PRIMITIVE_TRIANGLE_STRIP,
- &p4.vertices[0],
- p4.vertices.size() );
- m_statisticTriangle += p4.vertices.size() - 2;
- }
+ DrawObject(p4);
}
}
}
@@ -3328,8 +3330,270 @@ void CEngine::DrawInterface()
void CEngine::UpdateGroundSpotTextures()
{
- // TODO the original code modifying the textures is very complex, so stub for now
- GetLogger()->Trace("CEngine::UpdateGroundSpotTextures(): stub!\n");
+ if (!m_firstGroundSpot &&
+ m_groundMark.drawPos.x == m_groundMark.pos.x &&
+ m_groundMark.drawPos.z == m_groundMark.pos.z &&
+ m_groundMark.drawRadius == m_groundMark.radius &&
+ m_groundMark.drawIntensity == m_groundMark.intensity)
+ return;
+
+ for (int s = 0; s < 16; s++)
+ {
+ Math::Point min, max;
+ min.x = (s%4) * 254.0f - 1.0f; // 1 pixel cover
+ min.y = (s/4) * 254.0f - 1.0f;
+ max.x = min.x + 254.0f + 2.0f;
+ max.y = min.y + 254.0f + 2.0f;
+
+ bool clear = false;
+ bool set = false;
+
+ // Calculate the area to be erased.
+ int dot = static_cast<int>(m_groundMark.drawRadius/2.0f);
+
+ float tu, tv;
+ float cx, cy;
+
+ tu = (m_groundMark.drawPos.x+1600.0f)/3200.0f;
+ tv = (m_groundMark.drawPos.z+1600.0f)/3200.0f; // 0..1
+
+ cx = (tu*254.0f*4.0f)-0.5f;
+ cy = (tv*254.0f*4.0f)-0.5f;
+
+ if (dot == 0)
+ {
+ cx += 0.5f;
+ cy += 0.5f;
+ }
+
+ float px = cx-Math::Mod(cx, 1.0f);
+ float py = cy-Math::Mod(cy, 1.0f); // multiple of 1
+
+ if (m_firstGroundSpot ||
+ (m_groundMark.drawRadius != 0.0f &&
+ px+dot >= min.x && py+dot >= min.y &&
+ px-dot <= max.x && py-dot <= max.y))
+ {
+ clear = true;
+ }
+
+ // Calculate the area to draw.
+ dot = static_cast<int>(m_groundMark.radius/2.0f);
+
+ tu = (m_groundMark.pos.x+1600.0f)/3200.0f;
+ tv = (m_groundMark.pos.z+1600.0f)/3200.0f; // 0..1
+
+ cx = (tu*254.0f*4.0f)-0.5f;
+ cy = (tv*254.0f*4.0f)-0.5f;
+
+ if ( dot == 0 )
+ {
+ cx += 0.5f;
+ cy += 0.5f;
+ }
+
+ px = cx - Math::Mod(cx, 1.0f);
+ py = cy - Math::Mod(cy, 1.0f); // multiple of 1
+
+ if (m_groundMark.draw &&
+ px+dot >= min.x && py+dot >= min.y &&
+ px-dot <= max.x && py-dot <= max.y)
+ {
+ set = true;
+ }
+
+ if (clear || set)
+ {
+ CImage shadowImg(Math::IntPoint(256, 256));
+ shadowImg.Fill(Gfx::IntColor(255, 255, 255, 255));
+
+ // Draw the new shadows.
+ for (int i = 0; i < static_cast<int>( m_groundSpots.size() ); i++)
+ {
+ if (m_groundSpots[i].used == false ||
+ m_groundSpots[i].radius == 0.0f)
+ continue;
+
+ if (m_groundSpots[i].min == 0.0f &&
+ m_groundSpots[i].max == 0.0f)
+ {
+ dot = static_cast<int>(m_groundSpots[i].radius/2.0f);
+
+ tu = (m_groundSpots[i].pos.x+1600.0f)/3200.0f;
+ tv = (m_groundSpots[i].pos.z+1600.0f)/3200.0f; // 0..1
+
+ cx = (tu*254.0f*4.0f) - 0.5f;
+ cy = (tv*254.0f*4.0f) - 0.5f;
+
+ if (dot == 0)
+ {
+ cx += 0.5f;
+ cy += 0.5f;
+ }
+
+ px = cx-Math::Mod(cx, 1.0f);
+ py = cy-Math::Mod(cy, 1.0f); // multiple of 1
+
+ if (px+dot < min.x || py+dot < min.y ||
+ px-dot > max.x || py-dot > max.y)
+ continue;
+
+ for (int iy = -dot; iy <= dot; iy++)
+ {
+ for (int ix =- dot; ix <= dot; ix++)
+ {
+ float ppx = px+ix;
+ float ppy = py+iy;
+
+ if (ppx < min.x || ppy < min.y ||
+ ppx >= max.x || ppy >= max.y)
+ continue;
+
+ float intensity;
+ if (dot == 0)
+ intensity = 0.0f;
+ else
+ intensity = Math::Point(ppx-cx, ppy-cy).Length()/dot;
+
+ Gfx::Color color;
+ color.r = Math::Norm(m_groundSpots[i].color.r+intensity);
+ color.g = Math::Norm(m_groundSpots[i].color.g+intensity);
+ color.b = Math::Norm(m_groundSpots[i].color.b+intensity);
+
+ ppx -= min.x; // on the texture
+ ppy -= min.y;
+
+ shadowImg.SetPixel(Math::IntPoint(ppx, ppy), color);
+ }
+ }
+ }
+ else
+ {
+ for (int iy = 0; iy < 256; iy++)
+ {
+ for (int ix = 0; ix < 256; ix++)
+ {
+ Math::Vector pos;
+ pos.x = (256.0f * (s%4) + ix) * 3200.0f/1024.0f - 1600.0f;
+ pos.z = (256.0f * (s/4) + iy) * 3200.0f/1024.0f - 1600.0f;
+ pos.y = 0.0f;
+
+ float level = m_terrain->GetFloorLevel(pos, true);
+ if (level < m_groundSpots[i].min ||
+ level > m_groundSpots[i].max)
+ continue;
+
+ float intensity;
+ if (level > (m_groundSpots[i].max+m_groundSpots[i].min)/2.0f)
+ intensity = 1.0f - (m_groundSpots[i].max-level) / m_groundSpots[i].smooth;
+ else
+ intensity = 1.0f - (level-m_groundSpots[i].min) / m_groundSpots[i].smooth;
+
+ if (intensity < 0.0f) intensity = 0.0f;
+
+ Gfx::Color color;
+ color.r = Math::Norm(m_groundSpots[i].color.r+intensity);
+ color.g = Math::Norm(m_groundSpots[i].color.g+intensity);
+ color.b = Math::Norm(m_groundSpots[i].color.b+intensity);
+
+ shadowImg.SetPixel(Math::IntPoint(ix, iy), color);
+ }
+ }
+ }
+ }
+
+ if (set)
+ {
+ dot = static_cast<int>(m_groundMark.radius/2.0f);
+
+ tu = (m_groundMark.pos.x + 1600.0f) / 3200.0f;
+ tv = (m_groundMark.pos.z + 1600.0f) / 3200.0f; // 0..1
+
+ cx = (tu*254.0f*4.0f)-0.5f;
+ cy = (tv*254.0f*4.0f)-0.5f;
+
+ if (dot == 0)
+ {
+ cx += 0.5f;
+ cy += 0.5f;
+ }
+
+ px = cx-Math::Mod(cx, 1.0f);
+ py = cy-Math::Mod(cy, 1.0f); // multiple of 1
+
+ for (int iy = -dot; iy <= dot; iy++)
+ {
+ for (int ix = -dot; ix <= dot; ix++)
+ {
+ float ppx = px+ix;
+ float ppy = py+iy;
+
+ if (ppx < min.x || ppy < min.y ||
+ ppx >= max.x || ppy >= max.y)
+ continue;
+
+ ppx -= min.x; // on the texture
+ ppy -= min.y;
+
+ float intensity = 1.0f - Math::Point(ix, iy).Length() / dot;
+ if (intensity <= 0.0f)
+ continue;
+
+ intensity *= m_groundMark.intensity;
+
+ int j = (ix+dot) + (iy+dot) * m_groundMark.dx;
+ if (m_groundMark.table[j] == 1) // green ?
+ {
+ Gfx::Color color;
+ color.r = Math::Norm(1.0f-intensity);
+ color.g = 1.0f;
+ color.b = Math::Norm(1.0f-intensity);
+ shadowImg.SetPixel(Math::IntPoint(ppx, ppy), color);
+ }
+ if (m_groundMark.table[j] == 2) // red ?
+ {
+ Gfx::Color color;
+ color.r = 1.0f;
+ color.g = Math::Norm(1.0f-intensity);
+ color.b = Math::Norm(1.0f-intensity);
+ shadowImg.SetPixel(Math::IntPoint(ppx, ppy), color);
+ }
+ }
+ }
+ }
+
+ std::stringstream str;
+ str << "shadow" << std::setfill('0') << std::setw(2) << s << ".png";
+ std::string texName = str.str();
+
+ DeleteTexture(texName);
+
+ Gfx::Texture tex = m_device->CreateTexture(&shadowImg, m_defaultTexParams);
+
+ m_texNameMap[texName] = tex;
+ m_revTexNameMap[tex] = texName;
+ }
+ }
+
+ for (int i = 0; i < static_cast<int>( m_groundSpots.size() ); i++)
+ {
+ if (m_groundSpots[i].used == false ||
+ m_groundSpots[i].radius == 0.0f)
+ {
+ m_groundSpots[i].drawRadius = 0.0f;
+ }
+ else
+ {
+ m_groundSpots[i].drawPos = m_groundSpots[i].pos;
+ m_groundSpots[i].drawRadius = m_groundSpots[i].radius;
+ }
+ }
+
+ m_groundMark.drawPos = m_groundMark.pos;
+ m_groundMark.drawRadius = m_groundMark.radius;
+ m_groundMark.drawIntensity = m_groundMark.intensity;
+
+ m_firstGroundSpot = false;
}
void CEngine::DrawShadow()
@@ -3366,11 +3630,13 @@ void CEngine::DrawShadow()
float lastIntensity = -1.0f;
for (int i = 0; i < static_cast<int>( m_shadows.size() ); i++)
{
- if (m_shadows[i].hide) continue;
+ if (m_shadows[i].hide)
+ continue;
Math::Vector pos = m_shadows[i].pos; // pos = center of the shadow on the ground
- if (m_eyePt.y == pos.y) continue; // camera at the same level?
+ if (m_eyePt.y == pos.y)
+ continue; // camera at the same level?
float d = 0.0f;
float D = 0.0f;
@@ -3386,7 +3652,9 @@ void CEngine::DrawShadow()
if ( h > 4.0f ) h = 4.0f;
D = Math::Distance(m_eyePt, pos);
- if ( D >= endDeepView ) continue;
+ if (D >= endDeepView)
+ continue;
+
d = D*h/height;
pos.x += (m_eyePt.x-pos.x)*d/D;
@@ -3402,7 +3670,9 @@ void CEngine::DrawShadow()
if ( h > 4.0f ) h = 4.0f;
D = Math::Distance(m_eyePt, pos);
- if ( D >= endDeepView ) continue;
+ if (D >= endDeepView)
+ continue;
+
d = D*h/height;
pos.x += (m_eyePt.x-pos.x)*d/D;
@@ -3510,7 +3780,8 @@ void CEngine::DrawShadow()
if ( D > startDeepView )
intensity *= 1.0f-(D-startDeepView)/(endDeepView-startDeepView);
- if (intensity == 0.0f) continue;
+ if (intensity == 0.0f)
+ continue;
if (lastIntensity != intensity) // intensity changed?
{
@@ -3526,7 +3797,6 @@ void CEngine::DrawShadow()
m_device->SetRenderState(RENDER_STATE_LIGHTING, true);
}
-// STATUS: TESTED, VERIFIED
void CEngine::DrawBackground()
{
if (m_skyMode && m_cloud->GetLevel() != 0.0f) // clouds ?
@@ -3546,7 +3816,6 @@ void CEngine::DrawBackground()
}
}
-// STATUS: TESTED
void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
{
Math::Point p1(0.0f, 0.5f);
@@ -3577,7 +3846,6 @@ void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
AddStatisticTriangle(2);
}
-// Status: TESTED, VERIFIED
void CEngine::DrawBackgroundImage()
{
Math::Point p1, p2;
@@ -3586,7 +3854,7 @@ void CEngine::DrawBackgroundImage()
p2.x = 1.0f;
p2.y = 1.0f;
-Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
+ Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
float u1, u2, v1, v2;
if (m_backgroundFull)
@@ -3635,7 +3903,8 @@ Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
void CEngine::DrawPlanet()
{
- if (! m_planet->PlanetExist()) return;
+ if (! m_planet->PlanetExist())
+ return;
m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false);
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
@@ -3648,10 +3917,10 @@ void CEngine::DrawPlanet()
m_planet->Draw(); // draws the planets
}
-// Status: PART_TESTED
void CEngine::DrawForegroundImage()
{
- if (m_foregroundName.empty()) return;
+ if (m_foregroundName.empty())
+ return;
Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
@@ -3684,12 +3953,11 @@ void CEngine::DrawForegroundImage()
AddStatisticTriangle(2);
}
-// Status: PART_TESTED
void CEngine::DrawOverColor()
{
- // TODO: fuzzy compare?
- if ( (m_overColor == Color(0.0f, 0.0f, 0.0f, 0.0f) && m_overMode == ENG_RSTATE_TCOLOR_BLACK) ||
- (m_overColor == Color(1.0f, 1.0f, 1.0f, 1.0f) && m_overMode == ENG_RSTATE_TCOLOR_WHITE) ) return;
+ if ((m_overColor == Color(0.0f, 0.0f, 0.0f, 0.0f) && m_overMode == ENG_RSTATE_TCOLOR_BLACK) ||
+ (m_overColor == Color(1.0f, 1.0f, 1.0f, 1.0f) && m_overMode == ENG_RSTATE_TCOLOR_WHITE))
+ return;
Math::Point p1(0.0f, 0.0f);
Math::Point p2(1.0f, 1.0f);
@@ -3703,11 +3971,6 @@ void CEngine::DrawOverColor()
SetState(m_overMode);
- // TODO: set also with m_overMode ?
- m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false);
- m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
- m_device->SetRenderState(RENDER_STATE_FOG, false);
-
m_device->SetTransform(TRANSFORM_VIEW, m_matViewInterface);
m_device->SetTransform(TRANSFORM_PROJECTION, m_matProjInterface);
m_device->SetTransform(TRANSFORM_WORLD, m_matWorldInterface);
@@ -3724,7 +3987,6 @@ void CEngine::DrawOverColor()
AddStatisticTriangle(2);
}
-// Status: TESTED, VERIFIED
void CEngine::DrawHighlight()
{
Math::Point min, max;
@@ -3816,7 +4078,6 @@ void CEngine::DrawHighlight()
m_device->DrawPrimitive(PRIMITIVE_LINE_STRIP, line, 3);
}
-// Status: TESTED, VERIFIED
void CEngine::DrawMouse()
{
MouseMode mode = m_app->GetMouseMode();
@@ -3850,7 +4111,6 @@ void CEngine::DrawMouse()
DrawMouseSprite(pos, m_mouseSize, m_mice[index].icon2);
}
-// Status: TESTED, VERIFIED
void CEngine::DrawMouseSprite(Math::Point pos, Math::Point size, int icon)
{
if (icon == -1)
@@ -3889,15 +4149,10 @@ void CEngine::DrawStats()
if (!m_showStats)
return;
- std::stringstream str;
- str << "Triangles: ";
- str << m_statisticTriangle;
- std::string triangleText = str.str();
-
float height = m_text->GetAscent(FONT_COLOBOT, 12.0f);
float width = 0.2f;
- Math::Point pos(0.04f, 0.04f + height);
+ Math::Point pos(0.04f, 0.04f + 17 * height);
SetState(ENG_RSTATE_OPAQUE_COLOR);
@@ -3905,9 +4160,9 @@ void CEngine::DrawStats()
VertexCol vertex[4] =
{
- VertexCol(Math::Vector(pos.x , pos.y - height, 0.0f), black),
+ VertexCol(Math::Vector(pos.x , pos.y - 17 * height, 0.0f), black),
VertexCol(Math::Vector(pos.x , pos.y + height, 0.0f), black),
- VertexCol(Math::Vector(pos.x + width, pos.y - height, 0.0f), black),
+ VertexCol(Math::Vector(pos.x + width, pos.y - 17 * height, 0.0f), black),
VertexCol(Math::Vector(pos.x + width, pos.y + height, 0.0f), black)
};
@@ -3915,7 +4170,107 @@ void CEngine::DrawStats()
SetState(ENG_RSTATE_TEXT);
- m_text->DrawText(triangleText, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+ std::stringstream str;
+
+ str.str("");
+ str << "Event processing: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_EVENT_PROCESSING);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+ pos.y -= height;
+
+
+ str.str("");
+ str << "Frame update: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_UPDATE_ALL);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Engine update: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_UPDATE_ENGINE);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Particle update: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_UPDATE_PARTICLE);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Game update: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_UPDATE_GAME);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ float otherUpdate = Math::Max(0.0f, m_app->GetPerformanceCounterData(PCNT_UPDATE_ALL) -
+ m_app->GetPerformanceCounterData(PCNT_UPDATE_ENGINE) -
+ m_app->GetPerformanceCounterData(PCNT_UPDATE_PARTICLE) -
+ m_app->GetPerformanceCounterData(PCNT_UPDATE_GAME));
+
+ str.str("");
+ str << "Other update: " << std::fixed << std::setprecision(2) << otherUpdate;
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+ pos.y -= height;
+
+
+ str.str("");
+ str << "Frame render: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_RENDER_ALL);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Particle render: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_RENDER_PARTICLE);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Water render: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_RENDER_WATER);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Terrain render: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_RENDER_TERRAIN);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "Objects render: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_RENDER_OBJECTS);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ str.str("");
+ str << "UI render: " << std::fixed << std::setprecision(2) << m_app->GetPerformanceCounterData(PCNT_RENDER_INTERFACE);
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+
+ float otherRender = m_app->GetPerformanceCounterData(PCNT_RENDER_ALL) -
+ m_app->GetPerformanceCounterData(PCNT_RENDER_PARTICLE) -
+ m_app->GetPerformanceCounterData(PCNT_RENDER_WATER) -
+ m_app->GetPerformanceCounterData(PCNT_RENDER_TERRAIN) -
+ m_app->GetPerformanceCounterData(PCNT_RENDER_OBJECTS) -
+ m_app->GetPerformanceCounterData(PCNT_RENDER_INTERFACE);
+
+ str.str("");
+ str << "Other render: " << std::fixed << std::setprecision(2) << otherRender;
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
+
+ pos.y -= height;
+ pos.y -= height;
+
+
+ str.str("");
+ str << "Triangles: " << m_statisticTriangle;
+ m_text->DrawText(str.str(), FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
pos.y -= height;
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index 27f0173..f9dfd45 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -26,12 +26,15 @@
#include "app/system.h"
#include "common/event.h"
+#include "common/singleton.h"
#include "graphics/core/color.h"
#include "graphics/core/material.h"
#include "graphics/core/texture.h"
#include "graphics/core/vertex.h"
+#include "graphics/engine/modelfile.h"
+
#include "math/intpoint.h"
#include "math/matrix.h"
#include "math/point.h"
@@ -45,7 +48,6 @@
class CApplication;
-class CInstanceManager;
class CObject;
class CSoundInterface;
class CImage;
@@ -151,7 +153,7 @@ struct EngineTriangle
//! 2nd texture
std::string tex2Name;
- EngineTriangle()
+ inline EngineTriangle()
{
state = ENG_RSTATE_NORMAL;
}
@@ -178,6 +180,91 @@ enum EngineObjectType
ENG_OBJTYPE_METAL = 6
};
+
+/**
+ * \struct EngineBaseObjDataTier
+ * \brief Tier 4 of object tree (data)
+ */
+struct EngineBaseObjDataTier
+{
+ EngineTriangleType type;
+ Material material;
+ int state;
+ std::vector<VertexTex2> vertices;
+ unsigned int staticBufferId;
+ bool updateStaticBuffer;
+
+ inline EngineBaseObjDataTier(EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES,
+ const Material& material = Material(),
+ int state = ENG_RSTATE_NORMAL)
+ : type(type), material(material), state(state), staticBufferId(0), updateStaticBuffer(false) {}
+};
+
+/**
+ * \struct EngineBaseObjLODTier
+ * \brief Tier 3 of base object tree (LOD)
+ */
+struct EngineBaseObjLODTier
+{
+ LODLevel lodLevel;
+ std::vector<EngineBaseObjDataTier> next;
+
+ inline EngineBaseObjLODTier(LODLevel lodLevel = LOD_Constant)
+ : lodLevel(lodLevel) {}
+};
+
+/**
+ * \struct EngineBaseObjTexTier
+ * \brief Tier 2 of base object tree (textures)
+ */
+struct EngineBaseObjTexTier
+{
+ std::string tex1Name;
+ Texture tex1;
+ std::string tex2Name;
+ Texture tex2;
+ std::vector<EngineBaseObjLODTier> next;
+
+ inline EngineBaseObjTexTier(const std::string& tex1Name = "", const std::string& tex2Name = "")
+ : tex1Name(tex1Name), tex2Name(tex2Name) {}
+};
+
+/**
+ * \struct BaseEngineObject
+ * \brief Base (template) object - geometry for engine objects
+ *
+ * This is also the tier 1 of base object tree.
+ */
+struct EngineBaseObject
+{
+ //! If true, base object is valid in objects vector
+ bool used;
+ //! Number of triangles
+ int totalTriangles;
+ //! Bounding box min (origin 0,0,0 always included)
+ Math::Vector bboxMin;
+ //! bounding box max (origin 0,0,0 always included)
+ Math::Vector bboxMax;
+ //! Radius of the sphere at the origin
+ float radius;
+ //! Next tier (LOD)
+ std::vector<EngineBaseObjTexTier> next;
+
+ inline EngineBaseObject()
+ {
+ LoadDefault();
+ }
+
+ inline void LoadDefault()
+ {
+ used = false;
+ totalTriangles = 0;
+ bboxMax.LoadZero();
+ bboxMin.LoadZero();
+ radius = 0.0f;
+ }
+};
+
/**
* \struct EngineObject
* \brief Object drawn by the graphics engine
@@ -186,33 +273,27 @@ struct EngineObject
{
//! If true, object is valid in objects vector
bool used;
+ //! Rank of associated base engine object
+ int baseObjRank;
//! If true, the object is drawn
bool visible;
//! If true, object is behind the 2D interface
bool drawWorld;
//! If true, the shape is before the 2D interface
bool drawFront;
- //! Number of triangles
- int totalTriangles;
//! Type of object
- EngineObjectType type;
+ EngineObjectType type;
//! Transformation matrix
Math::Matrix transform;
//! Distance to object from eye point
float distance;
- //! Bounding box min (origin 0,0,0 always included)
- Math::Vector bboxMin;
- //! bounding box max (origin 0,0,0 always included)
- Math::Vector bboxMax;
- //! Radius of the sphere at the origin
- float radius;
//! Rank of the associated shadow
int shadowRank;
//! Transparency of the object [0, 1]
float transparency;
//! Calls LoadDefault()
- EngineObject()
+ inline EngineObject()
{
LoadDefault();
}
@@ -221,88 +302,18 @@ struct EngineObject
inline void LoadDefault()
{
used = false;
+ baseObjRank = -1;
visible = false;
drawWorld = false;
drawFront = false;
- totalTriangles = 0;
type = ENG_OBJTYPE_NULL;
transform.LoadIdentity();
- bboxMax.LoadZero();
- bboxMin.LoadZero();
distance = 0.0f;
- radius = 0.0f;
shadowRank = -1;
transparency = 0.0f;
}
};
-struct EngineObjLevel1;
-struct EngineObjLevel2;
-struct EngineObjLevel3;
-struct EngineObjLevel4;
-
-/**
- * \struct EngineObjLevel4
- * \brief Tier 4 of object tree
- */
-struct EngineObjLevel4
-{
- bool used;
- EngineTriangleType type;
- Material material;
- int state;
- std::vector<VertexTex2> vertices;
-
- EngineObjLevel4(bool used = false,
- EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES,
- const Material& material = Material(),
- int state = ENG_RSTATE_NORMAL);
-};
-
-/**
- * \struct EngineObjLevel3
- * \brief Tier 3 of object tree
- */
-struct EngineObjLevel3
-{
- bool used;
- float min;
- float max;
- std::vector<EngineObjLevel4> next;
-
- EngineObjLevel3(bool used = false, float min = 0.0f, float max = 0.0f);
-};
-
-/**
- * \struct EngineObjLevel2
- * \brief Tier 2 of object tree
- */
-struct EngineObjLevel2
-{
- bool used;
- int objRank;
- std::vector<EngineObjLevel3> next;
-
- EngineObjLevel2(bool used = false, int objRank = -1);
-};
-
-/**
- * \struct EngineObjLevel1
- * \brief Tier 1 of object tree
- */
-struct EngineObjLevel1
-{
- bool used;
- std::string tex1Name;
- Texture tex1;
- std::string tex2Name;
- Texture tex2;
- std::vector<EngineObjLevel2> next;
-
- EngineObjLevel1(bool used = false, const std::string& tex1Name = "",
- const std::string& tex2Name = "");
-};
-
/**
* \struct EngineShadowType
* \brief Type of shadow drawn by the graphics engine
@@ -342,12 +353,12 @@ struct EngineShadow
//! Height from the ground
float height;
- EngineShadow()
+ inline EngineShadow()
{
LoadDefault();
}
- void LoadDefault()
+ inline void LoadDefault()
{
used = false;
hide = false;
@@ -384,12 +395,12 @@ struct EngineGroundSpot
//! Radius of the shadow drawn
float drawRadius;
- EngineGroundSpot()
+ inline EngineGroundSpot()
{
LoadDefault();
}
- void LoadDefault()
+ inline void LoadDefault()
{
used = false;
color = Color();
@@ -448,12 +459,12 @@ struct EngineGroundMark
//! Pointer to the table
char* table;
- EngineGroundMark()
+ inline EngineGroundMark()
{
LoadDefault();
}
- void LoadDefault()
+ inline void LoadDefault()
{
draw = false;
phase = ENG_GR_MARK_PHASE_NULL;
@@ -545,10 +556,10 @@ struct EngineMouse
//! Hot point
Math::Point hotPoint;
- EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1,
- EngineRenderState mode1 = ENG_RSTATE_NORMAL,
- EngineRenderState mode2 = ENG_RSTATE_NORMAL,
- Math::Point hotPoint = Math::Point())
+ inline EngineMouse(int icon1 = -1, int icon2 = -1, int iconShadow = -1,
+ EngineRenderState mode1 = ENG_RSTATE_NORMAL,
+ EngineRenderState mode2 = ENG_RSTATE_NORMAL,
+ Math::Point hotPoint = Math::Point())
{
this->icon1 = icon1;
this->icon2 = icon2;
@@ -609,27 +620,36 @@ struct EngineMouse
*
* Objects are uniquely identified by object rank obtained at object creation. Creating an
* object equals to allocating space for EngineObject structure which holds object parameters.
- * Object's geometric data is stored in a separate structure - a 4-tier tree which splits
- * the information of each geometric triangle.
+ *
+ * Object's geometric data is stored as a separate object -- base engine object. Each object
+ * must reference a valid base engine object or an empty base engine object (with rank = -1).
+ * This many-to-one association allows to share same geometric data (e.g. from same model)
+ * across objects.
+ *
+ * Base engine object data is stored in a 4-tier tree which splits the data describing triangles.
*
* The 4 tiers contain the following information:
- * - level 1 (EngineObjLevel1) - two textures (names and structs) applied to triangles,
- * - level 2 (EngineObjLevel2) - object rank
- * - level 3 (EngineObjLevel3) - minumum and maximum LOD (=level of detail)
- * - level 4 (EngineObjLevel4) - type of object*, material, render state and the actual triangle data
+ * - level 1 (EngineBaseObject) - geometric statistics
+ * - level 2 (EngineBaseObjTexTier) - two textures (names and structs) applied to triangles,
+ * - level 3 (EngineBaseObjLODTier) - minumum and maximum LOD (=level of detail)
+ * - level 4 (EngineBaseObjDataTier) - type of object*, material, render state and the actual vertex data
*
- * NOTE: type of object in this context means only the internal type in 3D engine. It is not related
+ * *NOTE: type of object in this context means only the internal type in 3D engine. It is not related
* to CObject types.
*
+ * Last tier containing vertex data contains also an ID of static buffer holding the data.
+ * The static buffer is created and updated with new data as needed.
+ *
* Such tiered structure complicates loops over all object data, but saves a lot of memory and
- * optimizes the rendering process (for instance, switching of textures is an expensive operation).
+ * optimizes the rendering process.
*
* \section Shadows Shadows
*
* Each engine object can be associated with a shadow (EngineShadow). Like objects, shadows are
* identified by their rank obtained upon creation.
*
- * ...
+ * Shadows are drawn as circular spots on the ground, except for shadows for worms, which have
+ * special mode for them.
*
* \section RenderStates Render States
*
@@ -651,22 +671,36 @@ struct EngineMouse
* which is what OpenGL actually wants. The old method is kept for now, with mapping between texture names
* and texture structs but it will also be subject to refactoring in the future.
*/
-class CEngine
+class CEngine : public CSingleton<CEngine>
{
public:
- CEngine(CInstanceManager* iMan, CApplication* app);
+ CEngine(CApplication* app);
~CEngine();
//! Sets the device to be used
void SetDevice(CDevice* device);
//! Returns the current device
- CDevice* GetDevice();
-
- //! Sets the terrain object
- void SetTerrain(CTerrain* terrain);
+ CDevice* GetDevice();
//! Returns the text rendering engine
CText* GetText();
+ //! Returns the light manager
+ CLightManager* GetLightManager();
+ //! Returns the particle manager
+ CParticle* GetParticle();
+ //! Returns the terrain manager
+ CTerrain* GetTerrain();
+ //! Returns the water manager
+ CWater* GetWater();
+ //! Returns the lighting manager
+ CLightning* GetLightning();
+ //! Returns the planet manager
+ CPlanet* GetPlanet();
+ //! Returns the fog manager
+ CCloud* GetCloud();
+
+ //! Sets the terrain object
+ void SetTerrain(CTerrain* terrain);
//! Performs the initialization; must be called after device was set
@@ -692,16 +726,10 @@ public:
//! Writes a screenshot containing the current frame
bool WriteScreenShot(const std::string& fileName, int width, int height);
-
- //! Reads settings from INI
- bool ReadSettings();
- //! Writes settings to INI
- bool WriteSettings();
-
//@{
//! Management of game pause mode
void SetPause(bool pause);
- bool GetPause();
+ TEST_VIRTUAL bool GetPause();
//@}
//@{
@@ -721,8 +749,6 @@ public:
//! Returns current size of viewport window
Math::IntPoint GetWindowSize();
- //! Returns the last size of viewport window
- Math::IntPoint GetLastWindowSize();
//@{
//! Conversion functions between window and interface coordinates
@@ -747,81 +773,93 @@ public:
/* *************** Object management *************** */
+ // Base objects
+
+ //! Creates a base object and returns its rank
+ int CreateBaseObject();
+ //! Deletes a base object
+ void DeleteBaseObject(int baseObjRank);
+ //! Deletes all base objects
+ void DeleteAllBaseObjects();
+
+ //! Copies geometry between two base objects
+ void CopyBaseObject(int sourceBaseObjRank, int destBaseObjRank);
+
+ //! Adds triangles to given object with the specified params
+ void AddBaseObjTriangles(int baseObjRank, const std::vector<VertexTex2>& vertices,
+ EngineTriangleType triangleType,
+ const Material& material, int state,
+ std::string tex1Name, std::string tex2Name,
+ LODLevel lodLevel, bool globalUpdate);
+
+ //! Adds a tier 4 engine object directly
+ void AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buffer,
+ std::string tex1Name, std::string tex2Name,
+ LODLevel lodLevel, bool globalUpdate);
+
+ // Objects
+
//! Creates a new object and returns its rank
int CreateObject();
//! Deletes all objects, shadows and ground spots
- void FlushObject();
+ void DeleteAllObjects();
//! Deletes the given object
- bool DeleteObject(int objRank);
+ void DeleteObject(int objRank);
+
+ //@{
+ //! Management of the base object rank for engine object
+ void SetObjectBaseRank(int objRank, int baseObjRank);
+ int GetObjectBaseRank(int objRank);
+ //@}
//@{
//! Management of engine object type
- bool SetObjectType(int objRank, EngineObjectType type);
+ void SetObjectType(int objRank, EngineObjectType type);
EngineObjectType GetObjectType(int objRank);
//@}
//@{
//! Management of object transform
- bool SetObjectTransform(int objRank, const Math::Matrix& transform);
- bool GetObjectTransform(int objRank, Math::Matrix& transform);
+ void SetObjectTransform(int objRank, const Math::Matrix& transform);
+ void GetObjectTransform(int objRank, Math::Matrix& transform);
//@}
//! Sets drawWorld for given object
- bool SetObjectDrawWorld(int objRank, bool draw);
+ void SetObjectDrawWorld(int objRank, bool draw);
//! Sets drawFront for given object
- bool SetObjectDrawFront(int objRank, bool draw);
+ void SetObjectDrawFront(int objRank, bool draw);
//! Sets the transparency level for given object
- bool SetObjectTransparency(int objRank, float value);
+ void SetObjectTransparency(int objRank, float value);
//! Returns the bounding box for an object
- bool GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max);
+ void GetObjectBBox(int objRank, Math::Vector& min, Math::Vector& max);
//! Returns the total number of triangles of given object
int GetObjectTotalTriangles(int objRank);
- //! Adds triangles to given object with the specified params
- bool AddTriangles(int objRank, const std::vector<VertexTex2>& vertices,
- const Material& material, int state,
- std::string tex1Name, std::string tex2Name,
- float min, float max, bool globalUpdate);
-
- //! Adds a surface to given object with the specified params
- bool AddSurface(int objRank, const std::vector<VertexTex2>& vertices,
- const Material& material, int state,
- std::string tex1Name, std::string tex2Name,
- float min, float max, bool globalUpdate);
-
- //! Adds a tier 4 engine object directly
- bool AddQuick(int objRank, const EngineObjLevel4& buffer,
- std::string tex1Name, std::string tex2Name,
- float min, float max, bool globalUpdate);
-
//! Returns the first found tier 4 engine object for the given params or nullptr if not found
- EngineObjLevel4* FindTriangles(int objRank, const Material& material,
- int state, std::string tex1Name, std::string tex2Name,
- float min, float max);
+ EngineBaseObjDataTier* FindTriangles(int objRank, const Material& material,
+ int state, std::string tex1Name, std::string tex2Name,
+ int lodLevelMask);
//! Returns a partial list of triangles for given object
- int GetPartialTriangles(int objRank, float min, float max, float percent, int maxCount,
+ int GetPartialTriangles(int objRank, int lodLevelMask, float percent, int maxCount,
std::vector<EngineTriangle>& triangles);
- //! Updates LOD after parameter or resolution change
- void ChangeLOD();
-
//! Changes the 2nd texure for given object
- bool ChangeSecondTexture(int objRank, const std::string& tex2Name);
+ void ChangeSecondTexture(int objRank, const std::string& tex2Name);
//! Changes (recalculates) texture mapping for given object
- bool ChangeTextureMapping(int objRank, const Material& mat, int state,
+ void ChangeTextureMapping(int objRank, const Material& mat, int state,
const std::string& tex1Name, const std::string& tex2Name,
- float min, float max, EngineTextureMapping mode,
+ int lodLevelMask, EngineTextureMapping mode,
float au, float bu, float av, float bv);
//! Changes texture mapping for robot tracks
- bool TrackTextureMapping(int objRank, const Material& mat, int state,
+ void TrackTextureMapping(int objRank, const Material& mat, int state,
const std::string& tex1Name, const std::string& tex2Name,
- float min, float max, EngineTextureMapping mode,
+ int lodLevelMask, EngineTextureMapping mode,
float pos, float factor, float tl, float ts, float tt);
//! Detects the target object that is selected with the mouse
@@ -829,20 +867,20 @@ public:
int DetectObject(Math::Point mouse);
//! Creates a shadow for the given object
- bool CreateShadow(int objRank);
+ void CreateShadow(int objRank);
//! Deletes the shadow for given object
void DeleteShadow(int objRank);
//@{
//! Management of different shadow params
- bool SetObjectShadowHide(int objRank, bool hide);
- bool SetObjectShadowType(int objRank, EngineShadowType type);
- bool SetObjectShadowPos(int objRank, const Math::Vector& pos);
- bool SetObjectShadowNormal(int objRank, const Math::Vector& normal);
- bool SetObjectShadowAngle(int objRank, float angle);
- bool SetObjectShadowRadius(int objRank, float radius);
- bool SetObjectShadowIntensity(int objRank, float intensity);
- bool SetObjectShadowHeight(int objRank, float height);
+ void SetObjectShadowHide(int objRank, bool hide);
+ void SetObjectShadowType(int objRank, EngineShadowType type);
+ void SetObjectShadowPos(int objRank, const Math::Vector& pos);
+ void SetObjectShadowNormal(int objRank, const Math::Vector& normal);
+ void SetObjectShadowAngle(int objRank, float angle);
+ void SetObjectShadowRadius(int objRank, float radius);
+ void SetObjectShadowIntensity(int objRank, float intensity);
+ void SetObjectShadowHeight(int objRank, float height);
float GetObjectShadowRadius(int objRank);
//@}
@@ -852,7 +890,7 @@ public:
bool GetHighlight(Math::Point& p1, Math::Point& p2);
//! Deletes all ground spots
- void FlushGroundSpot();
+ void DeleteAllGroundSpots();
//! Creates a new ground spot and returns its rank
int CreateGroundSpot();
//! Deletes the given ground spot
@@ -860,11 +898,11 @@ public:
//@{
//! Management of different ground spot params
- bool SetObjectGroundSpotPos(int rank, const Math::Vector& pos);
- bool SetObjectGroundSpotRadius(int rank, float radius);
- bool SetObjectGroundSpotColor(int rank, const Color& color);
- bool SetObjectGroundSpotMinMax(int rank, float min, float max);
- bool SetObjectGroundSpotSmooth(int rank, float smooth);
+ void SetObjectGroundSpotPos(int rank, const Math::Vector& pos);
+ void SetObjectGroundSpotRadius(int rank, float radius);
+ void SetObjectGroundSpotColor(int rank, const Color& color);
+ void SetObjectGroundSpotMinMax(int rank, float min, float max);
+ void SetObjectGroundSpotSmooth(int rank, float smooth);
//@}
//! Creates the ground mark with the given params
@@ -919,12 +957,6 @@ public:
//! Deletes the given texture, unloading it and removing from cache
void DeleteTexture(const Texture& tex);
- //@{
- //! Border management (distance limits) depends of the resolution (LOD = level-of-detail)
- void SetLimitLOD(int rank, float limit);
- float GetLimitLOD(int rank, bool last=false);
- //@}
-
//! Defines of the distance field of vision
void SetTerrainVision(float vision);
@@ -1138,9 +1170,9 @@ public:
//! Returns the view matrix
const Math::Matrix& GetMatView();
//! Returns the camera center point
- Math::Vector GetEyePt();
+ TEST_VIRTUAL Math::Vector GetEyePt();
//! Returns the camera target point
- Math::Vector GetLookatPt();
+ TEST_VIRTUAL Math::Vector GetLookatPt();
//! Returns the horizontal direction angle of view
float GetEyeDirH();
//! Returns the vertical direction angle of view
@@ -1157,6 +1189,8 @@ public:
protected:
//! Prepares the interface for 3D scene
void Draw3DScene();
+ //! Draw 3D object
+ void DrawObject(const EngineBaseObjDataTier& p4);
//! Draws the user interface over the scene
void DrawInterface();
@@ -1186,15 +1220,13 @@ protected:
//! Draw statistic texts
void DrawStats();
- //! Creates new tier 1 object
- EngineObjLevel1& AddLevel1(const std::string& tex1Name, const std::string& tex2Name);
- //! Creates a new tier 2 object
- EngineObjLevel2& AddLevel2(EngineObjLevel1 &p1, int objRank);
- //! Creates a new tier 3 object
- EngineObjLevel3& AddLevel3(EngineObjLevel2 &p2, float min, float max);
- //! Creates a new tier 4 object
- EngineObjLevel4& AddLevel4(EngineObjLevel3 &p3, EngineTriangleType type,
- const Material& mat, int state);
+ //! Creates a new tier 2 object (texture)
+ EngineBaseObjTexTier& AddLevel2(EngineBaseObject& p1, const std::string& tex1Name, const std::string& tex2Name);
+ //! Creates a new tier 3 object (LOD)
+ EngineBaseObjLODTier& AddLevel3(EngineBaseObjTexTier &p2, LODLevel lodLevel);
+ //! Creates a new tier 4 object (data)
+ EngineBaseObjDataTier& AddLevel4(EngineBaseObjLODTier &p3, EngineTriangleType type,
+ const Material& mat, int state);
//! Create texture and add it to cache
Texture CreateTexture(const std::string &texName, const TextureCreateParams &params, CImage* image = nullptr);
@@ -1202,6 +1234,9 @@ protected:
//! Tests whether the given object is visible
bool IsVisible(int objRank);
+ //! Checks whether the given distance is within LOD min & max limit
+ bool IsWithinLODLimit(float distance, LODLevel lodLevel);
+
//! Detects whether an object is affected by the mouse
bool DetectBBox(int objRank, Math::Point mouse);
@@ -1221,8 +1256,13 @@ protected:
//! Updates geometric parameters of objects (bounding box and radius)
void UpdateGeometry();
+ //! Updates a given static buffer
+ void UpdateStaticBuffer(EngineBaseObjDataTier& p4);
+
+ //! Updates static buffers of changed objects
+ void UpdateStaticBuffers();
+
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
CSoundInterface* m_sound;
CDevice* m_device;
@@ -1270,11 +1310,9 @@ protected:
//! Current size of viewport window
Math::IntPoint m_size;
- //! Previous size of viewport window
- Math::IntPoint m_lastSize;
- //! Root of tree object structure (level 1 list)
- std::vector<EngineObjLevel1> m_objectTree;
+ //! Base objects (also level 1 tier list)
+ std::vector<EngineBaseObject> m_baseObjects;
//! Object parameters
std::vector<EngineObject> m_objects;
//! Shadow list
@@ -1299,6 +1337,7 @@ protected:
Color m_waterAddColor;
int m_statisticTriangle;
bool m_updateGeometry;
+ bool m_updateStaticBuffers;
int m_alphaMode;
bool m_groundSpotVisible;
bool m_shadowVisible;
@@ -1321,12 +1360,10 @@ protected:
Texture m_foregroundTex;
bool m_drawWorld;
bool m_drawFront;
- float m_limitLOD[2];
float m_particleDensity;
float m_clippingDistance;
float m_lastClippingDistance;
float m_objectDetail;
- float m_lastObjectDetail;
float m_terrainVision;
float m_gadgetQuantity;
int m_textureQuality;
diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp
index 3055f08..16c84ea 100644
--- a/src/graphics/engine/lightman.cpp
+++ b/src/graphics/engine/lightman.cpp
@@ -19,7 +19,6 @@
#include "graphics/engine/lightman.h"
#include "common/logger.h"
-#include "common/iman.h"
#include "graphics/core/device.h"
@@ -27,6 +26,7 @@
#include <cmath>
+#include <algorithm>
// Graphics module namespace
@@ -78,11 +78,8 @@ DynamicLight::DynamicLight()
-CLightManager::CLightManager(CInstanceManager* iMan, CEngine* engine)
+CLightManager::CLightManager(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_LIGHT, this);
-
m_device = nullptr;
m_engine = engine;
@@ -91,9 +88,6 @@ CLightManager::CLightManager(CInstanceManager* iMan, CEngine* engine)
CLightManager::~CLightManager()
{
- m_iMan->DeleteInstance(CLASS_LIGHT, this);
-
- m_iMan = nullptr;
m_device = nullptr;
m_engine = nullptr;
}
@@ -132,6 +126,7 @@ int CLightManager::CreateLight(LightPriority priority)
m_dynLights[index].light.type = LIGHT_DIRECTIONAL;
m_dynLights[index].light.diffuse = Color(0.5f, 0.5f, 0.5f);
+ m_dynLights[index].light.ambient = Color(0.0f, 0.0f, 0.0f);
m_dynLights[index].light.position = Math::Vector(-100.0f, 100.0f, -100.0f);
m_dynLights[index].light.direction = Math::Vector( 1.0f, -1.0f, 1.0f);
@@ -393,68 +388,35 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type)
for (int i = 0; i < static_cast<int>( m_lightMap.size() ); ++i)
m_lightMap[i] = -1;
- // High priority
- for (int i = 0; i < static_cast<int>( m_dynLights.size() ); i++)
- {
- if (! m_dynLights[i].used)
- continue;
- if (! m_dynLights[i].enabled)
- continue;
- if (Math::IsZero(m_dynLights[i].intensity.current))
- continue;
- if (m_dynLights[i].priority == LIGHT_PRI_LOW)
- continue;
-
- bool enabled = true;
- if (m_dynLights[i].includeType != ENG_OBJTYPE_NULL)
- enabled = (m_dynLights[i].includeType == type);
-
- if (m_dynLights[i].excludeType != ENG_OBJTYPE_NULL)
- enabled = (m_dynLights[i].excludeType != type);
+ std::vector<DynamicLight> sortedLights = m_dynLights;
+ LightsComparator lightsComparator(m_engine->GetEyePt(), type);
+ std::sort(sortedLights.begin(), sortedLights.end(), lightsComparator);
- if (enabled)
- {
- for (int j = 0; j < static_cast<int>( m_lightMap.size() ); ++j)
- {
- if (m_lightMap[j] == -1)
- {
- m_lightMap[j] = i;
- break;
- }
- }
- }
- }
-
- // Low priority
- for (int i = 0; i < static_cast<int>( m_dynLights.size() ); i++)
+ int lightMapIndex = 0;
+ for (int i = 0; i < static_cast<int>( sortedLights.size() ); i++)
{
- if (! m_dynLights[i].used)
- continue;
- if (! m_dynLights[i].enabled)
+ if (! sortedLights[i].used)
continue;
- if (m_dynLights[i].intensity.current == 0.0f)
+ if (! sortedLights[i].enabled)
continue;
- if (m_dynLights[i].priority == LIGHT_PRI_HIGH)
+ if (sortedLights[i].intensity.current == 0.0f)
continue;
bool enabled = true;
- if (m_dynLights[i].includeType != ENG_OBJTYPE_NULL)
- enabled = (m_dynLights[i].includeType == type);
+ if (sortedLights[i].includeType != ENG_OBJTYPE_NULL)
+ enabled = (sortedLights[i].includeType == type);
- if (m_dynLights[i].excludeType != ENG_OBJTYPE_NULL)
- enabled = (m_dynLights[i].excludeType != type);
+ if (sortedLights[i].excludeType != ENG_OBJTYPE_NULL)
+ enabled = (sortedLights[i].excludeType != type);
if (enabled)
{
- for (int j = 0; j < static_cast<int>( m_lightMap.size() ); ++j)
- {
- if (m_lightMap[j] == -1)
- {
- m_lightMap[j] = i;
- break;
- }
- }
+ m_lightMap[lightMapIndex] = i;
+ ++lightMapIndex;
}
+
+ if (lightMapIndex >= static_cast<int>( m_lightMap.size() ))
+ break;
}
for (int i = 0; i < static_cast<int>( m_lightMap.size() ); ++i)
@@ -462,7 +424,8 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type)
int rank = m_lightMap[i];
if (rank != -1)
{
- m_device->SetLight(i, m_dynLights[rank].light);
+ sortedLights[rank].light.ambient = Gfx::Color(0.2f, 0.2f, 0.2f);
+ m_device->SetLight(i, sortedLights[rank].light);
m_device->SetLightEnabled(i, true);
}
else
@@ -472,5 +435,33 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type)
}
}
+// -----------
+
+CLightManager::LightsComparator::LightsComparator(Math::Vector eyePos, EngineObjectType objectType)
+{
+ m_eyePos = eyePos;
+ m_objectType = objectType;
+}
+
+float CLightManager::LightsComparator::GetLightWeight(const DynamicLight& dynLight)
+{
+ bool enabled = true;
+ if (!dynLight.used || !dynLight.enabled || dynLight.intensity.current == 0.0f)
+ enabled = false;
+ else if (dynLight.includeType != ENG_OBJTYPE_NULL)
+ enabled = dynLight.includeType == m_objectType;
+ else if (dynLight.excludeType != ENG_OBJTYPE_NULL)
+ enabled = dynLight.excludeType != m_objectType;
+
+ return enabled ? ( (dynLight.light.position - m_eyePos).Length() * dynLight.priority ) : 10000.0f;
+}
+
+bool CLightManager::LightsComparator::operator()(const DynamicLight& left, const DynamicLight& right)
+{
+ float leftWeight = GetLightWeight(left);
+ float rightWeight = GetLightWeight(right);
+
+ return leftWeight < rightWeight;
+}
} // namespace Gfx
diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h
index d83dfb3..ab66524 100644
--- a/src/graphics/engine/lightman.h
+++ b/src/graphics/engine/lightman.h
@@ -71,8 +71,8 @@ struct LightProgression
*/
enum LightPriority
{
- LIGHT_PRI_HIGH,
- LIGHT_PRI_LOW
+ LIGHT_PRI_HIGH = 1,
+ LIGHT_PRI_LOW = 2
};
/**
@@ -129,7 +129,7 @@ class CLightManager
{
public:
//! Constructor
- CLightManager(CInstanceManager *iMan, CEngine* engine);
+ CLightManager(CEngine* engine);
//! Destructor
virtual ~CLightManager();
@@ -189,7 +189,21 @@ public:
void UpdateDeviceLights(EngineObjectType type);
protected:
- CInstanceManager* m_iMan;
+ class LightsComparator
+ {
+ public:
+ LightsComparator(Math::Vector eyePos, EngineObjectType objectType);
+
+ bool operator()(const DynamicLight& left, const DynamicLight& right);
+
+ private:
+ float GetLightWeight(const DynamicLight& dynLight);
+
+ Math::Vector m_eyePos;
+ EngineObjectType m_objectType;
+ };
+
+protected:
CEngine* m_engine;
CDevice* m_device;
@@ -197,7 +211,7 @@ protected:
float m_time;
//! List of dynamic lights
std::vector<DynamicLight> m_dynLights;
- //! Map of current light allotment: graphics light -> dynamic light
+ //! Map of current light allocation: graphics light -> dynamic light
std::vector<int> m_lightMap;
};
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index d256599..5fdae51 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -18,6 +18,8 @@
#include "graphics/engine/lightning.h"
+#include "app/app.h"
+
#include "common/logger.h"
#include "common/iman.h"
@@ -25,22 +27,20 @@
#include "graphics/engine/camera.h"
#include "graphics/engine/terrain.h"
+#include "math/geometry.h"
+
#include "object/object.h"
+#include "object/robotmain.h"
#include "object/auto/autopara.h"
-#include "math/geometry.h"
-
// Graphics module namespace
namespace Gfx {
-CLightning::CLightning(CInstanceManager* iMan, CEngine* engine)
+CLightning::CLightning(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_BLITZ, this);
-
m_engine = engine;
m_terrain = nullptr;
m_camera = nullptr;
@@ -187,13 +187,13 @@ bool CLightning::Create(float sleep, float delay, float magnetic)
m_speed = 1.0f / m_sleep;
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
if (m_camera == nullptr)
- m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
return false;
}
@@ -312,12 +312,14 @@ CObject* CLightning::SearchObject(Math::Vector pos)
std::vector<Math::Vector> paraObjPos;
paraObjPos.reserve(100);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Seeking the object closest to the point of impact of lightning.
CObject* bestObj = 0;
float min = 100000.0f;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive object?
diff --git a/src/graphics/engine/lightning.h b/src/graphics/engine/lightning.h
index b21f681..7809a6c 100644
--- a/src/graphics/engine/lightning.h
+++ b/src/graphics/engine/lightning.h
@@ -28,7 +28,6 @@
#include "math/vector.h"
-class CInstanceManager;
class CObject;
class CSoundInterface;
@@ -53,7 +52,7 @@ const float LTNG_PROTECTION_RADIUS = 200.0f;
class CLightning
{
public:
- CLightning(CInstanceManager* iMan, CEngine* engine);
+ CLightning(CEngine* engine);
~CLightning();
//! Triggers lightning
@@ -80,7 +79,6 @@ protected:
CObject* SearchObject(Math::Vector pos);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
diff --git a/src/graphics/engine/modelfile.cpp b/src/graphics/engine/modelfile.cpp
index c0d04a0..f6d7a7b 100644
--- a/src/graphics/engine/modelfile.cpp
+++ b/src/graphics/engine/modelfile.cpp
@@ -18,7 +18,6 @@
#include "graphics/engine/modelfile.h"
-#include "common/iman.h"
#include "common/ioutils.h"
#include "common/logger.h"
#include "common/stringutils.h"
@@ -34,22 +33,10 @@
#include <sstream>
-/*
- * NOTE: #ifndef checking for MODELFILE_NO_ENGINE
- * is provided in this module to conditionally
- * disable dependence on CEngine.
- */
-
-
// Graphics module namespace
namespace Gfx {
-//! How big the triangle vector is by default
-const int TRIANGLE_PREALLOCATE_COUNT = 2000;
-
-
-
bool ReadBinaryVertex(std::istream& stream, Vertex& vertex)
{
vertex.coord.x = IOUtils::ReadBinaryFloat(stream);
@@ -322,15 +309,8 @@ bool ReadLineString(std::istream& stream, const std::string& prefix, std::string
}
-CModelFile::CModelFile(CInstanceManager* iMan)
+CModelFile::CModelFile()
{
- m_iMan = iMan;
-
-#ifndef MODELFILE_NO_ENGINE
- m_engine = static_cast<CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
-#endif
-
- m_triangles.reserve(TRIANGLE_PREALLOCATE_COUNT);
}
CModelFile::~CModelFile()
@@ -514,8 +494,7 @@ bool CModelFile::ReadModel(std::istream& stream)
triangle.material = t.material;
triangle.tex1Name = std::string(t.texName);
- triangle.min = t.min;
- triangle.max = t.max;
+ triangle.lodLevel = MinMaxToLodLevel(t.min, t.max);
m_triangles.push_back(triangle);
}
@@ -558,8 +537,7 @@ bool CModelFile::ReadModel(std::istream& stream)
triangle.material = t.material;
triangle.tex1Name = std::string(t.texName);
- triangle.min = t.min;
- triangle.max = t.max;
+ triangle.lodLevel = MinMaxToLodLevel(t.min, t.max);
triangle.state = t.state;
m_triangles.push_back(triangle);
@@ -603,14 +581,10 @@ bool CModelFile::ReadModel(std::istream& stream)
triangle.material = t.material;
triangle.tex1Name = std::string(t.texName);
- triangle.min = t.min;
- triangle.max = t.max;
+ triangle.lodLevel = MinMaxToLodLevel(t.min, t.max);
triangle.state = t.state;
triangle.variableTex2 = t.texNum2 == 1;
- if (triangle.tex1Name == "plant.png")
- triangle.state |= ENG_RSTATE_ALPHA;
-
if (!triangle.variableTex2 && t.texNum2 != 0)
{
if (t.texNum2 >= 1 && t.texNum2 <= 10)
@@ -637,6 +611,10 @@ bool CModelFile::ReadModel(std::istream& stream)
m_triangles[i].tex2Name = StrUtils::Replace(m_triangles[i].tex2Name, "bmp", "png");
m_triangles[i].tex2Name = StrUtils::Replace(m_triangles[i].tex2Name, "tga", "png");
+ // TODO: fix this in model files
+ if (m_triangles[i].tex1Name == "plant.png")
+ m_triangles[i].state |= ENG_RSTATE_ALPHA;
+
GetLogger()->Trace("ModelTriangle %d\n", i+1);
std::string s1 = m_triangles[i].p1.ToString();
GetLogger()->Trace(" p1: %s\n", s1.c_str());
@@ -652,7 +630,7 @@ bool CModelFile::ReadModel(std::istream& stream)
GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(),
m_triangles[i].variableTex2 ? "(variable)" : m_triangles[i].tex2Name.c_str());
- GetLogger()->Trace(" min: %.2f max: %.2f\n", m_triangles[i].min, m_triangles[i].max);
+ GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel);
GetLogger()->Trace(" state: %ld\n", m_triangles[i].state);
}
@@ -703,8 +681,7 @@ bool CModelFile::WriteModel(std::ostream& stream)
t.material = m_triangles[i].material;
strncpy(t.texName, m_triangles[i].tex1Name.c_str(), 20);
- t.min = m_triangles[i].min;
- t.max = m_triangles[i].max;
+ LODLevelToMinMax(m_triangles[i].lodLevel, t.min, t.max);
t.state = m_triangles[i].state;
int no = 0;
@@ -740,6 +717,46 @@ bool CModelFile::WriteModel(std::ostream& stream)
return true;
}
+LODLevel CModelFile::MinMaxToLodLevel(float min, float max)
+{
+ if (min == 0.0f && max == 100.0f)
+ return LOD_High;
+ else if (min == 100.0f && max == 200.0f)
+ return LOD_Medium;
+ else if (min == 200.0f && max == 1000000.0f)
+ return LOD_Low;
+ else if (min == 0.0f && max == 1000000.0f)
+ return LOD_Constant;
+
+ return LOD_Constant;
+}
+
+void CModelFile::LODLevelToMinMax(LODLevel lodLevel, float& min, float& max)
+{
+ switch (lodLevel)
+ {
+ case LOD_High:
+ min = 0.0f;
+ max = 100.0f;
+ break;
+
+ case LOD_Medium:
+ min = 100.0f;
+ max = 200.0f;
+ break;
+
+ case LOD_Low:
+ min = 200.0f;
+ max = 1000000.0f;
+ break;
+
+ case LOD_Constant:
+ min = 0.0f;
+ max = 1000000.0f;
+ break;
+ }
+}
+
/*******************************************************
New formats
@@ -786,17 +803,15 @@ struct NewModelTriangle1
std::string tex2Name;
//! If true, 2nd texture will be taken from current engine setting
bool variableTex2;
- //! Min LOD threshold
- float min;
- //! Max LOD threshold
- float max;
+ //! LOD level
+ int lodLevel;
//! Rendering state to be set
int state;
NewModelTriangle1()
{
variableTex2 = true;
- min = max = 0.0f;
+ lodLevel = 0;
state = 0;
}
};
@@ -852,8 +867,7 @@ bool CModelFile::ReadTextModel(std::istream& stream)
ReadLineValue<std::string>(stream, "tex1", t.tex1Name) &&
ReadLineValue<std::string>(stream, "tex2", t.tex2Name) &&
ReadLineValue<char>(stream, "var_tex2", varTex2Ch) &&
- ReadLineValue<float>(stream, "min", t.min) &&
- ReadLineValue<float>(stream, "max", t.max) &&
+ ReadLineValue<int>(stream, "lod_level", t.lodLevel) &&
ReadLineValue<int>(stream, "state", t.state);
if (!triOk || stream.fail())
@@ -873,10 +887,17 @@ bool CModelFile::ReadTextModel(std::istream& stream)
triangle.tex1Name = t.tex1Name;
triangle.tex2Name = t.tex2Name;
triangle.variableTex2 = t.variableTex2;
- triangle.min = t.min;
- triangle.max = t.max;
triangle.state = t.state;
+ switch (t.lodLevel)
+ {
+ case 0: triangle.lodLevel = LOD_Constant; break;
+ case 1: triangle.lodLevel = LOD_Low; break;
+ case 2: triangle.lodLevel = LOD_Medium; break;
+ case 3: triangle.lodLevel = LOD_High; break;
+ default: break;
+ }
+
m_triangles.push_back(triangle);
continue;
@@ -904,7 +925,7 @@ bool CModelFile::ReadTextModel(std::istream& stream)
GetLogger()->Trace(" mat: d: %s a: %s s: %s\n", d.c_str(), a.c_str(), s.c_str());
GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(), m_triangles[i].tex2Name.c_str());
- GetLogger()->Trace(" min: %.2f max: %.2f\n", m_triangles[i].min, m_triangles[i].max);
+ GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel);
GetLogger()->Trace(" state: %ld\n", m_triangles[i].state);
}
@@ -956,10 +977,16 @@ bool CModelFile::WriteTextModel(std::ostream& stream)
t.tex1Name = m_triangles[i].tex1Name;
t.tex2Name = m_triangles[i].tex2Name;
t.variableTex2 = m_triangles[i].variableTex2;
- t.min = m_triangles[i].min;
- t.max = m_triangles[i].max;
t.state = m_triangles[i].state;
+ switch (m_triangles[i].lodLevel)
+ {
+ case LOD_Constant: t.lodLevel = 0; break;
+ case LOD_Low: t.lodLevel = 1; break;
+ case LOD_Medium: t.lodLevel = 2; break;
+ case LOD_High: t.lodLevel = 3; break;
+ }
+
stream << "p1 ";
WriteTextVertexTex2(t.p1, stream);
stream << "p2 ";
@@ -972,8 +999,7 @@ bool CModelFile::WriteTextModel(std::ostream& stream)
stream << "tex1 " << t.tex1Name << std::endl;
stream << "tex2 " << t.tex2Name << std::endl;
stream << "var_tex2 " << (t.variableTex2 ? 'Y' : 'N') << std::endl;
- stream << "min " << t.min << std::endl;
- stream << "max " << t.max << std::endl;
+ stream << "lod_level " << t.lodLevel << std::endl;
stream << "state " << t.state << std::endl;
stream << std::endl;
@@ -1030,9 +1056,8 @@ bool CModelFile::ReadBinaryModel(std::istream& stream)
t.tex1Name = IOUtils::ReadBinaryString<1>(stream);
t.tex2Name = IOUtils::ReadBinaryString<1>(stream);
t.variableTex2 = IOUtils::ReadBinaryBool(stream);
- t.min = IOUtils::ReadBinaryFloat(stream);
- t.max = IOUtils::ReadBinaryFloat(stream);
- t.state = IOUtils::ReadBinary<4, unsigned int>(stream);
+ t.lodLevel = IOUtils::ReadBinary<4, int>(stream);
+ t.state = IOUtils::ReadBinary<4, int>(stream);
if (stream.fail())
{
@@ -1048,10 +1073,17 @@ bool CModelFile::ReadBinaryModel(std::istream& stream)
triangle.tex1Name = t.tex1Name;
triangle.tex2Name = t.tex2Name;
triangle.variableTex2 = t.variableTex2;
- triangle.min = t.min;
- triangle.max = t.max;
triangle.state = t.state;
+ switch (t.lodLevel)
+ {
+ case 0: triangle.lodLevel = LOD_Constant; break;
+ case 1: triangle.lodLevel = LOD_Low; break;
+ case 2: triangle.lodLevel = LOD_Medium; break;
+ case 3: triangle.lodLevel = LOD_High; break;
+ default: break;
+ }
+
m_triangles.push_back(triangle);
}
}
@@ -1077,7 +1109,7 @@ bool CModelFile::ReadBinaryModel(std::istream& stream)
GetLogger()->Trace(" mat: d: %s a: %s s: %s\n", d.c_str(), a.c_str(), s.c_str());
GetLogger()->Trace(" tex1: %s tex2: %s\n", m_triangles[i].tex1Name.c_str(), m_triangles[i].tex2Name.c_str());
- GetLogger()->Trace(" min: %.2f max: %.2f\n", m_triangles[i].min, m_triangles[i].max);
+ GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel);
GetLogger()->Trace(" state: %ld\n", m_triangles[i].state);
}
@@ -1124,10 +1156,16 @@ bool CModelFile::WriteBinaryModel(std::ostream& stream)
t.tex1Name = m_triangles[i].tex1Name;
t.tex2Name = m_triangles[i].tex2Name;
t.variableTex2 = m_triangles[i].variableTex2;
- t.min = m_triangles[i].min;
- t.max = m_triangles[i].max;
t.state = m_triangles[i].state;
+ switch (m_triangles[i].lodLevel)
+ {
+ case LOD_Constant: t.lodLevel = 0; break;
+ case LOD_Low: t.lodLevel = 1; break;
+ case LOD_Medium: t.lodLevel = 2; break;
+ case LOD_High: t.lodLevel = 3; break;
+ }
+
WriteBinaryVertexTex2(t.p1, stream);
WriteBinaryVertexTex2(t.p2, stream);
WriteBinaryVertexTex2(t.p3, stream);
@@ -1135,9 +1173,8 @@ bool CModelFile::WriteBinaryModel(std::ostream& stream)
IOUtils::WriteBinaryString<1>(t.tex1Name, stream);
IOUtils::WriteBinaryString<1>(t.tex2Name, stream);
IOUtils::WriteBinaryBool(t.variableTex2, stream);
- IOUtils::WriteBinaryFloat(t.min, stream);
- IOUtils::WriteBinaryFloat(t.max, stream);
- IOUtils::WriteBinary<4, unsigned int>(t.state, stream);
+ IOUtils::WriteBinary<4, int>(t.lodLevel, stream);
+ IOUtils::WriteBinary<4, int>(t.state, stream);
if (stream.fail())
{
@@ -1150,97 +1187,6 @@ bool CModelFile::WriteBinaryModel(std::ostream& stream)
}
-/*******************************************************
- Other stuff
- *******************************************************/
-
-#ifndef MODELFILE_NO_ENGINE
-
-bool CModelFile::CreateEngineObject(int objRank)
-{
- std::vector<VertexTex2> vs(3, VertexTex2());
-
- float limit[2];
- limit[0] = m_engine->GetLimitLOD(0); // frontier AB as config
- limit[1] = m_engine->GetLimitLOD(1); // frontier BC as config
-
- for (int i = 0; i < static_cast<int>( m_triangles.size() ); i++)
- {
- // TODO move this to CEngine
-
- float min = m_triangles[i].min;
- float max = m_triangles[i].max;
-
- // Standard frontiers -> config
- if (min == 0.0f && max == 100.0f) // resolution A ?
- {
- max = limit[0];
- }
- else if (min == 100.0f && max == 200.0f) // resolution B ?
- {
- min = limit[0];
- max = limit[1];
- }
- else if (min == 200.0f && max == 1000000.0f) // resolution C ?
- {
- min = limit[1];
- }
-
- int state = m_triangles[i].state;
- std::string tex2Name = m_triangles[i].tex2Name;
-
- if (m_triangles[i].variableTex2)
- {
- int texNum = m_engine->GetSecondTexture();
-
- if (texNum >= 1 && texNum <= 10)
- state |= ENG_RSTATE_DUAL_BLACK;
-
- if (texNum >= 11 && texNum <= 20)
- state |= ENG_RSTATE_DUAL_WHITE;
-
- char name[20] = { 0 };
- sprintf(name, "dirty%.2d.png", texNum);
- tex2Name = name;
- }
-
- vs[0] = m_triangles[i].p1;
- vs[1] = m_triangles[i].p2;
- vs[2] = m_triangles[i].p3;
-
- bool ok = m_engine->AddTriangles(objRank, vs,
- m_triangles[i].material,
- state,
- m_triangles[i].tex1Name,
- tex2Name,
- min, max, false);
- if (!ok)
- return false;
- }
-
- return true;
-}
-
-#endif
-
-void CModelFile::Mirror()
-{
- for (int i = 0; i < static_cast<int>( m_triangles.size() ); i++)
- {
- VertexTex2 t = m_triangles[i].p1;
- m_triangles[i].p1 = m_triangles[i].p2;
- m_triangles[i].p2 = t;
-
- m_triangles[i].p1.coord.z = -m_triangles[i].p1.coord.z;
- m_triangles[i].p2.coord.z = -m_triangles[i].p2.coord.z;
- m_triangles[i].p3.coord.z = -m_triangles[i].p3.coord.z;
-
- m_triangles[i].p1.normal.z = -m_triangles[i].p1.normal.z;
- m_triangles[i].p2.normal.z = -m_triangles[i].p2.normal.z;
- m_triangles[i].p3.normal.z = -m_triangles[i].p3.normal.z;
- }
-}
-
const std::vector<ModelTriangle>& CModelFile::GetTriangles()
{
return m_triangles;
@@ -1251,45 +1197,5 @@ int CModelFile::GetTriangleCount()
return m_triangles.size();
}
-float CModelFile::GetHeight(Math::Vector pos)
-{
- float limit = 5.0f;
-
- for (int i = 0; i < static_cast<int>( m_triangles.size() ); i++)
- {
- if ( fabs(pos.x - m_triangles[i].p1.coord.x) < limit &&
- fabs(pos.z - m_triangles[i].p1.coord.z) < limit )
- return m_triangles[i].p1.coord.y;
-
- if ( fabs(pos.x - m_triangles[i].p2.coord.x) < limit &&
- fabs(pos.z - m_triangles[i].p2.coord.z) < limit )
- return m_triangles[i].p2.coord.y;
-
- if ( fabs(pos.x - m_triangles[i].p3.coord.x) < limit &&
- fabs(pos.z - m_triangles[i].p3.coord.z) < limit )
- return m_triangles[i].p3.coord.y;
- }
-
- return 0.0f;
-}
-
-void CModelFile::CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max)
-{
- ModelTriangle triangle;
-
- Math::Vector n = Math::NormalToPlane(p3, p2, p1);
- triangle.p1 = VertexTex2(p1, n);
- triangle.p2 = VertexTex2(p2, n);
- triangle.p3 = VertexTex2(p3, n);
-
- triangle.material.diffuse = Color(1.0f, 1.0f, 1.0f, 0.0f);
- triangle.material.ambient = Color(0.5f, 0.5f, 0.5f, 0.0f);
-
- triangle.min = min;
- triangle.max = max;
-
- m_triangles.push_back(triangle);
-}
-
} // namespace Gfx
diff --git a/src/graphics/engine/modelfile.h b/src/graphics/engine/modelfile.h
index 6c573b8..3a702cb 100644
--- a/src/graphics/engine/modelfile.h
+++ b/src/graphics/engine/modelfile.h
@@ -33,19 +33,29 @@
#include <iostream>
-class CInstanceManager;
-
// Graphics module namespace
namespace Gfx {
-class CEngine;
+/**
+ * \enum LODLevel
+ * \brief Level-of-detail
+ *
+ * A quantified replacement for older values of min/max.
+ */
+enum LODLevel
+{
+ LOD_Constant = -1, //!< triangle is always visible, no matter at what distance
+ LOD_Low = 1, //!< triangle is visible at farthest distance (lowest quality)
+ LOD_Medium = 2, //!< triangle is visible at medium distance (medium quality)
+ LOD_High = 4 //!< triangle is visible at closest distance (highest quality)
+};
/**
- \struct ModelTriangle
- \brief Triangle of a 3D model
- */
+ * \struct ModelTriangle
+ * \brief Triangle of a 3D model
+ */
struct ModelTriangle
{
//! 1st vertex
@@ -62,31 +72,30 @@ struct ModelTriangle
std::string tex2Name;
//! If true, 2nd texture will be taken from current engine setting
bool variableTex2;
- //! Min LOD threshold
- float min;
- //! Max LOD threshold
- float max;
+ //! LOD level
+ LODLevel lodLevel;
//! Rendering state to be set
int state;
ModelTriangle()
{
variableTex2 = true;
- min = max = 0.0f;
+ lodLevel = LOD_Constant;
state = 0;
}
};
/**
- \class CModelFile
- \brief Model file reader/writer
-
- Allows reading and writing model objects. Models are collections of ModelTriangle structs. */
+ * \class CModelFile
+ * \brief Model file reader/writer
+ *
+ * Allows reading and writing model objects. Models are collections of ModelTriangle structs.
+ */
class CModelFile
{
public:
- CModelFile(CInstanceManager* iMan);
+ CModelFile();
~CModelFile();
//! Reads a model in text format from file
@@ -128,23 +137,14 @@ public:
//! Returns the triangle vector
const std::vector<ModelTriangle>& GetTriangles();
- //! Returns the height of model -- closest point to X and Z coords of \a pos
- float GetHeight(Math::Vector pos);
-
- //! Mirrors the model along the Z axis
- void Mirror();
-
- //! Creates an object in the graphics engine from the model
- bool CreateEngineObject(int objRank);
-
protected:
- //! Adds a triangle to the list
- void CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max);
+ //@{
+ //! @deprecated min, max conversions
+ LODLevel MinMaxToLodLevel(float min, float max);
+ void LODLevelToMinMax(LODLevel lodLevel, float& min, float& max);
+ //@}
protected:
- CInstanceManager* m_iMan;
- CEngine* m_engine;
-
//! Model triangles
std::vector<ModelTriangle> m_triangles;
};
diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp
new file mode 100644
index 0000000..c23b79d
--- /dev/null
+++ b/src/graphics/engine/modelmanager.cpp
@@ -0,0 +1,191 @@
+#include "graphics/engine/modelmanager.h"
+
+#include "app/app.h"
+
+#include "common/logger.h"
+
+#include "graphics/engine/engine.h"
+
+#include <cstdio>
+
+template<> Gfx::CModelManager* CSingleton<Gfx::CModelManager>::m_instance = nullptr;
+
+namespace Gfx {
+
+CModelManager::CModelManager(CEngine* engine)
+{
+ m_engine = engine;
+}
+
+CModelManager::~CModelManager()
+{
+}
+
+bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
+{
+ GetLogger()->Info("Loading model '%s'\n", fileName.c_str());
+
+ CModelFile modelFile;
+
+ std::string filePath = CApplication::GetInstance().GetDataFilePath(DIR_MODEL, fileName);
+
+ if (!modelFile.ReadModel(filePath))
+ {
+ GetLogger()->Error("Loading model '%s' failed\n", filePath.c_str());
+ return false;
+ }
+
+ ModelInfo modelInfo;
+ modelInfo.baseObjRank = m_engine->CreateBaseObject();
+ modelInfo.triangles = modelFile.GetTriangles();
+
+ if (mirrored)
+ Mirror(modelInfo.triangles);
+
+ FileInfo fileInfo(fileName, mirrored);
+ m_models[fileInfo] = modelInfo;
+
+ std::vector<VertexTex2> vs(3, VertexTex2());
+
+ for (int i = 0; i < static_cast<int>( modelInfo.triangles.size() ); i++)
+ {
+ int state = modelInfo.triangles[i].state;
+ std::string tex2Name = modelInfo.triangles[i].tex2Name;
+
+ if (modelInfo.triangles[i].variableTex2)
+ {
+ int texNum = m_engine->GetSecondTexture();
+
+ if (texNum >= 1 && texNum <= 10)
+ state |= ENG_RSTATE_DUAL_BLACK;
+
+ if (texNum >= 11 && texNum <= 20)
+ state |= ENG_RSTATE_DUAL_WHITE;
+
+ char name[20] = { 0 };
+ sprintf(name, "dirty%.2d.png", texNum);
+ tex2Name = name;
+ }
+
+ vs[0] = modelInfo.triangles[i].p1;
+ vs[1] = modelInfo.triangles[i].p2;
+ vs[2] = modelInfo.triangles[i].p3;
+
+ m_engine->AddBaseObjTriangles(modelInfo.baseObjRank, vs, ENG_TRIANGLE_TYPE_TRIANGLES,
+ modelInfo.triangles[i].material, state,
+ modelInfo.triangles[i].tex1Name, tex2Name,
+ modelInfo.triangles[i].lodLevel, false);
+ }
+
+ return true;
+}
+
+bool CModelManager::AddModelReference(const std::string& fileName, bool mirrored, int objRank)
+{
+ auto it = m_models.find(FileInfo(fileName, mirrored));
+ if (it == m_models.end())
+ {
+ if (!LoadModel(fileName, mirrored))
+ return false;
+
+ it = m_models.find(FileInfo(fileName, mirrored));
+ }
+
+ m_engine->SetObjectBaseRank(objRank, (*it).second.baseObjRank);
+
+ return true;
+}
+
+bool CModelManager::AddModelCopy(const std::string& fileName, bool mirrored, int objRank)
+{
+ auto it = m_models.find(FileInfo(fileName, mirrored));
+ if (it == m_models.end())
+ {
+ if (!LoadModel(fileName, mirrored))
+ return false;
+
+ it = m_models.find(FileInfo(fileName, mirrored));
+ }
+
+ int copyBaseObjRank = m_engine->CreateBaseObject();
+ m_engine->CopyBaseObject((*it).second.baseObjRank, copyBaseObjRank);
+ m_engine->SetObjectBaseRank(objRank, copyBaseObjRank);
+
+ return true;
+}
+
+bool CModelManager::IsModelLoaded(const std::string& fileName, bool mirrored)
+{
+ return m_models.count(FileInfo(fileName, mirrored)) > 0;
+}
+
+int CModelManager::GetModelBaseObjRank(const std::string& fileName, bool mirrored)
+{
+ auto it = m_models.find(FileInfo(fileName, mirrored));
+ if (it == m_models.end())
+ return -1;
+
+ return (*it).second.baseObjRank;
+}
+
+void CModelManager::UnloadModel(const std::string& fileName, bool mirrored)
+{
+ auto it = m_models.find(FileInfo(fileName, mirrored));
+ if (it == m_models.end())
+ return;
+
+ m_engine->DeleteBaseObject((*it).second.baseObjRank);
+
+ m_models.erase(it);
+}
+
+void CModelManager::UnloadAllModels()
+{
+ for (auto& mf : m_models)
+ m_engine->DeleteBaseObject(mf.second.baseObjRank);
+
+ m_models.clear();
+}
+
+void CModelManager::Mirror(std::vector<ModelTriangle>& triangles)
+{
+ for (int i = 0; i < static_cast<int>( triangles.size() ); i++)
+ {
+ VertexTex2 t = triangles[i].p1;
+ triangles[i].p1 = triangles[i].p2;
+ triangles[i].p2 = t;
+
+ triangles[i].p1.coord.z = -triangles[i].p1.coord.z;
+ triangles[i].p2.coord.z = -triangles[i].p2.coord.z;
+ triangles[i].p3.coord.z = -triangles[i].p3.coord.z;
+
+ triangles[i].p1.normal.z = -triangles[i].p1.normal.z;
+ triangles[i].p2.normal.z = -triangles[i].p2.normal.z;
+ triangles[i].p3.normal.z = -triangles[i].p3.normal.z;
+ }
+}
+
+float CModelManager::GetHeight(std::vector<ModelTriangle>& triangles, Math::Vector pos)
+{
+ const float limit = 5.0f;
+
+ for (int i = 0; i < static_cast<int>( triangles.size() ); i++)
+ {
+ if ( fabs(pos.x - triangles[i].p1.coord.x) < limit &&
+ fabs(pos.z - triangles[i].p1.coord.z) < limit )
+ return triangles[i].p1.coord.y;
+
+ if ( fabs(pos.x - triangles[i].p2.coord.x) < limit &&
+ fabs(pos.z - triangles[i].p2.coord.z) < limit )
+ return triangles[i].p2.coord.y;
+
+ if ( fabs(pos.x - triangles[i].p3.coord.x) < limit &&
+ fabs(pos.z - triangles[i].p3.coord.z) < limit )
+ return triangles[i].p3.coord.y;
+ }
+
+ return 0.0f;
+}
+
+
+}
diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h
new file mode 100644
index 0000000..601d636
--- /dev/null
+++ b/src/graphics/engine/modelmanager.h
@@ -0,0 +1,97 @@
+#pragma once
+
+#include "common/singleton.h"
+
+#include "graphics/engine/modelfile.h"
+
+#include <string>
+#include <vector>
+#include <map>
+
+namespace Gfx {
+
+class CEngine;
+class CModelFile;
+
+/**
+ * \class CModelManager
+ * \brief Manager for static models
+ *
+ * The manager allows for loading models as static objects and adding
+ * new instances of models to the engine.
+ *
+ * The models are loaded from stanard application model directory and
+ * they are identified by unique file names.
+ *
+ * The models are loaded by creating (if it doesn't exist yet)
+ * a base engine object from the model geometry. This base object
+ * is then shared among all instances of this model with the instances
+ * being engine objects linked to the shared base object.
+ *
+ * There is also a possibility of creating a copy of model so it has
+ * its own and unique base engine object. This is especially useful
+ * for models where the geometry must be altered.
+ */
+class CModelManager : public CSingleton<CModelManager>
+{
+public:
+ CModelManager(CEngine* engine);
+ ~CModelManager();
+
+ //! Loads a model from given file
+ bool LoadModel(const std::string& fileName, bool mirrored);
+
+ //! Adds an instance of model to the given object rank as a reference to base object
+ bool AddModelReference(const std::string& fileName, bool mirrored, int objRank);
+
+ //! Adds an instance of model to the given object rank as a copy (copied base object)
+ bool AddModelCopy(const std::string& fileName, bool mirrored, int objRank);
+
+ //! Returns true if given model is loaded
+ bool IsModelLoaded(const std::string& fileName, bool mirrored);
+
+ //! Returns the rank of base engine object of given loaded model
+ int GetModelBaseObjRank(const std::string& fileName, bool mirrored);
+
+ //! Unloads the given model
+ void UnloadModel(const std::string& fileName, bool mirrored);
+ //! Unloads all models
+ void UnloadAllModels();
+
+protected:
+ //! Returns the height of model -- closest point to X and Z coords of \a pos
+ float GetHeight(std::vector<ModelTriangle>& triangles, Math::Vector pos);
+
+ //! Mirrors the model along the Z axis
+ void Mirror(std::vector<ModelTriangle>& triangles);
+
+private:
+ struct ModelInfo
+ {
+ std::vector<ModelTriangle> triangles;
+ int baseObjRank;
+ };
+ struct FileInfo
+ {
+ std::string fileName;
+ bool mirrored;
+
+ inline FileInfo(const std::string& fileName, bool mirrored)
+ : fileName(fileName), mirrored(mirrored) {}
+
+ inline bool operator<(const FileInfo& other) const
+ {
+ int compare = fileName.compare(other.fileName);
+ if (compare < 0)
+ return true;
+ if (compare > 0)
+ return false;
+
+ return !mirrored && mirrored != other.mirrored;
+ }
+ };
+ std::map<FileInfo, ModelInfo> m_models;
+ CEngine* m_engine;
+};
+
+} // namespace Gfx
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index acc40df..d15ee3b 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -18,6 +18,9 @@
#include "graphics/engine/particle.h"
+#include "app/app.h"
+
+#include "common/iman.h"
#include "common/logger.h"
#include "graphics/core/device.h"
@@ -117,11 +120,8 @@ float GetDecay(ObjectType type)
-CParticle::CParticle(CInstanceManager *iMan, CEngine* engine)
+CParticle::CParticle(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PARTICULE, this);
-
m_device = nullptr;
m_engine = engine;
m_main = nullptr;
@@ -138,7 +138,6 @@ CParticle::CParticle(CInstanceManager *iMan, CEngine* engine)
CParticle::~CParticle()
{
- m_iMan->DeleteInstance(CLASS_PARTICULE, this);
}
void CParticle::SetDevice(CDevice* device)
@@ -213,7 +212,7 @@ int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point
float windSensitivity, int sheet)
{
if (m_main == nullptr)
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_main = CRobotMain::GetInstancePointer();
int t = -1;
if ( type == PARTIEXPLOT ||
@@ -649,7 +648,7 @@ void CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2,
m_wheelTrace[i].startTime = m_absTime;
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = m_main->GetTerrain();
m_terrain->AdjustToFloor(m_wheelTrace[i].pos[0]);
m_wheelTrace[i].pos[0].y += 0.2f; // just above the ground
@@ -808,15 +807,15 @@ void CParticle::SetFrameUpdate(int sheet, bool update)
void CParticle::FrameParticle(float rTime)
{
if (m_main == nullptr)
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_main = CRobotMain::GetInstancePointer();
bool pause = (m_engine->GetPause() && !m_main->GetInfoLock());
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = m_main->GetTerrain();
if (m_water == nullptr)
- m_water = static_cast<CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_water = m_engine->GetWater();
if (!pause)
{
@@ -3214,7 +3213,7 @@ void CParticle::DrawParticleSphere(int i)
angle.z = m_particle[i].angle*0.7f;
Math::Matrix rot;
Math::LoadRotationZXYMatrix(rot, angle);
- mat = Math::MultiplyMatrices(rot, mat);
+ mat = Math::MultiplyMatrices(mat, rot);
}
m_device->SetTransform(TRANSFORM_WORLD, mat);
@@ -3654,11 +3653,13 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos,
box2.y += min;
box2.z += min;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
CObject* best = 0;
bool shield = false;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
if (!obj->GetActif()) continue; // inactive?
@@ -3782,9 +3783,11 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
box2.y += min;
box2.z += min;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
+ CObject* obj = static_cast<CObject*>( iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive?
@@ -3822,7 +3825,7 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal,
void CParticle::Play(Sound sound, Math::Vector pos, float amplitude)
{
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
m_sound->Play(sound, pos, amplitude);
}
diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h
index 90aec55..708a04d 100644
--- a/src/graphics/engine/particle.h
+++ b/src/graphics/engine/particle.h
@@ -28,7 +28,6 @@
#include "sound/sound.h"
-class CInstanceManager;
class CRobotMain;
class CObject;
class CSoundInterface;
@@ -267,7 +266,7 @@ struct WheelTrace
class CParticle
{
public:
- CParticle(CInstanceManager* iMan, CEngine* engine);
+ CParticle(CEngine* engine);
~CParticle();
//! Sets the device to use
@@ -371,7 +370,6 @@ protected:
void TrackDraw(int i, ParticleType type);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
CTerrain* m_terrain;
diff --git a/src/graphics/engine/planet.cpp b/src/graphics/engine/planet.cpp
index 3b9aa6c..49bcb4c 100644
--- a/src/graphics/engine/planet.cpp
+++ b/src/graphics/engine/planet.cpp
@@ -18,8 +18,6 @@
#include "graphics/engine/planet.h"
-#include "common/iman.h"
-
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
@@ -31,11 +29,8 @@ namespace Gfx {
const int PLANET_PREALLOCATE_COUNT = 10;
-CPlanet::CPlanet(CInstanceManager* iMan, CEngine* engine)
+CPlanet::CPlanet(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PLANET, this);
-
m_planet[0].reserve(PLANET_PREALLOCATE_COUNT);
m_planet[1].reserve(PLANET_PREALLOCATE_COUNT);
@@ -46,7 +41,6 @@ CPlanet::CPlanet(CInstanceManager* iMan, CEngine* engine)
CPlanet::~CPlanet()
{
- m_iMan = nullptr;
}
void CPlanet::Flush()
diff --git a/src/graphics/engine/planet.h b/src/graphics/engine/planet.h
index 1b16da0..3762e1d 100644
--- a/src/graphics/engine/planet.h
+++ b/src/graphics/engine/planet.h
@@ -30,8 +30,6 @@
#include <vector>
-class CInstanceManager;
-
// Graphics module namespace
namespace Gfx {
@@ -82,7 +80,7 @@ struct Planet
class CPlanet
{
public:
- CPlanet(CInstanceManager* iMan, CEngine* engine);
+ CPlanet(CEngine* engine);
~CPlanet();
//! Removes all the planets
@@ -110,7 +108,6 @@ protected:
bool EventFrame(const Event &event);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
float m_time;
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index 978471b..cab28b6 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -18,6 +18,9 @@
#include "graphics/engine/pyro.h"
+#include "app/app.h"
+
+#include "common/iman.h"
#include "common/logger.h"
#include "graphics/engine/lightman.h"
@@ -36,20 +39,19 @@
namespace Gfx {
-CPyro::CPyro(CInstanceManager* iMan)
+CPyro::CPyro()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PYRO, this, 100);
-
- m_engine = static_cast<CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_particle = static_cast<CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_lightMan = static_cast<CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_object = 0;
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_PYRO, this, 100);
+
+ m_engine = CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_particle = m_engine->GetParticle();
+ m_lightMan = m_engine->GetLightManager();
+ m_displayText = m_main->GetDisplayText();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_object = nullptr;
m_progress = 0.0f;
m_speed = 0.0f;
@@ -60,7 +62,7 @@ CPyro::CPyro(CInstanceManager* iMan)
CPyro::~CPyro()
{
- m_iMan->DeleteInstance(CLASS_PYRO, this);
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_PYRO, this);
}
void CPyro::DeleteObject()
@@ -1316,12 +1318,9 @@ void CPyro::CreateLight(Math::Vector pos, float height)
Gfx::Light light;
light.type = LIGHT_SPOT;
- light.position.x = pos.x;
- light.position.y = pos.y+height;
- light.position.z = pos.z;
- light.direction.x = 0.0f;
- light.direction.y = -1.0f; // against the bottom
- light.direction.z = 0.0f;
+ light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f);
+ light.position = Math::Vector(pos.x, pos.y+height, pos.z);
+ light.direction = Math::Vector(0.0f, -1.0f, 0.0f); // against the bottom
light.spotIntensity = 1.0f;
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
@@ -1397,27 +1396,39 @@ void CPyro::CreateTriangle(CObject* obj, ObjectType oType, int part)
int objRank = obj->GetObjectRank(part);
if (objRank == -1) return;
- float min = 0.0f;
- float max = m_engine->GetLimitLOD(0);
+
int total = m_engine->GetObjectTotalTriangles(objRank);
+
float percent = 0.10f;
if (total < 50) percent = 0.25f;
if (total < 20) percent = 0.50f;
if (m_type == PT_EGG) percent = 0.30f;
- if ( oType == OBJECT_POWER ||
- oType == OBJECT_ATOMIC ||
- oType == OBJECT_URANIUM ||
- oType == OBJECT_TNT ||
- oType == OBJECT_BOMB ) percent = 0.75f;
- if ( oType == OBJECT_MOBILEtg ) percent = 0.50f;
- if ( oType == OBJECT_TEEN28 ) percent = 0.75f;
- if ( oType == OBJECT_MOTHER ) max = 1000000.0f;
- if ( oType == OBJECT_TEEN28 ) max = 1000000.0f;
- if ( oType == OBJECT_TEEN31 ) max = 1000000.0f;
+ if (oType == OBJECT_POWER ||
+ oType == OBJECT_ATOMIC ||
+ oType == OBJECT_URANIUM ||
+ oType == OBJECT_TNT ||
+ oType == OBJECT_BOMB ||
+ oType == OBJECT_TEEN28)
+ {
+ percent = 0.75f;
+ }
+ else if (oType == OBJECT_MOBILEtg)
+ {
+ percent = 0.50f;
+ }
+
+ LODLevel lodLevel = LOD_High;
+
+ if (oType == OBJECT_MOTHER ||
+ oType == OBJECT_TEEN28 ||
+ oType == OBJECT_TEEN31)
+ {
+ lodLevel = LOD_Constant;
+ }
std::vector<EngineTriangle> buffer;
- total = m_engine->GetPartialTriangles(objRank, min, max, percent, 100, buffer);
+ total = m_engine->GetPartialTriangles(objRank, lodLevel, percent, 100, buffer);
for (int i = 0; i < total; i++)
{
@@ -2171,9 +2182,11 @@ CObject* CPyro::FallSearchBeeExplo()
float iRadius;
m_object->GetCrashSphere(0, iPos, iRadius);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
ObjectType oType = pObj->GetType();
diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h
index 0204070..9548a07 100644
--- a/src/graphics/engine/pyro.h
+++ b/src/graphics/engine/pyro.h
@@ -31,7 +31,6 @@
#include "object/object.h"
-class CInstanceManager;
class CObject;
class CRobotMain;
class CSoundInterface;
@@ -111,7 +110,7 @@ struct PyroLightOper
class CPyro
{
public:
- CPyro(CInstanceManager* iMan);
+ CPyro();
~CPyro();
//! Creates pyrotechnic effect
@@ -174,7 +173,6 @@ protected:
void LightOperFrame(float rTime);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 4c22a32..c2a7855 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -19,33 +19,28 @@
#include "graphics/engine/terrain.h"
#include "app/app.h"
-#include "common/iman.h"
+
#include "common/image.h"
#include "common/logger.h"
+
#include "graphics/engine/engine.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
#include <sstream>
-#include <SDL/SDL.h>
+#include <SDL.h>
// Graphics module namespace
namespace Gfx {
-const int LEVEL_MAT_PREALLOCATE_COUNT = 101;
-const int FLYING_LIMIT_PREALLOCATE_COUNT = 10;
-const int BUILDING_LEVEL_PREALLOCATE_COUNT = 101;
-
-CTerrain::CTerrain(CInstanceManager* iMan)
+CTerrain::CTerrain()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_TERRAIN, this);
-
- m_engine = static_cast<CEngine*>( m_iMan->SearchInstance(CLASS_ENGINE) );
- m_water = static_cast<CWater*>( m_iMan->SearchInstance(CLASS_WATER) );
+ m_engine = CEngine::GetInstancePointer();
+ m_water = m_engine->GetWater();
m_mosaicCount = 20;
m_brickCount = 1 << 4;
@@ -60,10 +55,6 @@ CTerrain::CTerrain(CInstanceManager* iMan)
m_defaultHardness = 0.5f;
m_useMaterials = false;
- m_materials.reserve(LEVEL_MAT_PREALLOCATE_COUNT);
- m_flyingLimits.reserve(FLYING_LIMIT_PREALLOCATE_COUNT);
- m_buildingLevels.reserve(BUILDING_LEVEL_PREALLOCATE_COUNT);
-
FlushBuildingLevel();
FlushFlyingLimit();
FlushMaterials();
@@ -478,6 +469,8 @@ VertexTex2 CTerrain::GetVertex(int x, int y, int step)
v.texCoord.x = (o.x-oo.x)*m_textureScale*m_textureSubdivCount;
v.texCoord.y = 1.0f - (o.z-oo.z)*m_textureScale*m_textureSubdivCount;
+ v.texCoord2 = v.texCoord;
+
return v;
}
@@ -493,9 +486,15 @@ VertexTex2 CTerrain::GetVertex(int x, int y, int step)
+-------------------> x
\endverbatim */
bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
- const Material &mat,
- float min, float max)
+ const Material &mat)
{
+ int baseObjRank = m_engine->GetObjectBaseRank(objRank);
+ if (baseObjRank == -1)
+ {
+ baseObjRank = m_engine->CreateBaseObject();
+ m_engine->SetObjectBaseRank(objRank, baseObjRank);
+ }
+
std::string texName1;
std::string texName2;
@@ -545,7 +544,7 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
for (int y = 0; y < brick; y += step)
{
- EngineObjLevel4 buffer;
+ EngineBaseObjDataTier buffer;
buffer.vertices.reserve(total);
buffer.type = ENG_TRIANGLE_TYPE_SURFACE;
@@ -638,7 +637,8 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
buffer.vertices.push_back(p1);
buffer.vertices.push_back(p2);
}
- m_engine->AddQuick(objRank, buffer, texName1, texName2, min, max, true);
+
+ m_engine->AddBaseObjQuick(baseObjRank, buffer, texName1, texName2, LOD_Constant, true);
}
}
}
@@ -1168,15 +1168,9 @@ bool CTerrain::CreateSquare(int x, int y)
m_objRanks[x+y*m_mosaicCount] = objRank;
- float min = 0.0f;
- float max = m_vision;
- max *= m_engine->GetClippingDistance();
for (int step = 0; step < m_depth; step++)
{
- CreateMosaic(x, y, 1 << step, objRank, mat, min, max);
- min = max;
- max *= 2;
- if (step == m_depth-1) max = Math::HUGE_NUM;
+ CreateMosaic(x, y, 1 << step, objRank, mat);
}
return true;
@@ -1272,7 +1266,10 @@ bool CTerrain::Terraform(const Math::Vector &p1, const Math::Vector &p2, float h
{
for (int x = pp1.x; x <= pp2.x; x++)
{
- m_engine->DeleteObject(m_objRanks[x+y*m_mosaicCount]);
+ int objRank = m_objRanks[x+y*m_mosaicCount];
+ int baseObjRank = m_engine->GetObjectBaseRank(objRank);
+ m_engine->DeleteBaseObject(baseObjRank);
+ m_engine->DeleteObject(objRank);
CreateSquare(x, y); // recreates the square
}
}
diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h
index 3012e62..1fa8dec 100644
--- a/src/graphics/engine/terrain.h
+++ b/src/graphics/engine/terrain.h
@@ -26,9 +26,6 @@
#include "graphics/engine/engine.h"
-class CInstanceManager;
-
-
// Graphics module namespace
namespace Gfx {
@@ -223,7 +220,7 @@ struct FlyingLimit
class CTerrain
{
public:
- CTerrain(CInstanceManager* iMan);
+ CTerrain();
~CTerrain();
//! Generates a new flat terrain
@@ -328,9 +325,9 @@ protected:
//! Calculates a vector of the terrain
Math::Vector GetVector(int x, int y);
//! Calculates a vertex of the terrain
- VertexTex2 GetVertex(int x, int y, int step);
+ VertexTex2 GetVertex(int x, int y, int step);
//! Creates all objects of a mosaic
- bool CreateMosaic(int ox, int oy, int step, int objRank, const Material& mat, float min, float max);
+ bool CreateMosaic(int ox, int oy, int step, int objRank, const Material& mat);
//! Creates all objects in a mesh square ground
bool CreateSquare(int x, int y);
@@ -359,7 +356,6 @@ protected:
void AdjustBuildingLevel(Math::Vector &p);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CWater* m_water;
diff --git a/src/graphics/engine/test/CMakeLists.txt b/src/graphics/engine/test/CMakeLists.txt
index c837ae5..afaa86a 100644
--- a/src/graphics/engine/test/CMakeLists.txt
+++ b/src/graphics/engine/test/CMakeLists.txt
@@ -10,7 +10,6 @@ modelfile_test.cpp
../modelfile.cpp
../../../common/logger.cpp
../../../common/stringutils.cpp
-../../../common/iman.cpp
)
add_definitions(-DMODELFILE_NO_ENGINE)
diff --git a/src/graphics/engine/test/modelfile_test.cpp b/src/graphics/engine/test/modelfile_test.cpp
index 6879a1b..e7078a9 100644
--- a/src/graphics/engine/test/modelfile_test.cpp
+++ b/src/graphics/engine/test/modelfile_test.cpp
@@ -15,12 +15,11 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include "common/iman.h"
#include "common/logger.h"
#include "graphics/engine/modelfile.h"
#include "math/func.h"
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
#include <cassert>
#include <sstream>
@@ -41,8 +40,7 @@ const char* const TEXT_MODEL =
"tex1 lemt.png\n"
"tex2\n"
"var_tex2 N\n"
-"min 200\n"
-"max 1e+06\n"
+"lod_level 0\n"
"state 1024\n"
"\n"
"p1 c -19 -1 4 n -1 0 0 t1 0.248047 0.123047 t2 0.905224 0.52067\n"
@@ -52,8 +50,7 @@ const char* const TEXT_MODEL =
"tex1 derrick.png\n"
"tex2\n"
"var_tex2 Y\n"
-"min 200\n"
-"max 1e+06\n"
+"lod_level 1\n"
"state 0\n"
"";
@@ -82,8 +79,7 @@ void Init()
TRIANGLE_1.material.specular = Gfx::Color(0, 0, 0, 0);
TRIANGLE_1.tex1Name = "lemt.png";
TRIANGLE_1.variableTex2 = false;
- TRIANGLE_1.min = 200.0f;
- TRIANGLE_1.max = 1e+06f;
+ TRIANGLE_1.lodLevel = Gfx::LOD_Constant;
TRIANGLE_1.state = 1024;
TRIANGLE_2.p1 = Gfx::VertexTex2(Math::Vector(-19, -1, 4),
@@ -103,8 +99,7 @@ void Init()
TRIANGLE_2.material.specular = Gfx::Color(0, 0, 0, 0);
TRIANGLE_2.tex1Name = "derrick.png";
TRIANGLE_2.variableTex2 = true;
- TRIANGLE_2.min = 200.0f;
- TRIANGLE_2.max = 1e+06f;
+ TRIANGLE_2.lodLevel = Gfx::LOD_Low;
TRIANGLE_2.state = 0;
}
@@ -172,10 +167,7 @@ bool CompareTriangles(const Gfx::ModelTriangle& t1, const Gfx::ModelTriangle& t2
if (t1.variableTex2 != t2.variableTex2)
return false;
- if (!Math::IsEqual(t1.min, t2.min))
- return false;
-
- if (!Math::IsEqual(t1.max, t2.max))
+ if (t1.lodLevel != t2.lodLevel)
return false;
if (t1.state != t2.state)
@@ -190,8 +182,7 @@ TEST(ModelFileTest, RWTxtModel)
std::stringstream str;
str.str(TEXT_MODEL);
- CInstanceManager iMan;
- Gfx::CModelFile modelFile(&iMan);
+ Gfx::CModelFile modelFile;
EXPECT_TRUE(modelFile.ReadTextModel(str));
@@ -216,8 +207,7 @@ TEST(ModelFileTest, RWBinModel)
std::stringstream str;
str.str(TEXT_MODEL);
- CInstanceManager iMan;
- Gfx::CModelFile modelFile(&iMan);
+ Gfx::CModelFile modelFile;
EXPECT_TRUE(modelFile.ReadTextModel(str));
@@ -242,8 +232,7 @@ TEST(ModelFileTest, RWOldModel)
std::stringstream str;
str.str(TEXT_MODEL);
- CInstanceManager iMan;
- Gfx::CModelFile modelFile(&iMan);
+ Gfx::CModelFile modelFile;
EXPECT_TRUE(modelFile.ReadTextModel(str));
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 101e01a..308c813 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -19,14 +19,15 @@
#include "graphics/engine/text.h"
#include "app/app.h"
+
#include "common/image.h"
-#include "common/iman.h"
#include "common/logger.h"
#include "common/stringutils.h"
+
#include "math/func.h"
-#include <SDL/SDL.h>
-#include <SDL/SDL_ttf.h>
+#include <SDL.h>
+#include <SDL_ttf.h>
// Graphics module namespace
@@ -46,14 +47,11 @@ struct CachedFont
};
+const Math::IntPoint REFERENCE_SIZE(800, 600);
-
-CText::CText(CInstanceManager *iMan, CEngine* engine)
+CText::CText(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_TEXT, this);
-
m_device = nullptr;
m_engine = engine;
@@ -66,9 +64,6 @@ CText::CText(CInstanceManager *iMan, CEngine* engine)
CText::~CText()
{
- m_iMan->DeleteInstance(CLASS_TEXT, this);
-
- m_iMan = nullptr;
m_device = nullptr;
m_engine = nullptr;
}
@@ -147,9 +142,14 @@ void CText::FlushCache()
f->cache.clear();
}
}
+
+ m_lastFontType = FONT_COLOBOT;
+ m_lastFontSize = 0;
+ m_lastCachedFont = nullptr;
}
-void CText::DrawText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+void CText::DrawText(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, Math::Point pos, float width, TextAlign align,
int eol, Color color)
{
@@ -157,18 +157,18 @@ void CText::DrawText(const std::string &text, std::map<unsigned int, FontMetaCha
if (align == TEXT_ALIGN_CENTER)
{
- sw = GetStringWidth(text, format, size);
+ sw = GetStringWidth(text, format, end, size);
if (sw > width) sw = width;
pos.x -= sw / 2.0f;
}
else if (align == TEXT_ALIGN_RIGHT)
{
- sw = GetStringWidth(text, format, size);
+ sw = GetStringWidth(text, format, end, size);
if (sw > width) sw = width;
pos.x -= sw;
}
- DrawString(text, format, size, pos, width, eol, color);
+ DrawString(text, format, end, size, pos, width, eol, color);
}
void CText::DrawText(const std::string &text, FontType font,
@@ -193,13 +193,14 @@ void CText::DrawText(const std::string &text, FontType font,
DrawString(text, font, size, pos, width, eol, color);
}
-void CText::SizeText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+void CText::SizeText(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator endFormat,
float size, Math::Point pos, TextAlign align,
Math::Point &start, Math::Point &end)
{
start = end = pos;
- float sw = GetStringWidth(text, format, size);
+ float sw = GetStringWidth(text, format, endFormat, size);
end.x += sw;
if (align == TEXT_ALIGN_CENTER)
{
@@ -277,7 +278,8 @@ float CText::GetHeight(FontType font, float size)
float CText::GetStringWidth(const std::string &text,
- std::map<unsigned int, FontMetaChar> &format, float size)
+ std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end, float size)
{
float width = 0.0f;
unsigned int index = 0;
@@ -285,8 +287,8 @@ float CText::GetStringWidth(const std::string &text,
while (index < text.length())
{
FontType font = FONT_COLOBOT;
- if (format.count(fmtIndex))
- font = static_cast<FontType>(format[fmtIndex] & FONT_MASK_FONT);
+ if (format + fmtIndex != end)
+ font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
UTF8Char ch;
@@ -343,7 +345,8 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
}
-int CText::Justify(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+int CText::Justify(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, float width)
{
float pos = 0.0f;
@@ -353,8 +356,8 @@ int CText::Justify(const std::string &text, std::map<unsigned int, FontMetaChar>
while (index < text.length())
{
FontType font = FONT_COLOBOT;
- if (format.count(fmtIndex))
- font = static_cast<FontType>(format[fmtIndex] & FONT_MASK_FONT);
+ if (format + fmtIndex != end)
+ font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
UTF8Char ch;
@@ -427,7 +430,8 @@ int CText::Justify(const std::string &text, FontType font, float size, float wid
return index;
}
-int CText::Detect(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+int CText::Detect(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, float offset)
{
float pos = 0.0f;
@@ -436,11 +440,12 @@ int CText::Detect(const std::string &text, std::map<unsigned int, FontMetaChar>
while (index < text.length())
{
FontType font = FONT_COLOBOT;
- if (format.count(fmtIndex))
- font = static_cast<FontType>(format[fmtIndex] & FONT_MASK_FONT);
+
+ if (format + fmtIndex != end)
+ font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
// TODO: if (font == FONT_BUTTON)
- if (font == FONT_BUTTON) continue;
+ //if (font == FONT_BUTTON) continue;
UTF8Char ch;
@@ -500,7 +505,8 @@ int CText::Detect(const std::string &text, FontType font, float size, float offs
return index;
}
-void CText::DrawString(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, Math::Point pos, float width, int eol, Color color)
{
m_engine->SetState(ENG_RSTATE_TEXT);
@@ -514,8 +520,8 @@ void CText::DrawString(const std::string &text, std::map<unsigned int, FontMetaC
for (auto it = chars.begin(); it != chars.end(); ++it)
{
FontType font = FONT_COLOBOT;
- if (format.count(fmtIndex))
- font = static_cast<FontType>(format[fmtIndex] & FONT_MASK_FONT);
+ if (format + fmtIndex != end)
+ font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
// TODO: if (font == FONT_BUTTON)
if (font == FONT_BUTTON) continue;
@@ -678,11 +684,14 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
int width = 1;
if (ch.c1 > 0 && ch.c1 < 32) { // FIXME add support for chars with code 9 10 23
- ch.c1 = ' ';
+ if (ch.c1 == '\t') {
+ ch.c1 = ':';
+ width = 4;
+ } else {
+ ch.c1 = ' ';
+ }
ch.c2 = 0;
ch.c3 = 0;
- if (ch.c1 == '\t')
- width = 4;
}
auto it = cf->cache.find(ch);
@@ -702,7 +711,7 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
}
Math::Point p1(pos.x, pos.y + tex.charSize.y - tex.texSize.y);
- Math::Point p2(pos.x + tex.texSize.x * width, pos.y + tex.charSize.y);
+ Math::Point p2(pos.x + tex.texSize.x, pos.y + tex.charSize.y);
Math::Vector n(0.0f, 0.0f, -1.0f); // normal
@@ -723,8 +732,8 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
CachedFont* CText::GetOrOpenFont(FontType font, float size)
{
- // TODO: sizing
- int pointSize = static_cast<int>(size);
+ Math::IntPoint windowSize = m_engine->GetWindowSize();
+ int pointSize = static_cast<int>(size * (windowSize.Length() / REFERENCE_SIZE.Length()));
if (m_lastCachedFont != nullptr)
{
diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h
index 57fad43..6bcc59b 100644
--- a/src/graphics/engine/text.h
+++ b/src/graphics/engine/text.h
@@ -31,9 +31,6 @@
#include <map>
-class CInstanceManager;
-
-
// Graphics module namespace
namespace Gfx {
@@ -226,7 +223,7 @@ struct MultisizeFont
class CText
{
public:
- CText(CInstanceManager *iMan, CEngine* engine);
+ CText(CEngine* engine);
virtual ~CText();
//! Sets the device to be used
@@ -244,7 +241,8 @@ public:
void FlushCache();
//! Draws text (multi-format)
- void DrawText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+ void DrawText(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, Math::Point pos, float width, TextAlign align,
int eol, Color color = Color(0.0f, 0.0f, 0.0f, 1.0f));
//! Draws text (one font)
@@ -253,7 +251,8 @@ public:
int eol, Color color = Color(0.0f, 0.0f, 0.0f, 1.0f));
//! Calculates dimensions for text (multi-format)
- void SizeText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+ void SizeText(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator endFormat,
float size, Math::Point pos, TextAlign align,
Math::Point &start, Math::Point &end);
//! Calculates dimensions for text (one font)
@@ -270,20 +269,23 @@ public:
//! Returns width of string (multi-format)
TEST_VIRTUAL float GetStringWidth(const std::string &text,
- std::map<unsigned int, FontMetaChar> &format, float size);
+ std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end, float size);
//! Returns width of string (single font)
TEST_VIRTUAL float GetStringWidth(const std::string &text, FontType font, float size);
//! Returns width of single character
TEST_VIRTUAL float GetCharWidth(UTF8Char ch, FontType font, float size, float offset);
//! Justifies a line of text (multi-format)
- int Justify(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+ int Justify(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, float width);
//! Justifies a line of text (one font)
int Justify(const std::string &text, FontType font, float size, float width);
//! Returns the most suitable position to a given offset (multi-format)
- int Detect(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+ int Detect(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, float offset);
//! Returns the most suitable position to a given offset (one font)
int Detect(const std::string &text, FontType font, float size, float offset);
@@ -292,7 +294,8 @@ protected:
CachedFont* GetOrOpenFont(FontType type, float size);
CharTexture CreateCharTexture(UTF8Char ch, CachedFont* font);
- void DrawString(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
+ void DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
+ std::vector<FontMetaChar>::iterator end,
float size, Math::Point pos, float width, int eol, Color color);
void DrawString(const std::string &text, FontType font,
float size, Math::Point pos, float width, int eol, Color color);
@@ -301,7 +304,6 @@ protected:
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
diff --git a/src/graphics/engine/water.cpp b/src/graphics/engine/water.cpp
index 18811eb..d90652b 100644
--- a/src/graphics/engine/water.cpp
+++ b/src/graphics/engine/water.cpp
@@ -18,7 +18,8 @@
#include "graphics/engine/water.h"
-#include "common/iman.h"
+#include "app/app.h"
+
#include "common/logger.h"
#include "graphics/core/device.h"
@@ -28,6 +29,7 @@
#include "math/geometry.h"
#include "object/object.h"
+#include "object/robotmain.h"
#include "sound/sound.h"
@@ -42,14 +44,11 @@ const int WATERLINE_PREALLOCATE_COUNT = 500;
const int VAPOR_SIZE = 10;
-CWater::CWater(CInstanceManager* iMan, CEngine* engine)
+CWater::CWater(CEngine* engine)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_WATER, this);
-
m_engine = engine;
m_terrain = nullptr;
- m_particule = nullptr;
+ m_particle = nullptr;
m_sound = nullptr;
m_type[0] = WATER_NULL;
@@ -67,10 +66,9 @@ CWater::CWater(CInstanceManager* iMan, CEngine* engine)
CWater::~CWater()
{
- m_iMan = nullptr;
m_engine = nullptr;
m_terrain = nullptr;
- m_particule = nullptr;
+ m_particle = nullptr;
m_sound = nullptr;
}
@@ -99,8 +97,8 @@ bool CWater::EventFrame(const Event &event)
void CWater::LavaFrame(float rTime)
{
- if (m_particule == nullptr)
- m_particule = static_cast<CParticle*>( m_iMan->SearchInstance(CLASS_PARTICULE) );
+ if (m_particle == nullptr)
+ m_particle = m_engine->GetParticle();
for (int i = 0; i < static_cast<int>( m_vapors.size() ); i++)
VaporFrame(i, rTime);
@@ -183,7 +181,7 @@ void CWater::VaporFrame(int i, float rTime)
m_vapors[i].time += rTime;
if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
if (m_vapors[i].time <= m_vapors[i].delay)
{
@@ -206,7 +204,7 @@ void CWater::VaporFrame(int i, float rTime)
Math::Point dim;
dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
- m_particule->CreateParticle(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
+ m_particle->CreateParticle(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
}
}
else if (m_vapors[i].type == PARTIFLAME)
@@ -222,7 +220,7 @@ void CWater::VaporFrame(int i, float rTime)
Math::Point dim;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticle(pos, speed, dim, PARTIFLAME);
+ m_particle->CreateParticle(pos, speed, dim, PARTIFLAME);
}
else
{
@@ -237,7 +235,7 @@ void CWater::VaporFrame(int i, float rTime)
Math::Point dim;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticle(pos, speed, dim, PARTIVAPOR);
+ m_particle->CreateParticle(pos, speed, dim, PARTIVAPOR);
}
}
}
@@ -386,9 +384,11 @@ void CWater::DrawSurf()
Math::Vector p = pos;
p.x += size*(m_lines[i].len-1);
float radius = sqrtf(powf(size, 2.0f)+powf(size*m_lines[i].len, 2.0f));
- if ( Math::Distance(p, eye) > deep+radius ) continue;
+ if (Math::Distance(p, eye) > deep + radius)
+ continue;
- // TODO: ComputeSphereVisibility
+ if (device->ComputeSphereVisibility(p, radius) != Gfx::FRUSTUM_PLANE_ALL)
+ continue;
int vertexIndex = 0;
@@ -495,7 +495,7 @@ void CWater::Create(WaterType type1, WaterType type2, const std::string& fileNam
m_engine->LoadTexture(m_fileName);
if (m_terrain == nullptr)
- m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
m_brickCount = m_terrain->GetBrickCount()*m_terrain->GetMosaicCount();
m_brickSize = m_terrain->GetBrickSize();
diff --git a/src/graphics/engine/water.h b/src/graphics/engine/water.h
index 21d96d4..bb113e0 100644
--- a/src/graphics/engine/water.h
+++ b/src/graphics/engine/water.h
@@ -28,7 +28,6 @@
#include "graphics/engine/particle.h"
-class CInstanceManager;
class CSoundInterface;
@@ -117,8 +116,8 @@ enum WaterType
class CWater
{
public:
- CWater(CInstanceManager* iMan, CEngine* engine);
- ~CWater();
+ CWater(CEngine* engine);
+ virtual ~CWater();
void SetDevice(CDevice* device);
bool EventProcess(const Event &event);
@@ -168,11 +167,10 @@ protected:
void VaporFrame(int i, float rTime);
protected:
- CInstanceManager* m_iMan;
CEngine* m_engine;
CDevice* m_device;
CTerrain* m_terrain;
- CParticle* m_particule;
+ CParticle* m_particle;
CSoundInterface* m_sound;
WaterType m_type[2];
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 94b0dbc..df64e34 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -24,23 +24,10 @@
#include "math/geometry.h"
-#if defined(USE_GLEW)
-
-// When using GLEW, only glew.h is needed
+// Using GLEW so only glew.h is needed
#include <GL/glew.h>
-#else
-
-// Should define prototypes of used extensions as OpenGL functions
-#define GL_GLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include <GL/glext.h>
-
-#endif // if defined(GLEW)
-
-#include <SDL/SDL.h>
+#include <SDL.h>
#include <cassert>
@@ -64,6 +51,8 @@ void GLDeviceConfig::LoadDefault()
greenSize = 8;
alphaSize = 8;
depthSize = 24;
+
+ vboMode = VBO_MODE_AUTO;
}
@@ -73,6 +62,9 @@ CGLDevice::CGLDevice(const GLDeviceConfig &config)
{
m_config = config;
m_lighting = false;
+ m_lastVboId = 0;
+ m_multitextureAvailable = false;
+ m_vboAvailable = false;
}
@@ -91,29 +83,45 @@ bool CGLDevice::Create()
{
GetLogger()->Info("Creating CDevice\n");
-#if defined(USE_GLEW)
static bool glewInited = false;
if (!glewInited)
{
glewInited = true;
+ glewExperimental = GL_TRUE;
+
if (glewInit() != GLEW_OK)
{
GetLogger()->Error("GLEW initialization failed\n");
return false;
}
- if ( (! GLEW_ARB_multitexture) || (! GLEW_EXT_texture_env_combine) )
+ m_multitextureAvailable = glewIsSupported("GL_ARB_multitexture GL_ARB_texture_env_combine");
+ if (!m_multitextureAvailable)
+ GetLogger()->Warn("GLEW reports multitexturing not supported - graphics quality will be degraded!\n");
+
+ if (m_config.vboMode == VBO_MODE_ENABLE)
{
- GetLogger()->Error("GLEW reports required extensions not supported\n");
- return false;
+ GetLogger()->Info("VBO enabled by override - using VBOs\n");
+ m_vboAvailable = true;
}
- }
-#endif
+ else if (m_config.vboMode == VBO_MODE_DISABLE)
+ {
+ GetLogger()->Info("VBO disabled by override - using display lists\n");
+ m_vboAvailable = false;
+ }
+ else
+ {
+ GetLogger()->Info("Auto-detecting VBO support\n");
+ m_vboAvailable = glewIsSupported("GL_ARB_vertex_buffer_object");
- /* NOTE: when not using GLEW, extension testing is not performed, as it is assumed that
- glext.h is up-to-date and the OpenGL shared library has the required functions present. */
+ if (m_vboAvailable)
+ GetLogger()->Info("Detected ARB_vertex_buffer_object extension - using VBOs\n");
+ else
+ GetLogger()->Info("No ARB_vertex_buffer_object extension present - using display lists\n");
+ }
+ }
// This is mostly done in all modern hardware by default
// DirectX doesn't even allow the option to turn off perspective correction anymore
@@ -123,6 +131,9 @@ bool CGLDevice::Create()
// To avoid problems with scaling & lighting
glEnable(GL_RESCALE_NORMAL);
+ // Minimal depth bias to avoid Z-fighting
+ SetDepthBias(0.001f);
+
// Set just to be sure
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
@@ -174,6 +185,16 @@ void CGLDevice::ConfigChanged(const GLDeviceConfig& newConfig)
Create();
}
+void CGLDevice::SetUseVbo(bool vboAvailable)
+{
+ m_vboAvailable = vboAvailable;
+}
+
+bool CGLDevice::GetUseVbo()
+{
+ return m_vboAvailable;
+}
+
void CGLDevice::BeginScene()
{
Clear();
@@ -413,7 +434,9 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
result.size.y = data->surface->h;
// Use & enable 1st texture stage
- glActiveTexture(GL_TEXTURE0);
+ if (m_multitextureAvailable)
+ glActiveTexture(GL_TEXTURE0);
+
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &result.id);
@@ -588,7 +611,7 @@ void CGLDevice::DestroyAllTextures()
m_allTextures.clear();
}
-int CGLDevice::GetMaxTextureCount()
+int CGLDevice::GetMaxTextureStageCount()
{
return m_currentTextures.size();
}
@@ -599,17 +622,21 @@ int CGLDevice::GetMaxTextureCount()
The setting is remembered, even if texturing is disabled at the moment. */
void CGLDevice::SetTexture(int index, const Texture &texture)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
bool same = m_currentTextures[index].id == texture.id;
m_currentTextures[index] = texture; // remember the new value
+ if (!m_multitextureAvailable && index != 0)
+ return;
+
if (same)
return; // nothing to do
- glActiveTexture(GL_TEXTURE0 + index);
+ if (m_multitextureAvailable)
+ glActiveTexture(GL_TEXTURE0 + index);
+
glBindTexture(GL_TEXTURE_2D, texture.id);
// Params need to be updated for the new bound texture
@@ -618,15 +645,19 @@ void CGLDevice::SetTexture(int index, const Texture &texture)
void CGLDevice::SetTexture(int index, unsigned int textureId)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
if (m_currentTextures[index].id == textureId)
return; // nothing to do
m_currentTextures[index].id = textureId;
- glActiveTexture(GL_TEXTURE0 + index);
+ if (!m_multitextureAvailable && index != 0)
+ return;
+
+ if (m_multitextureAvailable)
+ glActiveTexture(GL_TEXTURE0 + index);
+
glBindTexture(GL_TEXTURE_2D, textureId);
// Params need to be updated for the new bound texture
@@ -637,16 +668,14 @@ void CGLDevice::SetTexture(int index, unsigned int textureId)
Returns the previously assigned texture or invalid texture if the given stage is not enabled. */
Texture CGLDevice::GetTexture(int index)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
return m_currentTextures[index];
}
void CGLDevice::SetTextureEnabled(int index, bool enabled)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
bool same = m_texturesEnabled[index] == enabled;
@@ -655,7 +684,12 @@ void CGLDevice::SetTextureEnabled(int index, bool enabled)
if (same)
return; // nothing to do
- glActiveTexture(GL_TEXTURE0 + index);
+ if (!m_multitextureAvailable && index != 0)
+ return;
+
+ if (m_multitextureAvailable)
+ glActiveTexture(GL_TEXTURE0 + index);
+
if (enabled)
glEnable(GL_TEXTURE_2D);
else
@@ -664,8 +698,7 @@ void CGLDevice::SetTextureEnabled(int index, bool enabled)
bool CGLDevice::GetTextureEnabled(int index)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
return m_texturesEnabled[index];
}
@@ -676,17 +709,36 @@ bool CGLDevice::GetTextureEnabled(int index)
The settings are remembered, even if texturing is disabled at the moment. */
void CGLDevice::SetTextureStageParams(int index, const TextureStageParams &params)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
// Remember the settings
m_textureStageParams[index] = params;
+ if (!m_multitextureAvailable && index != 0)
+ return;
+
// Don't actually do anything if texture not set
if (! m_currentTextures[index].Valid())
return;
- glActiveTexture(GL_TEXTURE0 + index);
+ if (m_multitextureAvailable)
+ glActiveTexture(GL_TEXTURE0 + index);
+
+ if (params.wrapS == TEX_WRAP_CLAMP)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ else if (params.wrapS == TEX_WRAP_REPEAT)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ else assert(false);
+
+ if (params.wrapT == TEX_WRAP_CLAMP)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ else if (params.wrapT == TEX_WRAP_REPEAT)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ else assert(false);
+
+ // Texture env setting is silly without multitexturing
+ if (!m_multitextureAvailable)
+ return;
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, params.factor.Array());
@@ -790,26 +842,12 @@ after_tex_color:
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
else assert(false);
-
-after_tex_operations:
-
- if (params.wrapS == TEX_WRAP_CLAMP)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- else if (params.wrapS == TEX_WRAP_REPEAT)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- else assert(false);
-
- if (params.wrapT == TEX_WRAP_CLAMP)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- else if (params.wrapT == TEX_WRAP_REPEAT)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- else assert(false);
+after_tex_operations: ;
}
void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
// Remember the settings
m_textureStageParams[index].wrapS = wrapS;
@@ -819,7 +857,11 @@ void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wr
if (! m_currentTextures[index].Valid())
return;
- glActiveTexture(GL_TEXTURE0 + index);
+ if (!m_multitextureAvailable && index != 0)
+ return;
+
+ if (m_multitextureAvailable)
+ glActiveTexture(GL_TEXTURE0 + index);
if (wrapS == TEX_WRAP_CLAMP)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -836,8 +878,7 @@ void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wr
TextureStageParams CGLDevice::GetTextureStageParams(int index)
{
- assert(index >= 0);
- assert(index < static_cast<int>( m_currentTextures.size() ));
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
return m_textureStageParams[index];
}
@@ -868,7 +909,9 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int ve
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
- glClientActiveTexture(GL_TEXTURE0);
+ if (m_multitextureAvailable)
+ glClientActiveTexture(GL_TEXTURE0);
+
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
@@ -892,13 +935,18 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, in
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
- glClientActiveTexture(GL_TEXTURE0);
+ if (m_multitextureAvailable)
+ glClientActiveTexture(GL_TEXTURE0);
+
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
- glClientActiveTexture(GL_TEXTURE1);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
+ if (m_multitextureAvailable)
+ {
+ glClientActiveTexture(GL_TEXTURE1);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
+ }
glColor4fv(color.Array());
@@ -907,8 +955,11 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, in
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
- glClientActiveTexture(GL_TEXTURE0);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ if (m_multitextureAvailable)
+ {
+ glClientActiveTexture(GL_TEXTURE0);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ }
}
void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
@@ -927,29 +978,318 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int
glDisableClientState(GL_COLOR_ARRAY);
}
+unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
+{
+ unsigned int id = 0;
+ if (m_vboAvailable)
+ {
+ id = ++m_lastVboId;
+
+ VboObjectInfo info;
+ info.primitiveType = primitiveType;
+ info.vertexType = VERTEX_TYPE_NORMAL;
+ info.vertexCount = vertexCount;
+ info.bufferId = 0;
+
+ glGenBuffers(1, &info.bufferId);
+ glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
+ glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ m_vboObjects[id] = info;
+ }
+ else
+ {
+ id = glGenLists(1);
+
+ glNewList(id, GL_COMPILE);
+
+ DrawPrimitive(primitiveType, vertices, vertexCount);
+
+ glEndList();
+ }
+
+ return id;
+}
+
+unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
+{
+ unsigned int id = 0;
+ if (m_vboAvailable)
+ {
+ id = ++m_lastVboId;
+
+ VboObjectInfo info;
+ info.primitiveType = primitiveType;
+ info.vertexType = VERTEX_TYPE_TEX2;
+ info.vertexCount = vertexCount;
+ info.bufferId = 0;
+
+ glGenBuffers(1, &info.bufferId);
+ glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
+ glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexTex2), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ m_vboObjects[id] = info;
+ }
+ else
+ {
+ id = glGenLists(1);
+
+ glNewList(id, GL_COMPILE);
+
+ DrawPrimitive(primitiveType, vertices, vertexCount);
+
+ glEndList();
+ }
+
+ return id;
+}
+
+unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
+{
+ unsigned int id = 0;
+ if (m_vboAvailable)
+ {
+ id = ++m_lastVboId;
+
+ VboObjectInfo info;
+ info.primitiveType = primitiveType;
+ info.vertexType = VERTEX_TYPE_COL;
+ info.vertexCount = vertexCount;
+ info.bufferId = 0;
+
+ glGenBuffers(1, &info.bufferId);
+ glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
+ glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexCol), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ m_vboObjects[id] = info;
+ }
+ else
+ {
+ id = glGenLists(1);
+
+ glNewList(id, GL_COMPILE);
+
+ DrawPrimitive(primitiveType, vertices, vertexCount);
+
+ glEndList();
+ }
+
+ return id;
+}
+
+void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
+{
+ if (m_vboAvailable)
+ {
+ auto it = m_vboObjects.find(bufferId);
+ if (it == m_vboObjects.end())
+ return;
+
+ VboObjectInfo& info = (*it).second;
+ info.primitiveType = primitiveType;
+ info.vertexType = VERTEX_TYPE_NORMAL;
+ info.vertexCount = vertexCount;
+
+ glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
+ glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
+ else
+ {
+ glNewList(bufferId, GL_COMPILE);
+
+ DrawPrimitive(primitiveType, vertices, vertexCount);
+
+ glEndList();
+ }
+}
+
+void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
+{
+ if (m_vboAvailable)
+ {
+ auto it = m_vboObjects.find(bufferId);
+ if (it == m_vboObjects.end())
+ return;
+
+ VboObjectInfo& info = (*it).second;
+ info.primitiveType = primitiveType;
+ info.vertexType = VERTEX_TYPE_TEX2;
+ info.vertexCount = vertexCount;
+
+ glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
+ glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexTex2), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
+ else
+ {
+ glNewList(bufferId, GL_COMPILE);
+
+ DrawPrimitive(primitiveType, vertices, vertexCount);
+
+ glEndList();
+ }
+}
+
+void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
+{
+ if (m_vboAvailable)
+ {
+ auto it = m_vboObjects.find(bufferId);
+ if (it == m_vboObjects.end())
+ return;
+
+ VboObjectInfo& info = (*it).second;
+ info.primitiveType = primitiveType;
+ info.vertexType = VERTEX_TYPE_COL;
+ info.vertexCount = vertexCount;
+
+ glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
+ glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexCol), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
+ else
+ {
+ glNewList(bufferId, GL_COMPILE);
+
+ DrawPrimitive(primitiveType, vertices, vertexCount);
+
+ glEndList();
+ }
+}
+
+void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
+{
+ if (m_vboAvailable)
+ {
+ auto it = m_vboObjects.find(bufferId);
+ if (it == m_vboObjects.end())
+ return;
+
+ glEnable(GL_VERTEX_ARRAY);
+ glBindBuffer(GL_ARRAY_BUFFER, (*it).second.bufferId);
+
+ if ((*it).second.vertexType == VERTEX_TYPE_NORMAL)
+ {
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, coord));
+
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, normal));
+
+ if (m_multitextureAvailable)
+ glClientActiveTexture(GL_TEXTURE0);
+
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, texCoord));
+ }
+ else if ((*it).second.vertexType == VERTEX_TYPE_TEX2)
+ {
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, coord));
+
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, normal));
+
+ if (m_multitextureAvailable)
+ glClientActiveTexture(GL_TEXTURE0);
+
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord));
+
+ if (m_multitextureAvailable)
+ {
+ glClientActiveTexture(GL_TEXTURE1);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord2));
+ }
+ }
+ else if ((*it).second.vertexType == VERTEX_TYPE_COL)
+ {
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), static_cast<char*>(nullptr) + offsetof(VertexCol, coord));
+
+ glEnableClientState(GL_COLOR_ARRAY);
+ glColorPointer(4, GL_FLOAT, sizeof(VertexCol), static_cast<char*>(nullptr) + offsetof(VertexCol, color));
+ }
+
+ GLenum mode = TranslateGfxPrimitive((*it).second.primitiveType);
+ glDrawArrays(mode, 0, (*it).second.vertexCount);
+
+ if ((*it).second.vertexType == VERTEX_TYPE_NORMAL)
+ {
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
+ }
+ else if ((*it).second.vertexType == VERTEX_TYPE_TEX2)
+ {
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
+ if (m_multitextureAvailable)
+ {
+ glClientActiveTexture(GL_TEXTURE0);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ }
+ }
+ else if ((*it).second.vertexType == VERTEX_TYPE_COL)
+ {
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ }
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glDisable(GL_VERTEX_ARRAY);
+ }
+ else
+ {
+ glCallList(bufferId);
+ }
+}
+
+void CGLDevice::DestroyStaticBuffer(unsigned int bufferId)
+{
+ if (m_vboAvailable)
+ {
+ auto it = m_vboObjects.find(bufferId);
+ if (it == m_vboObjects.end())
+ return;
+
+ glDeleteBuffers(1, &(*it).second.bufferId);
+
+ m_vboObjects.erase(it);
+ }
+ else
+ {
+ glDeleteLists(bufferId, 1);
+ }
+}
+
bool InPlane(Math::Vector normal, float originPlane, Math::Vector center, float radius)
{
- float distance = (originPlane + Math::DotProduct(normal, center)) / normal.Length();
+ float distance = originPlane + Math::DotProduct(normal, center);
if (distance < -radius)
- return true;
+ return false;
- return false;
+ return true;
}
-/*
- The implementation of ComputeSphereVisibility is taken from libwine's device.c
- Copyright of the WINE team, licensed under GNU LGPL v 2.1
- */
+/* Based on libwine's implementation */
-// TODO: testing
int CGLDevice::ComputeSphereVisibility(const Math::Vector &center, float radius)
{
Math::Matrix m;
- m.LoadIdentity();
- m = Math::MultiplyMatrices(m, m_worldMat);
- m = Math::MultiplyMatrices(m, m_viewMat);
- m = Math::MultiplyMatrices(m, m_projectionMat);
+ m = Math::MultiplyMatrices(m_worldMat, m);
+ m = Math::MultiplyMatrices(m_viewMat, m);
+ Math::Matrix sc;
+ Math::LoadScaleMatrix(sc, Math::Vector(1.0f, 1.0f, -1.0f));
+ m = Math::MultiplyMatrices(sc, m);
+ m = Math::MultiplyMatrices(m_projectionMat, m);
Math::Vector vec[6];
float originPlane[6];
@@ -958,52 +1298,64 @@ int CGLDevice::ComputeSphereVisibility(const Math::Vector &center, float radius)
vec[0].x = m.Get(4, 1) + m.Get(1, 1);
vec[0].y = m.Get(4, 2) + m.Get(1, 2);
vec[0].z = m.Get(4, 3) + m.Get(1, 3);
- originPlane[0] = m.Get(4, 4) + m.Get(1, 4);
+ float l1 = vec[0].Length();
+ vec[0].Normalize();
+ originPlane[0] = (m.Get(4, 4) + m.Get(1, 4)) / l1;
// Right plane
vec[1].x = m.Get(4, 1) - m.Get(1, 1);
vec[1].y = m.Get(4, 2) - m.Get(1, 2);
vec[1].z = m.Get(4, 3) - m.Get(1, 3);
- originPlane[1] = m.Get(4, 4) - m.Get(1, 4);
-
- // Top plane
- vec[2].x = m.Get(4, 1) - m.Get(2, 1);
- vec[2].y = m.Get(4, 2) - m.Get(2, 2);
- vec[2].z = m.Get(4, 3) - m.Get(2, 3);
- originPlane[2] = m.Get(4, 4) - m.Get(2, 4);
+ float l2 = vec[1].Length();
+ vec[1].Normalize();
+ originPlane[1] = (m.Get(4, 4) - m.Get(1, 4)) / l2;
// Bottom plane
- vec[3].x = m.Get(4, 1) + m.Get(2, 1);
- vec[3].y = m.Get(4, 2) + m.Get(2, 2);
- vec[3].z = m.Get(4, 3) + m.Get(2, 3);
- originPlane[3] = m.Get(4, 4) + m.Get(2, 4);
+ vec[2].x = m.Get(4, 1) + m.Get(2, 1);
+ vec[2].y = m.Get(4, 2) + m.Get(2, 2);
+ vec[2].z = m.Get(4, 3) + m.Get(2, 3);
+ float l3 = vec[2].Length();
+ vec[2].Normalize();
+ originPlane[2] = (m.Get(4, 4) + m.Get(2, 4)) / l3;
+
+ // Top plane
+ vec[3].x = m.Get(4, 1) - m.Get(2, 1);
+ vec[3].y = m.Get(4, 2) - m.Get(2, 2);
+ vec[3].z = m.Get(4, 3) - m.Get(2, 3);
+ float l4 = vec[3].Length();
+ vec[3].Normalize();
+ originPlane[3] = (m.Get(4, 4) - m.Get(2, 4)) / l4;
// Front plane
- vec[4].x = m.Get(3, 1);
- vec[4].y = m.Get(3, 2);
- vec[4].z = m.Get(3, 3);
- originPlane[4] = m.Get(3, 4);
+ vec[4].x = m.Get(4, 1) + m.Get(3, 1);
+ vec[4].y = m.Get(4, 2) + m.Get(3, 2);
+ vec[4].z = m.Get(4, 3) + m.Get(3, 3);
+ float l5 = vec[4].Length();
+ vec[4].Normalize();
+ originPlane[4] = (m.Get(4, 4) + m.Get(3, 4)) / l5;
// Back plane
vec[5].x = m.Get(4, 1) - m.Get(3, 1);
vec[5].y = m.Get(4, 2) - m.Get(3, 2);
vec[5].z = m.Get(4, 3) - m.Get(3, 3);
- originPlane[5] = m.Get(4, 4) - m.Get(3, 4);
+ float l6 = vec[5].Length();
+ vec[5].Normalize();
+ originPlane[5] = (m.Get(4, 4) - m.Get(3, 4)) / l6;
int result = 0;
if (InPlane(vec[0], originPlane[0], center, radius))
- result |= INTERSECT_PLANE_LEFT;
+ result |= FRUSTUM_PLANE_LEFT;
if (InPlane(vec[1], originPlane[1], center, radius))
- result |= INTERSECT_PLANE_RIGHT;
+ result |= FRUSTUM_PLANE_RIGHT;
if (InPlane(vec[2], originPlane[2], center, radius))
- result |= INTERSECT_PLANE_TOP;
+ result |= FRUSTUM_PLANE_BOTTOM;
if (InPlane(vec[3], originPlane[3], center, radius))
- result |= INTERSECT_PLANE_BOTTOM;
+ result |= FRUSTUM_PLANE_TOP;
if (InPlane(vec[4], originPlane[4], center, radius))
- result |= INTERSECT_PLANE_FRONT;
+ result |= FRUSTUM_PLANE_FRONT;
if (InPlane(vec[5], originPlane[5], center, radius))
- result |= INTERSECT_PLANE_BACK;
+ result |= FRUSTUM_PLANE_BACK;
return result;
}
@@ -1042,7 +1394,6 @@ void CGLDevice::SetRenderState(RenderState state, bool enabled)
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break;
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
- case RENDER_STATE_DITHERING: flag = GL_DITHER; break;
default: assert(false); break;
}
@@ -1067,7 +1418,6 @@ bool CGLDevice::GetRenderState(RenderState state)
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break;
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
- case RENDER_STATE_DITHERING: flag = GL_DITHER; break;
default: assert(false); break;
}
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index 87c1247..fe3f2a1 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -27,12 +27,24 @@
#include <string>
#include <vector>
#include <set>
+#include <map>
// Graphics module namespace
namespace Gfx {
/**
+ \enum VBOMode
+ \brief VBO autodetect/override
+ */
+enum VBOMode
+{
+ VBO_MODE_ENABLE, //! < override: enable
+ VBO_MODE_DISABLE, //! < override: disable
+ VBO_MODE_AUTO //! < autodetect
+};
+
+/**
\struct GLDeviceConfig
\brief Additional config with OpenGL-specific settings */
struct GLDeviceConfig : public DeviceConfig
@@ -51,6 +63,9 @@ struct GLDeviceConfig : public DeviceConfig
//! Force hardware acceleration (video mode set will fail on lack of hw accel)
bool hardwareAccel;
+ //! VBO override/autodetect
+ VBOMode vboMode;
+
//! Constructor calls LoadDefaults()
GLDeviceConfig();
@@ -84,6 +99,9 @@ public:
void ConfigChanged(const GLDeviceConfig &newConfig);
+ void SetUseVbo(bool useVbo);
+ bool GetUseVbo();
+
virtual void BeginScene();
virtual void EndScene();
@@ -107,7 +125,7 @@ public:
virtual void DestroyTexture(const Texture &texture);
virtual void DestroyAllTextures();
- virtual int GetMaxTextureCount();
+ virtual int GetMaxTextureStageCount();
virtual void SetTexture(int index, const Texture &texture);
virtual void SetTexture(int index, unsigned int textureId);
virtual Texture GetTexture(int index);
@@ -119,14 +137,21 @@ public:
virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT);
- //! Renders primitive composed of vertices with single texture
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f));
- //! Renders primitive composed of vertices with multitexturing (2 textures)
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f));
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount);
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount);
+ virtual unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount);
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount);
+ virtual void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount);
+ virtual void DrawStaticBuffer(unsigned int bufferId);
+ virtual void DestroyStaticBuffer(unsigned int bufferId);
+
virtual int ComputeSphereVisibility(const Math::Vector &center, float radius);
virtual void SetRenderState(RenderState state, bool enabled);
@@ -200,6 +225,32 @@ private:
//! Set of all created textures
std::set<Texture> m_allTextures;
+
+ //! Type of vertex structure
+ enum VertexType
+ {
+ VERTEX_TYPE_NORMAL,
+ VERTEX_TYPE_TEX2,
+ VERTEX_TYPE_COL,
+ };
+
+ //! Info about static VBO buffers
+ struct VboObjectInfo
+ {
+ PrimitiveType primitiveType;
+ unsigned int bufferId;
+ VertexType vertexType;
+ int vertexCount;
+ };
+
+ //! Whether to use multitexturing
+ bool m_multitextureAvailable;
+ //! Whether to use VBOs or display lists
+ bool m_vboAvailable;
+ //! Map of saved VBO objects
+ std::map<unsigned int, VboObjectInfo> m_vboObjects;
+ //! Last ID of VBO object
+ unsigned int m_lastVboId;
};
diff --git a/src/graphics/opengl/test/CMakeLists.txt b/src/graphics/opengl/test/CMakeLists.txt
deleted file mode 100644
index 79e0ba5..0000000
--- a/src/graphics/opengl/test/CMakeLists.txt
+++ /dev/null
@@ -1,90 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-find_package(OpenGL REQUIRED)
-find_package(SDL REQUIRED)
-find_package(SDL_image REQUIRED)
-find_package(PNG REQUIRED)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-set(ADD_LIBS "")
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
- set(PLATFORM_WINDOWS 1)
- set(PLATFORM_LINUX 0)
- set(PLATFORM_OTHER 0)
-elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
- set(PLATFORM_WINDOWS 0)
- set(PLATFORM_LINUX 1)
- set(PLATFORM_OTHER 0)
- set(ADD_LIBS "-lrt")
-else()
- set(PLATFORM_WINDOWS 0)
- set(PLATFORM_LINUX 0)
- set(PLATFORM_OTHER 1)
-endif()
-
-configure_file(../../../common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
-
-
-set(TEXTURE_SOURCES
-../gldevice.cpp
-../../../common/logger.cpp
-../../../common/image.cpp
-texture_test.cpp
-)
-
-set(MODEL_SOURCES
-../gldevice.cpp
-../../engine/modelfile.cpp
-../../../common/logger.cpp
-../../../common/image.cpp
-../../../common/iman.cpp
-../../../common/stringutils.cpp
-../../../app/system.cpp
-model_test.cpp
-)
-
-set(TRANSFORM_SOURCES
-../gldevice.cpp
-../../../common/logger.cpp
-../../../common/image.cpp
-../../../common/iman.cpp
-../../../app/system.cpp
-transform_test.cpp
-)
-
-set(LIGHT_SOURCES
-../gldevice.cpp
-../../../common/logger.cpp
-../../../common/image.cpp
-../../../common/iman.cpp
-../../../app/system.cpp
-light_test.cpp
-)
-
-include_directories(../../../ ${CMAKE_CURRENT_BINARY_DIR})
-
-set(LIBS
-${SDL_LIBRARY}
-${SDLIMAGE_LIBRARY}
-${OPENGL_LIBRARY}
-${PNG_LIBRARIES}
-${ADD_LIBS}
-)
-
-add_executable(texture_test ${TEXTURE_SOURCES})
-target_link_libraries(texture_test ${LIBS})
-
-# Temporarily disabling because of dependencies on CEngine et al.
-#add_executable(model_test ${MODEL_SOURCES})
-#target_link_libraries(model_test ${LIBS})
-
-add_executable(transform_test ${TRANSFORM_SOURCES})
-target_link_libraries(transform_test ${LIBS})
-
-add_executable(light_test ${LIGHT_SOURCES})
-target_link_libraries(light_test ${LIBS})
diff --git a/src/graphics/opengl/test/README.txt b/src/graphics/opengl/test/README.txt
deleted file mode 100644
index c618415..0000000
--- a/src/graphics/opengl/test/README.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Test programs for OpenGL engine:
- - texture_test -> multitexturing test with 2 textures (included as files: ./tex1.png, ./tex2.png)
- - model_test -> simple model viewer to test model loading
- usage: ./model_test {dxf|mod} model_file
- second argument is the loaded format (DXF or Colobot .mod files)
- requires ./tex folder (or symlink) with Colobot textures
- viewer is controlled from keyboard - the bindings can be found in code
- - transform_test -> simple "walk around" test for world & view transformations
- - light test -> test for lighting
diff --git a/src/graphics/opengl/test/light_test.cpp b/src/graphics/opengl/test/light_test.cpp
deleted file mode 100644
index 6ff3b1c..0000000
--- a/src/graphics/opengl/test/light_test.cpp
+++ /dev/null
@@ -1,437 +0,0 @@
-#include "app/system.h"
-#include "common/logger.h"
-#include "common/image.h"
-#include "common/iman.h"
-#include "graphics/opengl/gldevice.h"
-#include "math/geometry.h"
-
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
-#include <unistd.h>
-
-#include <iostream>
-#include <map>
-
-enum KeySlots
-{
- K_Forward,
- K_Back,
- K_Left,
- K_Right,
- K_Up,
- K_Down,
- K_Count
-};
-bool KEYMAP[K_Count] = { false };
-
-Math::Point MOUSE_POS_BASE;
-
-Math::Vector TRANSLATION(0.0f, 2.0f, 0.0f);
-Math::Vector ROTATION, ROTATION_BASE;
-
-float CUBE_ORBIT = 0.0f;
-
-const int FRAME_DELAY = 5000;
-
-SystemTimeStamp *PREV_TIME = NULL, *CURR_TIME = NULL;
-
-void Init(Gfx::CGLDevice *device)
-{
- device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, true);
- device->SetShadeModel(Gfx::SHADE_SMOOTH);
-}
-
-void Render(Gfx::CGLDevice *device)
-{
- device->BeginScene();
-
- /* Unlit part of scene */
-
- device->SetRenderState(Gfx::RENDER_STATE_LIGHTING, false);
- device->SetRenderState(Gfx::RENDER_STATE_CULLING, false); // Double-sided drawing
-
- Math::Matrix persp;
- Math::LoadProjectionMatrix(persp, Math::PI / 4.0f, (800.0f) / (600.0f), 0.1f, 100.0f);
- device->SetTransform(Gfx::TRANSFORM_PROJECTION, persp);
-
-
- Math::Matrix viewMat;
- Math::Matrix mat;
-
- viewMat.LoadIdentity();
-
- Math::LoadRotationXMatrix(mat, -ROTATION.x);
- viewMat = Math::MultiplyMatrices(viewMat, mat);
-
- Math::LoadRotationYMatrix(mat, -ROTATION.y);
- viewMat = Math::MultiplyMatrices(viewMat, mat);
-
- Math::LoadTranslationMatrix(mat, -TRANSLATION);
- viewMat = Math::MultiplyMatrices(viewMat, mat);
-
- device->SetTransform(Gfx::TRANSFORM_VIEW, viewMat);
-
- Math::Matrix worldMat;
- worldMat.LoadIdentity();
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- Gfx::VertexCol line[2] = { Gfx::VertexCol() };
-
- for (int x = -40; x <= 40; ++x)
- {
- line[0].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f);
- line[0].coord.z = -40;
- line[0].coord.x = x;
- line[1].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f);
- line[1].coord.z = 40;
- line[1].coord.x = x;
- device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2);
- }
-
- for (int z = -40; z <= 40; ++z)
- {
- line[0].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f);
- line[0].coord.z = z;
- line[0].coord.x = -40;
- line[1].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f);
- line[1].coord.z = z;
- line[1].coord.x = 40;
- device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2);
- }
-
-
- Gfx::VertexCol quad[6] = { Gfx::VertexCol() };
-
- quad[0].coord = Math::Vector(-1.0f, -1.0f, 0.0f);
- quad[1].coord = Math::Vector( 1.0f, -1.0f, 0.0f);
- quad[2].coord = Math::Vector(-1.0f, 1.0f, 0.0f);
- quad[3].coord = Math::Vector( 1.0f, 1.0f, 0.0f);
-
- for (int i = 0; i < 6; ++i)
- quad[i].color = Gfx::Color(1.0f, 1.0f, 0.0f);
-
- Math::LoadTranslationMatrix(worldMat, Math::Vector(40.0f, 2.0f, 40.0f));
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4);
-
- for (int i = 0; i < 6; ++i)
- quad[i].color = Gfx::Color(0.0f, 1.0f, 1.0f);
-
- Math::LoadTranslationMatrix(worldMat, Math::Vector(-40.0f, 2.0f, -40.0f));
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4);
-
- for (int i = 0; i < 6; ++i)
- quad[i].color = Gfx::Color(1.0f, 0.0f, 1.0f);
-
- Math::LoadTranslationMatrix(worldMat, Math::Vector(10.0f, 4.5f, 5.0f));
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4);
-
- /* Moving lit cube */
- device->SetRenderState(Gfx::RENDER_STATE_LIGHTING, true);
- device->SetRenderState(Gfx::RENDER_STATE_CULLING, true); // Culling (CCW faces)
-
- device->SetGlobalAmbient(Gfx::Color(0.4f, 0.4f, 0.4f));
-
- Gfx::Light light1;
- light1.type = Gfx::LIGHT_POINT;
- light1.position = Math::Vector(10.0f, 4.5f, 5.0f);
- light1.ambient = Gfx::Color(0.2f, 0.2f, 0.2f);
- light1.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f);
- light1.specular = Gfx::Color(0.0f, 0.0f, 0.0f);
- device->SetLight(0, light1);
- device->SetLightEnabled(0, true);
-
- /*Gfx::Light light2;
- device->SetLight(1, light2);
- device->SetLightEnabled(1, true);*/
-
- Gfx::Material material;
- material.ambient = Gfx::Color(0.3f, 0.3f, 0.3f);
- material.diffuse = Gfx::Color(0.8f, 0.7f, 0.6f);
- material.specular = Gfx::Color(0.0f, 0.0f, 0.0f);
- device->SetMaterial(material);
-
- const Gfx::Vertex cube[6][4] =
- {
- {
- // Front
- Gfx::Vertex(Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f))
- },
-
- {
- // Back
- Gfx::Vertex(Math::Vector( 1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f))
- },
-
- {
- // Top
- Gfx::Vertex(Math::Vector(-1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 1.0f, 0.0f))
- },
-
- {
- // Bottom
- Gfx::Vertex(Math::Vector(-1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, -1.0f, 0.0f))
- },
-
- {
- // Left
- Gfx::Vertex(Math::Vector(-1.0f, -1.0f, 1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, 1.0f, 1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)),
- Gfx::Vertex(Math::Vector(-1.0f, 1.0f, -1.0f), Math::Vector(-1.0f, 0.0f, 0.0f))
- },
-
- {
- // Right
- Gfx::Vertex(Math::Vector( 1.0f, -1.0f, -1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, -1.0f, 1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, 1.0f, -1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)),
- Gfx::Vertex(Math::Vector( 1.0f, 1.0f, 1.0f), Math::Vector( 1.0f, 0.0f, 0.0f))
- }
- };
-
- Math::Matrix cubeTrans;
- Math::LoadTranslationMatrix(cubeTrans, Math::Vector(10.0f, 2.0f, 5.0f));
- Math::Matrix cubeRot;
- Math::LoadRotationMatrix(cubeRot, Math::Vector(0.0f, 1.0f, 0.0f), CUBE_ORBIT);
- Math::Matrix cubeRotInv;
- Math::LoadRotationMatrix(cubeRotInv, Math::Vector(0.0f, 1.0f, 0.0f), -CUBE_ORBIT);
- Math::Matrix cubeTransRad;
- Math::LoadTranslationMatrix(cubeTransRad, Math::Vector(0.0f, 0.0f, 6.0f));
- worldMat = Math::MultiplyMatrices(cubeTransRad, cubeRotInv);
- worldMat = Math::MultiplyMatrices(cubeRot, worldMat);
- worldMat = Math::MultiplyMatrices(cubeTrans, worldMat);
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- for (int i = 0; i < 6; ++i)
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, cube[i], 4);
-
- device->EndScene();
-}
-
-void Update()
-{
- const float TRANS_SPEED = 6.0f; // units / sec
-
- GetCurrentTimeStamp(CURR_TIME);
- float timeDiff = TimeStampDiff(PREV_TIME, CURR_TIME, STU_SEC);
- CopyTimeStamp(PREV_TIME, CURR_TIME);
-
- CUBE_ORBIT += timeDiff * (Math::PI / 4.0f);
-
- Math::Vector incTrans;
-
- if (KEYMAP[K_Forward])
- incTrans.z = +TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Back])
- incTrans.z = -TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Right])
- incTrans.x = +TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Left])
- incTrans.x = -TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Up])
- incTrans.y = +TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Down])
- incTrans.y = -TRANS_SPEED * timeDiff;
-
- Math::Point rotTrans = Math::RotatePoint(-ROTATION.y, Math::Point(incTrans.x, incTrans.z));
- incTrans.x = rotTrans.x;
- incTrans.z = rotTrans.y;
- TRANSLATION += incTrans;
-}
-
-void KeyboardDown(SDLKey key)
-{
- switch (key)
- {
- case SDLK_w:
- KEYMAP[K_Forward] = true;
- break;
- case SDLK_s:
- KEYMAP[K_Back] = true;
- break;
- case SDLK_d:
- KEYMAP[K_Right] = true;
- break;
- case SDLK_a:
- KEYMAP[K_Left] = true;
- break;
- case SDLK_z:
- KEYMAP[K_Down] = true;
- break;
- case SDLK_x:
- KEYMAP[K_Up] = true;
- break;
- default:
- break;
- }
-}
-
-void KeyboardUp(SDLKey key)
-{
- switch (key)
- {
- case SDLK_w:
- KEYMAP[K_Forward] = false;
- break;
- case SDLK_s:
- KEYMAP[K_Back] = false;
- break;
- case SDLK_d:
- KEYMAP[K_Right] = false;
- break;
- case SDLK_a:
- KEYMAP[K_Left] = false;
- break;
- case SDLK_z:
- KEYMAP[K_Down] = false;
- break;
- case SDLK_x:
- KEYMAP[K_Up] = false;
- break;
- default:
- break;
- }
-}
-
-void MouseMove(int x, int y)
-{
- Math::Point currentPos(static_cast<float>(x), static_cast<float>(y));
-
- static bool first = true;
- if (first || (x < 10) || (y < 10) || (x > 790) || (y > 590))
- {
- SDL_WarpMouse(400, 300);
- MOUSE_POS_BASE.x = 400;
- MOUSE_POS_BASE.y = 300;
- ROTATION_BASE = ROTATION;
- first = false;
- return;
- }
-
- ROTATION.y = ROTATION_BASE.y + (static_cast<float> (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI;
- ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
-}
-
-int main(int argc, char *argv[])
-{
- CLogger logger;
-
- PREV_TIME = CreateTimeStamp();
- CURR_TIME = CreateTimeStamp();
-
- GetCurrentTimeStamp(PREV_TIME);
- GetCurrentTimeStamp(CURR_TIME);
-
- CInstanceManager iMan;
-
- // Without any error checking, for simplicity
-
- SDL_Init(SDL_INIT_VIDEO);
-
- IMG_Init(IMG_INIT_PNG);
-
- const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
-
- Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
-
- if (videoInfo->hw_available)
- videoFlags |= SDL_HWSURFACE;
- else
- videoFlags |= SDL_SWSURFACE;
-
- if (videoInfo->blit_hw)
- videoFlags |= SDL_HWACCEL;
-
-
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags);
-
-
- SDL_WM_SetCaption("Light Test", "Light Test");
-
- //SDL_WM_GrabInput(SDL_GRAB_ON);
- SDL_ShowCursor(SDL_DISABLE);
-
- Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
- device->Create();
-
- Init(device);
-
- bool done = false;
- while (! done)
- {
- Render(device);
- Update();
-
- SDL_GL_SwapBuffers();
-
- SDL_Event event;
- while (SDL_PollEvent(&event))
- {
- if (event.type == SDL_QUIT)
- {
- break;
- done = true;
- }
- else if (event.type == SDL_KEYDOWN)
- {
- if (event.key.keysym.sym == SDLK_q)
- {
- done = true;
- break;
- }
- else
- KeyboardDown(event.key.keysym.sym);
- }
- else if (event.type == SDL_KEYUP)
- KeyboardUp(event.key.keysym.sym);
- else if (event.type == SDL_MOUSEMOTION)
- MouseMove(event.motion.x, event.motion.y);
- }
-
- usleep(FRAME_DELAY);
- }
-
- //SDL_WM_GrabInput(SDL_GRAB_OFF);
- SDL_ShowCursor(SDL_ENABLE);
-
- device->Destroy();
- delete device;
-
- SDL_FreeSurface(surface);
-
- IMG_Quit();
-
- SDL_Quit();
-
- DestroyTimeStamp(PREV_TIME);
- DestroyTimeStamp(CURR_TIME);
-
- return 0;
-}
diff --git a/src/graphics/opengl/test/model_test.cpp b/src/graphics/opengl/test/model_test.cpp
deleted file mode 100644
index e951e6e..0000000
--- a/src/graphics/opengl/test/model_test.cpp
+++ /dev/null
@@ -1,377 +0,0 @@
-#include "app/system.h"
-#include "common/logger.h"
-#include "common/image.h"
-#include "common/iman.h"
-#include "graphics/engine/modelfile.h"
-#include "graphics/opengl/gldevice.h"
-#include "math/geometry.h"
-
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
-#include <unistd.h>
-
-#include <iostream>
-#include <map>
-
-enum KeySlots
-{
- K_RotXUp,
- K_RotXDown,
- K_RotYLeft,
- K_RotYRight,
- K_Forward,
- K_Back,
- K_Left,
- K_Right,
- K_Up,
- K_Down,
- K_Count
-};
-bool KEYMAP[K_Count] = { false };
-
-Math::Vector TRANSLATION(0.0f, 0.0f, 30.0f);
-Math::Vector ROTATION;
-
-const int FRAME_DELAY = 5000;
-
-std::map<std::string, Gfx::Texture> TEXS;
-
-SystemTimeStamp *PREV_TIME = NULL, *CURR_TIME = NULL;
-
-Gfx::Texture GetTexture(const std::string &name)
-{
- std::map<std::string, Gfx::Texture>::iterator it = TEXS.find(name);
- if (it == TEXS.end())
- return Gfx::Texture();
-
- return (*it).second;
-}
-
-void LoadTexture(Gfx::CGLDevice *device, const std::string &name)
-{
- if (name.empty())
- return;
-
- Gfx::Texture tex = GetTexture(name);
-
- if (tex.Valid())
- return;
-
- CImage img;
- if (! img.Load(std::string("tex/") + name))
- {
- std::string err = img.GetError();
- GetLogger()->Error("Texture not loaded, error: %s!\n", err.c_str());
- }
- else
- {
- Gfx::TextureCreateParams texCreateParams;
- texCreateParams.mipmap = true;
- if (img.GetData()->surface->format->Amask == 0)
- texCreateParams.format = Gfx::TEX_IMG_BGR;
- else
- texCreateParams.format = Gfx::TEX_IMG_BGRA;
- texCreateParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR;
- texCreateParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR;
-
- tex = device->CreateTexture(&img, texCreateParams);
- }
-
- TEXS[name] = tex;
-}
-
-void Init(Gfx::CGLDevice *device, Gfx::CModelFile *model)
-{
- std::vector<Gfx::ModelTriangle> &triangles = model->GetTriangles();
-
- for (int i = 0; i < static_cast<int>( triangles.size() ); ++i)
- {
- LoadTexture(device, triangles[i].tex1Name);
- LoadTexture(device, triangles[i].tex2Name);
- }
-
- device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
- device->SetRenderState(Gfx::RENDER_STATE_LIGHTING, true);
- device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, true);
- device->SetShadeModel(Gfx::SHADE_SMOOTH);
-
- Gfx::Light light;
- light.type = Gfx::LIGHT_DIRECTIONAL;
- light.ambient = Gfx::Color(0.4f, 0.4f, 0.4f, 0.0f);
- light.diffuse = Gfx::Color(0.8f, 0.8f, 0.8f, 0.0f);
- light.specular = Gfx::Color(0.2f, 0.2f, 0.2f, 0.0f);
- light.position = Math::Vector(0.0f, 0.0f, -1.0f);
- light.direction = Math::Vector(0.0f, 0.0f, 1.0f);
-
- device->SetGlobalAmbient(Gfx::Color(0.5f, 0.5f, 0.5f, 0.0f));
- device->SetLight(0, light);
- device->SetLightEnabled(0, true);
-}
-
-void Render(Gfx::CGLDevice *device, Gfx::CModelFile *modelFile)
-{
- device->BeginScene();
-
- Math::Matrix persp;
- Math::LoadProjectionMatrix(persp, Math::PI / 4.0f, (800.0f) / (600.0f), 0.1f, 100.0f);
- device->SetTransform(Gfx::TRANSFORM_PROJECTION, persp);
-
- Math::Matrix id;
- id.LoadIdentity();
- device->SetTransform(Gfx::TRANSFORM_WORLD, id);
-
- Math::Matrix viewMat;
- Math::LoadTranslationMatrix(viewMat, TRANSLATION);
- Math::Matrix rot;
- Math::LoadRotationXZYMatrix(rot, ROTATION);
- viewMat = Math::MultiplyMatrices(viewMat, rot);
- device->SetTransform(Gfx::TRANSFORM_VIEW, viewMat);
-
- std::vector<Gfx::ModelTriangle> &triangles = modelFile->GetTriangles();
-
- Gfx::VertexTex2 tri[3];
-
- for (int i = 0; i < static_cast<int>( triangles.size() ); ++i)
- {
- device->SetTexture(0, GetTexture(triangles[i].tex1Name));
- device->SetTexture(1, GetTexture(triangles[i].tex2Name));
- device->SetTextureEnabled(0, true);
- device->SetTextureEnabled(1, true);
-
- device->SetMaterial(triangles[i].material);
-
- tri[0] = triangles[i].p1;
- tri[1] = triangles[i].p2;
- tri[2] = triangles[i].p3;
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, tri, 3);
- }
-
- device->EndScene();
-}
-
-void Update()
-{
- const float ROT_SPEED = 80.0f * Math::DEG_TO_RAD; // rad / sec
- const float TRANS_SPEED = 3.0f; // units / sec
-
- GetCurrentTimeStamp(CURR_TIME);
- float timeDiff = TimeStampDiff(PREV_TIME, CURR_TIME, STU_SEC);
- CopyTimeStamp(PREV_TIME, CURR_TIME);
-
- if (KEYMAP[K_RotYLeft])
- ROTATION.y -= ROT_SPEED * timeDiff;
- if (KEYMAP[K_RotYRight])
- ROTATION.y += ROT_SPEED * timeDiff;
- if (KEYMAP[K_RotXDown])
- ROTATION.x -= ROT_SPEED * timeDiff;
- if (KEYMAP[K_RotXUp])
- ROTATION.x += ROT_SPEED * timeDiff;
-
- if (KEYMAP[K_Forward])
- TRANSLATION.z -= TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Back])
- TRANSLATION.z += TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Left])
- TRANSLATION.x += TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Right])
- TRANSLATION.x -= TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Up])
- TRANSLATION.y += TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Down])
- TRANSLATION.y -= TRANS_SPEED * timeDiff;
-}
-
-void KeyboardDown(SDLKey key)
-{
- switch (key)
- {
- case SDLK_LEFT:
- KEYMAP[K_RotYLeft] = true;
- break;
- case SDLK_RIGHT:
- KEYMAP[K_RotYRight] = true;
- break;
- case SDLK_UP:
- KEYMAP[K_RotXUp] = true;
- break;
- case SDLK_DOWN:
- KEYMAP[K_RotXDown] = true;
- break;
- case SDLK_w:
- KEYMAP[K_Forward] = true;
- break;
- case SDLK_s:
- KEYMAP[K_Back] = true;
- break;
- case SDLK_a:
- KEYMAP[K_Left] = true;
- break;
- case SDLK_d:
- KEYMAP[K_Right] = true;
- break;
- case SDLK_z:
- KEYMAP[K_Down] = true;
- break;
- case SDLK_x:
- KEYMAP[K_Up] = true;
- break;
- default:
- break;
- }
-}
-
-void KeyboardUp(SDLKey key)
-{
- switch (key)
- {
- case SDLK_LEFT:
- KEYMAP[K_RotYLeft] = false;
- break;
- case SDLK_RIGHT:
- KEYMAP[K_RotYRight] = false;
- break;
- case SDLK_UP:
- KEYMAP[K_RotXUp] = false;
- break;
- case SDLK_DOWN:
- KEYMAP[K_RotXDown] = false;
- break;
- case SDLK_w:
- KEYMAP[K_Forward] = false;
- break;
- case SDLK_s:
- KEYMAP[K_Back] = false;
- break;
- case SDLK_a:
- KEYMAP[K_Left] = false;
- break;
- case SDLK_d:
- KEYMAP[K_Right] = false;
- break;
- case SDLK_z:
- KEYMAP[K_Down] = false;
- break;
- case SDLK_x:
- KEYMAP[K_Up] = false;
- break;
- default:
- break;
- }
-}
-
-int main(int argc, char *argv[])
-{
- CLogger logger;
-
- PREV_TIME = CreateTimeStamp();
- CURR_TIME = CreateTimeStamp();
-
- GetCurrentTimeStamp(PREV_TIME);
- GetCurrentTimeStamp(CURR_TIME);
-
- if (argc != 3)
- {
- std::cerr << "Usage: " << argv[0] << "{mod|dxf} model_file" << std::endl;
- return 1;
- }
-
- CInstanceManager iMan;
-
- Gfx::CModelFile *modelFile = new Gfx::CModelFile(&iMan);
- if (std::string(argv[1]) == "mod")
- {
- if (! modelFile->ReadModel(argv[2], false, false))
- {
- std::cerr << "Error reading MOD: " << modelFile->GetError() << std::endl;
- return 1;
- }
- }
- else if (std::string(argv[1]) == "dxf")
- {
- if (! modelFile->ReadDXF(argv[2], 0.0f, 0.0f))
- {
- std::cerr << "Error reading DXF: " << modelFile->GetError() << std::endl;
- return 1;
- }
- }
- else
- {
- std::cerr << "Usage: " << argv[0] << "{mod|dxf} model_file" << std::endl;
- return 1;
- }
-
- // Without any error checking, for simplicity
-
- SDL_Init(SDL_INIT_VIDEO);
-
- IMG_Init(IMG_INIT_PNG);
-
- const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
-
- Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
-
- if (videoInfo->hw_available)
- videoFlags |= SDL_HWSURFACE;
- else
- videoFlags |= SDL_SWSURFACE;
-
- if (videoInfo->blit_hw)
- videoFlags |= SDL_HWACCEL;
-
-
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags);
-
-
- SDL_WM_SetCaption("Model Test", "Model Test");
-
- Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
- device->Create();
-
- Init(device, modelFile);
-
- bool done = false;
- while (! done)
- {
- Render(device, modelFile);
- Update();
-
- SDL_GL_SwapBuffers();
-
- SDL_Event event;
- SDL_PollEvent(&event);
- if (event.type == SDL_QUIT)
- done = true;
- else if (event.type == SDL_KEYDOWN)
- KeyboardDown(event.key.keysym.sym);
- else if (event.type == SDL_KEYUP)
- KeyboardUp(event.key.keysym.sym);
-
- usleep(FRAME_DELAY);
- }
-
- delete modelFile;
-
- device->Destroy();
- delete device;
-
- SDL_FreeSurface(surface);
-
- IMG_Quit();
-
- SDL_Quit();
-
- DestroyTimeStamp(PREV_TIME);
- DestroyTimeStamp(CURR_TIME);
-
- return 0;
-}
diff --git a/src/graphics/opengl/test/tex1.png b/src/graphics/opengl/test/tex1.png
deleted file mode 100644
index 46c68a0..0000000
--- a/src/graphics/opengl/test/tex1.png
+++ /dev/null
Binary files differ
diff --git a/src/graphics/opengl/test/tex2.png b/src/graphics/opengl/test/tex2.png
deleted file mode 100644
index ebdae0d..0000000
--- a/src/graphics/opengl/test/tex2.png
+++ /dev/null
Binary files differ
diff --git a/src/graphics/opengl/test/texture_test.cpp b/src/graphics/opengl/test/texture_test.cpp
deleted file mode 100644
index 534a5c0..0000000
--- a/src/graphics/opengl/test/texture_test.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-#include "common/logger.h"
-#include "common/image.h"
-#include "graphics/opengl/gldevice.h"
-#include "math/geometry.h"
-
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
-#include <unistd.h>
-
-
-void Init(Gfx::CGLDevice *device)
-{
- device->SetShadeModel(Gfx::SHADE_SMOOTH);
-
- device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, false);
- device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true);
-
- device->SetTextureEnabled(0, true);
- device->SetTextureEnabled(1, true);
-
- CImage img1;
- if (! img1.Load("tex1.png"))
- {
- std::string err = img1.GetError();
- GetLogger()->Error("texture 1 not loaded, error: %d!\n", err.c_str());
- }
- CImage img2;
- if (! img2.Load("tex2.png"))
- {
- std::string err = img2.GetError();
- GetLogger()->Error("texture 2 not loaded, error: %d!\n", err.c_str());
- }
-
- Gfx::TextureCreateParams tex1CreateParams;
- tex1CreateParams.mipmap = true;
- tex1CreateParams.format = Gfx::TEX_IMG_RGBA;
- tex1CreateParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR;
- tex1CreateParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR;
-
- Gfx::TextureCreateParams tex2CreateParams;
- tex2CreateParams.mipmap = true;
- tex2CreateParams.format = Gfx::TEX_IMG_RGBA;
- tex2CreateParams.minFilter = Gfx::TEX_MIN_FILTER_NEAREST_MIPMAP_NEAREST;
- tex2CreateParams.magFilter = Gfx::TEX_MAG_FILTER_NEAREST;
-
- Gfx::Texture tex1 = device->CreateTexture(&img1, tex1CreateParams);
- Gfx::Texture tex2 = device->CreateTexture(&img2, tex2CreateParams);
-
- device->SetTexture(0, tex1);
- device->SetTexture(1, tex2);
-}
-
-void Render(Gfx::CGLDevice *device)
-{
- device->BeginScene();
-
- Math::Matrix ortho;
- Math::LoadOrthoProjectionMatrix(ortho, -10, 10, -10, 10);
- device->SetTransform(Gfx::TRANSFORM_PROJECTION, ortho);
-
- Math::Matrix id;
- id.LoadIdentity();
-
- device->SetTransform(Gfx::TRANSFORM_WORLD, id);
- device->SetTransform(Gfx::TRANSFORM_VIEW, id);
-
- static Gfx::VertexTex2 quad[] =
- {
- Gfx::VertexTex2(Math::Vector(-2.0f, 2.0f, 0.0f), Math::Vector(), Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f)),
- Gfx::VertexTex2(Math::Vector( 2.0f, 2.0f, 0.0f), Math::Vector(), Math::Point(1.0f, 0.0f), Math::Point(1.0f, 0.0f)),
- Gfx::VertexTex2(Math::Vector( 2.0f, -2.0f, 0.0f), Math::Vector(), Math::Point(1.0f, 1.0f), Math::Point(1.0f, 1.0f)),
-
- Gfx::VertexTex2(Math::Vector( 2.0f, -2.0f, 0.0f), Math::Vector(), Math::Point(1.0f, 1.0f), Math::Point(1.0f, 1.0f)),
- Gfx::VertexTex2(Math::Vector(-2.0f, -2.0f, 0.0f), Math::Vector(), Math::Point(0.0f, 1.0f), Math::Point(0.0f, 1.0f)),
- Gfx::VertexTex2(Math::Vector(-2.0f, 2.0f, 0.0f), Math::Vector(), Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f)),
- };
-
- Gfx::TextureStageParams tex1StageParams;
- tex1StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- tex1StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- device->SetTextureStageParams(0, tex1StageParams);
-
- Gfx::TextureStageParams tex2StageParams;
- tex2StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- tex2StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- device->SetTextureStageParams(1, tex2StageParams);
-
- Math::Matrix t;
- Math::LoadTranslationMatrix(t, Math::Vector(-4.0f, 4.0f, 0.0f));
- device->SetTransform(Gfx::TRANSFORM_VIEW, t);
-
- device->SetTextureEnabled(0, true);
- device->SetTextureEnabled(1, false);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
-
- Math::LoadTranslationMatrix(t, Math::Vector( 4.0f, 4.0f, 0.0f));
- device->SetTransform(Gfx::TRANSFORM_VIEW, t);
-
- device->SetTextureEnabled(0, false);
- device->SetTextureEnabled(1, true);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
-
- Math::LoadTranslationMatrix(t, Math::Vector( 0.0f, -4.0f, 0.0f));
- device->SetTransform(Gfx::TRANSFORM_VIEW, t);
-
- device->SetTextureEnabled(0, true);
- device->SetTextureEnabled(1, true);
-
- tex1StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- tex1StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- device->SetTextureStageParams(0, tex1StageParams);
-
- tex2StageParams.colorOperation = Gfx::TEX_MIX_OPER_ADD;
- tex2StageParams.colorArg1 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR;
- tex2StageParams.colorArg2 = Gfx::TEX_MIX_ARG_TEXTURE;
- tex2StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
- device->SetTextureStageParams(1, tex2StageParams);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
-
- device->EndScene();
-}
-
-int main()
-{
- CLogger();
-
- // Without any error checking, for simplicity
-
- SDL_Init(SDL_INIT_VIDEO);
-
- IMG_Init(IMG_INIT_PNG);
-
- const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
-
- Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
-
- if (videoInfo->hw_available)
- videoFlags |= SDL_HWSURFACE;
- else
- videoFlags |= SDL_SWSURFACE;
-
- if (videoInfo->blit_hw)
- videoFlags |= SDL_HWACCEL;
-
-
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags);
-
-
- SDL_WM_SetCaption("Texture Test", "Texture Test");
-
- Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
- device->Create();
-
- Init(device);
-
- bool done = false;
- while (! done)
- {
- Render(device);
-
- SDL_GL_SwapBuffers();
-
- SDL_Event event;
- SDL_PollEvent(&event);
- if (event.type == SDL_QUIT)
- done = true;
-
- usleep(10000);
- }
-
- device->Destroy();
- delete device;
-
- SDL_FreeSurface(surface);
-
- IMG_Quit();
-
- SDL_Quit();
-
- return 0;
-}
diff --git a/src/graphics/opengl/test/transform_test.cpp b/src/graphics/opengl/test/transform_test.cpp
deleted file mode 100644
index cddd1b8..0000000
--- a/src/graphics/opengl/test/transform_test.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-#include "app/system.h"
-#include "common/logger.h"
-#include "common/image.h"
-#include "common/iman.h"
-#include "graphics/opengl/gldevice.h"
-#include "math/geometry.h"
-
-#include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
-#include <unistd.h>
-
-#include <iostream>
-#include <map>
-
-enum KeySlots
-{
- K_Forward,
- K_Back,
- K_Left,
- K_Right,
- K_Up,
- K_Down,
- K_Count
-};
-bool KEYMAP[K_Count] = { false };
-
-Math::Point MOUSE_POS_BASE;
-
-Math::Vector TRANSLATION(0.0f, 2.0f, 0.0f);
-Math::Vector ROTATION, ROTATION_BASE;
-
-const int FRAME_DELAY = 5000;
-
-SystemTimeStamp *PREV_TIME = NULL, *CURR_TIME = NULL;
-
-void Init(Gfx::CGLDevice *device)
-{
- device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, true);
- device->SetShadeModel(Gfx::SHADE_SMOOTH);
-}
-
-void Render(Gfx::CGLDevice *device)
-{
- device->BeginScene();
-
- Math::Matrix persp;
- Math::LoadProjectionMatrix(persp, Math::PI / 4.0f, (800.0f) / (600.0f), 0.1f, 100.0f);
- device->SetTransform(Gfx::TRANSFORM_PROJECTION, persp);
-
-
- Math::Matrix viewMat;
- Math::Matrix mat;
-
- viewMat.LoadIdentity();
-
- Math::LoadRotationXMatrix(mat, -ROTATION.x);
- viewMat = Math::MultiplyMatrices(viewMat, mat);
-
- Math::LoadRotationYMatrix(mat, -ROTATION.y);
- viewMat = Math::MultiplyMatrices(viewMat, mat);
-
- Math::LoadTranslationMatrix(mat, -TRANSLATION);
- viewMat = Math::MultiplyMatrices(viewMat, mat);
-
- device->SetTransform(Gfx::TRANSFORM_VIEW, viewMat);
-
-
- Math::Matrix worldMat;
- worldMat.LoadIdentity();
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- Gfx::VertexCol line[2] = { Gfx::VertexCol() };
-
- for (int x = -40; x <= 40; ++x)
- {
- line[0].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f);
- line[0].coord.z = -40;
- line[0].coord.x = x;
- line[1].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f);
- line[1].coord.z = 40;
- line[1].coord.x = x;
- device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2);
- }
-
- for (int z = -40; z <= 40; ++z)
- {
- line[0].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f);
- line[0].coord.z = z;
- line[0].coord.x = -40;
- line[1].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f);
- line[1].coord.z = z;
- line[1].coord.x = 40;
- device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2);
- }
-
-
- Gfx::VertexCol quad[6] = { Gfx::VertexCol() };
-
- for (int i = 0; i < 6; ++i)
- quad[i].color = Gfx::Color(1.0f, 1.0f, 0.0f);
-
- quad[0].coord = Math::Vector(-1.0f, -1.0f, 0.0f);
- quad[1].coord = Math::Vector( 1.0f, -1.0f, 0.0f);
- quad[2].coord = Math::Vector( 1.0f, 1.0f, 0.0f);
- quad[3].coord = Math::Vector( 1.0f, 1.0f, 0.0f);
- quad[4].coord = Math::Vector(-1.0f, 1.0f, 0.0f);
- quad[5].coord = Math::Vector(-1.0f, -1.0f, 0.0f);
-
- Math::LoadTranslationMatrix(worldMat, Math::Vector(40.0f, 2.0f, 40.0f));
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
-
- for (int i = 0; i < 6; ++i)
- quad[i].color = Gfx::Color(0.0f, 1.0f, 1.0f);
-
- Math::LoadTranslationMatrix(worldMat, Math::Vector(-40.0f, 2.0f, -40.0f));
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
-
- for (int i = 0; i < 6; ++i)
- quad[i].color = Gfx::Color(1.0f, 0.0f, 1.0f);
-
- Math::LoadTranslationMatrix(worldMat, Math::Vector(0.0f, 10.0f, 0.0f));
- device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
-
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
-
- device->EndScene();
-}
-
-void Update()
-{
- const float TRANS_SPEED = 6.0f; // units / sec
-
- GetCurrentTimeStamp(CURR_TIME);
- float timeDiff = TimeStampDiff(PREV_TIME, CURR_TIME, STU_SEC);
- CopyTimeStamp(PREV_TIME, CURR_TIME);
-
- Math::Vector incTrans;
-
- if (KEYMAP[K_Forward])
- incTrans.z = +TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Back])
- incTrans.z = -TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Right])
- incTrans.x = +TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Left])
- incTrans.x = -TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Up])
- incTrans.y = +TRANS_SPEED * timeDiff;
- if (KEYMAP[K_Down])
- incTrans.y = -TRANS_SPEED * timeDiff;
-
- Math::Point rotTrans = Math::RotatePoint(-ROTATION.y, Math::Point(incTrans.x, incTrans.z));
- incTrans.x = rotTrans.x;
- incTrans.z = rotTrans.y;
- TRANSLATION += incTrans;
-}
-
-void KeyboardDown(SDLKey key)
-{
- switch (key)
- {
- case SDLK_w:
- KEYMAP[K_Forward] = true;
- break;
- case SDLK_s:
- KEYMAP[K_Back] = true;
- break;
- case SDLK_d:
- KEYMAP[K_Right] = true;
- break;
- case SDLK_a:
- KEYMAP[K_Left] = true;
- break;
- case SDLK_z:
- KEYMAP[K_Down] = true;
- break;
- case SDLK_x:
- KEYMAP[K_Up] = true;
- break;
- default:
- break;
- }
-}
-
-void KeyboardUp(SDLKey key)
-{
- switch (key)
- {
- case SDLK_w:
- KEYMAP[K_Forward] = false;
- break;
- case SDLK_s:
- KEYMAP[K_Back] = false;
- break;
- case SDLK_d:
- KEYMAP[K_Right] = false;
- break;
- case SDLK_a:
- KEYMAP[K_Left] = false;
- break;
- case SDLK_z:
- KEYMAP[K_Down] = false;
- break;
- case SDLK_x:
- KEYMAP[K_Up] = false;
- break;
- default:
- break;
- }
-}
-
-void MouseMove(int x, int y)
-{
- Math::Point currentPos(static_cast<float>(x), static_cast<float>(y));
-
- static bool first = true;
- if (first || (x < 10) || (y < 10) || (x > 790) || (y > 590))
- {
- SDL_WarpMouse(400, 300);
- MOUSE_POS_BASE.x = 400;
- MOUSE_POS_BASE.y = 300;
- ROTATION_BASE = ROTATION;
- first = false;
- return;
- }
-
- ROTATION.y = ROTATION_BASE.y + (static_cast<float> (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI;
- ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
-}
-
-int main(int argc, char *argv[])
-{
- CLogger logger;
-
- PREV_TIME = CreateTimeStamp();
- CURR_TIME = CreateTimeStamp();
-
- GetCurrentTimeStamp(PREV_TIME);
- GetCurrentTimeStamp(CURR_TIME);
-
- CInstanceManager iMan;
-
- // Without any error checking, for simplicity
-
- SDL_Init(SDL_INIT_VIDEO);
-
- IMG_Init(IMG_INIT_PNG);
-
- const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
-
- Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
-
- if (videoInfo->hw_available)
- videoFlags |= SDL_HWSURFACE;
- else
- videoFlags |= SDL_SWSURFACE;
-
- if (videoInfo->blit_hw)
- videoFlags |= SDL_HWACCEL;
-
-
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags);
-
-
- SDL_WM_SetCaption("Transform Test", "Transform Test");
-
- //SDL_WM_GrabInput(SDL_GRAB_ON);
- SDL_ShowCursor(SDL_DISABLE);
-
- Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig());
- device->Create();
-
- Init(device);
-
- bool done = false;
- while (! done)
- {
- Render(device);
- Update();
-
- SDL_GL_SwapBuffers();
-
- SDL_Event event;
- while (SDL_PollEvent(&event))
- {
- if (event.type == SDL_QUIT)
- {
- break;
- done = true;
- }
- else if (event.type == SDL_KEYDOWN)
- {
- if (event.key.keysym.sym == SDLK_q)
- {
- done = true;
- break;
- }
- else
- KeyboardDown(event.key.keysym.sym);
- }
- else if (event.type == SDL_KEYUP)
- KeyboardUp(event.key.keysym.sym);
- else if (event.type == SDL_MOUSEMOTION)
- MouseMove(event.motion.x, event.motion.y);
- }
-
- usleep(FRAME_DELAY);
- }
-
- //SDL_WM_GrabInput(SDL_GRAB_OFF);
- SDL_ShowCursor(SDL_ENABLE);
-
- device->Destroy();
- delete device;
-
- SDL_FreeSurface(surface);
-
- IMG_Quit();
-
- SDL_Quit();
-
- DestroyTimeStamp(PREV_TIME);
- DestroyTimeStamp(CURR_TIME);
-
- return 0;
-}
diff --git a/src/math/geometry.h b/src/math/geometry.h
index ee6fc52..23c149c 100644
--- a/src/math/geometry.h
+++ b/src/math/geometry.h
@@ -197,15 +197,34 @@ inline void RotatePoint2(const Math::Vector center, float angleH, float angleV,
//! Returns the angle between point (x,y) and (0,0)
inline float RotateAngle(float x, float y)
{
- if ( (x == 0.0f) && (y == 0.0f) )
- return 0.0f;
+ if (x == 0.0f && y == 0.0f) return 0.0f;
- float atan = atan2(x, y);
-
- if ((y < 0.0f) && (x >= 0.0f))
- return -atan + 2.5f*PI;
+ if (x >= 0.0f)
+ {
+ if (y >= 0.0f)
+ {
+ if (x > y) return atanf(y/x);
+ else return PI*0.5f - atanf(x/y);
+ }
+ else
+ {
+ if (x > -y) return PI*2.0f + atanf(y/x);
+ else return PI*1.5f - atanf(x/y);
+ }
+ }
else
- return -atan + 0.5f*PI;
+ {
+ if (y >= 0.0f)
+ {
+ if (-x > y) return PI*1.0f + atanf(y/x);
+ else return PI*0.5f - atanf(x/y);
+ }
+ else
+ {
+ if (-x > -y) return PI*1.0f + atanf(y/x);
+ else return PI*1.5f - atanf(x/y);
+ }
+ }
}
//! Calculates the angle between two points and a center
diff --git a/src/math/intpoint.h b/src/math/intpoint.h
index ebd9c5e..010b0fb 100644
--- a/src/math/intpoint.h
+++ b/src/math/intpoint.h
@@ -21,6 +21,7 @@
#pragma once
+#include <cmath>
// Math module namespace
namespace Math {
@@ -49,6 +50,11 @@ struct IntPoint
{
return !operator==(p);
}
+
+ inline float Length() const
+ {
+ return sqrtf(x*x + y*y);
+ }
};
diff --git a/src/math/test/CMakeLists.txt b/src/math/test/CMakeLists.txt
deleted file mode 100644
index e31260c..0000000
--- a/src/math/test/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-include_directories(
-.
-../..
-../../..
-${GTEST_INCLUDE_DIR}
-)
-
-add_executable(matrix_test matrix_test.cpp)
-target_link_libraries(matrix_test gtest)
-
-add_executable(vector_test vector_test.cpp)
-target_link_libraries(vector_test gtest)
-
-add_executable(geometry_test geometry_test.cpp)
-target_link_libraries(geometry_test gtest)
-
-add_test(matrix_test matrix_test)
-add_test(vector_test vector_test)
-add_test(geometry_test geometry_test)
diff --git a/src/math/test/gendata.m b/src/math/test/gendata.m
deleted file mode 100644
index 5c13491..0000000
--- a/src/math/test/gendata.m
+++ /dev/null
@@ -1,86 +0,0 @@
-% Script in Octave for generating test data
-
-1;
-
-% Returns the minor matrix
-function m = minor(A, r, c)
-
- m = A;
- m(r,:) = [];
- m(:,c) = [];
-
-end;
-
-% Returns the cofactor matrix
-function m = cofactors(A)
-
- m = zeros(rows(A), columns(A));
-
- for r = [1 : rows(A)]
- for c = [1 : columns(A)]
- m(r, c) = det(minor(A, r, c));
- if (mod(r + c, 2) == 1)
- m(r, c) = -m(r, c);
- end;
- end;
- end;
-
-end;
-
-% Prints the matrix as C++ code
-function printout(A, name)
-
- printf('const float %s[16] = \n', name);
- printf('{\n');
-
- for c = [1 : columns(A)]
- for r = [1 : rows(A)]
- printf(' %f', A(r,c));
- if (! ( (r == 4) && (c == 4) ) )
- printf(',');
- end;
- printf('\n');
- end;
- end;
-
- printf('};\n');
-
-end;
-
-printf('// Cofactors\n');
-A = randn(4,4);
-printout(A, 'COF_MAT');
-printf('\n');
-printout(cofactors(A), 'COF_RESULT');
-printf('\n');
-
-printf('\n');
-
-printf('// Det\n');
-A = randn(4,4);
-printout(A, 'DET_MAT');
-printf('\n');
-printf('const float DET_RESULT = %f;', det(A));
-printf('\n');
-
-printf('\n');
-
-printf('// Invert\n');
-A = randn(4,4);
-printout(A, 'INV_MAT');
-printf('\n');
-printout(inv(A), 'COF_RESULT');
-printf('\n');
-
-printf('\n');
-
-printf('// Multiplication\n');
-A = randn(4,4);
-printout(A, 'MUL_A');
-printf('\n');
-B = randn(4,4);
-printout(B, 'MUL_B');
-printf('\n');
-C = A * B;
-printout(C, 'MUL_RESULT');
-printf('\n');
diff --git a/src/math/test/geometry_test.cpp b/src/math/test/geometry_test.cpp
deleted file mode 100644
index 8b83b8d..0000000
--- a/src/math/test/geometry_test.cpp
+++ /dev/null
@@ -1,359 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-// math/test/geometry_test.cpp
-
-/* Unit tests for functions in geometry.h */
-
-#include "../func.h"
-#include "../geometry.h"
-
-#include "gtest/gtest.h"
-
-
-const float TEST_TOLERANCE = 1e-5;
-
-
-// Test for rewritten function RotateAngle()
-TEST(GeometryTest, RotateAngleTest)
-{
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE));
-}
-
-// Tests for other altered, complex or uncertain functions
-
-/*
-
- TODO: write meaningful tests with proper test values
-
-int TestAngle()
-{
- const Math::Vector u(-0.0786076246943884, 0.2231249091714256, -1.1601361718477805);
- const Math::Vector v(-1.231228742001907, -1.720549809950561, -0.690468438834111);
-
- float mathResult = Math::Angle(u, v);
- float oldMathResult = Angle(VEC_TO_D3DVEC(u), VEC_TO_D3DVEC(v));
-
- if (! Math::IsEqual(mathResult, oldMathResult, TEST_TOLERANCE) )
- return __LINE__;
-
- return 0;
-}
-
-int TestRotateView()
-{
- const Math::Vector center(0.617909142705555, 0.896939729454538, -0.615041943652284);
- const float angleH = 44.5;
- const float angleV = 12.3;
- const float dist = 34.76;
-
- Math::Vector mathResult = Math::RotateView(center, angleH, angleV, dist);
- Math::Vector oldMathResult = D3DVEC_TO_VEC(RotateView(VEC_TO_D3DVEC(center), angleH, angleV, dist));
-
- if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLookatPoint()
-{
- const Math::Vector eye(-2.451183170579471, 0.241270270546559, -0.490677411454893);
- const float angleH = 48.4;
- const float angleV = 32.4;
- const float length = 74.44;
-
- Math::Vector mathResult = Math::LookatPoint(eye, angleH, angleV, length);
- Math::Vector oldMathResult = D3DVEC_TO_VEC(LookatPoint(VEC_TO_D3DVEC(eye), angleH, angleV, length));
-
- if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestProjection()
-{
- const Math::Vector a(0.852064846846319, -0.794279497087496, -0.655779805476688);
- const Math::Vector b(-0.245838834102304, -0.841115596038861, 0.470457161487799);
- const Math::Vector p(2.289326061164255, -0.505511362271196, 0.660204551169491);
-
- Math::Vector mathResult = Math::Projection(a, b, p);
- Math::Vector oldMathResult = D3DVEC_TO_VEC(Projection(VEC_TO_D3DVEC(a), VEC_TO_D3DVEC(b), VEC_TO_D3DVEC(p)));
-
- if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadViewMatrix()
-{
- const Math::Vector from(2.5646013154868874, -0.6058794133917031, -0.0441195127419744);
- const Math::Vector at(0.728044925765569, -0.206343977871841, 2.543158236935463);
- const Math::Vector worldUp(-1.893738133660711, -1.009584441407070, 0.521745988225582);
-
- Math::Matrix mathResult;
- Math::LoadViewMatrix(mathResult, from, at, worldUp);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DVECTOR fromD3D = VEC_TO_D3DVEC(from);
- D3DVECTOR atD3D = VEC_TO_D3DVEC(at);
- D3DVECTOR worldUpD3D = VEC_TO_D3DVEC(worldUp);
- D3DUtil_SetViewMatrix(mat, fromD3D, atD3D, worldUpD3D);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadProjectionMatrix()
-{
- const float fov = 76.3f;
- const float aspect = 0.891f;
- const float nearPlane = 12.3f;
- const float farPlane = 1238.9f;
-
- Math::Matrix mathResult;
- Math::LoadProjectionMatrix(mathResult, fov, aspect, nearPlane, farPlane);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DUtil_SetProjectionMatrix(mat, fov, aspect, nearPlane, farPlane);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadTranslationMatrix()
-{
- const Math::Vector translation(-0.3631590720995237, 1.6976327614875211, 0.0148815191502145);
-
- Math::Matrix mathResult;
- Math::LoadTranslationMatrix(mathResult, translation);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DUtil_SetTranslateMatrix(mat, translation.x, translation.y, translation.z);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadScaleMatrix()
-{
- const Math::Vector scale(0.612236460285503, -0.635566935025364, -0.254321375332065);
-
- Math::Matrix mathResult;
- Math::LoadScaleMatrix(mathResult, scale);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DUtil_SetScaleMatrix(mat, scale.x, scale.y, scale.z);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadRotationXMatrix()
-{
- const float angle = 0.513790685774275;
-
- Math::Matrix mathResult;
- Math::LoadRotationXMatrix(mathResult, angle);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DUtil_SetRotateXMatrix(mat, angle);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadRotationYMatrix()
-{
- const float angle = -0.569166650127303;
-
- Math::Matrix mathResult;
- Math::LoadRotationYMatrix(mathResult, angle);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DUtil_SetRotateYMatrix(mat, angle);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadRotationZMatrix()
-{
- const float angle = 0.380448034347452;
-
- Math::Matrix mathResult;
- Math::LoadRotationZMatrix(mathResult, angle);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DUtil_SetRotateZMatrix(mat, angle);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadRotationMatrix()
-{
- const float angle = -0.987747190637790;
- const Math::Vector dir(-0.113024727688331, -0.781265998072571, 1.838972397076884);
-
- Math::Matrix mathResult;
- Math::LoadRotationMatrix(mathResult, dir, angle);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- D3DVECTOR dirD3D = VEC_TO_D3DVEC(dir);
- D3DUtil_SetRotationMatrix(mat, dirD3D, angle);
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadRotationXZYMatrix()
-{
- const Math::Vector angles(-0.841366567984597, -0.100543315396357, 1.610647811559988);
-
- Math::Matrix mathResult;
- Math::LoadRotationXZYMatrix(mathResult, angles);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- MatRotateXZY(mat, VEC_TO_D3DVEC(angles));
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestLoadRotationZXYMatrix()
-{
- const Math::Vector angles(0.275558495480206, -0.224328265970090, 0.943077216574253);
-
- Math::Matrix mathResult;
- Math::LoadRotationZXYMatrix(mathResult, angles);
-
- Math::Matrix oldMathResult;
- {
- D3DMATRIX mat;
- MatRotateZXY(mat, VEC_TO_D3DVEC(angles));
- oldMathResult = D3DMAT_TO_MAT(mat);
- }
-
- if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-int TestTransform()
-{
- Math::Matrix transformMatrix(
- (float[4][4])
- {
- { -0.9282074720977896, 0.6794734970319730, -1.3234304946882685, 0.0925294727863890 },
- { -0.0395527963683484, 0.2897634352353881, 1.9144398570315440, -1.4062267508968478 },
- { 0.9133323625282361, -0.6741836434774530, -0.2188812951424338, -1.0089184339952666 },
- { 0.0f, 0.0f, 0.0f, 1.0f }
- }
- );
- Math::Vector vector(-0.314596433318370, -0.622681232583150, -0.371307535743574);
-
- Math::Vector mathResult = Math::Transform(transformMatrix, vector);
- Math::Vector oldMathResult = Transform(transformMatrix, vector);
-
- if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
-}
-
-*/
-
-
-int main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/math/test/matrix_test.cpp b/src/math/test/matrix_test.cpp
deleted file mode 100644
index 867e0ec..0000000
--- a/src/math/test/matrix_test.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-// math/test/matrix_test.cpp
-
-/*
- Unit tests for Matrix struct
-
- Test data was randomly generated and the expected results
- calculated using GNU Octave.
- */
-
-#include "../func.h"
-#include "../matrix.h"
-
-#include "gtest/gtest.h"
-
-
-const float TEST_TOLERANCE = 1e-6;
-
-
-TEST(MatrixTest, TransposeTest)
-{
- const Math::Matrix mat(
- (float[4][4])
- {
- { -0.07011674491203920, 1.26145596067429810, 2.09476603598066902, 0.35560176915570696 },
- { -1.34075615966224704, 1.17988499016709314, 0.00601713429241016, -0.75213676977972566 },
- { 0.59186722295223981, 0.88089224074765293, 0.70994467464257294, 0.36730385425340212 },
- { -0.95649396555068111, 0.75912182022565566, 1.34883305778387186, -1.34957997578168754 }
- }
- );
-
- const Math::Matrix expectedTranspose(
- (float[4][4])
- {
- { -0.07011674491203920, -1.34075615966224704, 0.59186722295223981, -0.95649396555068111 },
- { 1.26145596067429810, 1.17988499016709314, 0.88089224074765293, 0.75912182022565566 },
- { 2.09476603598066902, 0.00601713429241016, 0.70994467464257294, 1.34883305778387186 },
- { 0.35560176915570696, -0.75213676977972566, 0.36730385425340212, -1.34957997578168754 }
- }
- );
-
- Math::Matrix transpose = Math::Transpose(mat);
-
- EXPECT_TRUE(Math::MatricesEqual(transpose, expectedTranspose, TEST_TOLERANCE));
-}
-
-TEST(MatrixTest, CofactorTest)
-{
- const Math::Matrix mat1(
- (float[4][4])
- {
- { 0.610630320796245, 1.059932357918312, -1.581674311378210, 1.782214448453331 },
- { 0.191028848211526, -0.813898708757524, 1.516114203870644, 0.395202639476002 },
- { 0.335142750345279, -0.346586619596529, 0.545382042472336, -0.879268918923072 },
- { 1.417588151657198, 1.450841789070141, 0.219080104196171, 0.378724047481655 }
- }
- );
-
- const Math::Matrix expectedCofactors1(
- (float[4][4])
- {
- { -2.402679369186782, 2.282452509293019, 1.722732204057644, -0.746939701104385 },
- { -0.687677756877654, 1.168949180331164, -0.985354966837796, -1.334071111592705 },
- { -5.115621958424845, 4.229724770159009, 2.529000630782808, 1.481632618355891 },
- { 0.147480897398694, -2.140677680337111, -1.207189492265546, 0.151236920408051 }
- }
- );
-
- for (int r = 0; r < 4; ++r)
- {
- for (int c = 0; c < 4; ++c)
- {
- float ret = mat1.Cofactor(r, c);
- float exp = expectedCofactors1.m[4*c+r];
- EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
- }
- }
-
- const Math::Matrix mat2(
- (float[4][4])
- {
- { 0.9845099464982393, -0.9091233416532389, -0.6272243714245945, 0.4645001858944354 },
- { -0.1333308471483736, 0.9128181433725897, -1.0937461393836190, 0.3180936795928376 },
- { -0.0654324396846289, 0.1014641705415945, 1.5107709042683430, -0.0240560430414690 },
- { 0.0179638644093347, -1.0695585982782767, -0.1741250853101032, 1.0803106709464336 }
- }
- );
-
- const Math::Matrix expectedCofactors2(
- (float[4][4])
- {
- { 2.0861102207614466, 0.2989010779528912, 0.0746276150537432, 0.2732659822656097 },
- { 0.6850002886584565, 1.5513169659641379, -0.0503743176545917, 1.5163672441575642 },
- { 1.2385556680997216, 1.1827709562505695, 1.2282813085138962, 1.3483789679871401 },
- { -1.0710790241539783, -0.5589604503588883, 0.0100959837872308, 1.1897872684455839 }
- }
- );
-
-
- for (int r = 0; r < 4; ++r)
- {
- for (int c = 0; c < 4; ++c)
- {
- float ret = mat2.Cofactor(r, c);
- float exp = expectedCofactors2.m[4*c+r];
- EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
- }
- }
-}
-
-TEST(MatrixTest, DetTest)
-{
- const Math::Matrix mat1(
- (float[4][4])
- {
- { -0.95880162984708284, 0.24004047608997131, -0.78172309932665407, -0.11604124457222834 },
- { -0.36230592086261376, -0.75778166876017261, 0.33041059404631740, -1.06001391941094836 },
- { 0.00260215210936187, 1.27485610196385113, -0.26149859846418033, -0.59669701186364876 },
- { 0.36899429848485432, 3.01720896813933104, 2.10311476609438719, -1.68627076626448269 }
- }
- );
-
- const float expectedDet1 = 4.07415413729671;
-
- float ret1 = mat1.Det();
- EXPECT_TRUE(Math::IsEqual(ret1, expectedDet1, TEST_TOLERANCE));
-
- const Math::Matrix mat2(
- (float[4][4])
- {
- { -1.0860073221346871, 0.9150354098189495, -0.2723201933559999, 0.2922832160271507 },
- { -1.0248331304801788, -2.5081237461125205, -1.0277123574586633, -0.2254690663329798 },
- { -1.4227635282899367, -0.0403846809122684, 0.9216148477171653, 1.2517067488015878 },
- { -0.1160254467152022, 0.8270675274393656, 1.0327218739781614, -0.3674886870220400 }
- }
- );
-
- const float expectedDet2 = -6.35122307880942;
-
- float ret2 = mat2.Det();
- EXPECT_TRUE(Math::IsEqual(ret2, expectedDet2, TEST_TOLERANCE));
-}
-
-TEST(MatrixTest, InverseTest)
-{
- const Math::Matrix mat1(
- (float[4][4])
- {
- { -2.2829352811514658, -0.9103222363187888, 0.2792976509411680, -0.7984393573193174 },
- { 2.4823665798689589, -0.0599056759070980, 0.3832364352926366, -1.6404257204372739 },
- { -0.3841952272526398, -0.8377700696457873, -0.3416328338427138, 1.1746577275723329 },
- { 0.1746031241954947, -0.4952532117949962, 0.2155084379835037, -1.6586460437329220 }
- }
- );
-
- const Math::Matrix expectedInverse1(
- (float[4][4])
- {
- { -0.119472603171041, 0.331675963276297, 0.187516809009720, -0.137720814290806 },
- { -0.387591686166085, -0.487284946727583, -0.798527541290274, 0.102991635972060 },
- { 2.601905603425902, 2.606899016264679, -0.528006148839176, -4.204703326522837 },
- { 0.441220327151392, 0.519128136207318, 0.189567009205522, -1.194469716136194 }
- }
- );
-
- Math::Matrix inverse1 = mat1.Inverse();
-
- EXPECT_TRUE(Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE));
-
- const Math::Matrix mat2(
- (float[4][4])
- {
- { -0.05464332404298505, -0.64357755258235749, -0.13017671677619302, -0.56742332785888006 },
- { 0.29048383600458222, -0.91517047043724875, 0.84517524415561684, 0.51628195547960565 },
- { 0.00946488004480186, -0.89077382212689293, 0.73565573766341397, -0.15932513521840930 },
- { -1.01244718912499132, -0.27840911963972276, -0.39189681211309862, 1.18315064340192055 }
- }
- );
-
- const Math::Matrix expectedInverse2(
- (float[4][4])
- {
- { 0.771302711132012, 1.587542278361995, -2.003075114445104, -0.592574156227379 },
- { -1.208929259769431, -0.786598967848473, 0.607335305808052, -0.154759693303324 },
- { -1.500037668208218, -0.774300278997914, 1.917800427261255, -0.123268572651291 },
- { -0.121314770937944, 0.916925149209746, -0.935924950785014, 0.260875394250671 }
- }
- );
-
- Math::Matrix inverse2 = mat2.Inverse();
-
- EXPECT_TRUE(Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE));
-}
-
-TEST(MatrixTest, MultiplyTest)
-{
- const Math::Matrix mat1A(
- (float[4][4])
- {
- { 0.6561727049162027, -1.4180263627131411, -0.8271026046117423, 2.3919331748512578 },
- { -0.6035665535146352, 0.0150827348790615, -0.7090794192822540, 0.9057604704594814 },
- { -0.9871045001223655, -0.4980646811455065, 0.3806177002298990, 0.1520583649240934 },
- { -0.2721911170792712, 0.7627928194552067, -0.1504091336784158, 0.9747545351840121 }
- }
- );
-
- const Math::Matrix mat1B(
- (float[4][4])
- {
- { -0.2643735892448818, -0.7542994492819621, 0.6082322350568750, 0.0581733424861419 },
- { 1.0293246070431237, 0.1979285388251341, -0.2932031385332818, 0.8838407179018929 },
- { 0.3448687251553114, 0.5031654871245456, 0.7554693012922442, -0.4845315903845708 },
- { -1.8662838497278593, -0.7843850624747805, 0.1389026096476257, -1.3686415408300689 }
- }
- );
-
- const Math::Matrix expectedMultiply1(
- (float[4][4])
- {
- { -6.382352236417988, -3.067984733682130, 0.522270304251466, -4.088079444498280 },
- { -1.759853366848825, -0.608994052024491, -0.781406179437379, -0.917870775786188 },
- { -0.404226802169062, 0.718232546720114, -0.145688356880835, -0.890167707987175 },
- { -1.013918490922430, -0.483971504099758, -0.367442194643757, -0.602858486133615 }
- }
- );
-
- Math::Matrix multiply1 = Math::MultiplyMatrices(mat1A, mat1B);
- EXPECT_TRUE(Math::MatricesEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
-
- const Math::Matrix mat2A(
- (float[4][4])
- {
- { 0.8697203025776754, 2.1259475710644935, 1.7856691009707812, -2.1563963348328126 },
- { 1.5888074489288735, -0.0794849733953615, 0.7307782768677457, 0.7943129159612630 },
- { 0.2859761537233830, -0.6231231890384962, -0.0496743172880377, -0.8137857518646087 },
- { 1.2670547229512983, -0.5305171374831831, -0.4987412674062375, -1.1257327113869595 }
- }
- );
-
- const Math::Matrix mat2B(
- (float[4][4])
- {
- { 1.1321105701165317, 0.1759563504574463, -2.0675778912000418, 1.4840339814245538 },
- { -1.5117280888829916, -0.0933013188828093, -0.2079262944351640, 0.9575727579539316 },
- { 0.3615378398970173, 1.2465163589027248, 1.1326150997082589, 0.9921208694352303 },
- { -0.7357104529373861, -0.4774022005969588, -0.2118739096676499, 1.1427567093270703 }
- }
- );
-
- const Math::Matrix expectedMultiply2(
- (float[4][4])
- {
- { 0.00283516267056338, 3.21001319965989307, 0.23910503934370686, 2.63380716363006107 },
- { 1.59868505822469742, 0.81869715594617765, -2.60905981088293570, 3.91445839239110294 },
- { 1.84650099286297942, 0.43504079532852930, -0.34555619012424243, -1.15152951542451487 },
- { 2.88434318563174585, 0.18818239851585700, -2.83579436909308980, -0.40890672198610400 }
- }
- );
-
- Math::Matrix multiply2 = Math::MultiplyMatrices(mat2A, mat2B);
- EXPECT_TRUE(Math::MatricesEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
-}
-
-TEST(MatrixTest, MultiplyVectorTest)
-{
- const Math::Matrix mat1(
- (float[4][4])
- {
- { 0.188562846910008, -0.015148651460679, 0.394512304108827, 0.906910631257135 },
- { -0.297506779519667, 0.940119328178913, 0.970957796752517, 0.310559318965526 },
- { -0.819770525290873, -2.316574438778879, 0.155756069319732, -0.855661405742964 },
- { 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000 }
- }
- );
-
- const Math::Vector vec1(-0.824708565156661, -1.598287748103842, -0.422498044734181);
-
- const Math::Vector expectedMultiply1(0.608932463260470, -1.356893266403749, 3.457156276255142);
-
- Math::Vector multiply1 = Math::MatrixVectorMultiply(mat1, vec1, false);
- EXPECT_TRUE(Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
-
- const Math::Matrix mat2(
- (float[4][4])
- {
- { -0.63287117038834284, 0.55148060401816856, -0.02042395559467368, -1.50367083897656850 },
- { 0.69629042156335297, 0.12982747869796774, -1.16250029235919405, 1.19084447253756909 },
- { 0.44164132914357224, -0.15169304045662041, -0.00880583574621390, -0.55817802940035310 },
- { 0.95680476533530789, -1.51912346889253125, -0.74209769406615944, -0.20938988867903682 }
- }
- );
-
- const Math::Vector vec2(0.330987381051962, 1.494375516393466, 1.483422335561857);
-
- const Math::Vector expectedMultiply2(0.2816820577317669, 0.0334468811767428, 0.1996974284970455);
-
- Math::Vector multiply2 = Math::MatrixVectorMultiply(mat2, vec2, true);
- EXPECT_TRUE(Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
-}
-
-int main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
-
diff --git a/src/math/test/vector_test.cpp b/src/math/test/vector_test.cpp
deleted file mode 100644
index ead2fd2..0000000
--- a/src/math/test/vector_test.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// * This file is part of the COLOBOT source code
-// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.
-
-// math/test/vector_test.cpp
-
-/*
- Unit tests for Vector struct
-
- Test data was randomly generated and the expected results
- calculated using GNU Octave.
- */
-
-#include "../func.h"
-#include "../vector.h"
-
-#include "gtest/gtest.h"
-
-
-const float TEST_TOLERANCE = 1e-6;
-
-
-TEST(VectorTest, LengthTest)
-{
- Math::Vector vec(-1.288447945923275, 0.681452565308134, -0.633761098985957);
- const float expectedLength = 1.58938001708428;
-
- EXPECT_TRUE(Math::IsEqual(vec.Length(), expectedLength, TEST_TOLERANCE));
-}
-
-TEST(VectorTest, NormalizeTest)
-{
- Math::Vector vec(1.848877241804398, -0.157262961268577, -1.963031403332377);
- const Math::Vector expectedNormalized(0.6844609421393856, -0.0582193085618106, -0.7267212194481797);
-
- vec.Normalize();
-
- EXPECT_TRUE(Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE));
-}
-
-TEST(VectorTest, DotTest)
-{
- Math::Vector vecA(0.8202190530968309, 0.0130926060162780, 0.2411914183883510);
- Math::Vector vecB(-0.0524083951404069, 1.5564932716738220, -0.8971342631500536);
-
- float expectedDot = -0.238988896477326;
-
- EXPECT_TRUE(Math::IsEqual(Math::DotProduct(vecA, vecB), expectedDot, TEST_TOLERANCE));
-}
-
-TEST(VectorTest, CrossTest)
-{
- Math::Vector vecA(1.37380499798567, 1.18054518384682, 1.95166361293121);
- Math::Vector vecB(0.891657855926886, 0.447591335394532, -0.901604070087823);
-
- Math::Vector expectedCross(-1.937932065431669, 2.978844370287636, -0.437739173833581);
- Math::Vector expectedReverseCross = -expectedCross;
-
- EXPECT_TRUE(Math::VectorsEqual(vecA.CrossMultiply(vecB), expectedCross, TEST_TOLERANCE));
-
- EXPECT_TRUE(Math::VectorsEqual(vecB.CrossMultiply(vecA), expectedReverseCross, TEST_TOLERANCE));
-}
-
-int main(int argc, char* argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 4003193..3d88012 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -18,8 +18,13 @@
#include "object/auto/auto.h"
+#include "app/app.h"
+
+#include "common/event.h"
#include "common/iman.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -30,26 +35,24 @@
// Object's constructor.
-CAuto::CAuto(CInstanceManager* iMan, CObject* object)
+CAuto::CAuto(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_AUTO, this, 100);
+ m_iMan = CInstanceManager::GetInstancePointer();
m_object = object;
- m_event = static_cast< CEventQueue* >(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_lightMan = static_cast< Gfx::CLightManager* >(m_iMan->SearchInstance(CLASS_LIGHT));
- m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
- m_cloud = static_cast< Gfx::CCloud* >(m_iMan->SearchInstance(CLASS_CLOUD));
- m_planet = static_cast< Gfx::CPlanet* >(m_iMan->SearchInstance(CLASS_PLANET));
- m_lightning = static_cast< Gfx::CLightning* >(m_iMan->SearchInstance(CLASS_BLITZ));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_interface = static_cast< Ui::CInterface* >(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_displayText = static_cast< Ui::CDisplayText* >(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_eventQueue = CApplication::GetInstancePointer()->GetEventQueue();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_particle = m_engine->GetParticle();
+ m_terrain = m_engine->GetTerrain();
+ m_water = m_engine->GetWater();
+ m_cloud = m_engine->GetCloud();
+ m_planet = m_engine->GetPlanet();
+ m_lightning = m_engine->GetLightning();
+ m_camera = m_main->GetCamera();
+ m_interface = m_main->GetInterface();
+ m_displayText = m_main->GetDisplayText();
m_type = m_object->GetType();
m_time = 0.0f;
@@ -65,7 +68,22 @@ CAuto::CAuto(CInstanceManager* iMan, CObject* object)
CAuto::~CAuto()
{
- m_iMan->DeleteInstance(CLASS_AUTO, this);
+ m_iMan = nullptr;
+
+ m_object = nullptr;
+ m_engine = nullptr;
+ m_main = nullptr;
+ m_eventQueue = nullptr;
+ m_sound = nullptr;
+ m_particle = nullptr;
+ m_terrain = nullptr;
+ m_water = nullptr;
+ m_cloud = nullptr;
+ m_planet = nullptr;
+ m_lightning = nullptr;
+ m_camera = nullptr;
+ m_interface = nullptr;
+ m_displayText = nullptr;
}
diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h
index 2194924..53ccdf9 100644
--- a/src/object/auto/auto.h
+++ b/src/object/auto/auto.h
@@ -50,7 +50,7 @@ class CLightning;
class CAuto
{
public:
- CAuto(CInstanceManager* iMan, CObject* object);
+ CAuto(CObject* object);
virtual ~CAuto();
virtual void DeleteObject(bool bAll=false);
@@ -88,11 +88,10 @@ protected:
void UpdateInterface(float rTime);
protected:
- CInstanceManager* m_iMan;
- CEventQueue* m_event;
+ CInstanceManager* m_iMan; // TODO: to be removed
+ CEventQueue* m_eventQueue;
Gfx::CEngine* m_engine;
Gfx::CParticle* m_particle;
- Gfx::CLightManager* m_lightMan;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
Gfx::CCloud* m_cloud;
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index 8370517..cb7f04c 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -20,13 +20,18 @@
#include "object/auto/autobase.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/cloud.h"
#include "graphics/engine/planet.h"
#include "graphics/engine/lightning.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "physics/physics.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -47,8 +52,7 @@ const float BASE_TRANSIT_TIME = 15.0f; // transit duration
// Object's constructor.
-CAutoBase::CAutoBase(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoBase::CAutoBase(CObject* object) : CAuto(object)
{
m_fogStart = m_engine->GetFogStart();
m_deepView = m_engine->GetDeepView();
@@ -329,7 +333,7 @@ begin:
m_main->DeselectAll();
newEvent.type = EVENT_UPDINTERFACE;
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
@@ -843,7 +847,7 @@ begin:
{
m_soundChannel = -1;
newEvent.type = EVENT_WIN;
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
m_phase = ABP_WAIT;
m_progress = 0.0f;
@@ -1176,7 +1180,7 @@ bool CAutoBase::Abort()
m_phase == ABP_TAKEOFF ) // off?
{
newEvent.type = EVENT_WIN;
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
}
}
diff --git a/src/object/auto/autobase.h b/src/object/auto/autobase.h
index 439d414..422f340 100644
--- a/src/object/auto/autobase.h
+++ b/src/object/auto/autobase.h
@@ -65,7 +65,7 @@ enum AutoBasePhase
class CAutoBase : public CAuto
{
public:
- CAutoBase(CInstanceManager* iMan, CObject* object);
+ CAutoBase(CObject* object);
~CAutoBase();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index a550697..7281ed7 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -19,8 +19,11 @@
#include "object/auto/autoconvert.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -31,8 +34,7 @@
// Object's constructor.
-CAutoConvert::CAutoConvert(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoConvert::CAutoConvert(CObject* object) : CAuto(object)
{
Init();
m_phase = ACP_STOP;
@@ -509,7 +511,7 @@ void CAutoConvert::CreateMetal()
pos = m_object->GetPosition(0);
angle = m_object->GetAngleY(0);
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, angle, OBJECT_METAL) )
{
delete fret;
diff --git a/src/object/auto/autoconvert.h b/src/object/auto/autoconvert.h
index b21690f..56591f7 100644
--- a/src/object/auto/autoconvert.h
+++ b/src/object/auto/autoconvert.h
@@ -38,7 +38,7 @@ enum AutoConvertPhase
class CAutoConvert : public CAuto
{
public:
- CAutoConvert(CInstanceManager* iMan, CObject* object);
+ CAutoConvert(CObject* object);
~CAutoConvert();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp
index 3578c0d..260edcb 100644
--- a/src/object/auto/autoderrick.cpp
+++ b/src/object/auto/autoderrick.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autoderrick.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -38,8 +42,7 @@ const float DERRICK_DELAYu = 30.0f; // same, but for uranium
// Object's constructor.
-CAutoDerrick::CAutoDerrick(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoDerrick::CAutoDerrick(CObject* object) : CAuto(object)
{
Init();
m_phase = ADP_WAIT; // paused until the first Init ()
@@ -528,7 +531,7 @@ void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type,
{
CObject* fret;
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, angle, type) )
{
delete fret;
diff --git a/src/object/auto/autoderrick.h b/src/object/auto/autoderrick.h
index b52f93b..81ed8b4 100644
--- a/src/object/auto/autoderrick.h
+++ b/src/object/auto/autoderrick.h
@@ -38,7 +38,7 @@ enum AutoDerrickPhase
class CAutoDerrick : public CAuto
{
public:
- CAutoDerrick(CInstanceManager* iMan, CObject* object);
+ CAutoDerrick(CObject* object);
~CAutoDerrick();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index ecf7c94..b62a45a 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.cpp
@@ -19,7 +19,9 @@
#include "object/auto/autodestroyer.h"
#include "common/iman.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -29,8 +31,7 @@
// Object's constructor.
-CAutoDestroyer::CAutoDestroyer(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoDestroyer::CAutoDestroyer(CObject* object) : CAuto(object)
{
Init();
m_phase = ADEP_WAIT; // paused until the first Init ()
@@ -111,18 +112,39 @@ bool CAutoDestroyer::EventProcess(const Event &event)
if ( SearchVehicle() )
{
- m_phase = ADEP_WAIT; // still waiting ...
- m_progress = 0.0f;
- m_speed = 1.0f/0.5f;
+ 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
{
- 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 ( 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;
+ }
}
}
}
@@ -135,7 +157,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
scrap = SearchPlastic();
if ( scrap != nullptr )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, scrap);
}
m_bExplo = true;
@@ -243,8 +265,55 @@ CObject* CAutoDestroyer::SearchPlastic()
if ( pObj == nullptr ) break;
type = pObj->GetType();
- if ( type != OBJECT_SCRAP4 &&
- type != OBJECT_SCRAP5 ) continue;
+ //if ( type != OBJECT_SCRAP4 &&
+ // type != OBJECT_SCRAP5 ) continue;
+ if ( type != OBJECT_FRET &&
+ type != OBJECT_STONE &&
+ type != OBJECT_URANIUM &&
+ type != OBJECT_METAL &&
+ type != OBJECT_POWER &&
+ type != OBJECT_ATOMIC &&
+ type != OBJECT_TNT &&
+ type != OBJECT_SCRAP1 &&
+ type != OBJECT_SCRAP2 &&
+ type != OBJECT_SCRAP3 &&
+ type != OBJECT_SCRAP4 &&
+ type != OBJECT_SCRAP5 &&
+ // Robots:
+ 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;
+
oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, sPos);
diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h
index 50858d3..26981c3 100644
--- a/src/object/auto/autodestroyer.h
+++ b/src/object/auto/autodestroyer.h
@@ -37,7 +37,7 @@ enum AutoDestroyerPhase
class CAutoDestroyer : public CAuto
{
public:
- CAutoDestroyer(CInstanceManager* iMan, CObject* object);
+ CAutoDestroyer(CObject* object);
~CAutoDestroyer();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
index 5b90ef9..e510ca6 100644
--- a/src/object/auto/autoegg.cpp
+++ b/src/object/auto/autoegg.cpp
@@ -18,8 +18,10 @@
#include "object/auto/autoegg.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
+#include "math/geometry.h"
+
#include "script/cmdtoken.h"
#include <stdio.h>
@@ -28,8 +30,7 @@
// Object's constructor.
-CAutoEgg::CAutoEgg(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoEgg::CAutoEgg(CObject* object) : CAuto(object)
{
m_type = OBJECT_NULL;
m_value = 0.0f;
@@ -174,7 +175,7 @@ bool CAutoEgg::EventProcess(const Event &event)
m_progress += event.rTime*m_speed;
if ( m_progress < 1.0f ) return true;
- alien = new CObject(m_iMan);
+ alien = new CObject();
if ( !alien->CreateInsect(m_object->GetPosition(0), m_object->GetAngleY(0), m_type) )
{
delete alien;
@@ -236,7 +237,7 @@ Error CAutoEgg::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_EGG, m_object); // exploding egg
alien->SetZoom(0, 1.0f); // this is a big boy now
diff --git a/src/object/auto/autoegg.h b/src/object/auto/autoegg.h
index fec07a6..00725db 100644
--- a/src/object/auto/autoegg.h
+++ b/src/object/auto/autoegg.h
@@ -37,7 +37,7 @@ enum AutoEggPhase
class CAutoEgg : public CAuto
{
public:
- CAutoEgg(CInstanceManager* iMan, CObject* object);
+ CAutoEgg(CObject* object);
~CAutoEgg();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index c63dede..a0b4d85 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autoenergy.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -39,8 +43,7 @@ const float ENERGY_DELAY = 12.0f; // processing time
// Object's constructor.
-CAutoEnergy::CAutoEnergy(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoEnergy::CAutoEnergy(CObject* object) : CAuto(object)
{
m_partiSphere = -1;
Init();
@@ -461,7 +464,7 @@ void CAutoEnergy::CreatePower()
pos = m_object->GetPosition(0);
angle = m_object->GetAngleY(0);
- power = new CObject(m_iMan);
+ power = new CObject();
if ( !power->CreateResource(pos, angle, OBJECT_POWER) )
{
delete power;
diff --git a/src/object/auto/autoenergy.h b/src/object/auto/autoenergy.h
index 53d47b6..d3ed5fe 100644
--- a/src/object/auto/autoenergy.h
+++ b/src/object/auto/autoenergy.h
@@ -38,7 +38,7 @@ enum AutoEnergyPhase
class CAutoEnergy : public CAuto
{
public:
- CAutoEnergy(CInstanceManager* iMan, CObject* object);
+ CAutoEnergy(CObject* object);
~CAutoEnergy();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
index 0789443..82877c6 100644
--- a/src/object/auto/autofactory.cpp
+++ b/src/object/auto/autofactory.cpp
@@ -20,10 +20,15 @@
#include "common/global.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -35,8 +40,7 @@
// Object's constructor.
-CAutoFactory::CAutoFactory(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoFactory::CAutoFactory(CObject* object) : CAuto(object)
{
Init();
m_type = OBJECT_MOBILEws;
@@ -632,7 +636,7 @@ bool CAutoFactory::CreateVehicle()
}
pos = Transform(*mat, pos);
- vehicle = new CObject(m_iMan);
+ vehicle = new CObject();
if ( !vehicle->CreateVehicle(pos, angle, m_type, -1.0f, false, false) )
{
delete vehicle;
diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h
index f62080d..7c5013d 100644
--- a/src/object/auto/autofactory.h
+++ b/src/object/auto/autofactory.h
@@ -40,7 +40,7 @@ enum AutoFactoryPhase
class CAutoFactory : public CAuto
{
public:
- CAutoFactory(CInstanceManager* iMan, CObject* object);
+ CAutoFactory(CObject* object);
~CAutoFactory();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoflag.cpp b/src/object/auto/autoflag.cpp
index c2dec5c..936546d 100644
--- a/src/object/auto/autoflag.cpp
+++ b/src/object/auto/autoflag.cpp
@@ -37,8 +37,7 @@ static float g_flag3 = 2.00f;
// Object's constructor.
-CAutoFlag::CAutoFlag(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoFlag::CAutoFlag(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autoflag.h b/src/object/auto/autoflag.h
index 3c6cf99..c3fd35a 100644
--- a/src/object/auto/autoflag.h
+++ b/src/object/auto/autoflag.h
@@ -27,7 +27,7 @@
class CAutoFlag : public CAuto
{
public:
- CAutoFlag(CInstanceManager* iMan, CObject* object);
+ CAutoFlag(CObject* object);
~CAutoFlag();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autohuston.cpp b/src/object/auto/autohuston.cpp
index 1b6778d..80f9185 100644
--- a/src/object/auto/autohuston.cpp
+++ b/src/object/auto/autohuston.cpp
@@ -26,8 +26,7 @@
// Object's constructor.
-CAutoHuston::CAutoHuston(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoHuston::CAutoHuston(CObject* object) : CAuto(object)
{
Math::Vector pos;
int i;
diff --git a/src/object/auto/autohuston.h b/src/object/auto/autohuston.h
index 27b016b..f99876a 100644
--- a/src/object/auto/autohuston.h
+++ b/src/object/auto/autohuston.h
@@ -42,7 +42,7 @@ const int HUSTONMAXLENS = 20;
class CAutoHuston : public CAuto
{
public:
- CAutoHuston(CInstanceManager* iMan, CObject* object);
+ CAutoHuston(CObject* object);
~CAutoHuston();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp
index 1245034..56c21d2 100644
--- a/src/object/auto/autoinfo.cpp
+++ b/src/object/auto/autoinfo.cpp
@@ -30,8 +30,7 @@
// Object's constructor.
-CAutoInfo::CAutoInfo(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoInfo::CAutoInfo(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autoinfo.h b/src/object/auto/autoinfo.h
index 30481bb..41b74d3 100644
--- a/src/object/auto/autoinfo.h
+++ b/src/object/auto/autoinfo.h
@@ -37,7 +37,7 @@ enum AutoInfoPhase
class CAutoInfo : public CAuto
{
public:
- CAutoInfo(CInstanceManager* iMan, CObject* object);
+ CAutoInfo(CObject* object);
~CAutoInfo();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autojostle.cpp b/src/object/auto/autojostle.cpp
index 788b562..11952c2 100644
--- a/src/object/auto/autojostle.cpp
+++ b/src/object/auto/autojostle.cpp
@@ -23,8 +23,7 @@
// Object's constructor.
-CAutoJostle::CAutoJostle(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoJostle::CAutoJostle(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autojostle.h b/src/object/auto/autojostle.h
index c156893..7b700ad 100644
--- a/src/object/auto/autojostle.h
+++ b/src/object/auto/autojostle.h
@@ -27,7 +27,7 @@
class CAutoJostle : public CAuto
{
public:
- CAutoJostle(CInstanceManager* iMan, CObject* object);
+ CAutoJostle(CObject* object);
~CAutoJostle();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autokid.cpp b/src/object/auto/autokid.cpp
index 64cd39a..a9f86b0 100644
--- a/src/object/auto/autokid.cpp
+++ b/src/object/auto/autokid.cpp
@@ -26,8 +26,7 @@
// Object's constructor.
-CAutoKid::CAutoKid(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoKid::CAutoKid(CObject* object) : CAuto(object)
{
m_soundChannel = -1;
Init();
diff --git a/src/object/auto/autokid.h b/src/object/auto/autokid.h
index 3e2fba7..19836a7 100644
--- a/src/object/auto/autokid.h
+++ b/src/object/auto/autokid.h
@@ -27,7 +27,7 @@
class CAutoKid : public CAuto
{
public:
- CAutoKid(CInstanceManager* iMan, CObject* object);
+ CAutoKid(CObject* object);
~CAutoKid();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 70bcc5e..6984fd6 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -20,9 +20,13 @@
#include "common/global.h"
#include "common/misc.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -38,8 +42,7 @@ const float LABO_DELAY = 20.0f; // duration of the analysis
// Object's constructor.
-CAutoLabo::CAutoLabo(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+ CAutoLabo::CAutoLabo(CObject* object) : CAuto(object)
{
int i;
@@ -543,8 +546,8 @@ void CAutoLabo::SetResearch(EventType event)
m_main->WriteFreeParam();
Event newEvent(EVENT_UPDINTERFACE);
-// m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
- m_event->AddEvent(newEvent);
+// m_eventQueue->MakeEvent(newEvent, EVENT_UPDINTERFACE);
+ m_eventQueue->AddEvent(newEvent);
UpdateInterface();
}
diff --git a/src/object/auto/autolabo.h b/src/object/auto/autolabo.h
index 8225462..b61e8e3 100644
--- a/src/object/auto/autolabo.h
+++ b/src/object/auto/autolabo.h
@@ -41,7 +41,7 @@ enum AutoLaboPhase
class CAutoLabo : public CAuto
{
public:
- CAutoLabo(CInstanceManager* iMan, CObject* object);
+ CAutoLabo(CObject* object);
~CAutoLabo();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp
index cb94590..e97e2a1 100644
--- a/src/object/auto/automush.cpp
+++ b/src/object/auto/automush.cpp
@@ -19,6 +19,7 @@
#include "object/auto/automush.h"
#include "common/iman.h"
+
#include "script/cmdtoken.h"
@@ -28,8 +29,7 @@
// Object's constructor.
-CAutoMush::CAutoMush(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+ CAutoMush::CAutoMush(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/automush.h b/src/object/auto/automush.h
index 245393a..1697c5a 100644
--- a/src/object/auto/automush.h
+++ b/src/object/auto/automush.h
@@ -38,7 +38,7 @@ enum AutoMushPhase
class CAutoMush : public CAuto
{
public:
- CAutoMush(CInstanceManager* iMan, CObject* object);
+ CAutoMush(CObject* object);
~CAutoMush();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp
index 99927bd..1cf13d6 100644
--- a/src/object/auto/autonest.cpp
+++ b/src/object/auto/autonest.cpp
@@ -19,7 +19,9 @@
#include "object/auto/autonest.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
+
#include "script/cmdtoken.h"
#include <stdio.h>
@@ -28,8 +30,7 @@
// Object's constructor.
-CAutoNest::CAutoNest(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+ CAutoNest::CAutoNest(CObject* object) : CAuto(object)
{
Init();
}
@@ -178,7 +179,7 @@ void CAutoNest::CreateFret(Math::Vector pos, float angle, ObjectType type)
{
CObject* fret;
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, angle, type) )
{
delete fret;
diff --git a/src/object/auto/autonest.h b/src/object/auto/autonest.h
index 1009457..4d734a8 100644
--- a/src/object/auto/autonest.h
+++ b/src/object/auto/autonest.h
@@ -35,7 +35,7 @@ enum AutoNestPhase
class CAutoNest : public CAuto
{
public:
- CAutoNest(CInstanceManager* iMan, CObject* object);
+ CAutoNest(CObject* object);
~CAutoNest();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index 375acf0..75bfb45 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.cpp
@@ -19,8 +19,11 @@
#include "object/auto/autonuclear.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
@@ -36,8 +39,7 @@ const float NUCLEAR_DELAY = 30.0f; // duration of the generation
// Object's constructor.
-CAutoNuclear::CAutoNuclear(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoNuclear::CAutoNuclear(CObject* object) : CAuto(object)
{
m_channelSound = -1;
Init();
@@ -396,7 +398,7 @@ void CAutoNuclear::CreatePower()
pos = m_object->GetPosition(0);
angle = m_object->GetAngleY(0);
- power = new CObject(m_iMan);
+ power = new CObject();
if ( !power->CreateResource(pos, angle, OBJECT_ATOMIC) )
{
delete power;
diff --git a/src/object/auto/autonuclear.h b/src/object/auto/autonuclear.h
index 06a99af..5b01bba 100644
--- a/src/object/auto/autonuclear.h
+++ b/src/object/auto/autonuclear.h
@@ -38,7 +38,7 @@ enum AutoNuclearPhase
class CAutoNuclear : public CAuto
{
public:
- CAutoNuclear(CInstanceManager* iMan, CObject* object);
+ CAutoNuclear(CObject* object);
~CAutoNuclear();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp
index a3082f5..ad6517b 100644
--- a/src/object/auto/autopara.cpp
+++ b/src/object/auto/autopara.cpp
@@ -20,8 +20,11 @@
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -32,8 +35,7 @@
// Object's constructor.
-CAutoPara::CAutoPara(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoPara::CAutoPara(CObject* object) : CAuto(object)
{
m_channelSound = -1;
Init();
diff --git a/src/object/auto/autopara.h b/src/object/auto/autopara.h
index 10a33a8..1f0b805 100644
--- a/src/object/auto/autopara.h
+++ b/src/object/auto/autopara.h
@@ -36,7 +36,7 @@ enum AutoParaPhase
class CAutoPara : public CAuto
{
public:
- CAutoPara(CInstanceManager* iMan, CObject* object);
+ CAutoPara(CObject* object);
~CAutoPara();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoportico.cpp b/src/object/auto/autoportico.cpp
index 3b3bf84..1646874 100644
--- a/src/object/auto/autoportico.cpp
+++ b/src/object/auto/autoportico.cpp
@@ -55,8 +55,7 @@ float Progress(float a, float b, float progress)
// Object's constructor.
-CAutoPortico::CAutoPortico(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoPortico::CAutoPortico(CObject* object) : CAuto(object)
{
Init();
m_phase = APOP_WAIT;
@@ -398,7 +397,6 @@ Error CAutoPortico::GetError()
void CAutoPortico::UpdateTrackMapping(float left, float right)
{
Gfx::Material mat;
- float limit[2];
int rank;
memset( &mat, 0, sizeof(Gfx::Material));
@@ -411,15 +409,12 @@ void CAutoPortico::UpdateTrackMapping(float left, float right)
rank = m_object->GetObjectRank(0);
- limit[0] = 0.0f;
- limit[1] = 1000000.0f;
-
m_engine->TrackTextureMapping(rank, mat, Gfx::ENG_RSTATE_PART1, "lemt.png", "",
- limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
+ Gfx::LOD_Constant, Gfx::ENG_TEX_MAPPING_X,
right, 8.0f, 8.0f, 192.0f, 256.0f);
m_engine->TrackTextureMapping(rank, mat, Gfx::ENG_RSTATE_PART2, "lemt.png", "",
- limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
+ Gfx::LOD_Constant, Gfx::ENG_TEX_MAPPING_X,
left, 8.0f, 8.0f, 192.0f, 256.0f);
}
diff --git a/src/object/auto/autoportico.h b/src/object/auto/autoportico.h
index c211d37..0aa580f 100644
--- a/src/object/auto/autoportico.h
+++ b/src/object/auto/autoportico.h
@@ -40,7 +40,7 @@ enum AutoPorticoPhase
class CAutoPortico : public CAuto
{
public:
- CAutoPortico(CInstanceManager* iMan, CObject* object);
+ CAutoPortico(CObject* object);
~CAutoPortico();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp
index 4214d17..1a10aa7 100644
--- a/src/object/auto/autoradar.cpp
+++ b/src/object/auto/autoradar.cpp
@@ -19,7 +19,9 @@
#include "object/auto/autoradar.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/gauge.h"
@@ -29,8 +31,7 @@
// Object's constructor.
-CAutoRadar::CAutoRadar(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoRadar::CAutoRadar(CObject* object) : CAuto(object)
{
Init();
m_phase = ARAP_WAIT;
diff --git a/src/object/auto/autoradar.h b/src/object/auto/autoradar.h
index e2c9df5..86833f9 100644
--- a/src/object/auto/autoradar.h
+++ b/src/object/auto/autoradar.h
@@ -37,7 +37,7 @@ enum AutoRadarPhase
class CAutoRadar : public CAuto
{
public:
- CAutoRadar(CInstanceManager* iMan, CObject* object);
+ CAutoRadar(CObject* object);
~CAutoRadar();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
index cf4f33e..95b6cc8 100644
--- a/src/object/auto/autorepair.cpp
+++ b/src/object/auto/autorepair.cpp
@@ -19,8 +19,11 @@
#include "object/auto/autorepair.h"
#include "common/iman.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -30,8 +33,7 @@
// Object's constructor.
-CAutoRepair::CAutoRepair(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoRepair::CAutoRepair(CObject* object) : CAuto(object)
{
Init();
m_phase = ARP_WAIT; // paused until the first Init ()
diff --git a/src/object/auto/autorepair.h b/src/object/auto/autorepair.h
index e8bb0b1..31a3c65 100644
--- a/src/object/auto/autorepair.h
+++ b/src/object/auto/autorepair.h
@@ -38,7 +38,7 @@ enum AutoRepairPhase
class CAutoRepair : public CAuto
{
public:
- CAutoRepair(CInstanceManager* iMan, CObject* object);
+ CAutoRepair(CObject* object);
~CAutoRepair();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index 9f423ec..3c32307 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autoresearch.h"
#include "common/global.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -37,8 +41,7 @@ const float SEARCH_TIME = 30.0f; // duration of a research
// Object's constructor.
-CAutoResearch::CAutoResearch(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoResearch::CAutoResearch(CObject* object) : CAuto(object)
{
int i;
@@ -488,7 +491,7 @@ void CAutoResearch::SetResearch(EventType event)
m_main->WriteFreeParam();
Event newEvent(EVENT_UPDINTERFACE);
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(newEvent);
UpdateInterface();
}
diff --git a/src/object/auto/autoresearch.h b/src/object/auto/autoresearch.h
index a838e64..6c804ef 100644
--- a/src/object/auto/autoresearch.h
+++ b/src/object/auto/autoresearch.h
@@ -35,7 +35,7 @@ enum AutoResearchPhase
class CAutoResearch : public CAuto
{
public:
- CAutoResearch(CInstanceManager* iMan, CObject* object);
+ CAutoResearch(CObject* object);
~CAutoResearch();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autoroot.cpp b/src/object/auto/autoroot.cpp
index 196ed5d..a390e90 100644
--- a/src/object/auto/autoroot.cpp
+++ b/src/object/auto/autoroot.cpp
@@ -19,6 +19,7 @@
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
#include <stdio.h>
@@ -26,8 +27,7 @@
// Object's constructor.
-CAutoRoot::CAutoRoot(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoRoot::CAutoRoot(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autoroot.h b/src/object/auto/autoroot.h
index d80abe8..3eb906c 100644
--- a/src/object/auto/autoroot.h
+++ b/src/object/auto/autoroot.h
@@ -27,7 +27,7 @@
class CAutoRoot : public CAuto
{
public:
- CAutoRoot(CInstanceManager* iMan, CObject* object);
+ CAutoRoot(CObject* object);
~CAutoRoot();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index e89acea..fc83400 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autosafe.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/window.h"
@@ -34,8 +38,7 @@ const float OPEN_DELAY = 8.0f; // duration of opening
// Object's constructor.
-CAutoSafe::CAutoSafe(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoSafe::CAutoSafe(CObject* object) : CAuto(object)
{
int i;
diff --git a/src/object/auto/autosafe.h b/src/object/auto/autosafe.h
index 3c0bcce..b575b4e 100644
--- a/src/object/auto/autosafe.h
+++ b/src/object/auto/autosafe.h
@@ -36,7 +36,7 @@ enum AutoSafePhase
class CAutoSafe : public CAuto
{
public:
- CAutoSafe(CInstanceManager* iMan, CObject* object);
+ CAutoSafe(CObject* object);
~CAutoSafe();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp
index e99ae4b..a2f5b6b 100644
--- a/src/object/auto/autostation.cpp
+++ b/src/object/auto/autostation.cpp
@@ -19,9 +19,12 @@
#include "object/auto/autostation.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
+
#include "math/geometry.h"
+
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
@@ -31,8 +34,7 @@
// Object's constructor.
-CAutoStation::CAutoStation(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoStation::CAutoStation(CObject* object) : CAuto(object)
{
Init();
}
diff --git a/src/object/auto/autostation.h b/src/object/auto/autostation.h
index cb8be2b..d8a37b4 100644
--- a/src/object/auto/autostation.h
+++ b/src/object/auto/autostation.h
@@ -27,7 +27,7 @@
class CAutoStation : public CAuto
{
public:
- CAutoStation(CInstanceManager* iMan, CObject* object);
+ CAutoStation(CObject* object);
~CAutoStation();
void DeleteObject(bool bAll=false);
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 84dcd85..e3b06cf 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -19,9 +19,13 @@
#include "object/auto/autotower.h"
#include "common/iman.h"
+
#include "math/geometry.h"
+
#include "physics/physics.h"
+
#include "script/cmdtoken.h"
+
#include "ui/interface.h"
#include "ui/displaytext.h"
#include "ui/window.h"
@@ -37,8 +41,7 @@ const float ENERGY_FIRE = 0.125f; // energy consumed by fire
// Object's constructor.
-CAutoTower::CAutoTower(CInstanceManager* iMan, CObject* object)
- : CAuto(iMan, object)
+CAutoTower::CAutoTower(CObject* object) : CAuto(object)
{
int i;
diff --git a/src/object/auto/autotower.h b/src/object/auto/autotower.h
index b29ba85..d219fb5 100644
--- a/src/object/auto/autotower.h
+++ b/src/object/auto/autotower.h
@@ -38,7 +38,7 @@ enum AutoTowerPhase
class CAutoTower : public CAuto
{
public:
- CAutoTower(CInstanceManager* iMan, CObject* object);
+ CAutoTower(CObject* object);
~CAutoTower();
void DeleteObject(bool bAll=false);
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index ef7309d..fa3e425 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -17,8 +17,10 @@
#include "object/brain.h"
-#include "common/misc.h"
+#include "app/app.h"
+
#include "common/iman.h"
+#include "common/misc.h"
#include "graphics/core/color.h"
#include "graphics/engine/terrain.h"
@@ -47,28 +49,25 @@ const int MAXTRACERECORD = 1000;
// Object's constructor.
-CBrain::CBrain(CInstanceManager* iMan, CObject* object)
+CBrain::CBrain(CObject* object)
{
- int i;
-
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_BRAIN, this, 100);
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_BRAIN, this, 100);
m_object = object;
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_physics = 0;
- m_motion = 0;
- m_primaryTask = 0;
- m_secondaryTask = 0;
- m_studio = 0;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_water = m_engine->GetWater();
+ m_particle = m_engine->GetParticle();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_interface = m_main->GetInterface();
+ m_displayText = m_main->GetDisplayText();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_physics = nullptr;
+ m_motion = nullptr;
+ m_primaryTask = nullptr;
+ m_secondaryTask = nullptr;
+ m_studio = nullptr;
m_program = -1;
m_bActivity = true;
@@ -89,7 +88,7 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
m_defaultEnter = EVENT_NULL;
m_manipStyle = EVENT_OBJECT_MFRONT;
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
m_script[i] = 0;
m_scriptName[i][0] = 0;
@@ -106,9 +105,7 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
CBrain::~CBrain()
{
- int i;
-
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
delete m_script[i];
m_script[i] = nullptr;
@@ -126,7 +123,7 @@ CBrain::~CBrain()
delete[] m_traceRecordBuffer;
m_traceRecordBuffer = nullptr;
- m_iMan->DeleteInstance(CLASS_BRAIN, this);
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_BRAIN, this);
}
@@ -255,7 +252,7 @@ bool CBrain::EventProcess(const Event &event)
if ( m_object->GetSelect() && // robot selected?
m_studio != 0 ) // current issue?
{
- // m_studio->EventProcess(event);
+ m_studio->EventProcess(event);
if ( action == EVENT_OBJECT_PROGRUN )
{
@@ -528,6 +525,10 @@ bool CBrain::EventProcess(const Event &event)
{
err = StartTaskBuild(OBJECT_INFO);
}
+ if ( action == EVENT_OBJECT_BDESTROYER )
+ {
+ err = StartTaskBuild(OBJECT_DESTROYER);
+ }
if ( action == EVENT_OBJECT_GFLAT )
{
@@ -601,6 +602,11 @@ bool CBrain::EventProcess(const Event &event)
//? err = StartTaskFireAnt();
}
+ if ( action == EVENT_OBJECT_SPIDEREXPLO && m_primaryTask == 0 )
+ {
+ err = StartTaskSpiderExplo();
+ }
+
if ( action == EVENT_OBJECT_PEN0 ) // up
{
err = StartTaskPen(false, m_object->GetTraceColor());
@@ -869,7 +875,7 @@ void CBrain::StartEditScript(int rank, char* name)
if ( m_script[rank] == 0 )
{
- m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[rank] = new CScript(m_object, &m_secondaryTask);
}
m_studio = new Ui::CStudio();
@@ -904,7 +910,7 @@ Error CBrain::StartTaskTake()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskTake();
UpdateInterface();
return err;
@@ -922,7 +928,7 @@ Error CBrain::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskManip(order, arm);
UpdateInterface();
return err;
@@ -940,7 +946,7 @@ Error CBrain::StartTaskFlag(TaskFlagOrder order, int rank)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskFlag(order, rank);
UpdateInterface();
return err;
@@ -958,7 +964,7 @@ Error CBrain::StartTaskBuild(ObjectType type)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskBuild(type);
UpdateInterface();
return err;
@@ -976,7 +982,7 @@ Error CBrain::StartTaskSearch()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskSearch();
UpdateInterface();
return err;
@@ -994,7 +1000,7 @@ Error CBrain::StartTaskTerraform()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskTerraform();
UpdateInterface();
return err;
@@ -1016,7 +1022,7 @@ Error CBrain::StartTaskPen(bool bDown, int color)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskPen(bDown, color);
UpdateInterface();
return err;
@@ -1034,7 +1040,7 @@ Error CBrain::StartTaskRecover()
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskRecover();
UpdateInterface();
return err;
@@ -1052,7 +1058,7 @@ Error CBrain::StartTaskShield(TaskShieldMode mode)
m_secondaryTask = 0;
}
- m_secondaryTask = new CTaskManager(m_iMan, m_object);
+ m_secondaryTask = new CTaskManager(m_object);
err = m_secondaryTask->StartTaskShield(mode, 1000.0f);
UpdateInterface();
return err;
@@ -1070,12 +1076,30 @@ Error CBrain::StartTaskFire(float delay)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskFire(delay);
UpdateInterface();
return err;
}
+// Explodes spider.
+
+Error CBrain::StartTaskSpiderExplo()
+{
+ Error err;
+
+ if ( m_primaryTask != 0 )
+ {
+ delete m_primaryTask; // stops the current task
+ m_primaryTask = 0;
+ }
+
+ m_primaryTask = new CTaskManager(m_object);
+ err = m_primaryTask->StartTaskSpiderExplo();
+ UpdateInterface();
+ return err;
+}
+
// Shoots to the ant.
Error CBrain::StartTaskFireAnt(Math::Vector impact)
@@ -1088,7 +1112,7 @@ Error CBrain::StartTaskFireAnt(Math::Vector impact)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskFireAnt(impact);
UpdateInterface();
return err;
@@ -1106,7 +1130,7 @@ Error CBrain::StartTaskGunGoal(float dirV, float dirH)
m_secondaryTask = 0;
}
- m_secondaryTask = new CTaskManager(m_iMan, m_object);
+ m_secondaryTask = new CTaskManager(m_object);
err = m_secondaryTask->StartTaskGunGoal(dirV, dirH);
UpdateInterface();
return err;
@@ -1124,7 +1148,7 @@ Error CBrain::StartTaskReset(Math::Vector goal, Math::Vector angle)
m_primaryTask = 0;
}
- m_primaryTask = new CTaskManager(m_iMan, m_object);
+ m_primaryTask = new CTaskManager(m_object);
err = m_primaryTask->StartTaskReset(goal, angle);
UpdateInterface();
return err;
@@ -1287,18 +1311,20 @@ bool CBrain::CreateInterface(bool bSelect)
type == OBJECT_BEE ||
type == OBJECT_WORM ) // vehicle?
{
- ddim.x = dim.x*5.1f;
- ddim.y = dim.y*2.0f;
- pos.x = ox+sx*0.0f;
- pos.y = oy+sy*0.0f;
- pw->CreateList(pos, ddim, -1, EVENT_OBJECT_PROGLIST, 1.10f);
- UpdateScript(pw);
+ if (!(m_main->GetRetroMode())) {
+ ddim.x = dim.x*5.1f;
+ ddim.y = dim.y*2.0f;
+ pos.x = ox+sx*0.0f;
+ pos.y = oy+sy*0.0f;
+ pw->CreateList(pos, ddim, -1, EVENT_OBJECT_PROGLIST, 1.10f);
+ UpdateScript(pw);
- pos.x = ox+sx*5.2f;
- pos.y = oy+sy*1.0f;
- pw->CreateButton(pos, dim, 8, EVENT_OBJECT_PROGRUN);
- pos.y = oy+sy*0.0f;
- pw->CreateButton(pos, dim, 22, EVENT_OBJECT_PROGEDIT);
+ pos.x = ox+sx*5.2f;
+ pos.y = oy+sy*1.0f;
+ pw->CreateButton(pos, dim, 8, EVENT_OBJECT_PROGRUN);
+ pos.y = oy+sy*0.0f;
+ pw->CreateButton(pos, dim, 22, EVENT_OBJECT_PROGEDIT);
+ }
}
if ( type == OBJECT_HUMAN ||
@@ -1363,8 +1389,9 @@ bool CBrain::CreateInterface(bool bSelect)
pw->CreateButton(pos, dim, 33, EVENT_OBJECT_MFRONT);
}
- if ( type == OBJECT_MOBILEsa && // underwater?
- !m_object->GetTrainer() )
+ if ( ( type == OBJECT_MOBILEsa && // underwater?
+ !m_object->GetTrainer() ) ||
+ type == OBJECT_BEE )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1454,8 +1481,8 @@ bool CBrain::CreateInterface(bool bSelect)
pos.x = ox+sx*5.4f;
pos.y = oy+sy*0.1f;
- pw->CreateButton(pos, ddim, 128+56, EVENT_OBJECT_BXXXX);
- DeadInterface(pw, EVENT_OBJECT_BXXXX, false);
+ pw->CreateButton(pos, ddim, 128+41, EVENT_OBJECT_BDESTROYER);
+ DeadInterface(pw, EVENT_OBJECT_BDESTROYER, g_build&BUILD_DESTROYER);
if ( g_build&BUILD_GFLAT )
{
@@ -1577,6 +1604,15 @@ bool CBrain::CreateInterface(bool bSelect)
//? pw->CreateButton(pos, dim, 41, EVENT_OBJECT_LIMIT);
}
+ if ( type == OBJECT_SPIDER )
+ {
+ pos.x = ox+sx*7.7f;
+ pos.y = oy+sy*0.5f;
+ pb = pw->CreateButton(pos, dim, 42, EVENT_OBJECT_SPIDEREXPLO);
+ pb->SetImmediat(true);
+ DefaultEnter(pw, EVENT_OBJECT_SPIDEREXPLO);
+ }
+
if ( type == OBJECT_MOBILEdr &&
m_object->GetManual() ) // scribbler in manual mode?
{
@@ -1908,9 +1944,7 @@ bool CBrain::CreateInterface(bool bSelect)
void CBrain::UpdateInterface(float rTime)
{
Ui::CWindow* pw;
-/* TODO: #if _TEEN
Ui::CButton* pb;
-#endif*/
Ui::CGauge* pg;
Ui::CCompass* pc;
Ui::CGroup* pgr;
@@ -1947,6 +1981,7 @@ void CBrain::UpdateInterface(float rTime)
if ( power == 0 )
{
energy = 0.0f;
+ limit = 0.0f;
}
else
{
@@ -2021,8 +2056,7 @@ void CBrain::UpdateInterface(float rTime)
pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap());
}
-#if _TEEN
- pb = (CButton*)pw->SearchControl(EVENT_OBJECT_REC);
+ pb = (Ui::CButton*)pw->SearchControl(EVENT_OBJECT_REC);
if ( pb != 0 )
{
if ( m_bTraceRecord && Math::Mod(m_time, 0.4f) >= 0.2f )
@@ -2034,7 +2068,6 @@ void CBrain::UpdateInterface(float rTime)
pb->ClearState(Ui::STATE_CHECK);
}
}
-#endif
bOnBoard = m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD;
@@ -2114,10 +2147,8 @@ void CBrain::UpdateInterface()
Ui::CWindow* pw;
Ui::CButton* pb;
Ui::CSlider* ps;
-#if _TEEN
- CColor* pc;
+ Ui::CColor* pc;
int color;
-#endif
bool bEnable, bFly, bRun;
char title[100];
@@ -2132,38 +2163,37 @@ void CBrain::UpdateInterface()
bEnable = ( m_primaryTask == 0 && m_program == -1 );
- EnableInterface(pw, EVENT_OBJECT_PROGEDIT, (m_primaryTask == 0 && !m_bTraceRecord));
- EnableInterface(pw, EVENT_OBJECT_PROGLIST, bEnable && !m_bTraceRecord);
- EnableInterface(pw, EVENT_OBJECT_LEFT, bEnable);
- EnableInterface(pw, EVENT_OBJECT_RIGHT, bEnable);
- EnableInterface(pw, EVENT_OBJECT_UP, bEnable);
- EnableInterface(pw, EVENT_OBJECT_DOWN, bEnable);
- EnableInterface(pw, EVENT_OBJECT_HTAKE, bEnable);
- EnableInterface(pw, EVENT_OBJECT_MTAKE, bEnable);
- EnableInterface(pw, EVENT_OBJECT_MBACK, bEnable);
- EnableInterface(pw, EVENT_OBJECT_MPOWER, bEnable);
- EnableInterface(pw, EVENT_OBJECT_MFRONT, bEnable);
- EnableInterface(pw, EVENT_OBJECT_GFLAT, bEnable);
- EnableInterface(pw, EVENT_OBJECT_FCREATE, bEnable);
- EnableInterface(pw, EVENT_OBJECT_FDELETE, bEnable);
- EnableInterface(pw, EVENT_OBJECT_SEARCH, bEnable);
- EnableInterface(pw, EVENT_OBJECT_TERRAFORM, bEnable);
- EnableInterface(pw, EVENT_OBJECT_RECOVER, bEnable);
- EnableInterface(pw, EVENT_OBJECT_FIRE, bEnable);
- EnableInterface(pw, EVENT_OBJECT_RESET, bEnable);
-#if _TEEN
- EnableInterface(pw, EVENT_OBJECT_PEN0, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN1, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN2, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN3, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN4, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN5, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN6, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN7, bEnable);
- EnableInterface(pw, EVENT_OBJECT_PEN8, bEnable);
- EnableInterface(pw, EVENT_OBJECT_REC, bEnable);
- EnableInterface(pw, EVENT_OBJECT_STOP, bEnable);
-#endif
+ EnableInterface(pw, EVENT_OBJECT_PROGEDIT, (m_primaryTask == 0 && !m_bTraceRecord));
+ EnableInterface(pw, EVENT_OBJECT_PROGLIST, bEnable && !m_bTraceRecord);
+ EnableInterface(pw, EVENT_OBJECT_LEFT, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_RIGHT, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_UP, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_DOWN, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_HTAKE, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_MTAKE, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_MBACK, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_MPOWER, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_MFRONT, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_GFLAT, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_FCREATE, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_FDELETE, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_SEARCH, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_TERRAFORM, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_RECOVER, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_FIRE, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_SPIDEREXPLO, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_RESET, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN0, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN1, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN2, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN3, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN4, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN5, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN6, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN7, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_PEN8, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_REC, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_STOP, bEnable);
if ( type == OBJECT_HUMAN ) // builder?
{
@@ -2180,7 +2210,7 @@ void CBrain::UpdateInterface()
EnableInterface(pw, EVENT_OBJECT_BNUCLEAR, bEnable);
EnableInterface(pw, EVENT_OBJECT_BPARA, bEnable);
EnableInterface(pw, EVENT_OBJECT_BINFO, bEnable);
- EnableInterface(pw, EVENT_OBJECT_BXXXX, bEnable);
+ EnableInterface(pw, EVENT_OBJECT_BDESTROYER,bEnable);
}
pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_GFLAT));
@@ -2314,7 +2344,6 @@ void CBrain::UpdateInterface()
CheckInterface(pw, EVENT_OBJECT_MFRONT, m_manipStyle==EVENT_OBJECT_MFRONT);
}
-#if _TEEN
if ( m_object->GetTraceDown() )
{
pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PEN0));
@@ -2414,7 +2443,6 @@ void CBrain::UpdateInterface()
pc->ClearState(Ui::STATE_CHECK);
}
}
-#endif
}
// Updates the list of programs.
@@ -2693,7 +2721,7 @@ bool CBrain::ReadProgram(int rank, const char* filename)
{
if ( m_script[rank] == 0 )
{
- m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[rank] = new CScript(m_object, &m_secondaryTask);
}
if ( m_script[rank]->ReadScript(filename) ) return true;
@@ -2718,7 +2746,7 @@ bool CBrain::WriteProgram(int rank, char* filename)
{
if ( m_script[rank] == 0 )
{
- m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[rank] = new CScript(m_object, &m_secondaryTask);
}
if ( m_script[rank]->WriteScript(filename) ) return true;
@@ -2748,7 +2776,7 @@ bool CBrain::ReadStack(FILE *file)
if ( m_script[op] == 0 )
{
- m_script[op] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[op] = new CScript(m_object, &m_secondaryTask);
}
if ( !m_script[op]->ReadStack(file) ) return false;
}
@@ -2910,7 +2938,7 @@ void CBrain::TraceRecordStop()
i = m_selScript;
if ( m_script[i] == 0 )
{
- m_script[i] = new CScript(m_iMan, m_object, &m_secondaryTask);
+ m_script[i] = new CScript(m_object, &m_secondaryTask);
}
m_script[i]->SendScript(buffer);
delete[] buffer;
diff --git a/src/object/brain.h b/src/object/brain.h
index ce7116e..eba8004 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -31,7 +31,6 @@
#include "object/task/taskshield.h"
-class CInstanceManager;
class CObject;
class CPhysics;
class CMotion;
@@ -80,7 +79,7 @@ struct TraceRecord
class CBrain
{
public:
- CBrain(CInstanceManager* iMan, CObject* object);
+ CBrain(CObject* object);
~CBrain();
void DeleteObject(bool bAll=false);
@@ -134,6 +133,7 @@ public:
Error StartTaskShield(TaskShieldMode mode);
Error StartTaskFire(float delay);
Error StartTaskFireAnt(Math::Vector impact);
+ Error StartTaskSpiderExplo();
Error StartTaskGunGoal(float dirV, float dirH);
Error StartTaskReset(Math::Vector goal, Math::Vector angle);
@@ -167,7 +167,6 @@ protected:
bool TraceRecordPut(char *buffer, int max, TraceOper oper, float param);
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
diff --git a/src/object/mainmovie.cpp b/src/object/mainmovie.cpp
index 9aaf345..04c0d56 100644
--- a/src/object/mainmovie.cpp
+++ b/src/object/mainmovie.cpp
@@ -17,7 +17,7 @@
#include "object/mainmovie.h"
-#include "common/iman.h"
+#include "app/app.h"
#include "math/geometry.h"
@@ -30,15 +30,12 @@
// Constructor of the application card.
-CMainMovie::CMainMovie(CInstanceManager* iMan)
+CMainMovie::CMainMovie()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_SHORT, this);
-
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_camera = m_main->GetCamera();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
Flush();
}
diff --git a/src/object/mainmovie.h b/src/object/mainmovie.h
index eba21eb..4554431 100644
--- a/src/object/mainmovie.h
+++ b/src/object/mainmovie.h
@@ -23,18 +23,17 @@
#include "common/event.h"
+
#include "math/vector.h"
-class CInstanceManager;
class CRobotMain;
class CSoundInterface;
-namespace Gfx
-{
- class CCamera;
- class CEngine;
-};
+namespace Gfx {
+class CCamera;
+class CEngine;
+}
enum MainMovieType
{
@@ -48,7 +47,7 @@ enum MainMovieType
class CMainMovie
{
public:
- CMainMovie(CInstanceManager* iMan);
+ CMainMovie();
~CMainMovie();
void Flush();
@@ -60,9 +59,6 @@ public:
MainMovieType GetStopType();
protected:
-
-protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
CRobotMain* m_main;
Gfx::CCamera* m_camera;
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index 605091f..00b3073 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "common/iman.h"
+#include "object/robotmain.h"
#include "script/cmdtoken.h"
@@ -30,20 +30,16 @@
// Object's constructor.
-CMotion::CMotion(CInstanceManager* iMan, CObject* object)
+CMotion::CMotion(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_MOTION, this, 100);
-
m_app = CApplication::GetInstancePointer();
- m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
- m_light = static_cast< Gfx::CLight* >(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
- m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = m_app->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
m_object = object;
m_physics = 0;
@@ -62,7 +58,6 @@ CMotion::CMotion(CInstanceManager* iMan, CObject* object)
CMotion::~CMotion()
{
- m_iMan->DeleteInstance(CLASS_MOTION, this);
}
// Deletes the object.
diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h
index 81bcb08..d35ee67 100644
--- a/src/object/motion/motion.h
+++ b/src/object/motion/motion.h
@@ -27,14 +27,12 @@
namespace Gfx {
class CEngine;
-class CLight;
class CParticle;
class CTerrain;
class CWater;
class CCamera;
}
-class CInstanceManager;
class CApplication;
class CBrain;
class CPhysics;
@@ -46,7 +44,7 @@ class CSoundInterface;
class CMotion
{
public:
- CMotion(CInstanceManager* iMan, CObject* object);
+ CMotion(CObject* object);
virtual ~CMotion();
void SetPhysics(CPhysics* physics);
@@ -72,12 +70,8 @@ public:
virtual Math::Vector GetInclinaison();
protected:
-
-protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
Gfx::CEngine* m_engine;
- Gfx::CLight* m_light;
Gfx::CParticle* m_particle;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp
index 07ee6b8..384d683 100644
--- a/src/object/motion/motionant.cpp
+++ b/src/object/motion/motionant.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "physics/physics.h"
@@ -35,8 +35,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionAnt::CMotionAnt(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionAnt::CMotionAnt(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -69,12 +68,8 @@ void CMotionAnt::DeleteObject(bool bAll)
bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
- int rank;
-
-// if ( m_engine->GetRestCreate() < 3+18 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
+ int rank;
m_object->SetType(type);
@@ -82,10 +77,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
-
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant1.mod"));
- pModFile->CreateEngineObject(rank);
-
+ modelManager->AddModelReference("ant1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -96,29 +88,26 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(2.0f, 0.0f, 0.0f));
// Creates the tail.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(-1.0f, 0.0f, 0.0f));
// Creates a right-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(-0.4f, -0.1f, -0.3f));
// Creates a right-back leg.
@@ -126,161 +115,135 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates a right-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates two middle-right thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.1f, -0.1f, -0.4f));
// Creates two middle-right legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates two middle-right foots.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates the right front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(9, Math::Vector(1.4f, -0.1f, -0.6f));
// Creates the right front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates the right front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates a left-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", true, rank);
m_object->SetPosition(12, Math::Vector(-0.4f, -0.1f, 0.3f));
// Creates a left-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", true, rank);
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, 1.0f));
// Creates a left-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 13);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", true, rank);
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, 2.0f));
// Creates two middle-left thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", true, rank);
m_object->SetPosition(15, Math::Vector(0.1f, -0.1f, 0.4f));
// Creates two middle-left legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 15);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", true, rank);
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, 1.0f));
// Creates two middle-left foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", true, rank);
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, 2.0f));
// Creates the left front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", true, rank);
m_object->SetPosition(18, Math::Vector(1.4f, -0.1f, 0.6f));
// Creates the left front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 18);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", true, rank);
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, 1.0f));
// Creates the left front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(20, rank);
m_object->SetObjectParent(20, 19);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", true, rank);
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, 2.0f));
m_object->CreateShadowCircle(4.0f, 0.5f);
@@ -293,7 +256,6 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionant.h b/src/object/motion/motionant.h
index 68a3b7f..45d02b3 100644
--- a/src/object/motion/motionant.h
+++ b/src/object/motion/motionant.h
@@ -46,7 +46,7 @@ enum MotionAntSpecialAction
class CMotionAnt : public CMotion
{
public:
- CMotionAnt(CInstanceManager* iMan, CObject* object);
+ CMotionAnt(CObject* object);
~CMotionAnt();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp
index a3421b8..8f69945 100644
--- a/src/object/motion/motionbee.cpp
+++ b/src/object/motion/motionbee.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "physics/physics.h"
@@ -34,8 +34,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionBee::CMotionBee(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionBee::CMotionBee(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -67,12 +66,8 @@ void CMotionBee::DeleteObject(bool bAll)
bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
- int rank;
-
-// if ( m_engine->GetRestCreate() < 3+18+2 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
+ int rank;
m_object->SetType(type);
@@ -80,10 +75,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
-
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee1.mod"));
- pModFile->CreateEngineObject(rank);
-
+ modelManager->AddModelReference("bee1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -97,8 +89,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(1.6f, 0.3f, 0.0f));
// Creates the tail.
@@ -106,8 +97,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(-0.8f, 0.0f, 0.0f));
// Creates a right-back thigh.
@@ -115,8 +105,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(-0.3f, -0.1f, -0.2f));
// Creates a right-back leg.
@@ -124,8 +113,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates a right-back foot.
@@ -133,8 +121,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates two middle-right thighs.
@@ -142,8 +129,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.3f, -0.1f, -0.4f));
// Creates two middle-right legs.
@@ -151,8 +137,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates two middle-right feet.
@@ -160,8 +145,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates the right front thigh.
@@ -169,8 +153,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(9, Math::Vector(1.0f, -0.1f, -0.7f));
// Creates the right front leg.
@@ -178,8 +161,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(10, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates the right front foot.
@@ -187,8 +169,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates a left-back thigh.
@@ -196,8 +177,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(12, Math::Vector(-0.3f, -0.1f, 0.2f));
m_object->SetAngleY(12, Math::PI);
@@ -206,8 +186,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates a left-back foot.
@@ -215,8 +194,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 13);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(14, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates two middle-left thigh.
@@ -224,8 +202,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(15, Math::Vector(0.3f, -0.1f, 0.4f));
m_object->SetAngleY(15, Math::PI);
@@ -234,8 +211,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 15);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(16, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates two middle-left feet.
@@ -243,8 +219,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(17, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates front-left thigh.
@@ -252,8 +227,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant4.mod", false, rank);
m_object->SetPosition(18, Math::Vector(1.0f, -0.1f, 0.7f));
m_object->SetAngleY(18, Math::PI);
@@ -262,8 +236,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 18);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant5.mod", false, rank);
m_object->SetPosition(19, Math::Vector(0.0f, 0.0f, -1.0f));
// Creates front-left foot.
@@ -271,8 +244,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(20, rank);
m_object->SetObjectParent(20, 19);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ant6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ant6.mod", false, rank);
m_object->SetPosition(20, Math::Vector(0.0f, 0.0f, -2.0f));
// Creates the right wing.
@@ -280,8 +252,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(21, rank);
m_object->SetObjectParent(21, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee7.mod", false, rank);
m_object->SetPosition(21, Math::Vector(0.8f, 0.4f, -0.5f));
// Creates the left wing.
@@ -289,9 +260,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(22, rank);
m_object->SetObjectParent(22, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "bee7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("bee7.mod", true, rank);
m_object->SetPosition(22, Math::Vector(0.8f, 0.4f, 0.5f));
m_object->CreateShadowCircle(6.0f, 0.5f);
@@ -304,7 +273,6 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionbee.h b/src/object/motion/motionbee.h
index aa8e5a6..c0347a0 100644
--- a/src/object/motion/motionbee.h
+++ b/src/object/motion/motionbee.h
@@ -40,7 +40,7 @@ enum MotionBeeSpecialAction
class CMotionBee : public CMotion
{
public:
- CMotionBee(CInstanceManager* iMan, CObject* object);
+ CMotionBee(CObject* object);
~CMotionBee();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index a9b79b5..dc5ff34 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
@@ -43,8 +43,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionHuman::CMotionHuman(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionHuman::CMotionHuman(CObject* object) : CMotion(object)
{
m_partiReactor = -1;
m_armMember = START_TIME;
@@ -97,30 +96,22 @@ Error CMotionHuman::SetAction(int action, float time)
bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
char filename[100];
int rank, option, face, glasses;
-// if ( m_engine->GetRestCreate() < 16 ) return false;
-
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
option = m_object->GetOption();
- std::string baseName;
-
if ( m_main->GetGamerOnlyHead() )
{
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
face = m_main->GetGamerFace();
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2h%d.mod");
- sprintf(filename, baseName.c_str(), face+1);
- pModFile->ReadModel(filename);
- pModFile->CreateEngineObject(rank);
+ sprintf(filename, "human2h%d.mod", face+1);
+ modelManager->AddModelReference(filename, false, rank);
glasses = m_main->GetGamerGlasses();
if ( glasses != 0 )
@@ -129,10 +120,8 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2g%d.mod");
- sprintf(filename, baseName.c_str(), glasses);
- pModFile->ReadModel(filename);
- pModFile->CreateEngineObject(rank);
+ sprintf(filename, "human2g%d.mod", glasses);
+ modelManager->AddModelReference(filename, false, rank);
}
CreatePhysics(type);
@@ -140,7 +129,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
@@ -149,19 +137,12 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- if ( option == 0 ) // head in helmet?
- {
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1c.mod"));
- }
- if ( option == 1 ) // head without helmet?
- {
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1h.mod"));
- }
- if ( option == 2 ) // without a backpack?
- {
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human1v.mod"));
- }
- pModFile->CreateEngineObject(rank);
+ if (option == 0) // head in helmet?
+ modelManager->AddModelReference("human1c.mod", false, rank);
+ else if (option == 1) // head without helmet?
+ modelManager->AddModelReference("human1h.mod", false, rank);
+ else if (option == 2) // without a backpack?
+ modelManager->AddModelReference("human1v.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -178,30 +159,28 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_HUMAN )
{
- if ( option == 0 ) // head in helmet?
+ if (option == 0) // head in helmet?
{
face = m_main->GetGamerFace();
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2c%d.mod");
- sprintf(filename, baseName.c_str(), face+1);
- pModFile->ReadModel(filename);
+ sprintf(filename, "human2c%d.mod", face+1);
+ modelManager->AddModelReference(filename, false, rank);
}
- if ( option == 1 || // head without helmet?
- option == 2 ) // without a backpack?
+ else if (option == 1 || // head without helmet?
+ option == 2) // without a backpack?
{
face = m_main->GetGamerFace();
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2h%d.mod");
- sprintf(filename, baseName.c_str(), face+1);
- pModFile->ReadModel(filename);
+ sprintf(filename, "human2h%d.mod", face+1);
+ modelManager->AddModelReference(filename, false, rank);
}
}
- if ( type == OBJECT_TECH )
+ else if (type == OBJECT_TECH)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human2t.mod"));
+ modelManager->AddModelReference("human2t.mod", false, rank);
}
- pModFile->CreateEngineObject(rank);
+
m_object->SetPosition(1, Math::Vector(0.0f, 2.7f, 0.0f));
- if ( option == 1 || // head without helmet?
- option == 2 ) // without a backpack?
+ if (option == 1 || // head without helmet?
+ option == 2) // without a backpack?
{
m_object->SetZoom(1, Math::Vector(1.0f, 1.05f, 1.0f));
}
@@ -214,10 +193,8 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 1);
- baseName = m_app->GetDataFilePath(DIR_MODEL, "human2g%d.mod");
- sprintf(filename, baseName.c_str(), glasses);
- pModFile->ReadModel(filename);
- pModFile->CreateEngineObject(rank);
+ sprintf(filename, "human2g%d.mod", glasses);
+ modelManager->AddModelReference(filename, false, rank);
}
// Creates the right arm.
@@ -225,8 +202,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.0f, 2.3f, -1.2f));
m_object->SetAngle(2, Math::Vector(90.0f*Math::PI/180.0f, 90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
@@ -235,8 +211,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human4r.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human4r.mod", false, rank);
m_object->SetPosition(3, Math::Vector(1.3f, 0.0f, 0.0f));
m_object->SetAngle(3, Math::Vector(0.0f*Math::PI/180.0f, -20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
@@ -245,8 +220,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(1.2f, 0.0f, 0.0f));
// Creates the right thigh.
@@ -254,8 +228,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -0.7f));
m_object->SetAngle(5, Math::Vector(10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -264,8 +237,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 5);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human7.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(6, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
@@ -274,8 +246,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human8.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human8.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(7, Math::Vector(-10.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -284,9 +255,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human3.mod", true, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 2.3f, 1.2f));
m_object->SetAngle(8, Math::Vector(-90.0f*Math::PI/180.0f, -90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
@@ -295,9 +264,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human4l.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human4l.mod", true, rank);
m_object->SetPosition(9, Math::Vector(1.3f, 0.0f, 0.0f));
m_object->SetAngle(9, Math::Vector(0.0f*Math::PI/180.0f, 20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
@@ -306,9 +273,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human5.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human5.mod", true, rank);
m_object->SetPosition(10, Math::Vector(1.2f, 0.0f, 0.0f));
// Creates the left thigh.
@@ -316,9 +281,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human6.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human6.mod", true, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, 0.7f));
m_object->SetAngle(11, Math::Vector(-10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -327,9 +290,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 11);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human7.mod", true, rank);
m_object->SetPosition(12, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(12, Math::Vector(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
@@ -338,9 +299,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human8.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human8.mod", true, rank);
m_object->SetPosition(13, Math::Vector(0.0f, -1.5f, 0.0f));
m_object->SetAngle(13, Math::Vector(10.0f*Math::PI/180.0f, -5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
@@ -351,8 +310,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "human9.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("human9.mod", false, rank);
m_object->SetPosition(14, Math::Vector(-1.5f, 0.3f, -1.35f));
m_object->SetAngleZ(14, Math::PI);
}
@@ -367,7 +325,6 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionhuman.h b/src/object/motion/motionhuman.h
index b365a77..ddb0843 100644
--- a/src/object/motion/motionhuman.h
+++ b/src/object/motion/motionhuman.h
@@ -58,7 +58,7 @@ enum MotionHumanSpecialAction
class CMotionHuman : public CMotion
{
public:
- CMotionHuman(CInstanceManager* iMan, CObject* object);
+ CMotionHuman(CObject* object);
~CMotionHuman();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp
index 8ea77a5..573a2e4 100644
--- a/src/object/motion/motionmother.cpp
+++ b/src/object/motion/motionmother.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "physics/physics.h"
@@ -34,8 +34,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionMother::CMotionMother(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionMother::CMotionMother(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -68,12 +67,8 @@ void CMotionMother::DeleteObject(bool bAll)
bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
- int rank;
-
-// if ( m_engine->GetRestCreate() < 2+12+6 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
+ int rank;
m_object->SetType(type);
@@ -81,10 +76,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
-
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother1.mod"));
- pModFile->CreateEngineObject(rank);
-
+ modelManager->AddModelReference("mother1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -98,8 +90,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(16.0f, 3.0f, 0.0f));
// Creates a right-back leg.
@@ -107,8 +98,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(-5.0f, -1.0f, -12.0f));
// Creates a right-back foot.
@@ -116,8 +106,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a middle-right leg.
@@ -125,8 +114,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(4, Math::Vector(3.5f, -1.0f, -12.0f));
// Creates a middle-right foot.
@@ -134,8 +122,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a right-front leg.
@@ -143,8 +130,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(6, Math::Vector(10.0f, -1.0f, -10.0f));
// Creates a right-front foot.
@@ -152,8 +138,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a left-back leg.
@@ -161,8 +146,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(8, Math::Vector(-5.0f, -1.0f, 12.0f));
m_object->SetAngleY(8, Math::PI);
@@ -171,8 +155,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(9, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a middle-left leg.
@@ -180,8 +163,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(10, Math::Vector(3.5f, -1.0f, 12.0f));
m_object->SetAngleY(10, Math::PI);
@@ -190,8 +172,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(11, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates a left-front leg.
@@ -199,8 +180,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother3.mod", false, rank);
m_object->SetPosition(12, Math::Vector(10.0f, -1.0f, 10.0f));
m_object->SetAngleY(12, Math::PI);
@@ -209,8 +189,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother4.mod", false, rank);
m_object->SetPosition(13, Math::Vector(0.0f, 0.0f, -8.5f));
// Creates the right antenna.
@@ -218,16 +197,14 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother5.mod", false, rank);
m_object->SetPosition(14, Math::Vector(6.0f, 1.0f, -2.5f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 14);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother6.mod", false, rank);
m_object->SetPosition(15, Math::Vector(8.0f, 0.0f, 0.0f));
// Creates the left antenna.
@@ -235,16 +212,14 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother5.mod", false, rank);
m_object->SetPosition(16, Math::Vector(6.0f, 1.0f, 2.5f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother6.mod", false, rank);
m_object->SetPosition(17, Math::Vector(8.0f, 0.0f, 0.0f));
// Creates the right claw.
@@ -252,8 +227,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother7.mod", false, rank);
m_object->SetPosition(18, Math::Vector(-4.0f, -3.5f, -8.0f));
m_object->SetZoomX(18, 1.2f);
@@ -262,9 +236,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mother7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mother7.mod", true, rank);
m_object->SetPosition(19, Math::Vector(-4.0f, -3.5f, 8.0f));
m_object->SetZoomX(19, 1.2f);
@@ -278,7 +250,6 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionmother.h b/src/object/motion/motionmother.h
index 5060315..a6c7e93 100644
--- a/src/object/motion/motionmother.h
+++ b/src/object/motion/motionmother.h
@@ -26,7 +26,7 @@
class CMotionMother : public CMotion
{
public:
- CMotionMother(CInstanceManager* iMan, CObject* object);
+ CMotionMother(CObject* object);
~CMotionMother();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp
index 516ec6e..59bc6e0 100644
--- a/src/object/motion/motionspider.cpp
+++ b/src/object/motion/motionspider.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "physics/physics.h"
@@ -35,8 +35,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionSpider::CMotionSpider(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionSpider::CMotionSpider(CObject* object) : CMotion(object)
{
m_armMember = START_TIME;
m_armTimeAbs = START_TIME;
@@ -69,12 +68,9 @@ void CMotionSpider::DeleteObject(bool bAll)
bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
int rank, i, j, parent;
char name[50];
- std::string baseName;
-
float table[] =
{
// x y z
@@ -99,9 +95,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
0.0f, 0.0f, -2.0f,
};
-// if ( m_engine->GetRestCreate() < 3+32+2 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
@@ -109,8 +103,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider0.mod")); // doesn't exist
- pModFile->CreateEngineObject(rank);
+ // This is an "empty" object, without triangles
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -124,8 +117,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(1.0f, 0.0f, 0.0f));
// Creates the head.
@@ -133,8 +125,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider2.mod", false, rank);
m_object->SetPosition(2, Math::Vector(1.0f, 0.0f, 0.0f));
// Creates legs.
@@ -142,8 +133,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
{
for ( j=0 ; j<4 ; j++ )
{
- baseName = m_app->GetDataFilePath(DIR_MODEL, "spider%d.mod");
- sprintf(name, baseName.c_str(), j+3); // 3..6
+ sprintf(name, "spider%d.mod", j+3); // 3..6
// Creates the right leg.
rank = m_engine->CreateObject();
@@ -152,8 +142,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 3+i*4+j-1;
m_object->SetObjectParent(3+i*4+j, parent);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, false, rank);
pos.x = table[i*12+j*3+0];
pos.y = table[i*12+j*3+1];
pos.z = table[i*12+j*3+2];
@@ -166,9 +155,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 19+i*4+j-1;
m_object->SetObjectParent(19+i*4+j, parent);
- pModFile->ReadModel(name);
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, true, rank);
pos.x = table[i*12+j*3+0];
pos.y = table[i*12+j*3+1];
pos.z = -table[i*12+j*3+2];
@@ -181,8 +168,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(35, rank);
m_object->SetObjectParent(35, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider7.mod", false, rank);
m_object->SetPosition(35, Math::Vector(0.0f, 0.0f, -0.3f));
// Creates the left mandible.
@@ -190,9 +176,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(36, rank);
m_object->SetObjectParent(36, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "spider7.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("spider7.mod", true, rank);
m_object->SetPosition(36, Math::Vector(0.0f, 0.0f, 0.3f));
m_object->CreateShadowCircle(4.0f, 0.5f);
@@ -205,7 +189,6 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionspider.h b/src/object/motion/motionspider.h
index fbf05f9..89745c4 100644
--- a/src/object/motion/motionspider.h
+++ b/src/object/motion/motionspider.h
@@ -44,7 +44,7 @@ enum MotionSpiderSpecialAction
class CMotionSpider : public CMotion
{
public:
- CMotionSpider(CInstanceManager* iMan, CObject* object);
+ CMotionSpider(CObject* object);
~CMotionSpider();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp
index 274f171..ddb1867 100644
--- a/src/object/motion/motiontoto.cpp
+++ b/src/object/motion/motiontoto.cpp
@@ -21,9 +21,9 @@
#include "math/geometry.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
-#include "graphics/engine/modelfile.h"
#include "object/robotmain.h"
@@ -38,8 +38,7 @@ const float START_TIME = 1000.0f; // beginning of the relative time
// Object's constructor.
-CMotionToto::CMotionToto(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionToto::CMotionToto(CObject* object) : CMotion(object)
{
m_time = 0.0f;
m_bDisplayInfo = false;
@@ -81,12 +80,9 @@ void CMotionToto::DeleteObject(bool bAll)
bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
int rank;
-// if ( m_engine->GetRestCreate() < 10 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
@@ -94,8 +90,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto1.mod", false, rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -104,8 +99,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(1.00f, 0.17f, 0.00f));
// Creates the left eye.
@@ -113,9 +107,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto3.mod", true, rank);
m_object->SetPosition(2, Math::Vector(0.85f, 1.04f, 0.25f));
m_object->SetAngleY(2, -20.0f*Math::PI/180.0f);
@@ -124,8 +116,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto3.mod", false, rank);
m_object->SetPosition(3, Math::Vector(0.85f, 1.04f, -0.25f));
m_object->SetAngleY(3, 20.0f*Math::PI/180.0f);
@@ -134,8 +125,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(4, Math::Vector(0.0f, 1.9f, 0.3f));
m_object->SetAngleX(4, 30.0f*Math::PI/180.0f);
@@ -143,8 +133,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(5, Math::Vector(0.0f, 0.67f, 0.0f));
m_object->SetAngleX(5, 30.0f*Math::PI/180.0f);
@@ -152,8 +141,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 5);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto5.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 0.70f, 0.0f));
m_object->SetAngleX(6, 30.0f*Math::PI/180.0f);
@@ -162,8 +150,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 1.9f, -0.3f));
m_object->SetAngleX(7, -30.0f*Math::PI/180.0f);
@@ -171,8 +158,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto4.mod", false, rank);
m_object->SetPosition(8, Math::Vector(0.0f, 0.67f, 0.0f));
m_object->SetAngleX(8, -30.0f*Math::PI/180.0f);
@@ -180,8 +166,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "toto5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("toto5.mod", false, rank);
m_object->SetPosition(9, Math::Vector(0.0f, 0.70f, 0.0f));
m_object->SetAngleX(9, -30.0f*Math::PI/180.0f);
@@ -193,7 +178,6 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h
index 4072b62..47baa28 100644
--- a/src/object/motion/motiontoto.h
+++ b/src/object/motion/motiontoto.h
@@ -35,7 +35,7 @@ enum MotionTotoAction
class CMotionToto : public CMotion
{
public:
- CMotionToto(CInstanceManager* iMan, CObject* object);
+ CMotionToto(CObject* object);
~CMotionToto();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp
index 849d53e..44b8fdd 100644
--- a/src/object/motion/motionvehicle.cpp
+++ b/src/object/motion/motionvehicle.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
@@ -38,8 +38,7 @@
// Object's constructor.
-CMotionVehicle::CMotionVehicle(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionVehicle::CMotionVehicle(CObject* object) : CMotion(object)
{
int i;
@@ -92,15 +91,12 @@ void CMotionVehicle::DeleteObject(bool bAll)
bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
CObject* pPower;
int rank, i, j, parent;
Gfx::Color color;
char name[50];
-// if ( m_engine->GetRestCreate() < 1+5+18+1 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
@@ -109,106 +105,105 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEfs )
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEfs)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1f.mod"));
+ modelManager->AddModelReference("lem1f.mod", false, rank);
}
- if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts )
+ else if (type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEts)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1t.mod"));
+ modelManager->AddModelReference("lem1t.mod", false, rank);
}
- if ( type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEws )
+ else if (type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEws)
{
- if ( m_object->GetTrainer() )
+ if (m_object->GetTrainer())
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1wt.mod"));
+ modelManager->AddModelReference("lem1wt.mod", false, rank);
}
else
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1w.mod"));
+ modelManager->AddModelReference("lem1w.mod", false, rank);
}
}
- if ( type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEii ||
- type == OBJECT_MOBILEis )
+ else if (type == OBJECT_MOBILEia ||
+ type == OBJECT_MOBILEic ||
+ type == OBJECT_MOBILEii ||
+ type == OBJECT_MOBILEis)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem1i.mod"));
+ modelManager->AddModelReference("lem1i.mod", false, rank);
}
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
+ else if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller1.mod"));
+ modelManager->AddModelReference("roller1.mod", false, rank);
}
- if ( type == OBJECT_MOBILEsa )
+ else if (type == OBJECT_MOBILEsa)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm1.mod"));
+ modelManager->AddModelReference("subm1.mod", false, rank);
}
- if ( type == OBJECT_MOBILEtg )
+ else if (type == OBJECT_MOBILEtg)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "target.mod"));
+ modelManager->AddModelReference("target.mod", false, rank);
}
- if ( type == OBJECT_MOBILEwt )
+ else if (type == OBJECT_MOBILEwt)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "trainerw.mod"));
+ modelManager->AddModelReference("trainerw.mod", false, rank);
}
- if ( type == OBJECT_MOBILEft )
+ else if (type == OBJECT_MOBILEft)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "trainerf.mod"));
+ modelManager->AddModelReference("trainerf.mod", false, rank);
}
- if ( type == OBJECT_MOBILEtt )
+ else if (type == OBJECT_MOBILEtt)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "trainert.mod"));
+ modelManager->AddModelReference("trainert.mod", false, rank);
}
- if ( type == OBJECT_MOBILEit )
+ else if (type == OBJECT_MOBILEit)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "traineri.mod"));
+ modelManager->AddModelReference("traineri.mod", false, rank);
}
- if ( type == OBJECT_MOBILEdr )
+ else if (type == OBJECT_MOBILEdr)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer1.mod"));
+ modelManager->AddModelReference("drawer1.mod", false, rank);
}
- if ( type == OBJECT_APOLLO2 )
+ else if (type == OBJECT_APOLLO2)
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj1.mod"));
+ modelManager->AddModelReference("apolloj1.mod", false, rank);
}
- pModFile->CreateEngineObject(rank);
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
// A vehicle must have a obligatory collision
// with a sphere of center (0, y, 0) (see GetCrashSphere).
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
+ if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 6.5f, SOUND_BOUMm, 0.45f);
m_object->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 7.0f);
}
- else if ( type == OBJECT_MOBILEsa )
+ else if (type == OBJECT_MOBILEsa)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 4.5f, SOUND_BOUMm, 0.45f);
m_object->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f);
}
- else if ( type == OBJECT_MOBILEdr )
+ else if (type == OBJECT_MOBILEdr)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f);
m_object->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 7.0f);
}
- else if ( type == OBJECT_APOLLO2 )
+ else if (type == OBJECT_APOLLO2)
{
m_object->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f, SOUND_BOUMm, 0.45f);
}
@@ -218,18 +213,17 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 6.0f);
}
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEia )
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEia)
{
// Creates the arm.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, ARM_NEUTRAL_ANGLE1);
@@ -238,8 +232,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(5.0f, 0.0f, 0.0f));
m_object->SetAngleZ(2, ARM_NEUTRAL_ANGLE2);
@@ -248,8 +241,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem4.mod", false, rank);
m_object->SetPosition(3, Math::Vector(3.5f, 0.0f, 0.0f));
m_object->SetAngleZ(3, ARM_NEUTRAL_ANGLE3);
m_object->SetAngleX(3, Math::PI/2.0f);
@@ -259,8 +251,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem5.mod", false, rank);
m_object->SetPosition(4, Math::Vector(1.5f, 0.0f, 0.0f));
m_object->SetAngleZ(4, -Math::PI*0.10f);
@@ -269,24 +260,22 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem6.mod", false, rank);
m_object->SetPosition(5, Math::Vector(1.5f, 0.0f, 0.0f));
m_object->SetAngleZ(5, Math::PI*0.10f);
}
- if ( type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEis )
+ if (type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEts ||
+ type == OBJECT_MOBILEws ||
+ type == OBJECT_MOBILEis)
{
// Creates the arm.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, 110.0f*Math::PI/180.0f);
@@ -295,8 +284,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(5.0f, 0.0f, 0.0f));
m_object->SetAngleZ(2, -110.0f*Math::PI/180.0f);
@@ -305,41 +293,38 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem4s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem4s.mod", false, rank);
m_object->SetPosition(3, Math::Vector(3.5f, 0.0f, 0.0f));
m_object->SetAngleZ(3, -65.0f*Math::PI/180.0f);
}
- if ( type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEic )
+ if (type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEic)
{
// Creates the cannon.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "canon.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("canon.mod", false, rank);
//? m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
}
- if ( type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEii )
+ if (type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEii)
{
// Creates the insect cannon.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "canoni1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("canoni1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 5.3f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
@@ -347,25 +332,23 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "canoni2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("canoni2.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.0f, 2.5f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
}
- if ( type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEwt )
+ if (type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEws ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEwt)
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(6, Math::Vector(-3.0f, 1.0f, -3.0f));
// Creates the left-back wheel.
@@ -373,8 +356,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f));
m_object->SetAngleY(7, Math::PI);
@@ -383,8 +365,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(8, Math::Vector(2.0f, 1.0f, -3.0f));
// Creates the left-front wheel.
@@ -392,21 +373,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f));
m_object->SetAngleY(9, Math::PI);
}
- if ( type == OBJECT_MOBILEtg )
+ if (type == OBJECT_MOBILEtg)
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(6, Math::Vector(-2.0f, 1.0f, -3.0f));
// Creates the left-back wheel.
@@ -414,8 +393,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(7, Math::Vector(-2.0f, 1.0f, 3.0f));
m_object->SetAngleY(7, Math::PI);
@@ -424,8 +402,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(8, Math::Vector(3.0f, 1.0f, -3.0f));
// Creates the left-front wheel.
@@ -433,24 +410,22 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2w.mod", false, rank);
m_object->SetPosition(9, Math::Vector(3.0f, 1.0f, 3.0f));
m_object->SetAngleY(9, Math::PI);
}
- if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts ) // caterpillars?
+ if (type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEts) // caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("lem2t.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 2.0f, -3.0f));
// Creates the left caterpillar.
@@ -458,23 +433,21 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem3t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("lem3t.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 2.0f, 3.0f));
}
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs ) // large caterpillars?
+ if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs) // large caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("roller2.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 2.0f, -3.0f));
// Creates the left caterpillar.
@@ -482,20 +455,18 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("roller3.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 2.0f, 3.0f));
}
- if ( type == OBJECT_MOBILEsa ) // underwater caterpillars?
+ if (type == OBJECT_MOBILEsa) // underwater caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("subm4.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 1.0f, -3.0f));
// Creates the left caterpillar.
@@ -503,20 +474,18 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("subm5.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 1.0f, 3.0f));
}
- if ( type == OBJECT_MOBILEdr ) // caterpillars?
+ if (type == OBJECT_MOBILEdr) // caterpillars?
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("drawer2.mod", false, rank);
m_object->SetPosition(6, Math::Vector(0.0f, 1.0f, -3.0f));
// Creates the left caterpillar.
@@ -524,24 +493,22 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("drawer3.mod", false, rank);
m_object->SetPosition(7, Math::Vector(0.0f, 1.0f, 3.0f));
}
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEft ) // flying?
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEft) // flying?
{
// Creates the front foot.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2f.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2f.mod", false, rank);
m_object->SetPosition(6, Math::Vector(1.7f, 3.0f, 0.0f));
// Creates the right-back foot.
@@ -549,8 +516,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2f.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2f.mod", false, rank);
m_object->SetPosition(7, Math::Vector(-1.8f, 3.0f, -1.5f));
m_object->SetAngleY(7, 120.0f*Math::PI/180.0f);
@@ -559,16 +525,15 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "lem2f.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("lem2f.mod", false, rank);
m_object->SetPosition(8, Math::Vector(-1.8f, 3.0f, 1.5f));
m_object->SetAngleY(8, -120.0f*Math::PI/180.0f);
}
- if ( type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEis ||
- type == OBJECT_MOBILEii ) // insect legs?
+ if (type == OBJECT_MOBILEia ||
+ type == OBJECT_MOBILEic ||
+ type == OBJECT_MOBILEis ||
+ type == OBJECT_MOBILEii) // insect legs?
{
float table[] =
{
@@ -590,8 +555,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
for ( j=0 ; j<3 ; j++ )
{
- std::string baseName = m_app->GetDataFilePath(DIR_MODEL, "ant%d.mod");
- sprintf(name, baseName.c_str(), j+4); // 4..6
+ sprintf(name, "ant%d.mod", j+4); // 4..6
// Creates the right leg.
rank = m_engine->CreateObject();
@@ -600,8 +564,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 6+i*3+j-1;
m_object->SetObjectParent(6+i*3+j, parent);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, false, rank);
pos.x = table[i*9+j*3+0];
pos.y = table[i*9+j*3+1];
pos.z = table[i*9+j*3+2];
@@ -614,9 +577,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
if ( j == 0 ) parent = 0;
else parent = 15+i*3+j-1;
m_object->SetObjectParent(15+i*3+j, parent);
- pModFile->ReadModel(name);
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, true, rank);
pos.x = table[i*9+j*3+0];
pos.y = table[i*9+j*3+1];
pos.z = -table[i*9+j*3+2];
@@ -625,15 +586,14 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
}
}
- if ( type == OBJECT_MOBILErt )
+ if (type == OBJECT_MOBILErt)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2t.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
@@ -642,21 +602,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3t.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3t.mod", false, rank);
m_object->SetPosition(2, Math::Vector(9.0f, 4.0f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
}
- if ( type == OBJECT_MOBILErc )
+ if (type == OBJECT_MOBILErc)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2c.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2c.mod", false, rank);
m_object->SetPosition(1, Math::Vector(3.0f, 4.6f, 0.0f));
m_object->SetAngleZ(1, Math::PI/8.0f);
@@ -665,21 +623,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3p.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3p.mod", false, rank);
m_object->SetPosition(2, Math::Vector(7.0f, 6.5f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
}
- if ( type == OBJECT_MOBILErr )
+ if (type == OBJECT_MOBILErr)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(2.0f, 5.0f, 0.0f));
// Creates the right arm.
@@ -687,8 +643,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover2.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.1f, 0.0f, -5.0f));
m_object->SetAngleZ(2, 126.0f*Math::PI/180.0f);
@@ -697,8 +652,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover3.mod", false, rank);
m_object->SetPosition(3, Math::Vector(5.0f, 0.0f, -0.5f));
m_object->SetAngleZ(3, -144.0f*Math::PI/180.0f);
@@ -707,9 +661,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover2.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover2.mod", true, rank);
m_object->SetPosition(4, Math::Vector(0.1f, 0.0f, 5.0f));
m_object->SetAngleZ(4, 126.0f*Math::PI/180.0f);
@@ -718,22 +670,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "recover3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("recover3.mod", true, rank);
m_object->SetPosition(5, Math::Vector(5.0f, 0.0f, 0.5f));
m_object->SetAngleZ(5, -144.0f*Math::PI/180.0f);
}
- if ( type == OBJECT_MOBILErs )
+ if (type == OBJECT_MOBILErs)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2s.mod", false, rank);
m_object->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetAngleZ(1, 0.0f);
@@ -742,8 +691,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3s.mod", false, rank);
m_object->SetPosition(2, Math::Vector(7.0f, 4.5f, 0.0f));
m_object->SetAngleZ(2, 0.0f);
@@ -752,21 +700,19 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller4s.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller4s.mod", false, rank);
m_object->SetPosition(3, Math::Vector(0.0f, 1.0f, 0.0f));
m_object->SetAngleZ(3, 0.0f);
}
- if ( type == OBJECT_MOBILEsa )
+ if (type == OBJECT_MOBILEsa)
{
// Creates the holder.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("subm2.mod", false, rank);
m_object->SetPosition(1, Math::Vector(4.2f, 3.0f, 0.0f));
// Creates the right tong.
@@ -774,8 +720,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("subm3.mod", false, rank);
m_object->SetPosition(2, Math::Vector(0.5f, 0.0f, -1.5f));
// Creates the left tong.
@@ -783,21 +728,18 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "subm3.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("subm3.mod", true, rank);
m_object->SetPosition(3, Math::Vector(0.5f, 0.0f, 1.5f));
}
- if ( type == OBJECT_MOBILEdr )
+ if (type == OBJECT_MOBILEdr)
{
// Creates the carousel.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("drawer4.mod", false, rank);
m_object->SetPosition(1, Math::Vector(-3.0f, 3.0f, 0.0f));
// Creates the key.
@@ -807,8 +749,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("drawer5.mod", false, rank);
m_posKey = Math::Vector(3.0f, 5.7f, 0.0f);
m_object->SetPosition(2, m_posKey);
m_object->SetAngleY(2, 90.0f*Math::PI/180.0f);
@@ -821,16 +762,14 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10+i, rank);
m_object->SetObjectParent(10+i, 1);
- std::string baseName = m_app->GetDataFilePath(DIR_MODEL, "drawer%d.mod");
- sprintf(name, baseName.c_str(), 10+i);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ sprintf(name, "drawer%d.mod", 10+i);
+ modelManager->AddModelReference(name, false, rank);
m_object->SetPosition(10+i, Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetAngleY(10+i, 45.0f*Math::PI/180.0f*i);
}
}
- if ( type == OBJECT_MOBILEwt )
+ if (type == OBJECT_MOBILEwt)
{
// Creates the key.
if ( m_object->GetToy() )
@@ -839,23 +778,21 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "drawer5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("drawer5.mod", false, rank);
m_posKey = Math::Vector(0.2f, 4.1f, 0.0f);
m_object->SetPosition(2, m_posKey);
m_object->SetAngleY(2, 90.0f*Math::PI/180.0f);
}
}
- if ( type == OBJECT_APOLLO2 )
+ if (type == OBJECT_APOLLO2)
{
// Creates the accessories.
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj2.mod")); // antenna
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna
m_object->SetPosition(1, Math::Vector(5.5f, 8.8f, 2.0f));
m_object->SetAngleY(1, -120.0f*Math::PI/180.0f);
m_object->SetAngleZ(1, 45.0f*Math::PI/180.0f);
@@ -864,8 +801,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj3.mod")); // camera
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj3.mod", false, rank); // camera
m_object->SetPosition(2, Math::Vector(5.5f, 2.8f, -2.0f));
m_object->SetAngleY(2, 30.0f*Math::PI/180.0f);
@@ -874,32 +810,28 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(6, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(7, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(8, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
m_object->SetPosition(9, Math::Vector(5.75f, 1.65f, 5.00f));
// Creates mud guards.
@@ -907,56 +839,51 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj6.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj6.mod", false, rank); // wheel
m_object->SetPosition(10, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj6.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj6.mod", false, rank); // wheel
m_object->SetPosition(11, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj5.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj5.mod", false, rank); // wheel
m_object->SetPosition(12, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj5.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj5.mod", false, rank); // wheel
m_object->SetPosition(13, Math::Vector(5.75f, 1.65f, 5.00f));
}
-#if 1
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
+ if (type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs)
{
m_object->CreateShadowCircle(6.0f, 1.0f);
}
- else if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEsa )
+ else if (type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEts ||
+ type == OBJECT_MOBILEsa)
{
m_object->CreateShadowCircle(5.0f, 1.0f);
}
- else if ( type == OBJECT_MOBILEdr )
+ else if (type == OBJECT_MOBILEdr)
{
m_object->CreateShadowCircle(4.5f, 1.0f);
}
- else if ( type == OBJECT_APOLLO2 )
+ else if (type == OBJECT_APOLLO2)
{
m_object->CreateShadowCircle(7.0f, 0.8f);
}
@@ -964,50 +891,12 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
m_object->CreateShadowCircle(4.0f, 1.0f);
}
-#else
- if ( type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs )
- {
- m_object->CreateShadowCircle(6.0f, 1.0f, D3DSHADOWTANK);
- }
- else if ( type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEts )
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWTANK);
- }
- else if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEfs )
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWFLY);
- }
- else if ( type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEws )
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWWHEEL);
- }
- else if ( type == OBJECT_APOLLO2 )
- {
- m_object->CreateShadowCircle(6.0f, 0.8f);
- }
- else
- {
- m_object->CreateShadowCircle(4.0f, 1.0f, D3DSHADOWNORM);
- }
-#endif
- if ( type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEft ) // flying?
+ if (type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEft) // flying?
{
//? color.r = 0.5f-1.0f;
//? color.g = 0.2f-1.0f;
@@ -1025,9 +914,9 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics(type);
m_object->SetFloorHeight(0.0f);
- if ( power > 0.0f &&
- type != OBJECT_MOBILEdr &&
- type != OBJECT_APOLLO2 )
+ if (power > 0.0f &&
+ type != OBJECT_MOBILEdr &&
+ type != OBJECT_APOLLO2)
{
color.r = 1.0f;
color.g = 1.0f;
@@ -1036,16 +925,15 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->CreateEffectLight(20.0f, color);
// Creates the battery.
- pPower = new CObject(m_iMan);
+ pPower = new CObject();
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
pPower->SetObjectRank(0, rank);
- if ( power <= 1.0f ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "power.mod"));
- else pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "atomic.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( power <= 1.0f ) modelManager->AddModelCopy("power.mod", false, rank);
+ else modelManager->AddModelCopy("atomic.mod", false, rank);
pPower->SetPosition(0, m_object->GetCharacter()->posPower);
pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
@@ -1063,7 +951,6 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
@@ -1989,52 +1876,33 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
void CMotionVehicle::UpdateTrackMapping(float left, float right, ObjectType type)
{
- Gfx::Material mat;
- float limit[4];
- int rRank, lRank, i;
+ Gfx::Material mat;
+ mat.diffuse = Gfx::Color(1.0f, 1.0f, 1.0f); // white
+ mat.ambient = Gfx::Color(0.5f, 0.5f, 0.5f);
- memset( &mat, 0, sizeof(Gfx::Material) );
- mat.diffuse.r = 1.0f;
- mat.diffuse.g = 1.0f;
- mat.diffuse.b = 1.0f; // white
- mat.ambient.r = 0.5f;
- mat.ambient.g = 0.5f;
- mat.ambient.b = 0.5f;
+ int rRank = m_object->GetObjectRank(6);
+ int lRank = m_object->GetObjectRank(7);
- rRank = m_object->GetObjectRank(6);
- lRank = m_object->GetObjectRank(7);
-
-
- if ( type == OBJECT_MOBILEdr )
+ if (type == OBJECT_MOBILEdr)
{
- limit[0] = 0.0f;
- limit[1] = 1000000.0f;
- limit[2] = limit[1];
- limit[3] = m_engine->GetLimitLOD(1);
-
m_engine->TrackTextureMapping(rRank, mat, Gfx::ENG_RSTATE_PART1, "drawer.png", "",
- limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
+ Gfx::LOD_Constant, Gfx::ENG_TEX_MAPPING_X,
right, 1.0f, 8.0f, 192.0f, 256.0f);
m_engine->TrackTextureMapping(lRank, mat, Gfx::ENG_RSTATE_PART2, "drawer.png", "",
- limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
+ Gfx::LOD_Constant, Gfx::ENG_TEX_MAPPING_X,
left, 1.0f, 8.0f, 192.0f, 256.0f);
}
else
{
- limit[0] = 0.0f;
- limit[1] = m_engine->GetLimitLOD(0);
- limit[2] = limit[1];
- limit[3] = m_engine->GetLimitLOD(1);
-
- for ( i=0 ; i<2 ; i++ )
+ for (int i = 0; i < 2; i++)
{
m_engine->TrackTextureMapping(rRank, mat, Gfx::ENG_RSTATE_PART1, "lemt.png", "",
- limit[i*2+0], limit[i*2+1], Gfx::ENG_TEX_MAPPING_X,
+ (i == 0) ? Gfx::LOD_High : Gfx::LOD_Medium, Gfx::ENG_TEX_MAPPING_X,
right, 1.0f, 8.0f, 192.0f, 256.0f);
m_engine->TrackTextureMapping(lRank, mat, Gfx::ENG_RSTATE_PART2, "lemt.png", "",
- limit[i*2+0], limit[i*2+1], Gfx::ENG_TEX_MAPPING_X,
+ (i == 0) ? Gfx::LOD_High : Gfx::LOD_Medium, Gfx::ENG_TEX_MAPPING_X,
left, 1.0f, 8.0f, 192.0f, 256.0f);
}
}
diff --git a/src/object/motion/motionvehicle.h b/src/object/motion/motionvehicle.h
index ca60c1e..ffb25ef 100644
--- a/src/object/motion/motionvehicle.h
+++ b/src/object/motion/motionvehicle.h
@@ -26,7 +26,7 @@
class CMotionVehicle : public CMotion
{
public:
- CMotionVehicle(CInstanceManager* iMan, CObject* object);
+ CMotionVehicle(CObject* object);
~CMotionVehicle();
void DeleteObject(bool bAll=false);
diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp
index 2401ebd..ee555a8 100644
--- a/src/object/motion/motionworm.cpp
+++ b/src/object/motion/motionworm.cpp
@@ -19,7 +19,7 @@
#include "app/app.h"
-#include "graphics/engine/modelfile.h"
+#include "graphics/engine/modelmanager.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
@@ -42,8 +42,7 @@ const int WORM_PART = 7; // number of parts of a worm
// Object's constructor.
-CMotionWorm::CMotionWorm(CInstanceManager* iMan, CObject* object)
- : CMotion(iMan, object)
+CMotionWorm::CMotionWorm(CObject* object) : CMotion(object)
{
m_timeUp = 18.0f;
m_timeDown = 18.0f;
@@ -81,13 +80,10 @@ void CMotionWorm::DeleteObject(bool bAll)
bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
int rank, i;
float px;
-// if ( m_engine->GetRestCreate() < 2+WORM_PART+1 ) return false;
-
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
m_object->SetType(type);
@@ -95,8 +91,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm0.mod")); // there is no purpose!
- pModFile->CreateEngineObject(rank);
+ // This is an "empty" object, without triangles
m_object->SetPosition(0, pos);
m_object->SetAngleY(0, angle);
@@ -111,8 +106,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("worm1.mod", false, rank);
m_object->SetPosition(1, Math::Vector(px, 0.0f, 0.0f));
px -= 1.0f;
@@ -123,8 +117,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2+i, rank);
m_object->SetObjectParent(2+i, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("worm2.mod", false, rank);
m_object->SetPosition(2+i, Math::Vector(px, 0.0f, 0.0f));
px -= 1.0f;
}
@@ -134,8 +127,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2+WORM_PART, rank);
m_object->SetObjectParent(2+WORM_PART, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "worm3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("worm3.mod", false, rank);
m_object->SetPosition(2+WORM_PART, Math::Vector(px, 0.0f, 0.0f));
m_object->CreateShadowCircle(0.0f, 1.0f, Gfx::ENG_SHADOW_WORM);
@@ -148,7 +140,6 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
diff --git a/src/object/motion/motionworm.h b/src/object/motion/motionworm.h
index aed5a23..7684faf 100644
--- a/src/object/motion/motionworm.h
+++ b/src/object/motion/motionworm.h
@@ -26,7 +26,7 @@
class CMotionWorm : public CMotion
{
public:
- CMotionWorm(CInstanceManager* iMan, CObject* object);
+ CMotionWorm(CObject* object);
~CMotionWorm();
void DeleteObject(bool bAll=false);
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 2eade93..23a757a 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -27,7 +27,7 @@
#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/pyro.h"
#include "graphics/engine/terrain.h"
@@ -209,28 +209,25 @@ void uObject(CBotVar* botThis, void* user)
// Object's constructor.
-CObject::CObject(CInstanceManager* iMan)
+CObject::CObject()
{
- int i;
-
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_OBJECT, this, 500);
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_OBJECT, this, 500);
m_app = CApplication::GetInstancePointer();
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_physics = 0;
- m_brain = 0;
- m_motion = 0;
- m_auto = 0;
- m_runScript = 0;
+ m_sound = m_app->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_water = m_engine->GetWater();
+ m_particle = m_engine->GetParticle();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_displayText = m_main->GetDisplayText();
+ m_physics = nullptr;
+ m_brain = nullptr;
+ m_motion = nullptr;
+ m_auto = nullptr;
+ m_runScript = nullptr;
m_type = OBJECT_FIX;
m_id = ++g_id;
@@ -309,18 +306,18 @@ CObject::CObject(CInstanceManager* iMan)
m_infoReturn = NAN;
m_bInfoUpdate = false;
- for ( i=0 ; i<OBJECTMAXPART ; i++ )
+ for (int i=0 ; i<OBJECTMAXPART ; i++ )
{
m_objectPart[i].bUsed = false;
}
m_totalPart = 0;
- for ( i=0 ; i<4 ; i++ )
+ for (int i=0 ; i<4 ; i++ )
{
m_partiSel[i] = -1;
}
- for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
+ for (int i=0 ; i<OBJECTMAXCMDLINE ; i++ )
{
m_cmdLine[i] = NAN;
}
@@ -362,7 +359,7 @@ CObject::~CObject()
delete m_auto;
m_auto = nullptr;
- m_iMan->DeleteInstance(CLASS_OBJECT, this);
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_OBJECT, this);
m_app = nullptr;
}
@@ -376,7 +373,6 @@ void CObject::DeleteObject(bool bAll)
{
CObject* pObj;
Gfx::CPyro* pPyro;
- int i;
if ( m_botVar != 0 )
{
@@ -388,9 +384,11 @@ void CObject::DeleteObject(bool bAll)
m_camera->SetControllingObject(0);
}
- for ( i=0 ; i<1000000 ; i++ )
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
+ for (int i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
pObj->DeleteDeselList(this);
@@ -419,9 +417,9 @@ void CObject::DeleteObject(bool bAll)
}
}
#endif
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i=0 ; i<1000000 ; i++ )
{
- pPyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, i));
+ pPyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, i));
if ( pPyro == 0 ) break;
pPyro->CutObjectLink(this); // the object no longer exists
@@ -496,7 +494,7 @@ void CObject::DeleteObject(bool bAll)
m_auto->DeleteObject(bAll);
}
- for ( i=0 ; i<OBJECTMAXPART ; i++ )
+ for (int i=0 ; i<OBJECTMAXPART ; i++ )
{
if ( m_objectPart[i].bUsed )
{
@@ -753,7 +751,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
loss = 1.0f;
}
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(pyroType, this, loss);
if ( shield == 0.0f ) // dead?
@@ -2091,7 +2089,7 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_TOTO )
{
- m_motion = new CMotionToto(m_iMan, this);
+ m_motion = new CMotionToto(this);
m_motion->Create(pos, angle, type, 1.0f);
return true;
}
@@ -2099,8 +2097,8 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type,
SetTrainer(bTrainer);
SetToy(bToy);
- m_physics = new CPhysics(m_iMan, this);
- m_brain = new CBrain(m_iMan, this);
+ m_physics = new CPhysics(this);
+ m_brain = new CBrain(this);
m_physics->SetBrain(m_brain);
m_brain->SetPhysics(m_physics);
@@ -2137,11 +2135,11 @@ bool CObject::CreateVehicle(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_HUMAN ||
type == OBJECT_TECH )
{
- m_motion = new CMotionHuman(m_iMan, this);
+ m_motion = new CMotionHuman(this);
}
else
{
- m_motion = new CMotionVehicle(m_iMan, this);
+ m_motion = new CMotionVehicle(this);
}
if ( m_motion == 0 ) return false;
@@ -2181,31 +2179,31 @@ bool CObject::CreateInsect(Math::Vector pos, float angle, ObjectType type)
{
m_type = type;
- m_physics = new CPhysics(m_iMan, this);
- m_brain = new CBrain(m_iMan, this);
+ m_physics = new CPhysics(this);
+ m_brain = new CBrain(this);
m_physics->SetBrain(m_brain);
m_brain->SetPhysics(m_physics);
if ( type == OBJECT_MOTHER )
{
- m_motion = new CMotionMother(m_iMan, this);
+ m_motion = new CMotionMother(this);
}
if ( type == OBJECT_ANT )
{
- m_motion = new CMotionAnt(m_iMan, this);
+ m_motion = new CMotionAnt(this);
}
if ( type == OBJECT_SPIDER )
{
- m_motion = new CMotionSpider(m_iMan, this);
+ m_motion = new CMotionSpider(this);
}
if ( type == OBJECT_BEE )
{
- m_motion = new CMotionBee(m_iMan, this);
+ m_motion = new CMotionBee(this);
}
if ( type == OBJECT_WORM )
{
- m_motion = new CMotionWorm(m_iMan, this);
+ m_motion = new CMotionWorm(this);
}
if ( m_motion == 0 ) return false;
@@ -2250,15 +2248,10 @@ bool CObject::CreateShadowLight(float height, Gfx::Color color)
Gfx::Light light;
light.type = Gfx::LIGHT_SPOT;
- light.diffuse.r = color.r;
- light.diffuse.g = color.g;
- light.diffuse.b = color.b;
- light.position.x = pos.x;
- light.position.y = pos.y+height;
- light.position.z = pos.z;
- light.direction.x = 0.0f;
- light.direction.y = -1.0f; // against the bottom
- light.direction.z = 0.0f;
+ light.diffuse = color;
+ light.ambient = color * 0.1f;
+ light.position = Math::Vector(pos.x, pos.y+height, pos.z);
+ light.direction = Math::Vector(0.0f, -1.0f, 0.0f); // against the bottom
light.spotIntensity = 128;
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
@@ -2293,15 +2286,9 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color)
Gfx::Light light;
light.type = Gfx::LIGHT_SPOT;
- light.diffuse.r = color.r;
- light.diffuse.g = color.g;
- light.diffuse.b = color.b;
- light.position.x = 0.0f;
- light.position.y = 0.0f+height;
- light.position.z = 0.0f;
- light.direction.x = 0.0f;
- light.direction.y = -1.0f; // against the bottom
- light.direction.z = 0.0f;
+ light.diffuse = color;
+ light.position = Math::Vector(0.0f, height, 0.0f);
+ light.direction = Math::Vector(0.0f, -1.0f, 0.0f); // against the bottom
light.spotIntensity = 0.0f;
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
@@ -2351,11 +2338,10 @@ bool CObject::CreateShadowCircle(float radius, float intensity,
bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
ObjectType type, float power)
{
- Gfx::CModelFile* pModFile;
Math::Point p;
int rank, i;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -2365,8 +2351,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_PORTICO )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2375,16 +2360,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 67.0f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico3.mod", false, rank);
SetPosition(2, Math::Vector(0.0f, 0.0f, -33.0f));
SetAngleY(2, 45.0f*Math::PI/180.0f);
@@ -2392,8 +2375,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico4.mod", false, rank);
SetPosition(3, Math::Vector(50.0f, 0.0f, 0.0f));
SetAngleY(3, -60.0f*Math::PI/180.0f);
@@ -2401,8 +2383,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(4, rank);
SetObjectParent(4, 3);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico5.mod", false, rank);
SetPosition(4, Math::Vector(35.0f, 0.0f, 0.0f));
SetAngleY(4, -55.0f*Math::PI/180.0f);
@@ -2410,8 +2391,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico3.mod", false, rank);
SetPosition(5, Math::Vector(0.0f, 0.0f, 33.0f));
SetAngleY(5, -45.0f*Math::PI/180.0f);
@@ -2419,8 +2399,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(6, rank);
SetObjectParent(6, 5);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico4.mod", false, rank);
SetPosition(6, Math::Vector(50.0f, 0.0f, 0.0f));
SetAngleY(6, 60.0f*Math::PI/180.0f);
@@ -2428,8 +2407,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(7, rank);
SetObjectParent(7, 6);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico5.mod", false, rank);
SetPosition(7, Math::Vector(35.0f, 0.0f, 0.0f));
SetAngleY(7, 55.0f*Math::PI/180.0f);
@@ -2437,8 +2415,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(8, rank);
SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico6.mod", false, rank);
SetPosition(8, Math::Vector(-35.0f, 50.0f, -35.0f));
SetAngleY(8, -Math::PI/2.0f);
SetZoom(8, 2.0f);
@@ -2447,16 +2424,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(9, rank);
SetObjectParent(9, 8);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico7.mod", false, rank);
SetPosition(9, Math::Vector(0.0f, 4.5f, 1.9f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(10, rank);
SetObjectParent(10, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico6.mod", false, rank);
SetPosition(10, Math::Vector(-35.0f, 50.0f, 35.0f));
SetAngleY(10, -Math::PI/2.0f);
SetZoom(10, 2.0f);
@@ -2465,8 +2440,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(11, rank);
SetObjectParent(11, 10);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "portico7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("portico7.mod", false, rank);
SetPosition(11, Math::Vector(0.0f, 4.5f, 1.9f));
CreateCrashSphere(Math::Vector( 0.0f, 28.0f, 0.0f), 45.5f, SOUND_BOUMm, 0.45f);
@@ -2487,8 +2461,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_BASE )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "base1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("base1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2499,8 +2472,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1+i, rank);
SetObjectParent(1+i, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "base2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("base2.mod", false, rank);
p = Math::RotatePoint(-Math::PI/4.0f*i, 27.8f);
SetPosition(1+i, Math::Vector(p.x, 30.0f, p.y));
SetAngleY(1+i, Math::PI/4.0f*i);
@@ -2510,17 +2482,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(10+i, rank);
SetObjectParent(10+i, 1+i);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "base4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("base4.mod", false, rank);
SetPosition(10+i, Math::Vector(23.5f, 0.0f, 7.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(18+i, rank);
SetObjectParent(18+i, 1+i);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "base4.mod"));
- pModFile->Mirror();
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("base4.mod", true, rank);
SetPosition(18+i, Math::Vector(23.5f, 0.0f, -7.0f));
}
@@ -2528,8 +2497,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(9, rank);
SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "base3.mod")); // central pillar
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("base3.mod", false, rank); // central pillar
CreateCrashSphere(Math::Vector( 0.0f, 33.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector( 0.0f, 39.0f, 0.0f), 2.5f, SOUND_BOUMm, 0.45f);
@@ -2559,8 +2527,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_DERRICK )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "derrick1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("derrick1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2569,8 +2536,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "derrick2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("derrick2.mod", false, rank);
CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(0.0f, 10.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f);
@@ -2584,8 +2550,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_RESEARCH )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "search1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("search1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2594,16 +2559,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "search2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("search2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 13.0f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "search3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("search3.mod", false, rank);
SetPosition(2, Math::Vector(0.0f, 4.0f, 0.0f));
SetAngleZ(2, 35.0f*Math::PI/180.0f);
@@ -2619,8 +2582,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_RADAR )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "radar1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("radar1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2629,16 +2591,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "radar2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("radar2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "radar3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("radar3.mod", false, rank);
SetPosition(2, Math::Vector(0.0f, 11.0f, 0.0f));
SetAngleY(2, -Math::PI/2.0f);
@@ -2646,8 +2606,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "radar4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("radar4.mod", false, rank);
SetPosition(3, Math::Vector(0.0f, 4.5f, 1.9f));
CreateCrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f);
@@ -2659,8 +2618,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_INFO )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "info1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("info1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2669,8 +2627,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "info2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("info2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f));
for ( i=0 ; i<3 ; i++ )
@@ -2679,16 +2636,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2+i*2, rank);
SetObjectParent(2+i*2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "info3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("info3.mod", false, rank);
SetPosition(2+i*2, Math::Vector(0.0f, 4.5f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3+i*2, rank);
SetObjectParent(3+i*2, 2+i*2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "radar4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("radar4.mod", false, rank);
SetPosition(3+i*2, Math::Vector(0.0f, 0.0f, -4.0f));
SetAngleY(2+i*2, 2.0f*Math::PI/3.0f*i);
@@ -2703,8 +2658,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_ENERGY )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "energy.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("energy.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2722,8 +2676,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_LABO )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "labo1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("labo1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2732,8 +2685,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "labo2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("labo2.mod", false, rank);
SetPosition(1, Math::Vector(-9.0f, 3.0f, 0.0f));
SetAngleZ(1, Math::PI/2.0f);
@@ -2741,16 +2693,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "labo3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("labo3.mod", false, rank);
SetPosition(2, Math::Vector(9.0f, -1.0f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "labo4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("labo4.mod", false, rank);
SetPosition(3, Math::Vector(0.0f, 0.0f, 0.0f));
SetAngleZ(3, 80.0f*Math::PI/180.0f);
@@ -2758,8 +2708,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(4, rank);
SetObjectParent(4, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "labo4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("labo4.mod", false, rank);
SetPosition(4, Math::Vector(0.0f, 0.0f, 0.0f));
SetAngleZ(4, 80.0f*Math::PI/180.0f);
SetAngleY(4, Math::PI*2.0f/3.0f);
@@ -2768,8 +2717,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 2);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "labo4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("labo4.mod", false, rank);
SetPosition(5, Math::Vector(0.0f, 0.0f, 0.0f));
SetAngleZ(5, 80.0f*Math::PI/180.0f);
SetAngleY(5, -Math::PI*2.0f/3.0f);
@@ -2788,8 +2736,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_FACTORY )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "factory1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("factory1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2800,8 +2747,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1+i, rank);
SetObjectParent(1+i, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "factory2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("factory2.mod", false, rank);
SetPosition(1+i, Math::Vector(10.0f, 2.0f*i, 10.0f));
SetAngleZ(1+i, Math::PI/2.0f);
SetZoomZ(1+i, 0.30f);
@@ -2810,8 +2756,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(10+i, rank);
SetObjectParent(10+i, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "factory2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("factory2.mod", false, rank);
SetPosition(10+i, Math::Vector(10.0f, 2.0f*i, -10.0f));
SetAngleZ(10+i, -Math::PI/2.0f);
SetAngleY(10+i, Math::PI);
@@ -2848,8 +2793,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_REPAIR )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "repair1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("repair1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2858,8 +2802,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "repair2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("repair2.mod", false, rank);
SetPosition(1, Math::Vector(-11.0f, 13.5f, 0.0f));
SetAngleZ(1, Math::PI/2.0f);
@@ -2874,8 +2817,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_DESTROYER )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "destroy1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("destroy1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2884,8 +2826,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "destroy2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("destroy2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f));
m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f);
@@ -2900,8 +2841,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_STATION )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "station.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelCopy("station.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2917,8 +2857,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_CONVERT )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "convert1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("convert1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2927,16 +2866,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "convert2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("convert2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 14.0f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "convert3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("convert3.mod", false, rank);
SetPosition(2, Math::Vector(0.0f, 11.5f, 0.0f));
SetAngleX(2, -Math::PI*0.35f);
@@ -2944,8 +2881,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "convert3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("convert3.mod", false, rank);
SetPosition(3, Math::Vector(0.0f, 11.5f, 0.0f));
SetAngleY(3, Math::PI);
SetAngleX(3, -Math::PI*0.35f);
@@ -2961,8 +2897,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_TOWER )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tower.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tower.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -2971,8 +2906,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller2c.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller2c.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 20.0f, 0.0f));
SetAngleZ(1, Math::PI/2.0f);
@@ -2980,8 +2914,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "roller3c.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("roller3c.mod", false, rank);
SetPosition(2, Math::Vector(4.5f, 0.0f, 0.0f));
SetAngleZ(2, 0.0f);
@@ -2999,8 +2932,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_NUCLEAR )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "nuclear1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("nuclear1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3009,8 +2941,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "nuclear2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("nuclear2.mod", false, rank);
SetPosition(1, Math::Vector(20.0f, 10.0f, 0.0f));
SetAngleZ(1, 135.0f*Math::PI/180.0f);
@@ -3026,8 +2957,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_PARA )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "para.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("para.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3052,8 +2982,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_SAFE )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "safe1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("safe1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3062,16 +2991,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "safe2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("safe2.mod", false, rank);
SetZoom(1, 1.05f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "safe3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("safe3.mod", false, rank);
SetZoom(2, 1.05f);
m_terrain->AddBuildingLevel(pos, 18.0f, 20.0f, 1.0f, 0.5f);
@@ -3084,8 +3011,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_HUSTON )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "huston1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("huston1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3094,8 +3020,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "huston2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("huston2.mod", false, rank);
SetPosition(1, Math::Vector(0.0f, 39.0f, 30.0f));
SetAngleY(1, -Math::PI/2.0f);
SetZoom(1, 3.0f);
@@ -3104,8 +3029,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "huston3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("huston3.mod", false, rank);
SetPosition(2, Math::Vector(0.0f, 4.5f, 1.9f));
CreateCrashSphere(Math::Vector( 15.0f, 6.0f, -53.0f), 16.0f, SOUND_BOUMm, 0.45f);
@@ -3128,8 +3052,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_TARGET1 )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "target1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("target1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 1.5f);
@@ -3158,8 +3081,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_TARGET2 )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "target2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("target2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3169,8 +3091,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_NEST )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "nest.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("nest.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3182,8 +3103,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_START )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "start.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("start.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3193,8 +3113,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
if ( m_type == OBJECT_END )
{
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "end.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("end.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -3207,16 +3126,15 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
{
CObject* pPower;
- pPower = new CObject(m_iMan);
+ pPower = new CObject();
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
pPower->SetObjectRank(0, rank);
- if ( power <= 1.0f ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "power.mod"));
- else pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "atomic.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( power <= 1.0f ) modelManager->AddModelReference("power.mod", false, rank);
+ else modelManager->AddModelReference("atomic.mod", false, rank);
pPower->SetPosition(0, GetCharacter()->posPower);
pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
@@ -3237,7 +3155,6 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
CreateOtherObject(type);
m_engine->LoadAllTextures();
- delete pModFile;
return true;
}
@@ -3246,11 +3163,10 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
float power)
{
- Gfx::CModelFile* pModFile;
int rank;
float radius, height;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -3260,46 +3176,51 @@ bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
SetEnergy(power);
std::string name;
- if ( type == OBJECT_STONE ) name = m_app->GetDataFilePath(DIR_MODEL, "stone.mod");
- if ( type == OBJECT_URANIUM ) name = m_app->GetDataFilePath(DIR_MODEL, "uranium.mod");
- if ( type == OBJECT_METAL ) name = m_app->GetDataFilePath(DIR_MODEL, "metal.mod");
- if ( type == OBJECT_POWER ) name = m_app->GetDataFilePath(DIR_MODEL, "power.mod");
- if ( type == OBJECT_ATOMIC ) name = m_app->GetDataFilePath(DIR_MODEL, "atomic.mod");
- if ( type == OBJECT_BULLET ) name = m_app->GetDataFilePath(DIR_MODEL, "bullet.mod");
- if ( type == OBJECT_BBOX ) name = m_app->GetDataFilePath(DIR_MODEL, "bbox.mod");
- if ( type == OBJECT_KEYa ) name = m_app->GetDataFilePath(DIR_MODEL, "keya.mod");
- if ( type == OBJECT_KEYb ) name = m_app->GetDataFilePath(DIR_MODEL, "keyb.mod");
- if ( type == OBJECT_KEYc ) name = m_app->GetDataFilePath(DIR_MODEL, "keyc.mod");
- if ( type == OBJECT_KEYd ) name = m_app->GetDataFilePath(DIR_MODEL, "keyd.mod");
- if ( type == OBJECT_TNT ) name = m_app->GetDataFilePath(DIR_MODEL, "tnt.mod");
- if ( type == OBJECT_SCRAP1 ) name = m_app->GetDataFilePath(DIR_MODEL, "scrap1.mod");
- if ( type == OBJECT_SCRAP2 ) name = m_app->GetDataFilePath(DIR_MODEL, "scrap2.mod");
- if ( type == OBJECT_SCRAP3 ) name = m_app->GetDataFilePath(DIR_MODEL, "scrap3.mod");
- if ( type == OBJECT_SCRAP4 ) name = m_app->GetDataFilePath(DIR_MODEL, "scrap4.mod");
- if ( type == OBJECT_SCRAP5 ) name = m_app->GetDataFilePath(DIR_MODEL, "scrap5.mod");
- if ( type == OBJECT_BOMB ) name = m_app->GetDataFilePath(DIR_MODEL, "bomb.mod");
- if ( type == OBJECT_WAYPOINT ) name = m_app->GetDataFilePath(DIR_MODEL, "waypoint.mod");
- if ( type == OBJECT_SHOW ) name = m_app->GetDataFilePath(DIR_MODEL, "show.mod");
- if ( type == OBJECT_WINFIRE ) name = m_app->GetDataFilePath(DIR_MODEL, "winfire.mod");
- if ( type == OBJECT_BAG ) name = m_app->GetDataFilePath(DIR_MODEL, "bag.mod");
- if ( type == OBJECT_MARKSTONE ) name = m_app->GetDataFilePath(DIR_MODEL, "cross1.mod");
- if ( type == OBJECT_MARKURANIUM ) name = m_app->GetDataFilePath(DIR_MODEL, "cross3.mod");
- if ( type == OBJECT_MARKPOWER ) name = m_app->GetDataFilePath(DIR_MODEL, "cross2.mod");
- if ( type == OBJECT_MARKKEYa ) name = m_app->GetDataFilePath(DIR_MODEL, "crossa.mod");
- if ( type == OBJECT_MARKKEYb ) name = m_app->GetDataFilePath(DIR_MODEL, "crossb.mod");
- if ( type == OBJECT_MARKKEYc ) name = m_app->GetDataFilePath(DIR_MODEL, "crossc.mod");
- if ( type == OBJECT_MARKKEYd ) name = m_app->GetDataFilePath(DIR_MODEL, "crossd.mod");
- if ( type == OBJECT_EGG ) name = m_app->GetDataFilePath(DIR_MODEL, "egg.mod");
-
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_STONE ) name = "stone.mod";
+ if ( type == OBJECT_URANIUM ) name = "uranium.mod";
+ if ( type == OBJECT_METAL ) name = "metal.mod";
+ if ( type == OBJECT_POWER ) name = "power.mod";
+ if ( type == OBJECT_ATOMIC ) name = "atomic.mod";
+ if ( type == OBJECT_BULLET ) name = "bullet.mod";
+ if ( type == OBJECT_BBOX ) name = "bbox.mod";
+ if ( type == OBJECT_KEYa ) name = "keya.mod";
+ if ( type == OBJECT_KEYb ) name = "keyb.mod";
+ if ( type == OBJECT_KEYc ) name = "keyc.mod";
+ if ( type == OBJECT_KEYd ) name = "keyd.mod";
+ if ( type == OBJECT_TNT ) name = "tnt.mod";
+ if ( type == OBJECT_SCRAP1 ) name = "scrap1.mod";
+ if ( type == OBJECT_SCRAP2 ) name = "scrap2.mod";
+ if ( type == OBJECT_SCRAP3 ) name = "scrap3.mod";
+ if ( type == OBJECT_SCRAP4 ) name = "scrap4.mod";
+ if ( type == OBJECT_SCRAP5 ) name = "scrap5.mod";
+ if ( type == OBJECT_BOMB ) name = "bomb.mod";
+ if ( type == OBJECT_WAYPOINT ) name = "waypoint.mod";
+ if ( type == OBJECT_SHOW ) name = "show.mod";
+ if ( type == OBJECT_WINFIRE ) name = "winfire.mod";
+ if ( type == OBJECT_BAG ) name = "bag.mod";
+ if ( type == OBJECT_MARKSTONE ) name = "cross1.mod";
+ if ( type == OBJECT_MARKURANIUM ) name = "cross3.mod";
+ if ( type == OBJECT_MARKPOWER ) name = "cross2.mod";
+ if ( type == OBJECT_MARKKEYa ) name = "crossa.mod";
+ if ( type == OBJECT_MARKKEYb ) name = "crossb.mod";
+ if ( type == OBJECT_MARKKEYc ) name = "crossc.mod";
+ if ( type == OBJECT_MARKKEYd ) name = "crossd.mod";
+ if ( type == OBJECT_EGG ) name = "egg.mod";
+
+ if (type == OBJECT_POWER || type == OBJECT_ATOMIC)
+ {
+ modelManager->AddModelCopy(name, false, rank);
+ }
+ else
+ {
+ modelManager->AddModelReference(name, false, rank);
+ }
SetPosition(0, pos);
SetAngleY(0, angle);
if ( type == OBJECT_SHOW ) // remains in the air?
{
- delete pModFile;
return true;
}
@@ -3352,7 +3273,6 @@ bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
pos.y += height;
SetPosition(0, pos); // to display the shadows immediately
- delete pModFile;
return true;
}
@@ -3360,36 +3280,34 @@ bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank, i;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
std::string name;
name = "";
- if ( type == OBJECT_FLAGb ) name = m_app->GetDataFilePath(DIR_MODEL, "flag1b.mod");
- if ( type == OBJECT_FLAGr ) name = m_app->GetDataFilePath(DIR_MODEL, "flag1r.mod");
- if ( type == OBJECT_FLAGg ) name = m_app->GetDataFilePath(DIR_MODEL, "flag1g.mod");
- if ( type == OBJECT_FLAGy ) name = m_app->GetDataFilePath(DIR_MODEL, "flag1y.mod");
- if ( type == OBJECT_FLAGv ) name = m_app->GetDataFilePath(DIR_MODEL, "flag1v.mod");
+ if ( type == OBJECT_FLAGb ) name = "flag1b.mod";
+ if ( type == OBJECT_FLAGr ) name = "flag1r.mod";
+ if ( type == OBJECT_FLAGg ) name = "flag1g.mod";
+ if ( type == OBJECT_FLAGy ) name = "flag1y.mod";
+ if ( type == OBJECT_FLAGv ) name = "flag1v.mod";
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
name = "";
- if ( type == OBJECT_FLAGb ) name = m_app->GetDataFilePath(DIR_MODEL, "flag2b.mod");
- if ( type == OBJECT_FLAGr ) name = m_app->GetDataFilePath(DIR_MODEL, "flag2r.mod");
- if ( type == OBJECT_FLAGg ) name = m_app->GetDataFilePath(DIR_MODEL, "flag2g.mod");
- if ( type == OBJECT_FLAGy ) name = m_app->GetDataFilePath(DIR_MODEL, "flag2y.mod");
- if ( type == OBJECT_FLAGv ) name = m_app->GetDataFilePath(DIR_MODEL, "flag2v.mod");
+ if ( type == OBJECT_FLAGb ) name = "flag2b.mod";
+ if ( type == OBJECT_FLAGr ) name = "flag2r.mod";
+ if ( type == OBJECT_FLAGg ) name = "flag2g.mod";
+ if ( type == OBJECT_FLAGy ) name = "flag2y.mod";
+ if ( type == OBJECT_FLAGv ) name = "flag2v.mod";
for ( i=0 ; i<4 ; i++ )
{
@@ -3397,8 +3315,7 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1+i, rank);
SetObjectParent(1+i, i);
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference(name, false, rank);
if ( i == 0 ) SetPosition(1+i, Math::Vector(0.15f, 5.0f, 0.0f));
else SetPosition(1+i, Math::Vector(0.79f, 0.0f, 0.0f));
}
@@ -3414,7 +3331,6 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
- delete pModFile;
return true;
}
@@ -3423,10 +3339,9 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -3435,8 +3350,7 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "barrier0.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("barrier0.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3452,8 +3366,7 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "barrier1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("barrier1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3471,8 +3384,7 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "barrier2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("barrier2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3490,8 +3402,7 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "barrier3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("barrier3.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3515,7 +3426,6 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
pos.y += height;
SetPosition(0, pos);
- delete pModFile;
return true;
}
@@ -3524,10 +3434,9 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -3540,12 +3449,11 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- if ( type == OBJECT_PLANT0 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant0.mod"));
- if ( type == OBJECT_PLANT1 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant1.mod"));
- if ( type == OBJECT_PLANT2 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant2.mod"));
- if ( type == OBJECT_PLANT3 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant3.mod"));
- if ( type == OBJECT_PLANT4 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant4.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_PLANT0 ) modelManager->AddModelReference("plant0.mod", false, rank);
+ if ( type == OBJECT_PLANT1 ) modelManager->AddModelReference("plant1.mod", false, rank);
+ if ( type == OBJECT_PLANT2 ) modelManager->AddModelReference("plant2.mod", false, rank);
+ if ( type == OBJECT_PLANT3 ) modelManager->AddModelReference("plant3.mod", false, rank);
+ if ( type == OBJECT_PLANT4 ) modelManager->AddModelReference("plant4.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3565,10 +3473,9 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- if ( type == OBJECT_PLANT5 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant5.mod"));
- if ( type == OBJECT_PLANT6 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant6.mod"));
- if ( type == OBJECT_PLANT7 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant7.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_PLANT5 ) modelManager->AddModelReference("plant5.mod", false, rank);
+ if ( type == OBJECT_PLANT6 ) modelManager->AddModelReference("plant6.mod", false, rank);
+ if ( type == OBJECT_PLANT7 ) modelManager->AddModelReference("plant7.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3584,9 +3491,8 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- if ( type == OBJECT_PLANT8 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant8.mod"));
- if ( type == OBJECT_PLANT9 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant9.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_PLANT8 ) modelManager->AddModelReference("plant8.mod", false, rank);
+ if ( type == OBJECT_PLANT9 ) modelManager->AddModelReference("plant9.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3605,12 +3511,11 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- if ( type == OBJECT_PLANT10 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant10.mod"));
- if ( type == OBJECT_PLANT11 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant11.mod"));
- if ( type == OBJECT_PLANT12 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant12.mod"));
- if ( type == OBJECT_PLANT13 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant13.mod"));
- if ( type == OBJECT_PLANT14 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant14.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_PLANT10 ) modelManager->AddModelReference("plant10.mod", false, rank);
+ if ( type == OBJECT_PLANT11 ) modelManager->AddModelReference("plant11.mod", false, rank);
+ if ( type == OBJECT_PLANT12 ) modelManager->AddModelReference("plant12.mod", false, rank);
+ if ( type == OBJECT_PLANT13 ) modelManager->AddModelReference("plant13.mod", false, rank);
+ if ( type == OBJECT_PLANT14 ) modelManager->AddModelReference("plant14.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3630,12 +3535,11 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- if ( type == OBJECT_PLANT15 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant15.mod"));
- if ( type == OBJECT_PLANT16 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant16.mod"));
- if ( type == OBJECT_PLANT17 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant17.mod"));
- if ( type == OBJECT_PLANT18 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant18.mod"));
- if ( type == OBJECT_PLANT19 ) pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "plant19.mod"));
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_PLANT15 ) modelManager->AddModelReference("plant15.mod", false, rank);
+ if ( type == OBJECT_PLANT16 ) modelManager->AddModelReference("plant16.mod", false, rank);
+ if ( type == OBJECT_PLANT17 ) modelManager->AddModelReference("plant17.mod", false, rank);
+ if ( type == OBJECT_PLANT18 ) modelManager->AddModelReference("plant18.mod", false, rank);
+ if ( type == OBJECT_PLANT19 ) modelManager->AddModelReference("plant19.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3654,8 +3558,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tree0.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tree0.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3672,8 +3575,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tree1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tree1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3691,8 +3593,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tree2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tree2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3710,8 +3611,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tree3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tree3.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3728,8 +3628,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tree4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tree4.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3745,8 +3644,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "tree5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("tree5.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3767,7 +3665,6 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
pos.y += height;
SetPosition(0, pos);
- delete pModFile;
return true;
}
@@ -3776,10 +3673,9 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -3788,8 +3684,7 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mush1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mush1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3805,8 +3700,7 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "mush2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("mush2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -3827,7 +3721,6 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
pos.y += height;
SetPosition(0, pos);
- delete pModFile;
return true;
}
@@ -3836,14 +3729,13 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
Math::Matrix* mat;
Gfx::Color color;
int rank;
float fShadow;
bool bFloorAdjust = true;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -3854,8 +3746,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen0.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen0.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3874,8 +3765,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3896,8 +3786,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3919,8 +3808,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen3.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3935,8 +3823,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen4.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3957,8 +3844,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen5.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3974,8 +3860,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen6.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen6.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -3995,8 +3880,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen7.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen7.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4016,8 +3900,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen8.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen8.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4038,8 +3921,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen9.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen9.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4060,8 +3942,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen10.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen10.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4086,8 +3967,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen11.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen11.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -4111,8 +3991,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen12.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen12.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4127,8 +4006,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen13.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen13.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4152,8 +4030,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen14.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen14.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4177,8 +4054,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen15.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen15.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4202,8 +4078,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen16.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen16.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4220,8 +4095,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen17.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen17.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4236,8 +4110,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen18.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen18.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4252,8 +4125,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen19.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen19.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4268,8 +4140,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen20.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen20.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4289,8 +4160,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen21.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen21.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4301,8 +4171,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen22.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen22.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4318,8 +4187,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen23.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen23.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4345,8 +4213,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen24.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen24.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4361,8 +4228,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen25.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen25.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4377,8 +4243,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen26.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen26.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4401,8 +4266,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen27.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen27.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4417,8 +4281,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen28.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen28.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4432,8 +4295,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen29.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen29.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4445,8 +4307,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen30.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen30.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4461,8 +4322,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen31.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen31.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4480,8 +4340,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen32.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen32.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4499,8 +4358,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen33.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen33.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4514,8 +4372,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen34.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen34.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4529,8 +4386,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen35.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen35.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4548,8 +4404,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen36.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen36.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4561,8 +4416,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen37.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen37.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4574,8 +4428,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen38a.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen38a.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4584,16 +4437,14 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen38b.mod")); // engine
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen38b.mod", false, rank); // engine
SetPosition(1, Math::Vector(0.0f, 30.0f, 0.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen38c.mod")); // propeller
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen38c.mod", false, rank); // propeller
SetPosition(2, Math::Vector(0.0f, 0.0f, 0.0f));
CreateCrashSphere(Math::Vector(0.0f, 2.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f);
@@ -4606,8 +4457,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen39.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen39.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4622,8 +4472,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen40.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen40.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4638,8 +4487,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen41.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen41.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4650,8 +4498,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen42.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen42.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4665,8 +4512,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen43.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen43.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4680,8 +4526,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "teen44.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("teen44.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, zoom);
@@ -4706,7 +4551,6 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
pos.y += height;
SetPosition(0, pos);
- delete pModFile;
return true;
}
@@ -4715,11 +4559,10 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
float radius;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -4728,8 +4571,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "quartz0.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("quartz0.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -4743,8 +4585,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "quartz1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("quartz1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -4758,8 +4599,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "quartz2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("quartz2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -4773,8 +4613,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "quartz3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("quartz3.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -4817,7 +4656,6 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
- delete pModFile;
return true;
}
@@ -4826,10 +4664,9 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -4838,8 +4675,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root0.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root0.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 2.0f);
@@ -4860,8 +4696,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 2.0f);
@@ -4882,8 +4717,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root2.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 2.0f);
@@ -4903,8 +4737,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root3.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root3.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 2.0f);
@@ -4926,8 +4759,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root4.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 2.0f);
@@ -4951,8 +4783,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root4.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root4.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 2.0f);
@@ -4961,8 +4792,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "root5.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("root5.mod", false, rank);
SetPosition(1, Math::Vector(-5.0f, 28.0f, -4.0f));
SetAngleX(1, -30.0f*Math::PI/180.0f);
SetAngleZ(1, 20.0f*Math::PI/180.0f);
@@ -4992,7 +4822,6 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
pos.y += height;
SetPosition(0, pos);
- delete pModFile;
return true;
}
@@ -5001,10 +4830,9 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
bool CObject::CreateHome(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -5013,8 +4841,7 @@ bool CObject::CreateHome(Math::Vector pos, float angle, float height,
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "home1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("home1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 1.3f);
@@ -5034,7 +4861,6 @@ bool CObject::CreateHome(Math::Vector pos, float angle, float height,
pos.y += height;
SetPosition(0, pos);
- delete pModFile;
return true;
}
@@ -5043,10 +4869,9 @@ bool CObject::CreateHome(Math::Vector pos, float angle, float height,
bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -5055,22 +4880,21 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(0, rank);
std::string name;
- if ( type == OBJECT_RUINmobilew1 ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin1.mod");
- if ( type == OBJECT_RUINmobilew2 ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin1.mod");
- if ( type == OBJECT_RUINmobilet1 ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin2.mod");
- if ( type == OBJECT_RUINmobilet2 ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin2.mod");
- if ( type == OBJECT_RUINmobiler1 ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin3.mod");
- if ( type == OBJECT_RUINmobiler2 ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin3.mod");
- if ( type == OBJECT_RUINfactory ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin4.mod");
- if ( type == OBJECT_RUINdoor ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin5.mod");
- if ( type == OBJECT_RUINsupport ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin6.mod");
- if ( type == OBJECT_RUINradar ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin7.mod");
- if ( type == OBJECT_RUINconvert ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin8.mod");
- if ( type == OBJECT_RUINbase ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin9.mod");
- if ( type == OBJECT_RUINhead ) name = m_app->GetDataFilePath(DIR_MODEL, "ruin10.mod");
-
- pModFile->ReadModel(name);
- pModFile->CreateEngineObject(rank);
+ if ( type == OBJECT_RUINmobilew1 ) name = "ruin1.mod";
+ if ( type == OBJECT_RUINmobilew2 ) name = "ruin1.mod";
+ if ( type == OBJECT_RUINmobilet1 ) name = "ruin2.mod";
+ if ( type == OBJECT_RUINmobilet2 ) name = "ruin2.mod";
+ if ( type == OBJECT_RUINmobiler1 ) name = "ruin3.mod";
+ if ( type == OBJECT_RUINmobiler2 ) name = "ruin3.mod";
+ if ( type == OBJECT_RUINfactory ) name = "ruin4.mod";
+ if ( type == OBJECT_RUINdoor ) name = "ruin5.mod";
+ if ( type == OBJECT_RUINsupport ) name = "ruin6.mod";
+ if ( type == OBJECT_RUINradar ) name = "ruin7.mod";
+ if ( type == OBJECT_RUINconvert ) name = "ruin8.mod";
+ if ( type == OBJECT_RUINbase ) name = "ruin9.mod";
+ if ( type == OBJECT_RUINhead ) name = "ruin10.mod";
+
+ modelManager->AddModelReference(name, false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
@@ -5083,8 +4907,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(6, rank);
SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin1w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin1w.mod", false, rank);
SetPosition(6, Math::Vector(-3.0f, 1.8f, -4.0f));
SetAngleX(6, -Math::PI/2.0f);
@@ -5095,8 +4918,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(7, rank);
SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin1w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin1w.mod", false, rank);
SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f));
SetAngleY(7, Math::PI-0.3f);
@@ -5108,8 +4930,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(8, rank);
SetObjectParent(8, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin1w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin1w.mod", false, rank);
SetPosition(8, Math::Vector(2.0f, 1.6f, -3.0f));
SetAngleY(8, 0.3f);
@@ -5120,8 +4941,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(9, rank);
SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin1w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin1w.mod", false, rank);
SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f));
SetAngleY(9, Math::PI-0.2f);
@@ -5141,8 +4961,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(7, rank);
SetObjectParent(7, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin1w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin1w.mod", false, rank);
SetPosition(7, Math::Vector(-3.0f, 1.0f, 3.0f));
SetAngleY(7, Math::PI+0.3f);
@@ -5154,8 +4973,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(9, rank);
SetObjectParent(9, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin1w.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin1w.mod", false, rank);
SetPosition(9, Math::Vector(2.0f, 1.0f, 3.0f));
SetAngleY(9, Math::PI+0.3f);
@@ -5175,8 +4993,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "ruin2c.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("ruin2c.mod", false, rank);
SetPosition(1, Math::Vector(3.0f, 5.0f, -2.5f));
SetAngleX(1, -Math::PI*0.85f);
@@ -5458,7 +5275,6 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
SetAngleX(0, angle);
}
- delete pModFile;
return true;
}
@@ -5466,10 +5282,9 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
{
- Gfx::CModelFile* pModFile;
int rank, i;
- pModFile = new Gfx::CModelFile(m_iMan);
+ Gfx::CModelManager* modelManager = Gfx::CModelManager::GetInstancePointer();
SetType(type);
@@ -5478,8 +5293,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apollol1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apollol1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetZoom(0, 1.2f);
@@ -5491,8 +5305,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(i+1, rank);
SetObjectParent(i+1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apollol2.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apollol2.mod", false, rank);
SetAngleY(i+1, Math::PI/2.0f*i);
}
@@ -5500,8 +5313,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apollol3.mod")); // ladder
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apollol3.mod", false, rank); // ladder
//? m_terrain->AddBuildingLevel(pos, 10.0f, 13.0f, 12.0f, 0.0f);
@@ -5521,8 +5333,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); //it is a stationary object
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj1.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj1.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -5532,32 +5343,28 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
SetPosition(1, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
SetPosition(2, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
SetPosition(3, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(4, rank);
SetObjectParent(4, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj4.mod")); // wheel
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj4.mod", false, rank); // wheel
SetPosition(4, Math::Vector(5.75f, 1.65f, 5.0f));
// Accessories:
@@ -5565,8 +5372,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj2.mod")); // antenna
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna
SetPosition(5, Math::Vector(5.5f, 8.8f, 2.0f));
SetAngleY(5, -120.0f*Math::PI/180.0f);
SetAngleZ(5, 45.0f*Math::PI/180.0f);
@@ -5575,8 +5381,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(6, rank);
SetObjectParent(6, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj3.mod")); // camera
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj3.mod", false, rank); // camera
SetPosition(6, Math::Vector(5.5f, 2.8f, -2.0f));
SetAngleY(6, 30.0f*Math::PI/180.0f);
@@ -5594,8 +5399,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apollof.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apollof.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -5609,8 +5413,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apollom.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apollom.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -5626,8 +5429,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloa.mod"));
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloa.mod", false, rank);
SetPosition(0, pos);
SetAngleY(0, angle);
SetFloorHeight(0.0f);
@@ -5636,8 +5438,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
- pModFile->ReadModel(m_app->GetDataFilePath(DIR_MODEL, "apolloj2.mod")); // antenna
- pModFile->CreateEngineObject(rank);
+ modelManager->AddModelReference("apolloj2.mod", false, rank); // antenna
SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f));
SetAngleY(1, -120.0f*Math::PI/180.0f);
SetAngleZ(1, 45.0f*Math::PI/180.0f);
@@ -5651,7 +5452,6 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
- delete pModFile;
return true;
}
@@ -5661,91 +5461,91 @@ void CObject::CreateOtherObject(ObjectType type)
{
if ( type == OBJECT_BASE )
{
- m_auto = new CAutoBase(m_iMan, this);
+ m_auto = new CAutoBase(this);
}
if ( type == OBJECT_PORTICO )
{
- m_auto = new CAutoPortico(m_iMan, this);
+ m_auto = new CAutoPortico(this);
}
if ( type == OBJECT_DERRICK )
{
- m_auto = new CAutoDerrick(m_iMan, this);
+ m_auto = new CAutoDerrick(this);
}
if ( type == OBJECT_FACTORY )
{
- m_auto = new CAutoFactory(m_iMan, this);
+ m_auto = new CAutoFactory(this);
}
if ( type == OBJECT_REPAIR )
{
- m_auto = new CAutoRepair(m_iMan, this);
+ m_auto = new CAutoRepair(this);
}
if ( type == OBJECT_DESTROYER )
{
- m_auto = new CAutoDestroyer(m_iMan, this);
+ m_auto = new CAutoDestroyer(this);
}
if ( type == OBJECT_STATION )
{
- m_auto = new CAutoStation(m_iMan, this);
+ m_auto = new CAutoStation(this);
}
if ( type == OBJECT_CONVERT )
{
- m_auto = new CAutoConvert(m_iMan, this);
+ m_auto = new CAutoConvert(this);
}
if ( type == OBJECT_TOWER )
{
- m_auto = new CAutoTower(m_iMan, this);
+ m_auto = new CAutoTower(this);
}
if ( type == OBJECT_RESEARCH )
{
- m_auto = new CAutoResearch(m_iMan, this);
+ m_auto = new CAutoResearch(this);
}
if ( type == OBJECT_RADAR )
{
- m_auto = new CAutoRadar(m_iMan, this);
+ m_auto = new CAutoRadar(this);
}
if ( type == OBJECT_INFO )
{
- m_auto = new CAutoInfo(m_iMan, this);
+ m_auto = new CAutoInfo(this);
}
if ( type == OBJECT_ENERGY )
{
- m_auto = new CAutoEnergy(m_iMan, this);
+ m_auto = new CAutoEnergy(this);
}
if ( type == OBJECT_LABO )
{
- m_auto = new CAutoLabo(m_iMan, this);
+ m_auto = new CAutoLabo(this);
}
if ( type == OBJECT_NUCLEAR )
{
- m_auto = new CAutoNuclear(m_iMan, this);
+ m_auto = new CAutoNuclear(this);
}
if ( type == OBJECT_PARA )
{
- m_auto = new CAutoPara(m_iMan, this);
+ m_auto = new CAutoPara(this);
}
if ( type == OBJECT_SAFE )
{
- m_auto = new CAutoSafe(m_iMan, this);
+ m_auto = new CAutoSafe(this);
}
if ( type == OBJECT_HUSTON )
{
- m_auto = new CAutoHuston(m_iMan, this);
+ m_auto = new CAutoHuston(this);
}
if ( type == OBJECT_EGG )
{
- m_auto = new CAutoEgg(m_iMan, this);
+ m_auto = new CAutoEgg(this);
}
if ( type == OBJECT_NEST )
{
- m_auto = new CAutoNest(m_iMan, this);
+ m_auto = new CAutoNest(this);
}
if ( type == OBJECT_ROOT5 )
{
- m_auto = new CAutoRoot(m_iMan, this);
+ m_auto = new CAutoRoot(this);
}
if ( type == OBJECT_MUSHROOM2 )
{
- m_auto = new CAutoMush(m_iMan, this);
+ m_auto = new CAutoMush(this);
}
if ( type == OBJECT_FLAGb ||
type == OBJECT_FLAGr ||
@@ -5753,13 +5553,13 @@ void CObject::CreateOtherObject(ObjectType type)
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv )
{
- m_auto = new CAutoFlag(m_iMan, this);
+ m_auto = new CAutoFlag(this);
}
if ( type == OBJECT_TEEN36 || // trunk?
type == OBJECT_TEEN37 || // boat?
type == OBJECT_TEEN38 ) // fan?
{
- m_auto = new CAutoKid(m_iMan, this);
+ m_auto = new CAutoKid(this);
}
}
@@ -6005,21 +5805,16 @@ void CObject::FlatParent()
void CObject::UpdateEnergyMapping()
{
- Gfx::Material mat;
- float a, b, i, s, au, bu;
- float limit[6];
- int j;
+ if (Math::IsEqual(m_energy, m_lastEnergy, 0.01f))
+ return;
- if ( fabs(m_energy-m_lastEnergy) < 0.01f ) return;
m_lastEnergy = m_energy;
- memset(&mat, 0, sizeof(mat));
- mat.diffuse.r = 1.0f;
- mat.diffuse.g = 1.0f;
- mat.diffuse.b = 1.0f; // white
- mat.ambient.r = 0.5f;
- mat.ambient.g = 0.5f;
- mat.ambient.b = 0.5f;
+ Gfx::Material mat;
+ mat.diffuse = Gfx::Color(1.0f, 1.0f, 1.0f); // white
+ mat.ambient = Gfx::Color(0.5f, 0.5f, 0.5f);
+
+ float a = 0.0f, b = 0.0f;
if ( m_type == OBJECT_POWER ||
m_type == OBJECT_ATOMIC )
@@ -6027,35 +5822,30 @@ void CObject::UpdateEnergyMapping()
a = 2.0f;
b = 0.0f; // dimensions of the battery (according to y)
}
- if ( m_type == OBJECT_STATION )
+ else if ( m_type == OBJECT_STATION )
{
a = 10.0f;
b = 4.0f; // dimensions of the battery (according to y)
}
- if ( m_type == OBJECT_ENERGY )
+ else if ( m_type == OBJECT_ENERGY )
{
a = 9.0f;
b = 3.0f; // dimensions of the battery (according to y)
}
- i = 0.50f+0.25f*m_energy; // origin
- s = i+0.25f; // width
+ float i = 0.50f+0.25f*m_energy; // origin
+ float s = i+0.25f; // width
- au = (s-i)/(b-a);
- bu = s-b*(s-i)/(b-a);
+ float au = (s-i)/(b-a);
+ float bu = s-b*(s-i)/(b-a);
- limit[0] = 0.0f;
- limit[1] = m_engine->GetLimitLOD(0);
- limit[2] = limit[1];
- limit[3] = m_engine->GetLimitLOD(1);
- limit[4] = limit[3];
- limit[5] = 1000000.0f;
+ Gfx::LODLevel lodLevels[3] = { Gfx::LOD_High, Gfx::LOD_Medium, Gfx::LOD_Low };
- for ( j=0 ; j<3 ; j++ )
+ for (int j = 0; j < 3; j++)
{
m_engine->ChangeTextureMapping(m_objectPart[0].object,
mat, Gfx::ENG_RSTATE_PART3, "lemt.png", "",
- limit[j*2+0], limit[j*2+1], Gfx::ENG_TEX_MAPPING_1Y,
+ lodLevels[j], Gfx::ENG_TEX_MAPPING_1Y,
au, bu, 1.0f, 0.0f);
}
}
@@ -6183,7 +5973,7 @@ bool CObject::EventFrame(const Event &event)
m_bProxyActivate = false;
m_main->CreateShortcuts();
m_sound->Play(SOUND_FINDING);
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FINDING, this, 0.0f);
m_displayText->DisplayError(INFO_FINDING, this);
}
@@ -6437,12 +6227,12 @@ void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
void CObject::SetCharacter(Character* character)
{
- memcpy(&m_character, character, sizeof(m_character));
+ memcpy(&m_character, character, sizeof(Character));
}
void CObject::GetCharacter(Character* character)
{
- memcpy(character, &m_character, sizeof(character));
+ memcpy(character, &m_character, sizeof(Character));
}
Character* CObject::GetCharacter()
@@ -6657,7 +6447,7 @@ bool CObject::JostleObject(float force)
{
if ( m_auto != 0 ) return false;
- m_auto = new CAutoJostle(m_iMan, this);
+ m_auto = new CAutoJostle(this);
pa = static_cast<CAutoJostle*>(m_auto);
pa->Start(0, force);
}
@@ -6821,7 +6611,7 @@ void CObject::SetSelect(bool bMode, bool bDisplayError)
if ( !m_bSelect )
{
- SetGunGoalH(0.0f); // puts the cannon right
+ //SetGunGoalH(0.0f); // puts the cannon right
return; // selects if not finished
}
@@ -7197,7 +6987,7 @@ void CObject::CreateSelectParticle()
}
}
- if ( m_bSelect || IsProgram() )
+ if ( m_bSelect || IsProgram() || m_main->GetRetroMode() )
{
// Creates particles lens for the headlights.
if ( m_type == OBJECT_MOBILEfa ||
@@ -7251,7 +7041,7 @@ void CObject::UpdateSelectParticle()
float angle;
int i;
- if ( !m_bSelect && !IsProgram() ) return;
+ if ( !m_bSelect && !IsProgram() && !m_main->GetRetroMode() ) return;
dim[0].x = 1.0f;
dim[1].x = 1.0f;
@@ -7374,7 +7164,8 @@ void CObject::UpdateSelectParticle()
zoom[2] = 1.0f;
zoom[3] = 1.0f;
- if ( IsProgram() && // current program?
+ if ( ( IsProgram() || // current program?
+ m_main->GetRetroMode() ) && // Retro mode?
Math::Mod(m_aTime, 0.7f) < 0.3f )
{
zoom[0] = 0.0f; // blinks
diff --git a/src/object/object.h b/src/object/object.h
index 8d8baca..4d8cc02 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -28,7 +28,6 @@
#include "sound/sound.h"
-class CInstanceManager;
class CApplication;
class CPhysics;
class CBrain;
@@ -39,8 +38,7 @@ class CRobotMain;
class CBotVar;
class CScript;
-namespace Ui
-{
+namespace Ui {
class CDisplayText;
}
@@ -377,7 +375,7 @@ enum RadarFilter
class CObject
{
public:
- CObject(CInstanceManager* iMan);
+ CObject();
~CObject();
void DeleteObject(bool bAll=false);
@@ -679,7 +677,6 @@ protected:
void UpdateSelectParticle();
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index aa2fe22..c1e4140 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -80,7 +80,7 @@
#include "ui/window.h"
-template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr;
+template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
// TODO: remove once using std::string
@@ -606,29 +606,27 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception)
//! Constructor of robot application
-CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
+CRobotMain::CRobotMain(CApplication* app)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_MAIN, this);
-
m_app = app;
- m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD));
- m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ));
- m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_eventQueue = m_app->GetEventQueue();
+ m_sound = m_app->GetSound();
+
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_cloud = m_engine->GetCloud();
+ m_lightning = m_engine->GetLightning();
+ m_planet = m_engine->GetPlanet();
m_interface = new Ui::CInterface();
- m_terrain = new Gfx::CTerrain(m_iMan);
- m_camera = new Gfx::CCamera(m_iMan);
+ m_terrain = new Gfx::CTerrain();
+ m_camera = new Gfx::CCamera();
m_displayText = new Ui::CDisplayText();
- m_movie = new CMainMovie(m_iMan);
- m_dialog = new Ui::CMainDialog(m_iMan);
+ m_movie = new CMainMovie();
+ m_dialog = new Ui::CMainDialog();
m_short = new Ui::CMainShort();
m_map = new Ui::CMainMap();
m_displayInfo = nullptr;
@@ -651,8 +649,17 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
m_selectObject = 0;
m_infoUsed = 0;
+ m_beginObject = false;
+ m_terrainGenerate = false;
+ m_terrainInit = false;
+ m_terrainInitTextures = false;
+ m_terrainCreate = false;
+
+ m_version = 1;
+ m_retroStyle = false;
m_immediatSatCom = false;
m_beginSatCom = false;
+ m_lockedSatCom = false;
m_movieLock = false;
m_satComLock = false;
m_editLock = false;
@@ -663,7 +670,11 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
m_showPos = false;
m_selectInsect = false;
m_showSoluce = false;
+ #ifdef NDEBUG
+ m_showAll = false;
+ #else
m_showAll = true; // for development
+ #endif
m_cheatRadar = false;
m_fixScene = false;
m_trainerPilot = false;
@@ -857,10 +868,29 @@ CRobotMain::~CRobotMain()
delete m_map;
m_map = nullptr;
- m_iMan = nullptr;
m_app = nullptr;
}
+Gfx::CCamera* CRobotMain::GetCamera()
+{
+ return m_camera;
+}
+
+Gfx::CTerrain* CRobotMain::GetTerrain()
+{
+ return m_terrain;
+}
+
+Ui::CInterface* CRobotMain::GetInterface()
+{
+ return m_interface;
+}
+
+Ui::CDisplayText* CRobotMain::GetDisplayText()
+{
+ return m_displayText;
+}
+
//! Creates the file colobot.ini at the first time
void CRobotMain::CreateIni()
@@ -1010,7 +1040,7 @@ void CRobotMain::ChangePhase(Phase phase)
ChangePause(false);
FlushDisplayInfo();
m_engine->SetRankView(0);
- m_engine->FlushObject();
+ m_engine->DeleteAllObjects();
m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
m_engine->SetBackground("");
m_engine->SetBackForce(false);
@@ -1027,10 +1057,6 @@ void CRobotMain::ChangePhase(Phase phase)
m_cloud->Flush();
m_lightning->Flush();
m_planet->Flush();
- m_iMan->Flush(CLASS_OBJECT);
- m_iMan->Flush(CLASS_PHYSICS);
- m_iMan->Flush(CLASS_BRAIN);
- m_iMan->Flush(CLASS_PYRO);
m_interface->Flush();
ClearInterface();
FlushNewScriptName();
@@ -1042,6 +1068,12 @@ void CRobotMain::ChangePhase(Phase phase)
m_cameraZoom = 0.0f;
m_shortCut = true;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+ iMan->Flush(CLASS_OBJECT);
+ iMan->Flush(CLASS_PHYSICS);
+ iMan->Flush(CLASS_BRAIN);
+ iMan->Flush(CLASS_PYRO);
+
Math::Point dim, pos;
// Creates and hide the command console.
@@ -1105,13 +1137,13 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_mapImage)
m_map->SetFixImage(m_mapFilename);
- Math::Point ddim;
+ /*Math::Point ddim;
pos.x = 620.0f/640.0f;
pos.y = 460.0f/480.0f;
ddim.x = 20.0f/640.0f;
ddim.y = 20.0f/480.0f;
- m_interface->CreateButton(pos, ddim, 11, EVENT_BUTTON_QUIT);
+ m_interface->CreateButton(pos, ddim, 11, EVENT_BUTTON_QUIT);*/
if (m_immediatSatCom && !loading &&
m_infoFilename[SATCOM_HUSTON][0] != 0)
@@ -1123,6 +1155,7 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_phase == PHASE_WIN)
{
+ m_sound->StopAll();
if (m_endingWinRank == -1)
{
ChangePhase(PHASE_TERM);
@@ -1162,20 +1195,20 @@ void CRobotMain::ChangePhase(Phase phase)
pe->SetGenericMode(true);
pe->SetFontType(Gfx::FONT_COLOBOT);
pe->SetEditCap(false);
- pe->SetHiliteCap(false);
- pe->ReadText("help/win.txt");
+ pe->SetHighlightCap(false);
+ pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt"));
}
else
{
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f);
}
+ StartMusic();
}
- m_sound->StopAll();
- StartMusic();
}
if (m_phase == PHASE_LOST)
{
+ m_sound->StopAll();
if (m_endingLostRank == -1)
{
ChangePhase(PHASE_TERM);
@@ -1192,9 +1225,9 @@ 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();
}
- m_sound->StopAll();
- StartMusic();
}
if (m_phase == PHASE_LOADING)
@@ -1299,6 +1332,7 @@ bool CRobotMain::EventProcess(Event &event)
// Management of the console.
if (m_phase != PHASE_NAME &&
!m_movie->IsExist() &&
+ !m_movieLock && !m_editLock &&
event.type == EVENT_KEY_DOWN &&
event.key.key == KEY(PAUSE)) // Pause ?
{
@@ -1986,7 +2020,7 @@ void CRobotMain::FlushDisplayInfo()
m_infoFilename[i][0] = 0;
m_infoPos[i] = 0;
}
- strcpy(m_infoFilename[SATCOM_OBJECT], "help/objects.txt");
+ strcpy(m_infoFilename[SATCOM_OBJECT], "help/") + m_app->GetLanguageChar() + std::string("/objects.txt");
m_infoIndex = 0;
}
@@ -1994,7 +2028,7 @@ void CRobotMain::FlushDisplayInfo()
//! index: SATCOM_*
void CRobotMain::StartDisplayInfo(int index, bool movie)
{
- if (m_cmdEdit || m_satComLock) return;
+ if (m_cmdEdit || m_satComLock || m_lockedSatCom) return;
CObject* obj = GetSelect();
bool human = obj != nullptr && obj->GetType() == OBJECT_HUMAN;
@@ -2058,6 +2092,8 @@ void CRobotMain::StartDisplayInfo(const char *filename, int index)
//! End of displaying of instructions
void CRobotMain::StopDisplayInfo()
{
+ if (m_cmdEdit) return;
+
if (m_movieInfoIndex != -1) // film to read the SatCom?
m_movie->Start(MM_SATCOMclose, 2.0f);
@@ -2392,10 +2428,11 @@ CObject* CRobotMain::GetSelectObject()
//! Deselects everything, and returns the object that was selected
CObject* CRobotMain::DeselectAll()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
CObject* prev = nullptr;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetSelect()) prev = obj;
@@ -2503,10 +2540,12 @@ bool CRobotMain::DeselectObject()
//! Quickly removes all objects
void CRobotMain::DeleteAllObjects()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Removes all pyrotechnic effects in progress.
while (true)
{
- Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
+ Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, 0));
if (pyro == nullptr) break;
pyro->DeleteObject();
@@ -2526,7 +2565,7 @@ void CRobotMain::DeleteAllObjects()
while (true)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, 0));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, 0));
if (obj == nullptr) break;
obj->DeleteObject(true); // destroys rapidly
@@ -2543,9 +2582,10 @@ void CRobotMain::SelectHuman()
//! Returns the object human
CObject* CRobotMain::SearchHuman()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
ObjectType type = obj->GetType();
@@ -2558,9 +2598,10 @@ CObject* CRobotMain::SearchHuman()
//! Returns the object toto
CObject* CRobotMain::SearchToto()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
ObjectType type = obj->GetType();
@@ -2573,11 +2614,12 @@ CObject* CRobotMain::SearchToto()
//! Returns the nearest selectable object from a given position
CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
float min = 100000.0f;
CObject* best = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj == exclu) continue;
@@ -2600,9 +2642,10 @@ CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
//! Returns the selected object
CObject* CRobotMain::GetSelect()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetSelect())
@@ -2613,9 +2656,10 @@ CObject* CRobotMain::GetSelect()
CObject* CRobotMain::SearchObject(ObjectType type)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == type)
@@ -2628,10 +2672,11 @@ CObject* CRobotMain::SearchObject(ObjectType type)
CObject* CRobotMain::DetectObject(Math::Point pos)
{
int objRank = m_engine->DetectObject(pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (!obj->GetActif()) continue;
@@ -2850,7 +2895,7 @@ bool CRobotMain::DeleteObject()
CObject* obj = GetSelect();
if (obj == nullptr) return false;
- Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ Gfx::CPyro* pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, obj);
obj->SetSelect(false); // deselects the object
@@ -2873,9 +2918,11 @@ void CRobotMain::HiliteClear()
int rank = -1;
m_engine->SetHighlightRank(&rank); // nothing more selected
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
obj->SetHilite(false);
@@ -3025,7 +3072,7 @@ void CRobotMain::HelpObject()
CObject* obj = GetSelect();
if (obj == nullptr) return;
- const char* filename = GetHelpFilename(obj->GetType());
+ const char* filename = GetHelpFilename(obj->GetType()).c_str();
if (filename[0] == 0) return;
StartDisplayInfo(filename, -1);
@@ -3035,9 +3082,11 @@ void CRobotMain::HelpObject()
//! Change the mode of the camera
void CRobotMain::ChangeCamera()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetSelect())
@@ -3191,9 +3240,11 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
//! Cancels the current movie
void CRobotMain::AbortMovie()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
CAuto* automat = obj->GetAuto();
@@ -3261,13 +3312,15 @@ bool CRobotMain::EventFrame(const Event &event)
if (pm != nullptr) pm->FlushObject();
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
CObject* toto = nullptr;
if (!m_freePhoto)
{
// Advances all the robots, but not toto.
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (pm != nullptr) pm->UpdateObject(obj);
if (obj->GetTruck() != nullptr) continue;
@@ -3280,7 +3333,7 @@ bool CRobotMain::EventFrame(const Event &event)
// Advances all objects transported by robots.
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() == nullptr) continue;
obj->EventProcess(event);
@@ -3289,7 +3342,7 @@ bool CRobotMain::EventFrame(const Event &event)
// Advances pyrotechnic effects.
for (int i = 0; i < 1000000; i++)
{
- Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, i));
+ Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(iMan->SearchInstance(CLASS_PYRO, i));
if (pyro == nullptr) break;
pyro->EventProcess(event);
@@ -3439,9 +3492,11 @@ bool CRobotMain::EventObject(const Event &event)
m_resetCreate = false;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
obj->EventProcess(event);
@@ -3673,16 +3728,18 @@ void CRobotMain::Convert()
void CRobotMain::ScenePerso()
{
DeleteAllObjects(); // removes all the current 3D Scene
- m_engine->FlushObject();
+ m_engine->DeleteAllObjects();
m_terrain->FlushRelief(); // all flat
m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit();
m_lightMan->FlushLights();
m_particle->FlushParticle();
- m_iMan->Flush(CLASS_OBJECT);
- m_iMan->Flush(CLASS_PHYSICS);
- m_iMan->Flush(CLASS_BRAIN);
- m_iMan->Flush(CLASS_PYRO);
+
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+ iMan->Flush(CLASS_OBJECT);
+ iMan->Flush(CLASS_PHYSICS);
+ iMan->Flush(CLASS_BRAIN);
+ iMan->Flush(CLASS_PYRO);
m_dialog->SetSceneName("perso");
m_dialog->SetSceneRank(0);
@@ -3733,6 +3790,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_displayText->SetDelay(1.0f);
m_displayText->SetEnable(true);
m_immediatSatCom = false;
+ m_lockedSatCom = false;
m_endingWinRank = 0;
m_endingLostRank = 0;
m_endTakeTotal = 0;
@@ -3773,31 +3831,49 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_dialog->BuildResumeName(m_resume, base, rank);
GetResource(RES_TEXT, RT_SCRIPT_NEW, m_scriptName);
m_scriptFile[0] = 0;
+
+ m_beginObject = false;
+ m_terrainGenerate = false;
+ m_terrainInit = false;
+ m_terrainInitTextures = false;
+ m_terrainCreate = false;
+
+ m_version = 1;
+ m_retroStyle = false;
}
char line[500];
char name[200];
char dir[100];
char op[100];
+ char filename[500];
+ int lineNum = 0;
memset(line, 0, 500);
memset(name, 0, 200);
memset(dir, 0, 100);
memset(op, 0, 100);
+ memset(filename, 0, 500);
std::string tempLine;
m_dialog->BuildSceneName(tempLine, base, rank);
- strcpy(line, tempLine.c_str());
- FILE* file = fopen(line, "r");
+ strcpy(filename, tempLine.c_str());
+ FILE* file = fopen(filename, "r");
if (file == NULL) return;
int rankObj = 0;
int rankGadget = 0;
CObject* sel = 0;
+
+ std::string oldLocale;
char *locale = setlocale(LC_NUMERIC, nullptr);
+ if (locale != nullptr)
+ oldLocale = locale;
+
setlocale(LC_NUMERIC, "C");
while (fgets(line, 500, file) != NULL)
{
+ lineNum++;
for (int i = 0; i < 500; i++)
{
if (line[i] == '\t' ) line[i] = ' '; // replace tab by space
@@ -3808,6 +3884,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
}
+ if (Cmd(line, "MissionFile") && !resetObject)
+ m_version = OpInt(line, "version", 1);
+
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
if (Cmd(line, op) && !resetObject)
@@ -3831,6 +3910,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 (Cmd(line, "Satellite") && !resetObject)
@@ -3950,34 +4030,96 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_engine->SetForegroundName(name);
}
- if (Cmd(line, "Global") && !resetObject)
+ if (((m_version == 1 && Cmd(line, "Global")) || (m_version >= 2 && Cmd(line, "Mission"))) && !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) {
+ m_retroStyle = OpInt(line, "retro", 0);
+ if(m_retroStyle) GetLogger()->Info("Retro mode enabled.\n");
+ }
}
if (Cmd(line, "TerrainGenerate") && !resetObject)
{
+ if(m_terrainCreate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainGenerate after TerrainCreate\n", filename, lineNum);
+ continue;
+ }
+
+ if(m_terrainInit) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainGenerate after TerrainInit\n", filename, lineNum);
+ continue;
+ }
+
m_terrain->Generate(OpInt(line, "mosaic", 20),
OpInt(line, "brick", 3),
OpFloat(line, "size", 20.0f),
OpFloat(line, "vision", 500.0f)*g_unit,
OpInt(line, "depth", 2),
OpFloat(line, "hard", 0.5f));
+
+ m_terrainGenerate = true;
}
- if (Cmd(line, "TerrainWind") && !resetObject)
+ 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) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind after TerrainInit\n", filename, lineNum);
+ continue;
+ }
+
+ if(!m_terrainGenerate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind before TerrainGenerate\n", filename, lineNum);
+ continue;
+ }
+
m_terrain->SetWind(OpPos(line, "speed"));
+ }
if (Cmd(line, "TerrainRelief") && !resetObject)
{
+ if(m_terrainCreate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief after TerrainCreate\n", filename, lineNum);
+ continue;
+ }
+
+ if(m_terrainInit) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief after TerrainInit\n", filename, lineNum);
+ continue;
+ }
+
+ if(!m_terrainGenerate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief before TerrainGenerate\n", filename, lineNum);
+ continue;
+ }
+
OpString(line, "image", name);
m_terrain->LoadRelief(name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1));
}
if (Cmd(line, "TerrainResource") && !resetObject)
{
+ if(m_terrainCreate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource after TerrainCreate\n", filename, lineNum);
+ continue;
+ }
+
+ if(m_terrainInit) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource after TerrainInit\n", filename, lineNum);
+ continue;
+ }
+
+ if(!m_terrainGenerate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource before TerrainGenerate\n", filename, lineNum);
+ continue;
+ }
+
OpString(line, "image", name);
m_terrain->LoadResources(name);
}
@@ -4022,6 +4164,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "TerrainInitTextures") && !resetObject)
{
+ if(m_terrainInit) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainInitTextures and TerrainInit at same time\n", filename, lineNum);
+ continue;
+ }
+
OpString(line, "image", name);
AddExt(name, ".png");
int dx = OpInt(line, "dx", 1);
@@ -4035,17 +4182,42 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
CopyFileListToTemp(name, tt, dx*dy);
m_terrain->InitTextures(name, tt, dx, dy);
+
+ m_terrainInitTextures = true;
}
- if (Cmd(line, "TerrainInit") && !resetObject)
+ 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;
+ }
+
m_terrain->InitMaterials(OpInt(line, "id", 1));
+ m_terrainInit = true;
+ }
if (Cmd(line, "TerrainMaterial") && !resetObject)
{
+ if(m_terrainCreate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial after TerrainCreate\n", filename, lineNum);
+ continue;
+ }
+
+ if(m_terrainInit) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial after TerrainInit\n", filename, lineNum);
+ continue;
+ }
+
+ 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)
- CopyFileToTemp(name);
+ if (strstr(name, "%user%") != 0) {
+ GetProfile().CopyFileToTemp(std::string(name));
+ }
m_terrain->AddMaterial(OpInt(line, "id", 0),
name,
@@ -4060,6 +4232,26 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "TerrainLevel") && !resetObject)
{
+ if(m_terrainCreate) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel after TerrainCreate\n", filename, lineNum);
+ continue;
+ }
+
+ if(!m_terrainInit) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel before TerrainInit\n", filename, lineNum);
+ continue;
+ }
+
+ 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) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel before TerrainGenerate\n", filename, lineNum);
+ continue;
+ }
+
char* op = SearchOp(line, "id");
int id[50];
int i = 0;
@@ -4078,8 +4270,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
OpFloat(line, "radius", 0.0f)*g_unit);
}
- if (Cmd(line, "TerrainCreate") && !resetObject)
+ if (Cmd(line, "TerrainCreate") && !resetObject) {
m_terrain->CreateObjects();
+ m_terrainCreate = true;
+ }
if (Cmd(line, "BeginObject"))
{
@@ -4088,10 +4282,17 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (read[0] != 0) // loading file ?
sel = IOReadScene(read, stack);
+
+ m_beginObject = true;
}
if (Cmd(line, "CreateObject") && read[0] == 0)
{
+ if (!m_beginObject) {
+ GetLogger()->Error("Syntax error in file '%s' (line %d): CreateObject before BeginObject\n", filename, lineNum);
+ continue;
+ }
+
ObjectType type = OpTypeObject(line, "type", OBJECT_NULL);
int gadget = OpInt(line, "gadget", -1);
@@ -4130,12 +4331,13 @@ 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;
+ bool trainer = OpInt(line, "trainer", 0);
CObject* obj = CreateObject(pos, dir,
OpFloat(line, "z", 1.0f),
OpFloat(line, "h", 0.0f),
type,
OpFloat(line, "power", 1.0f),
- OpInt(line, "trainer", 0),
+ trainer,
OpInt(line, "toy", 0),
OpInt(line, "option", 0));
@@ -4155,7 +4357,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
Gfx::PyroType pType = OpPyro(line, "pyro");
if (pType != Gfx::PT_NULL)
{
- Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ Gfx::CPyro* pyro = new Gfx::CPyro();
pyro->Create(pType, obj);
}
@@ -4197,8 +4399,14 @@ 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(OpInt(line, "checkToken", 1));
- obj->SetManual(OpInt(line, "manual", 0));
+ obj->SetCheckToken(m_version >= 2 ? trainer : OpInt(line, "manual", 1));
+ obj->SetManual(m_version >= 2 ? !trainer : OpInt(line, "manual", 0));
+
+ 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);
+ }
CMotion* motion = obj->GetMotion();
if (motion != nullptr)
@@ -4528,8 +4736,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
m_dialog->SetSceneRead("");
m_dialog->SetStackRead("");
-
- setlocale(LC_NUMERIC, locale);
+
+ setlocale(LC_NUMERIC, oldLocale.c_str());
}
//! Creates an object of decoration mobile or stationary
@@ -4572,7 +4780,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_START ||
type == OBJECT_END )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateBuilding(pos, angle, height, type, power);
CAuto* automat = object->GetAuto();
@@ -4614,7 +4822,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MARKKEYd ||
type == OBJECT_EGG )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateResource(pos, angle, type, power);
}
else
@@ -4624,7 +4832,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateFlag(pos, angle, type);
}
else
@@ -4634,7 +4842,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_BARRIER3 ||
type == OBJECT_BARRIER4 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateBarrier(pos, angle, height, type);
}
else
@@ -4669,7 +4877,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_TREE8 ||
type == OBJECT_TREE9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreatePlant(pos, angle, height, type);
}
else
@@ -4684,7 +4892,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MUSHROOM8 ||
type == OBJECT_MUSHROOM9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateMushroom(pos, angle, height, type);
}
else
@@ -4739,7 +4947,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_TEEN48 ||
type == OBJECT_TEEN49 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->SetOption(option);
object->CreateTeen(pos, angle, zoom, height, type);
}
@@ -4755,7 +4963,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_QUARTZ8 ||
type == OBJECT_QUARTZ9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateQuartz(pos, angle, height, type);
}
else
@@ -4770,13 +4978,13 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_ROOT8 ||
type == OBJECT_ROOT9 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateRoot(pos, angle, height, type);
}
else
if ( type == OBJECT_HOME1 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateHome(pos, angle, height, type);
}
else
@@ -4794,7 +5002,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_RUINbase ||
type == OBJECT_RUINhead )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateRuin(pos, angle, height, type);
}
else
@@ -4803,7 +5011,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_APOLLO4 ||
type == OBJECT_APOLLO5 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateApollo(pos, angle, type);
}
else
@@ -4813,7 +5021,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_BEE ||
type == OBJECT_WORM )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->CreateInsect(pos, angle, type); // no eggs
}
else
@@ -4849,7 +5057,7 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MOBILEdr ||
type == OBJECT_APOLLO2 )
{
- object = new CObject(m_iMan);
+ object = new CObject();
object->SetOption(option);
object->CreateVehicle(pos, angle, type, power, trainer, toy);
}
@@ -4877,6 +5085,7 @@ int CRobotMain::CreateLight(Math::Vector direction, Gfx::Color color)
Gfx::Light light;
light.type = Gfx::LIGHT_DIRECTIONAL;
light.diffuse = color;
+ light.ambient = color * 0.1f;
light.direction = direction;
int obj = m_lightMan->CreateLight(Gfx::LIGHT_PRI_HIGH);
m_lightMan->SetLight(obj, light);
@@ -4894,6 +5103,7 @@ int CRobotMain::CreateSpot(Math::Vector pos, Gfx::Color color)
Gfx::Light light;
light.type = Gfx::LIGHT_SPOT;
light.diffuse = color;
+ light.ambient = color * 0.1f;
light.position = pos;
light.direction = Math::Vector(0.0f, -1.0f, 0.0f);
light.spotIntensity = 1.0f;
@@ -5069,10 +5279,12 @@ bool CRobotMain::TestGadgetQuantity(int rank)
//! Calculates the distance to the nearest object
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
float min = 100000.0f;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive?
@@ -5218,12 +5430,14 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
Math::Vector center = metal->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Calculates the maximum radius possible depending on other items.
float oMax = 30.0f; // radius to build the biggest building
float tMax;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive?
@@ -5441,13 +5655,15 @@ void CRobotMain::CompileScript(bool soluce)
int nbError = 0;
int lastError = 0;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
do
{
lastError = nbError;
nbError = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() != nullptr) continue;
@@ -5476,7 +5692,7 @@ void CRobotMain::CompileScript(bool soluce)
{
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
if (obj->GetTruck() != 0) continue;
@@ -5494,7 +5710,7 @@ void CRobotMain::CompileScript(bool soluce)
// Start all programs according to the command "run".
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() != nullptr) continue;
@@ -5569,9 +5785,11 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank,
//! Saves all programs of all the robots
void CRobotMain::SaveAllScript()
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
SaveOneScript(obj);
@@ -5706,9 +5924,11 @@ bool CRobotMain::IsBusy()
{
if (m_CompteurFileOpen > 0) return true;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
CBrain* brain = obj->GetBrain();
@@ -5851,10 +6071,12 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
fputs(line, file);
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
int objRank = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == OBJECT_TOTO) continue;
@@ -5892,7 +6114,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
objRank = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == OBJECT_TOTO) continue;
@@ -6047,7 +6269,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
if (fret != nullptr)
{
obj->SetFret(fret);
- CTaskManip* task = new CTaskManip(m_iMan, obj);
+ CTaskManip* task = new CTaskManip(obj);
task->Start(TMO_AUTO, TMA_GRAB); // holds the object!
delete task;
}
@@ -6065,6 +6287,8 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
fclose(file);
#if CBOT_STACK
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Compiles scripts.
int nbError = 0;
int lastError = 0;
@@ -6074,7 +6298,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
nbError = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetTruck() != nullptr) continue;
@@ -6100,7 +6324,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
objRank = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
if (obj->GetType() == OBJECT_TOTO) continue;
@@ -6176,10 +6400,12 @@ void CRobotMain::ResetObject()
Math::Vector pos, angle;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
// Removes all pyrotechnic effects in progress.
while ( true )
{
- pyro = static_cast<CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
+ pyro = static_cast<CPyro*>(iMan->SearchInstance(CLASS_PYRO, 0));
if ( pyro == 0 ) break;
pyro->DeleteObject();
@@ -6194,7 +6420,7 @@ void CRobotMain::ResetObject()
for ( i=0 ; i<1000000 ; i++ )
{
- obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( obj == 0 ) break;
cap = obj->GetResetCap();
@@ -6243,7 +6469,7 @@ void CRobotMain::ResetObject()
if ( pos == obj->GetPosition(0) &&
angle == obj->GetAngle(0) ) continue;
- pyro = new CPyro(m_iMan);
+ pyro = new CPyro();
pyro->Create(PT_RESET, obj);
brain = obj->GetBrain();
@@ -6273,10 +6499,13 @@ void CRobotMain::ResetCreate()
m_particle->FlushParticle();
m_terrain->FlushBuildingLevel();
- m_iMan->Flush(CLASS_OBJECT);
- m_iMan->Flush(CLASS_PHYSICS);
- m_iMan->Flush(CLASS_BRAIN);
- m_iMan->Flush(CLASS_PYRO);
+
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+ iMan->Flush(CLASS_OBJECT);
+ iMan->Flush(CLASS_PHYSICS);
+ iMan->Flush(CLASS_BRAIN);
+ iMan->Flush(CLASS_PYRO);
+
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
CreateScene(m_dialog->GetSceneSoluce(), false, true);
@@ -6285,13 +6514,13 @@ void CRobotMain::ResetCreate()
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
ResetCap cap = obj->GetResetCap();
if (cap == RESET_NONE) continue;
- Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ Gfx::CPyro* pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_RESET, obj);
}
}
@@ -6299,6 +6528,8 @@ void CRobotMain::ResetCreate()
//! Checks if the mission is over
Error CRobotMain::CheckEndMission(bool frame)
{
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int t = 0; t < m_endTakeTotal; t++)
{
if (m_endTake[t].message[0] != 0) continue;
@@ -6311,7 +6542,7 @@ Error CRobotMain::CheckEndMission(bool frame)
int nb = 0;
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == nullptr) break;
// Do not use GetActif () because an invisible worm (underground)
@@ -6545,9 +6776,11 @@ bool CRobotMain::GetRadar()
if (m_cheatRadar)
return true;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for (int i = 0; i < 1000000; i++)
{
- CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ CObject* obj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if (obj == 0) break;
ObjectType type = obj->GetType();
@@ -6572,6 +6805,10 @@ const char* CRobotMain::GetFilesDir()
return m_dialog->GetFilesDir().c_str();
}
+bool CRobotMain::GetRetroMode()
+{
+ return m_retroStyle;
+}
//! Change the player's name
void CRobotMain::SetGamerName(const char *name)
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index cb0cd7f..fe5fbd5 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -71,12 +71,10 @@ enum Phase
};
-class CInstanceManager;
class CEventQueue;
class CSoundInterface;
-namespace Gfx
-{
+namespace Gfx {
class CEngine;
class CLightManager;
class CWater;
@@ -84,17 +82,16 @@ class CCloud;
class CLightning;
class CPlanet;
class CTerrain;
-};
+}
-namespace Ui
-{
+namespace Ui {
class CMainDialog;
class CMainShort;
class CMainMap;
class CInterface;
class CDisplayText;
class CDisplayInfo;
-};
+}
struct EndTake
@@ -178,9 +175,14 @@ const int AXIS_INVALID = -1;
class CRobotMain : public CSingleton<CRobotMain>
{
public:
- CRobotMain(CInstanceManager* iMan, CApplication* app);
+ CRobotMain(CApplication* app);
~CRobotMain();
+ Gfx::CCamera* GetCamera();
+ Gfx::CTerrain* GetTerrain();
+ Ui::CInterface* GetInterface();
+ Ui::CDisplayText* GetDisplayText();
+
void CreateIni();
//! Sets the default input bindings (key and axes)
@@ -302,6 +304,7 @@ public:
const char* GetSavegameDir();
const char* GetPublicDir();
const char* GetFilesDir();
+ bool GetRetroMode();
void SetGamerName(const char *name);
char* GetGamerName();
@@ -358,7 +361,6 @@ protected:
void Convert();
void CreateScene(bool soluce, bool fixScene, bool resetObject);
- void CreateModel();
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,
@@ -390,7 +392,6 @@ protected:
void UpdateSpeedLabel();
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
CEventQueue* m_eventQueue;
CMainMovie* m_movie;
@@ -447,8 +448,18 @@ protected:
int m_delayWriteMessage;
int m_movieInfoIndex;
+ //Level Checker flags
+ bool m_beginObject;
+ bool m_terrainGenerate;
+ bool m_terrainInitTextures;
+ bool m_terrainInit;
+ bool m_terrainCreate;
+
+ int m_version; // Mission file version
+ bool m_retroStyle; // Retro
bool m_immediatSatCom; // SatCom immediately?
bool m_beginSatCom; // messages SatCom poster?
+ bool m_lockedSatCom; // SatCom locked?
bool m_movieLock; // movie in progress?
bool m_satComLock; // call of SatCom is possible?
bool m_editLock; // edition in progress?
diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp
index b310fd5..39fdccf 100644
--- a/src/object/task/task.cpp
+++ b/src/object/task/task.cpp
@@ -14,33 +14,28 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// task.cpp
-
-
-// #include <stdio.h>
#include "object/task/task.h"
-#include "common/iman.h"
-#include "object/object.h"
+#include "app/app.h"
+#include "object/object.h"
+#include "object/robotmain.h"
// Object's constructor.
-CTask::CTask(CInstanceManager* iMan, CObject* object)
+CTask::CTask(CObject* object)
{
- m_iMan = iMan;
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_water = m_engine->GetWater();
+ m_particle = m_engine->GetParticle();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_camera = m_main->GetCamera();
+ m_displayText = m_main->GetDisplayText();
m_object = object;
m_physics = m_object->GetPhysics();
diff --git a/src/object/task/task.h b/src/object/task/task.h
index 7239d48..12961ef 100644
--- a/src/object/task/task.h
+++ b/src/object/task/task.h
@@ -21,10 +21,10 @@
#include "common/event.h"
#include "common/global.h"
+
#include "math/const.h"
-class CInstanceManager;
class CBrain;
class CPhysics;
class CMotion;
@@ -64,7 +64,7 @@ const float ARM_STOCK_ANGLE3 = -70.0f*Math::PI/180.0f;
class CTask
{
public:
- CTask(CInstanceManager* iMan, CObject* object);
+ CTask(CObject* object);
virtual ~CTask();
virtual bool EventProcess(const Event &event);
@@ -73,7 +73,6 @@ public:
virtual bool Abort();
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
Gfx::CParticle* m_particle;
diff --git a/src/object/task/taskadvance.cpp b/src/object/task/taskadvance.cpp
index 0d159d2..58eb939 100644
--- a/src/object/task/taskadvance.cpp
+++ b/src/object/task/taskadvance.cpp
@@ -14,11 +14,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskadvance.cpp
#include "object/task/taskadvance.h"
#include "math/geometry.h"
+
#include "physics/physics.h"
@@ -26,8 +26,7 @@
// Object's constructor.
-CTaskAdvance::CTaskAdvance(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskAdvance::CTaskAdvance(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskadvance.h b/src/object/task/taskadvance.h
index dbb80d9..f8c672d 100644
--- a/src/object/task/taskadvance.h
+++ b/src/object/task/taskadvance.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -27,7 +28,7 @@
class CTaskAdvance : public CTask
{
public:
- CTaskAdvance(CInstanceManager* iMan, CObject* object);
+ CTaskAdvance(CObject* object);
~CTaskAdvance();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index d82874c..b9af475 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -14,29 +14,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskbuild.cpp
#include "object/task/taskbuild.h"
#include "common/iman.h"
+
#include "graphics/core/color.h"
#include "graphics/core/light.h"
#include "graphics/engine/lightman.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
+
#include "object/auto/auto.h"
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"
+
#include "physics/physics.h"
+
#include "ui/displaytext.h"
#include <string.h>
// Object's constructor.
-CTaskBuild::CTaskBuild(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskBuild::CTaskBuild(CObject* object) : CTask(object)
{
int i;
@@ -75,7 +78,7 @@ CTaskBuild::~CTaskBuild()
bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
{
- m_building = new CObject(m_iMan);
+ m_building = new CObject();
if ( !m_building->CreateBuilding(pos, angle, 0.0f, m_type, 0.0f) )
{
delete m_building;
@@ -98,6 +101,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
if ( m_type == OBJECT_NUCLEAR ) m_buildingHeight = 40.0f;
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;
m_buildingHeight *= 0.25f;
m_buildingPos = m_building->GetPosition(0);
@@ -110,7 +114,6 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
void CTaskBuild::CreateLight()
{
- Gfx::Light light;
Gfx::Color color;
Math::Vector center, pos, dir;
Math::Point c, p;
@@ -137,18 +140,12 @@ void CTaskBuild::CreateLight()
pos.y = center.y+40.0f;
dir = center-pos;
- memset(&light, 0, sizeof(light));
+ Gfx::Light light;
light.type = Gfx::LIGHT_SPOT;
- light.diffuse.r = 0.0f;
- light.diffuse.g = 0.0f;
- light.diffuse.b = 0.0f; // white (invisible)
- light.position.x = pos.x;
- light.position.y = pos.y;
- light.position.z = pos.z;
- light.direction.x = dir.x;
- light.direction.y = dir.y;
- light.direction.z = dir.z;
- //TODO Is this value correct
+ light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f);
+ light.diffuse = Gfx::Color(0.0f, 0.0f, 0.0f); // invisible
+ light.position = pos;
+ light.direction = dir;
light.spotIntensity = 128;
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
@@ -578,6 +575,7 @@ Error CTaskBuild::FlatFloor()
if ( m_type == OBJECT_NUCLEAR ) radius = 20.0f;
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;
center = m_metal->GetPosition(0);
@@ -594,11 +592,13 @@ Error CTaskBuild::FlatFloor()
return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
max = 100000.0f;
bBase = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue; // inactive?
@@ -646,7 +646,7 @@ Error CTaskBuild::FlatFloor()
max = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue; // inactive?
@@ -666,6 +666,7 @@ Error CTaskBuild::FlatFloor()
type == OBJECT_ENERGY ||
type == OBJECT_LABO ||
type == OBJECT_NUCLEAR ||
+ type == OBJECT_DESTROYER||
type == OBJECT_START ||
type == OBJECT_END ||
type == OBJECT_INFO ||
@@ -712,12 +713,14 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bMetal = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue; // objet inactive?
@@ -776,9 +779,11 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
float distance;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskbuild.h b/src/object/task/taskbuild.h
index 25300b3..b3193a0 100644
--- a/src/object/task/taskbuild.h
+++ b/src/object/task/taskbuild.h
@@ -45,7 +45,7 @@ enum TaskBuildPhase
class CTaskBuild : public CTask
{
public:
- CTaskBuild(CInstanceManager* iMan, CObject* object);
+ CTaskBuild(CObject* object);
~CTaskBuild();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp
index 99a88b8..beb4944 100644
--- a/src/object/task/taskfire.cpp
+++ b/src/object/task/taskfire.cpp
@@ -14,12 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskfire.cpp
#include "object/task/taskfire.h"
#include "graphics/engine/particle.h"
+
#include "math/geometry.h"
+
#include "physics/physics.h"
@@ -31,8 +32,7 @@ const float ENERGY_FIREi = (0.10f/2.5f); // energy consumed/organic
// Object's constructor.
-CTaskFire::CTaskFire(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskFire::CTaskFire(CObject* object) : CTask(object)
{
m_soundChannel = -1;
}
diff --git a/src/object/task/taskfire.h b/src/object/task/taskfire.h
index 5cf4f0c..81058df 100644
--- a/src/object/task/taskfire.h
+++ b/src/object/task/taskfire.h
@@ -26,7 +26,7 @@
class CTaskFire : public CTask
{
public:
- CTaskFire(CInstanceManager* iMan, CObject* object);
+ CTaskFire(CObject* object);
~CTaskFire();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskfireant.cpp b/src/object/task/taskfireant.cpp
index 2044685..c0acf64 100644
--- a/src/object/task/taskfireant.cpp
+++ b/src/object/task/taskfireant.cpp
@@ -14,13 +14,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskfireant.cpp
#include "object/task/taskfireant.h"
#include "graphics/engine/particle.h"
+
#include "math/geometry.h"
+
#include "object/motion/motionant.h"
+
#include "physics/physics.h"
@@ -28,8 +30,7 @@
// Object's constructor.
-CTaskFireAnt::CTaskFireAnt(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskFireAnt::CTaskFireAnt(CObject* object) : CTask(object)
{
m_phase = TFA_NULL;
}
diff --git a/src/object/task/taskfireant.h b/src/object/task/taskfireant.h
index 4fa77b8..2a0ead8 100644
--- a/src/object/task/taskfireant.h
+++ b/src/object/task/taskfireant.h
@@ -38,7 +38,7 @@ enum TaskFireAnt
class CTaskFireAnt : public CTask
{
public:
- CTaskFireAnt(CInstanceManager* iMan, CObject* object);
+ CTaskFireAnt(CObject* object);
~CTaskFireAnt();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskflag.cpp b/src/object/task/taskflag.cpp
index c88b5c0..dd5e11d 100644
--- a/src/object/task/taskflag.cpp
+++ b/src/object/task/taskflag.cpp
@@ -14,26 +14,28 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskflag.cpp
#include "object/task/taskflag.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
+#include "math/geometry.h"
+
#include "graphics/engine/particle.h"
#include "graphics/engine/pyro.h"
#include "graphics/engine/water.h"
-#include "physics/physics.h"
+
#include "object/motion/motionhuman.h"
+#include "physics/physics.h"
+
// Object's constructor.
-CTaskFlag::CTaskFlag(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskFlag::CTaskFlag(CObject* object) : CTask(object)
{
}
@@ -137,11 +139,13 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
float min, dist;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetEnable() ) continue;
@@ -180,10 +184,12 @@ int CTaskFlag::CountObject(ObjectType type)
Math::Vector oPos;
int i, count;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
count = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetEnable() ) continue;
@@ -247,7 +253,7 @@ Error CTaskFlag::CreateFlag(int rank)
return ERR_FLAG_CREATE;
}
- pNew = new CObject(m_iMan);
+ pNew = new CObject();
if ( !pNew->CreateFlag(pos, 0.0f, table[i]) )
{
delete pNew;
@@ -256,7 +262,7 @@ Error CTaskFlag::CreateFlag(int rank)
//pNew->SetZoom(0, 0.0f);
m_sound->Play(SOUND_WAYPOINT, pos);
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FLCREATE, pNew);
return ERR_OK;
@@ -295,7 +301,7 @@ Error CTaskFlag::DeleteFlag()
}
m_sound->Play(SOUND_WAYPOINT, iPos);
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FLDELETE, pObj);
return ERR_OK;
diff --git a/src/object/task/taskflag.h b/src/object/task/taskflag.h
index 5b0a058..7e3e4ef 100644
--- a/src/object/task/taskflag.h
+++ b/src/object/task/taskflag.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
#include "object/object.h"
+
#include "math/vector.h"
@@ -35,7 +36,7 @@ enum TaskFlagOrder
class CTaskFlag : public CTask
{
public:
- CTaskFlag(CInstanceManager* iMan, CObject* object);
+ CTaskFlag(CObject* object);
~CTaskFlag();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
index cab57f1..c4a2939 100644
--- a/src/object/task/taskgoto.cpp
+++ b/src/object/task/taskgoto.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskgoto.cpp
-
#include <stdio.h>
@@ -23,9 +21,12 @@
#include "common/event.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
+
#include "physics/physics.h"
#include <string.h>
@@ -40,8 +41,7 @@ const float BM_DIM_STEP = 5.0f;
// Object's constructor.
-CTaskGoto::CTaskGoto(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskGoto::CTaskGoto(CObject* object) : CTask(object)
{
m_bmArray = 0;
}
@@ -494,12 +494,14 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
float distance, min, radius;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
iPos = m_object->GetPosition(0);
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
oType = pObj->GetType();
@@ -1026,11 +1028,13 @@ CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin)
float dist, min;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
pBest = 0;
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
@@ -1170,9 +1174,11 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
float dist, suppl;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
@@ -1339,11 +1345,13 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
m_object->GetCrashSphere(0, iPos, iRadius);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
bRadius = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1401,7 +1409,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1522,9 +1530,11 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
bAlien = true;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1614,9 +1624,11 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
fac = 1.5f;
dir = 0.0f;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
@@ -1928,9 +1940,11 @@ void CTaskGoto::BitmapObject()
m_object->GetCrashSphere(0, iPos, iRadius);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskgoto.h b/src/object/task/taskgoto.h
index 1382d4c..d2b2d7e 100644
--- a/src/object/task/taskgoto.h
+++ b/src/object/task/taskgoto.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -72,7 +73,7 @@ enum TaskGotoPhase
class CTaskGoto : public CTask
{
public:
- CTaskGoto(CInstanceManager* iMan, CObject* object);
+ CTaskGoto(CObject* object);
~CTaskGoto();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index aed3355..3373610 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskgungoal.cpp
#include "object/task/taskgungoal.h"
@@ -25,8 +24,7 @@
// Object's constructor.
-CTaskGunGoal::CTaskGunGoal(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskGunGoal::CTaskGunGoal(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskgungoal.h b/src/object/task/taskgungoal.h
index 0c063d1..c6f010b 100644
--- a/src/object/task/taskgungoal.h
+++ b/src/object/task/taskgungoal.h
@@ -26,7 +26,7 @@
class CTaskGunGoal : public CTask
{
public:
- CTaskGunGoal(CInstanceManager* iMan, CObject* object);
+ CTaskGunGoal(CObject* object);
~CTaskGunGoal();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskinfo.cpp b/src/object/task/taskinfo.cpp
index 4e64584..32ac342 100644
--- a/src/object/task/taskinfo.cpp
+++ b/src/object/task/taskinfo.cpp
@@ -14,12 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskinfo.cpp
#include "object/task/taskinfo.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
+
#include "object/auto/autoinfo.h"
#include <string.h>
@@ -28,8 +29,7 @@
// Object's constructor.
-CTaskInfo::CTaskInfo(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskInfo::CTaskInfo(CObject* object) : CTask(object)
{
}
@@ -189,11 +189,13 @@ CObject* CTaskInfo::SearchInfo(float power)
iPos = m_object->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskinfo.h b/src/object/task/taskinfo.h
index 036b57d..1ce3dca 100644
--- a/src/object/task/taskinfo.h
+++ b/src/object/task/taskinfo.h
@@ -26,7 +26,7 @@
class CTaskInfo : public CTask
{
public:
- CTaskInfo(CInstanceManager* iMan, CObject* object);
+ CTaskInfo(CObject* object);
~CTaskInfo();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskmanager.cpp b/src/object/task/taskmanager.cpp
index 26e389d..a2ce8b8 100644
--- a/src/object/task/taskmanager.cpp
+++ b/src/object/task/taskmanager.cpp
@@ -14,14 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskmanager.cpp
-
#include <stdio.h>
#include "object/task/taskmanager.h"
#include "common/iman.h"
+
#include "object/task/taskwait.h"
#include "object/task/taskadvance.h"
#include "object/task/taskturn.h"
@@ -43,12 +42,9 @@
// Object's constructor.
-CTaskManager::CTaskManager(CInstanceManager* iMan, CObject* object)
+CTaskManager::CTaskManager(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_TASKMANAGER, this, 100);
-
- m_task = 0;
+ m_task = nullptr;
m_object = object;
m_bPilot = false;
}
@@ -66,7 +62,7 @@ CTaskManager::~CTaskManager()
Error CTaskManager::StartTaskWait(float time)
{
- m_task = new CTaskWait(m_iMan, m_object);
+ m_task = new CTaskWait(m_object);
return (static_cast<CTaskWait*>(m_task))->Start(time);
}
@@ -74,7 +70,7 @@ Error CTaskManager::StartTaskWait(float time)
Error CTaskManager::StartTaskAdvance(float length)
{
- m_task = new CTaskAdvance(m_iMan, m_object);
+ m_task = new CTaskAdvance(m_object);
return (static_cast<CTaskAdvance*>(m_task))->Start(length);
}
@@ -82,7 +78,7 @@ Error CTaskManager::StartTaskAdvance(float length)
Error CTaskManager::StartTaskTurn(float angle)
{
- m_task = new CTaskTurn(m_iMan, m_object);
+ m_task = new CTaskTurn(m_object);
return (static_cast<CTaskTurn*>(m_task))->Start(angle);
}
@@ -90,7 +86,7 @@ Error CTaskManager::StartTaskTurn(float angle)
Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal goalMode, TaskGotoCrash crashMode)
{
- m_task = new CTaskGoto(m_iMan, m_object);
+ m_task = new CTaskGoto(m_object);
return (static_cast<CTaskGoto*>(m_task))->Start(pos, altitude, goalMode, crashMode);
}
@@ -98,7 +94,7 @@ Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal
Error CTaskManager::StartTaskTake()
{
- m_task = new CTaskTake(m_iMan, m_object);
+ m_task = new CTaskTake(m_object);
return (static_cast<CTaskTake*>(m_task))->Start();
}
@@ -106,7 +102,7 @@ Error CTaskManager::StartTaskTake()
Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
{
- m_task = new CTaskManip(m_iMan, m_object);
+ m_task = new CTaskManip(m_object);
return (static_cast<CTaskManip*>(m_task))->Start(order, arm);
}
@@ -114,7 +110,7 @@ Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
{
- m_task = new CTaskFlag(m_iMan, m_object);
+ m_task = new CTaskFlag(m_object);
return (static_cast<CTaskFlag*>(m_task))->Start(order, rank);
}
@@ -122,7 +118,7 @@ Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
Error CTaskManager::StartTaskBuild(ObjectType type)
{
- m_task = new CTaskBuild(m_iMan, m_object);
+ m_task = new CTaskBuild(m_object);
return (static_cast<CTaskBuild*>(m_task))->Start(type);
}
@@ -130,7 +126,7 @@ Error CTaskManager::StartTaskBuild(ObjectType type)
Error CTaskManager::StartTaskSearch()
{
- m_task = new CTaskSearch(m_iMan, m_object);
+ m_task = new CTaskSearch(m_object);
return (static_cast<CTaskSearch*>(m_task))->Start();
}
@@ -138,7 +134,7 @@ Error CTaskManager::StartTaskSearch()
Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
{
- m_task = new CTaskInfo(m_iMan, m_object);
+ m_task = new CTaskInfo(m_object);
return (static_cast<CTaskInfo*>(m_task))->Start(name, value, power, bSend);
}
@@ -146,7 +142,7 @@ Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bo
Error CTaskManager::StartTaskTerraform()
{
- m_task = new CTaskTerraform(m_iMan, m_object);
+ m_task = new CTaskTerraform(m_object);
return (static_cast<CTaskTerraform*>(m_task))->Start();
}
@@ -154,7 +150,7 @@ Error CTaskManager::StartTaskTerraform()
Error CTaskManager::StartTaskPen(bool bDown, int color)
{
- m_task = new CTaskPen(m_iMan, m_object);
+ m_task = new CTaskPen(m_object);
return (static_cast<CTaskPen*>(m_task))->Start(bDown, color);
}
@@ -162,7 +158,7 @@ Error CTaskManager::StartTaskPen(bool bDown, int color)
Error CTaskManager::StartTaskRecover()
{
- m_task = new CTaskRecover(m_iMan, m_object);
+ m_task = new CTaskRecover(m_object);
return (static_cast<CTaskRecover*>(m_task))->Start();
}
@@ -172,7 +168,7 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
{
if ( mode == TSM_UP )
{
- m_task = new CTaskShield(m_iMan, m_object);
+ m_task = new CTaskShield(m_object);
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
if ( mode == TSM_DOWN && m_task != 0 )
@@ -191,7 +187,7 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
Error CTaskManager::StartTaskFire(float delay)
{
m_bPilot = true;
- m_task = new CTaskFire(m_iMan, m_object);
+ m_task = new CTaskFire(m_object);
return (static_cast<CTaskFire*>(m_task))->Start(delay);
}
@@ -199,7 +195,7 @@ Error CTaskManager::StartTaskFire(float delay)
Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
{
- m_task = new CTaskFireAnt(m_iMan, m_object);
+ m_task = new CTaskFireAnt(m_object);
return (static_cast<CTaskFireAnt*>(m_task))->Start(impact);
}
@@ -207,7 +203,7 @@ Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
{
- m_task = new CTaskGunGoal(m_iMan, m_object);
+ m_task = new CTaskGunGoal(m_object);
return (static_cast<CTaskGunGoal*>(m_task))->Start(dirV, dirH);
}
@@ -215,7 +211,7 @@ Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
Error CTaskManager::StartTaskSpiderExplo()
{
- m_task = new CTaskSpiderExplo(m_iMan, m_object);
+ m_task = new CTaskSpiderExplo(m_object);
return (static_cast<CTaskSpiderExplo*>(m_task))->Start();
}
@@ -223,7 +219,7 @@ Error CTaskManager::StartTaskSpiderExplo()
Error CTaskManager::StartTaskReset(Math::Vector goal, Math::Vector angle)
{
- m_task = new CTaskReset(m_iMan, m_object);
+ m_task = new CTaskReset(m_object);
return (static_cast<CTaskReset*>(m_task))->Start(goal, angle);
}
diff --git a/src/object/task/taskmanager.h b/src/object/task/taskmanager.h
index 6ce023a..80a78fd 100644
--- a/src/object/task/taskmanager.h
+++ b/src/object/task/taskmanager.h
@@ -19,8 +19,8 @@
#pragma once
-#include "object/task/task.h"
#include "object/object.h"
+#include "object/task/task.h"
#include "object/task/taskmanip.h"
#include "object/task/taskgoto.h"
#include "object/task/taskshield.h"
@@ -31,7 +31,7 @@
class CTaskManager
{
public:
- CTaskManager(CInstanceManager* iMan, CObject* object);
+ CTaskManager(CObject* object);
~CTaskManager();
Error StartTaskWait(float time);
@@ -61,9 +61,6 @@ public:
bool Abort();
protected:
-
-protected:
- CInstanceManager* m_iMan;
CTask* m_task;
CObject* m_object;
bool m_bPilot;
diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp
index b0b146c..0608b6e 100644
--- a/src/object/task/taskmanip.cpp
+++ b/src/object/task/taskmanip.cpp
@@ -14,15 +14,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskmanip.cpp
#include "object/task/taskmanip.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/pyro.h"
+
#include "math/geometry.h"
+
#include "object/robotmain.h"
+
#include "physics/physics.h"
@@ -40,8 +43,7 @@ const float MARGIN_BEE = 5.0f; //OK 1.9
// Object's constructor.
-CTaskManip::CTaskManip(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskManip::CTaskManip(CObject* object) : CTask(object)
{
m_arm = TMA_NEUTRAL;
m_hand = TMH_OPEN;
@@ -338,7 +340,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
pos.y += 2.0f;
m_object->SetPosition(0, pos); // against the top of jump
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FALL, other); // the ball falls
}
@@ -728,11 +730,13 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
iPos = m_object->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -798,12 +802,14 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
dLimit = MARGIN_FRONT;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -889,12 +895,14 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
dLimit = MARGIN_BACK;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -989,9 +997,11 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
dLimit = MARGIN_FRIEND;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
@@ -1345,9 +1355,11 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
diff --git a/src/object/task/taskmanip.h b/src/object/task/taskmanip.h
index 79d9ad5..e80602c 100644
--- a/src/object/task/taskmanip.h
+++ b/src/object/task/taskmanip.h
@@ -54,7 +54,7 @@ enum TaskManipHand
class CTaskManip : public CTask
{
public:
- CTaskManip(CInstanceManager* iMan, CObject* object);
+ CTaskManip(CObject* object);
~CTaskManip();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskpen.cpp b/src/object/task/taskpen.cpp
index 6e04233..03c2322 100644
--- a/src/object/task/taskpen.cpp
+++ b/src/object/task/taskpen.cpp
@@ -14,20 +14,20 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskpen.cpp
#include "object/task/taskpen.h"
#include "graphics/engine/particle.h"
-#include "math/geometry.h"
+
#include "object/object.h"
+#include "math/geometry.h"
+
// Object's constructor.
-CTaskPen::CTaskPen(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskPen::CTaskPen(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskpen.h b/src/object/task/taskpen.h
index 0974322..adaba6c 100644
--- a/src/object/task/taskpen.h
+++ b/src/object/task/taskpen.h
@@ -36,7 +36,7 @@ enum TaskPenPhase
class CTaskPen : public CTask
{
public:
- CTaskPen(CInstanceManager* iMan, CObject* object);
+ CTaskPen(CObject* object);
~CTaskPen();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index 4c8ead8..b86e9a5 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -14,17 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskrecover.cpp
-
#include <stdio.h>
#include "object/task/taskrecover.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
+
+#include "math/geometry.h"
+
#include "physics/physics.h"
+
#include "ui/displaytext.h"
@@ -35,8 +37,7 @@ const float RECOVER_DIST = 11.8f;
// Object's constructor.
-CTaskRecover::CTaskRecover(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskRecover::CTaskRecover(CObject* object) : CTask(object)
{
m_ruin = 0;
m_soundChannel = -1;
@@ -297,7 +298,7 @@ Error CTaskRecover::IsEnded()
if ( m_phase == TRP_DOWN )
{
- m_metal = new CObject(m_iMan);
+ m_metal = new CObject();
if ( !m_metal->CreateResource(m_recoverPos, 0.0f, OBJECT_METAL) )
{
delete m_metal;
@@ -385,11 +386,13 @@ CObject* CTaskRecover::SearchRuin()
float dist, min;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
pBest = 0;
min = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskrecover.h b/src/object/task/taskrecover.h
index 151ab6b..817ed5f 100644
--- a/src/object/task/taskrecover.h
+++ b/src/object/task/taskrecover.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -38,7 +39,7 @@ enum TaskRecoverPhase
class CTaskRecover : public CTask
{
public:
- CTaskRecover(CInstanceManager* iMan, CObject* object);
+ CTaskRecover(CObject* object);
~CTaskRecover();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskreset.cpp b/src/object/task/taskreset.cpp
index 7e097bf..98d9730 100644
--- a/src/object/task/taskreset.cpp
+++ b/src/object/task/taskreset.cpp
@@ -14,11 +14,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskreset.cpp
#include "object/task/taskreset.h"
#include "common/iman.h"
+
#include "object/brain.h"
#include "object/robotmain.h"
@@ -32,8 +32,7 @@ const float RESET_DELAY_MOVE = 0.7f;
// Object's constructor.
-CTaskReset::CTaskReset(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskReset::CTaskReset(CObject* object) : CTask(object)
{
}
@@ -273,9 +272,11 @@ bool CTaskReset::SearchVehicle()
float oRadius, dist;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
diff --git a/src/object/task/taskreset.h b/src/object/task/taskreset.h
index e3dacf7..5f1bb34 100644
--- a/src/object/task/taskreset.h
+++ b/src/object/task/taskreset.h
@@ -36,7 +36,7 @@ enum TaskResetPhase
class CTaskReset : public CTask
{
public:
- CTaskReset(CInstanceManager* iMan, CObject* object);
+ CTaskReset(CObject* object);
~CTaskReset();
bool EventProcess(const Event &event);
diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp
index 578b41e..b219185 100644
--- a/src/object/task/tasksearch.cpp
+++ b/src/object/task/tasksearch.cpp
@@ -14,15 +14,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// tasksearch.cpp
#include "object/task/tasksearch.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
+
+#include "math/geometry.h"
+
#include "physics/physics.h"
+
#include "ui/displaytext.h"
@@ -30,8 +33,7 @@
// Object's constructor.
-CTaskSearch::CTaskSearch(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskSearch::CTaskSearch(CObject* object) : CTask(object)
{
m_hand = TSH_UP;
}
@@ -280,7 +282,7 @@ bool CTaskSearch::CreateMark()
//? DeleteMark(type);
- fret = new CObject(m_iMan);
+ fret = new CObject();
if ( !fret->CreateResource(pos, 0.0f, type) )
{
delete fret;
@@ -301,9 +303,11 @@ void CTaskSearch::DeleteMark(ObjectType type)
Math::Vector oPos;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( type == pObj->GetType() )
diff --git a/src/object/task/tasksearch.h b/src/object/task/tasksearch.h
index bffec16..582d45a 100644
--- a/src/object/task/tasksearch.h
+++ b/src/object/task/tasksearch.h
@@ -42,7 +42,7 @@ enum TaskSearchPhase
class CTaskSearch : public CTask
{
public:
- CTaskSearch(CInstanceManager* iMan, CObject* object);
+ CTaskSearch(CObject* object);
~CTaskSearch();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index 93afd62..929dd5c 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -14,16 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskshield.cpp
#include "object/task/taskshield.h"
#include "common/iman.h"
+
#include "graphics/core/light.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/lightman.h"
+
#include "math/geometry.h"
+
#include "object/brain.h"
+
#include "physics/physics.h"
#include <string.h>
@@ -34,8 +37,7 @@ const float ENERGY_TIME = 20.0f; // maximum duration if full battery
// Object's constructor.
-CTaskShield::CTaskShield(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskShield::CTaskShield(CObject* object) : CTask(object)
{
m_rankSphere = -1;
m_soundChannel = -1;
@@ -486,15 +488,10 @@ bool CTaskShield::CreateLight(Math::Vector pos)
memset(&light, 0, sizeof(light));
light.type = Gfx::LIGHT_SPOT;
- light.diffuse.r = 0.0f;
- light.diffuse.g = 1.0f;
- light.diffuse.b = 2.0f;
- light.position.x = pos.x;
- light.position.y = pos.y;
- light.position.z = pos.z;
- light.direction.x = 0.0f;
- light.direction.y = -1.0f; // against the bottom
- light.direction.z = 0.0f;
+ light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f);
+ light.diffuse = Gfx::Color(0.0f, 1.0f, 2.0f);
+ light.position = pos;
+ light.direction = Math::Vector(0.0f, -1.0f, 0.0f); // against the bottom
light.spotIntensity = 128;
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
@@ -521,9 +518,11 @@ void CTaskShield::IncreaseShield()
float dist, shield;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/object/task/taskshield.h b/src/object/task/taskshield.h
index 4a6811c..36d3819 100644
--- a/src/object/task/taskshield.h
+++ b/src/object/task/taskshield.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -49,7 +50,7 @@ enum TaskShieldMode
class CTaskShield : public CTask
{
public:
- CTaskShield(CInstanceManager* iMan, CObject* object);
+ CTaskShield(CObject* object);
~CTaskShield();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskspiderexplo.cpp b/src/object/task/taskspiderexplo.cpp
index 8110870..f629714 100644
--- a/src/object/task/taskspiderexplo.cpp
+++ b/src/object/task/taskspiderexplo.cpp
@@ -14,12 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskspiderexplo.cpp
#include "object/task/taskspiderexplo.h"
#include "graphics/engine/pyro.h"
+
#include "object/motion/motionspider.h"
+
#include "physics/physics.h"
@@ -27,8 +28,7 @@
// Object's constructor.
-CTaskSpiderExplo::CTaskSpiderExplo(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskSpiderExplo::CTaskSpiderExplo(CObject* object) : CTask(object)
{
m_time = 0.0f;
m_bError = false;
@@ -91,7 +91,7 @@ Error CTaskSpiderExplo::IsEnded()
if ( m_time < 1.0f ) return ERR_CONTINUE;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_SPIDER, m_object); // the spider explodes (suicide)
Abort();
diff --git a/src/object/task/taskspiderexplo.h b/src/object/task/taskspiderexplo.h
index 50f3ad2..0984020 100644
--- a/src/object/task/taskspiderexplo.h
+++ b/src/object/task/taskspiderexplo.h
@@ -26,7 +26,7 @@
class CTaskSpiderExplo : public CTask
{
public:
- CTaskSpiderExplo(CInstanceManager* iMan, CObject* object);
+ CTaskSpiderExplo(CObject* object);
~CTaskSpiderExplo();
bool EventProcess(const Event &event);
diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp
index 2737324..0037f85 100644
--- a/src/object/task/tasktake.cpp
+++ b/src/object/task/tasktake.cpp
@@ -14,16 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// tasktake.cpp
#include "object/task/tasktake.h"
#include "common/iman.h"
+
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
+
#include "math/geometry.h"
+
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"
+
#include "physics/physics.h"
@@ -31,10 +34,9 @@
// Object's constructor.
-CTaskTake::CTaskTake(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskTake::CTaskTake(CObject* object) : CTask(object)
{
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
m_arm = TTA_NEUTRAL;
}
@@ -305,12 +307,14 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 1000000.0f;
pBest = 0;
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -374,9 +378,11 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
@@ -569,9 +575,11 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
diff --git a/src/object/task/tasktake.h b/src/object/task/tasktake.h
index c7950fe..7f3f831 100644
--- a/src/object/task/tasktake.h
+++ b/src/object/task/tasktake.h
@@ -42,7 +42,7 @@ enum TaskTakeArm
class CTaskTake : public CTask
{
public:
- CTaskTake(CInstanceManager* iMan, CObject* object);
+ CTaskTake(CObject* object);
~CTaskTake();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 6afece4..1f5ef7b 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -14,23 +14,25 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskterraform.cpp
-
#include <stdio.h>
#include "object/task/taskterraform.h"
-#include "math/geometry.h"
#include "common/iman.h"
+
#include "graphics/engine/pyro.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/terrain.h"
-#include "physics/physics.h"
+
+#include "math/geometry.h"
+
#include "object/brain.h"
#include "object/motion/motionant.h"
#include "object/motion/motionspider.h"
+#include "physics/physics.h"
+
const float ENERGY_TERRA = 0.40f; // energy consumed by blow
const float ACTION_RADIUS = 400.0f;
@@ -39,8 +41,7 @@ const float ACTION_RADIUS = 400.0f;
// Object's constructor.
-CTaskTerraform::CTaskTerraform(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskTerraform::CTaskTerraform(CObject* object) : CTask(object)
{
m_lastParticle = 0.0f;
m_soundChannel = -1;
@@ -370,9 +371,11 @@ bool CTaskTerraform::Terraform()
m_sound->Play(SOUND_THUMP, m_terraPos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -383,7 +386,7 @@ bool CTaskTerraform::Terraform()
dist = Math::Distance(m_terraPos, pObj->GetPosition(0));
if ( dist > 20.0f ) continue;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj);
}
else
diff --git a/src/object/task/taskterraform.h b/src/object/task/taskterraform.h
index 91526b6..8ae0d64 100644
--- a/src/object/task/taskterraform.h
+++ b/src/object/task/taskterraform.h
@@ -20,6 +20,7 @@
#include "object/task/task.h"
+
#include "math/vector.h"
@@ -37,7 +38,7 @@ enum TaskTerraPhase
class CTaskTerraform : public CTask
{
public:
- CTaskTerraform(CInstanceManager* iMan, CObject* object);
+ CTaskTerraform(CObject* object);
~CTaskTerraform();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp
index 8f4bbd2..7a924cb 100644
--- a/src/object/task/taskturn.cpp
+++ b/src/object/task/taskturn.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskturn.cpp
#include "object/task/taskturn.h"
@@ -26,8 +25,7 @@
// Object's constructor.
-CTaskTurn::CTaskTurn(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskTurn::CTaskTurn(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskturn.h b/src/object/task/taskturn.h
index 1ee40d9..11de476 100644
--- a/src/object/task/taskturn.h
+++ b/src/object/task/taskturn.h
@@ -26,7 +26,7 @@
class CTaskTurn : public CTask
{
public:
- CTaskTurn(CInstanceManager* iMan, CObject* object);
+ CTaskTurn(CObject* object);
~CTaskTurn();
bool EventProcess(const Event &event);
diff --git a/src/object/task/taskwait.cpp b/src/object/task/taskwait.cpp
index f612c24..3e201e0 100644
--- a/src/object/task/taskwait.cpp
+++ b/src/object/task/taskwait.cpp
@@ -14,7 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// taskwait.cpp
#include "object/task/taskwait.h"
@@ -22,8 +21,7 @@
// Object's constructor.
-CTaskWait::CTaskWait(CInstanceManager* iMan, CObject* object)
- : CTask(iMan, object)
+CTaskWait::CTaskWait(CObject* object) : CTask(object)
{
}
diff --git a/src/object/task/taskwait.h b/src/object/task/taskwait.h
index 3434c36..3225c9a 100644
--- a/src/object/task/taskwait.h
+++ b/src/object/task/taskwait.h
@@ -26,7 +26,7 @@
class CTaskWait : public CTask
{
public:
- CTaskWait(CInstanceManager* iMan, CObject* object);
+ CTaskWait(CObject* object);
~CTaskWait();
bool EventProcess(const Event &event);
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index f56f81d..6311ecf 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -17,6 +17,8 @@
#include "physics/physics.h"
+#include "app/app.h"
+
#include "common/event.h"
#include "common/global.h"
#include "common/iman.h"
@@ -31,6 +33,7 @@
#include "math/geometry.h"
#include "object/brain.h"
+#include "object/robotmain.h"
#include "object/motion/motion.h"
#include "object/motion/motionhuman.h"
#include "object/task/task.h"
@@ -51,21 +54,18 @@ const float LANDING_ACCELh = 1.5f;
// Object's constructor.
-CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
+CPhysics::CPhysics(CObject* object)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_PHYSICS, this, 100);
-
m_object = object;
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_brain = 0;
- m_motion = 0;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_lightMan = m_engine->GetLightManager();
+ m_particle = m_engine->GetParticle();
+ m_water = m_engine->GetWater();
+ m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_brain = nullptr;
+ m_motion = nullptr;
m_type = TYPE_ROLLING;
m_gravity = 9.81f; // default gravity
@@ -116,8 +116,7 @@ CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
CPhysics::~CPhysics()
{
- m_iMan->DeleteInstance(CLASS_PHYSICS, this);
-}
+ }
// Destroys the object.
@@ -2510,9 +2509,11 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
iPos = iiPos + (pos - m_object->GetPosition(0));
iType = m_object->GetType();
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
@@ -2578,7 +2579,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
if ( distance < 4.0f )
{
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition(0));
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_WPCHECK, pObj);
}
}
@@ -2590,7 +2591,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
if ( distance < 10.0f*1.5f )
{
m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition(0));
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_WPCHECK, pObj);
}
}
@@ -2752,7 +2753,7 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_FRET ||
oType == OBJECT_METAL ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_EXPLOT, pObj); // total destruction
}
@@ -2760,7 +2761,7 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_POWER ||
oType == OBJECT_ATOMIC ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
@@ -2768,7 +2769,7 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_STONE ||
oType == OBJECT_URANIUM ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
@@ -2829,14 +2830,14 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_MOBILEtg ||
oType == OBJECT_TNT ) )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
if ( force > 0.0f &&
oType == OBJECT_BOMB )
{
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
@@ -2859,7 +2860,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
{
if ( iType == OBJECT_HUMAN ) type = Gfx::PT_DEADG;
else type = Gfx::PT_EXPLOT;
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(type, m_object); // total destruction
return 2;
}
@@ -2881,7 +2882,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
{
type = Gfx::PT_EXPLOT;
}
- pyro = new Gfx::CPyro(m_iMan);
+ pyro = new Gfx::CPyro();
pyro->Create(type, m_object); // total destruction
return 2;
}
diff --git a/src/physics/physics.h b/src/physics/physics.h
index db88e8c..cce57f3 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -30,21 +30,19 @@
#include "math/vector.h"
-class CInstanceManager;
class CObject;
class CBrain;
class CMotion;
class CSoundInterface;
-namespace Gfx
-{
+namespace Gfx {
class CCamera;
class CEngine;
class CLight;
class CParticle;
class CTerrain;
class CWater;
-};
+}
enum PhysicsType
@@ -97,7 +95,7 @@ struct Motion
class CPhysics
{
public:
- CPhysics(CInstanceManager* iMan, CObject* object);
+ CPhysics(CObject* object);
~CPhysics();
void DeleteObject(bool bAll=false);
@@ -195,7 +193,6 @@ protected:
void WheelParticle(int color, float width);
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
Gfx::CParticle* m_particle;
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 0bb368c..95b259b 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -18,6 +18,7 @@
#include "script/cbottoken.h"
#include "object/object.h"
+#include "app/app.h"
#include <string.h>
@@ -130,208 +131,208 @@ const char* GetObjectAlias(ObjectType type)
// Returns the help file to use for the object.
-const char* GetHelpFilename(ObjectType type)
+std::string GetHelpFilename(ObjectType type)
{
- if ( type == OBJECT_BASE ) return "help\\object\\base.txt";
- if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt";
- if ( type == OBJECT_FACTORY ) return "help\\object\\factory.txt";
- if ( type == OBJECT_STATION ) return "help\\object\\station.txt";
- if ( type == OBJECT_CONVERT ) return "help\\object\\convert.txt";
- if ( type == OBJECT_REPAIR ) return "help\\object\\repair.txt";
- if ( type == OBJECT_DESTROYER ) return "help\\object\\destroy.txt";
- if ( type == OBJECT_TOWER ) return "help\\object\\tower.txt";
- if ( type == OBJECT_NEST ) return "help\\object\\nest.txt";
- if ( type == OBJECT_RESEARCH ) return "help\\object\\research.txt";
- if ( type == OBJECT_RADAR ) return "help\\object\\radar.txt";
- if ( type == OBJECT_INFO ) return "help\\object\\exchange.txt";
- if ( type == OBJECT_ENERGY ) return "help\\object\\energy.txt";
- if ( type == OBJECT_LABO ) return "help\\object\\labo.txt";
- if ( type == OBJECT_NUCLEAR ) return "help\\object\\nuclear.txt";
- if ( type == OBJECT_PARA ) return "help\\object\\captor.txt";
- if ( type == OBJECT_SAFE ) return "help\\object\\safe.txt";
- if ( type == OBJECT_HUSTON ) return "help\\object\\huston.txt";
- if ( type == OBJECT_START ) return "help\\object\\start.txt";
- if ( type == OBJECT_END ) return "help\\object\\goal.txt";
- if ( type == OBJECT_STONE ) return "help\\object\\titanore.txt";
- if ( type == OBJECT_URANIUM ) return "help\\object\\uranore.txt";
- if ( type == OBJECT_METAL ) return "help\\object\\titan.txt";
- if ( type == OBJECT_POWER ) return "help\\object\\power.txt";
- if ( type == OBJECT_ATOMIC ) return "help\\object\\atomic.txt";
- if ( type == OBJECT_BULLET ) return "help\\object\\bullet.txt";
- if ( type == OBJECT_BBOX ) return "help\\object\\bbox.txt";
- if ( type == OBJECT_KEYa ) return "help\\object\\key.txt";
- if ( type == OBJECT_KEYb ) return "help\\object\\key.txt";
- if ( type == OBJECT_KEYc ) return "help\\object\\key.txt";
- if ( type == OBJECT_KEYd ) return "help\\object\\key.txt";
- if ( type == OBJECT_TNT ) return "help\\object\\tnt.txt";
- if ( type == OBJECT_SCRAP1 ) return "help\\object\\scrap.txt";
- if ( type == OBJECT_BOMB ) return "help\\object\\mine.txt";
- if ( type == OBJECT_BARRIER1 ) return "help\\object\\barrier.txt";
- if ( type == OBJECT_WAYPOINT ) return "help\\object\\waypoint.txt";
- if ( type == OBJECT_FLAGb ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGr ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGg ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGy ) return "help\\object\\flag.txt";
- if ( type == OBJECT_FLAGv ) return "help\\object\\flag.txt";
- if ( type == OBJECT_MARKPOWER ) return "help\\object\\enerspot.txt";
- if ( type == OBJECT_MARKSTONE ) return "help\\object\\stonspot.txt";
- if ( type == OBJECT_MARKURANIUM ) return "help\\object\\uranspot.txt";
- if ( type == OBJECT_MOBILEwa ) return "help\\object\\botgr.txt";
- if ( type == OBJECT_MOBILEta ) return "help\\object\\botgc.txt";
- if ( type == OBJECT_MOBILEfa ) return "help\\object\\botgj.txt";
- if ( type == OBJECT_MOBILEia ) return "help\\object\\botgs.txt";
- if ( type == OBJECT_MOBILEws ) return "help\\object\\botsr.txt";
- if ( type == OBJECT_MOBILEts ) return "help\\object\\botsc.txt";
- if ( type == OBJECT_MOBILEfs ) return "help\\object\\botsj.txt";
- if ( type == OBJECT_MOBILEis ) return "help\\object\\botss.txt";
- if ( type == OBJECT_MOBILEwi ) return "help\\object\\botor.txt";
- if ( type == OBJECT_MOBILEti ) return "help\\object\\botoc.txt";
- if ( type == OBJECT_MOBILEfi ) return "help\\object\\botoj.txt";
- if ( type == OBJECT_MOBILEii ) return "help\\object\\botos.txt";
- if ( type == OBJECT_MOBILEwc ) return "help\\object\\botfr.txt";
- if ( type == OBJECT_MOBILEtc ) return "help\\object\\botfc.txt";
- if ( type == OBJECT_MOBILEfc ) return "help\\object\\botfj.txt";
- if ( type == OBJECT_MOBILEic ) return "help\\object\\botfs.txt";
- if ( type == OBJECT_MOBILErt ) return "help\\object\\bottump.txt";
- if ( type == OBJECT_MOBILErc ) return "help\\object\\botphaz.txt";
- if ( type == OBJECT_MOBILErr ) return "help\\object\\botrecy.txt";
- if ( type == OBJECT_MOBILErs ) return "help\\object\\botshld.txt";
- if ( type == OBJECT_MOBILEsa ) return "help\\object\\botsub.txt";
- if ( type == OBJECT_MOBILEwt ) return "help\\object\\bottr.txt";
- if ( type == OBJECT_MOBILEtg ) return "help\\object\\bottarg.txt";
- if ( type == OBJECT_MOBILEdr ) return "help\\object\\botdraw.txt";
- if ( type == OBJECT_APOLLO2 ) return "help\\object\\lrv.txt";
- if ( type == OBJECT_HUMAN ) return "help\\object\\human.txt";
- if ( type == OBJECT_MOTHER ) return "help\\object\\mother.txt";
- if ( type == OBJECT_EGG ) return "help\\object\\egg.txt";
- if ( type == OBJECT_ANT ) return "help\\object\\ant.txt";
- if ( type == OBJECT_SPIDER ) return "help\\object\\spider.txt";
- if ( type == OBJECT_BEE ) return "help\\object\\wasp.txt";
- if ( type == OBJECT_WORM ) return "help\\object\\worm.txt";
- if ( type == OBJECT_RUINmobilew1) return "help\\object\\wreck.txt";
+ if ( type == OBJECT_BASE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/base.txt");
+ if ( type == OBJECT_DERRICK ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/derrick.txt");
+ if ( type == OBJECT_FACTORY ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/factory.txt");
+ if ( type == OBJECT_STATION ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/station.txt");
+ if ( type == OBJECT_CONVERT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/convert.txt");
+ if ( type == OBJECT_REPAIR ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/repair.txt");
+ if ( type == OBJECT_DESTROYER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/destroy.txt");
+ if ( type == OBJECT_TOWER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/tower.txt");
+ if ( type == OBJECT_NEST ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/nest.txt");
+ if ( type == OBJECT_RESEARCH ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/research.txt");
+ if ( type == OBJECT_RADAR ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/radar.txt");
+ if ( type == OBJECT_INFO ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/exchange.txt");
+ if ( type == OBJECT_ENERGY ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/energy.txt");
+ if ( type == OBJECT_LABO ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/labo.txt");
+ if ( type == OBJECT_NUCLEAR ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/nuclear.txt");
+ if ( type == OBJECT_PARA ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/captor.txt");
+ if ( type == OBJECT_SAFE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/safe.txt");
+ if ( type == OBJECT_HUSTON ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/huston.txt");
+ if ( type == OBJECT_START ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/start.txt");
+ if ( type == OBJECT_END ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/goal.txt");
+ if ( type == OBJECT_STONE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/titanore.txt");
+ if ( type == OBJECT_URANIUM ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/uranore.txt");
+ if ( type == OBJECT_METAL ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/titan.txt");
+ if ( type == OBJECT_POWER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/power.txt");
+ if ( type == OBJECT_ATOMIC ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/atomic.txt");
+ if ( type == OBJECT_BULLET ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bullet.txt");
+ if ( type == OBJECT_BBOX ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bbox.txt");
+ if ( type == OBJECT_KEYa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_KEYb ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_KEYc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_KEYd ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/key.txt");
+ if ( type == OBJECT_TNT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/tnt.txt");
+ if ( type == OBJECT_SCRAP1 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/scrap.txt");
+ if ( type == OBJECT_BOMB ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/mine.txt");
+ if ( type == OBJECT_BARRIER1 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/barrier.txt");
+ if ( type == OBJECT_WAYPOINT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/waypoint.txt");
+ if ( type == OBJECT_FLAGb ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGr ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGg ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGy ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_FLAGv ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/flag.txt");
+ if ( type == OBJECT_MARKPOWER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/enerspot.txt");
+ if ( type == OBJECT_MARKSTONE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/stonspot.txt");
+ if ( type == OBJECT_MARKURANIUM ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/uranspot.txt");
+ if ( type == OBJECT_MOBILEwa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgr.txt");
+ if ( type == OBJECT_MOBILEta ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgc.txt");
+ if ( type == OBJECT_MOBILEfa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgj.txt");
+ if ( type == OBJECT_MOBILEia ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botgs.txt");
+ if ( type == OBJECT_MOBILEws ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsr.txt");
+ if ( type == OBJECT_MOBILEts ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsc.txt");
+ if ( type == OBJECT_MOBILEfs ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsj.txt");
+ if ( type == OBJECT_MOBILEis ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botss.txt");
+ if ( type == OBJECT_MOBILEwi ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botor.txt");
+ if ( type == OBJECT_MOBILEti ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botoc.txt");
+ if ( type == OBJECT_MOBILEfi ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botoj.txt");
+ if ( type == OBJECT_MOBILEii ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botos.txt");
+ if ( type == OBJECT_MOBILEwc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfr.txt");
+ if ( type == OBJECT_MOBILEtc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfc.txt");
+ if ( type == OBJECT_MOBILEfc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfj.txt");
+ if ( type == OBJECT_MOBILEic ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botfs.txt");
+ if ( type == OBJECT_MOBILErt ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bottump.txt");
+ if ( type == OBJECT_MOBILErc ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botphaz.txt");
+ if ( type == OBJECT_MOBILErr ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botrecy.txt");
+ if ( type == OBJECT_MOBILErs ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botshld.txt");
+ if ( type == OBJECT_MOBILEsa ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botsub.txt");
+ if ( type == OBJECT_MOBILEwt ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bottr.txt");
+ if ( type == OBJECT_MOBILEtg ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/bottarg.txt");
+ if ( type == OBJECT_MOBILEdr ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/botdraw.txt");
+ if ( type == OBJECT_APOLLO2 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/lrv.txt");
+ if ( type == OBJECT_HUMAN ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/human.txt");
+ if ( type == OBJECT_MOTHER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/mother.txt");
+ if ( type == OBJECT_EGG ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/egg.txt");
+ if ( type == OBJECT_ANT ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/ant.txt");
+ if ( type == OBJECT_SPIDER ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/spider.txt");
+ if ( type == OBJECT_BEE ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/wasp.txt");
+ if ( type == OBJECT_WORM ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/worm.txt");
+ if ( type == OBJECT_RUINmobilew1) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/object/wreck.txt");
return "";
}
// Returns the help file to use for instruction.
-const char* GetHelpFilename(const char *token)
+std::string GetHelpFilename(const char *token)
{
- if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt";
- if ( strcmp(token, "else" ) == 0 ) return "help\\cbot\\if.txt";
- if ( strcmp(token, "repeat" ) == 0 ) return "help\\cbot\\repeat.txt";
- if ( strcmp(token, "for" ) == 0 ) return "help\\cbot\\for.txt";
- if ( strcmp(token, "while" ) == 0 ) return "help\\cbot\\while.txt";
- if ( strcmp(token, "do" ) == 0 ) return "help\\cbot\\do.txt";
- if ( strcmp(token, "break" ) == 0 ) return "help\\cbot\\break.txt";
- if ( strcmp(token, "continue" ) == 0 ) return "help\\cbot\\continue.txt";
- if ( strcmp(token, "return" ) == 0 ) return "help\\cbot\\return.txt";
- if ( strcmp(token, "sizeof" ) == 0 ) return "help\\cbot\\sizeof.txt";
- if ( strcmp(token, "int" ) == 0 ) return "help\\cbot\\int.txt";
- if ( strcmp(token, "float" ) == 0 ) return "help\\cbot\\float.txt";
- if ( strcmp(token, "bool" ) == 0 ) return "help\\cbot\\bool.txt";
- if ( strcmp(token, "string" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "point" ) == 0 ) return "help\\cbot\\point.txt";
- if ( strcmp(token, "object" ) == 0 ) return "help\\cbot\\object.txt";
- if ( strcmp(token, "file" ) == 0 ) return "help\\cbot\\file.txt";
- if ( strcmp(token, "void" ) == 0 ) return "help\\cbot\\void.txt";
- if ( strcmp(token, "null" ) == 0 ) return "help\\cbot\\null.txt";
- if ( strcmp(token, "nan" ) == 0 ) return "help\\cbot\\nan.txt";
- if ( strcmp(token, "true" ) == 0 ) return "help\\cbot\\true.txt";
- if ( strcmp(token, "false" ) == 0 ) return "help\\cbot\\false.txt";
- if ( strcmp(token, "sin" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "cos" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "tan" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "asin" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "acos" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "atan" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "sqrt" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "pow" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "rand" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "abs" ) == 0 ) return "help\\cbot\\expr.txt";
- if ( strcmp(token, "retobject" ) == 0 ) return "help\\cbot\\retobj.txt";
- if ( strcmp(token, "search" ) == 0 ) return "help\\cbot\\search.txt";
- if ( strcmp(token, "radar" ) == 0 ) return "help\\cbot\\radar.txt";
- if ( strcmp(token, "direction" ) == 0 ) return "help\\cbot\\direct.txt";
- if ( strcmp(token, "distance" ) == 0 ) return "help\\cbot\\dist.txt";
- if ( strcmp(token, "distance2d" ) == 0 ) return "help\\cbot\\dist2d.txt";
- if ( strcmp(token, "space" ) == 0 ) return "help\\cbot\\space.txt";
- if ( strcmp(token, "flatground" ) == 0 ) return "help\\cbot\\flatgrnd.txt";
- if ( strcmp(token, "wait" ) == 0 ) return "help\\cbot\\wait.txt";
- if ( strcmp(token, "move" ) == 0 ) return "help\\cbot\\move.txt";
- if ( strcmp(token, "turn" ) == 0 ) return "help\\cbot\\turn.txt";
- if ( strcmp(token, "goto" ) == 0 ) return "help\\cbot\\goto.txt";
- if ( strcmp(token, "find" ) == 0 ) return "help\\cbot\\find.txt";
- if ( strcmp(token, "grab" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "drop" ) == 0 ) return "help\\cbot\\drop.txt";
- if ( strcmp(token, "sniff" ) == 0 ) return "help\\cbot\\sniff.txt";
- if ( strcmp(token, "receive" ) == 0 ) return "help\\cbot\\receive.txt";
- if ( strcmp(token, "send" ) == 0 ) return "help\\cbot\\send.txt";
- if ( strcmp(token, "deleteinfo" ) == 0 ) return "help\\cbot\\delinfo.txt";
- if ( strcmp(token, "testinfo" ) == 0 ) return "help\\cbot\\testinfo.txt";
- if ( strcmp(token, "thump" ) == 0 ) return "help\\cbot\\thump.txt";
- if ( strcmp(token, "recycle" ) == 0 ) return "help\\cbot\\recycle.txt";
- if ( strcmp(token, "shield" ) == 0 ) return "help\\cbot\\shield.txt";
- if ( strcmp(token, "fire" ) == 0 ) return "help\\cbot\\fire.txt";
- if ( strcmp(token, "antfire" ) == 0 ) return "help\\cbot\\antfire.txt";
- if ( strcmp(token, "aim" ) == 0 ) return "help\\cbot\\aim.txt";
- if ( strcmp(token, "motor" ) == 0 ) return "help\\cbot\\motor.txt";
- if ( strcmp(token, "jet" ) == 0 ) return "help\\cbot\\jet.txt";
- if ( strcmp(token, "topo" ) == 0 ) return "help\\cbot\\topo.txt";
- if ( strcmp(token, "message" ) == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "abstime" ) == 0 ) return "help\\cbot\\abstime.txt";
- if ( strcmp(token, "BlackArrow" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "RedArrow" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "White" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Black" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Gray" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "LightGray" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Red" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Pink" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Purple" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Orange" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Yellow" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Beige" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Brown" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Skin" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Green" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "LightGreen" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "Blue" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "LightBlue" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "InFront" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "Behind" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "EnergyCell" ) == 0 ) return "help\\cbot\\grab.txt";
- if ( strcmp(token, "DisplayError" ) == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "DisplayWarning") == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "DisplayInfo" ) == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "DisplayMessage") == 0 ) return "help\\cbot\\message.txt";
- if ( strcmp(token, "strlen" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strleft" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strright" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strmid" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strval" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strfind" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strlower" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "strupper" ) == 0 ) return "help\\cbot\\string.txt";
- if ( strcmp(token, "open" ) == 0 ) return "help\\cbot\\open.txt";
- if ( strcmp(token, "close" ) == 0 ) return "help\\cbot\\close.txt";
- if ( strcmp(token, "writeln" ) == 0 ) return "help\\cbot\\writeln.txt";
- if ( strcmp(token, "readln " ) == 0 ) return "help\\cbot\\readln.txt";
- if ( strcmp(token, "eof" ) == 0 ) return "help\\cbot\\eof.txt";
- if ( strcmp(token, "deletefile" ) == 0 ) return "help\\cbot\\deletef.txt";
- if ( strcmp(token, "openfile" ) == 0 ) return "help\\cbot\\openfile.txt";
- if ( strcmp(token, "pendown" ) == 0 ) return "help\\cbot\\pendown.txt";
- if ( strcmp(token, "penup" ) == 0 ) return "help\\cbot\\penup.txt";
- if ( strcmp(token, "pencolor" ) == 0 ) return "help\\cbot\\pencolor.txt";
- if ( strcmp(token, "penwidth" ) == 0 ) return "help\\cbot\\penwidth.txt";
- if ( strcmp(token, "extern" ) == 0 ) return "help\\cbot\\extern.txt";
- if ( strcmp(token, "class" ) == 0 ) return "help\\cbot\\class.txt";
- if ( strcmp(token, "static" ) == 0 ) return "help\\cbot\\static.txt";
- if ( strcmp(token, "public" ) == 0 ) return "help\\cbot\\public.txt";
- if ( strcmp(token, "private" ) == 0 ) return "help\\cbot\\private.txt";
- if ( strcmp(token, "synchronized" ) == 0 ) return "help\\cbot\\synchro.txt";
- if ( strcmp(token, "new" ) == 0 ) return "help\\cbot\\new.txt";
- if ( strcmp(token, "this" ) == 0 ) return "help\\cbot\\this.txt";
+ if ( strcmp(token, "if" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt");
+ if ( strcmp(token, "else" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/if.txt");
+ if ( strcmp(token, "repeat" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/repeat.txt");
+ if ( strcmp(token, "for" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/for.txt");
+ if ( strcmp(token, "while" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/while.txt");
+ if ( strcmp(token, "do" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/do.txt");
+ if ( strcmp(token, "break" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/break.txt");
+ if ( strcmp(token, "continue" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/continue.txt");
+ if ( strcmp(token, "return" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/return.txt");
+ if ( strcmp(token, "sizeof" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sizeof.txt");
+ if ( strcmp(token, "int" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/int.txt");
+ if ( strcmp(token, "float" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/float.txt");
+ if ( strcmp(token, "bool" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/bool.txt");
+ if ( strcmp(token, "string" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "point" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/point.txt");
+ if ( strcmp(token, "object" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/object.txt");
+ if ( strcmp(token, "file" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/file.txt");
+ if ( strcmp(token, "void" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/void.txt");
+ if ( strcmp(token, "null" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/null.txt");
+ if ( strcmp(token, "nan" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/nan.txt");
+ if ( strcmp(token, "true" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/true.txt");
+ if ( strcmp(token, "false" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/false.txt");
+ if ( strcmp(token, "sin" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "cos" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "tan" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "asin" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "acos" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "atan" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "sqrt" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "pow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "rand" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "abs" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/expr.txt");
+ if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt");
+ if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt");
+ if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt");
+ if ( strcmp(token, "direction" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/direct.txt");
+ if ( strcmp(token, "distance" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/dist.txt");
+ if ( strcmp(token, "distance2d" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/dist2d.txt");
+ if ( strcmp(token, "space" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/space.txt");
+ if ( strcmp(token, "flatground" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/flatgrnd.txt");
+ if ( strcmp(token, "wait" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/wait.txt");
+ if ( strcmp(token, "move" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/move.txt");
+ if ( strcmp(token, "turn" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/turn.txt");
+ if ( strcmp(token, "goto" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/goto.txt");
+ if ( strcmp(token, "find" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/find.txt");
+ if ( strcmp(token, "grab" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "drop" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/drop.txt");
+ if ( strcmp(token, "sniff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/sniff.txt");
+ if ( strcmp(token, "receive" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/receive.txt");
+ if ( strcmp(token, "send" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/send.txt");
+ if ( strcmp(token, "deleteinfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/delinfo.txt");
+ if ( strcmp(token, "testinfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/testinfo.txt");
+ if ( strcmp(token, "thump" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/thump.txt");
+ if ( strcmp(token, "recycle" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/recycle.txt");
+ if ( strcmp(token, "shield" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/shield.txt");
+ if ( strcmp(token, "fire" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/fire.txt");
+ if ( strcmp(token, "antfire" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/antfire.txt");
+ if ( strcmp(token, "aim" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/aim.txt");
+ if ( strcmp(token, "motor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/motor.txt");
+ if ( strcmp(token, "jet" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/jet.txt");
+ if ( strcmp(token, "topo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/topo.txt");
+ if ( strcmp(token, "message" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "abstime" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/abstime.txt");
+ if ( strcmp(token, "BlackArrow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "RedArrow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "White" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Black" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Gray" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "LightGray" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Red" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Pink" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Purple" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Orange" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Yellow" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Beige" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Brown" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Skin" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Green" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "LightGreen" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "Blue" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "LightBlue" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "InFront" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "Behind" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "EnergyCell" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/grab.txt");
+ if ( strcmp(token, "DisplayError" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "DisplayWarning") == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "DisplayInfo" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "DisplayMessage") == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/message.txt");
+ if ( strcmp(token, "strlen" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strleft" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strright" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strmid" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strval" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strfind" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strlower" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "strupper" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/string.txt");
+ if ( strcmp(token, "open" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/open.txt");
+ if ( strcmp(token, "close" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/close.txt");
+ if ( strcmp(token, "writeln" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/writeln.txt");
+ if ( strcmp(token, "readln " ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/readln.txt");
+ if ( strcmp(token, "eof" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/eof.txt");
+ if ( strcmp(token, "deletefile" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/deletef.txt");
+ if ( strcmp(token, "openfile" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/openfile.txt");
+ if ( strcmp(token, "pendown" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pendown.txt");
+ if ( strcmp(token, "penup" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penup.txt");
+ if ( strcmp(token, "pencolor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pencolor.txt");
+ if ( strcmp(token, "penwidth" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penwidth.txt");
+ if ( strcmp(token, "extern" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/extern.txt");
+ if ( strcmp(token, "class" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/class.txt");
+ if ( strcmp(token, "static" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/static.txt");
+ if ( strcmp(token, "public" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/public.txt");
+ if ( strcmp(token, "private" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/private.txt");
+ if ( strcmp(token, "synchronized" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/synchro.txt");
+ if ( strcmp(token, "new" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/new.txt");
+ if ( strcmp(token, "this" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/this.txt");
return "";
}
@@ -450,7 +451,7 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "pow" ) == 0 ) return "pow ( x, y );";
if ( strcmp(token, "rand" ) == 0 ) return "rand ( );";
if ( strcmp(token, "abs" ) == 0 ) return "abs ( value );";
- if ( strcmp(token, "retobject" ) == 0 ) return "retobjet ( );";
+ if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( );";
if ( strcmp(token, "search" ) == 0 ) return "search ( );";
if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );";
if ( strcmp(token, "detect" ) == 0 ) return "detect ( cat );";
@@ -475,8 +476,8 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "recycle" ) == 0 ) return "recycle ( );";
if ( strcmp(token, "shield" ) == 0 ) return "shield ( oper, radius );";
if ( strcmp(token, "fire" ) == 0 ) return "fire ( time );";
- if ( strcmp(token, "antfire" ) == 0 ) return "antfire ( );";
- if ( strcmp(token, "aim" ) == 0 ) return "aim ( angle );";
+ //if ( strcmp(token, "antfire" ) == 0 ) return "antfire ( );";
+ if ( strcmp(token, "aim" ) == 0 ) return "aim ( x, y );";
if ( strcmp(token, "motor" ) == 0 ) return "motor ( left, right );";
if ( strcmp(token, "jet" ) == 0 ) return "jet ( power );";
if ( strcmp(token, "topo" ) == 0 ) return "topo ( position );";
diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h
index f5b7b70..bc53f77 100644
--- a/src/script/cbottoken.h
+++ b/src/script/cbottoken.h
@@ -30,8 +30,8 @@
extern const char* GetObjectName(ObjectType type);
extern const char* GetObjectAlias(ObjectType type);
-extern const char* GetHelpFilename(ObjectType type);
-extern const char* GetHelpFilename(const char *token);
+extern std::string GetHelpFilename(ObjectType type);
+extern std::string GetHelpFilename(const char *token);
extern bool IsType(const char *token);
extern bool IsFunction(const char *token);
extern const char* GetHelpText(const char *token);
diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp
index e44f82d..ab0528b 100644
--- a/src/script/cmdtoken.cpp
+++ b/src/script/cmdtoken.cpp
@@ -708,6 +708,7 @@ int GetBuild(char *line, int rank)
if ( Cmd(p, "AutoLab" ) ) return BUILD_LABO;
if ( Cmd(p, "PowerCaptor" ) ) return BUILD_PARA;
if ( Cmd(p, "ExchangePost" ) ) return BUILD_INFO;
+ if ( Cmd(p, "Destroyer" ) ) return BUILD_DESTROYER;
if ( Cmd(p, "FlatGround" ) ) return BUILD_GFLAT;
if ( Cmd(p, "Flag" ) ) return BUILD_FLAG;
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 57d638e..d5fe2ce 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -335,7 +335,9 @@ bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* us
rank = var->GetValInt();
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, rank));
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, rank));
if ( pObj == 0 )
{
result->SetPointer(0);
@@ -404,11 +406,13 @@ bool CScript::rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
bNearest = true;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj->GetTruck() != 0 ) continue; // object transported?
@@ -592,12 +596,14 @@ bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
iAngle = pThis->GetAngleY(0)+angle;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
if ( sens >= 0.0f ) best = 100000.0f;
else best = 0.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
@@ -778,6 +784,8 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
iAngle = pThis->GetAngleY(0)+angle;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
bGoal = 100000.0f;
pGoal = 0;
if ( sens >= 0.0f ) best = 100000.0f;
@@ -785,7 +793,7 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
@@ -885,7 +893,7 @@ bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
script->m_returnValue = 1.0f;
}
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskWait(0.3f);
if ( err != ERR_OK )
{
@@ -940,86 +948,143 @@ bool CScript::rDirection(CBotVar* var, CBotVar* result, int& exception, void* us
}
-// Compilation of the instruction "produce(pos, angle, type, scriptName)".
+// Compilation of the instruction "produce(pos, angle, type[, scriptName[, power]])"
+// or "produce(type[, power])".
CBotTypResult CScript::cProduce(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- ret = cPoint(var, user);
- if ( ret.GetType() != 0 ) return ret;
- if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GetNext();
+ if ( var->GetType() <= CBotTypDouble ) {
+ var = var->GetNext();
+ if( var != 0 ) {
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+ }
+ } else {
+ ret = cPoint(var, user);
+ if ( ret.GetType() != 0 ) return ret;
- if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GetNext();
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
- if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
- var = var->GetNext();
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+
+ if ( var != 0 ) {
+ if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
+ var = var->GetNext();
+
+ if ( var != 0 ) {
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+ }
+ }
+ }
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
}
-// Instruction "produce(pos, angle, type, scriptName)".
+// Instruction "produce(pos, angle, type[, scriptName[, power]])"
+// or "produce(type[, power])".
bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
{
CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CObject* object;
+ CObject* me = (static_cast<CObject *>(user));
CBotString cbs;
const char* name;
Math::Vector pos;
float angle;
ObjectType type;
+ float power;
- if ( !GetPoint(var, exception, pos) ) return true;
+ if ( var->GetType() <= CBotTypDouble ) {
+ type = static_cast<ObjectType>(var->GetValInt());
+ var = var->GetNext();
- angle = var->GetValFloat()*Math::PI/180.0f;
- var = var->GetNext();
+ pos = me->GetPosition(0);
- type = static_cast<ObjectType>(var->GetValInt());
- var = var->GetNext();
+ Math::Vector rotation = me->GetAngle(0) + me->GetInclinaison();
+ angle = rotation.y;
- cbs = var->GetValString();
- name = cbs;
-
- 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 )
- {
- object = new CObject(script->m_iMan);
+ if( var != 0 )
+ power = var->GetValFloat();
+ else
+ power = -1.0f;
+
+ name = "";
+ } else {
+ if ( !GetPoint(var, exception, pos) ) return true;
+
+ angle = var->GetValFloat()*Math::PI/180.0f;
+ var = var->GetNext();
+
+ type = static_cast<ObjectType>(var->GetValInt());
+ var = var->GetNext();
+
+ if ( var != 0 ) {
+ cbs = var->GetValString();
+ name = cbs;
+ var = var->GetNext();
+ if ( var != 0 ) {
+ power = var->GetValFloat();
+ } else {
+ power = -1.0f;
+ }
+ } else {
+ name = "";
+ power = -1.0f;
+ }
+ }
+
+ 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();
if ( !object->CreateResource(pos, angle, type) )
{
delete object;
result->SetValInt(1); // error
return true;
}
+ object->SetActivity(false);
}
else
if ( type == OBJECT_MOTHER ||
@@ -1030,7 +1095,7 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
{
CObject* egg;
- object = new CObject(script->m_iMan);
+ object = new CObject();
if ( !object->CreateInsect(pos, angle, type) )
{
delete object;
@@ -1038,18 +1103,123 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
return true;
}
- egg = new CObject(script->m_iMan);
+ egg = new CObject();
if ( !egg->CreateResource(pos, angle, OBJECT_EGG, 0.0f) )
{
delete egg;
}
+ object->SetActivity(false);
+ }
+ else
+ if ( type == OBJECT_PORTICO ||
+ type == OBJECT_BASE ||
+ type == OBJECT_DERRICK ||
+ type == OBJECT_FACTORY ||
+ type == OBJECT_STATION ||
+ type == OBJECT_CONVERT ||
+ type == OBJECT_REPAIR ||
+ type == OBJECT_DESTROYER||
+ type == OBJECT_TOWER ||
+ type == OBJECT_NEST ||
+ type == OBJECT_RESEARCH ||
+ type == OBJECT_RADAR ||
+ type == OBJECT_INFO ||
+ type == OBJECT_ENERGY ||
+ type == OBJECT_LABO ||
+ type == OBJECT_NUCLEAR ||
+ type == OBJECT_PARA ||
+ type == OBJECT_SAFE ||
+ type == OBJECT_HUSTON ||
+ type == OBJECT_TARGET1 ||
+ type == OBJECT_TARGET2 ||
+ type == OBJECT_START ||
+ type == OBJECT_END )
+ {
+ object = new CObject();
+ if ( !object->CreateBuilding(pos, angle, 0, type) )
+ {
+ delete object;
+ result->SetValInt(1); // error
+ return true;
+ }
+ object->SetActivity(false);
+ script->m_main->CreateShortcuts();
+ }
+ else
+ if ( type == OBJECT_FLAGb ||
+ type == OBJECT_FLAGr ||
+ type == OBJECT_FLAGg ||
+ type == OBJECT_FLAGy ||
+ type == OBJECT_FLAGv )
+ {
+ object = new CObject();
+ if ( !object->CreateFlag(pos, angle, type) )
+ {
+ delete object;
+ result->SetValInt(1); // error
+ return true;
+ }
+ object->SetActivity(false);
+ }
+ else
+ if ( type == OBJECT_HUMAN ||
+ type == OBJECT_TECH ||
+ type == OBJECT_TOTO ||
+ type == OBJECT_MOBILEfa ||
+ type == OBJECT_MOBILEta ||
+ type == OBJECT_MOBILEwa ||
+ type == OBJECT_MOBILEia ||
+ type == OBJECT_MOBILEfc ||
+ type == OBJECT_MOBILEtc ||
+ type == OBJECT_MOBILEwc ||
+ type == OBJECT_MOBILEic ||
+ type == OBJECT_MOBILEfi ||
+ type == OBJECT_MOBILEti ||
+ type == OBJECT_MOBILEwi ||
+ type == OBJECT_MOBILEii ||
+ type == OBJECT_MOBILEfs ||
+ type == OBJECT_MOBILEts ||
+ type == OBJECT_MOBILEws ||
+ type == OBJECT_MOBILEis ||
+ type == OBJECT_MOBILErt ||
+ type == OBJECT_MOBILErc ||
+ type == OBJECT_MOBILErr ||
+ type == OBJECT_MOBILErs ||
+ type == OBJECT_MOBILEsa ||
+ type == OBJECT_MOBILEtg ||
+ type == OBJECT_MOBILEft ||
+ type == OBJECT_MOBILEtt ||
+ type == OBJECT_MOBILEwt ||
+ type == OBJECT_MOBILEit ||
+ type == OBJECT_MOBILEdr ||
+ type == OBJECT_APOLLO2 )
+ {
+ object = new CObject();
+ if ( !object->CreateVehicle(pos, angle, type, power, false, false) )
+ {
+ delete object;
+ result->SetValInt(1); // error
+ return true;
+ }
+ object->UpdateMapping();
+ object->SetRange(30.0f);
+ object->SetZoom(0, 1.0f);
+ CPhysics* physics = object->GetPhysics();
+ if ( physics != 0 )
+ {
+ physics->SetFreeze(false); // can move
+ }
+ object->SetLock(false); // vehicle useable
+ object->SetManual(true);
+ object->SetActivity(true);
+ script->m_main->CreateShortcuts();
}
else
{
result->SetValInt(1); // impossible
return true;
}
- object->SetActivity(false);
+
object->ReadProgram(0, static_cast<const char*>(name));
object->RunProgram(0);
@@ -1243,7 +1413,7 @@ bool CScript::rWait(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
value = var->GetValFloat();
err = script->m_primaryTask->StartTaskWait(value);
if ( err != ERR_OK )
@@ -1274,7 +1444,7 @@ bool CScript::rMove(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
value = var->GetValFloat();
err = script->m_primaryTask->StartTaskAdvance(value*g_unit);
if ( err != ERR_OK )
@@ -1305,7 +1475,7 @@ bool CScript::rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
value = var->GetValFloat();
err = script->m_primaryTask->StartTaskTurn(-value*Math::PI/180.0f);
if ( err != ERR_OK )
@@ -1365,7 +1535,7 @@ bool CScript::rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
if ( !GetPoint(var, exception, pos) ) return true;
goal = TGG_DEFAULT;
@@ -1444,11 +1614,13 @@ bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
bArray = false;
}
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
best = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
@@ -1527,7 +1699,7 @@ bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
crash = TGC_DEFAULT;
altitude = 0.0f*g_unit;
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskGoto(pos, altitude, goal, crash);
if ( err != ERR_OK )
{
@@ -1570,7 +1742,7 @@ bool CScript::rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
if ( var == 0 )
{
type = TMA_FFRONT;
@@ -1621,7 +1793,7 @@ bool CScript::rDrop(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
if ( var == 0 ) type = TMA_FFRONT;
else type = static_cast<TaskManipArm>(var->GetValInt());
@@ -1663,7 +1835,7 @@ bool CScript::rSniff(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskSearch();
if ( err != ERR_OK )
{
@@ -1712,7 +1884,7 @@ bool CScript::rReceive(CBotVar* var, CBotVar* result, int& exception, void* user
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
cbs = var->GetValString();
p = cbs;
@@ -1782,7 +1954,7 @@ bool CScript::rSend(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
cbs = var->GetValString();
p = cbs;
@@ -1827,11 +1999,13 @@ CObject* CScript::SearchInfo(CScript* script, CObject* object, float power)
iPos = object->GetPosition(0);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -1990,7 +2164,7 @@ bool CScript::rThump(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskTerraform();
if ( err != ERR_OK )
{
@@ -2019,7 +2193,7 @@ bool CScript::rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskRecover();
if ( err != ERR_OK )
{
@@ -2081,7 +2255,7 @@ bool CScript::rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
{
pThis->SetParam(radius);
- *script->m_secondaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ *script->m_secondaryTask = new CTaskManager(script->m_object);
err = (*script->m_secondaryTask)->StartTaskShield(TSM_UP, 1000.0f);
if ( err != ERR_OK )
{
@@ -2154,7 +2328,7 @@ bool CScript::rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
type = pThis->GetType();
@@ -2186,21 +2360,40 @@ bool CScript::rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
return Process(script, result, exception);
}
+// Compilation of the instruction "aim(x, y)".
+
+CBotTypResult CScript::cAim(CBotVar* &var, void* user)
+{
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+
+ if ( var == 0 ) return CBotTypResult(CBotTypFloat);
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
+
+ return CBotTypResult(CBotTypFloat);
+}
+
// Instruction "aim(dir)".
bool CScript::rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
{
CScript* script = (static_cast<CObject *>(user))->GetRunScript();
- float value;
+ float x, y;
Error err;
exception = 0;
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- value = var->GetValFloat();
- err = script->m_primaryTask->StartTaskGunGoal(value*Math::PI/180.0f, 0.0f);
+ script->m_primaryTask = new CTaskManager(script->m_object);
+ x = var->GetValFloat();
+ var = var->GetNext();
+ var == 0 ? y=0.0f : y=var->GetValFloat();
+ err = script->m_primaryTask->StartTaskGunGoal(x*Math::PI/180.0f, y*Math::PI/180.0f);
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -2269,6 +2462,8 @@ bool CScript::rJet(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
+ if( value > 1.0f ) value = 1.0f;
+
physics->SetMotorSpeedY(value);
return true;
@@ -2513,7 +2708,7 @@ bool CScript::rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user
}
pThis->SetTraceDown(true);
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
@@ -2570,7 +2765,7 @@ bool CScript::rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user)
{
pThis->SetTraceDown(false);
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
@@ -2614,7 +2809,7 @@ bool CScript::rPenColor(CBotVar* var, CBotVar* result, int& exception, void* use
if ( color > 17 ) color = 17;
pThis->SetTraceColor(color);
- script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
+ script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
@@ -2660,27 +2855,24 @@ bool CScript::rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* use
// Object's constructor.
-CScript::CScript(CInstanceManager* iMan, CObject* object, CTaskManager** secondaryTask)
+CScript::CScript(CObject* object, CTaskManager** secondaryTask)
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_SCRIPT, this, 100);
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
- m_botProg = 0;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_water = m_engine->GetWater();
+ m_botProg = nullptr;
m_object = object;
- m_primaryTask = 0;
+ m_primaryTask = nullptr;
m_secondaryTask = secondaryTask;
- m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
+ m_interface = m_main->GetInterface();
+ m_displayText = m_main->GetDisplayText();
m_ipf = CBOT_IPF;
m_errMode = ERM_STOP;
m_len = 0;
- m_script = 0;
+ m_script = nullptr;
m_bRun = false;
m_bStepMode = false;
m_bCompile = false;
@@ -2731,7 +2923,7 @@ void CScript::InitFonctions()
CBotProgram::AddFunction("recycle", rRecycle, CScript::cNull);
CBotProgram::AddFunction("shield", rShield, CScript::cShield);
CBotProgram::AddFunction("fire", rFire, CScript::cFire);
- CBotProgram::AddFunction("aim", rAim, CScript::cOneFloat);
+ CBotProgram::AddFunction("aim", rAim, CScript::cAim);
CBotProgram::AddFunction("motor", rMotor, CScript::cMotor);
CBotProgram::AddFunction("jet", rJet, CScript::cOneFloat);
CBotProgram::AddFunction("topo", rTopo, CScript::cTopo);
@@ -2762,8 +2954,6 @@ CScript::~CScript()
m_script = nullptr;
m_len = 0;
-
- m_iMan->DeleteInstance(CLASS_SCRIPT, this);
}
@@ -3346,7 +3536,6 @@ void CScript::ColorizeScript(Ui::CEdit* edit)
cursor1 = bt->GetStart();
cursor2 = bt->GetEnd();
-
color = Gfx::FONT_HIGHLIGHT_NONE;
if ( type >= TokenKeyWord && type < TokenKeyWord+100 )
{
@@ -3376,7 +3565,7 @@ void CScript::ColorizeScript(Ui::CEdit* edit)
color =Gfx::FONT_HIGHLIGHT_CONST;
}
- if ( cursor1 < cursor2 && color != 0 )
+ if ( cursor1 < cursor2 && color != Gfx::FONT_HIGHLIGHT_NONE )
{
edit->SetFormat(cursor1, cursor2, color);
}
@@ -3712,7 +3901,7 @@ bool CScript::WriteScript(const char* filename)
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->SetText(m_script);
- edit->WriteText(name.c_str());
+ edit->WriteText(name);
m_interface->DeleteControl(EVENT_EDIT9);
return true;
}
diff --git a/src/script/script.h b/src/script/script.h
index dbd66a2..982d12b 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -29,7 +29,6 @@
#include <stdio.h>
-class CInstanceManager;
class CObject;
class CTaskManager;
class CRobotMain;
@@ -52,7 +51,7 @@ class CWater;
class CScript
{
public:
- CScript(CInstanceManager* iMan, CObject* object, CTaskManager** secondaryTask);
+ CScript(CObject* object, CTaskManager** secondaryTask);
~CScript();
static void InitFonctions();
@@ -117,6 +116,7 @@ private:
static CBotTypResult cTestInfo(CBotVar* &var, void* user);
static CBotTypResult cShield(CBotVar* &var, void* user);
static CBotTypResult cFire(CBotVar* &var, void* user);
+ static CBotTypResult cAim(CBotVar* &var, void* user);
static CBotTypResult cMotor(CBotVar* &var, void* user);
static CBotTypResult cTopo(CBotVar* &var, void* user);
static CBotTypResult cMessage(CBotVar* &var, void* user);
@@ -177,7 +177,7 @@ private:
static bool Process(CScript* script, CBotVar* result, int &exception);
static CObject* SearchInfo(CScript* script, CObject* object, float power);
- CInstanceManager* m_iMan;
+protected:
Gfx::CEngine* m_engine;
Ui::CInterface* m_interface;
Ui::CDisplayText* m_displayText;
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index f683a62..8c1cb81 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -15,31 +15,24 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// alsound.cpp
-
#include "alsound.h"
-
#define MIN(a, b) (a > b ? b : a)
ALSound::ALSound()
{
mEnabled = false;
m3D = false;
- mAudioVolume = MAXVOLUME;
+ mAudioVolume = 1.0f;
+ mMusicVolume = 1.0f;
mMute = false;
- auto pointer = CInstanceManager::GetInstancePointer();
- if (pointer != nullptr)
- CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
+ mCurrentMusic = nullptr;
}
ALSound::~ALSound()
{
- auto pointer = CInstanceManager::GetInstancePointer();
- if (pointer != nullptr)
- CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
CleanUp();
}
@@ -50,11 +43,20 @@ void ALSound::CleanUp()
GetLogger()->Info("Unloading files and closing device...\n");
StopAll();
- for (auto item : mSounds)
+ for (auto channel : mChannels) {
+ delete channel.second;
+ }
+
+ for (auto item : mSounds) {
delete item.second;
+ }
mEnabled = false;
- alutExit();
+
+ mCurrentMusic->FreeBuffer();
+ delete mCurrentMusic;
+ alcDestroyContext(mContext);
+ alcCloseDevice(mDevice);
}
}
@@ -67,13 +69,21 @@ bool ALSound::Create(bool b3D)
return true;
GetLogger()->Info("Opening audio device...\n");
- if (!alutInit(NULL, NULL)) {
- ALenum error = alutGetError();
- GetLogger()->Error("Could not open audio device! Reason: %s\n", alutGetErrorString(error));
+ mDevice = alcOpenDevice(NULL);
+ if (!mDevice) {
+ GetLogger()->Error("Could not open audio device!\n");
return false;
}
- GetLogger()->Info("Done.\n");
+ mContext = alcCreateContext(mDevice, NULL);
+ if (!mContext) {
+ GetLogger()->Error("Could not create audio context!\n");
+ return false;
+ }
+ alcMakeContextCurrent(mContext);
+
+ mCurrentMusic = new Channel();
+ GetLogger()->Info("Done.\n");
mEnabled = true;
return true;
}
@@ -100,7 +110,7 @@ bool ALSound::GetSound3DCap()
}
-bool ALSound::RetEnable()
+bool ALSound::GetEnable()
{
return mEnabled;
}
@@ -108,35 +118,35 @@ bool ALSound::RetEnable()
void ALSound::SetAudioVolume(int volume)
{
- alListenerf(AL_GAIN, MIN(volume, MAXVOLUME) * 0.01f);
- mAudioVolume = MIN(volume, MAXVOLUME);
+ mAudioVolume = MIN(static_cast<float>(volume) / MAXVOLUME, 1.0f);
+ alListenerf(AL_GAIN, mAudioVolume);
}
int ALSound::GetAudioVolume()
{
- float volume;
if ( !mEnabled )
return 0;
- alGetListenerf(AL_GAIN, &volume);
- return volume * MAXVOLUME;
+ return mAudioVolume * MAXVOLUME;
}
void ALSound::SetMusicVolume(int volume)
{
- // TODO stub! Add music support
+ mMusicVolume = MIN(static_cast<float>(volume) / MAXVOLUME, 1.0f);
+ if (mCurrentMusic) {
+ mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume);
+ }
}
int ALSound::GetMusicVolume()
{
- // TODO stub! Add music support
if ( !mEnabled )
- return 0;
+ return 0.0f;
- return 0;
+ return mMusicVolume * MAXVOLUME;
}
@@ -213,7 +223,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
it.second->SetPriority(priority);
channel = it.first;
- bAlreadyLoaded = true;
+ bAlreadyLoaded = it.second->IsLoaded();
return true;
}
@@ -238,8 +248,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
auto it = mChannels.end();
it--;
int i = (*it).first;
- while (++i)
- {
+ while (++i) {
if (mChannels.find(i) == mChannels.end()) {
Channel *chn = new Channel();
// check if channel is ready to play music, if not destroy it and seek free one
@@ -286,37 +295,38 @@ int ALSound::Play(Sound sound, float amplitude, float frequency, bool bLoop)
int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequency, bool bLoop)
{
- if (!mEnabled)
- return -1;
-
- if (mAudioVolume <= 0.0f)
+ if (!mEnabled) {
return -1;
+ }
if (mSounds.find(sound) == mSounds.end()) {
GetLogger()->Warn("Sound %d was not loaded!\n", sound);
return -1;
}
-
- GetLogger()->Trace("ALSound::Play sound: %d volume: %f frequency: %f\n", sound, amplitude, frequency);
int channel;
- bool bAlreadyLoaded;
+ bool bAlreadyLoaded = false;
if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded))
return -1;
- if ( !bAlreadyLoaded ) {
- mChannels[channel]->SetBuffer(mSounds[sound]);
- }
+ if (!bAlreadyLoaded) {
+ if (!mChannels[channel]->SetBuffer(mSounds[sound])) {
+ mChannels[channel]->SetBuffer(nullptr);
+ return -1;
+ }
+ }
Position(channel, pos);
// setting initial values
- mChannels[channel]->SetStartAmplitude(mAudioVolume);
+ mChannels[channel]->SetStartAmplitude(amplitude);
mChannels[channel]->SetStartFrequency(frequency);
mChannels[channel]->SetChangeFrequency(1.0f);
mChannels[channel]->ResetOper();
- mChannels[channel]->AdjustFrequency(frequency);
- mChannels[channel]->AdjustVolume(amplitude * mAudioVolume);
+ mChannels[channel]->SetFrequency(frequency);
+ mChannels[channel]->SetVolume(amplitude * mAudioVolume);
+ mChannels[channel]->SetLoop(bLoop);
mChannels[channel]->Play();
+
return channel;
}
@@ -340,15 +350,16 @@ bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float t
if (mChannels.find(channel) == mChannels.end()) {
return false;
}
-
+
SoundOper op;
op.finalAmplitude = amplitude;
op.finalFrequency = frequency;
op.totalTime = time;
op.nextOper = oper;
+ op.currentTime = 0.0f;
mChannels[channel]->AddOper(op);
- return false;
+ return true;
}
@@ -375,7 +386,8 @@ bool ALSound::Frequency(int channel, float frequency)
return false;
}
- mChannels[channel]->SetFrequency(frequency);
+ mChannels[channel]->SetFrequency(frequency * mChannels[channel]->GetInitFrequency());
+ mChannels[channel]->SetChangeFrequency(frequency);
return true;
}
@@ -422,13 +434,12 @@ bool ALSound::MuteAll(bool bMute)
volume = mAudioVolume;
for (auto channel : mChannels) {
- channel.second->SetVolume(volume);
+ channel.second->SetVolume(volume * mAudioVolume);
}
return true;
}
-
void ALSound::FrameMove(float delta)
{
if (!mEnabled)
@@ -437,35 +448,38 @@ void ALSound::FrameMove(float delta)
float progress;
float volume, frequency;
for (auto it : mChannels) {
- if (!it.second->IsPlaying())
+ if (!it.second->IsPlaying()) {
continue;
+ }
if (!it.second->HasEnvelope())
continue;
- //it.second->GetEnvelope().currentTime += delta;
- SoundOper oper = it.second->GetEnvelope();
- progress = it.second->GetCurrentTime() / oper.totalTime;
+ SoundOper &oper = it.second->GetEnvelope();
+ oper.currentTime += delta;
+ progress = oper.currentTime / oper.totalTime;
progress = MIN(progress, 1.0f);
-
+
// setting volume
- volume = progress * abs(oper.finalAmplitude - it.second->GetStartAmplitude());
- it.second->AdjustVolume(volume * mAudioVolume);
+ volume = progress * (oper.finalAmplitude - it.second->GetStartAmplitude());
+ volume = (volume + it.second->GetStartAmplitude()) * mAudioVolume;
+ it.second->SetVolume(volume);
// setting frequency
- frequency = progress * abs(oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency();
+ frequency = progress * (oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency() * it.second->GetInitFrequency();
it.second->AdjustFrequency(frequency);
- if (it.second->GetEnvelope().totalTime <= it.second->GetCurrentTime()) {
-
+ if (oper.totalTime <= oper.currentTime) {
if (oper.nextOper == SOPER_LOOP) {
- GetLogger()->Trace("ALSound::FrameMove oper: replay.\n");
- it.second->SetCurrentTime(0.0f);
+ oper.currentTime = 0.0f;
it.second->Play();
} else {
- GetLogger()->Trace("ALSound::FrameMove oper: next.\n");
it.second->SetStartAmplitude(oper.finalAmplitude);
it.second->SetStartFrequency(oper.finalFrequency);
+ if (oper.nextOper == SOPER_STOP) {
+ it.second->Stop();
+ }
+
it.second->PopEnvelope();
}
}
@@ -483,32 +497,86 @@ void ALSound::SetListener(Math::Vector eye, Math::Vector lookat)
bool ALSound::PlayMusic(int rank, bool bRepeat)
{
- // TODO stub! Add music support
+ if (!mEnabled) {
+ return false;
+ }
+
+ if (static_cast<int>(mCurrentMusic->GetSoundType()) != rank) {
+ // check if we have music in cache
+ for (auto music : mMusicCache) {
+ if (static_cast<int>(music->GetSoundType()) == rank) {
+ GetLogger()->Debug("Music loaded from cache\n");
+ mCurrentMusic->SetBuffer(music);
+
+ mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume);
+ mCurrentMusic->SetLoop(bRepeat);
+ mCurrentMusic->Play();
+ return true;
+ }
+ }
+
+ // we cache only 3 music files
+ if (mMusicCache.size() == 3) {
+ mCurrentMusic->FreeBuffer();
+ mMusicCache.pop_back();
+ }
+
+ if (mMusic.find(rank) == mMusic.end()) {
+ GetLogger()->Info("Requested music %d was not found.\n", rank);
+ return false;
+ }
+
+ Buffer *buffer = new Buffer();
+ mMusicCache.push_front(buffer);
+ buffer->LoadFromFile(mMusic.at(rank), static_cast<Sound>(rank));
+ mCurrentMusic->SetBuffer(buffer);
+ mMusicCache[rank] = buffer;
+ }
+
+ mCurrentMusic->SetVolume(mMusicVolume * mAudioVolume);
+ mCurrentMusic->SetLoop(bRepeat);
+ mCurrentMusic->Play();
+
return true;
}
bool ALSound::RestartMusic()
{
- // TODO stub! Add music support
+ if (!mEnabled || !mCurrentMusic) {
+ return false;
+ }
+
+ mCurrentMusic->Stop();
+ mCurrentMusic->Play();
return true;
}
void ALSound::StopMusic()
{
- // TODO stub! Add music support
+ if (!mEnabled || !mCurrentMusic) {
+ return;
+ }
+
SuspendMusic();
}
bool ALSound::IsPlayingMusic()
{
- // TODO stub! Add music support
- return true;
+ if (!mEnabled || !mCurrentMusic) {
+ return false;
+ }
+
+ return mCurrentMusic->IsPlaying();
}
void ALSound::SuspendMusic()
{
- // TODO stub! Add music support
+ if (!mEnabled || !mCurrentMusic) {
+ return;
+ }
+
+ mCurrentMusic->Stop();
}
diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h
index 7d24ba6..bdf06b1 100644
--- a/src/sound/oalsound/alsound.h
+++ b/src/sound/oalsound/alsound.h
@@ -22,9 +22,8 @@
#include <map>
#include <string>
-#include <AL/alut.h>
+#include <AL/al.h>
-#include "common/iman.h"
#include "common/logger.h"
#include "sound/sound.h"
@@ -42,7 +41,7 @@ class ALSound : public CSoundInterface
bool Create(bool b3D);
bool Cache(Sound, std::string);
- bool RetEnable();
+ bool GetEnable();
void SetSound3D(bool bMode);
bool GetSound3D();
@@ -86,9 +85,12 @@ class ALSound : public CSoundInterface
bool mEnabled;
bool m3D;
bool mMute;
- int mAudioVolume;
- ALCdevice* audioDevice;
- ALCcontext* audioContext;
+ float mAudioVolume;
+ float mMusicVolume;
+ ALCdevice* mDevice;
+ ALCcontext* mContext;
std::map<Sound, Buffer*> mSounds;
std::map<int, Channel*> mChannels;
+ std::deque<Buffer*> mMusicCache;
+ Channel *mCurrentMusic;
};
diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp
index dbfdca2..edc3d74 100644
--- a/src/sound/oalsound/buffer.cpp
+++ b/src/sound/oalsound/buffer.cpp
@@ -14,13 +14,12 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// buffer.cpp
#include "buffer.h"
Buffer::Buffer() {
mLoaded = false;
- mDuration = 0;
+ mDuration = 0.0f;
}
@@ -35,26 +34,43 @@ Buffer::~Buffer() {
bool Buffer::LoadFromFile(std::string filename, Sound sound) {
mSound = sound;
-
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
- mBuffer = alutCreateBufferFromFile(filename.c_str());
- ALenum error = alutGetError();
- if (error) {
- GetLogger()->Warn("Failed to load file. Reason: %s\n", alutGetErrorString(error));
+ SF_INFO fileInfo;
+ SNDFILE *file = sf_open(filename.c_str(), SFM_READ, &fileInfo);
+
+ GetLogger()->Trace(" channels %d\n", fileInfo.channels);
+ GetLogger()->Trace(" format %d\n", fileInfo.format);
+ GetLogger()->Trace(" frames %d\n", fileInfo.frames);
+ GetLogger()->Trace(" samplerate %d\n", fileInfo.samplerate);
+ GetLogger()->Trace(" sections %d\n", fileInfo.sections);
+
+ if (!file) {
+ GetLogger()->Warn("Could not load file. Reason: %s\n", sf_strerror(file));
mLoaded = false;
return false;
}
- ALint size, bits, channels, freq;
-
- alGetBufferi(mBuffer, AL_SIZE, &size);
- alGetBufferi(mBuffer, AL_BITS, &bits);
- alGetBufferi(mBuffer, AL_CHANNELS, &channels);
- alGetBufferi(mBuffer, AL_FREQUENCY, &freq);
+ alGenBuffers(1, &mBuffer);
+ if (!mBuffer) {
+ GetLogger()->Warn("Could not create audio buffer\n");
+ mLoaded = false;
+ sf_close(file);
+ return false;
+ }
- mDuration = static_cast<ALfloat>(size) / channels / bits / 8 / static_cast<ALfloat>(freq);
+ // read chunks of 4096 samples
+ std::vector<uint16_t> data;
+ std::array<int16_t, 4096> buffer;
+ data.reserve(fileInfo.frames);
+ size_t read = 0;
+ while ((read = sf_read_short(file, buffer.data(), buffer.size())) != 0) {
+ data.insert(data.end(), buffer.begin(), buffer.begin() + read);
+ }
+ sf_close(file);
+ alBufferData(mBuffer, fileInfo.channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, &data.front(), data.size() * sizeof(uint16_t), fileInfo.samplerate);
+ mDuration = static_cast<float>(fileInfo.frames) / fileInfo.samplerate;
mLoaded = true;
return true;
}
diff --git a/src/sound/oalsound/buffer.h b/src/sound/oalsound/buffer.h
index 8c4a2d3..7286deb 100644
--- a/src/sound/oalsound/buffer.h
+++ b/src/sound/oalsound/buffer.h
@@ -19,8 +19,11 @@
#pragma once
#include <string>
+#include <vector>
+#include <array>
-#include <AL/alut.h>
+#include <AL/al.h>
+#include <sndfile.h>
#include "sound/sound.h"
#include "common/logger.h"
diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp
index 7d8244b..19394c6 100644
--- a/src/sound/oalsound/channel.cpp
+++ b/src/sound/oalsound/channel.cpp
@@ -14,10 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// channel.cpp
#include "channel.h"
+#define MIN(a, b) (a > b ? b : a)
Channel::Channel() {
alGenSources(1, &mSource);
@@ -31,11 +31,17 @@ Channel::Channel() {
mPriority = 0;
mBuffer = nullptr;
+ mLoop = false;
+ mInitFrequency = 0.0f;
+ mStartAmplitude = 0.0f;
+ mStartFrequency = 0.0f;
+ mChangeFrequency = 0.0f;
}
Channel::~Channel() {
if (mReady) {
+ alSourceStop(mSource);
alSourcei(mSource, AL_BUFFER, 0);
alDeleteSources(1, &mSource);
if (alCheck())
@@ -45,9 +51,10 @@ Channel::~Channel() {
bool Channel::Play() {
- if (!mReady)
+ if (!mReady || mBuffer == nullptr)
return false;
-
+
+ alSourcei(mSource, AL_LOOPING, static_cast<ALint>(mLoop));
alSourcePlay(mSource);
if (alCheck())
GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode());
@@ -56,7 +63,7 @@ bool Channel::Play() {
bool Channel::SetPosition(Math::Vector pos) {
- if (!mReady)
+ if (!mReady || mBuffer == nullptr)
return false;
alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z);
@@ -70,7 +77,7 @@ bool Channel::SetPosition(Math::Vector pos) {
bool Channel::SetFrequency(float freq)
{
- if (!mReady)
+ if (!mReady || mBuffer == nullptr)
return false;
alSourcef(mSource, AL_PITCH, freq);
@@ -82,10 +89,19 @@ bool Channel::SetFrequency(float freq)
}
+bool Channel::AdjustFrequency(float freq)
+{
+ if (!mReady || mBuffer == nullptr)
+ return false;
+
+ return SetFrequency(mInitFrequency + fabs(freq));
+}
+
+
float Channel::GetFrequency()
{
ALfloat freq;
- if (!mReady)
+ if (!mReady || mBuffer == nullptr)
return 0;
alGetSourcef(mSource, AL_PITCH, &freq);
@@ -100,10 +116,10 @@ float Channel::GetFrequency()
bool Channel::SetVolume(float vol)
{
- if (!mReady || vol < 0)
+ if (!mReady || vol < 0 || mBuffer == nullptr)
return false;
- alSourcef(mSource, AL_GAIN, vol / MAXVOLUME);
+ alSourcef(mSource, AL_GAIN, MIN(powf(vol, 0.2f), 1.0f));
if (alCheck()) {
GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
return false;
@@ -115,7 +131,7 @@ bool Channel::SetVolume(float vol)
float Channel::GetVolume()
{
ALfloat vol;
- if (!mReady)
+ if (!mReady || mBuffer == nullptr)
return 0;
alGetSourcef(mSource, AL_GAIN, &vol);
@@ -124,7 +140,7 @@ float Channel::GetVolume()
return 0;
}
- return vol * MAXVOLUME;
+ return vol;
}
@@ -143,6 +159,7 @@ void Channel::SetPriority(int pri)
void Channel::SetStartAmplitude(float gain)
{
mStartAmplitude = gain;
+ SetVolume(mStartAmplitude);
}
@@ -158,12 +175,6 @@ void Channel::SetChangeFrequency(float freq)
}
-void Channel::SetInitFrequency(float freq)
-{
- mInitFrequency = freq;
-}
-
-
float Channel::GetStartAmplitude()
{
return mStartAmplitude;
@@ -201,6 +212,9 @@ void Channel::ResetOper()
Sound Channel::GetSoundType() {
+ if (!mReady || mBuffer == nullptr)
+ return SOUND_NONE;
+
return mBuffer->GetSoundType();
}
@@ -208,9 +222,14 @@ Sound Channel::GetSoundType() {
bool Channel::SetBuffer(Buffer *buffer) {
if (!mReady)
return false;
-
- assert(buffer);
+
+ Stop();
mBuffer = buffer;
+ if (buffer == nullptr) {
+ alSourcei(mSource, AL_BUFFER, 0);
+ return true;
+ }
+
alSourcei(mSource, AL_BUFFER, buffer->GetBuffer());
if (alCheck()) {
GetLogger()->Warn("Could not set sound buffer. Code: %d\n", alGetCode());
@@ -221,19 +240,26 @@ bool Channel::SetBuffer(Buffer *buffer) {
}
-void Channel::AdjustFrequency(float freq) {
- SetFrequency(freq * mInitFrequency);
-}
-
+bool Channel::FreeBuffer() {
+ if (!mReady)
+ return false;
+
+ if (!mBuffer) {
+ return false;
+ }
-void Channel::AdjustVolume(float volume) {
- SetVolume(mStartAmplitude * volume);
+ alSourceStop(mSource);
+ alSourcei(mSource, AL_BUFFER, 0);
+ delete mBuffer;
+ mBuffer = nullptr;
+ return true;
}
bool Channel::IsPlaying() {
ALint status;
- if (!mReady) return false;
+ if (!mReady || mBuffer == nullptr)
+ return false;
alGetSourcei(mSource, AL_SOURCE_STATE, &status);
if (alCheck()) {
@@ -249,8 +275,15 @@ bool Channel::IsReady() {
return mReady;
}
+bool Channel::IsLoaded() {
+ return mBuffer != nullptr;
+}
+
bool Channel::Stop() {
+ if (!mReady || mBuffer == nullptr)
+ return false;
+
alSourceStop(mSource);
if (alCheck()) {
GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode());
@@ -262,6 +295,9 @@ bool Channel::Stop() {
float Channel::GetCurrentTime()
{
+ if (!mReady || mBuffer == nullptr)
+ return 0.0f;
+
ALfloat current;
alGetSourcef(mSource, AL_SEC_OFFSET, &current);
if (alCheck()) {
@@ -274,6 +310,9 @@ float Channel::GetCurrentTime()
void Channel::SetCurrentTime(float current)
{
+ if (!mReady || mBuffer == nullptr)
+ return;
+
alSourcef(mSource, AL_SEC_OFFSET, current);
if (alCheck())
GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode());
@@ -282,6 +321,9 @@ void Channel::SetCurrentTime(float current)
float Channel::GetDuration()
{
+ if (!mReady || mBuffer == nullptr)
+ return 0.0f;
+
return mBuffer->GetDuration();
}
@@ -302,3 +344,8 @@ void Channel::PopEnvelope()
{
mOper.pop_front();
}
+
+
+void Channel::SetLoop(bool loop) {
+ mLoop = loop;
+}
diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h
index 165ff50..8965306 100644
--- a/src/sound/oalsound/channel.h
+++ b/src/sound/oalsound/channel.h
@@ -35,6 +35,7 @@ struct SoundOper
float finalAmplitude;
float finalFrequency;
float totalTime;
+ float currentTime;
SoundNext nextOper;
};
@@ -51,6 +52,7 @@ class Channel
bool SetFrequency(float);
float GetFrequency();
+ bool AdjustFrequency(float);
float GetCurrentTime();
void SetCurrentTime(float);
@@ -60,8 +62,11 @@ class Channel
float GetVolume();
bool IsPlaying();
bool IsReady();
+ bool IsLoaded();
bool SetBuffer(Buffer *);
+ bool FreeBuffer();
+
bool HasEnvelope();
SoundOper& GetEnvelope();
void PopEnvelope();
@@ -72,7 +77,6 @@ class Channel
void SetStartAmplitude(float);
void SetStartFrequency(float);
void SetChangeFrequency(float);
- void SetInitFrequency(float);
float GetStartAmplitude();
float GetStartFrequency();
@@ -82,8 +86,7 @@ class Channel
void AddOper(SoundOper);
void ResetOper();
Sound GetSoundType();
- void AdjustFrequency(float);
- void AdjustVolume(float);
+ void SetLoop(bool);
private:
Buffer *mBuffer;
@@ -96,4 +99,5 @@ class Channel
float mInitFrequency;
std::deque<SoundOper> mOper;
bool mReady;
+ bool mLoop;
};
diff --git a/src/sound/sound.h b/src/sound/sound.h
index 518e2ad..70139ea 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -22,22 +22,23 @@
#pragma once
+#include <boost/filesystem.hpp>
#include "math/vector.h"
-#include "common/iman.h"
#include "common/logger.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
+#include <map>
/*!
* Maximum possible audio volume
*/
-#define MAXVOLUME 100
+#define MAXVOLUME 100.0f
/**
@@ -47,6 +48,7 @@
**/
enum Sound
{
+ SOUND_NONE = -1,
SOUND_CLICK = 0,
SOUND_BOUM = 1,
SOUND_EXPLO = 2,
@@ -153,11 +155,8 @@ enum SoundNext
class CSoundInterface
{
public:
- inline CSoundInterface() {
- CInstanceManager::GetInstance().AddInstance(CLASS_SOUND, this);
- //m_iMan->AddInstance(CLASS_SOUND, this);
- };
- inline virtual ~CSoundInterface() {};
+ inline CSoundInterface() {}
+ inline virtual ~CSoundInterface() {}
/** Function to initialize sound device
* \param b3D - enable support for 3D sound
@@ -176,6 +175,16 @@ class CSoundInterface
}
};
+ /** Function called to add all music files to list */
+ inline void AddMusicFiles(std::string path) {
+ for ( int i = 1; i <= 12; i++ ) {
+ std::stringstream filename;
+ filename << path << "/music" << std::setfill('0') << std::setw(3) << i << ".ogg";
+ if (boost::filesystem::exists(filename.str()))
+ mMusic[i] = filename.str();
+ }
+ };
+
/** Function called to cache sound effect file.
* This function is called by plugin interface for each file.
* \param bSound - id of a file, will be used to identify sound files
@@ -327,5 +336,8 @@ class CSoundInterface
* \return return true if music is playing
*/
inline virtual bool IsPlayingMusic() {return true;};
+
+ protected:
+ std::map<int, std::string> mMusic;
};
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index f6c6112..0be2bd5 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -1,5 +1,4 @@
set(CONVERT_MODEL_SOURCES
-../common/iman.cpp
../common/logger.cpp
../common/stringutils.cpp
../graphics/engine/modelfile.cpp
@@ -8,6 +7,8 @@ convert_model.cpp
include_directories(. ..)
+include_directories(SYSTEM ${SDL_INCLUDE_DIR})
+
add_definitions(-DMODELFILE_NO_ENGINE)
add_executable(convert_model ${CONVERT_MODEL_SOURCES})
diff --git a/src/tools/convert_model.cpp b/src/tools/convert_model.cpp
index a33d7d0..463b83a 100644
--- a/src/tools/convert_model.cpp
+++ b/src/tools/convert_model.cpp
@@ -1,4 +1,3 @@
-#include "common/iman.h"
#include "common/logger.h"
#include "graphics/engine/modelfile.h"
@@ -8,11 +7,10 @@
bool EndsWith(std::string const &fullString, std::string const &ending)
{
- if (fullString.length() >= ending.length()) {
+ if (fullString.length() >= ending.length())
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
- } else {
+ else
return false;
- }
}
@@ -20,7 +18,6 @@ struct Args
{
bool usage;
bool dumpInfo;
- bool mirror;
std::string inputFile;
std::string outputFile;
std::string inputFormat;
@@ -30,7 +27,6 @@ struct Args
{
usage = false;
dumpInfo = false;
- mirror = false;
}
};
@@ -43,8 +39,7 @@ void PrintUsage(const std::string& program)
std::cerr << "Usage:" << std::endl;
std::cerr << std::endl;
std::cerr << " Convert files:" << std::endl;
- std::cerr << " " << program << " -i input_file -if input_format -o output_file -of output_format [-m]" << std::endl;
- std::cerr << " -m => mirror" << std::endl;
+ std::cerr << " " << program << " -i input_file -if input_format -o output_file -of output_format" << std::endl;
std::cerr << std::endl;
std::cerr << " Dump info:" << std::endl;
std::cerr << " " << program << " -d -i input_file -if input_format" << std::endl;
@@ -117,10 +112,6 @@ bool ParseArgs(int argc, char *argv[])
{
ARGS.dumpInfo = true;
}
- else if (arg == "-m")
- {
- ARGS.mirror = true;
- }
else
{
return false;
@@ -142,6 +133,18 @@ bool ParseArgs(int argc, char *argv[])
return true;
}
+std::ostream& operator<<(std::ostream& stream, Gfx::LODLevel lodLevel)
+{
+ switch (lodLevel)
+ {
+ case Gfx::LOD_Constant: stream << "constant"; break;
+ case Gfx::LOD_High: stream << "high"; break;
+ case Gfx::LOD_Medium: stream << "medium"; break;
+ case Gfx::LOD_Low: stream << "low"; break;
+ }
+ return stream;
+}
+
template<typename T>
void PrintStats(const std::map<T, int>& stats, int total)
{
@@ -165,8 +168,7 @@ int main(int argc, char *argv[])
if (ARGS.usage)
return 0;
- CInstanceManager iMan;
- Gfx::CModelFile model(&iMan);
+ Gfx::CModelFile model;
bool ok = true;
@@ -198,25 +200,25 @@ int main(int argc, char *argv[])
{
const std::vector<Gfx::ModelTriangle>& triangles = model.GetTriangles();
- Math::Vector min( Math::HUGE_NUM, Math::HUGE_NUM, Math::HUGE_NUM);
- Math::Vector max(-Math::HUGE_NUM, -Math::HUGE_NUM, -Math::HUGE_NUM);
+ Math::Vector bboxMin( Math::HUGE_NUM, Math::HUGE_NUM, Math::HUGE_NUM);
+ Math::Vector bboxMax(-Math::HUGE_NUM, -Math::HUGE_NUM, -Math::HUGE_NUM);
std::map<std::string, int> texs1, texs2;
std::map<int, int> states;
- std::map<float, int> mins, maxs;
+ std::map<Gfx::LODLevel, int> lodLevels;
int variableTexs2 = 0;
for (int i = 0; i < static_cast<int>( triangles.size() ); ++i)
{
const Gfx::ModelTriangle& t = triangles[i];
- min.x = Math::Min(t.p1.coord.x, t.p2.coord.x, t.p3.coord.x, min.x);
- min.y = Math::Min(t.p1.coord.y, t.p2.coord.y, t.p3.coord.y, min.y);
- min.z = Math::Min(t.p1.coord.z, t.p2.coord.z, t.p3.coord.z, min.z);
+ bboxMin.x = Math::Min(t.p1.coord.x, t.p2.coord.x, t.p3.coord.x, bboxMin.x);
+ bboxMin.y = Math::Min(t.p1.coord.y, t.p2.coord.y, t.p3.coord.y, bboxMin.y);
+ bboxMin.z = Math::Min(t.p1.coord.z, t.p2.coord.z, t.p3.coord.z, bboxMin.z);
- max.x = Math::Max(t.p1.coord.x, t.p2.coord.x, t.p3.coord.x, max.x);
- max.y = Math::Max(t.p1.coord.y, t.p2.coord.y, t.p3.coord.y, max.y);
- max.z = Math::Max(t.p1.coord.z, t.p2.coord.z, t.p3.coord.z, max.z);
+ bboxMax.x = Math::Max(t.p1.coord.x, t.p2.coord.x, t.p3.coord.x, bboxMax.x);
+ bboxMax.y = Math::Max(t.p1.coord.y, t.p2.coord.y, t.p3.coord.y, bboxMax.y);
+ bboxMax.z = Math::Max(t.p1.coord.z, t.p2.coord.z, t.p3.coord.z, bboxMax.z);
texs1[t.tex1Name] += 1;
if (! t.tex2Name.empty())
@@ -225,16 +227,15 @@ int main(int argc, char *argv[])
variableTexs2 += 1;
states[t.state] += 1;
- mins[t.min] += 1;
- maxs[t.max] += 1;
+ lodLevels[t.lodLevel] += 1;
}
std::cerr << "---- Info ----" << std::endl;
std::cerr << "Total triangles: " << triangles.size();
std::cerr << std::endl;
std::cerr << "Bounding box:" << std::endl;
- std::cerr << " min: [" << min.x << ", " << min.y << ", " << min.z << "]" << std::endl;
- std::cerr << " max: [" << max.x << ", " << max.y << ", " << max.z << "]" << std::endl;
+ std::cerr << " bboxMin: [" << bboxMin.x << ", " << bboxMin.y << ", " << bboxMin.z << "]" << std::endl;
+ std::cerr << " bboxMax: [" << bboxMax.x << ", " << bboxMax.y << ", " << bboxMax.z << "]" << std::endl;
std::cerr << std::endl;
std::cerr << "Textures:" << std::endl;
std::cerr << " tex1:" << std::endl;
@@ -247,17 +248,11 @@ int main(int argc, char *argv[])
PrintStats(states, triangles.size());
std::cerr << std::endl;
std::cerr << "LOD:" << std::endl;
- std::cerr << " min:" << std::endl;
- PrintStats(mins, triangles.size());
- std::cerr << " max:" << std::endl;
- PrintStats(maxs, triangles.size());
+ PrintStats(lodLevels, triangles.size());
return 0;
}
- if (ARGS.mirror)
- model.Mirror();
-
if (ARGS.outputFormat == "old")
{
ok = model.WriteModel(ARGS.outputFile);
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index e3dbc30..a68b34d 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -16,7 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-
#include "ui/button.h"
#include "common/event.h"
diff --git a/src/ui/button.h b/src/ui/button.h
index 33a48ee..a9aa020 100644
--- a/src/ui/button.h
+++ b/src/ui/button.h
@@ -25,31 +25,29 @@
namespace Ui {
- class CButton : public CControl
- {
- public:
- CButton();
- virtual ~CButton();
+class CButton : public CControl
+{
+public:
+ CButton();
+ virtual ~CButton();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetImmediat(bool bRepeat);
- bool GetImmediat();
+ void SetImmediat(bool bRepeat);
+ bool GetImmediat();
- void SetRepeat(bool bRepeat);
- bool GetRepeat();
+ void SetRepeat(bool bRepeat);
+ bool GetRepeat();
- protected:
-
- protected:
- bool m_bCapture;
- bool m_bImmediat;
- bool m_bRepeat;
- float m_repeat;
- };
+protected:
+ bool m_bCapture;
+ bool m_bImmediat;
+ bool m_bRepeat;
+ float m_repeat;
+};
}
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index bc80b7c..761264d 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.cpp
@@ -19,7 +19,6 @@
#include "ui/check.h"
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
diff --git a/src/ui/check.h b/src/ui/check.h
index af26add..65bc367 100644
--- a/src/ui/check.h
+++ b/src/ui/check.h
@@ -22,27 +22,24 @@
#include "ui/control.h"
-namespace Gfx{
- class CEngine;
+namespace Gfx {
+class CEngine;
}
namespace Ui {
- class CCheck : public CControl
- {
- public:
- CCheck();
- virtual ~CCheck();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+class CCheck : public CControl
+{
+public:
+ CCheck();
+ virtual ~CCheck();
- bool EventProcess(const Event &event);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- void Draw();
+ bool EventProcess(const Event &event);
- protected:
-
- protected:
- };
+ void Draw();
+};
}
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index 65f9770..fd05bd9 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -19,7 +19,6 @@
#include "ui/color.h"
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -37,7 +36,6 @@ const float DELAY2 = 0.1f;
// Object's constructor.
-//CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
CColor::CColor() : CControl()
{
m_bRepeat = false;
diff --git a/src/ui/color.h b/src/ui/color.h
index 311a532..ec2c537 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -23,37 +23,34 @@
namespace Gfx{
- class CEngine;
- struct Color;
+class CEngine;
+struct Color;
}
namespace Ui {
- class CColor : public CControl
- {
- public:
- // CColor(CInstanceManager* iMan);
- CColor();
- virtual ~CColor();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+class CColor : public CControl
+{
+public:
+ CColor();
+ virtual ~CColor();
- bool EventProcess(const Event &event);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- void Draw();
+ bool EventProcess(const Event &event);
- void SetRepeat(bool bRepeat);
- bool GetRepeat();
+ void Draw();
- void SetColor(Gfx::Color color);
- Gfx::Color GetColor();
+ void SetRepeat(bool bRepeat);
+ bool GetRepeat();
- protected:
-
- protected:
- bool m_bRepeat;
- float m_repeat;
- Gfx::Color m_color;
- };
+ void SetColor(Gfx::Color color);
+ Gfx::Color GetColor();
+protected:
+ bool m_bRepeat;
+ float m_repeat;
+ Gfx::Color m_color;
+};
}
diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp
index 1bc0f8c..ac97cb8 100644
--- a/src/ui/compass.cpp
+++ b/src/ui/compass.cpp
@@ -15,10 +15,10 @@
// * 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 "ui/compass.h"
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "graphics/core/device.h"
@@ -29,7 +29,6 @@
namespace Ui {
// Object's constructor.
-//CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan)
CCompass::CCompass() : CControl()
{
m_dir = 0.0f;
diff --git a/src/ui/compass.h b/src/ui/compass.h
index 09eec9d..18546e5 100644
--- a/src/ui/compass.h
+++ b/src/ui/compass.h
@@ -23,32 +23,29 @@
namespace Gfx {
- class CEngine;
+class CEngine;
}
namespace Ui {
- class CCompass : public CControl
- {
- public:
- // CCompass(CInstanceManager* iMan);
- CCompass();
- virtual ~CCompass();
+class CCompass : public CControl
+{
+public:
+ CCompass();
+ virtual ~CCompass();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetDirection(float dir);
- float GetDirection();
+ void SetDirection(float dir);
+ float GetDirection();
- protected:
-
- protected:
- float m_dir;
- };
+protected:
+ float m_dir;
+};
}
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 718ad3b..6dc92cd 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -18,25 +18,23 @@
#include "ui/control.h"
+#include "app/app.h"
+
namespace Ui {
// Object's constructor.
CControl::CControl()
{
- m_iMan = CInstanceManager::GetInstancePointer();
-
- m_engine = static_cast< Gfx::CEngine* > ( m_iMan->SearchInstance(CLASS_ENGINE) );
- m_event = static_cast< CEventQueue* > ( m_iMan->SearchInstance(CLASS_EVENT) );
- m_main = static_cast< CRobotMain* > ( m_iMan->SearchInstance(CLASS_MAIN) );
- m_particle = static_cast< Gfx::CParticle* > (m_iMan->SearchInstance(CLASS_PARTICULE));
- m_sound = static_cast< CSoundInterface* > (m_iMan->SearchInstance(CLASS_SOUND));
- m_eventType = EVENT_NULL;
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_eventType = EVENT_NULL;
m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT;
m_fontSize = Gfx::FONT_SIZE_SMALL;
-// m_fontStretch = Gfx::FONT_NORM_STRETCH; //there is font stretching no more master
m_fontType = Gfx::FONT_COLOBOT;
m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
-// m_justif = 0;
m_bFocus = false;
m_bCapture = false;
diff --git a/src/ui/control.h b/src/ui/control.h
index 635ae12..7f5077d 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -22,7 +22,6 @@
#include <string>
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
@@ -39,108 +38,106 @@
namespace Ui {
- enum ControlState
- {
- STATE_ENABLE = (1<<0), // active
- STATE_CHECK = (1<<1), // pressed
- STATE_HILIGHT = (1<<2), // overflown by mouse
- STATE_PRESS = (1<<3), // pressed by mouse
- STATE_VISIBLE = (1<<4), // visible
- STATE_DEAD = (1<<5), // inaccessible (x)
- STATE_DEFAULT = (1<<6), // actuated by RETURN
- STATE_OKAY = (1<<7), // green point at the bottom right
- STATE_SHADOW = (1<<8), // shadow
- STATE_GLINT = (1<<9), // dynamic reflection
- STATE_CARD = (1<<10), // tab
- STATE_EXTEND = (1<<11), // extended mode
- STATE_SIMPLY = (1<<12), // undecorated
- STATE_FRAME = (1<<13), // framework highlighting
- STATE_WARNING = (1<<14), // framework hatched yellow / black
- STATE_VALUE = (1<<15), // displays the value
- STATE_RUN = (1<<16) // running program
- };
-
-
-
- class CControl
- {
- public:
- CControl();
- virtual ~CControl();
-
- virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
-
- virtual bool EventProcess(const Event &event);
-
- virtual void SetPos(Math::Point pos);
- virtual Math::Point GetPos();
- virtual void SetDim(Math::Point dim);
- virtual Math::Point GetDim();
- virtual bool SetState(int state, bool bState);
- virtual bool SetState(int state);
- virtual bool ClearState(int state);
- virtual bool TestState(int state);
- virtual int GetState();
- virtual void SetIcon(int icon);
- virtual int GetIcon();
- virtual void SetName(std::string name, bool bTooltip=true);
- virtual std::string GetName();
- virtual void SetTextAlign(Gfx::TextAlign mode);
- virtual int GetTextAlign();
- virtual void SetFontSize(float size);
- virtual float GetFontSize();
- virtual void SetFontStretch(float stretch);
- virtual float GetFontStretch();
- virtual void SetFontType(Gfx::FontType font);
- virtual Gfx::FontType GetFontType();
- virtual bool SetTooltip(std::string name);
- virtual bool GetTooltip(Math::Point pos, std::string &name);
- virtual void SetFocus(bool bFocus);
- virtual bool GetFocus();
-
- virtual EventType GetEventType();
-
- virtual void Draw();
-
- protected:
- void GlintDelete();
- void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
- void GlintFrame(const Event &event);
- void DrawPart(int icon, float zoom, float ex);
- void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
- void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
- void DrawWarning(Math::Point pos, Math::Point dim);
- void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
- virtual bool Detect(Math::Point pos);
-
- protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- Gfx::CParticle* m_particle;
- CEventQueue* m_event;
- CRobotMain* m_main;
- CSoundInterface* m_sound;
-
- Math::Point m_pos; // corner upper / left
- Math::Point m_dim; // dimensions
- int m_icon;
- EventType m_eventType; // message to send when clicking
- int m_state; // states (STATE_ *)
- float m_fontSize; // size of the button name
- float m_fontStretch; // stretch of the font
- Gfx::FontType m_fontType; // type of font
- Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
- // int m_justif; // type of justification (-1,0,1)
- std::string m_name; // name of the button
- std::string m_tooltip; // name of tooltip
- bool m_bFocus;
- bool m_bCapture;
-
- bool m_bGlint;
- Math::Point m_glintCorner1;
- Math::Point m_glintCorner2;
- float m_glintProgress;
- Math::Point m_glintMouse;
- };
-
-}
+enum ControlState
+{
+ STATE_ENABLE = (1<<0), // active
+ STATE_CHECK = (1<<1), // pressed
+ STATE_HILIGHT = (1<<2), // overflown by mouse
+ STATE_PRESS = (1<<3), // pressed by mouse
+ STATE_VISIBLE = (1<<4), // visible
+ STATE_DEAD = (1<<5), // inaccessible (x)
+ STATE_DEFAULT = (1<<6), // actuated by RETURN
+ STATE_OKAY = (1<<7), // green point at the bottom right
+ STATE_SHADOW = (1<<8), // shadow
+ STATE_GLINT = (1<<9), // dynamic reflection
+ STATE_CARD = (1<<10), // tab
+ STATE_EXTEND = (1<<11), // extended mode
+ STATE_SIMPLY = (1<<12), // undecorated
+ STATE_FRAME = (1<<13), // framework highlighting
+ STATE_WARNING = (1<<14), // framework hatched yellow / black
+ STATE_VALUE = (1<<15), // displays the value
+ STATE_RUN = (1<<16) // running program
+};
+
+
+
+class CControl
+{
+public:
+ CControl();
+ virtual ~CControl();
+
+ virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+
+ virtual bool EventProcess(const Event &event);
+
+ virtual void SetPos(Math::Point pos);
+ virtual Math::Point GetPos();
+ virtual void SetDim(Math::Point dim);
+ virtual Math::Point GetDim();
+ virtual bool SetState(int state, bool bState);
+ virtual bool SetState(int state);
+ virtual bool ClearState(int state);
+ virtual bool TestState(int state);
+ virtual int GetState();
+ virtual void SetIcon(int icon);
+ virtual int GetIcon();
+ virtual void SetName(std::string name, bool bTooltip=true);
+ virtual std::string GetName();
+ virtual void SetTextAlign(Gfx::TextAlign mode);
+ virtual int GetTextAlign();
+ virtual void SetFontSize(float size);
+ virtual float GetFontSize();
+ virtual void SetFontStretch(float stretch);
+ virtual float GetFontStretch();
+ virtual void SetFontType(Gfx::FontType font);
+ virtual Gfx::FontType GetFontType();
+ virtual bool SetTooltip(std::string name);
+ virtual bool GetTooltip(Math::Point pos, std::string &name);
+ virtual void SetFocus(bool bFocus);
+ virtual bool GetFocus();
+
+ virtual EventType GetEventType();
+
+ virtual void Draw();
+
+protected:
+ void GlintDelete();
+ void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
+ void GlintFrame(const Event &event);
+ void DrawPart(int icon, float zoom, float ex);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
+ void DrawWarning(Math::Point pos, Math::Point dim);
+ void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
+ virtual bool Detect(Math::Point pos);
+
+protected:
+ Gfx::CEngine* m_engine;
+ Gfx::CParticle* m_particle;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ CSoundInterface* m_sound;
+
+ Math::Point m_pos; // corner upper / left
+ Math::Point m_dim; // dimensions
+ int m_icon;
+ EventType m_eventType; // message to send when clicking
+ int m_state; // states (STATE_ *)
+ float m_fontSize; // size of the button name
+ float m_fontStretch; // stretch of the font
+ Gfx::FontType m_fontType; // type of font
+ Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
+ std::string m_name; // name of the button
+ std::string m_tooltip; // name of tooltip
+ bool m_bFocus;
+ bool m_bCapture;
+
+ bool m_bGlint;
+ Math::Point m_glintCorner1;
+ Math::Point m_glintCorner2;
+ float m_glintProgress;
+ Math::Point m_glintMouse;
+};
+
+} // namespace Ui
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 29499bd..fcc77db 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -15,17 +15,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// displayinfo.cpp
-
#include "ui/displayinfo.h"
-#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/slider.h"
-#include "ui/edit.h"
-#include "ui/group.h"
-#include "ui/window.h"
+#include "app/app.h"
#include "common/iman.h"
#include "common/misc.h"
@@ -43,25 +36,28 @@
#include "script/cbottoken.h"
+#include "ui/interface.h"
+#include "ui/button.h"
+#include "ui/slider.h"
+#include "ui/edit.h"
+#include "ui/group.h"
+#include "ui/window.h"
+
#include <string.h>
namespace Ui {
// Object's constructor.
-//CDisplayInfo::CDisplayInfo(CInstanceManager* iMan)
CDisplayInfo::CDisplayInfo()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_STUDIO, this);
-
- m_engine = static_cast <Gfx::CEngine*> (m_iMan->SearchInstance(CLASS_ENGINE));
- m_event = static_cast <CEventQueue*> (m_iMan->SearchInstance(CLASS_EVENT));
- m_interface = static_cast <CInterface*> (m_iMan->SearchInstance(CLASS_INTERFACE));
- m_main = static_cast <CRobotMain*> (m_iMan->SearchInstance(CLASS_MAIN));
- m_camera = static_cast <Gfx::CCamera*> (m_iMan->SearchInstance(CLASS_CAMERA));
- m_particle = static_cast <Gfx::CParticle*> (m_iMan->SearchInstance(CLASS_PARTICULE));
- m_light = static_cast <Gfx::CLightManager*> (m_iMan->SearchInstance(CLASS_LIGHT));
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
+ m_light = m_engine->GetLightManager();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
+ m_camera = m_main->GetCamera();
m_bInfoMaximized = true;
m_bInfoMinimized = false;
@@ -77,7 +73,6 @@ CDisplayInfo::CDisplayInfo()
CDisplayInfo::~CDisplayInfo()
{
- m_iMan->DeleteInstance(CLASS_STUDIO, this);
}
@@ -386,7 +381,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
edit->ReadText(filename.c_str());
edit->HyperHome(filename.c_str());
edit->SetEditCap(false); // just to see!
- edit->SetHiliteCap(false);
+ edit->SetHighlightCap(false);
edit->SetFocus(true);
ViewDisplayInfo();
@@ -460,6 +455,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
}
light.type = Gfx::LIGHT_DIRECTIONAL;
+ light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f);
light.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f);
light.direction = Math::Vector(1.0f, 0.0f, 1.0f);
@@ -675,7 +671,7 @@ void CDisplayInfo::ChangeIndexButton(int index)
{
filename = m_main->GetDisplayInfoName(m_index);
edit->ReadText(filename);
- edit->HyperHome(filename);
+ edit->HyperHome(std::string(filename));
SetPosition(m_main->GetDisplayInfoPosition(m_index));
}
@@ -789,7 +785,7 @@ void CDisplayInfo::UpdateIndexButton()
if ( edit != 0 )
{
//? edit->SetHiliteCap(m_index==SATCOM_LOADING);
- edit->SetHiliteCap(true);
+ edit->SetHighlightCap(true);
}
UpdateCopyButton();
@@ -927,9 +923,11 @@ CObject* CDisplayInfo::SearchToto()
CObject* pObj;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
@@ -991,9 +989,9 @@ void ObjectWrite(FILE* file, ObjectList list[], int i)
strcat(line, res);
strcat(line, "\\u ");
- p = const_cast<char*>(GetHelpFilename(list[i].type));
+ p = const_cast<char*>(GetHelpFilename(list[i].type).c_str());
if ( p[0] == 0 ) return;
- strcat(line, p+5); // skip "help\"
+ strcat(line, p+7); // skip "help\?\"
p = strstr(line, ".txt");
if ( p != 0 ) *p = 0;
strcat(line, ";\n");
@@ -1012,14 +1010,16 @@ void CDisplayInfo::CreateObjectsFile()
int i;
bool bRadar, bAtLeast;
- file = fopen("help\\objects.txt", "w");
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
+ file = fopen((std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("objects.txt")).c_str(), "w");
if ( file == 0 ) return;
list[0].total = 0; // empty list
bRadar = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h
index 2eabbf2..ab42d62 100644
--- a/src/ui/displayinfo.h
+++ b/src/ui/displayinfo.h
@@ -25,7 +25,6 @@
#include "graphics/engine/camera.h"
-class CInstanceManager;
class CRobotMain;
class CObject;
class CEventQueue;
@@ -33,67 +32,66 @@ class CEventQueue;
struct Event;
namespace Gfx {
- class CEngine;
- class CParticle;
- class CLightManager;
+class CEngine;
+class CParticle;
+class CLightManager;
}
namespace Ui {
- class CInterface;
-
- class CDisplayInfo
- {
- public:
- // CDisplayInfo(CInstanceManager* iMan);
- CDisplayInfo();
- ~CDisplayInfo();
-
- bool EventProcess(const Event &event);
-
- void StartDisplayInfo(std::string filename, int index, bool bSoluce);
- void StopDisplayInfo();
-
- void SetPosition(int pos);
- int GetPosition();
-
- protected:
- bool EventFrame(const Event &event);
- void HyperUpdate();
- void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
- void ChangeIndexButton(int index);
- void UpdateIndexButton();
- void UpdateCopyButton();
- void ViewDisplayInfo();
- CObject* SearchToto();
- void CreateObjectsFile();
-
- protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- CEventQueue* m_event;
- CRobotMain* m_main;
- Gfx::CCamera* m_camera;
- CInterface* m_interface;
- Gfx::CParticle* m_particle;
- Gfx::CLightManager* m_light;
-
- bool m_bInfoMaximized;
- bool m_bInfoMinimized;
-
- int m_index;
- Gfx::CameraType m_infoCamera;
- Math::Point m_infoNormalPos;
- Math::Point m_infoNormalDim;
- Math::Point m_infoActualPos;
- Math::Point m_infoActualDim;
- Math::Point m_infoFinalPos;
- Math::Point m_infoFinalDim;
- int m_lightSuppl;
- bool m_bEditLock;
- bool m_bInitPause;
- bool m_bSoluce;
- CObject* m_toto;
- };
-
-}
+class CInterface;
+
+class CDisplayInfo
+{
+public:
+ CDisplayInfo();
+ ~CDisplayInfo();
+
+ bool EventProcess(const Event &event);
+
+ void StartDisplayInfo(std::string filename, int index, bool bSoluce);
+ void StopDisplayInfo();
+
+ void SetPosition(int pos);
+ int GetPosition();
+
+protected:
+ bool EventFrame(const Event &event);
+ void HyperUpdate();
+ void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
+ void ChangeIndexButton(int index);
+ void UpdateIndexButton();
+ void UpdateCopyButton();
+ void ViewDisplayInfo();
+ CObject* SearchToto();
+ void CreateObjectsFile();
+
+protected:
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CInterface* m_interface;
+ Gfx::CParticle* m_particle;
+ Gfx::CLightManager* m_light;
+
+ bool m_bInfoMaximized;
+ bool m_bInfoMinimized;
+
+ int m_index;
+ Gfx::CameraType m_infoCamera;
+ Math::Point m_infoNormalPos;
+ Math::Point m_infoNormalDim;
+ Math::Point m_infoActualPos;
+ Math::Point m_infoActualDim;
+ Math::Point m_infoFinalPos;
+ Math::Point m_infoFinalDim;
+ int m_lightSuppl;
+ bool m_bEditLock;
+ bool m_bInitPause;
+ bool m_bSoluce;
+ CObject* m_toto;
+};
+
+
+} // namespace Ui
diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp
index 7c60f8b..630b385 100644
--- a/src/ui/displaytext.cpp
+++ b/src/ui/displaytext.cpp
@@ -15,16 +15,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// displaytext.cpp
-
#include "ui/displaytext.h"
-#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/label.h"
-#include "ui/window.h"
-#include "ui/group.h"
+#include "app/app.h"
#include "common/event.h"
#include "common/iman.h"
@@ -36,6 +30,11 @@
#include "object/motion/motion.h"
#include "object/motion/motiontoto.h"
+#include "ui/interface.h"
+#include "ui/button.h"
+#include "ui/label.h"
+#include "ui/window.h"
+#include "ui/group.h"
@@ -46,20 +45,13 @@ const float FONTSIZE = 12.0f;
// Object's constructor.
-//CDisplayText::CDisplayText(CInstanceManager* iMan)
CDisplayText::CDisplayText()
{
- int i;
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_interface = CRobotMain::GetInstancePointer()->GetInterface();
+ m_sound = CApplication::GetInstancePointer()->GetSound();
-// m_iMan = iMan;
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_DISPLAYTEXT, this);
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
-
- for ( i=0 ; i<MAXDTLINE ; i++ )
+ for (int i=0 ; i<MAXDTLINE ; i++ )
{
m_bExist[i] = false;
m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f);
@@ -77,7 +69,6 @@ CDisplayText::CDisplayText()
CDisplayText::~CDisplayText()
{
- m_iMan->DeleteInstance(CLASS_DISPLAYTEXT, this);
}
@@ -598,9 +589,11 @@ CObject* CDisplayText::SearchToto()
CObject* pObj;
int i;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->GetType();
diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h
index 5714cc5..94572a8 100644
--- a/src/ui/displaytext.h
+++ b/src/ui/displaytext.h
@@ -27,16 +27,14 @@
-class CInstanceManager;
-//class CD3DEngine
class CObject;
class CSound;
namespace Gfx {
- class CEngine;
+class CEngine;
}
-namespace Ui {;
+namespace Ui {
class CInterface;
@@ -54,7 +52,6 @@ const int MAXDTLINE = 4;
class CDisplayText
{
public:
-// CDisplayText(CInstanceManager* iMan);
CDisplayText();
~CDisplayText();
@@ -87,7 +84,6 @@ protected:
CObject* SearchToto();
protected:
- CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Ui::CInterface* m_interface;
CSoundInterface* m_sound;
@@ -104,4 +100,5 @@ protected:
};
-}
+} // namespace Ui
+
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 639215a..e60a040 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -15,11 +15,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// edit.cpp
-#include "app/app.h"
#include "ui/edit.h"
+#include "app/app.h"
+
#include <string.h>
namespace Ui {
@@ -261,7 +261,7 @@ bool CEdit::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE )
{
- if ( Detect(event.mousePos) &&
+ if ( Detect(event.mousePos) &&
event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
{
if ( m_bEdit )
@@ -560,7 +560,7 @@ bool CEdit::IsLinkPos(Math::Point pos)
if ( i == -1 ) return false;
if ( i >= m_len ) return false;
- if ( (m_format[i]& Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) return true; // TODO
+ if ( m_format.size() > static_cast<unsigned int>(i) && ((m_format[i] & Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK)) return true; // TODO
return false;
}
@@ -735,7 +735,8 @@ int CEdit::MouseDetect(Math::Point mouse)
// len, offset, size,
// m_fontStretch);
c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]).substr(0, len),
- m_format,
+ m_format.begin() + m_lineOffset[i],
+ m_format.end(),
size,
offset); // TODO check if good
}
@@ -759,7 +760,7 @@ void CEdit::HyperFlush()
// Indicates which is the home page.
-void CEdit::HyperHome(const char *filename)
+void CEdit::HyperHome(std::string filename)
{
HyperFlush();
HyperAdd(filename, 0);
@@ -767,10 +768,10 @@ void CEdit::HyperHome(const char *filename)
// Performs a hyper jump through a link.
-void CEdit::HyperJump(const char *name, const char *marker)
+void CEdit::HyperJump(std::string name, std::string marker)
{
- char filename[100];
- char sMarker[100];
+ std::string filename;
+ std:: string sMarker;
int i, line, pos;
if ( m_historyCurrent >= 0 )
@@ -778,18 +779,16 @@ void CEdit::HyperJump(const char *name, const char *marker)
m_history[m_historyCurrent].firstLine = m_lineFirst;
}
- strcpy(sMarker, marker);
+ sMarker = marker;
//? sprintf(filename, "help\\%s.txt", name);
- if ( name[0] == '%' )
- {
- UserDir(filename, name, "");
- strcat(filename, ".txt");
- }
- else
- {
- sprintf(filename, "help\\%s.txt", name);
+
+ if ( name[0] == '%' ) {
+ filename = GetProfile().GetUserBasedPath(name, "") + ".txt";
+ } else {
+ filename = std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + "/" + name + std::string(".txt");
}
+
if ( ReadText(filename) )
{
Justif();
@@ -797,7 +796,7 @@ void CEdit::HyperJump(const char *name, const char *marker)
line = 0;
for ( i=0 ; i<m_markerTotal ; i++ )
{
- if ( strcmp(sMarker, m_marker[i].name) == 0 )
+ if (sMarker == m_marker[i].name)
{
pos = m_marker[i].pos;
for ( i=0 ; i<m_lineTotal ; i++ )
@@ -818,12 +817,12 @@ void CEdit::HyperJump(const char *name, const char *marker)
// Adds text to the history of visited.
-bool CEdit::HyperAdd(const char *filename, int firstLine)
+bool CEdit::HyperAdd(std::string filename, int firstLine)
{
if ( m_historyCurrent >= EDITHISTORYMAX-1 ) return false;
m_historyCurrent ++;
- strcpy(m_history[m_historyCurrent].filename, filename);
+ m_history[m_historyCurrent].filename = filename;
m_history[m_historyCurrent].firstLine = firstLine;
m_historyTotal = m_historyCurrent+1;
@@ -935,10 +934,10 @@ void CEdit::Draw()
pos.x = m_pos.x+(10.0f/640.0f);
if ( m_bAutoIndent )
{
+ const char *s = "\t"; // line | dotted
for ( j=0 ; j<m_lineIndent[i] ; j++ )
{
- char s = '\t'; // line | dotted
- m_engine->GetText()->DrawText(&s, m_fontType, m_fontSize, pos, 1.0f, Gfx::TEXT_ALIGN_LEFT, 0);
+ m_engine->GetText()->DrawText(s, m_fontType, m_fontSize, pos, 1.0f, Gfx::TEXT_ALIGN_LEFT, 0);
pos.x += indentLength;
}
}
@@ -950,7 +949,7 @@ void CEdit::Draw()
size = m_fontSize;
// Headline \b;?
- if ( beg+len < m_len && m_format.count(beg) &&
+ if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG )
{
start.x = ppos.x-MARGX;
@@ -964,7 +963,7 @@ void CEdit::Draw()
}
// As \t;?
- if ( beg+len < m_len && m_format.count(beg) &&
+ if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_NORM )
{
start.x = ppos.x-MARGX;
@@ -975,7 +974,7 @@ void CEdit::Draw()
}
// Subtitle \s;?
- if ( beg+len < m_len && m_format.count(beg) &&
+ if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) &&
(m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_LITTLE )
{
start.x = ppos.x-MARGX;
@@ -986,7 +985,7 @@ void CEdit::Draw()
}
// Table \tab;?
- if ( beg+len < m_len && m_format.count(beg) &&
+ if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) &&
(m_format[beg]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE )
{
start.x = ppos.x-MARGX;
@@ -997,7 +996,7 @@ void CEdit::Draw()
}
// Image \image; ?
- if ( beg+len < m_len && m_format.count(beg) &&
+ if ( beg+len < m_len && m_format.size() > static_cast<unsigned int>(beg) &&
(m_format[beg]&Gfx::FONT_MASK_IMAGE) != 0 )
{
line = 1;
@@ -1005,7 +1004,7 @@ void CEdit::Draw()
{
if ( i+line >= m_lineTotal ||
i+line >= m_lineFirst+m_lineVisible ||
- (m_format.count(beg+line) && m_format[beg+line]&Gfx::FONT_MASK_IMAGE) == 0 ) break;
+ (m_format.size() > static_cast<unsigned int>(beg+line) && m_format[beg+line]&Gfx::FONT_MASK_IMAGE) == 0 ) break;
line ++;
}
@@ -1034,16 +1033,18 @@ void CEdit::Draw()
else
{
start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg).substr(0, o1-beg),
- m_format,
+ m_format.begin() + beg,
+ m_format.end(),
size);
end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1).substr(0, o2-o1),
- m_format,
+ m_format.begin() + o1,
+ m_format.end(),
size);
}
start.y = ppos.y-(m_bMulti?0.0f:MARGY1);
end.y = m_lineHeight;
- if ( m_format.count(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
+ if ( m_format.size() > static_cast<unsigned int>(beg) && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
DrawPart(start, end, 1); // plain yellow background
}
@@ -1065,7 +1066,8 @@ void CEdit::Draw()
else
{
m_engine->GetText()->DrawText(std::string(m_text+beg).substr(0, len),
- m_format,
+ m_format.begin() + beg,
+ m_format.end(),
size,
ppos,
m_dim.x,
@@ -1107,7 +1109,8 @@ void CEdit::Draw()
else
{
m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]).substr(0, len),
- m_format,
+ m_format.begin() + m_lineOffset[i],
+ m_format.end(),
size, pos, Gfx::TEXT_ALIGN_LEFT,
start, end);
}
@@ -1131,16 +1134,14 @@ void CEdit::Draw()
// Draw an image part.
-void CEdit::DrawImage(Math::Point pos, const char *name, float width,
+void CEdit::DrawImage(Math::Point pos, std::string name, float width,
float offset, float height, int nbLine)
{
- Math::Point uv1, uv2, dim;
- float dp;
- char filename[100];
+ Math::Point uv1, uv2, dim;
+ float dp;
+ std::string filename;
-//? sprintf(filename, "diagram\\%s.png", name);
- UserDir(filename, name, "diagram");
- strcat(filename, ".png");
+ filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png";
m_engine->SetTexture(filename);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
@@ -1384,77 +1385,58 @@ int CEdit::GetTextLength()
// Returns a name in a command.
// \x nom1 nom2 nom3;
-void GetNameParam(const char *cmd, int rank, char *buffer)
+std::string GetNameParam(std::string cmd, int rank)
{
- int i;
-
- for ( i=0 ; i<rank ; i++ )
- {
- while ( *cmd != ' ' && *cmd != ';' )
- {
- cmd ++;
- }
- if ( *cmd != ';' ) cmd ++;
+ std::vector<std::string> results;
+ boost::split(results, cmd, boost::is_any_of(" ;"));
+
+ if (results.size() > static_cast<unsigned int>(rank)) {
+ return results.at(rank);
}
- while ( *cmd != ' ' && *cmd != ';' )
- {
- *buffer++ = *cmd++;
- }
- *buffer = 0;
+ return "";
}
// Returns a number of a command.
// \x nom n1 n2;
-int GetValueParam(const char *cmd, int rank)
+int GetValueParam(std::string cmd, int rank)
{
- int n, i;
-
- for ( i=0 ; i<rank ; i++ )
- {
- while ( *cmd != ' ' && *cmd != ';' )
- {
- cmd ++;
- }
- if ( *cmd != ';' ) cmd ++;
+ std::vector<std::string> results;
+ boost::split(results, cmd, boost::is_any_of(" ;"));
+ int return_value = 0;
+
+ if (results.size() > static_cast<unsigned int>(rank)) {
+ return_value = atoi(results.at(rank).c_str());
}
- sscanf(cmd, "%d", &n);
- return n;
+ return return_value;
}
// Frees all images.
void CEdit::FreeImage()
{
- char filename[100];
- int i;
+ std::string filename;
- for ( i=0 ; i<m_imageTotal ; i++ )
- {
-//? sprintf(filename, "diagram\\%s.png", m_image[i].name);
- UserDir(filename, m_image[i].name, "diagram");
- strcat(filename, ".png");
+ for (int i = 0 ; i < m_imageTotal; i++ ) {
+ filename = GetProfile().GetUserBasedPath(m_image[i].name, "diagram") + ".png";
m_engine->DeleteTexture(filename);
}
}
// Reads the texture of an image.
-void CEdit::LoadImage(const char *name)
+void CEdit::LoadImage(std::string name)
{
- char filename[100];
-
-//? sprintf(filename, "diagram\\%s.png", name);
- UserDir(filename, name, "diagram");
- strcat(filename, ".png");
+ std::string filename;
+ filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png";
m_engine->LoadTexture(filename);
}
// Read from a text file.
-bool CEdit::ReadText(const char *filename, int addSize)
+bool CEdit::ReadText(std::string filename, int addSize)
{
FILE *file = NULL;
char *buffer;
@@ -1466,7 +1448,16 @@ bool CEdit::ReadText(const char *filename, int addSize)
bool bInSoluce, bBOL;
if ( filename[0] == 0 ) return false;
- file = fopen(filename, "rb");
+ boost::replace_all(filename, "\\", "/");
+
+ /* This is ugly but doesn't require many changes in code. If file doesn't
+ exists it's posible filename is absolute not full path */
+ std::string path = filename;
+ if (!fs::exists(path)) {
+ path = CApplication::GetInstancePointer()->GetDataDirPath() + "/" + filename;
+ }
+
+ file = fopen(fs::path(path).make_preferred().string().c_str(), "rb");
if ( file == NULL ) return false;
fseek(file, 0, SEEK_END);
@@ -1491,8 +1482,11 @@ bool CEdit::ReadText(const char *filename, int addSize)
fread(buffer, 1, len, file);
- if ( m_format.size() > 0 )
- m_format.clear();
+ m_format.clear();
+ m_format.reserve(m_maxChar+1);
+ for (i = 0; i <= m_maxChar+1; i++) {
+ m_format.push_back(0);
+ }
fclose(file);
@@ -1597,8 +1591,8 @@ bool CEdit::ReadText(const char *filename, int addSize)
{
if ( iLink < EDITLINKMAX )
{
- GetNameParam(buffer+i+3, 0, m_link[iLink].name);
- GetNameParam(buffer+i+3, 1, m_link[iLink].marker);
+ m_link[iLink].name = GetNameParam(buffer+i+3, 0);
+ m_link[iLink].marker = GetNameParam(buffer+i+3, 1);
iLink ++;
}
font &= ~Gfx::FONT_MASK_HIGHLIGHT;
@@ -1614,7 +1608,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
{
if ( m_markerTotal < EDITLINKMAX )
{
- GetNameParam(buffer+i+3, 0, m_marker[m_markerTotal].name);
+ m_marker[m_markerTotal].name = GetNameParam(buffer+i+3, 0);
m_marker[m_markerTotal].pos = j;
m_markerTotal ++;
}
@@ -1632,21 +1626,19 @@ bool CEdit::ReadText(const char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
-#if _DEMO
- strcpy(iName, "demo");
-#else
- GetNameParam(buffer+i+7, 0, iName);
-#endif
+
+ strcpy(iName, GetNameParam(buffer+i+7, 0).c_str());
+
//? iWidth = m_lineHeight*RetValueParam(buffer+i+7, 1);
iWidth = static_cast<float>(GetValueParam(buffer+i+7, 1));
iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL);
iLines = GetValueParam(buffer+i+7, 2);
- LoadImage(iName);
+ LoadImage(std::string(iName));
// A part of image per line of text.
for ( iCount=0 ; iCount<iLines ; iCount++ )
{
- strcpy(m_image[iIndex].name, iName);
+ m_image[iIndex].name = iName;
m_image[iIndex].offset = static_cast<float>(iCount/iLines);
m_image[iIndex].height = 1.0f/iLines;
m_image[iIndex].width = iWidth*0.75f;
@@ -1880,7 +1872,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
// Writes all the text in a file.
-bool CEdit::WriteText(const char *filename)
+bool CEdit::WriteText(std::string filename)
{
FILE* file;
char buffer[1000+20];
@@ -1888,7 +1880,7 @@ bool CEdit::WriteText(const char *filename)
float iDim;
if ( filename[0] == 0 ) return false;
- file = fopen(filename, "wb");
+ file = fopen(filename.c_str(), "wb");
if ( file == NULL ) return false;
if ( m_bAutoIndent )
@@ -1957,8 +1949,11 @@ void CEdit::SetMaxChar(int max)
m_text = new char[m_maxChar+1];
memset(m_text, 0, m_maxChar+1);
- if (m_format.size() > 0)
- m_format.clear();
+ m_format.clear();
+ m_format.reserve(m_maxChar+1);
+ for (int i = 0; i <= m_maxChar+1; i++) {
+ m_format.push_back(0);
+ }
m_len = 0;
m_cursor1 = 0;
@@ -1987,12 +1982,12 @@ bool CEdit::GetEditCap()
// Mode management "hilitable" (that's the franch).
-void CEdit::SetHiliteCap(bool bEnable)
+void CEdit::SetHighlightCap(bool bEnable)
{
m_bHilite = bEnable;
}
-bool CEdit::GetHiliteCap()
+bool CEdit::GetHighlightCap()
{
return m_bHilite;
}
@@ -2147,6 +2142,13 @@ bool CEdit::GetDisplaySpec()
void CEdit::SetMultiFont(bool bMulti)
{
m_format.clear();
+
+ if (bMulti) {
+ m_format.reserve(m_maxChar+1);
+ for (int i = 0; i <= m_maxChar+1; i++) {
+ m_format.push_back(0);
+ }
+ }
}
// TODO check if it works correctly; was checking if variable is null
@@ -2450,7 +2452,8 @@ void CEdit::MoveLine(int move, bool bWord, bool bSelect)
else
{
c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
- m_format,
+ m_format.begin() + m_lineOffset[line],
+ m_format.end(),
m_fontSize,
m_lineOffset[line+1]-m_lineOffset[line]);
}
@@ -2481,7 +2484,8 @@ void CEdit::ColumnFix()
{
m_column = m_engine->GetText()->GetStringWidth(
std::string(m_text+m_lineOffset[line]),
- m_format,
+ m_format.begin() + m_lineOffset[line],
+ m_format.end(),
m_fontSize
);
}
@@ -2823,20 +2827,20 @@ void CEdit::InsertOne(char character)
{
m_text[i] = m_text[i-1]; // shoot
- //if ( m_format.size() > 0 )
- //{
+ if ( m_format.size() > static_cast<unsigned int>(i) )
+ {
m_format[i] = m_format[i-1]; // shoot
- //}
+ }
}
m_len ++;
m_text[m_cursor1] = character;
- //if ( m_format.size() > 0 )
- //{
+ if ( m_format.size() > static_cast<unsigned int>(m_cursor1) )
+ {
m_format[m_cursor1] = 0;
- //}
+ }
m_cursor1++;
m_cursor2 = m_cursor1;
@@ -2884,7 +2888,7 @@ void CEdit::DeleteOne(int dir)
{
m_text[i] = m_text[i+hole];
- if ( m_format.count(i+hole) )
+ if ( m_format.size() > static_cast<unsigned int>(i + hole) )
{
m_format[i] = m_format[i+hole];
}
@@ -3087,13 +3091,13 @@ void CEdit::Justif()
{
size = m_fontSize;
- if ( m_format.count(i) && (m_format[i]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) // headline?
+ if ( m_format.size() > static_cast<unsigned int>(i) && (m_format[i]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) // headline?
{
size *= BIG_FONT;
bDual = true;
}
- if ( m_format.count(i) && (m_format[i]&Gfx::FONT_MASK_IMAGE) != 0 ) // image part?
+ if ( m_format.size() > static_cast<unsigned int>(i) && (m_format[i]&Gfx::FONT_MASK_IMAGE) != 0 ) // image part?
{
i ++; // jumps just a character (index in m_image)
}
@@ -3101,7 +3105,8 @@ void CEdit::Justif()
{
// TODO check if good
i += m_engine->GetText()->Justify(std::string(m_text+i),
- m_format,
+ m_format.begin() + i,
+ m_format.end(),
size,
width);
}
@@ -3296,12 +3301,12 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format)
{
int i;
- //if ( m_format.size() == 0 ) return false;
+ if ( m_format.size() < static_cast<unsigned int>(cursor2) )
+ SetMultiFont(true);
for ( i=cursor1 ; i<cursor2 ; i++ )
{
- if (m_format.count(i))
- m_format[i] |= format;
+ m_format.at(i) |= format;
}
return true;
diff --git a/src/ui/edit.h b/src/ui/edit.h
index 7247181..1cfec80 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -32,11 +32,16 @@
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
#include <set>
+#include <string>
+#include <cstdlib>
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
+
+namespace fs = boost::filesystem;
namespace Ui {
@@ -85,7 +90,7 @@ enum OperUndo
struct ImageLine
{
//! name of the image (without diagram \)
- char name[40];
+ std::string name;
//! vertical offset (v texture)
float offset;
//! height of the part (dv texture)
@@ -97,15 +102,15 @@ struct ImageLine
struct HyperLink
{
//! text file name (without help \)
- char name[40];
+ std::string name;
//! name of the marker
- char marker[20];
+ std::string marker;
};
struct HyperMarker
{
//! name of the marker
- char name[20];
+ std::string name;
//! position in the text
int pos;
};
@@ -113,7 +118,7 @@ struct HyperMarker
struct HyperHistory
{
//! full file name text
- char filename[50];
+ std::string filename;
//! rank of the first displayed line
int firstLine;
};
@@ -141,8 +146,8 @@ public:
char* GetText();
int GetTextLength();
- bool ReadText(const char *filename, int addSize=0);
- bool WriteText(const char *filename);
+ bool ReadText(std::string filename, int addSize=0);
+ bool WriteText(std::string filename);
void SetMaxChar(int max);
int GetMaxChar();
@@ -150,8 +155,8 @@ public:
void SetEditCap(bool bMode);
bool GetEditCap();
- void SetHiliteCap(bool bEnable);
- bool GetHiliteCap();
+ void SetHighlightCap(bool bEnable);
+ bool GetHighlightCap();
void SetInsideScroll(bool bInside);
bool GetInsideScroll();
@@ -184,7 +189,7 @@ public:
bool Undo();
void HyperFlush();
- void HyperHome(const char *filename);
+ void HyperHome(std::string filename);
bool HyperTest(EventType event);
bool HyperGo(EventType event);
@@ -203,15 +208,15 @@ protected:
int MouseDetect(Math::Point mouse);
void MoveAdjust();
- void HyperJump(const char *name, const char *marker);
- bool HyperAdd(const char *filename, int firstLine);
+ void HyperJump(std::string name, std::string marker);
+ bool HyperAdd(std::string filename, int firstLine);
- void DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine);
+ void DrawImage(Math::Point pos, std::string name, float width, float offset, float height, int nbLine);
void DrawBack(Math::Point pos, Math::Point dim);
void DrawPart(Math::Point pos, Math::Point dim, int icon);
void FreeImage();
- void LoadImage(const char *name);
+ void LoadImage(std::string name);
void Scroll(int pos, bool bAdjustCursor);
void Scroll();
void MoveChar(int move, bool bWord, bool bSelect);
@@ -242,7 +247,7 @@ protected:
int m_maxChar; // max length of the buffer m_text
char* m_text; // text (without zero terminator)
- std::map<unsigned int, Gfx::FontMetaChar> m_format; // format characters
+ std::vector<Gfx::FontMetaChar> m_format; // format characters
int m_len; // length used in m_text
int m_cursor1; // offset cursor
int m_cursor2; // offset cursor
diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp
index 3cc856d..6397a73 100644
--- a/src/ui/editvalue.cpp
+++ b/src/ui/editvalue.cpp
@@ -15,22 +15,21 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// editvalue.cpp
+#include "ui/editvalue.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "ui/edit.h"
#include "ui/button.h"
-#include "ui/editvalue.h"
+
namespace Ui {
// Object's constructor.
-//CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan)
CEditValue::CEditValue() : CControl ()
{
m_edit = 0;
diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h
index 1469b69..5d6e643 100644
--- a/src/ui/editvalue.h
+++ b/src/ui/editvalue.h
@@ -44,7 +44,6 @@ class CButton;
class CEditValue : public CControl
{
public:
-// CEditValue(CInstanceManager* iMan);
CEditValue();
virtual ~CEditValue();
diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp
index b1fa057..c98e3b6 100644
--- a/src/ui/gauge.cpp
+++ b/src/ui/gauge.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// gauge.cpp
-
#include "ui/gauge.h"
@@ -24,7 +22,6 @@
namespace Ui {
// Object's constructor.
-//CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan)
CGauge::CGauge() : CControl()
{
m_level = 0.0f;
diff --git a/src/ui/gauge.h b/src/ui/gauge.h
index f4a008f..a2b689a 100644
--- a/src/ui/gauge.h
+++ b/src/ui/gauge.h
@@ -32,7 +32,6 @@ namespace Ui {
class CGauge : public CControl
{
public:
- // CGauge(CInstanceManager* iMan);
CGauge();
virtual ~CGauge();
diff --git a/src/ui/group.cpp b/src/ui/group.cpp
index 67369d9..c3c7028 100644
--- a/src/ui/group.cpp
+++ b/src/ui/group.cpp
@@ -14,14 +14,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// group.cpp
#include "ui/group.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
+
#include "graphics/engine/engine.h"
@@ -32,7 +31,6 @@
namespace Ui {
// Object's constructor.
-//CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan)
CGroup::CGroup() : CControl()
{
}
diff --git a/src/ui/group.h b/src/ui/group.h
index bfeef74..fd31716 100644
--- a/src/ui/group.h
+++ b/src/ui/group.h
@@ -30,7 +30,6 @@ namespace Ui {
class CGroup : public CControl
{
public:
-// CGroup(CInstanceManager* iMan);
CGroup();
virtual ~CGroup();
diff --git a/src/ui/image.cpp b/src/ui/image.cpp
index ad838fa..94b9586 100644
--- a/src/ui/image.cpp
+++ b/src/ui/image.cpp
@@ -15,16 +15,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// image.cpp
-
+#include "ui/image.h"
-#include "graphics/engine/engine.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
-#include "ui/image.h"
+
+#include "graphics/engine/engine.h"
+
#include <string.h>
#include <stdio.h>
@@ -33,7 +32,6 @@
namespace Ui {
// Object's constructor.
-//CImage::CImage(CInstanceManager* iMan) : CControl(iMan)
CImage::CImage() : CControl()
{
m_filename[0] = 0;
diff --git a/src/ui/image.h b/src/ui/image.h
index b73a5ae..c40828c 100644
--- a/src/ui/image.h
+++ b/src/ui/image.h
@@ -32,7 +32,6 @@ namespace Ui {
class CImage : public CControl
{
public:
-// CImage(CInstanceManager* iMan);
CImage ();
virtual ~CImage();
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 885cef4..24d2626 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -15,20 +15,18 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// interface.cpp
-
#include "ui/interface.h"
+#include "app/app.h"
+
namespace Ui {
CInterface::CInterface()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_INTERFACE, this);
- m_event = static_cast<CEventQueue *>( m_iMan->SearchInstance(CLASS_EVENT) );
- m_engine = static_cast<Gfx::CEngine *>( m_iMan->SearchInstance(CLASS_ENGINE) );
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
m_camera = nullptr;
for (int i = 0; i < MAXCONTROL; i++ )
@@ -42,7 +40,6 @@ CInterface::CInterface()
CInterface::~CInterface()
{
Flush();
- m_iMan->DeleteInstance(CLASS_INTERFACE, this);
}
@@ -278,15 +275,18 @@ CControl* CInterface::SearchControl(EventType eventMsg)
bool CInterface::EventProcess(const Event &event)
{
- if (event.type == EVENT_MOUSE_MOVE) {
- if (m_camera == nullptr) {
- m_camera = static_cast<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA));
- }
+ if (event.type == EVENT_MOUSE_MOVE)
+ {
+ if (m_camera == nullptr)
+ m_camera = CRobotMain::GetInstancePointer()->GetCamera();
+
m_engine->SetMouseType(m_camera->GetMouseDef(event.mousePos));
}
- for (int i = MAXCONTROL-1; i >= 0; i--) {
- if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE)) {
+ for (int i = MAXCONTROL-1; i >= 0; i--)
+ {
+ if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE))
+ {
if ( !m_table[i]->EventProcess(event) )
return false;
}
@@ -300,8 +300,10 @@ bool CInterface::EventProcess(const Event &event)
bool CInterface::GetTooltip(Math::Point pos, std::string &name)
{
- for (int i = MAXCONTROL-1; i >= 0; i--) {
- if (m_table[i] != nullptr) {
+ for (int i = MAXCONTROL-1; i >= 0; i--)
+ {
+ if (m_table[i] != nullptr)
+ {
if (m_table[i]->GetTooltip(pos, name))
return true;
}
@@ -314,16 +316,8 @@ bool CInterface::GetTooltip(Math::Point pos, std::string &name)
void CInterface::Draw()
{
- /*ZeroMemory( &material, sizeof(D3DMATERIAL7) );
- material.diffuse.r = 1.0f;
- material.diffuse.g = 1.0f;
- material.diffuse.b = 1.0f;
- material.ambient.r = 0.5f;
- material.ambient.g = 0.5f;
- material.ambient.b = 0.5f;
- m_engine->SetMaterial(material);*/
-
- for (int i = 0; i < MAXCONTROL; i++) {
+ for (int i = 0; i < MAXCONTROL; i++)
+ {
if ( m_table[i] != nullptr )
m_table[i]->Draw();
}
diff --git a/src/ui/interface.h b/src/ui/interface.h
index 1496541..ebc80e7 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -19,11 +19,8 @@
#pragma once
-#include <string>
-
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "math/point.h"
@@ -49,6 +46,8 @@
#include "ui/map.h"
#include "ui/window.h"
+#include <string>
+
namespace Ui {
const int MAXCONTROL = 100;
@@ -92,7 +91,6 @@ class CInterface
int GetNextFreeControl();
template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
- CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
Gfx::CCamera* m_camera;
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index 9a76127..b181f70 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -15,6 +15,7 @@
// * 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 "ui/key.h"
#include "common/global.h"
diff --git a/src/ui/key.h b/src/ui/key.h
index 2332c9b..d8e935c 100644
--- a/src/ui/key.h
+++ b/src/ui/key.h
@@ -24,7 +24,6 @@
#include "ui/control.h"
-#include "common/iman.h"
#include "common/event.h"
#include "common/restext.h"
#include "common/key.h"
diff --git a/src/ui/label.cpp b/src/ui/label.cpp
index af65ab2..b5195b5 100644
--- a/src/ui/label.cpp
+++ b/src/ui/label.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// label.cpp
-
#include "ui/label.h"
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index 4356ea4..84aa8ca 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// list.cpp
-
#include "ui/list.h"
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 68e7854..9060e8b 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -14,22 +14,25 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// maindialog.cpp
#include "ui/maindialog.h"
#include "app/app.h"
+#include "app/system.h"
+
#include "common/global.h"
#include "common/event.h"
#include "common/logger.h"
#include "common/misc.h"
#include "common/profile.h"
-#include "common/iman.h"
#include "common/restext.h"
#include "common/logger.h"
+
#include "object/robotmain.h"
+
#include "script/cmdtoken.h"
#include "sound/sound.h"
+
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/color.h"
@@ -54,8 +57,7 @@
//TODO Get rid of all sprintf's
-namespace Ui
-{
+namespace Ui {
const int KEY_VISIBLE = 6; // number of visible keys redefinable
@@ -106,20 +108,16 @@ namespace fs = boost::filesystem;
// Constructor of robot application.
-CMainDialog::CMainDialog(CInstanceManager* iMan)
+CMainDialog::CMainDialog()
{
- m_iMan = iMan;
- m_iMan->AddInstance(CLASS_DIALOG, this);
-
- m_app = CApplication::GetInstancePointer();
-
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_app = CApplication::GetInstancePointer();
+ m_eventQueue = m_app->GetEventQueue();
+ m_sound = m_app->GetSound();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
+ m_camera = m_main->GetCamera();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_particle = m_engine->GetParticle();
m_phase = PHASE_NAME;
m_phaseSetup = PHASE_SETUPg;
@@ -176,7 +174,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan)
m_sceneDir = "levels";
- m_savegameDir = "savegame";
+ m_savegameDir = GetSystemUtils()->savegameDirectoryLocation();
m_publicDir = "program";
m_userDir = "user";
m_filesDir = "files";
@@ -378,7 +376,7 @@ pb->SetState(STATE_SHADOW);
pos.y -= 5.0f/480.0f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "PPC Team");
pl->SetFontType(Gfx::FONT_COURIER);
- pl->SetFontSize(8.0f);
+ pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
m_engine->SetBackground("interface.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -748,6 +746,10 @@ pb->SetState(STATE_SHADOW);
m_phase == PHASE_USER ||
m_phase == PHASE_PROTO )
{
+ if (!m_sound->IsPlayingMusic()) {
+ m_sound->PlayMusic(11, true);
+ }
+
if ( m_phase == PHASE_TRAINER ) m_index = 0;
if ( m_phase == PHASE_DEFI ) m_index = 1;
if ( m_phase == PHASE_MISSION ) m_index = 2;
@@ -890,7 +892,7 @@ pb->SetState(STATE_SHADOW);
pe->SetState(STATE_SHADOW);
pe->SetMaxChar(500);
pe->SetEditCap(false); // just to see
- pe->SetHiliteCap(false);
+ pe->SetHighlightCap(false);
// Button displays the "soluce":
if ( m_phase != PHASE_TRAINER &&
@@ -1761,9 +1763,6 @@ pos.y -= 0.048f;
}
if ( m_phase == PHASE_WELCOME2 )
{
- m_sound->StopMusic();
- m_sound->PlayMusic(11, false);
-
pos.x = 0.0f;
pos.y = 0.0f;
ddim.x = 0.0f;
@@ -1817,10 +1816,10 @@ pos.y -= 0.048f;
pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1);
pe->SetGenericMode(true);
pe->SetEditCap(false);
- pe->SetHiliteCap(false);
+ pe->SetHighlightCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
- pe->SetFontSize(8.0f);
- pe->ReadText("help/authors.txt");
+ pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
+ pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));
pos.x = 80.0f/640.0f;
pos.y = 140.0f/480.0f;
@@ -1829,30 +1828,30 @@ pos.y -= 0.048f;
pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT2);
pe->SetGenericMode(true);
pe->SetEditCap(false);
- pe->SetHiliteCap(false);
+ pe->SetHighlightCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
- pe->SetFontSize(6.5f);
- pe->ReadText("help/licences.txt");
+ pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
+ pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/licences.txt"));
// #endif
/* TODO: #if _SCHOOL
-#if _CEEBOTDEMO
-pos.x = 80.0f/640.0f;
-pos.y = 210.0f/480.0f;
-ddim.x = 490.0f/640.0f;
-ddim.y = 150.0f/480.0f;
-#else
-pos.x = 80.0f/640.0f;
-pos.y = 200.0f/480.0f;
-ddim.x = 490.0f/640.0f;
-ddim.y = 150.0f/480.0f;
-#endif*/
+ #if _CEEBOTDEMO
+ pos.x = 80.0f/640.0f;
+ pos.y = 210.0f/480.0f;
+ ddim.x = 490.0f/640.0f;
+ ddim.y = 150.0f/480.0f;
+ #else
+ pos.x = 80.0f/640.0f;
+ pos.y = 200.0f/480.0f;
+ ddim.x = 490.0f/640.0f;
+ ddim.y = 150.0f/480.0f;
+ #endif
pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1);
pe->SetGenericMode(true);
pe->SetEditCap(false);
- pe->SetHiliteCap(false);
+ pe->SetHighlightCap(false);
pe->SetFontType(Gfx::FONT_COURIER);
- pe->SetFontSize(8.0f);
- pe->ReadText("help/authors.txt");
+ pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
+ pe->ReadText("help/authors.txt");*/
/* #if _DEMO
//? pos.x = 80.0f/640.0f;
@@ -1864,7 +1863,7 @@ ddim.y = 150.0f/480.0f;
//? pe->SetEditCap(false);
//? pe->SetHiliteCap(false);
//? pe->SetFontType(Gfx::FONT_COURIER);
- //? pe->SetFontSize(8.0f);
+ //? pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
//? pe->ReadText("help/demo.txt");
//? pos.x = 80.0f/640.0f;
@@ -1876,7 +1875,7 @@ ddim.y = 150.0f/480.0f;
//? pe->SetEditCap(false);
//? pe->SetHiliteCap(false);
//? pe->SetFontType(Gfx::FONT_COURIER);
- //? pe->SetFontSize(8.0f);
+ //? pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
//? pe->ReadText("help/authors.txt");
#endif */
@@ -1888,13 +1887,13 @@ ddim.y = 150.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_DEV1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetFontType(Gfx::FONT_COURIER);
- pl->SetFontSize(8.0f);
+ pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.y = 13.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_DEV2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
pl->SetFontType(Gfx::FONT_COURIER);
- pl->SetFontSize(8.0f);
+ pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.x = 355.0f/640.0f;
pos.y = 83.0f/480.0f;
@@ -1903,13 +1902,13 @@ ddim.y = 150.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_EDIT1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name);
pl->SetFontType(Gfx::FONT_COURIER);
- pl->SetFontSize(8.0f);
+ pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
pos.y = 13.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_EDIT2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name);
pl->SetFontType(Gfx::FONT_COURIER);
- pl->SetFontSize(8.0f);
+ pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
// #endif
/* TODO: #if _DEMO
@@ -1928,7 +1927,7 @@ ddim.y = 150.0f/480.0f;
pb->SetState(STATE_SHADOW);
// #endif
- m_engine->SetBackground("generic.png",
+ m_engine->SetBackground("generico.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1972,8 +1971,8 @@ ddim.y = 9.0f/480.0f;
ddim.x = 90.0f/640.0f;
ddim.y = 10.0f/480.0f;
//#endif
- GetResource(RES_TEXT, RT_VERSION_ID, name);
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
+ //GetResource(RES_TEXT, RT_VERSION_ID, name);
+ pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, __DATE__);
pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(9.0f);
}
@@ -3561,11 +3560,11 @@ void CMainDialog::SetUserDir(char *base, int rank)
if ( strcmp(base, "user") == 0 && rank >= 100 )
{
dir = m_userDir + "/" + m_userList.at(rank/100-1);
- UserDir(true, dir.c_str());
+ GetProfile().SetUserDir(dir);
}
else
{
- UserDir(false, "");
+ GetProfile().SetUserDir("");
}
}
@@ -4260,7 +4259,6 @@ bool CMainDialog::IsIOReadScene()
FILE* file;
std::string filename;
- //TODO: Change this to point user dir acocrding to operating system
filename = m_savegameDir + "/" + m_main->GetGamerName() + "/" + "save" + m_sceneName[0] + "000/data.sav";
file = fopen(filename.c_str(), "r");
if ( file == NULL ) return false;
@@ -4277,6 +4275,7 @@ void CMainDialog::IOReadName()
CEdit* pe;
std::string filename;
char op[100];
+ char op_i18n[100];
char line[500];
char resume[100];
char name[100];
@@ -4290,6 +4289,9 @@ void CMainDialog::IOReadName()
sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1);
BuildSceneName(filename, m_sceneName, (m_chap[m_index]+1)*100);
+ sprintf(op, "Title.E");
+ sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar() );
+
file = fopen(filename.c_str(), "r");
if ( file != NULL )
{
@@ -4305,11 +4307,13 @@ void CMainDialog::IOReadName()
}
}
- // TODO: Fallback to an non-localized entry
- sprintf(op, "Title.%c", m_app->GetLanguageChar() );
if ( Cmd(line, op) )
{
OpString(line, "resume", resume);
+ }
+ if ( Cmd(line, op_i18n) )
+ {
+ OpString(line, "resume", resume);
break;
}
}
@@ -4350,7 +4354,7 @@ void CMainDialog::IOReadList()
filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav";
// sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j);
- file = fopen(filename.c_str(), "r");
+ file = fopen(fs::path(filename).make_preferred().string().c_str(), "r");
if ( file == NULL ) break;
while ( fgets(line, 500, file) != NULL )
@@ -4648,12 +4652,14 @@ void CMainDialog::UpdateSceneChap(int &chap)
//struct _finddata_t fileBuffer;
std::string fileName;
char op[100];
+ char op_i18n[100];
char line[500];
char name[100];
int i, j;
bool bPassed;
memset(op, 0, 100);
+ memset(op_i18n, 0, 100);
memset(line, 0, 500);
memset(name, 0, 100);
@@ -4668,6 +4674,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
{
j = 0;
fs::directory_iterator dirIt(m_savegameDir), dirEndIt;
+ m_userList.clear();
BOOST_FOREACH (const fs::path & p, std::make_pair(dirIt, dirEndIt))
{
@@ -4689,6 +4696,9 @@ void CMainDialog::UpdateSceneChap(int &chap)
else
{
BuildResumeName(name, m_sceneName, j+1); // default name
+ sprintf(op, "Title.E");
+ sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar());
+
while ( fgets(line, 500, file) != NULL )
{
for ( i=0 ; i<500 ; i++ )
@@ -4701,11 +4711,13 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
- // TODO: Fallback to an non-localized entry
- sprintf(op, "Title.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
+ }
+ if ( Cmd(line, op_i18n) )
+ {
+ OpString(line, "text", name);
break;
}
}
@@ -4736,6 +4748,9 @@ void CMainDialog::UpdateSceneChap(int &chap)
if ( file == NULL ) break;
BuildResumeName(name, m_sceneName, j+1); // default name
+ sprintf(op, "Title.E");
+ sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar());
+
while ( fgets(line, 500, file) != NULL )
{
for ( i=0 ; i<500 ; i++ )
@@ -4748,11 +4763,13 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
- // TODO: Fallback to an non-localized entry
- sprintf(op, "Title.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
+ }
+ if ( Cmd(line, op_i18n) )
+ {
+ OpString(line, "text", name);
break;
}
}
@@ -4801,12 +4818,14 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
CList* pl;
std::string fileName;
char op[100];
+ char op_i18n[100];
char line[500];
char name[100];
int i, j;
bool bPassed;
memset(op, 0, 100);
+ memset(op_i18n, 0, 100);
memset(line, 0, 500);
memset(name, 0, 100);
@@ -4839,6 +4858,9 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
if ( file == NULL ) break;
BuildResumeName(name, m_sceneName, j+1); // default name
+ sprintf(op, "Title.E");
+ sprintf(op_i18n, "Title.%c", m_app->GetLanguageChar());
+
while ( fgets(line, 500, file) != NULL )
{
for ( i=0 ; i<500 ; i++ )
@@ -4851,11 +4873,13 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
}
}
- // TODO: Fallback to an non-localized entry
- sprintf(op, "Title.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
+ }
+ if ( Cmd(line, op_i18n) )
+ {
+ OpString(line, "text", name);
break;
}
}
@@ -4950,6 +4974,7 @@ void CMainDialog::UpdateSceneResume(int rank)
CCheck* pc;
std::string fileName;
char op[100];
+ char op_i18n[100];
char line[500];
char name[500];
int i, numTry;
@@ -4980,6 +5005,9 @@ void CMainDialog::UpdateSceneResume(int rank)
}
BuildSceneName(fileName, m_sceneName, rank);
+ sprintf(op, "Resume.E");
+ sprintf(op_i18n, "Resume.%c", m_app->GetLanguageChar());
+
file = fopen(fileName.c_str(), "r");
if ( file == NULL ) return;
@@ -4996,11 +5024,13 @@ void CMainDialog::UpdateSceneResume(int rank)
}
}
- // TODO: Fallback to an non-localized entry
- sprintf(op, "Resume.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
+ }
+ if ( Cmd(line, op_i18n) )
+ {
+ OpString(line, "text", name);
break;
}
}
@@ -5016,8 +5046,8 @@ void CMainDialog::UpdateDisplayDevice()
CWindow* pw;
CList* pl;
char bufDevices[1000];
- char bufModes[5000];
- int i, j, totalDevices, selectDevices, totalModes, selectModes;
+ //char bufModes[5000];
+ int i, j;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
@@ -5025,7 +5055,7 @@ void CMainDialog::UpdateDisplayDevice()
if ( pl == 0 ) return;
pl->Flush();
- bufModes[0] = 0;
+ //bufModes[0] = 0;
/* TODO: remove device choice
m_engine->EnumDevices(bufDevices, 1000,
bufModes, 5000,
@@ -5040,10 +5070,10 @@ void CMainDialog::UpdateDisplayDevice()
while ( bufDevices[i++] != 0 );
}
- pl->SetSelect(selectDevices);
+ pl->SetSelect(0);
pl->ShowSelect(false);
- m_setupSelDevice = selectDevices;
+ m_setupSelDevice = 0;
}
// Updates the list of modes.
@@ -5080,8 +5110,8 @@ void CMainDialog::ChangeDisplay()
CWindow* pw;
CList* pl;
CCheck* pc;
- char* device;
- char* mode;
+ //char* device;
+ //char* mode;
bool bFull;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
@@ -5090,12 +5120,12 @@ void CMainDialog::ChangeDisplay()
pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1));
if ( pl == 0 ) return;
m_setupSelDevice = pl->GetSelect();
- device = pl->GetName(m_setupSelDevice);
+ //device = pl->GetName(m_setupSelDevice);
pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
m_setupSelMode = pl->GetSelect();
- mode = pl->GetName(m_setupSelMode);
+ //mode = pl->GetName(m_setupSelMode);
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
if ( pc == 0 ) return;
@@ -5427,10 +5457,8 @@ void CMainDialog::ChangeSetupButtons()
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
- /*
- TODO: midi volume
value = ps->GetVisibleValue();
- m_sound->SetMidiVolume((int)value);*/
+ m_sound->SetMusicVolume(static_cast<int>(value));
}
}
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index 51c6f2e..a79b95e 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -20,20 +20,24 @@
#include "graphics/core/color.h"
+
#include "object/robotmain.h"
-class CInstanceManager;
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
+
+namespace fs = boost::filesystem;
+
+
class CEventQueue;
class CSoundInterface;
-namespace Gfx
-{
+namespace Gfx {
class CEngine;
class CParticle;
-};
+}
-namespace Ui
-{
+namespace Ui {
class CInterface;
class CWindow;
@@ -64,7 +68,7 @@ struct GamerPerso
class CMainDialog
{
public:
- CMainDialog(CInstanceManager* iMan);
+ CMainDialog();
~CMainDialog();
bool EventProcess(const Event &event);
@@ -172,7 +176,6 @@ protected:
void ChangeKey(EventType event);
protected:
- CInstanceManager* m_iMan;
CApplication* m_app;
CRobotMain* m_main;
CEventQueue* m_eventQueue;
@@ -260,3 +263,4 @@ protected:
};
} // namespace Ui
+
diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp
index b70bad9..1143a77 100644
--- a/src/ui/mainmap.cpp
+++ b/src/ui/mainmap.cpp
@@ -15,11 +15,11 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// mainmap.cpp
-
#include "ui/mainmap.h"
+#include "app/app.h"
+
namespace Ui {
@@ -32,12 +32,9 @@ const float ZOOM_MAX = 16.0f;
CMainMap::CMainMap()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_MAP, this);
-
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_interface = CRobotMain::GetInstancePointer()->GetInterface();
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
m_mapMode = 1;
m_bFixImage = false;
diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h
index 35aae4c..9d0d72f 100644
--- a/src/ui/mainmap.h
+++ b/src/ui/mainmap.h
@@ -20,9 +20,13 @@
#pragma once
#include "common/event.h"
+
#include "graphics/core/color.h"
+
#include "math/point.h"
+
#include "object/object.h"
+
#include "ui/interface.h"
@@ -55,7 +59,6 @@ class CMainMap
void CenterMap();
protected:
- CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index 55b9612..d33482c 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -15,24 +15,24 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// mainshort.cpp
-
#include "ui/mainshort.h"
+#include "app/app.h"
+
+#include "common/iman.h"
+
+
namespace Ui {
// Constructor of the application card.
CMainShort::CMainShort()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_SHORT, this);
-
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_event = CApplication::GetInstancePointer()->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
FlushShortcuts();
}
@@ -137,9 +137,11 @@ bool CMainShort::CreateShortcuts()
m_shortcuts[rank] = 0;
rank ++;
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == nullptr ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h
index 0912e68..d679eb0 100644
--- a/src/ui/mainshort.h
+++ b/src/ui/mainshort.h
@@ -19,12 +19,16 @@
#pragma once
-#include "ui/interface.h"
#include "common/event.h"
+
#include "math/point.h"
+
#include "object/object.h"
+
#include "graphics/engine/engine.h"
+#include "ui/interface.h"
+
namespace Ui {
@@ -46,7 +50,6 @@ class CMainShort
protected:
protected:
- CInstanceManager* m_iMan;
CEventQueue* m_event;
Gfx::CEngine* m_engine;
CInterface* m_interface;
diff --git a/src/ui/map.cpp b/src/ui/map.cpp
index b852976..33d0fb1 100644
--- a/src/ui/map.cpp
+++ b/src/ui/map.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// map.cpp
-
#include "ui/map.h"
@@ -31,9 +29,9 @@ namespace Ui {
CMap::CMap() : CControl()
{
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
- m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_main = CRobotMain::GetInstancePointer();
+ m_terrain = m_main->GetTerrain();
+ m_water = Gfx::CEngine::GetInstancePointer()->GetWater();
m_bEnable = true;
m_time = 0.0f;
diff --git a/src/ui/map.h b/src/ui/map.h
index 9e1767c..258dcdf 100644
--- a/src/ui/map.h
+++ b/src/ui/map.h
@@ -22,11 +22,7 @@
#include "ui/control.h"
-#include "object/object.h"
-#include "object/robotmain.h"
-
#include "common/event.h"
-#include "common/iman.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
@@ -36,6 +32,9 @@
#include "math/geometry.h"
+#include "object/object.h"
+#include "object/robotmain.h"
+
namespace Ui {
diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp
index 17f210e..ff7451d 100644
--- a/src/ui/scroll.cpp
+++ b/src/ui/scroll.cpp
@@ -15,14 +15,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// scroll.cpp
#include "ui/scroll.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "graphics/engine/engine.h"
+
#include "ui/button.h"
diff --git a/src/ui/scroll.h b/src/ui/scroll.h
index 52b60bc..57d6f8f 100644
--- a/src/ui/scroll.h
+++ b/src/ui/scroll.h
@@ -20,9 +20,10 @@
#pragma once
-#include "ui/control.h"
#include "common/event.h"
+#include "ui/control.h"
+
namespace Ui {
class CButton;
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index 18b8f31..4462140 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -15,13 +15,12 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// shortcut.cpp
#include "ui/shortcut.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "graphics/engine/engine.h"
#include "graphics/core/device.h"
@@ -31,7 +30,6 @@ namespace Ui {
// Object's constructor.
-//CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan)
CShortcut::CShortcut() : CControl()
{
m_time = 0.0f;
diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp
index ca907fe..f516e70 100644
--- a/src/ui/slider.cpp
+++ b/src/ui/slider.cpp
@@ -15,15 +15,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// slider.cpp
#include "ui/slider.h"
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
+
#include "graphics/engine/engine.h"
#include "graphics/engine/text.h"
+
#include "ui/button.h"
#include <stdio.h>
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index 2f58c95..29dfebf 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -15,23 +15,26 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// studio.cpp
-
-#include "studio.h"
+#include "ui/studio.h"
#include "CBot/CBotDll.h"
#include "app/app.h"
+
#include "common/event.h"
-#include "common/iman.h"
#include "common/misc.h"
+
#include "graphics/engine/camera.h"
#include "graphics/engine/engine.h"
+
#include "object/object.h"
+
#include "script/cbottoken.h"
#include "script/script.h"
+
#include "sound/sound.h"
+
#include "ui/check.h"
#include "ui/control.h"
#include "ui/color.h"
@@ -61,16 +64,13 @@ namespace Ui {
CStudio::CStudio()
{
- m_iMan = CInstanceManager::GetInstancePointer();
- m_iMan->AddInstance(CLASS_STUDIO, this);
-
- m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
- m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
- m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
- m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
- m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
- m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
- m_app = CApplication::GetInstancePointer();
+ m_app = CApplication::GetInstancePointer();
+ m_sound = m_app->GetSound();
+ m_event = m_app->GetEventQueue();
+ m_engine = Gfx::CEngine::GetInstancePointer();
+ m_main = CRobotMain::GetInstancePointer();
+ m_interface = m_main->GetInterface();
+ m_camera = m_main->GetCamera();
m_bEditMaximized = false;
m_bEditMinimized = false;
@@ -87,7 +87,6 @@ CStudio::CStudio()
CStudio::~CStudio()
{
- m_iMan->DeleteInstance(CLASS_STUDIO, this);
}
@@ -114,7 +113,7 @@ bool CStudio::EventProcess(const Event &event)
if ( pw == nullptr ) return false;
edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT));
- if ( edit == 0 ) return false;
+ if ( edit == nullptr ) return false;
if ( event.type == pw->GetEventTypeClose() )
{
@@ -501,7 +500,7 @@ void CStudio::SearchToken(CEdit* edit)
}
token[i] = 0;
- m_helpFilename = std::string(GetHelpFilename(token));
+ m_helpFilename = GetHelpFilename(token);
if ( m_helpFilename.length() == 0 )
{
for ( i=0 ; i<OBJECT_MAX ; i++ )
@@ -692,7 +691,7 @@ void CStudio::AdjustEditScript()
dim.x = wdim.x-0.02f;
dim.y = wdim.y-0.22f-hList;
edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
- if ( edit != 0 )
+ if ( edit != nullptr )
{
edit->SetPos(pos);
edit->SetDim(dim);
@@ -703,7 +702,7 @@ void CStudio::AdjustEditScript()
dim.x = wdim.x-0.02f;
dim.y = hList;
list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST));
- if ( list != 0 )
+ if ( list != nullptr )
{
list->SetPos(pos);
list->SetDim(dim);
@@ -716,56 +715,56 @@ void CStudio::AdjustEditScript()
pos.y = wpos.y+wdim.y-dim.y-0.06f;
pos.x = wpos.x+0.01f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_NEW));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.05f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OPEN));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.09f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_SAVE));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.14f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_UNDO));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.19f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CUT));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.23f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COPY));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.27f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_PASTE));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.32f;
slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE));
- if ( slider != 0 )
+ if ( slider != nullptr )
{
ppos = pos;
ddim.x = dim.x*0.7f;
@@ -777,21 +776,21 @@ void CStudio::AdjustEditScript()
}
pos.x = wpos.x+0.36f;
group = static_cast< CGroup* >(pw->SearchControl(EVENT_LABEL1));
- if ( group != 0 )
+ if ( group != nullptr )
{
group->SetPos(pos);
group->SetDim(dim);
}
pos.x = wpos.x+0.40f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_TOOL));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.44f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_HELP));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
@@ -802,14 +801,14 @@ void CStudio::AdjustEditScript()
dim.x = 80.0f/640.0f;
dim.y = 25.0f/480.0f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OK));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.14f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CANCEL));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
@@ -817,28 +816,28 @@ void CStudio::AdjustEditScript()
pos.x = wpos.x+0.28f;
dim.x = dim.y*0.75f;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.28f+dim.x*1;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.28f+dim.x*2;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.28f+dim.x*3;
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP));
- if ( button != 0 )
+ if ( button != nullptr )
{
button->SetPos(pos);
button->SetDim(dim);
@@ -991,13 +990,13 @@ void CStudio::UpdateButtons()
{
edit->SetIcon(1); // red background
edit->SetEditCap(false); // just to see
- edit->SetHiliteCap(true);
+ edit->SetHighlightCap(true);
}
else
{
edit->SetIcon(0); // standard background
edit->SetEditCap(true);
- edit->SetHiliteCap(true);
+ edit->SetHighlightCap(true);
}
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE));
@@ -1478,8 +1477,7 @@ void CStudio::UpdateDialogPublic()
CCheck* pc;
CLabel* pl;
char name[100];
- char dir[MAX_FNAME];
- char text[MAX_FNAME+100];
+ //char text[MAX_FNAME+100];
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return;
@@ -1500,9 +1498,7 @@ void CStudio::UpdateDialogPublic()
if ( pl != 0 )
{
GetResource(RES_TEXT, RT_IO_LIST, name);
- SearchDirectory(dir, false);
- sprintf(text, name, dir);
- pl->SetName(text, false);
+ pl->SetName(SearchDirectory(false).c_str(), false);
}
}
@@ -1510,84 +1506,52 @@ void CStudio::UpdateDialogPublic()
void CStudio::UpdateDialogList()
{
- // TODO rewrite to multiplatform
- /*CWindow* pw;
- CList* pl;
- long hFile;
- struct _finddata_t fileBuffer;
- struct _finddata_t* listBuffer;
- bool bDo;
- char dir[MAX_FNAME];
- char temp[MAX_FNAME];
- int nbFilenames, i;
-
- pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9);
+ CWindow* pw;
+ CList* pl;
+ fs::path path;
+ int i = 0;
+ char time[100];
+ char temp[100];
+
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return;
- pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST);
- if ( pl == 0 ) return;
+ pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST));
+ if ( pl == nullptr ) return;
pl->Flush();
- nbFilenames = 0;
- listBuffer = (_finddata_t*)malloc(sizeof(_finddata_t)*1000);
-
- SearchDirectory(dir, false);
- strcat(dir, "*"); // list all
- hFile = _findfirst(dir, &fileBuffer);
- if ( hFile != -1 )
- {
- do
- {
- if ( (fileBuffer.attrib & _A_SUBDIR) == 0 )
- {
- listBuffer[nbFilenames++] = fileBuffer;
+ path = fs::path(SearchDirectory(false));
+ fs::directory_iterator end_iter;
+ if ( fs::exists(path) && fs::is_directory(path) ) {
+ for( fs::directory_iterator file(path); file != end_iter; file++) {
+ if (fs::is_regular_file(file->status()) ) {
+ TimeToAscii(fs::last_write_time(file->path()), time);
+ sprintf(temp, "%s\t%lu \t%s", file->path().filename().string().c_str(), fs::file_size(file->path()), time);
+
+ pl->SetName(i++, temp);
}
}
- while ( _findnext(hFile, &fileBuffer) == 0 && nbFilenames < 1000 );
}
- do // sorts all names:
- {
- bDo = false;
- for ( i=0 ; i<nbFilenames-1 ; i++ )
- {
- if ( strcmp(listBuffer[i].name, listBuffer[i+1].name) > 0 )
- {
- fileBuffer = listBuffer[i]; // exchange i and i +1
- listBuffer[i] = listBuffer[i+1];
- listBuffer[i+1] = fileBuffer;
- bDo = true;
- }
- }
- }
- while ( bDo );
-
- for ( i=0 ; i<nbFilenames ; i++ )
- {
- TimeToAscii(listBuffer[i].time_write, dir);
- sprintf(temp, "%s\t%d \t%s", listBuffer[i].name, listBuffer[i].size, dir);
- pl->SetName(i, temp);
- }
-
- free(listBuffer);*/
}
// Constructs the name of the folder or open/save.
// If the folder does not exist, it will be created.
-void CStudio::SearchDirectory(char *dir, bool bCreate)
+std::string CStudio::SearchDirectory(bool bCreate)
{
- if ( m_main->GetIOPublic() )
- {
- sprintf(dir, "%s\\", m_main->GetPublicDir());
+ char dir[MAX_FNAME];
+ if ( m_main->GetIOPublic() ) {
+ sprintf(dir, "%s/", m_main->GetPublicDir());
+ } else {
+ sprintf(dir, "%s/%s/Program/", m_main->GetSavegameDir(), m_main->GetGamerName());
}
- else
- {
- sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName());
+
+ fs::path path = fs::path(dir);
+
+ if ( bCreate ) {
+ fs::create_directory(path);
}
- if ( bCreate )
- {// TODO
-// mkdir(dir,0777); // if does not exist yet!
- }
+ return path.make_preferred().string();
}
// Reads a new program.
@@ -1613,7 +1577,7 @@ bool CStudio::ReadProgram()
{
strcat(filename, ".txt");
}
- SearchDirectory(dir, true);
+ strcpy(dir, SearchDirectory(true).c_str());
strcat(dir, filename);
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
@@ -1651,7 +1615,7 @@ bool CStudio::WriteProgram()
{
strcat(filename, ".txt");
}
- SearchDirectory(dir, true);
+ strcpy(dir, SearchDirectory(true).c_str());
strcat(dir, filename);
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
@@ -1659,7 +1623,7 @@ bool CStudio::WriteProgram()
pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( pe == nullptr ) return false;
- if ( !pe->WriteText(dir) ) return false;
+ if ( !pe->WriteText(std::string(dir)) ) return false;
m_script->SetFilename(filename);
return true;
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 905baa6..1c14124 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -22,11 +22,13 @@
#include "graphics/engine/camera.h"
+#include <boost/filesystem.hpp>
+
+namespace fs = boost::filesystem;
#include <string>
class CEventQueue;
-class CInstanceManager;
class CRobotMain;
class CScript;
class CSoundInterface;
@@ -54,70 +56,69 @@ enum StudioDialog
class CStudio
{
- public:
- CStudio();
- ~CStudio();
-
- bool EventProcess(const Event &event);
-
- void StartEditScript(CScript *script, std::string name, int rank);
- bool StopEditScript(bool bCancel);
-
- protected:
- bool EventFrame(const Event &event);
- void SearchToken(CEdit* edit);
- void ColorizeScript(CEdit* edit);
- void AdjustEditScript();
- void SetInfoText(std::string text, bool bClickable);
- void ViewEditScript();
- void UpdateFlux();
- void UpdateButtons();
-
- void StartDialog(StudioDialog type);
- void StopDialog();
- void AdjustDialog();
- bool EventDialog(const Event &event);
- void UpdateChangeList();
- void UpdateChangeEdit();
- void UpdateDialogAction();
- void UpdateDialogPublic();
- void UpdateDialogList();
- void SearchDirectory(char* dir, bool bCreate);
- bool ReadProgram();
- bool WriteProgram();
-
- protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- CEventQueue* m_event;
- CRobotMain* m_main;
- Gfx::CCamera* m_camera;
- CSoundInterface* m_sound;
- CInterface* m_interface;
- CApplication *m_app;
-
- int m_rank;
- CScript* m_script;
- Gfx::CameraType m_editCamera;
-
- bool m_bEditMaximized;
- bool m_bEditMinimized;
-
- Math::Point m_editActualPos;
- Math::Point m_editActualDim;
- Math::Point m_editFinalPos;
- Math::Point m_editFinalDim;
-
- float m_time;
- float m_fixInfoTextTime;
- bool m_bRunning;
- bool m_bRealTime;
- bool m_bInitPause;
- std::string m_helpFilename;
+public:
+ CStudio();
+ ~CStudio();
+
+ bool EventProcess(const Event &event);
+
+ void StartEditScript(CScript *script, std::string name, int rank);
+ bool StopEditScript(bool bCancel);
+
+protected:
+ bool EventFrame(const Event &event);
+ void SearchToken(CEdit* edit);
+ void ColorizeScript(CEdit* edit);
+ void AdjustEditScript();
+ void SetInfoText(std::string text, bool bClickable);
+ void ViewEditScript();
+ void UpdateFlux();
+ void UpdateButtons();
+
+ void StartDialog(StudioDialog type);
+ void StopDialog();
+ void AdjustDialog();
+ bool EventDialog(const Event &event);
+ void UpdateChangeList();
+ void UpdateChangeEdit();
+ void UpdateDialogAction();
+ void UpdateDialogPublic();
+ void UpdateDialogList();
+ std::string SearchDirectory(bool bCreate);
+ bool ReadProgram();
+ bool WriteProgram();
+
+protected:
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CSoundInterface* m_sound;
+ CInterface* m_interface;
+ CApplication* m_app;
+
+ int m_rank;
+ CScript* m_script;
+ Gfx::CameraType m_editCamera;
+
+ bool m_bEditMaximized;
+ bool m_bEditMinimized;
+
+ Math::Point m_editActualPos;
+ Math::Point m_editActualDim;
+ Math::Point m_editFinalPos;
+ Math::Point m_editFinalDim;
+
+ float m_time;
+ float m_fixInfoTextTime;
+ bool m_bRunning;
+ bool m_bRealTime;
+ bool m_bInitPause;
+ std::string m_helpFilename;
StudioDialog m_dialog;
};
-}
+} // namespace Ui
diff --git a/src/ui/target.cpp b/src/ui/target.cpp
index b47ba16..cc74750 100644
--- a/src/ui/target.cpp
+++ b/src/ui/target.cpp
@@ -14,11 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// target.cpp
-
#include "ui/target.h"
+#include "common/iman.h"
namespace Ui {
@@ -189,9 +188,11 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
objRank = m_engine->DetectObject(pos);
+ CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
+
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ pObj = static_cast<CObject*>(iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->GetActif() ) continue;
diff --git a/src/ui/target.h b/src/ui/target.h
index 05a3651..054524b 100644
--- a/src/ui/target.h
+++ b/src/ui/target.h
@@ -18,20 +18,19 @@
#pragma once
-#include <string>
-
-#include "ui/control.h"
-
+#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
-#include "common/event.h"
#include "graphics/engine/engine.h"
#include "object/robotmain.h"
#include "object/object.h"
+#include "ui/control.h"
+
+#include <string>
+
namespace Ui {
diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt
deleted file mode 100644
index c38d2bb..0000000
--- a/src/ui/test/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-include_directories(
-.
-../..
-../../..
-${GTEST_INCLUDE_DIR}
-${GMOCK_INCLUDE_DIR}
-)
-
-
-add_executable(edit_test
- ../../common/event.cpp
- ../../common/logger.cpp
- ../../common/misc.cpp
- ../../common/iman.cpp
- ../../common/stringutils.cpp
- ../../graphics/engine/text.cpp
- ../button.cpp
- ../control.cpp
- ../edit.cpp
- ../scroll.cpp
- stubs/app_stub.cpp
- stubs/engine_stub.cpp
- stubs/particle_stub.cpp
- stubs/restext_stub.cpp
- stubs/robotmain_stub.cpp
- edit_test.cpp)
-target_link_libraries(edit_test gtest gmock ${SDL_LIBRARY} ${SDLTTF_LIBRARY})
-
-add_test(edit_test ./edit_test)
diff --git a/src/ui/test/edit_test.cpp b/src/ui/test/edit_test.cpp
deleted file mode 100644
index 489b873..0000000
--- a/src/ui/test/edit_test.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "../edit.h"
-#include "../../app/app.h"
-#include "mocks/text_mock.h"
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-#include <fstream>
-
-class CEditTest : public testing::Test
-{
-public:
- CEditTest(){};
-
- virtual void SetUp()
- {
- m_engine = new Gfx::CEngine(&m_iMan, NULL);
-
- m_iMan.AddInstance(CLASS_ENGINE, m_engine);
- m_edit = new Ui::CEdit;
- }
-
- virtual void TearDown()
- {
- m_iMan.DeleteInstance(CLASS_ENGINE, m_engine);
- delete m_engine;
- m_engine = NULL;
- delete m_edit;
- m_edit = NULL;
-
- }
- virtual ~CEditTest()
- {
-
- };
-
-protected:
- CInstanceManager m_iMan;
- CApplication m_app;
- Gfx::CEngine * m_engine;
- Ui::CEdit * m_edit;
- CLogger m_logger;
-};
-
-using ::testing::_;
-using ::testing::Return;
-
-TEST_F(CEditTest, WriteTest)
-{
- ASSERT_TRUE(true);
- CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText());
- EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f));
- EXPECT_CALL(*text, GetStringWidth(_, _, _)).WillOnce(Return(1.0f));
- std::string filename = "test.file";
- m_edit->SetMaxChar(Ui::EDITSTUDIOMAX);
- m_edit->SetAutoIndent(true);
- std::string inputScript = "{\ntext1\ntext2\n\ntext3\n{\ntext4\n}\n}";
- std::string expectedScript = "{\r\n\ttext1\r\n\ttext2\r\n\t\r\n\ttext3\r\n\t{\r\n\t\ttext4\r\n\t}\r\n}";
- m_edit->SetText(inputScript.c_str(), true);
- GetLogger()->Info("Writing text \n");
- m_edit->WriteText("script.txt");
-
- std::fstream scriptFile;
-
- scriptFile.open("script.txt", std::ios_base::binary | std::ios_base::in);
- std::string outputScript((std::istreambuf_iterator<char>(scriptFile)), std::istreambuf_iterator<char>());
- ASSERT_STREQ(expectedScript.c_str(), outputScript.c_str());
-}
-
-int main(int argc, char *argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
diff --git a/src/ui/test/mocks/text_mock.h b/src/ui/test/mocks/text_mock.h
deleted file mode 100644
index 59a6c48..0000000
--- a/src/ui/test/mocks/text_mock.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "../../graphics/engine/text.h"
-#include <gmock/gmock.h>
-#include "../../common/logger.h"
-
-
-class CTextMock : public Gfx::CText
-{
-public:
- CTextMock(CInstanceManager *iMan, Gfx::CEngine* engine) : CText(iMan, engine)
- {
- }
-
- virtual ~CTextMock()
- {
- };
-
- MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float));
- MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float));
-
-};
-
diff --git a/src/ui/test/stubs/app_stub.cpp b/src/ui/test/stubs/app_stub.cpp
deleted file mode 100644
index 5dd79e4..0000000
--- a/src/ui/test/stubs/app_stub.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "../../app/app.h"
-#include "../../graphics/opengl/gldevice.h"
-
-template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
-
-namespace Gfx {
-
-GLDeviceConfig::GLDeviceConfig()
-{
-}
-
-} /* Gfx */
-CApplication::CApplication()
-{
-}
-
-CApplication::~CApplication()
-{
-}
-
-std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::string& subpath)
-{
- return subpath;
-}
-
-
diff --git a/src/ui/test/stubs/engine_stub.cpp b/src/ui/test/stubs/engine_stub.cpp
deleted file mode 100644
index 6ec6006..0000000
--- a/src/ui/test/stubs/engine_stub.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "../../graphics/engine/engine.h"
-#include "../../graphics/engine/text.h"
-#include "../mocks/text_mock.h"
-
-namespace Gfx {
-
-CEngine::CEngine(CInstanceManager* iMan, CApplication* app) :
- m_iMan(iMan), m_app(app)
-{
- m_text = new CTextMock(m_iMan, this);
- m_text->Create();
-}
-
-CEngine::~CEngine()
-{
- delete m_text;
- m_text = NULL;
-}
-
-Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size)
-{
- return Math::Point(size.x, size.y);
-}
-
-void CEngine::SetState(int state, const Color& color)
-{
- if (state == m_lastState && color == m_lastColor)
- return;
-
- m_lastState = state;
- m_lastColor = color;
-}
-
-Math::IntPoint CEngine::GetWindowSize()
-{
- return m_size;
-}
-
-void CEngine::AddStatisticTriangle(int count)
-{
- m_statisticTriangle += count;
-}
-
-void CEngine::SetMouseType(EngineMouseType type)
-{
- m_mouseType = type;
-}
-
-bool CEngine::SetTexture(const std::string& /* name */, int /* stage */)
-{
- return true;
-}
-
-CText* CEngine::GetText()
-{
- return m_text;
-}
-
-CDevice* CEngine::GetDevice()
-{
- return m_device;
-}
-
-int CEngine::GetEditIndentValue()
-{
- return m_editIndentValue;
-}
-
-void CEngine::DeleteTexture(const std::string& /* texName */)
-{
-}
-Texture CEngine::LoadTexture(const std::string& /* name */)
-{
- Texture texture;
- return texture;
-}
-
-} /* Gfx */
-
diff --git a/src/ui/test/stubs/particle_stub.cpp b/src/ui/test/stubs/particle_stub.cpp
deleted file mode 100644
index 41f07cc..0000000
--- a/src/ui/test/stubs/particle_stub.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-#include "graphics/engine/particle.h"
-
-#include "common/logger.h"
-
-
-// Graphics module namespace
-namespace Gfx {
-
-
-CParticle::CParticle(CInstanceManager* iMan, CEngine* engine)
-{
- GetLogger()->Trace("CParticle::CParticle() stub!\n");
- // TODO!
-}
-
-CParticle::~CParticle()
-{
- GetLogger()->Trace("CParticle::~CParticle() stub!\n");
- // TODO!
-}
-
-void CParticle::SetDevice(CDevice* device)
-{
- GetLogger()->Trace("CParticle::SetDevice() stub!\n");
- // TODO!
-}
-
-void CParticle::FlushParticle()
-{
- GetLogger()->Trace("CParticle::FlushParticle() stub!\n");
- // TODO!
-}
-
-void CParticle::FlushParticle(int sheet)
-{
- GetLogger()->Trace("CParticle::FlushParticle() stub!\n");
- // TODO!
-}
-
-int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim,
- ParticleType type, float duration, float mass,
- float windSensitivity, int sheet)
-{
- GetLogger()->Trace("CParticle::CreateParticle() stub!\n");
- // TODO!
- return 0;
-}
-
-int CParticle::CreateFrag(Math::Vector pos, Math::Vector speed, EngineTriangle *triangle,
- ParticleType type, float duration, float mass,
- float windSensitivity, int sheet)
-{
- GetLogger()->Trace("CParticle::CreateFrag() stub!\n");
- // TODO!
- return 0;
-}
-
-int CParticle::CreatePart(Math::Vector pos, Math::Vector speed, ParticleType type,
- float duration, float mass, float weight,
- float windSensitivity, int sheet)
-{
- GetLogger()->Trace("CParticle::CreatePart() stub!\n");
- // TODO!
- return 0;
-}
-
-int CParticle::CreateRay(Math::Vector pos, Math::Vector goal, ParticleType type, Math::Point dim,
- float duration, int sheet)
-{
- GetLogger()->Trace("CParticle::CreateRay() stub!\n");
- // TODO!
- return 0;
-}
-
-int CParticle::CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticleType type,
- float duration, float mass, float length, float width)
-{
- GetLogger()->Trace("CParticle::CreateTrack() stub!\n");
- // TODO!
- return 0;
-}
-
-void CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3,
- const Math::Vector &p4, ParticleType type)
-{
- GetLogger()->Trace("CParticle::CreateWheelTrace() stub!\n");
- // TODO!
-}
-
-void CParticle::DeleteParticle(ParticleType type)
-{
- GetLogger()->Trace("CParticle::DeleteParticle() stub!\n");
- // TODO!
-}
-
-void CParticle::DeleteParticle(int channel)
-{
- GetLogger()->Trace("CParticle::DeleteParticle() stub!\n");
- // TODO!
-}
-
-void CParticle::SetObjectLink(int channel, CObject *object)
-{
- GetLogger()->Trace("CParticle::SetObjectLink() stub!\n");
- // TODO!
-}
-
-void CParticle::SetObjectFather(int channel, CObject *object)
-{
- GetLogger()->Trace("CParticle::SetObjectFather() stub!\n");
- // TODO!
-}
-
-void CParticle::SetPosition(int channel, Math::Vector pos)
-{
- GetLogger()->Trace("CParticle::SetPosition() stub!\n");
- // TODO!
-}
-
-void CParticle::SetDimension(int channel, Math::Point dim)
-{
- GetLogger()->Trace("CParticle::SetDimension() stub!\n");
- // TODO!
-}
-
-void CParticle::SetZoom(int channel, float zoom)
-{
- GetLogger()->Trace("CParticle::SetZoom() stub!\n");
- // TODO!
-}
-
-void CParticle::SetAngle(int channel, float angle)
-{
- GetLogger()->Trace("CParticle::SetAngle() stub!\n");
- // TODO!
-}
-
-void CParticle::SetIntensity(int channel, float intensity)
-{
- GetLogger()->Trace("CParticle::SetIntensity() stub!\n");
- // TODO!
-}
-
-void CParticle::SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity)
-{
- GetLogger()->Trace("CParticle::SetParam() stub!\n");
- // TODO!
-}
-
-void CParticle::SetPhase(int channel, ParticlePhase phase, float duration)
-{
- GetLogger()->Trace("CParticle::SetPhase() stub!\n");
- // TODO!
-}
-
-bool CParticle::GetPosition(int channel, Math::Vector &pos)
-{
- GetLogger()->Trace("CParticle::GetPosition() stub!\n");
- // TODO!
- return true;
-}
-
-Color CParticle::GetFogColor(Math::Vector pos)
-{
- GetLogger()->Trace("CParticle::GetFogColor() stub!\n");
- // TODO!
- return Color();
-}
-
-void CParticle::SetFrameUpdate(int sheet, bool update)
-{
- GetLogger()->Trace("CParticle::SetFrameUpdate() stub!\n");
- // TODO!
-}
-
-void CParticle::FrameParticle(float rTime)
-{
- GetLogger()->Trace("CParticle::FrameParticle() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticle(int sheet)
-{
- GetLogger()->Trace("CParticle::DrawParticle() stub!\n");
- // TODO!
-}
-
-bool CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
-{
- GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n");
- // TODO!
- return true;
-}
-
-void CParticle::DeleteRank(int rank)
-{
- GetLogger()->Trace("CParticle::DeleteRank() stub!\n");
- // TODO!
-}
-
-bool CParticle::CheckChannel(int &channel)
-{
- GetLogger()->Trace("CParticle::CheckChannel() stub!\n");
- // TODO!
- return true;
-}
-
-void CParticle::DrawParticleTriangle(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleTriangle() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleNorm(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleNorm() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleFlat(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleFlat() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleFog(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleFog() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleRay(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleRay() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleSphere(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleSphere() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleCylinder(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleCylinder() stub!\n");
- // TODO!
-}
-
-void CParticle::DrawParticleWheel(int i)
-{
- GetLogger()->Trace("CParticle::DrawParticleWheel() stub!\n");
- // TODO!
-}
-
-CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father)
-{
- GetLogger()->Trace("CParticle::SearchObjectGun() stub!\n");
- // TODO!
- return nullptr;
-}
-
-CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father)
-{
- GetLogger()->Trace("CParticle::SearchObjectRay() stub!\n");
- // TODO!
- return nullptr;
-}
-
-void CParticle::Play(Sound sound, Math::Vector pos, float amplitude)
-{
- GetLogger()->Trace("CParticle::Play() stub!\n");
- // TODO!
-}
-
-bool CParticle::TrackMove(int i, Math::Vector pos, float progress)
-{
- GetLogger()->Trace("CParticle::TrackMove() stub!\n");
- // TODO!
- return true;
-}
-
-void CParticle::TrackDraw(int i, ParticleType type)
-{
- GetLogger()->Trace("CParticle::TrackDraw() stub!\n");
- // TODO!
-}
-
-
-} // namespace Gfx
-
diff --git a/src/ui/test/stubs/restext_stub.cpp b/src/ui/test/stubs/restext_stub.cpp
deleted file mode 100644
index c1986ca..0000000
--- a/src/ui/test/stubs/restext_stub.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "../../common/restext.h"
-bool GetResource(ResType /* type */, int /* num */, char* /* text */)
-{
- return true;
-}
-
-bool SearchKey(const char * /* cmd */, InputSlot & /* key */)
-{
- return true;
-}
-
diff --git a/src/ui/test/stubs/robotmain_stub.cpp b/src/ui/test/stubs/robotmain_stub.cpp
deleted file mode 100644
index 93e0e82..0000000
--- a/src/ui/test/stubs/robotmain_stub.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "../../object/robotmain.h"
-
-
-template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr;
-
-bool CRobotMain::GetGlint()
-{
- return false;
-}
-
-const InputBinding& CRobotMain::GetInputBinding(InputSlot slot)
-{
- unsigned int index = static_cast<unsigned int>(slot);
- assert(index >= 0 && index < INPUT_SLOT_MAX);
- return m_inputBindings[index];
-}
-
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 97daf94..6013d37 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -15,8 +15,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// window.cpp
-
#include "ui/window.h"
@@ -25,7 +23,6 @@
namespace Ui {
// Object's constructor.
-//CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
CWindow::CWindow() : CControl()
{
int i;
@@ -122,7 +119,6 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CButton(m_iMan);
m_table[i] = new CButton();
pc = static_cast<CButton*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -145,7 +141,6 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CColor(m_iMan);
m_table[i] = new CColor();
pc = static_cast<CColor*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -168,7 +163,6 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CCheck(m_iMan);
m_table[i] = new CCheck();
pc = static_cast<CCheck*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -191,7 +185,6 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType e
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CKey(m_iMan);
m_table[i] = new CKey();
pc = static_cast<CKey*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -214,7 +207,6 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CGroup(m_iMan);
m_table[i] = new CGroup();
pc = static_cast<CGroup*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -237,7 +229,6 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CImage(m_iMan);
m_table[i] = new CImage();
pc = static_cast<CImage*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -260,7 +251,6 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventTy
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CLabel(m_iMan);
m_table[i] = new CLabel();
pc = static_cast<CLabel*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -289,7 +279,6 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CEdit(m_iMan);
m_table[i] = new CEdit();
pc = static_cast<CEdit*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -312,7 +301,6 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon,
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CEditValue(m_iMan);
m_table[i] = new CEditValue();
pc = static_cast<CEditValue*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -335,7 +323,6 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CScroll(m_iMan);
m_table[i] = new CScroll();
pc = static_cast<CScroll*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -358,7 +345,6 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CSlider(m_iMan);
m_table[i] = new CSlider();
pc = static_cast<CSlider*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
@@ -382,7 +368,6 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType
{
if ( m_table[i] == 0 )
{
-// m_table[i] = new CList(m_iMan);
m_table[i] = new CList();
pc = static_cast<CList*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg, expand);
diff --git a/src/ui/window.h b/src/ui/window.h
index 8d7090c..e39b8a9 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -19,12 +19,12 @@
#pragma once
-#include <string>
-
#include "common/event.h"
#include "common/misc.h"
#include "common/restext.h"
+#include "graphics/engine/text.h"
+
#include "ui/button.h"
#include "ui/color.h"
#include "ui/check.h"
@@ -44,7 +44,7 @@
#include "ui/target.h"
#include "ui/control.h"
-#include "graphics/engine/text.h"
+#include <string>
namespace Ui {