Skip to content

Commit

Permalink
UI layouts finished, next track works
Browse files Browse the repository at this point in the history
- ui
  * Area::align() calculates global (x, y)
  * layout settings finished
  * MusicPlayer: auto next track fixed
- client
  * VehicleAudio fixed
  * Sound: track can be restarted
  • Loading branch information
ducakar committed Nov 25, 2012
1 parent 63eb7c2 commit 706481d
Show file tree
Hide file tree
Showing 39 changed files with 282 additions and 349 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -118,7 +118,7 @@ if( OZ_GL_ES )
# On embedded platform GLES is part of system libraries and is guaranteed to exist in toolchain or
# platform directory, no need to explicitly check existence or to detect library names.
if( NOT PLATFORM_EMBEDDED )
pkg_check_modules( GLES2 REQUIRED gles2 )
pkg_check_modules( GLES2 REQUIRED glesv2 )
endif()
else()
find_package( OpenGL REQUIRED )
Expand Down Expand Up @@ -169,7 +169,7 @@ if( ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang )
# Use libc++ instead of libstdc++.
# set( flags "${flags} -stdlib=libc++" )
# AddressSanitizer memory checker
# set( flags "${flags} -faddress-sanitizer" )
# set( flags "${flags} -fsanitize=address" )
elseif( ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.5 )
set( flags "-pipe -std=gnu++0x" )
elseif( ANDROID )
Expand Down
3 changes: 2 additions & 1 deletion ChangeLog.md
Expand Up @@ -2,9 +2,10 @@

- ozCore
* null replaced by nullptr keyword
* global abs(), min(), max(), clamp() and hash() functions, overloaded where necessary
* container improvements
+ improved iterators: much less code duplication, no more key() and value() members
+ STL-like begin() and end() members for containers
+ STL-like begin() and end() members on containers
+ new Set template class: Map with arbitrary elements instead of key-value pairs
+ HashIndex and HashString merged into new HashMap template class with an arbitrary key type
+ new HashSet template class: hashtable of key-only elements instead of key-value pairs
Expand Down
6 changes: 3 additions & 3 deletions doc/PREBERI.html
Expand Up @@ -361,7 +361,7 @@ <h2><a name="cmdline" href="#">Ukazna vrstica</a></h2>
<tr>
<th>-v</th>
<td>
Zgovornejši dnevnik.
Izpisuj podrobna dnevniška sporočila na terminal.
</td>
</tr>
<tr>
Expand All @@ -386,8 +386,8 @@ <h2><a name="cmdline" href="#">Ukazna vrstica</a></h2>
<tr>
<th>-L &lt;jezik&gt;</th>
<td>
Nastavi jezik »&lt;jezik&gt;. Mora sovpadati s podimenikom imenika »lingua/« v podatkovnih
arhivih.
Nastavi jezik »&lt;jezik&gt;. Mora sovpadati s imenom podimenika v imeniku »lingua/« v
podatkovnih arhivih.
</td>
</tr>
<tr>
Expand Down
7 changes: 4 additions & 3 deletions doc/README.html
Expand Up @@ -361,13 +361,13 @@ <h2><a name="cmdline" href="#">Command Line</a></h2>
<tr>
<th>-v</th>
<td>
More verbose log output.
Print verbose log messages to terminal.
</td>
</tr>
<tr>
<th>-l</th>
<td>
Skip main menu and load the last autosaved state.
Skip main menu and load the last autosaved game.
</td>
</tr>
<tr>
Expand All @@ -386,7 +386,8 @@ <h2><a name="cmdline" href="#">Command Line</a></h2>
<tr>
<th>-L &lt;lang&gt;</th>
<td>
Use language &lt;lang&gt;. Should match a subdirectory of 'lingua/' directory in game data.
Use language &lt;lang&gt;. Should match a subdirectory name in 'lingua/' directory inside game
data archives.
</td>
</tr>
<tr>
Expand Down
5 changes: 3 additions & 2 deletions etc/PKGBUILD
Expand Up @@ -17,9 +17,10 @@ build()
cd "${srcdir}/${pkgbase}-${pkgver}/build"

cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_CXX_FLAGS="$CXXFLAGS -msse3 -mfpmath=sse" \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS="${CXXFLAGS/-O2} -msse3 -mfpmath=sse" \
-D CMAKE_CXX_FLAGS_RELEASE="-Ofast -flto" \
-D OZ_LUAJIT=1 \
-D OZ_NONFREE=1 \
..
Expand Down
4 changes: 2 additions & 2 deletions etc/openzone.spec
Expand Up @@ -69,10 +69,10 @@ Game data for OpenZone. Includes tutorial, test world and cviček mission.
cd build

cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_C_FLAGS="-msse3 -mfpmath=sse" \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS="-msse3 -mfpmath=sse" \
-D CMAKE_CXX_FLAGS_RELEASE="-Ofast -flto" \
..

make %{?_smp_mflags}
Expand Down
2 changes: 1 addition & 1 deletion nacl-test.sh
Expand Up @@ -20,7 +20,7 @@ for i in share/openzone/*.{7z,zip} share/openzone/packages.ozManifest \
build/NaCl-*/src/tools/openzone.*.nexe etc/nacl/openzone.nmf \
etc/nacl/openzone.??.html doc
do
[[ -e $i ]] && ln -sf $i build/NaCl-test
[[ -e $i ]] && ln -sf ../../$i build/NaCl-test
done

# Strip binaries if "strip" parameter given.
Expand Down
28 changes: 0 additions & 28 deletions src/client/Audio.cc
Expand Up @@ -41,11 +41,6 @@ void Audio::playSound( int sound, float volume, const Object* parent ) const
{
hard_assert( uint( sound ) < uint( liber.sounds.length() ) );

#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( sound );
static_cast<void>( volume );
static_cast<void>( parent );
#else
const Dynamic* dynParent = static_cast<const Dynamic*>( parent );

uint srcId = context.addSource( sound );
Expand Down Expand Up @@ -80,18 +75,12 @@ void Audio::playSound( int sound, float volume, const Object* parent ) const
alSourcePlay( srcId );

OZ_AL_CHECK_ERROR();
#endif
}

void Audio::playContSound( int sound, float volume, const Object* parent ) const
{
hard_assert( uint( sound ) < uint( liber.sounds.length() ) );

#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( sound );
static_cast<void>( volume );
static_cast<void>( parent );
#else
int key = obj->index * ObjectClass::MAX_SOUNDS + sound;

Context::ContSource* contSource = context.contSources.find( key );
Expand Down Expand Up @@ -128,16 +117,10 @@ void Audio::playContSound( int sound, float volume, const Object* parent ) const
}

OZ_AL_CHECK_ERROR();
#endif
}

bool Audio::playSpeak( const char* text, float volume, const Object* parent ) const
{
#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( text );
static_cast<void>( volume );
static_cast<void>( parent );
#else
const Dynamic* dynParent = static_cast<const Dynamic*>( parent );

if( context.speakSource.owner < 0 ) {
Expand Down Expand Up @@ -169,7 +152,6 @@ bool Audio::playSpeak( const char* text, float volume, const Object* parent ) co
}

OZ_AL_CHECK_ERROR();
#endif

return true;
}
Expand All @@ -179,11 +161,6 @@ void Audio::playEngineSound( int sound, float volume, float pitch ) const
hard_assert( uint( sound ) < uint( liber.sounds.length() ) );
hard_assert( obj->flags & Object::VEHICLE_BIT );

#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( sound );
static_cast<void>( volume );
static_cast<void>( pitch );
#else
const Vehicle* veh = static_cast<const Vehicle*>( obj );

if( !camera.isExternal && veh->pilot >= 0 && veh->pilot == camera.bot ) {
Expand Down Expand Up @@ -224,13 +201,11 @@ void Audio::playEngineSound( int sound, float volume, float pitch ) const
}

