Permalink
Browse files

JSON layouts, Alloc chunk iterators

- saving to JSON format
- ozCore
  * Alloc
    + iterating over alocated chunks: objectCIter(), arrayCIter()
    + printSummary() -> Log::printMemorySummary()
    + printLeaks() -> Log::printMemoryLeaks()
  * String(float) -> String(double), parseFloat() -> parseDouble()
- matrix
  * read( const JSON& ), write( JSON* ) on Object, Struct, Frag, Matrix etc.
- client
  * Ctrl+F9 toggles UI
  * GameStage
    + reload() removed, new GameStage is scheduled instead
    + readLayout(), writeLayout()
  • Loading branch information...
ducakar committed Feb 26, 2013
1 parent d17c6ec commit 3cf6674e6938e9864cd108aab5f170fda7bd64a6
Showing with 1,433 additions and 405 deletions.
  1. +4 −0 data/oz_missions/mission/empty/description.json
  2. +192 −0 data/oz_missions/mission/empty/main.lua
  3. +6 −1 doc/PREBERI.html
  4. +7 −3 doc/README.html
  5. +1 −1 src/builder/Compiler.cc
  6. +9 −6 src/client/Client.cc
  7. +1 −1 src/client/Context.cc
  8. +86 −113 src/client/GameStage.cc
  9. +9 −10 src/client/GameStage.hh
  10. +12 −6 src/client/Input.cc
  11. +2 −0 src/client/Input.hh
  12. +2 −2 src/client/Loader.cc
  13. +3 −11 src/client/MenuStage.cc
  14. +0 −3 src/client/MenuStage.hh
  15. +3 −3 src/client/Sound.cc
  16. +6 −6 src/client/ui/MainMenu.cc
  17. +3 −3 src/client/ui/MissionMenu.cc
  18. +20 −12 src/client/ui/UI.cc
  19. +3 −2 src/client/ui/UI.hh
  20. +61 −0 src/matrix/Bot.cc
  21. +2 −0 src/matrix/Bot.hh
  22. +5 −0 src/matrix/BotClass.cc
  23. +1 −0 src/matrix/BotClass.hh
  24. +25 −0 src/matrix/Dynamic.cc
  25. +2 −0 src/matrix/Dynamic.hh
  26. +5 −0 src/matrix/DynamicClass.cc
  27. +1 −0 src/matrix/DynamicClass.hh
  28. +21 −0 src/matrix/Frag.cc
  29. +2 −0 src/matrix/Frag.hh
  30. +20 −0 src/matrix/Matrix.cc
  31. +3 −0 src/matrix/Matrix.hh
  32. +64 −0 src/matrix/Object.cc
  33. +2 −0 src/matrix/Object.hh
  34. +5 −0 src/matrix/ObjectClass.cc
  35. +1 −0 src/matrix/ObjectClass.hh
  36. +218 −9 src/matrix/Orbis.cc
  37. +3 −0 src/matrix/Orbis.hh
  38. +94 −0 src/matrix/Struct.cc
  39. +2 −0 src/matrix/Struct.hh
  40. +60 −0 src/matrix/Vehicle.cc
  41. +2 −0 src/matrix/Vehicle.hh
  42. +5 −0 src/matrix/VehicleClass.cc
  43. +1 −0 src/matrix/VehicleClass.hh
  44. +15 −0 src/matrix/Weapon.cc
  45. +2 −0 src/matrix/Weapon.hh
  46. +5 −0 src/matrix/WeaponClass.cc
  47. +1 −0 src/matrix/WeaponClass.hh
  48. +49 −96 src/ozCore/Alloc.cc
  49. +73 −18 src/ozCore/Alloc.hh
  50. +5 −4 src/ozCore/Gettext.cc
  51. +2 −2 src/ozCore/Gettext.hh
  52. +9 −20 src/ozCore/JSON.cc
  53. +4 −10 src/ozCore/JSON.hh
  54. +46 −0 src/ozCore/Log.cc
  55. +20 −4 src/ozCore/Log.hh
  56. +8 −10 src/ozCore/String.cc
  57. +12 −11 src/ozCore/String.hh
  58. +8 −7 src/ozCore/Thread.cc
  59. +7 −7 src/ozCore/Thread.hh
  60. +7 −7 src/ozCore/ozCore.hh
  61. +0 −1 src/ozEngine/CMakeLists.txt
  62. 0 src/ozEngine/dummy.cc
  63. +1 −1 src/tests/foreach.cc
  64. +1 −1 src/tests/quicksort.cc
  65. +165 −2 src/tests/test.cc
  66. +1 −2 src/tools/CMakeLists.txt
  67. +10 −2 src/tools/openzone.cc
  68. +1 −1 src/tools/ozBuild.cc
  69. +6 −6 src/unittest/String.cc
  70. +1 −1 src/unittest/unittest.cc
