Skip to content

Commit

Permalink
JSON layouts, Alloc chunk iterators
Browse files Browse the repository at this point in the history
- 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 3cf6674
Show file tree
Hide file tree
Showing 70 changed files with 1,433 additions and 405 deletions.
4 changes: 4 additions & 0 deletions data/oz_missions/mission/empty/description.json
@@ -0,0 +1,4 @@
{
"title": "Empty",
"description": "Empty world intended for creating new mission."
}
192 changes: 192 additions & 0 deletions data/oz_missions/mission/empty/main.lua
@@ -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
7 changes: 6 additions & 1 deletion doc/PREBERI.html
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
10 changes: 7 additions & 3 deletions doc/README.html
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/builder/Compiler.cc
Expand Up @@ -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 };
Expand Down
15 changes: 9 additions & 6 deletions src/client/Client.cc
Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() );
}
}
Expand Down Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/Context.cc
Expand Up @@ -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;
}

Expand Down

0 comments on commit 3cf6674

Please sign in to comment.