OZ_AL_CHECK_ERROR();
#endif
}

Audio::Audio( const Object* obj_ ) :
obj( obj_ ), clazz( obj_->clazz ), flags( 0 )
{
#ifndef OZ_ADDRESS_SANITIZER
const int* sounds = clazz->audioSounds;

Log::verboseMode = true;
Expand All @@ -244,12 +219,10 @@ Audio::Audio( const Object* obj_ ) :
Log::verboseMode = false;

OZ_AL_CHECK_ERROR();
#endif
}

Audio::~Audio()
{
#ifndef OZ_ADDRESS_SANITIZER
const int* sounds = clazz->audioSounds;

Log::verboseMode = true;
Expand All @@ -263,7 +236,6 @@ Audio::~Audio()
Log::verboseMode = false;

OZ_AL_CHECK_ERROR();
#endif
}

}
Expand Down
19 changes: 0 additions & 19 deletions src/client/BSPAudio.cc
Expand Up @@ -36,10 +36,6 @@ void BSPAudio::playDemolish( const Struct* str, int sound ) const
{
hard_assert( uint( sound ) < uint( liber.sounds.length() ) );

#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( str );
static_cast<void>( sound );
#else
uint srcId = context.addSource( sound );
if( srcId == Context::INVALID_SOURCE ) {
return;
Expand All @@ -53,17 +49,12 @@ void BSPAudio::playDemolish( const Struct* str, int sound ) const
alSourcePlay( srcId );

OZ_AL_CHECK_ERROR();
#endif
}

void BSPAudio::playSound( const Entity* entity, int sound ) const
{
hard_assert( uint( sound ) < uint( liber.sounds.length() ) );

#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( entity );
static_cast<void>( sound );
#else
const Struct* str = entity->str;
Point p = str->toAbsoluteCS( entity->clazz->p() + entity->offset );
Vec3 velocity = str->toAbsoluteCS( entity->velocity );
Expand All @@ -82,17 +73,12 @@ void BSPAudio::playSound( const Entity* entity, int sound ) const
alSourcePlay( srcId );

OZ_AL_CHECK_ERROR();
#endif
}

void BSPAudio::playContSound( const Entity* entity, int sound ) const
{
hard_assert( uint( sound ) < uint( liber.sounds.length() ) );

#ifdef OZ_ADDRESS_SANITIZER
static_cast<void>( entity );
static_cast<void>( sound );
#else
const Struct* str = entity->str;
int key = str->index * Struct::MAX_ENTITIES +
int( entity - str->entities.begin() );
Expand Down Expand Up @@ -122,26 +108,21 @@ void BSPAudio::playContSound( const Entity* entity, int sound ) const
}

OZ_AL_CHECK_ERROR();
#endif
}

BSPAudio::BSPAudio( const matrix::BSP* bsp_ ) :
bsp( bsp_ )
{
#ifndef OZ_ADDRESS_SANITIZER
foreach( i, bsp->sounds.citer() ) {
context.requestSound( *i );
}
#endif
}

BSPAudio::~BSPAudio()
{
#ifndef OZ_ADDRESS_SANITIZER
foreach( i, bsp->sounds.citer() ) {
context.releaseSound( *i );
}
#endif
}

void BSPAudio::play( const Struct* str ) const
Expand Down
2 changes: 1 addition & 1 deletion src/client/BasicAudio.cc
Expand Up @@ -46,7 +46,7 @@ Audio* BasicAudio::create( const Object* obj )