@@ -0,0 +1,4 @@
+{
+ "title": "Empty",
+ "description": "Empty world intended for creating new mission."
+}
@@ -0,0 +1,192 @@
+--[[
+ * OpenZone - simple cross-platform FPS/RTS game engine.
+ * Copyright (C) 2002-2012 Davorin Učakar
+ *
+ * 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/>.
+ *
+ * Davorin Učakar
+ * <davorin.ucakar@gmail.com>
+]]--
+
+--[[
+ * mission/test.lua
+ *
+ * Test world.
+]]--
+
+function onUpdate()
+ ozUIShowBuild( true )
+end
+
+function onCreate()
+ --ozOrbisSetGravity( -6.0 )
+
+ ozTerraLoad( "terra" )
+
+ ozCaelumLoad( "earth" )
+ ozCaelumSetHeading( math.pi / 8 )
+ ozCaelumSetPeriod( 3600 )
+ ozCaelumSetTime( 0 )
+ --ozCaelumSetRealTime()
+
+-- local me = ozOrbisAddPlayer( OZ_FORCE, 137, -6, 73, OZ_SOUTH )
+ --local me = ozOrbisAddPlayer( OZ_FORCE, 2000, 2002, 100, OZ_SOUTH )
+-- ozCameraAddSwitchableUnit( me )
+-- ozCameraSwitchTo( me )
+
+-- init_sample()
+
+-- ozFloraSeed()
+
+-- init_stressTest()
+end
+
+function init_sample()
+ local cX, cY, cZ = 143, 0, 79
+ --local cX, cY, cZ = 2000, 2000, 100
+
+ local lord = ozOrbisAddObj( OZ_FORCE, "bauul", cX - 5, cY - 11, cZ - 6, OZ_EAST )
+ ozBotSetName( "Jean-Claude van Damme" )
+ local memo = ozOrbisAddObj( OZ_FORCE, "datacube", cX - 9, cY - 6, cZ - 6 )
+ local droid = ozOrbisAddObj( OZ_FORCE, "droid.OOM-9", cX - 3, cY - 11, cZ - 6, OZ_WEST )
+ local cyborg = ozOrbisAddObj( OZ_FORCE, "cyborg", cX - 3, cY - 13, cZ - 6, OZ_WEST )
+ ozBotSetMind( "" )
+
+ ozNirvanaAddMemo( memo, "Simulations are like miniskirts, they show a lot but hide the " ..
+ "essentials.\n\n -- Hubert Kirrman" )
+ ozNirvanaAddMemo( lord, "Buahahahaha" )
+
+ ozCameraAddSwitchableUnit( cyborg )
+ ozCameraAddSwitchableUnit( droid )
+
+ --ozOrbisAddObj( "reaper", 145, -15, 73 )
+
+ ozOrbisAddObj( OZ_FORCE, "musicPlayer", cX - 8, cY - 4, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "galileo", cX - 7, cY - 4, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "nvGoggles", cX - 6, cY - 4, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "cvicek", cX - 8, cY - 2, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "firstAid", cX - 7, cY - 2, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "binoculars", cX - 6, cY - 2, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "droid$hyperblaster", cX - 8, cY - 3, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "droid$chaingun", cX - 7, cY - 3, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "droid$grenadeLauncher", cX - 6, cY - 3, cZ - 6 )
+
+ ozOrbisAddObj( OZ_FORCE, "key", cX + 17, cY + 3, cZ - 6 )
+
+ ozOrbisAddObj( OZ_FORCE, "raptor", cX + 12, cY - 30, cZ - 8 )
+ ozOrbisAddObj( OZ_FORCE, "hoverTank", cX + 2, cY - 30, cZ - 8 )
+
+ ozOrbisAddObj( OZ_FORCE, "metalBarrel", cX + 4, cY - 11, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "metalBarrel", cX + 4, cY - 11, cZ - 5 )
+ ozOrbisAddObj( OZ_FORCE, "metalBarrel", cX + 4, cY - 11, cZ - 3 )
+
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 11, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 11, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 11, cZ - 5 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 11, cZ - 4 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 11, cZ - 3 )
+
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 12, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 12, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 12, cZ - 5 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 12, cZ - 4 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 4, cY + 12, cZ - 3 )
+
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 11, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 11, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 11, cZ - 5 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 11, cZ - 4 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 11, cZ - 3 )
+
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 12, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 12, cZ - 6 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 12, cZ - 5 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 12, cZ - 4 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX + 5, cY + 12, cZ - 3 )
+
+ ozOrbisGenFrags( "ruins", 100, cX + 3, cY + 10, cZ, cX + 6, cY + 13, cZ, 0, 0, 2 )
+
+ ozOrbisAddObj( OZ_FORCE, "box", cX - 3, cY - 2, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "bigCrate", cX - 3, cY - 7, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "metalCrate", cX - 3, cY - 4, cZ - 7 )
+ ozOrbisAddObj( OZ_FORCE, "metalBarrel", cX - 3, cY - 5.5, cZ - 7 )
+
+ ozOrbisAddStr( OZ_FORCE, "testCastle", cX, cY, cZ, OZ_NORTH )
+ ozOrbisAddStr( OZ_FORCE, "pool", cX - 31, cY - 7, cZ - 9 )
+ ozOrbisAddStr( OZ_FORCE, "tower", cX - 37, cY - 7, cZ - 4, OZ_WEST )
+ ozOrbisAddStr( OZ_FORCE, "atlantis", cX - 303, cY + 220, cZ - 84 )
+ ozOrbisAddStr( OZ_FORCE, "house", cX - 17, cY - 30, cZ - 8.5 )
+
+ ozOrbisAddObj( OZ_FORCE, "serviceStation", cX - 33, cY - 25, cZ - 9.4, OZ_WEST )
+ ozOrbisAddObj( OZ_FORCE, "console", cX - 36, cY - 24, cZ - 11, OZ_EAST )
+
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX - 35, cY - 6, cZ + 2 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX - 35, cY - 6, cZ + 3 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX - 35, cY - 6, cZ + 4 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX - 35, cY - 8, cZ + 2 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX - 35, cY - 8, cZ + 3 )
+ ozOrbisAddObj( OZ_FORCE, "smallCrate", cX - 35, cY - 8, cZ + 4 )
+end
+
+function init_stressTest()
+ for i = 1, 0 do
+ local x = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local y = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local z = ozTerraHeight( x, y )
+
+ if z > 0 then
+ ozOrbisAddObj( OZ_TRY, "goblin", x, y, z + 0.75 )
+ end
+ end
+
+ for i = 1, 1000 do
+ local x = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local y = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local z = ozTerraHeight( x, y )
+
+ if z > 0 then
+ ozOrbisAddObj( OZ_TRY, "knight", x, y, z + 1.10 )
+ end
+ end
+
+ for i = 1, 1000 do
+ local x = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local y = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local z = ozTerraHeight( x, y )
+
+ if z > 0 then
+ ozOrbisAddObj( OZ_TRY, "beast", x, y, z + 1.10 )
+ end
+ end
+
+ for i = 1, 10000 do
+ local x = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local y = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local z = ozTerraHeight( x, y )
+
+ if z > 0 then
+ ozOrbisAddObj( OZ_TRY, "explosiveBarrel", x, y, z + 0.70 )
+ end
+ end
+
+ for i = 1, 10000 do
+ local x = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local y = -OZ_ORBIS_DIM + 2 * OZ_ORBIS_DIM * math.random()
+ local z = ozTerraHeight( x, y )
+
+ if z > 0 then
+ ozOrbisAddObj( OZ_TRY, "smallCrate", x, y, z + 0.40 )
+ end
+ end
+end
View
@@ -331,6 +331,10 @@ <h2><a name="controls" href="#">Nadzor</a></h2>
<th>F9</th>
<td>zajem zaslona</td>
</tr>
+ <tr>
+ <th>Ctrl + F9</th>
+ <td>preklopi vidnost uporabniškega vmesnika</td>
+ </tr>
<tr>
<th>F10, Esc</th>
<td>izhod v glavni meni (samo F10 na NaCl)</td>
@@ -341,7 +345,8 @@ <h2><a name="controls" href="#">Nadzor</a></h2>
</tr>
<tr>
<th>Ctrl + F11</th>
- <td>preklopi centriranje miške in vidljivost sistemskega kazalca</td>
+ <td>preklopi centriranje miške in vidljivost sistemskega kazalca (ter izključni zajem vhoda na
+ SDL 1.2)</td>
</tr>
<tr>
<th>F12</th>
View
@@ -329,19 +329,23 @@ <h2><a name="controls" href="#">Controls</a></h2>
</tr>
<tr>
<th>F9</th>
- <td>save screenshot</td>
+ <td>take screenshot</td>
+ </tr>
+ <tr>
+ <th>Ctrl + F9</th>
+ <td>toggle UI visibility</td>
</tr>
<tr>
<th>F10, Esc</th>
- <td>exit to main menu (on NaCl only F10)</td>
+ <td>exit to main menu (only F10 works on NaCl)</td>
</tr>
<tr>
<th>F11</th>
<td>toggle fullscreen mode</td>
</tr>
<tr>
<th>Ctrl + F11</th>
- <td>toggle mouse centring and system cursor visibility</td>
+ <td>toggle mouse centring and system cursor visibility (and input grab on SDL 1.2)</td>
</tr>
<tr>
<th>F12</th>
View
@@ -214,7 +214,7 @@ void Compiler::end()
case POLYGON: {
hard_assert( vertNum >= 3 );
- List<ushort> polyIndices = static_cast< List<ushort>&& >( part.indices );
+ List<ushort> polyIndices = static_cast<List<ushort>&&>( part.indices );
part.indices.clear();
int last[2] = { 0, 1 };
View
@@ -108,7 +108,7 @@ int Client::init( int argc, char** argv )
}
case 't': {
const char* end;
- benchmarkTime = String::parseFloat( optarg, &end );
+ benchmarkTime = float( String::parseDouble( optarg, &end ) );
if( end == optarg ) {
printUsage( invocationName );
@@ -200,11 +200,12 @@ int Client::init( int argc, char** argv )
if( File::mkdir( configDir ) ) {
Log::println( "Profile directory '%s' created", configDir.cstr() );
}
-
if( File::mkdir( configDir + "/saves" ) ) {
Log::println( "Directory for saved games '%s/saves' created", configDir.cstr() );
}
-
+ if( File::mkdir( configDir + "/layouts" ) ) {
+ Log::println( "Directory for layouts '%s/layouts' created", configDir.cstr() );
+ }
if( File::mkdir( configDir + "/screenshots" ) ) {
Log::println( "Directory for screenshots '%s/screenshots' created", configDir.cstr() );
}
@@ -477,7 +478,7 @@ int Client::init( int argc, char** argv )
stage = &gameStage;
}
else if( doAutoload ) {
- gameStage.stateFile = GameStage::AUTOSAVE_FILE;
+ gameStage.stateFile = gameStage.autosaveFile;
stage = &gameStage;
}
else {
@@ -561,8 +562,7 @@ void Client::shutdown()
#endif
if( initFlags & INIT_MAIN_LOOP ) {
- Alloc::printSummary();
-
+ Log::printMemorySummary();
Log::println( "OpenZone " OZ_VERSION " finished on %s", Time::local().toString().cstr() );
}
}
@@ -608,6 +608,9 @@ int Client::main()
if( !( keysym.mod & KMOD_CTRL ) ) {
loader.makeScreenshot();
}
+ else {
+ ui::ui.doShow = !ui::ui.doShow;
+ }
}
else if( keysym.sym == SDLK_F11 ) {
if( keysym.mod & KMOD_CTRL ) {
View
@@ -252,7 +252,7 @@ uint Context::requestSpeakSource( const char* text, int owner )
speakSource.isAlive = true;
speakSource.text = text;
- speakSource.thread.start( "speak", Thread::JOINABLE, speakMain, nullptr );
+ speakSource.thread.start( "speak", Thread::JOINABLE, speakMain );
return speakSource.id;
}
Oops, something went wrong.

0 comments on commit 3cf6674

Please sign in to comment.