void BasicAudio::play( const Audio* parent )
{
const int ( & sounds )[ObjectClass::MAX_SOUNDS] = obj->clazz->audioSounds;
const auto& sounds = obj->clazz->audioSounds;

for( int i = 0; i < ObjectClass::MAX_SOUNDS; ++i ) {
recent[i] = max( recent[i] - 1, 0 );
Expand Down
6 changes: 3 additions & 3 deletions src/client/BotAudio.cc
Expand Up @@ -112,7 +112,7 @@ void BotAudio::play( const Audio* parent )
prevStep = 0;
}

// if( bot->clazz->name.equals( "bauul" ) ) {
if( bot->clazz->name.equals( "bauul" ) ) {
// playSpeak( "Gil-galad was an Elven-king.\n"
// "Of him the harpers sadly sing:\n"
// "the last whose realm was fair and free\n"
Expand All @@ -128,8 +128,8 @@ void BotAudio::play( const Audio* parent )
// "for into darkness fell his star\n"
// "in Mordor where the shadows are.\n",
// 1.0f, bot );
// playSpeak( "Booa-ha-ha-ha-ha!", 1.0f, bot );
// }
playSpeak( "Joj prejoj, kako sem žejen!", 1.0f, bot );
}
}

}
Expand Down
4 changes: 3 additions & 1 deletion src/client/BuildInfo.cc.in
Expand Up @@ -24,7 +24,7 @@ namespace oz
{

#ifdef OZ_MSVC
static const String COMPILER_STRING = "MSVC " + String::str( "%g", float( OZ_MSVC ) / 100.0f );
static const String COMPILER_STRING = String::str( "MSVC %g", float( OZ_MSVC ) / 100.0f );
#endif

const char* const BuildInfo::TIME = __DATE__ " " __TIME__;
Expand All @@ -34,6 +34,8 @@ const char* const BuildInfo::TARGET_ARCH = "@CMAKE_SYSTEM_NAME@-@CMAKE_SYSTEM_
const char* const BuildInfo::BUILD_TYPE = "@CMAKE_BUILD_TYPE@";
#if defined( OZ_MSVC )
const char* const BuildInfo::COMPILER = COMPILER_STRING;
#elif defined( OZ_OPEN64 )
const char* const BuildInfo::COMPILER = "Open64 " __OPEN64__;
#elif defined( OZ_CLANG )
const char* const BuildInfo::COMPILER = "LLVM/Clang " __clang_version__;
#else
Expand Down
2 changes: 1 addition & 1 deletion src/client/CinematicProxy.cc
Expand Up @@ -233,7 +233,7 @@ void CinematicProxy::update()
sound.stopMusic();
}
else if( step.track != -1 ) {
sound.playMusic( step.track, false );
sound.playMusic( step.track );
}

if( !step.title.isEmpty() ) {
Expand Down
15 changes: 7 additions & 8 deletions src/client/Client.cc
Expand Up @@ -41,11 +41,10 @@
#include <client/Network.hh>
#include <client/BuildInfo.hh>

#include <SDL_ttf.h>

#include <clocale>
#include <sstream>
#include <unistd.h>
#include <SDL_ttf.h>

#if defined( __native_client__ )
# include <ppapi/cpp/completion_callback.h>
Expand All @@ -62,22 +61,22 @@ namespace client

void Client::printUsage( const char* invocationName )
{

Log::printRaw(
"Usage:\n"
" %s [-v] [-l | -i <mission>] [-t <num>] [-L <lang>] [-p <prefix>]\n"
"\n"
" -v More verbose log output.\n"
" -l Skip main menu and load the last autosaved state.\n"
" -v Print verbose log messages to terminal.\n"
" -l Skip main menu and load the last autosaved game.\n"
" -i <mission> Skip main menu and start mission <mission>.\n"
" -t <num> Exit after <num> seconds (can be a floating-point number) and\n"
" use 42 as the random seed. Useful for benchmarking.\n"
" -L <lang> Use language <lang>. Should match a subdirectory of 'lingua/'\n"
" directory in game data.\n"
" -L <lang> Use language <lang>. Should match a subdirectory name in\n"
" 'lingua/' directory inside game data archives.\n"
" -p <prefix> Sets data directory to '<prefix>/share/openzone'.\n"
" Defaults to '%s'.\n"
"\n",
invocationName,
OZ_INSTALL_PREFIX );
invocationName, OZ_INSTALL_PREFIX );
}

int Client::init( int argc, char** argv )
Expand Down

0 comments on commit 706481d

Please sign in to comment.