Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5935


Ignore:
Timestamp:
Oct 13, 2009, 5:05:17 PM (15 years ago)
Author:
dafrick
Message:

Hopefully merged trunk successfully into pickup branch.

Location:
code/branches/pickup
Files:
15 deleted
281 edited
47 copied

Legend:

Unmodified
Added
Removed
  • code/branches/pickup

  • code/branches/pickup/bin/CMakeLists.txt

    r5781 r5935  
    2626
    2727# Create run scripts for Windows to manually add the DLL path when executing
    28 SET(RUN_SCRIPTS run standalone client1 client2 server dedicated)
     28SET(RUN_SCRIPTS run standalone client1 client2 server dedicated dedicatedClient)
    2929IF(WIN32)
    3030  FOREACH(_script ${RUN_SCRIPTS})
  • code/branches/pickup/bin/vld.ini.in

    r3196 r5935  
    5656;   Default: None.
    5757;
    58 ForceIncludeModules =
     58ForceIncludeModules = boost_date_time-vc80-mt-gd-1_39.dll, boost_filesystem-vc80-mt-gd-1_39.dll, boost_system-vc80-mt-gd-1_39.dll, boost_thread-vc80-mt-gd-1_39.dll, enet_d.dll, lua_d.dll, ogg_d.dll, vorbis_d.dll, vorbifile_d.dll
    5959
    6060; Maximum number of data bytes to display for each leaked block. If zero, then
     
    6666;   Default: 4294967295
    6767;
    68 MaxDataDump =
     68MaxDataDump = 0
    6969
    7070; Maximum number of call stack frames to trace back during leak detection.
  • code/branches/pickup/cmake/CompilerConfigMSVC.cmake

    r5695 r5935  
    7070
    7171# Overwrite CMake default flags here.
    72 SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -Gm -RTC1" Debug          CACHE)
    73 SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"      Release        CACHE)
    74 SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"      RelWithDebInfo CACHE)
    75 SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"      MinSizeRel     CACHE)
     72SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -MP2 -RTC1" Debug          CACHE)
     73SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG -MP2"       Release        CACHE)
     74SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG -MP2"       RelWithDebInfo CACHE)
     75SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG -MP2"       MinSizeRel     CACHE)
    7676
    7777# Use Link time code generation for Release config if ORXONOX_RELEASE is defined
  • code/branches/pickup/cmake/PackageConfig.cmake

    r5781 r5935  
    2626
    2727# Check package version info
    28 # MAJOR: Interface breaking change somewhere (library version changed, etc.)
    29 # MINOR: Bug fix or small conformant changes
    30 SET(DEPENDENCY_VERSION_REQUIRED 3)
     28# MAJOR: Breaking change
     29# MINOR: No breaking changes by the dependency package
     30#        For example any code running on 3.0 should still run on 3.1
     31#        But you can specify that the code only runs on 3.1 and higher
     32#        or 4.0 and higher (so both 3.1 and 4.0 will work).
     33SET(ALLOWED_MINIMUM_VERSIONS 3.1 4.0)
     34
    3135IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
    3236  SET(DEPENDENCY_VERSION 1.0)
     
    4448
    4549INCLUDE(CompareVersionStrings)
    46 COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${DEPENDENCY_VERSION_REQUIRED} _result TRUE)
    47 IF(NOT _result EQUAL 0)
     50SET(_version_match FALSE)
     51FOREACH(_version ${ALLOWED_MINIMUM_VERSIONS})
     52  # Get major version
     53  STRING(REGEX REPLACE "^([0-9]+)\\..*$" "\\1" _major_version "${_version}")
     54  COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_major_version} _result TRUE)
     55  IF(_result EQUAL 0)
     56    COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_version} _result FALSE)
     57    IF(NOT _result LESS 0)
     58      SET(_version_match TRUE)
     59    ENDIF()
     60  ENDIF()
     61ENDFOREACH(_version)
     62IF(NOT _version_match)
    4863  MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n"
    49           "Required version: ${DEPENDENCY_VERSION_REQUIRED}\n"
    50           "You can get a new version from www.orxonox.net")
     64          "Possible required versions: ${ALLOWED_MINIMUM_VERSIONS}\n"
     65          "You can get a new version from www.orxonox.net")
    5166ENDIF()
    5267
  • code/branches/pickup/cmake/ParseMacroArguments.cmake

    r5695 r5935  
    3939  # Using LIST(FIND ...) speeds up the process
    4040  SET(_keywords ${_switches} ${_list_names})
     41
     42  # Reset all arguments
     43  FOREACH(_arg ${_switches} ${_list_names})
     44    SET(_arg_${_arg})
     45  ENDFOREACH(_arg)
    4146
    4247  # Parse all the arguments and set the corresponding variable
  • code/branches/pickup/cmake/PrecompiledHeaderFiles.cmake

    r3251 r5935  
    110110    GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags)
    111111    # Make sure we recompile the pch file even if only the flags change
    112     IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}")
     112    IF(NOT "${_pch_gcc_flags}" STREQUAL "${_INTERNAL_${_target_name}_PCH_GCC_FLAGS}" OR NOT EXISTS "${_pch_dep_helper_file}")
    113113      SET(_INTERNAL_${_target_name}_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "")
    114114      FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */")
  • code/branches/pickup/cmake/SourceFileUtilities.cmake

    r2710 r5935  
    2424 #    [ADD/SET]_SOURCE_FILES - Writes source files to the cache by force and
    2525 #                             adds the current directory.
    26  #    GET_ALL_HEADER_FILES - Finds all header files recursively.
     26 #                             Also compiles multiple source files into a single
     27 #                             one by including them
     28 #                             Use COMPILATION_[BEGIN|END] in
     29 #                             [ADD|SET]_SOURCE_FILES and specify the name of
     30 #                             the new source file after COMPILATION_BEGIN
     31 #    GET_ALL_HEADER_FILES   - Finds all header files recursively.
    2732 #    GENERATE_SOURCE_GROUPS - Set Visual Studio source groups.
    2833 #
    2934
     35FUNCTION(PREPARE_SOURCE_FILES)
     36  SET(_fullpath_sources)
     37  FOREACH(_file ${ARGN})
     38    IF(_file STREQUAL "COMPILATION_BEGIN")
     39      SET(_compile TRUE)
     40      # Next file is the name of the compilation
     41      SET(_get_name TRUE)
     42    ELSEIF(_get_name)
     43      SET(_get_name FALSE)
     44      SET(_compilation_name ${_file})
     45    ELSEIF(_file STREQUAL "COMPILATION_END")
     46      IF(NOT _compilation_name)
     47        MESSAGE(FATAL_ERROR "No name provided for source file compilation")
     48      ENDIF()
     49      IF(NOT DISABLE_COMPILATIONS)
     50        SET(_include_string)
     51        FOREACH(_file2 ${_compilation})
     52          SET(_include_string "${_include_string}#include \"${_file2}\"\n")
     53        ENDFOREACH(_file2)
     54        IF(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name})
     55          FILE(READ ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name} _include_string_file)
     56        ENDIF()
     57        IF(NOT _include_string STREQUAL "${_include_string_file}")
     58          FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name} "${_include_string}")
     59        ENDIF()
     60        LIST(APPEND _fullpath_sources ${CMAKE_CURRENT_BINARY_DIR}/${_compilation_name})
     61      ENDIF()
     62      SET(_compilation_name)
     63      SET(_compilation)
     64      SET(_compile FALSE)
     65    ELSE()
     66      # Prefix the full path
     67      GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
     68      LIST(APPEND _fullpath_sources ${_filepath})
     69      IF(_compile AND NOT DISABLE_COMPILATIONS)
     70        LIST(APPEND _compilation ${_filepath})
     71        LIST(APPEND _fullpath_sources "H")
     72      ENDIF()
     73    ENDIF()
     74  ENDFOREACH(_file)
     75  SET(_fullpath_sources ${_fullpath_sources} PARENT_SCOPE)
     76ENDFUNCTION(PREPARE_SOURCE_FILES)
     77
     78
    3079# Adds source files with the full path to a list
    3180FUNCTION(ADD_SOURCE_FILES _varname)
    32   # Prefix the full path
    33   SET(_fullpath_sources)
    34   FOREACH(_file ${ARGN})
    35     GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
    36     LIST(APPEND _fullpath_sources ${_filepath})
    37   ENDFOREACH(_file)
     81  PREPARE_SOURCE_FILES(${ARGN})
    3882  # Write into the cache to avoid variable scoping in subdirs
    3983  SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
     
    4387# Sets source files with the full path
    4488FUNCTION(SET_SOURCE_FILES _varname)
    45   # Prefix the full path
    46   SET(_fullpath_sources)
    47   FOREACH(_file ${ARGN})
    48     GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
    49     LIST(APPEND _fullpath_sources ${_filepath})
    50   ENDFOREACH(_file)
     89  PREPARE_SOURCE_FILES(${ARGN})
    5190  # Write into the cache to avoid variable scoping in subdirs
    5291  SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
     
    66105    GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION)
    67106    FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath})
    68     GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
    69     STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
    70     SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
     107    IF(NOT _relative_path MATCHES "^\\.\\.")
     108      GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
     109      STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
     110      SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
     111    ELSE()
     112      # Has to be a compilation
     113      SOURCE_GROUP("Compilations" FILES ${_file})
     114    ENDIF()
    71115  ENDFOREACH(_file)
    72116
  • code/branches/pickup/cmake/TargetUtilities.cmake

    r5695 r5935  
    6767ENDIF()
    6868
    69 FUNCTION(ORXONOX_ADD_LIBRARY _target_name)
     69MACRO(ORXONOX_ADD_LIBRARY _target_name)
    7070  TU_ADD_TARGET(${_target_name} LIBRARY "STATIC;SHARED" ${ARGN})
    71 ENDFUNCTION(ORXONOX_ADD_LIBRARY)
    72 
    73 FUNCTION(ORXONOX_ADD_EXECUTABLE _target_name)
     71ENDMACRO(ORXONOX_ADD_LIBRARY)
     72
     73MACRO(ORXONOX_ADD_EXECUTABLE _target_name)
    7474  TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN})
    75 ENDFUNCTION(ORXONOX_ADD_EXECUTABLE)
    76 
    77 
    78 FUNCTION(TU_ADD_TARGET _target_name _target_type _additional_switches)
     75ENDMACRO(ORXONOX_ADD_EXECUTABLE)
     76
     77
     78MACRO(TU_ADD_TARGET _target_name _target_type _additional_switches)
    7979  CAPITALISE_NAME(${_target_name} _target_name_capitalised)
    8080
     
    8888
    8989
    90   # GET_HEADER_FILES
     90  # Workaround: Source file properties get lost when leaving a subdirectory
     91  # Therefore an "H" after a file means we have to set it as HEADER_FILE_ONLY
     92  FOREACH(_file ${_arg_SOURCE_FILES})
     93    IF(_file STREQUAL "H")
     94      SET_SOURCE_FILES_PROPERTIES(${_last_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     95    ELSE()
     96      SET(_last_file ${_file})
     97      LIST(APPEND _${_target_name}_source_files ${_file})
     98    ENDIF()
     99  ENDFOREACH(_file)
     100
     101  # Assemble all header files of the library
    91102  IF(_arg_FIND_HEADER_FILES)
    92     GET_ALL_HEADER_FILES(_${target_name}_header_files)
     103    GET_ALL_HEADER_FILES(_${_target_name}_header_files)
    93104  ENDIF()
    94105
    95106  # Remove potential duplicates
    96   SET(_${_target_name}_files ${_${target_name}_header_files} ${_arg_SOURCE_FILES})
     107  SET(_${_target_name}_files ${_${_target_name}_header_files} ${_${_target_name}_source_files})
    97108  LIST(REMOVE_DUPLICATES _${_target_name}_files)
    98109
     
    141152  ENDIF()
    142153
     154  # No warnings needed from third party libraries
     155  IF(_arg_ORXONOX_EXTERNAL)
     156    REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
     157    ADD_COMPILER_FLAGS("-w")
     158  ENDIF()
     159
    143160  # Set default linking if required
    144161  IF(NOT _arg_SHARED AND NOT _arg_STATIC)
     
    156173    SET(_arg_STATIC)
    157174  ENDIF()
     175
     176  # Don't compile header files
     177  FOREACH(_file ${_${_target_name}_files})
     178    IF(NOT _file MATCHES "\\.(c|cc|cpp)")
     179      SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
     180    ENDIF()
     181  ENDFOREACH(_file)
    158182
    159183  # Add the library/executable
     
    164188    ADD_EXECUTABLE(${_target_name} ${_arg_WIN32} ${_arg_EXCLUDE_FROM_ALL}
    165189                   ${_${_target_name}_files})
     190  ENDIF()
     191
     192  # Change library prefix to "lib"
     193  IF(MSVC AND ${_target_type} STREQUAL "LIBRARY")
     194    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
     195      PREFIX "lib"
     196    )
    166197  ENDIF()
    167198
     
    216247  ENDIF()
    217248
    218 ENDFUNCTION(TU_ADD_TARGET)
     249ENDMACRO(TU_ADD_TARGET)
    219250
    220251
  • code/branches/pickup/data/defaultConfig/keybindings.ini

    r5781 r5935  
    2525KeyEscape="exit"
    2626KeyF="scale -1 moveUpDown"
    27 KeyF1=
     27KeyF1="OverlayGroup toggleVisibility Debug"
    2828KeyF10=
    2929KeyF11=
     
    4141KeyF9=
    4242KeyG=greet
    43 KeyGrave=
     43KeyGrave="openConsole"
    4444KeyH=
    45 KeyHome=showGUI
     45KeyHome=
    4646KeyI=
    4747KeyInsert=
     
    126126KeyU=
    127127KeyUP="scale 1 moveFrontBack"
    128 KeyUnassigned=
     128KeyUnassigned="openConsole"
    129129KeyUnderline=
    130130KeyUnlabeled=
  • code/branches/pickup/data/levels/old/physicstest2.oxw

    r5781 r5935  
    243243    <!--EventDispatcher>
    244244      <targets>
    245         <EventTarget name=fireright />
    246         <EventTarget name=firecenter />
    247         <EventTarget name=fireleft />
     245        <EventTarget target=fireright />
     246        <EventTarget target=firecenter />
     247        <EventTarget target=fireleft />
    248248      </targets>
    249249      <events>
  • code/branches/pickup/data/levels/old/princessaeryn.oxw

    r5781 r5935  
    264264            <EventDispatcher>
    265265                <targets>
    266                     <EventTarget name=trail />
     266                    <EventTarget target=trail />
    267267                </targets>
    268268                <events>
  • code/branches/pickup/data/levels/old/sample4.oxw

    r5781 r5935  
    123123    <EventDispatcher>
    124124      <targets>
    125         <EventTarget name=fireright />
    126         <EventTarget name=firecenter />
    127         <EventTarget name=fireleft />
     125        <EventTarget target=fireright />
     126        <EventTarget target=firecenter />
     127        <EventTarget target=fireleft />
    128128      </targets>
    129129      <events>
  • code/branches/pickup/data/levels/presentation.oxw

    r5781 r5935  
    151151    <EventDispatcher>
    152152      <targets>
    153         <EventTarget name=fireright />
    154         <EventTarget name=firecenter />
    155         <EventTarget name=fireleft />
     153        <EventTarget target=fireright />
     154        <EventTarget target=firecenter />
     155        <EventTarget target=fireleft />
    156156      </targets>
    157157      <events>
  • code/branches/pickup/data/levels/presentation09b.oxw

    r5781 r5935  
    111111    <EventDispatcher>
    112112      <targets>
    113         <EventTarget name=pirates />
     113        <EventTarget target=pirates />
    114114      </targets>
    115115      <events>
     
    163163    <EventDispatcher>
    164164      <targets>
    165         <EventTarget name=attacker />
     165        <EventTarget target=attacker />
    166166      </targets>
    167167      <events>
  • code/branches/pickup/data/levels/presentation_pong.oxw

    r5781 r5935  
    3232      <Backlight scale=0.2 colour="1.0, 1.0, 0.5" width=7 length=500 lifetime=0.3 elements=20 trailmaterial="Trail/backlighttrail" material="Examples/Flare" />
    3333      <Light type=point diffuse="1.0, 1.0, 0.5" specular="1.0, 1.0, 0.5" attenuation="1200, 1.0, 0.0035, 0.00005" />
    34     </attached>
     34      <ParticleSpawner name=hiteffect position="0,0,0" source="Orxonox/sparks2" lifetime=0.01 autostart=0 mainstate=spawn />
     35    </attached>
     36    <eventlisteners>
     37      <EventTarget target=hiteffect />
     38    </eventlisteners>
    3539  </PongBall>
    3640</Template>
     
    4246 gametype     = Pong
    4347>
     48  <AmbientSound source="ambient/mainmenu.wav" playOnLoad=true />
     49
    4450  <Scene
    4551   ambientlight = "0.5, 0.5, 0.5"
     
    5864  <MovableEntity rotationrate=5 rotationaxis="0,0,1">
    5965    <attached>
    60       <PongCenterpoint name=pongcenter dimension="200,120" balltemplate=pongball battemplate=pongbat ballspeed=200 batspeed=130 batlength=0.25>
     66      <PongCenterpoint name=pongcenter dimension="200,120" balltemplate=pongball battemplate=pongbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25>
    6167        <attached>
    6268          <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" />
    6369          <Model position="0,0,-60" mesh="cube.mesh" scale3D="105,1,1" />
    64 <!--
    65           <ParticleSpawner name=scoreeffect_R position=" 100,0, 60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    66           <ParticleSpawner name=scoreeffect position="  50,0, 60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    67           <ParticleSpawner name=scoreeffect position="   0,0, 60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    68           <ParticleSpawner name=scoreeffect position=" -50,0, 60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    69           <ParticleSpawner name=scoreeffect_L position="-100,0, 60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    70           <ParticleSpawner name=scoreeffect_R position=" 100,0,-60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    71           <ParticleSpawner name=scoreeffect position="  50,0,-60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    72           <ParticleSpawner name=scoreeffect position="   0,0,-60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    73           <ParticleSpawner name=scoreeffect position=" -50,0,-60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    74           <ParticleSpawner name=scoreeffect_L position="-100,0,-60" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 />
    75 -->
     70
     71          <ParticleSpawner name=scoreeffect_right position="120,0, 45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     72          <ParticleSpawner name=scoreeffect_right position="120,0, 30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
     73          <ParticleSpawner name=scoreeffect_right position="120,0, 15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     74          <ParticleSpawner name=scoreeffect_right position="120,0,  0" source="Orxonox/BigExplosion1part2" lifetime=0.1 autostart=0 />
     75          <ParticleSpawner name=scoreeffect_right position="120,0,-15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     76          <ParticleSpawner name=scoreeffect_right position="120,0,-30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
     77          <ParticleSpawner name=scoreeffect_right position="120,0,-45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     78
     79          <ParticleSpawner name=scoreeffect_left position="-120,0, 45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     80          <ParticleSpawner name=scoreeffect_left position="-120,0, 30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
     81          <ParticleSpawner name=scoreeffect_left position="-120,0, 15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     82          <ParticleSpawner name=scoreeffect_left position="-120,0,  0" source="Orxonox/BigExplosion1part2" lifetime=0.1 autostart=0 />
     83          <ParticleSpawner name=scoreeffect_left position="-120,0,-15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     84          <ParticleSpawner name=scoreeffect_left position="-120,0,-30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
     85          <ParticleSpawner name=scoreeffect_left position="-120,0,-45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
     86
     87          <WorldSound name="scoreSound" position="0,0,0" source="sounds/pong_score.wav" >
     88            <events>
     89              <play>
     90                <EventListener event=pongcenter />
     91              </play>
     92            </events>
     93          </WorldSound>
     94
     95<?lua
     96for i = 1, 15, 1
     97do ?>
     98          <ParticleSpawner name=scoreeffect_center position="<?lua print(math.random() * 200 - 100) ?>,0,<?lua print(math.random() * 120 - 60) ?>" source="Orxonox/sparks2" lifetime=0.02 autostart=0 startdelay=<?lua print(math.random() * 0.7) ?> />
     99<?lua
     100end
     101?>
     102
    76103        </attached>
    77104      </PongCenterpoint>
     
    81108  <EventDispatcher>
    82109    <targets>
    83       <EventTarget name=scoreeffect />
     110      <EventTarget target=scoreeffect_right />
     111      <EventTarget target=scoreeffect_center />
    84112    </targets>
    85113    <events>
    86114      <spawn>
    87         <EventListener event=pongcenter />
     115        <EventFilter>
     116          <names>
     117            <EventName name=right />
     118          </names>
     119          <EventListener event=pongcenter />
     120        </EventFilter>
     121      </spawn>
     122    </events>
     123  </EventDispatcher>
     124  <EventDispatcher>
     125    <targets>
     126      <EventTarget target=scoreeffect_left />
     127      <EventTarget target=scoreeffect_center />
     128    </targets>
     129    <events>
     130      <spawn>
     131        <EventFilter>
     132          <names>
     133            <EventName name=left />
     134          </names>
     135          <EventListener event=pongcenter />
     136        </EventFilter>
    88137      </spawn>
    89138    </events>
  • code/branches/pickup/data/levels/princessaeryn.oxw

    r5781 r5935  
    66
    77<?lua
    8         dofile("../../media/levels/includes/CuboidSpaceStation.lua")
     8        dofile("includes/CuboidSpaceStation.lua")
    99?>
    1010
     
    227227            <EventDispatcher>
    228228                <targets>
    229                     <EventTarget name=trail />
     229                    <EventTarget target=trail />
    230230                </targets>
    231231                <events>
  • code/branches/pickup/data/particle/ExplosionComp1.particle

    r5781 r5935  
    4141                repeat_delay_max        2.5
    4242                width           20
    43                 hight           20
     43                height          20
    4444                depth           0
    4545        }
  • code/branches/pickup/src/Orxonox.cc

    r5752 r5935  
    6363        for (int i = 1; i < argc; ++i)
    6464            strCmdLine += argv[i] + std::string(" ");
     65#endif
    6566
    6667        return orxonox::main(strCmdLine);
    67 #endif
    6868    }
    6969    catch (...)
  • code/branches/pickup/src/OrxonoxConfig.cmake

    r5695 r5935  
    3838  OPTION(PCH_ENABLE "Global PCH switch" TRUE)
    3939ENDIF()
     40
     41# Global switch to disable multiple file compilations
     42OPTION(DISABLE_COMPILATIONS "Global multi-file compilation switch" FALSE)
    4043
    4144# Use WinMain() or main()?
  • code/branches/pickup/src/external/bullet/BulletCollision/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(BULLET_FILES
     2
     3COMPILATION_BEGIN BulletCollisionCompilation.cpp
     4
    25        BroadphaseCollision/btAxisSweep3.cpp
    36        BroadphaseCollision/btBroadphaseProxy.cpp
     
    6871        Gimpact/btContactProcessing.cpp
    6972        Gimpact/btGImpactShape.cpp
    70         Gimpact/gim_contact.cpp
    7173        Gimpact/btGImpactBvh.cpp
    7274        Gimpact/btGenericPoolAllocator.cpp
    73         Gimpact/gim_memory.cpp
    7475        Gimpact/btGImpactCollisionAlgorithm.cpp
    7576        Gimpact/btTriangleShapeEx.cpp
    76         Gimpact/gim_tri_collision.cpp
    7777        Gimpact/btGImpactQuantizedBvh.cpp
    78         Gimpact/gim_box_set.cpp
    7978
    8079        NarrowPhaseCollision/btContinuousConvexCollision.cpp
     
    8988        NarrowPhaseCollision/btSubSimplexConvexCast.cpp
    9089        NarrowPhaseCollision/btVoronoiSimplexSolver.cpp
     90
     91COMPILATION_END
     92
     93COMPILATION_BEGIN BulletGImpactCompilation.cpp
     94        Gimpact/gim_contact.cpp
     95        Gimpact/gim_memory.cpp
     96        Gimpact/gim_tri_collision.cpp
     97        Gimpact/gim_box_set.cpp
     98COMPILATION_END
    9199
    92100        # Headers
  • code/branches/pickup/src/external/bullet/BulletDynamics/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(BULLET_FILES
     2
     3COMPILATION_BEGIN BulletDynamicsCompilation.cpp
     4
    25        ConstraintSolver/btContactConstraint.cpp
    36        ConstraintSolver/btConeTwistConstraint.cpp
     
    1922
    2023        Character/btKinematicCharacterController.cpp
     24
     25COMPILATION_END
    2126
    2227        # Headers
  • code/branches/pickup/src/external/bullet/CMakeLists.txt

    r5781 r5935  
    2727ADD_SUBDIRECTORY(LinearMath)
    2828
    29 # No warnings needed from third party libraries
    30 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    31 ADD_COMPILER_FLAGS("-w")
    32 
    3329ORXONOX_ADD_LIBRARY(bullet_orxonox
    3430  ORXONOX_EXTERNAL
    3531  NO_DLL_INTERFACE
    36   PCH_FILE
    37     BulletPrecompiledHeaders.h
    3832  VERSION
    3933    2.74
  • code/branches/pickup/src/external/bullet/LinearMath/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(BULLET_FILES
     2
     3COMPILATION_BEGIN BulletLinearMathCompilation.cpp
    24                btConvexHull.cpp
    35                btQuickprof.cpp
    46                btGeometryUtil.cpp
    57                btAlignedAllocator.cpp
     8COMPILATION_END
    69
    710                # Headers
  • code/branches/pickup/src/external/ceguilua/CMakeLists.txt

    r5781 r5935  
    6767)
    6868
    69 # No warnings needed from third party libraries
    70 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    71 ADD_COMPILER_FLAGS("-w")
    72 
    7369SOURCE_GROUP("Source" FILES ${CEGUILUA_FILES})
    7470
  • code/branches/pickup/src/external/cpptcl/CMakeLists.txt

    r5781 r5935  
    3232)
    3333
    34 # No warnings needed from third party libraries
    35 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    36 ADD_COMPILER_FLAGS("-w")
    37 
    3834ORXONOX_ADD_LIBRARY(cpptcl_orxonox
    3935  ORXONOX_EXTERNAL
  • code/branches/pickup/src/external/ogreceguirenderer/CMakeLists.txt

    r5781 r5935  
    1818 #
    1919
    20 SET(OCR_FILES
     20SET_SOURCE_FILES(OCR_FILES
    2121  OgreCEGUIRenderer.h
    2222  OgreCEGUIResourceProvider.h
    2323  OgreCEGUITexture.h
    2424
     25COMPILATION_BEGIN OgreCEGUIRendererCompilation.cpp
    2526  OgreCEGUIRenderer.cpp
    2627  OgreCEGUIResourceProvider.cpp
    2728  OgreCEGUITexture.cpp
     29COMPILATION_END
    2830)
    29 
    30 # No warnings needed from third party libraries
    31 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    32 ADD_COMPILER_FLAGS("-w")
    3331
    3432ORXONOX_ADD_LIBRARY(ogreceguirenderer_orxonox
  • code/branches/pickup/src/external/ois/CMakeLists.txt

    r5781 r5935  
    3434  OISPrereqs.h
    3535
     36COMPILATION_BEGIN OISCompilation.cpp
    3637  OISEffect.cpp
    3738  OISException.cpp
     
    4142  OISKeyboard.cpp
    4243  OISObject.cpp
     44COMPILATION_END
    4345)
    4446IF(WIN32)
     
    4951  ADD_SUBDIRECTORY(linux)
    5052ENDIF()
    51 
    52 # No warnings needed from third party libraries
    53 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    54 ADD_COMPILER_FLAGS("-w")
    5553
    5654INCLUDE_DIRECTORIES(.)
  • code/branches/pickup/src/external/ois/changes_orxonox.diff

    r5781 r5935  
    2323 
    2424
     25--- win32/Win32ForceFeedback.cpp
     26+++ win32/Win32ForceFeedback.cpp
     27@@ -25,7 +25,7 @@
     28 #include <Math.h>
     29 
     30 // 0 = No trace; 1 = Important traces; 2 = Debug traces
     31-#define OIS_WIN32_JOYFF_DEBUG 1
     32+#define OIS_WIN32_JOYFF_DEBUG 0
     33 
     34 #if (defined (_DEBUG) || defined(OIS_WIN32_JOYFF_DEBUG))
     35   #include <iostream>
  • code/branches/pickup/src/external/ois/linux/CMakeLists.txt

    r5781 r5935  
    88  LinuxPrereqs.h
    99
     10COMPILATION_BEGIN OISLinuxCompilation.cpp
    1011  EventHelpers.cpp
    1112  LinuxForceFeedback.cpp
     
    1415  LinuxKeyboard.cpp
    1516  LinuxMouse.cpp
     17COMPILATION_END
    1618)
  • code/branches/pickup/src/external/ois/mac/CMakeLists.txt

    r5781 r5935  
    77  MacPrereqs.h
    88
     9COMPILATION_BEGIN OISMacCompilation.cpp
    910  MacHelpers.cpp
    1011  MacHIDManager.cpp
     
    1213  MacKeyboard.cpp
    1314  MacMouse.cpp
     15COMPILATION_END
    1416)
  • code/branches/pickup/src/external/ois/win32/CMakeLists.txt

    r5781 r5935  
    77  Win32Prereqs.h
    88
     9COMPILATION_BEGIN OISWin32Compilation.cpp
    910  Win32ForceFeedback.cpp
    1011  Win32InputManager.cpp
     
    1213  Win32KeyBoard.cpp
    1314  Win32Mouse.cpp
     15COMPILATION_END
    1416)
  • code/branches/pickup/src/external/ois/win32/Win32ForceFeedback.cpp

    r5781 r5935  
    2626
    2727// 0 = No trace; 1 = Important traces; 2 = Debug traces
    28 #define OIS_WIN32_JOYFF_DEBUG 1
     28#define OIS_WIN32_JOYFF_DEBUG 0
    2929
    3030#if (defined (_DEBUG) || defined(OIS_WIN32_JOYFF_DEBUG))
  • code/branches/pickup/src/external/tinyxml/CMakeLists.txt

    r5781 r5935  
    1818 #
    1919
    20 SET(TINYXML++_FILES
     20SET_SOURCE_FILES(TINYXML++_FILES
    2121  ticpp.h
    2222  ticpprc.h
     
    2424  tinyxml.h
    2525
     26COMPILATION_BEGIN TicppCompilation.cpp
    2627  ticpp.cpp
    2728  tinystr.cpp
     
    2930  tinyxmlerror.cpp
    3031  tinyxmlparser.cpp
     32COMPILATION_END
    3133)
    32 
    33 # No warnings needed from third party libraries
    34 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    35 ADD_COMPILER_FLAGS("-w")
    3634
    3735ORXONOX_ADD_LIBRARY(tinyxml++_orxonox
  • code/branches/pickup/src/external/tolua/CMakeLists.txt

    r5738 r5935  
    2020################### Tolua++ library ###################
    2121
    22 SET(TOLUA++_FILES
     22SET_SOURCE_FILES(TOLUA++_FILES
    2323  tolua_event.h
    2424  tolua++.h
    25 
     25COMPILATION_BEGIN ToluaCompilation.c
    2626  tolua_event.c
    2727  tolua_is.c
     
    2929  tolua_push.c
    3030  tolua_to.c
     31COMPILATION_END
    3132)
    32 GENERATE_SOURCE_GROUPS(${TOLUA++_FILES})
    33 
    34 # No warnings needed from third party libraries
    35 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)
    36 ADD_COMPILER_FLAGS("-w")
    3733
    3834ORXONOX_ADD_LIBRARY(tolua++_orxonox
  • code/branches/pickup/src/libraries/CMakeLists.txt

    r5781 r5935  
    2525################ Sub Directories ################
    2626
     27ADD_SUBDIRECTORY(util)
    2728ADD_SUBDIRECTORY(core)
    2829ADD_SUBDIRECTORY(network)
    2930ADD_SUBDIRECTORY(tools)
    30 ADD_SUBDIRECTORY(util)
  • code/branches/pickup/src/libraries/core/ArgumentCompletionFunctions.cc

    r5781 r5935  
    100100            ArgumentCompletionList classlist;
    101101
    102             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
     102            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    103103                if ((*it).second->hasConfigValues())
    104104                    classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
     
    110110        {
    111111            ArgumentCompletionList configvalues;
    112             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getIdentifierMap().find(classname);
     112            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getStringIdentifierMap().find(classname);
    113113
    114             if (identifier != Identifier::getIdentifierMapEnd() && (*identifier).second->hasConfigValues())
     114            if (identifier != Identifier::getStringIdentifierMapEnd() && (*identifier).second->hasConfigValues())
    115115            {
    116116                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it)
     
    124124        {
    125125            ArgumentCompletionList oldvalue;
    126             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    127             if (identifier != Identifier::getLowercaseIdentifierMapEnd())
     126            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     127            if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    128128            {
    129129                std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
  • code/branches/pickup/src/libraries/core/BaseObject.cc

    r5781 r5935  
    6363        this->bVisible_ = true;
    6464        this->oldGametype_ = 0;
     65        this->bRegisteredEventStates_ = false;
    6566
    6667        this->lastLoadedXMLElement_ = 0;
    6768
    68         this->functorSetMainState_ = 0;
    69         this->functorGetMainState_ = 0;
     69        this->mainStateFunctor_ = 0;
    7070
    7171        this->setCreator(creator);
     
    7474            this->setFile(this->creator_->getFile());
    7575            this->setNamespace(this->creator_->getNamespace());
    76             this->setScene(this->creator_->getScene());
     76            this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
    7777            this->setGametype(this->creator_->getGametype());
    7878        }
     
    8282            this->namespace_ = 0;
    8383            this->scene_ = 0;
     84            this->sceneID_ = OBJECTID_UNKNOWN;
    8485            this->gametype_ = 0;
    8586        }
     
    9394        if (this->isInitialized())
    9495        {
    95             for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
    96                 (*it)->unregisterEventListener(this);
    97 
    98             for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    99                 it->first->removeEvent(this);
    100 
    101             if (this->functorSetMainState_)
    102                 delete this->functorSetMainState_;
    103             if (this->functorGetMainState_)
    104                 delete this->functorGetMainState_;
     96            for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); )
     97                this->removeEventSource((it++)->first);
     98
     99            for (std::set<BaseObject*>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); )
     100                (*(it++))->removeEventSource(this);
     101
     102            for (std::map<std::string, EventState*>::const_iterator it = this->eventStates_.begin(); it != this->eventStates_.end(); ++it)
     103                delete it->second;
    105104        }
    106105    }
     
    110109        @param xmlelement The XML-element
    111110        @param loading Loading (true) or saving (false)
    112         @return The XML-element
    113111    */
    114112    void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    120118
    121119        XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
    122 
    123         Element* events = xmlelement.FirstChildElement("events", false);
    124 
     120        XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode);
     121       
     122        Element* events = 0;
     123        if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
     124            events = xmlelement.FirstChildElement("events", false);
     125        else if (mode == XMLPort::SaveObject)
     126            {}
    125127        if (events)
    126         {
    127             std::list<std::string> eventnames;
    128 
    129             if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
    130             {
    131                 for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)
    132                     eventnames.push_back(child->Value());
    133             }
    134             else if (mode == XMLPort::SaveObject)
    135             {
    136                 for (std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->getIdentifier()->getXMLPortEventMapBegin(); it != this->getIdentifier()->getXMLPortEventMapEnd(); ++it)
    137                     eventnames.push_back(it->first);
    138             }
    139 
    140             for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
    141             {
    142                 std::string sectionname = (*it);
    143                 ExecutorMember<BaseObject>* loadexecutor = createExecutor(createFunctor(&BaseObject::addEvent), std::string( "BaseObject" ) + "::" + "addEvent");
    144                 ExecutorMember<BaseObject>* saveexecutor = createExecutor(createFunctor(&BaseObject::getEvent), std::string( "BaseObject" ) + "::" + "getEvent");
    145                 loadexecutor->setDefaultValue(1, sectionname);
    146 
    147                 XMLPortClassObjectContainer<BaseObject, BaseObject>* container = 0;
    148                 container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(this->getIdentifier()->getXMLPortEventContainer(sectionname));
    149                 if (!container)
    150                 {
    151                     container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(sectionname, this->getIdentifier(), loadexecutor, saveexecutor, false, true);
    152                     this->getIdentifier()->addXMLPortEventContainer(sectionname, container);
    153                 }
    154                 container->port(this, *events, mode);
    155             }
    156         }
     128            this->XMLEventPort(*events, mode);
     129    }
     130
     131    /**
     132        @brief Defines the possible event states of this object and parses eventsources from an XML file.
     133        @param xmlelement The XML-element
     134        @param loading Loading (true) or saving (false)
     135    */
     136    void BaseObject::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     137    {
     138        XMLPortEventState(BaseObject, BaseObject, "activity", setActive, xmlelement, mode);
     139        XMLPortEventState(BaseObject, BaseObject, "visibility", setVisible, xmlelement, mode);
     140        XMLPortEventState(BaseObject, BaseObject, "mainstate", setMainState, xmlelement, mode);
     141       
     142        this->bRegisteredEventStates_ = true;
    157143    }
    158144
     
    220206    }
    221207
    222     void BaseObject::addEvent(BaseObject* event, const std::string& sectionname)
    223     {
    224         event->registerEventListener(this, sectionname);
    225         this->events_.push_back(event);
    226     }
    227 
    228     void BaseObject::removeEvent(BaseObject* event)
    229     {
    230         this->events_.remove(event);
    231     }
    232 
    233     BaseObject* BaseObject::getEvent(unsigned int index) const
     208    /**
     209        @brief Adds a new event source for a specific state.
     210        @param source The object which sends events to this object
     211        @param state The state of this object which will be affected by the events
     212    */
     213    void BaseObject::addEventSource(BaseObject* source, const std::string& state)
     214    {
     215        this->eventSources_[source] = state;
     216        source->registerEventListener(this);
     217    }
     218
     219    /**
     220        @brief Removes an eventsource (but doesn't unregister itself at the source).
     221    */
     222    void BaseObject::removeEventSource(BaseObject* source)
     223    {
     224        this->eventSources_.erase(source);
     225        source->unregisterEventListener(this);
     226    }
     227
     228    /**
     229        @brief Returns an eventsource with a given index.
     230    */
     231    BaseObject* BaseObject::getEventSource(unsigned int index, const std::string& state) const
    234232    {
    235233        unsigned int i = 0;
    236         for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
    237         {
     234        for (std::map<BaseObject*, std::string>::const_iterator it = this->eventSources_.begin(); it != this->eventSources_.end(); ++it)
     235        {
     236            if (it->second != state)
     237                continue;
     238           
    238239            if (i == index)
    239                 return (*it);
     240                return it->first;
    240241            ++i;
    241242        }
     
    243244    }
    244245
    245     void BaseObject::addEventContainer(const std::string& sectionname, EventContainer* container)
    246     {
    247         std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);
    248         if (it != this->eventContainers_.end())
    249         {
    250             COUT(2) << "Warning: Overwriting EventContainer in class " << this->getIdentifier()->getName() << "." << std::endl;
     246    /**
     247        @brief Adds an object which listens to the events of this object. The events are sent to the other objects mainstate.
     248    */
     249    void BaseObject::addEventListener(BaseObject* listener)
     250    {
     251        this->eventListenersXML_.insert(listener);
     252        listener->addEventSource(this, "mainstate");
     253    }
     254   
     255    /**
     256        @brief Returns an event listener with a given index.
     257    */
     258    BaseObject* BaseObject::getEventListener(unsigned int index) const
     259    {
     260        unsigned int i = 0;
     261        for (std::set<BaseObject*>::const_iterator it = this->eventListenersXML_.begin(); it != this->eventListenersXML_.end(); ++it)
     262        {
     263            if (i == index)
     264                return *it;
     265            ++i;
     266        }
     267        return 0;
     268    }
     269
     270    /**
     271        @brief Adds a new event-state to the object. Event-states are states which can be changed by events.
     272        @param name  The name of the event
     273        @param state The object containing information about the event-state
     274    */
     275    void BaseObject::addEventState(const std::string& name, EventState* state)
     276    {
     277        std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name);
     278        if (it != this->eventStates_.end())
     279        {
     280            COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << "." << std::endl;
    251281            delete (it->second);
    252282        }
    253283
    254         this->eventContainers_[sectionname] = container;
    255     }
    256 
    257     EventContainer* BaseObject::getEventContainer(const std::string& sectionname) const
    258     {
    259         std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);
    260         if (it != this->eventContainers_.end())
     284        this->eventStates_[name] = state;
     285    }
     286
     287    /**
     288        @brief Returns the event-state with the given name.
     289    */
     290    EventState* BaseObject::getEventState(const std::string& name) const
     291    {
     292        std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name);
     293        if (it != this->eventStates_.end())
    261294            return ((*it).second);
    262295        else
     
    264297    }
    265298
    266     void BaseObject::fireEvent()
    267     {
    268         this->fireEvent(true);
    269         this->fireEvent(false);
    270     }
    271 
    272     void BaseObject::fireEvent(bool activate)
    273     {
    274         this->fireEvent(activate, this);
    275     }
    276 
    277     void BaseObject::fireEvent(bool activate, BaseObject* originator)
    278     {
    279         Event event(activate, originator);
    280 
    281         for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    282         {
    283             event.sectionname_ = it->second;
    284             it->first->processEvent(event);
    285         }
    286     }
    287 
     299    /**
     300        @brief Fires an event (without a state).
     301    */
     302    void BaseObject::fireEvent(const std::string& name)
     303    {
     304        this->fireEvent(true, name);
     305        this->fireEvent(false, name);
     306    }
     307
     308    /**
     309        @brief Fires an event which activates or deactivates a state.
     310    */
     311    void BaseObject::fireEvent(bool activate, const std::string& name)
     312    {
     313        this->fireEvent(activate, this, name);
     314    }
     315
     316    /**
     317        @brief Fires an event which activates or deactivates a state with agiven originator (the object which triggered the event).
     318    */
     319    void BaseObject::fireEvent(bool activate, BaseObject* originator, const std::string& name)
     320    {
     321        Event event(activate, originator, name);
     322
     323        for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     324        {
     325            event.statename_ = (*it)->eventSources_[this];
     326            (*it)->processEvent(event);
     327        }
     328    }
     329
     330    /**
     331        @brief Fires an event, using the Event struct.
     332    */
    288333    void BaseObject::fireEvent(Event& event)
    289334    {
    290         for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    291             it->first->processEvent(event);
    292     }
    293 
     335        for (std::set<BaseObject*>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     336            (*it)->processEvent(event);
     337    }
     338
     339    /**
     340        @brief Processing an event by calling the right main state.
     341        @param event The event struct which contains the information about the event
     342    */
    294343    void BaseObject::processEvent(Event& event)
    295344    {
    296         ORXONOX_SET_EVENT(BaseObject, "activity", setActive, event);
    297         ORXONOX_SET_EVENT(BaseObject, "visibility", setVisible, event);
    298     }
    299 
    300     void BaseObject::setMainStateName(const std::string& name)
    301     {
    302         if (this->mainStateName_ != name)
    303         {
    304             this->mainStateName_ = name;
    305             if (this->functorSetMainState_)
    306                 delete this->functorSetMainState_;
    307             if (this->functorGetMainState_)
    308                 delete this->functorGetMainState_;
    309             this->changedMainState();
    310             if (!this->functorSetMainState_)
    311                 COUT(2) << "Warning: \"" << name << "\" is not a valid MainState." << std::endl;
    312         }
    313     }
    314 
     345        this->registerEventStates();
     346       
     347        std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(event.statename_);
     348        if (it != this->eventStates_.end())
     349            it->second->process(event, this);
     350        else if (event.statename_ != "")
     351            COUT(2) << "Warning: \"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
     352        else
     353            COUT(2) << "Warning: Event with invalid source sent to object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
     354    }
     355
     356    /**
     357        @brief Sets the main state of the object to a given boolean value.
     358       
     359        Note: The main state of an object can be set with the @ref setMainStateName function.
     360        It's part of the eventsystem and used for event forwarding (when the target object can't specify a specific state,
     361        the main state is used by default).
     362    */
    315363    void BaseObject::setMainState(bool state)
    316364    {
    317         if (this->functorSetMainState_)
    318             (*this->functorSetMainState_)(state);
     365        if (this->mainStateFunctor_)
     366        {
     367            if (this->mainStateFunctor_->getParamCount() == 0)
     368            {
     369                if (state)
     370                    (*this->mainStateFunctor_)();
     371            }
     372            else
     373            {
     374                (*this->mainStateFunctor_)(state);
     375            }
     376        }
    319377        else
    320378            COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;
    321379    }
    322380
    323     bool BaseObject::getMainState() const
    324     {
    325         if (this->functorGetMainState_)
    326         {
    327             (*this->functorGetMainState_)();
    328             return this->functorGetMainState_->getReturnvalue();
    329         }
    330         else
    331         {
    332             COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;
    333             return false;
    334         }
    335     }
    336 
    337     void BaseObject::changedMainState()
    338     {
    339         SetMainState(BaseObject, "activity",   setActive,  isActive);
    340         SetMainState(BaseObject, "visibility", setVisible, isVisible);
     381    /**
     382        @brief This function gets called if the main state name of the object changes.
     383    */
     384    void BaseObject::changedMainStateName()
     385    {
     386        this->mainStateFunctor_ = 0;
     387
     388        if (this->mainStateName_ != "")
     389        {
     390            this->registerEventStates();
     391           
     392            std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(this->mainStateName_);
     393            if (it != this->eventStates_.end() && it->second->getFunctor())
     394            {
     395                if (it->second->getFunctor()->getParamCount() <= 1)
     396                    this->mainStateFunctor_ = it->second->getFunctor();
     397                else
     398                    COUT(2) << "Warning: Can't use \"" << this->mainStateName_ << "\" as MainState because it needs a second argument." << std::endl;
     399            }
     400            else
     401                COUT(2) << "Warning: \"" << this->mainStateName_ << "\" is not a valid MainState." << std::endl;
     402        }
     403    }
     404   
     405    /**
     406        @brief Calls XMLEventPort with an empty XML-element to register the event states if necessary.
     407    */
     408    void BaseObject::registerEventStates()
     409    {
     410        if (!this->bRegisteredEventStates_)
     411        {
     412            Element xmlelement;
     413            this->XMLEventPort(xmlelement, XMLPort::NOP);
     414        }
     415    }
     416   
     417    /**
     418        @brief Manually loads all event states, even if the class doesn't officially support them. This is needed by some classes like @ref EventDispatcher or @ref EventTarget.
     419    */
     420    void BaseObject::loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier)
     421    {
     422        Element* events = xmlelement.FirstChildElement("events", false);
     423        if (events)
     424        {
     425            // get the list of all states present
     426            std::list<std::string> eventnames;
     427            if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
     428            {
     429                for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)
     430                    eventnames.push_back(child->Value());
     431            }
     432            else if (mode == XMLPort::SaveObject)
     433            {
     434            }
     435
     436            // iterate through all states and get the event sources
     437            for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)
     438            {
     439                std::string statename = (*it);
     440
     441                // if the event state is already known, continue with the next state
     442                orxonox::EventState* eventstate = object->getEventState(statename);
     443                if (eventstate)
     444                    continue;
     445
     446                XMLPortClassObjectContainer<BaseObject, BaseObject>* container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(identifier->getXMLPortObjectContainer(statename));
     447                if (!container)
     448                {
     449                    ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + "(" + statename + ")");
     450                    ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + "(" + statename + ")");
     451                    setfunctor->setDefaultValue(1, statename);
     452                    getfunctor->setDefaultValue(1, statename);
     453
     454                    container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(statename, identifier, setfunctor, getfunctor, false, true);
     455                    identifier->addXMLPortObjectContainer(statename, container);
     456                }
     457                container->port(object, *events, mode);
     458            }
     459        }
    341460    }
    342461}
  • code/branches/pickup/src/libraries/core/BaseObject.h

    r5781 r5935  
    3737#define _BaseObject_H__
    3838
    39 #define SetMainState(classname, statename, setfunction, getfunction) \
    40     if (this->getMainStateName() == statename) \
    41     { \
    42         this->functorSetMainState_ = createFunctor(&classname::setfunction)->setObject(this); \
    43         this->functorGetMainState_ = createFunctor(&classname::getfunction)->setObject(this); \
    44     }
    45 
    46 
    4739#include "CorePrereqs.h"
    4840
     
    5345#include "OrxonoxClass.h"
    5446#include "Super.h"
     47#include "SmartPtr.h"
    5548
    5649namespace orxonox
     
    6861            virtual ~BaseObject();
    6962            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     63            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    7064
    7165            /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */
     
    110104
    111105            void setMainState(bool state);
    112             bool getMainState() const;
    113 
    114             void setMainStateName(const std::string& name);
     106
     107            /** @brief Sets the name of the main state (used for event reactions). */
     108            void setMainStateName(const std::string& name)
     109            {
     110                if (this->mainStateName_ != name)
     111                {
     112                    this->mainStateName_ = name;
     113                    this->changedMainStateName();
     114                }
     115            }
     116            /** @brief Returns the name of the main state. */
    115117            inline const std::string& getMainStateName() const { return this->mainStateName_; }
    116             virtual void changedMainState();
     118            /** @brief This function gets called if the main state name of the object changes. */
     119            virtual void changedMainStateName();
    117120
    118121            /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */
     
    134137            inline BaseObject* getCreator() const { return this->creator_; }
    135138
    136             inline void setScene(Scene* scene) { this->scene_ = scene; }
    137             inline Scene* getScene() const { return this->scene_; }
    138 
    139             inline void setGametype(Gametype* gametype)
     139            inline void setScene(const SmartPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }
     140            inline const SmartPtr<Scene>& getScene() const { return this->scene_; }
     141            inline virtual uint32_t getSceneID() const { return this->sceneID_; }
     142
     143            inline void setGametype(const SmartPtr<Gametype>& gametype)
    140144            {
    141145                if (gametype != this->gametype_)
     
    146150                }
    147151            }
    148             inline Gametype* getGametype() const { return this->gametype_; }
     152            inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; }
    149153            inline Gametype* getOldGametype() const { return this->oldGametype_; }
    150154            virtual void changedGametype() {}
    151155
    152             void fireEvent();
    153             void fireEvent(bool activate);
    154             void fireEvent(bool activate, BaseObject* originator);
     156            void addEventSource(BaseObject* source, const std::string& state);
     157            void removeEventSource(BaseObject* source);
     158            BaseObject* getEventSource(unsigned int index, const std::string& state) const;
     159           
     160            void addEventListener(BaseObject* listener);
     161            BaseObject* getEventListener(unsigned int index) const;
     162
     163            void fireEvent(const std::string& name = "");
     164            void fireEvent(bool activate, const std::string& name = "");
     165            void fireEvent(bool activate, BaseObject* originator, const std::string& name = "");
    155166            void fireEvent(Event& event);
    156167
    157168            virtual void processEvent(Event& event);
    158 
    159             inline void registerEventListener(BaseObject* object, const std::string& sectionname)
    160                 { this->eventListeners_[object] = sectionname; }
    161             inline void unregisterEventListener(BaseObject* object)
    162                 { this->eventListeners_.erase(object); }
    163 
    164             void addEvent(BaseObject* event, const std::string& sectionname);
    165             void removeEvent(BaseObject* event);
    166             BaseObject* getEvent(unsigned int index) const;
    167 
    168             void addEventContainer(const std::string& sectionname, EventContainer* container);
    169             EventContainer* getEventContainer(const std::string& sectionname) const;
    170169
    171170            /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */
     
    173172            /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */
    174173            inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
     174           
     175            static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier);
    175176
    176177        protected:
     178            void addEventState(const std::string& name, EventState* container);
     179            EventState* getEventState(const std::string& name) const;
     180
    177181            std::string name_;                                 //!< The name of the object
    178182            std::string oldName_;                              //!< The old name of the object
     
    180184            mbool       bVisible_;                             //!< True = the object is visible
    181185            std::string mainStateName_;
    182             Functor*    functorSetMainState_;
    183             Functor*    functorGetMainState_;
     186            Functor*    mainStateFunctor_;
    184187
    185188        private:
     189            /** @brief Adds an object which listens to the events of this object. */
     190            inline void registerEventListener(BaseObject* object)
     191                { this->eventListeners_.insert(object); }
     192            /** @brief Removes an event listener from this object. */
     193            inline void unregisterEventListener(BaseObject* object)
     194                { this->eventListeners_.erase(object); }
     195
    186196            void setXMLName(const std::string& name);
    187197            Template* getTemplate(unsigned int index) const;
     198            void registerEventStates();
    188199
    189200            bool                   bInitialized_;              //!< True if the object was initialized (passed the object registration)
     
    194205            Namespace*             namespace_;
    195206            BaseObject*            creator_;
    196             Scene*                 scene_;
    197             Gametype*              gametype_;
     207            SmartPtr<Scene>        scene_;
     208            uint32_t               sceneID_;
     209            SmartPtr<Gametype>     gametype_;
    198210            Gametype*              oldGametype_;
    199211            std::set<Template*>    templates_;
    200             std::map<BaseObject*,  std::string> eventListeners_;
    201             std::list<BaseObject*> events_;
    202             std::map<std::string, EventContainer*> eventContainers_;
     212           
     213            std::map<BaseObject*, std::string>  eventSources_;           //!< List of objects which send events to this object, mapped to the state which they affect
     214            std::set<BaseObject*>               eventListeners_;         //!< List of objects which listen to the events of this object
     215            std::set<BaseObject*>               eventListenersXML_;      //!< List of objects which listen to the events of this object through the "eventlisteners" subsection in XML
     216            std::map<std::string, EventState*>  eventStates_;            //!< Maps the name of the event states to their helper objects
     217            bool                                bRegisteredEventStates_; //!< Becomes true after the object registered its event states (with XMLEventPort)
    203218    };
    204219
     
    206221    SUPER_FUNCTION(2, BaseObject, changedActivity, false);
    207222    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
    208     SUPER_FUNCTION(4, BaseObject, processEvent, false);
    209     SUPER_FUNCTION(6, BaseObject, changedMainState, false);
    210     SUPER_FUNCTION(9, BaseObject, changedName, false);
    211     SUPER_FUNCTION(10, BaseObject, changedGametype, false);
     223    SUPER_FUNCTION(4, BaseObject, XMLEventPort, false);
     224    SUPER_FUNCTION(8, BaseObject, changedName, false);
     225    SUPER_FUNCTION(9, BaseObject, changedGametype, false);
    212226}
    213227
  • code/branches/pickup/src/libraries/core/CMakeLists.txt

    r5781 r5935  
    1919
    2020SET_SOURCE_FILES(CORE_SRC_FILES
    21   Clock.cc
    22   ConfigFileManager.cc
    2321  ConfigValueContainer.cc
    2422  Core.cc
     
    3331  Language.cc
    3432  LuaState.cc
    35   MemoryArchive.cc
    3633  ObjectListBase.cc
    3734  OrxonoxClass.cc
    3835  Resource.cc
     36  ScopedSingletonManager.cc
    3937  WindowEventListener.cc
    4038
    4139  # command
    42   ArgumentCompletionFunctions.cc
    4340  CommandEvaluation.cc
    4441  CommandExecutor.cc
     
    4946
    5047  # hierarchy
    51   Factory.cc
    5248  Identifier.cc
    5349  MetaObjectList.cc
     
    6763  Shell.cc
    6864  TclBind.cc
     65
     66COMPILATION_BEGIN FilesystemCompilation.cc
     67  ArgumentCompletionFunctions.cc
     68  ConfigFileManager.cc
     69  MemoryArchive.cc
     70  PathConfig.cc
     71COMPILATION_END
     72
     73  # multithreading
     74  ThreadPool.cc
     75COMPILATION_BEGIN ThreadCompilation.cc
    6976  TclThreadManager.cc
    70  
    71   # multithreading
    7277  Thread.cc
    73   ThreadPool.cc
     78COMPILATION_END
    7479)
     80
    7581ADD_SUBDIRECTORY(input)
    7682
  • code/branches/pickup/src/libraries/core/ClassFactory.h

    r5781 r5935  
    4242
    4343#include "util/Debug.h"
    44 #include "Factory.h"
    4544#include "Identifier.h"
    4645
    4746namespace orxonox
    4847{
     48    // ###########################
     49    // ###       Factory       ###
     50    // ###########################
     51    //! Base-class of ClassFactory.
     52    class _CoreExport Factory
     53    {
     54        public:
     55            virtual ~Factory() {};
     56            virtual BaseObject* fabricate(BaseObject* creator) = 0;
     57    };
     58
    4959    // ###############################
    5060    // ###      ClassFactory       ###
     
    5262    //! The ClassFactory is able to create new objects of a specific class.
    5363    template <class T>
    54     class ClassFactory : public BaseFactory
     64    class ClassFactory : public Factory
    5565    {
    5666        public:
    57             static bool create(const std::string& name, bool bLoadable = true);
    58             BaseObject* fabricate(BaseObject* creator);
     67            /**
     68                @brief Constructor: Adds the ClassFactory to the Identifier of the same type.
     69                @param name The name of the class
     70                @param bLoadable True if the class can be loaded through XML
     71            */
     72            ClassFactory(const std::string& name, bool bLoadable = true)
     73            {
     74                COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
     75                ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
     76                ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
     77            }
    5978
    60         private:
    61             ClassFactory() {}                               // Don't create
    62             ClassFactory(const ClassFactory& factory) {}    // Don't copy
    63             virtual ~ClassFactory() {}                      // Don't delete
    64 
    65             static T* createNewObject(BaseObject* creator);
     79            /**
     80                @brief Creates and returns a new object of class T.
     81                @return The new object
     82            */
     83            inline BaseObject* fabricate(BaseObject* creator)
     84            {
     85                return static_cast<BaseObject*>(new T(creator));
     86            }
    6687    };
    67 
    68     /**
    69         @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
    70         @param name The name of the class
    71         @param bLoadable True if the class can be loaded through XML
    72         @return Always true (this is needed because the compiler only allows assignments before main())
    73     */
    74     template <class T>
    75     bool ClassFactory<T>::create(const std::string& name, bool bLoadable)
    76     {
    77         COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
    78         ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
    79         ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    80         Factory::add(name, ClassIdentifier<T>::getIdentifier());
    81 
    82         return true;
    83     }
    84 
    85     /**
    86         @brief Creates and returns a new object of class T.
    87         @return The new object
    88     */
    89     template <class T>
    90     inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
    91     {
    92         return ClassFactory<T>::createNewObject(creator);
    93     }
    94 
    95     /**
    96         @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
    97         @return The new object
    98     */
    99     template <class T>
    100     inline T* ClassFactory<T>::createNewObject(BaseObject* creator)
    101     {
    102         return new T(creator);
    103     }
    10488}
    10589
  • code/branches/pickup/src/libraries/core/ClassTreeMask.cc

    r5781 r5935  
    488488
    489489                // Remove the redundant subnode from the current node
     490                delete (*it);
    490491                node->subnodes_.erase(it++);
    491492            }
  • code/branches/pickup/src/libraries/core/ClassTreeMask.h

    r5781 r5935  
    265265
    266266            /** @brief Returns true if the ClassTreeMaskObjectIterator points at the given object. @param pointer The pointer of the object */
    267             inline bool operator==(BaseObject* pointer) const { return ((*this->objectIterator_) == pointer); }
     267            inline bool operator==(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) == pointer) || (!this->objectIterator_ && pointer == 0); }
    268268            /** @brief Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. @param pointer The pointer of the object */
    269             inline bool operator!=(BaseObject* pointer) const { return ((*this->objectIterator_) != pointer); }
     269            inline bool operator!=(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) != pointer) || (!this->objectIterator_ && pointer != 0); }
    270270            /** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */
    271271            inline operator bool() const { return (this->objectIterator_); }
  • code/branches/pickup/src/libraries/core/CommandExecutor.cc

    r5781 r5935  
    468468        CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
    469469        std::string lowercase = getLowercase(fragment);
    470         for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)
     470        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it)
    471471            if ((*it).second->hasConsoleCommands())
    472472                if ((*it).first.find(lowercase) == 0 || fragment == "")
     
    516516    {
    517517        std::string lowercase = getLowercase(name);
    518         std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMap().find(lowercase);
    519         if ((it != Identifier::getLowercaseIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
     518        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase);
     519        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
    520520            return (*it).second;
    521521
  • code/branches/pickup/src/libraries/core/CommandLine.cc

    r5738 r5935  
    3131#include <algorithm>
    3232#include <sstream>
    33 #include <boost/filesystem.hpp>
    3433
    3534#include "util/Convert.h"
     
    3837#include "util/StringUtils.h"
    3938#include "util/SubString.h"
    40 #include "Core.h"
     39#include "PathConfig.h"
    4140
    4241namespace orxonox
     
    285284        }
    286285
     286        infoStr << std::endl;
    287287        infoStr << "Usage: orxonox [options]" << std::endl;
    288288        infoStr << "Available options:" << std::endl;
     
    348348    {
    349349        std::string filename = CommandLine::getValue("optionsFile").getString();
    350         boost::filesystem::path filepath(Core::getConfigPath() / filename);
    351350
    352351        // look for additional arguments in given file or start.ini as default
    353352        // They will not overwrite the arguments given directly
    354353        std::ifstream file;
    355         file.open(filepath.string().c_str());
     354        file.open((PathConfig::getConfigPathString() + filename).c_str());
    356355        std::vector<std::string> args;
    357356        if (file)
  • code/branches/pickup/src/libraries/core/ConfigFileManager.cc

    r5781 r5935  
    3636#include "ConsoleCommand.h"
    3737#include "ConfigValueContainer.h"
    38 #include "Core.h"
     38#include "PathConfig.h"
    3939
    4040namespace orxonox
     
    4848    bool config(const std::string& classname, const std::string& varname, const std::string& value)
    4949    {
    50         std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    51         if (identifier != Identifier::getLowercaseIdentifierMapEnd())
     50        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     51        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    5252        {
    5353            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
     
    6060    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
    6161    {
    62         std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    63         if (identifier != Identifier::getLowercaseIdentifierMapEnd())
     62        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     63        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    6464        {
    6565            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
     
    222222
    223223        // Get default file if necessary and available
    224         boost::filesystem::path filepath(Core::getConfigPath() / this->filename_);
     224        boost::filesystem::path filepath(PathConfig::getConfigPath() / this->filename_);
    225225        if (!boost::filesystem::exists(filepath))
    226226        {
    227227            // Try to get default one from the data folder
    228             boost::filesystem::path defaultFilepath(Core::getDataPath() / "defaultConfig" / this->filename_);
     228            boost::filesystem::path defaultFilepath(PathConfig::getDataPath() / "defaultConfig" / this->filename_);
    229229            if (boost::filesystem::exists(defaultFilepath))
    230230            {
     
    336336    {
    337337        std::ofstream file;
    338         file.open((Core::getConfigPathString() + filename_).c_str(), std::fstream::out);
     338        file.open((PathConfig::getConfigPathString() + filename_).c_str(), std::fstream::out);
    339339        file.setf(std::ios::fixed, std::ios::floatfield);
    340340        file.precision(6);
     
    376376        for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
    377377        {
    378             std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getIdentifierMap().find((*it1)->getName());
    379             if (it2 != Identifier::getIdentifierMapEnd() && (*it2).second->hasConfigValues())
     378            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
     379            if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues())
    380380            {
    381381                // The section exists, delete comment
     
    455455        if (this->type_ == ConfigFileType::Settings)
    456456        {
    457             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
     457            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    458458            {
    459459                if (it->second->hasConfigValues())
  • code/branches/pickup/src/libraries/core/Core.cc

    r5781 r5935  
    3737
    3838#include <cassert>
    39 #include <fstream>
    40 #include <cstdlib>
    41 #include <cstdio>
    42 #include <boost/version.hpp>
    43 #include <boost/filesystem.hpp>
     39#include <vector>
    4440
    4541#ifdef ORXONOX_PLATFORM_WINDOWS
     
    5046#  undef min
    5147#  undef max
    52 #elif defined(ORXONOX_PLATFORM_APPLE)
    53 #  include <sys/param.h>
    54 #  include <mach-o/dyld.h>
    55 #else /* Linux */
    56 #  include <sys/types.h>
    57 #  include <unistd.h>
    5848#endif
    5949
    60 #include "SpecialConfig.h"
     50#include "util/Clock.h"
    6151#include "util/Debug.h"
    6252#include "util/Exception.h"
    6353#include "util/SignalHandler.h"
    64 #include "Clock.h"
     54#include "PathConfig.h"
    6555#include "CommandExecutor.h"
    6656#include "CommandLine.h"
     
    6959#include "CoreIncludes.h"
    7060#include "DynLibManager.h"
    71 #include "Factory.h"
    7261#include "GameMode.h"
    7362#include "GraphicsManager.h"
     
    7665#include "Language.h"
    7766#include "LuaState.h"
     67#include "ScopedSingletonManager.h"
    7868#include "Shell.h"
    7969#include "TclBind.h"
     
    8171#include "input/InputManager.h"
    8272
    83 // Boost 1.36 has some issues with deprecated functions that have been omitted
    84 #if (BOOST_VERSION == 103600)
    85 #  define BOOST_LEAF_FUNCTION filename
    86 #else
    87 #  define BOOST_LEAF_FUNCTION leaf
    88 #endif
    89 
    9073namespace orxonox
    9174{
     
    9376    Core* Core::singletonPtr_s  = 0;
    9477
    95     SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
    96     SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
    9778    SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
    9879#ifdef ORXONOX_PLATFORM_WINDOWS
     
    11798            RegisterRootObject(CoreConfiguration);
    11899            this->setConfigValues();
    119 
    120             // External data directory only exists for dev runs
    121             if (Core::isDevelopmentRun())
    122             {
    123                 // Possible data path override by the command line
    124                 if (!CommandLine::getArgument("externalDataPath")->hasDefaultValue())
    125                     tsetExternalDataPath(CommandLine::getValue("externalDataPath"));
    126             }
    127100        }
    128101
     
    194167        }
    195168
    196         /**
    197         @brief
    198             Temporary sets the external data path
    199         @param path
    200             The new data path
    201         */
    202         void tsetExternalDataPath(const std::string& path)
    203         {
    204             externalDataPath_ = boost::filesystem::path(path);
    205         }
    206 
    207169        void initializeRandomNumberGenerator()
    208170        {
     
    222184        std::string language_;                          //!< The language
    223185        bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    224 
    225         //! Path to the parent directory of the ones above if program was installed with relativ pahts
    226         boost::filesystem::path rootPath_;
    227         boost::filesystem::path executablePath_;        //!< Path to the executable
    228         boost::filesystem::path modulePath_;            //!< Path to the modules
    229         boost::filesystem::path dataPath_;              //!< Path to the data file folder
    230         boost::filesystem::path externalDataPath_;      //!< Path to the external data file folder
    231         boost::filesystem::path configPath_;            //!< Path to the config file folder
    232         boost::filesystem::path logPath_;               //!< Path to the log file folder
    233186    };
    234187
     
    240193        , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)
    241194        , configuration_(new CoreConfiguration()) // Don't yet create config values!
    242         , bDevRun_(false)
    243195        , bGraphicsLoaded_(false)
    244196    {
    245197        // Set the hard coded fixed paths
    246         this->setFixedPaths();
     198        this->pathConfig_.reset(new PathConfig());
    247199
    248200        // Create a new dynamic library manager
     
    250202
    251203        // Load modules
    252         try
    253         {
    254             // We search for helper files with the following extension
    255             std::string moduleextension = specialConfig::moduleExtension;
    256             size_t moduleextensionlength = moduleextension.size();
    257 
    258             // Search in the directory of our executable
    259             boost::filesystem::path searchpath = this->configuration_->modulePath_;
    260 
    261             // Add that path to the PATH variable in case a module depends on another one
    262             std::string pathVariable = getenv("PATH");
    263             putenv(const_cast<char*>(("PATH=" + pathVariable + ";" + configuration_->modulePath_.string()).c_str()));
    264 
    265             boost::filesystem::directory_iterator file(searchpath);
    266             boost::filesystem::directory_iterator end;
    267 
    268             // Iterate through all files
    269             while (file != end)
     204        const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();
     205        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
     206        {
     207            try
    270208            {
    271                 std::string filename = file->BOOST_LEAF_FUNCTION();
    272 
    273                 // Check if the file ends with the exension in question
    274                 if (filename.size() > moduleextensionlength)
    275                 {
    276                     if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
    277                     {
    278                         // We've found a helper file - now load the library with the same name
    279                         std::string library = filename.substr(0, filename.size() - moduleextensionlength);
    280                         boost::filesystem::path librarypath = searchpath / library;
    281 
    282                         try
    283                         {
    284                             DynLibManager::getInstance().load(librarypath.string());
    285                         }
    286                         catch (...)
    287                         {
    288                             COUT(1) << "Couldn't load module \"" << librarypath.string() << "\": " << Exception::handleMessage() << std::endl;
    289                         }
    290                     }
    291                 }
    292 
    293                 ++file;
     209                this->dynLibManager_->load(*it);
    294210            }
    295         }
    296         catch (...)
    297         {
    298             COUT(1) << "An error occurred while loading modules: " << Exception::handleMessage() << std::endl;
     211            catch (...)
     212            {
     213                COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;
     214            }
    299215        }
    300216
     
    303219
    304220        // Set configurable paths like log, config and media
    305         this->setConfigurablePaths();
     221        this->pathConfig_->setConfigurablePaths();
    306222
    307223        // create a signal handler (only active for linux)
    308224        // This call is placed as soon as possible, but after the directories are set
    309225        this->signalHandler_.reset(new SignalHandler());
    310         this->signalHandler_->doCatch(configuration_->executablePath_.string(), Core::getLogPathString() + "orxonox_crash.log");
     226        this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");
    311227
    312228        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
    313         OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
     229        OutputHandler::getOutStream().setLogPath(PathConfig::getLogPathString());
    314230
    315231        // Parse additional options file now that we know its path
     
    334250
    335251        // creates the class hierarchy for all classes with factories
    336         Factory::createClassHierarchy();
     252        Identifier::createClassHierarchy();
    337253
    338254        // Do this soon after the ConfigFileManager has been created to open up the
     
    344260
    345261        // initialise Tcl
    346         this->tclBind_.reset(new TclBind(Core::getDataPathString()));
     262        this->tclBind_.reset(new TclBind(PathConfig::getDataPathString()));
    347263        this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));
    348264
    349265        // create a shell
    350266        this->shell_.reset(new Shell());
     267
     268        // Create singletons that always exist (in other libraries)
     269        this->rootScope_.reset(new Scope<ScopeID::Root>());
    351270    }
    352271
     
    370289        inputManager_.reset(new InputManager());
    371290
    372         // load the CEGUI interface
     291        // Load the CEGUI interface
    373292        guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(),
    374293            inputManager_->getMousePosition(), graphicsManager_->isFullScreen()));
    375294
     295        bGraphicsLoaded_ = true;
     296        GameMode::bShowsGraphics_s = true;
     297
     298        // Load some sort of a debug overlay (only denoted by its name, "debug.oxo")
     299        graphicsManager_->loadDebugOverlay();
     300
     301        // Create singletons associated with graphics (in other libraries)
     302        graphicsScope_.reset(new Scope<ScopeID::Graphics>());
     303
    376304        unloader.Dismiss();
    377 
    378         bGraphicsLoaded_ = true;
    379305    }
    380306
    381307    void Core::unloadGraphics()
    382308    {
    383         this->guiManager_.reset();;
    384         this->inputManager_.reset();;
     309        this->graphicsScope_.reset();
     310        this->guiManager_.reset();
     311        this->inputManager_.reset();
    385312        this->graphicsManager_.reset();
    386313
     
    397324
    398325        bGraphicsLoaded_ = false;
     326        GameMode::bShowsGraphics_s = false;
    399327    }
    400328
     
    457385    }
    458386
    459     /*static*/ void Core::tsetExternalDataPath(const std::string& path)
    460     {
    461         getInstance().configuration_->tsetExternalDataPath(path);
    462     }
    463 
    464     /*static*/ const boost::filesystem::path& Core::getDataPath()
    465     {
    466         return getInstance().configuration_->dataPath_;
    467     }
    468     /*static*/ std::string Core::getDataPathString()
    469     {
    470         return getInstance().configuration_->dataPath_.string() + '/';
    471     }
    472 
    473     /*static*/ const boost::filesystem::path& Core::getExternalDataPath()
    474     {
    475         return getInstance().configuration_->externalDataPath_;
    476     }
    477     /*static*/ std::string Core::getExternalDataPathString()
    478     {
    479         return getInstance().configuration_->externalDataPath_.string() + '/';
    480     }
    481 
    482     /*static*/ const boost::filesystem::path& Core::getConfigPath()
    483     {
    484         return getInstance().configuration_->configPath_;
    485     }
    486     /*static*/ std::string Core::getConfigPathString()
    487     {
    488         return getInstance().configuration_->configPath_.string() + '/';
    489     }
    490 
    491     /*static*/ const boost::filesystem::path& Core::getLogPath()
    492     {
    493         return getInstance().configuration_->logPath_;
    494     }
    495     /*static*/ std::string Core::getLogPathString()
    496     {
    497         return getInstance().configuration_->logPath_.string() + '/';
    498     }
    499 
    500     /*static*/ const boost::filesystem::path& Core::getRootPath()
    501     {
    502         return getInstance().configuration_->rootPath_;
    503     }
    504     /*static*/ std::string Core::getRootPathString()
    505     {
    506         return getInstance().configuration_->rootPath_.string() + '/';
    507     }
    508 
    509387    /**
    510388    @note
     
    553431    }
    554432
    555     /**
    556     @brief
    557         Retrievs the executable path and sets all hard coded fixed path (currently only the module path)
    558         Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
    559         If found it means that this is not an installed run, hence we
    560         don't write the logs and config files to ~/.orxonox
    561     @throw
    562         GeneralException
    563     */
    564     void Core::setFixedPaths()
    565     {
    566         //////////////////////////
    567         // FIND EXECUTABLE PATH //
    568         //////////////////////////
    569 
    570 #ifdef ORXONOX_PLATFORM_WINDOWS
    571         // get executable module
    572         TCHAR buffer[1024];
    573         if (GetModuleFileName(NULL, buffer, 1024) == 0)
    574             ThrowException(General, "Could not retrieve executable path.");
    575 
    576 #elif defined(ORXONOX_PLATFORM_APPLE)
    577         char buffer[1024];
    578         unsigned long path_len = 1023;
    579         if (_NSGetExecutablePath(buffer, &path_len))
    580             ThrowException(General, "Could not retrieve executable path.");
    581 
    582 #else /* Linux */
    583         /* written by Nicolai Haehnle <prefect_@gmx.net> */
    584 
    585         /* Get our PID and build the name of the link in /proc */
    586         char linkname[64]; /* /proc/<pid>/exe */
    587         if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
    588         {
    589             /* This should only happen on large word systems. I'm not sure
    590                what the proper response is here.
    591                Since it really is an assert-like condition, aborting the
    592                program seems to be in order. */
    593             assert(false);
    594         }
    595 
    596         /* Now read the symbolic link */
    597         char buffer[1024];
    598         int ret;
    599         ret = readlink(linkname, buffer, 1024);
    600         /* In case of an error, leave the handling up to the caller */
    601         if (ret == -1)
    602             ThrowException(General, "Could not retrieve executable path.");
    603 
    604         /* Ensure proper NUL termination */
    605         buffer[ret] = 0;
    606 #endif
    607 
    608         configuration_->executablePath_ = boost::filesystem::path(buffer);
    609 #ifndef ORXONOX_PLATFORM_APPLE
    610         configuration_->executablePath_ = configuration_->executablePath_.branch_path(); // remove executable name
    611 #endif
    612 
    613         /////////////////////
    614         // SET MODULE PATH //
    615         /////////////////////
    616 
    617         if (boost::filesystem::exists(configuration_->executablePath_ / "orxonox_dev_build.keep_me"))
    618         {
    619             COUT(1) << "Running from the build tree." << std::endl;
    620             Core::bDevRun_ = true;
    621             configuration_->modulePath_ = specialConfig::moduleDevDirectory;
    622         }
    623         else
    624         {
    625 
    626 #ifdef INSTALL_COPYABLE // --> relative paths
    627 
    628             // Also set the root path
    629             boost::filesystem::path relativeExecutablePath(specialConfig::defaultRuntimePath);
    630             configuration_->rootPath_ = configuration_->executablePath_;
    631             while (!boost::filesystem::equivalent(configuration_->rootPath_ / relativeExecutablePath, configuration_->executablePath_)
    632                    && !configuration_->rootPath_.empty())
    633                 configuration_->rootPath_ = configuration_->rootPath_.branch_path();
    634             if (configuration_->rootPath_.empty())
    635                 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    636 
    637             // Module path is fixed as well
    638             configuration_->modulePath_ = configuration_->rootPath_ / specialConfig::defaultModulePath;
    639 
    640 #else
    641 
    642             // There is no root path, so don't set it at all
    643             // Module path is fixed as well
    644             configuration_->modulePath_ = specialConfig::moduleInstallDirectory;
    645 
    646 #endif
    647         }
    648     }
    649 
    650     /**
    651     @brief
    652         Sets config, log and media path and creates folders if necessary.
    653     @throws
    654         GeneralException
    655     */
    656     void Core::setConfigurablePaths()
    657     {
    658         if (Core::isDevelopmentRun())
    659         {
    660             configuration_->dataPath_  = specialConfig::dataDevDirectory;
    661             configuration_->externalDataPath_ = specialConfig::externalDataDevDirectory;
    662             configuration_->configPath_ = specialConfig::configDevDirectory;
    663             configuration_->logPath_    = specialConfig::logDevDirectory;
    664         }
    665         else
    666         {
    667 
    668 #ifdef INSTALL_COPYABLE // --> relative paths
    669 
    670             // Using paths relative to the install prefix, complete them
    671             configuration_->dataPath_   = configuration_->rootPath_ / specialConfig::defaultDataPath;
    672             configuration_->configPath_ = configuration_->rootPath_ / specialConfig::defaultConfigPath;
    673             configuration_->logPath_    = configuration_->rootPath_ / specialConfig::defaultLogPath;
    674 
    675 #else
    676 
    677             configuration_->dataPath_  = specialConfig::dataInstallDirectory;
    678 
    679             // Get user directory
    680 #  ifdef ORXONOX_PLATFORM_UNIX /* Apple? */
    681             char* userDataPathPtr(getenv("HOME"));
    682 #  else
    683             char* userDataPathPtr(getenv("APPDATA"));
    684 #  endif
    685             if (userDataPathPtr == NULL)
    686                 ThrowException(General, "Could not retrieve user data path.");
    687             boost::filesystem::path userDataPath(userDataPathPtr);
    688             userDataPath /= ".orxonox";
    689 
    690             configuration_->configPath_ = userDataPath / specialConfig::defaultConfigPath;
    691             configuration_->logPath_    = userDataPath / specialConfig::defaultLogPath;
    692 
    693 #endif
    694 
    695         }
    696 
    697         // Option to put all the config and log files in a separate folder
    698         if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
    699         {
    700             std::string directory(CommandLine::getValue("writingPathSuffix").getString());
    701             configuration_->configPath_ = configuration_->configPath_ / directory;
    702             configuration_->logPath_    = configuration_->logPath_    / directory;
    703         }
    704 
    705         // Create directories to avoid problems when opening files in non existent folders.
    706         std::vector<std::pair<boost::filesystem::path, std::string> > directories;
    707         directories.push_back(std::make_pair(boost::filesystem::path(configuration_->configPath_), "config"));
    708         directories.push_back(std::make_pair(boost::filesystem::path(configuration_->logPath_), "log"));
    709 
    710         for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
    711             it != directories.end(); ++it)
    712         {
    713             if (boost::filesystem::exists(it->first) && !boost::filesystem::is_directory(it->first))
    714             {
    715                 ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
    716                                          Please remove " + it->first.string());
    717             }
    718             if (boost::filesystem::create_directories(it->first)) // function may not return true at all (bug?)
    719             {
    720                 COUT(4) << "Created " << it->second << " directory" << std::endl;
    721             }
    722         }
    723     }
    724 
    725433    void Core::preUpdate(const Clock& time)
    726434    {
     435        // singletons from other libraries
     436        ScopedSingletonManager::update<ScopeID::Root>(time);
    727437        if (this->bGraphicsLoaded_)
    728438        {
     
    731441            // process gui events
    732442            this->guiManager_->update(time);
     443            // graphics singletons from other libraries
     444            ScopedSingletonManager::update<ScopeID::Graphics>(time);
    733445        }
    734446        // process thread commands
  • code/branches/pickup/src/libraries/core/Core.h

    r5781 r5935  
    2828 */
    2929
    30 /**
    31 @file
    32 @brief
    33     Declaration of the Core class.
    34 @details
    35     The Core class is a singleton, only used to configure some variables
    36     in the core through the config-file.
    37 */
    38 
    3930#ifndef _Core_H__
    4031#define _Core_H__
     
    4536#include <boost/scoped_ptr.hpp>
    4637#include "util/OutputHandler.h"
     38#include "util/Scope.h"
    4739#include "util/ScopeGuard.h"
    4840#include "util/Singleton.h"
     
    5547    @brief
    5648        The Core class is a singleton used to configure the program basics.
    57     @details
    58         The class provides information about the data, config and log path.
    59         It determines those by the use of platform specific functions.
    6049    @remark
    6150        You should only create this singleton once because it destroys the identifiers!
     
    8574            static void  resetLanguage();
    8675
    87             static void tsetExternalDataPath(const std::string& path);
    88             //! Returns the path to the data files as boost::filesystem::path
    89             static const boost::filesystem::path& getDataPath();
    90             //! Returns the path to the external data files as boost::filesystem::path
    91             static const boost::filesystem::path& getExternalDataPath();
    92             //! Returns the path to the config files as boost::filesystem::path
    93             static const boost::filesystem::path& getConfigPath();
    94             //! Returns the path to the log files as boost::filesystem::path
    95             static const boost::filesystem::path& getLogPath();
    96             //! Returns the path to the root folder as boost::filesystem::path
    97             static const boost::filesystem::path& getRootPath();
    98             //! Returns the path to the data files as std::string
    99             static std::string getDataPathString();
    100             //! Returns the path to the external data files as std::string
    101             static std::string getExternalDataPathString();
    102             //! Returns the path to the config files as std::string
    103             static std::string getConfigPathString();
    104             //! Returns the path to the log files as std::string
    105             static std::string getLogPathString();
    106             //! Returns the path to the root folder as std::string
    107             static std::string getRootPathString();
    108 
    109             static bool isDevelopmentRun() { return getInstance().bDevRun_; }
    110 
    11176        private:
    11277            Core(const Core&); //!< Don't use (undefined symbol)
     
    11883            void unloadGraphics();
    11984
    120             void setFixedPaths();
    121             void setConfigurablePaths();
    12285            void setThreadAffinity(int limitToCPU);
    12386
    12487            // Mind the order for the destruction!
     88            scoped_ptr<PathConfig>        pathConfig_;
    12589            scoped_ptr<DynLibManager>     dynLibManager_;
    12690            scoped_ptr<SignalHandler>     signalHandler_;
     
    137101            scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
    138102            scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
     103            scoped_ptr<Scope<ScopeID::Root> >     rootScope_;
     104            scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;
    139105
    140             bool                          bDevRun_;             //!< True for runs in the build directory (not installed)
    141106            bool                          bGraphicsLoaded_;
    142 
    143107            static Core* singletonPtr_s;
    144108    };
  • code/branches/pickup/src/libraries/core/CoreIncludes.h

    r5781 r5935  
    2929/**
    3030    @file
    31     @brief Definition of macros for Identifier and Factory.
     31    @brief Definition of macros for Identifiers
    3232
    3333    Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface
     
    4545#include "util/Debug.h"
    4646#include "Identifier.h"
    47 #include "Factory.h"
     47#include "SubclassIdentifier.h"
    4848#include "ClassFactory.h"
    4949#include "ObjectList.h"
     
    7676
    7777/**
    78     @brief Creates the entry in the Factory.
     78    @brief Creates the Factory.
    7979    @param ClassName The name of the class
    8080*/
    8181#define CreateFactory(ClassName) \
    82     bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true)
     82    Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, true)
    8383
    8484/**
    85     @brief Creates the entry in the Factory for classes which should not be loaded through XML.
     85    @brief Creates the Factory for classes which should not be loaded through XML.
    8686    @param ClassName The name of the class
    8787*/
    8888#define CreateUnloadableFactory(ClassName) \
    89     bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false)
     89    Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, false)
    9090
    9191/**
     
    100100{
    101101    /**
    102         @brief Returns the Identifier with a given name through the factory.
     102        @brief Returns the Identifier with a given name.
    103103        @param String The name of the class
    104104    */
    105105    inline Identifier* ClassByString(const std::string& name)
    106106    {
    107         return Factory::getIdentifier(name);
     107        return Identifier::getIdentifierByString(name);
    108108    }
    109109
    110110    /**
    111         @brief Returns the Identifier with a given network ID through the factory.
     111        @brief Returns the Identifier with a given lowercase name.
     112        @param String The lowercase name of the class
     113    */
     114    inline Identifier* ClassByLowercaseString(const std::string& name)
     115    {
     116        return Identifier::getIdentifierByLowercaseString(name);
     117    }
     118
     119    /**
     120        @brief Returns the Identifier with a given network ID.
    112121        @param networkID The network ID of the class
    113122    */
    114123    inline Identifier* ClassByID(uint32_t id)
    115124    {
    116         return Factory::getIdentifier(id);
     125        return Identifier::getIdentifierByID(id);
    117126    }
    118127}
  • code/branches/pickup/src/libraries/core/CorePrereqs.h

    r5738 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the core library
    3233*/
    3334
     
    4041// Shared library settings
    4142//-----------------------------------------------------------------------
     43
    4244#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( CORE_STATIC_BUILD )
    4345#  ifdef CORE_SHARED_BUILD
     
    5658#endif
    5759
    58 
    59 //-----------------------------------------------------------------------
    60 // Forward declarations
    61 //-----------------------------------------------------------------------
     60//-----------------------------------------------------------------------
     61// Constants
     62//-----------------------------------------------------------------------
     63
     64namespace orxonox
     65{
     66    static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
     67}
     68
     69//-----------------------------------------------------------------------
     70// Enums
     71//-----------------------------------------------------------------------
     72
    6273namespace orxonox
    6374{
     
    6677        enum Mode
    6778        {
     79            NOP,
    6880            LoadObject,
    6981            SaveObject,
     
    8294        };
    8395    };
    84 
     96}
     97
     98//-----------------------------------------------------------------------
     99// Forward declarations
     100//-----------------------------------------------------------------------
     101
     102namespace orxonox
     103{
    85104    typedef std::string LanguageEntryLabel;
    86105
    87106    class ArgumentCompleter;
    88107    class ArgumentCompletionListElement;
    89     class BaseFactory;
    90     class BaseMetaObjectListElement;
    91108    class BaseObject;
    92109    template <class T>
     
    98115    class ClassTreeMaskNode;
    99116    class ClassTreeMaskObjectIterator;
    100     class Clock;
    101117    class CommandEvaluation;
    102     class CommandExecutor;
    103118    class CommandLine;
    104119    class CommandLineArgument;
     
    109124    class ConfigFileManager;
    110125    class ConfigFileSection;
     126    struct ConfigFileType;
    111127    class ConfigValueContainer;
    112128    class ConsoleCommand;
     
    115131    class DynLibManager;
    116132    struct Event;
    117     class EventContainer;
     133    class EventState;
    118134    class Executor;
    119135    template <class T>
     
    125141    class FunctorMember;
    126142    class FunctorStatic;
     143    class Game;
     144    class GameState;
     145    struct GameStateInfo;
     146    struct GameStateTreeNode;
    127147    class GraphicsManager;
    128148    class GUIManager;
     
    131151    template <class T>
    132152    class Iterator;
    133     class IteratorBase;
    134153    class Language;
    135     class LanguageEntry;
    136     class Loader;
    137154    class LuaState;
    138155    class MemoryArchive;
     
    152169    class OgreWindowEventListener;
    153170    class OrxonoxClass;
     171    class PathConfig;
    154172    struct ResourceInfo;
    155173    class Shell;
    156174    class ShellListener;
    157175    template <class T>
     176    class SmartPtr;
     177    template <class T>
    158178    class SubclassIdentifier;
    159179    class TclBind;
     
    163183    class TclThreadManager;
    164184    class Template;
     185    class Thread;
     186    class ThreadPool;
     187    template <class T>
     188    class WeakPtr;
    165189    class WindowEventListener;
    166190    class XMLFile;
     
    173197    class XMLPortParamContainer;
    174198
    175     // game states
    176     class Game;
    177     class GameState;
    178     struct GameStateInfo;
    179     struct GameStateTreeNode;
    180 
    181     // input
     199    // Input
    182200    class BaseCommand;
    183201    class BufferedParamCommand;
    184202    class Button;
    185     class CalibratorCallback;
    186203    class HalfAxis;
    187204    class InputBuffer;
     
    192209    class InputManager;
    193210    class InputState;
     211    struct InputStatePriority;
     212    class JoyStickQuantityListener;
    194213    class JoyStick;
     214    class KeyBinder;
     215    class KeyBinderManager;
     216    class Keyboard;
     217    class KeyDetector;
     218    class KeyEvent;
    195219    class Mouse;
    196     class Keyboard;
    197     class KeyBinder;
    198     class KeyDetector;
    199220    class ParamCommand;
    200221    class SimpleCommand;
    201 
    202 
    203     // multithreading
    204     class Thread;
    205     class ThreadPool;
    206222}
    207223
     
    282298namespace orxonox
    283299{
    284     using ticpp::Document;
    285300    using ticpp::Element;
    286     using ticpp::Declaration;
    287     using ticpp::StylesheetReference;
    288     using ticpp::Text;
    289     using ticpp::Comment;
    290     using ticpp::Attribute;
    291 }
    292 
     301}
    293302
    294303#endif /* _CorePrereqs_H__ */
  • code/branches/pickup/src/libraries/core/Event.cc

    r5781 r5935  
    3030
    3131#include "BaseObject.h"
    32 #include "Executor.h"
     32#include "Identifier.h"
    3333
    3434namespace orxonox
    3535{
    36     EventContainer::~EventContainer()
     36    /**
     37        @brief Destructor: Deletes the functor of the event state.
     38    */
     39    EventState::~EventState()
    3740    {
    38         delete this->eventfunction_;
     41        if (this->statefunction_)
     42            delete this->statefunction_;
    3943    }
    4044
    41     void EventContainer::process(BaseObject* object, const Event& event)
     45    /**
     46        @brief Processes an event (calls the set-function if the necessary conditions are met).
     47       
     48        @param event     The fired event
     49        @param object    The object whose state is affected by the event (only needed for debug output)
     50    */
     51    void EventState::process(const Event& event, BaseObject* object)
    4252    {
    43         if (this->bActive_)
     53        if (this->bProcessingEvent_)
    4454        {
    45             COUT(2) << "Warning: Detected Event loop in section \"" << this->eventname_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << "\"" << std::endl;
     55            COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << "\"" << std::endl;
    4656            return;
    4757        }
    4858
    49         this->bActive_ = true;
     59        this->bProcessingEvent_ = true;
    5060
    51         if (this->eventname_ == event.sectionname_)
     61        // check if the originator is an instance of the requested class
     62        if (event.originator_->isA(this->subclass_))
    5263        {
    53             if (event.originator_->isA(this->subclass_))
     64            // actualize the activationcounter
     65            if (event.activate_)
     66                ++this->activeEvents_;
     67            else
    5468            {
    55                 if (event.activate_)
    56                     ++this->activeEvents_;
    57                 else
     69                --this->activeEvents_;
     70
     71                if (this->activeEvents_ < 0)
     72                    this->activeEvents_ = 0;
     73            }
     74
     75            if (this->statefunction_->getParamCount() == 0 && event.activate_)
     76            {
     77                // if the eventfunction doesn't have a state, just call it whenever an activation-event comes in
     78                (*this->statefunction_)();
     79            }
     80            else if ((this->activeEvents_ == 1 && event.activate_) || (this->activeEvents_ == 0 && !event.activate_))
     81            {
     82                // if the eventfunction needs a state, we just call the function if the state changed from 0 to 1 (state = true) or from 1 to 0 (state = false) [but not if activeEvents_ is > 1]
     83                if (this->statefunction_->getParamCount() == 1)
    5884                {
    59                     --this->activeEvents_;
    60 
    61                     if (this->activeEvents_ < 0)
    62                         this->activeEvents_ = 0;
     85                    // one argument: just the eventstate
     86                    (*this->statefunction_)(this->activeEvents_);
    6387                }
    64 
    65                 if (this->eventfunction_->getParamCount() == 0 && event.activate_)
    66                     (*this->eventfunction_)();
    67                 else if ((this->activeEvents_ == 1 && event.activate_) || (this->activeEvents_ == 0 && !event.activate_))
     88                else if (this->statefunction_->getParamCount() >= 2)
    6889                {
    69                     if (this->eventfunction_->getParamCount() == 1)
    70                         (*this->eventfunction_)(this->activeEvents_);
    71                     else if (this->eventfunction_->getParamCount() >= 2 && event.castedOriginator_)
    72                         (*this->eventfunction_)(this->activeEvents_, event.castedOriginator_);
     90                    // two arguments: the eventstate and the originator
     91                    if (this->subclass_->isExactlyA(ClassIdentifier<BaseObject>::getIdentifier()))
     92                    {
     93                        // if the subclass is BaseObject, we don't have to cast the pointer
     94                        (*this->statefunction_)(this->activeEvents_, event.originator_);
     95                    }
     96                    else
     97                    {
     98                        // else cast the pointer to the desired class
     99                        void* castedOriginator = event.originator_->getDerivedPointer(this->subclass_->getClassID());
     100                        (*this->statefunction_)(this->activeEvents_, castedOriginator);
     101                    }
    73102                }
    74103            }
    75104        }
    76105
    77         this->bActive_ = false;
     106        this->bProcessingEvent_ = false;
    78107    }
    79108}
  • code/branches/pickup/src/libraries/core/Event.h

    r5781 r5935  
    3535namespace orxonox
    3636{
     37    /**
     38        @brief The Event struct contains information about a fired Event.
     39    */
    3740    struct _CoreExport Event
    3841    {
    39             Event(bool activate, BaseObject* originator) : activate_(activate), originator_(originator), castedOriginator_(0) {}
     42        Event(bool activate, BaseObject* originator, const std::string& name) : activate_(activate), originator_(originator), name_(name) {}
    4043
    41             bool        activate_;
    42             BaseObject* originator_;
    43             void*       castedOriginator_;
    44             std::string sectionname_;
     44        bool        activate_;   //!< True if this is an activating event (the event source was inactive before and just triggered the event) - false otherwise
     45        std::string statename_;  //!< The name of the state this event affects
     46        BaseObject* originator_; //!< The object which triggered this event
     47        std::string name_;       //!< The name of this event
    4548    };
    4649
    47     class _CoreExport EventContainer
     50    /**
     51        @brief The EventState contains information about an event state.
     52       
     53        An event state is a state of an object, which can be changed by events.
     54        Event states are changed through functions. Possible functions headers for set event states are:
     55         - memoryless state: function()
     56         - boolean state:    function(bool state)
     57         - individual state: function(bool state, SomeClass originator)
     58         
     59        Note that SomeClass may be any class deriving from BaseObject. You will not receive events from originators of other classes.
     60        The actual class for SomeClass must be specified as the second argument of the XMLPortEventState macro.
     61       
     62        The this pointer of the affected object is hidden in the functors, because the events are processed in the BaseObject, but some
     63        statefunctions may be from child-classes.
     64    */
     65    class _CoreExport EventState
    4866    {
    4967        public:
    50             EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
    51             virtual ~EventContainer();
     68            EventState(Functor* statefunction, Identifier* subclass) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass) {}
     69            virtual ~EventState();
    5270
    53             void process(BaseObject* object, const Event& event);
     71            void process(const Event& event, BaseObject* object);
     72           
     73            Functor* getFunctor() const
     74                { return this->statefunction_; }
    5475
    5576        private:
    56             bool bActive_;
    57             std::string eventname_;
    58             Executor* eventfunction_;
    59             Identifier* subclass_;
    60 
    61             int activeEvents_;
     77            bool        bProcessingEvent_;  //!< This becomes true while the container processes an event (used to prevent loops)
     78            int         activeEvents_;      //!< The number of events which affect this state and are currently active
     79            Functor*    statefunction_;     //!< A functor to set the state
     80            Identifier* subclass_;          //!< Originators must be an instance of this class (usually BaseObject, but some statefunctions allow a second argument with an originator of a specific class)
    6281    };
    6382}
  • code/branches/pickup/src/libraries/core/EventIncludes.h

    r5781 r5935  
    3232#include "CorePrereqs.h"
    3333#include "Executor.h"
     34#include "XMLPort.h"
    3435
    35 #define ORXONOX_SET_EVENT(classname, eventname, functionname, event) \
    36     ORXONOX_SET_EVENT_GENERIC(eventcontainer##classname##functionname, classname, eventname, functionname, event, BaseObject)
     36/**
     37    @brief Defines a new event state (a state of the object which can be changed by events).
     38   
     39    @param classname    The name of this class
     40    @param subclassname Usually BaseObject - if different, only instances of this class can send events to this object
     41    @param statename    The name (string) of this state
     42    @param function     The function which should be used to set the state
     43    @param xmlelement   Argument for XMLPort
     44    @param mode         Argument for XMLPort
     45*/
     46#define XMLPortEventState(classname, subclassname, statename, function, xmlelement, mode) \
     47    orxonox::EventState* containername##function = this->getEventState(statename); \
     48    if (!containername##function) \
     49    { \
     50        containername##function = new orxonox::EventState(orxonox::createFunctor(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
     51        this->addEventState(statename, containername##function); \
     52    } \
     53    XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
    3754
    38 #define ORXONOX_SET_EVENT_TEMPLATE(classname, eventname, functionname, event, ...) \
    39     ORXONOX_SET_EVENT_GENERIC_TEMPLATE(eventcontainer##classname##functionname, classname, eventname, functionname, event, BaseObject, __VA_ARGS__)
     55/**
     56    @brief Like XMLPortEventState but with additional template arguments to identify the function of the state (if ambiguous).
     57*/
     58#define XMLPortEventStateTemplate(classname, subclassname, statename, function, xmlelement, mode, ...) \
     59    orxonox::EventState* containername##function = this->getEventState(statename); \
     60    if (!containername##function) \
     61    { \
     62        containername##function = new orxonox::EventState(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::function, this), orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
     63        this->addEventState(statename, containername##function); \
     64    } \
     65    XMLPortEventStateIntern(xmlportevent##function, classname, statename, xmlelement, mode)
    4066
    41 #define ORXONOX_SET_SUBCLASS_EVENT(classname, eventname, functionname, event, subclassname) \
    42     ORXONOX_SET_EVENT_GENERIC(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname)
     67#define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \
     68    static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + "(" + statename + ")")->setDefaultValue(1, statename); \
     69    static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + "(" + statename + ")")->setDefaultValue(1, statename); \
     70    XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
     71   
    4372
    44 #define ORXONOX_SET_SUBCLASS_EVENT_TEMPLATE(classname, eventname, functionname, event, subclassname, ...) \
    45     ORXONOX_SET_EVENT_GENERIC_TEMPLATE(eventcontainer##classname##functionname, classname, eventname, functionname, event, subclassname, __VA_ARGS__)
     73/**
     74    @brief Defines a new event name for a class. Named events can only have names which were defined with this macro.
     75   
     76    @param classname The name of the class
     77    @param name      The name of the event
     78*/
     79#define CreateEventName(classname, name) \
     80    static std::string eventname##classname##name = #name
    4681
    47 #define ORXONOX_SET_EVENT_GENERIC(containername, classname, eventname, functionname, event, subclassname) \
    48     orxonox::EventContainer* containername = this->getEventContainer(eventname); \
    49     if (!containername) \
    50     { \
    51         ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
    52         executor->setObject(this); \
    53         containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
    54         this->addEventContainer(eventname, containername); \
    55     } \
    56     event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
    57     containername->process(this, event)
    58 
    59 #define ORXONOX_SET_EVENT_GENERIC_TEMPLATE(containername, classname, eventname, functionname, event, subclassname, ...) \
    60     orxonox::EventContainer* containername = this->getEventContainer(eventname); \
    61     if (!containername) \
    62     { \
    63         ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
    64         executor->setObject(this); \
    65         containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
    66         this->addEventContainer(eventname, containername); \
    67     } \
    68     event.castedOriginator_ = orxonox::orxonox_cast<subclassname*>(event.originator_); \
    69     containername->process(this, event)
    70 
     82/**
     83    @brief This macro is needed to fire an event with this name. The event name must previously be declared with @ref CreateEventName.
     84*/   
     85#define FireEventName(classname, name) \
     86    eventname##classname##name
     87 
    7188#endif /* _EventIncludes_H__ */
  • code/branches/pickup/src/libraries/core/Functor.h

    r5738 r5935  
    191191
    192192
    193 #define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams
    194 #define FUNCTOR_TEMPLATE000
    195 #define FUNCTOR_TEMPLATE001 template <class P1>
    196 #define FUNCTOR_TEMPLATE002 template <class P1, class P2>
    197 #define FUNCTOR_TEMPLATE003 template <class P1, class P2, class P3>
    198 #define FUNCTOR_TEMPLATE004 template <class P1, class P2, class P3, class P4>
    199 #define FUNCTOR_TEMPLATE005 template <class P1, class P2, class P3, class P4, class P5>
    200 #define FUNCTOR_TEMPLATE010 template <class R>
    201 #define FUNCTOR_TEMPLATE011 template <class R, class P1>
    202 #define FUNCTOR_TEMPLATE012 template <class R, class P1, class P2>
    203 #define FUNCTOR_TEMPLATE013 template <class R, class P1, class P2, class P3>
    204 #define FUNCTOR_TEMPLATE014 template <class R, class P1, class P2, class P3, class P4>
    205 #define FUNCTOR_TEMPLATE015 template <class R, class P1, class P2, class P3, class P4, class P5>
    206 #define FUNCTOR_TEMPLATE100 template <class T>
    207 #define FUNCTOR_TEMPLATE101 template <class T, class P1>
    208 #define FUNCTOR_TEMPLATE102 template <class T, class P1, class P2>
    209 #define FUNCTOR_TEMPLATE103 template <class T, class P1, class P2, class P3>
    210 #define FUNCTOR_TEMPLATE104 template <class T, class P1, class P2, class P3, class P4>
    211 #define FUNCTOR_TEMPLATE105 template <class T, class P1, class P2, class P3, class P4, class P5>
    212 #define FUNCTOR_TEMPLATE110 template <class T, class R>
    213 #define FUNCTOR_TEMPLATE111 template <class T, class R, class P1>
    214 #define FUNCTOR_TEMPLATE112 template <class T, class R, class P1, class P2>
    215 #define FUNCTOR_TEMPLATE113 template <class T, class R, class P1, class P2, class P3>
    216 #define FUNCTOR_TEMPLATE114 template <class T, class R, class P1, class P2, class P3, class P4>
    217 #define FUNCTOR_TEMPLATE115 template <class T, class R, class P1, class P2, class P3, class P4, class P5>
     193#define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams, additionalobject) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams(additionalobject)
     194#define FUNCTOR_TEMPLATE000(additionalobject)
     195#define FUNCTOR_TEMPLATE001(additionalobject) template <class P1>
     196#define FUNCTOR_TEMPLATE002(additionalobject) template <class P1, class P2>
     197#define FUNCTOR_TEMPLATE003(additionalobject) template <class P1, class P2, class P3>
     198#define FUNCTOR_TEMPLATE004(additionalobject) template <class P1, class P2, class P3, class P4>
     199#define FUNCTOR_TEMPLATE005(additionalobject) template <class P1, class P2, class P3, class P4, class P5>
     200#define FUNCTOR_TEMPLATE010(additionalobject) template <class R>
     201#define FUNCTOR_TEMPLATE011(additionalobject) template <class R, class P1>
     202#define FUNCTOR_TEMPLATE012(additionalobject) template <class R, class P1, class P2>
     203#define FUNCTOR_TEMPLATE013(additionalobject) template <class R, class P1, class P2, class P3>
     204#define FUNCTOR_TEMPLATE014(additionalobject) template <class R, class P1, class P2, class P3, class P4>
     205#define FUNCTOR_TEMPLATE015(additionalobject) template <class R, class P1, class P2, class P3, class P4, class P5>
     206#define FUNCTOR_TEMPLATE100(additionalobject) template <class T FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     207#define FUNCTOR_TEMPLATE101(additionalobject) template <class T, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     208#define FUNCTOR_TEMPLATE102(additionalobject) template <class T, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     209#define FUNCTOR_TEMPLATE103(additionalobject) template <class T, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     210#define FUNCTOR_TEMPLATE104(additionalobject) template <class T, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     211#define FUNCTOR_TEMPLATE105(additionalobject) template <class T, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     212#define FUNCTOR_TEMPLATE110(additionalobject) template <class T, class R FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     213#define FUNCTOR_TEMPLATE111(additionalobject) template <class T, class R, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     214#define FUNCTOR_TEMPLATE112(additionalobject) template <class T, class R, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     215#define FUNCTOR_TEMPLATE113(additionalobject) template <class T, class R, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     216#define FUNCTOR_TEMPLATE114(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     217#define FUNCTOR_TEMPLATE115(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     218
     219
     220
     221#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT##additionalobject
     222#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT0
     223#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT1 , class O
    218224
    219225
     
    317323
    318324#define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
    319     FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
     325    FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
    320326    class FunctorStatic##returnvalue##numparams : public FunctorStatic \
    321327    { \
     
    347353    \
    348354    \
    349     FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
     355    FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
    350356    inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
    351357    { \
     
    358364
    359365#define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \
    360     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     366    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    361367    class FunctorMember##returnvalue##numparams : public FunctorMember<T> \
    362368    { \
     
    391397    \
    392398    \
    393     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     399    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    394400    class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \
    395401    { \
     
    423429    \
    424430    \
    425     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     431    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    426432    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
    427433    { \
     
    430436    \
    431437    \
    432     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     438    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    433439    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
    434440    { \
    435441        return new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
     442    } \
     443    \
     444    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
     445    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), O* object) \
     446    { \
     447        FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
     448        functor->setObject(object); \
     449        return functor; \
     450    } \
     451    \
     452    \
     453    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
     454    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, O* object) \
     455    { \
     456        FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
     457        functor->setObject(object); \
     458        return functor; \
    436459    }
    437460
  • code/branches/pickup/src/libraries/core/GUIManager.cc

    r5781 r5935  
    4949#endif
    5050
     51#include "util/Clock.h"
    5152#include "util/Debug.h"
    5253#include "util/Exception.h"
    5354#include "util/OrxAssert.h"
    5455#include "Core.h"
    55 #include "Clock.h"
    5656#include "LuaState.h"
     57#include "PathConfig.h"
    5758#include "Resource.h"
    5859
     
    6263    {
    6364    public:
    64             void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
     65        void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
    6566        {
    6667            int orxonoxLevel = CEGUI::Standard;
     
    100101        : renderWindow_(renderWindow)
    101102        , resourceProvider_(0)
     103        , camera_(NULL)
    102104    {
    103105        using namespace CEGUI;
     
    116118        // Create our own logger to specify the filepath
    117119        std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
    118         ceguiLogger->setLogFilename(Core::getLogPathString() + "cegui.log");
     120        ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log");
    119121        // set the log level according to ours (translate by subtracting 1)
    120122        ceguiLogger->setLoggingLevel(
     
    173175    void GUIManager::setCamera(Ogre::Camera* camera)
    174176    {
     177        this->camera_ = camera;
    175178        if (camera == NULL)
    176179            this->guiRenderer_->setTargetSceneManager(0);
  • code/branches/pickup/src/libraries/core/GUIManager.h

    r5781 r5935  
    7171
    7272        void setCamera(Ogre::Camera* camera);
     73        Ogre::Camera* getCamera() { return this->camera_; }
    7374
    7475        static GUIManager* getInstancePtr() { return singletonPtr_s; }
     
    101102        CEGUI::Logger*                       ceguiLogger_;      //!< CEGUI's logger to be able to log CEGUI errors in our log
    102103        std::map<std::string, PlayerInfo*>   players_;          //!< Stores the player (owner) for each gui
     104        Ogre::Camera*                        camera_;           //!< Camera used to render the scene with the GUI
    103105
    104106        static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
  • code/branches/pickup/src/libraries/core/Game.cc

    r5781 r5935  
    3838#include <boost/weak_ptr.hpp>
    3939
     40#include "util/Clock.h"
    4041#include "util/Debug.h"
    4142#include "util/Exception.h"
     
    4344#include "util/Sleep.h"
    4445#include "util/SubString.h"
    45 #include "Clock.h"
    4646#include "CommandLine.h"
    4747#include "ConsoleCommand.h"
     
    5757        { Game::getInstance().stop(); }
    5858    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
     59    static void printFPS()
     60        { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
     61    SetConsoleCommandShortcutExternAlias(printFPS, "printFPS");
     62    static void printTickTime()
     63        { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
     64    SetConsoleCommandShortcutExternAlias(printTickTime, "printTickTime");
    5965
    6066    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
     
    111117    Game::Game(const std::string& cmdLine)
    112118        // Destroy factories before the Core!
    113         : gsFactoryDestroyer_(Game::GameStateFactory::factories_s, &std::map<std::string, shared_ptr<GameStateFactory> >::clear)
     119        : gsFactoryDestroyer_(Game::GameStateFactory::getFactories(), &std::map<std::string, shared_ptr<GameStateFactory> >::clear)
    114120    {
    115121        this->bAbort_ = false;
     
    410416                requestedNodes.push_back(currentNode);
    411417            }
     418            if (currentNode == NULL)
     419                requestedNodes.clear();
    412420        }
    413421
     
    457465    {
    458466        // Split string into pieces of the form whitespacesText
    459         std::vector<std::pair<std::string, unsigned> > stateStrings;
     467        std::vector<std::pair<std::string, int> > stateStrings;
    460468        size_t pos = 0;
    461469        size_t startPos = 0;
    462470        while (pos < str.size())
    463471        {
    464             unsigned indentation = 0;
     472            int indentation = 0;
    465473            while(pos < str.size() && str[pos] == ' ')
    466474                ++indentation, ++pos;
     
    470478            stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));
    471479        }
    472         unsigned int currentLevel = 0;
    473         shared_ptr<GameStateTreeNode> currentNode = this->rootStateNode_;
    474         for (std::vector<std::pair<std::string, unsigned> >::const_iterator it = stateStrings.begin(); it != stateStrings.end(); ++it)
    475         {
    476             std::string newStateName = it->first;
    477             unsigned newLevel = it->second + 1; // empty root is 0
    478             if (!this->checkState(newStateName))
    479                 ThrowException(GameState, "GameState with name '" << newStateName << "' not found!");
    480             if (newStateName == this->rootStateNode_->name_)
     480        if (stateStrings.empty())
     481            ThrowException(GameState, "Emtpy GameState hierarchy provided, terminating.");
     482        // Add element with large identation to detect the last with just an iterator
     483        stateStrings.push_back(std::make_pair("", -1));
     484
     485        // Parse elements recursively
     486        std::vector<std::pair<std::string, int> >::const_iterator begin = stateStrings.begin();
     487        parseStates(begin, this->rootStateNode_);
     488    }
     489
     490    /*** Internal ***/
     491
     492    void Game::parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode)
     493    {
     494        SubString tokens(it->first, ",");
     495        std::vector<std::pair<std::string, int> >::const_iterator startIt = it;
     496
     497        for (unsigned int i = 0; i < tokens.size(); ++i)
     498        {
     499            it = startIt; // Reset iterator to the beginning of the sub tree
     500            if (!this->checkState(tokens[i]))
     501                ThrowException(GameState, "GameState with name '" << tokens[i] << "' not found!");
     502            if (tokens[i] == this->rootStateNode_->name_)
    481503                ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
    482             shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
    483             newNode->name_ = newStateName;
    484 
    485             if (newLevel <= currentLevel)
    486             {
    487                 do
    488                     currentNode = currentNode->parent_.lock();
    489                 while (newLevel <= --currentLevel);
    490             }
    491             if (newLevel == currentLevel + 1)
    492             {
    493                 // Add the child
    494                 newNode->parent_ = currentNode;
    495                 currentNode->children_.push_back(newNode);
    496             }
    497             else
    498                 ThrowException(GameState, "Indentation error while parsing the hierarchy.");
    499             currentNode = newNode;
    500             currentLevel = newLevel;
    501         }
    502     }
    503 
    504     /*** Internal ***/
     504            shared_ptr<GameStateTreeNode> node(new GameStateTreeNode());
     505            node->name_ = tokens[i];
     506            node->parent_ = currentNode;
     507            currentNode->children_.push_back(node);
     508
     509            int currentLevel = it->second;
     510            ++it;
     511            while (it->second != -1)
     512            {
     513                if (it->second <= currentLevel)
     514                    break;
     515                else if (it->second == currentLevel + 1)
     516                    parseStates(it, node);
     517                else
     518                    ThrowException(GameState, "Indentation error while parsing the hierarchy.");
     519            }
     520        }
     521    }
    505522
    506523    void Game::loadGraphics()
    507524    {
    508         if (!GameMode::bShowsGraphics_s)
     525        if (!GameMode::showsGraphics())
    509526        {
    510527            core_->loadGraphics();
    511528            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
    512             GameMode::bShowsGraphics_s = true;
    513529
    514530            // Construct all the GameStates that require graphics
     
    531547    void Game::unloadGraphics()
    532548    {
    533         if (GameMode::bShowsGraphics_s)
     549        if (GameMode::showsGraphics())
    534550        {
    535551            // Destroy all the GameStates that require graphics
     
    543559
    544560            core_->unloadGraphics();
    545             GameMode::bShowsGraphics_s = false;
    546561        }
    547562    }
     
    607622    }
    608623
    609     std::map<std::string, shared_ptr<Game::GameStateFactory> > Game::GameStateFactory::factories_s;
     624    /*static*/ std::map<std::string, shared_ptr<Game::GameStateFactory> >& Game::GameStateFactory::getFactories()
     625    {
     626        static std::map<std::string, shared_ptr<GameStateFactory> > factories;
     627        return factories;
     628    }
    610629
    611630    /*static*/ shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info)
    612631    {
    613         std::map<std::string, shared_ptr<Game::GameStateFactory> >::const_iterator it = factories_s.find(info.className);
    614         assert(it != factories_s.end());
     632        std::map<std::string, shared_ptr<Game::GameStateFactory> >::const_iterator it = getFactories().find(info.className);
     633        assert(it != getFactories().end());
    615634        return it->second->fabricateInternal(info);
    616635    }
  • code/branches/pickup/src/libraries/core/Game.h

    r5747 r5935  
    117117            template <class T>
    118118            static void createFactory(const std::string& className)
    119                 { factories_s[className].reset(new TemplateGameStateFactory<T>()); }
     119                { getFactories()[className].reset(new TemplateGameStateFactory<T>()); }
    120120
    121121            virtual shared_ptr<GameState> fabricateInternal(const GameStateInfo& info) = 0;
    122             static std::map<std::string, shared_ptr<GameStateFactory> > factories_s;
     122            static std::map<std::string, shared_ptr<GameStateFactory> >& getFactories();
    123123        };
    124124        template <class T>
     
    143143        void unloadGraphics();
    144144
     145        void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode);
    145146        bool checkState(const std::string& name) const;
    146147        void loadState(const std::string& name);
  • code/branches/pickup/src/libraries/core/GameMode.cc

    r5781 r5935  
    2727 */
    2828
    29 /**
    30     @file
    31     @brief Implementation of the GameMode class.
    32 */
    33 
    3429#include "GameMode.h"
    3530
     
    3732{
    3833    bool GameMode::bShowsGraphics_s = false;
     34    bool GameMode::bPlaysSound_s    = false;
    3935    bool GameMode::bHasServer_s     = false;
    4036    bool GameMode::bIsClient_s      = false;
  • code/branches/pickup/src/libraries/core/GameMode.h

    r5781 r5935  
    4141    class _CoreExport GameMode
    4242    {
    43         friend class Game;
     43        friend class Core;
    4444
    4545        public:
    4646            static bool showsGraphics() { return bShowsGraphics_s; }
     47            static bool playsSound()    { return bPlaysSound_s; }
    4748            static bool hasServer()     { return bHasServer_s; }
    4849            static bool isClient()      { return bIsClient_s; }
     
    5051            static bool isMaster()      { return bIsMaster_s; }
    5152
     53            static void setPlaysSound   (bool val) { bPlaysSound_s    = val; }
    5254            static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
    5355            static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
     
    6567
    6668            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     69            static bool bPlaysSound_s;                      //!< global variable that tells whether to sound works
    6770            static bool bHasServer_s;                       //!< global variable that tells whether this is a server
    6871            static bool bIsClient_s;
  • code/branches/pickup/src/libraries/core/GameState.h

    r5738 r5935  
    4040#include <map>
    4141#include <string>
     42#include "util/UtilPrereqs.h"
    4243
    4344namespace orxonox
  • code/branches/pickup/src/libraries/core/GraphicsManager.cc

    r5781 r5935  
    4848
    4949#include "SpecialConfig.h"
     50#include "util/Clock.h"
    5051#include "util/Exception.h"
    5152#include "util/StringUtils.h"
    5253#include "util/SubString.h"
    53 #include "Clock.h"
    5454#include "ConsoleCommand.h"
    5555#include "ConfigValueIncludes.h"
    5656#include "CoreIncludes.h"
    57 #include "Core.h"
    5857#include "Game.h"
    5958#include "GameMode.h"
    6059#include "Loader.h"
    6160#include "MemoryArchive.h"
     61#include "PathConfig.h"
    6262#include "WindowEventListener.h"
    6363#include "XMLFile.h"
     
    102102
    103103        // At first, add the root paths of the data directories as resource locations
    104         Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Core::getDataPathString(), "FileSystem", "dataRoot", false);
     104        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem", "dataRoot", false);
    105105        // Load resources
    106106        resources_.reset(new XMLFile("resources.oxr", "dataRoot"));
     
    109109
    110110        // Only for development runs
    111         if (Core::isDevelopmentRun())
    112         {
    113             Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Core::getExternalDataPathString(), "FileSystem", "externalDataRoot", false);
     111        if (PathConfig::isDevelopmentRun())
     112        {
     113            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem", "externalDataRoot", false);
    114114            extResources_.reset(new XMLFile("resources.oxr", "externalDataRoot"));
    115115            extResources_->setLuaSupport(false);
     
    130130    GraphicsManager::~GraphicsManager()
    131131    {
     132        Loader::unload(debugOverlay_.get());
     133
    132134        Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get());
    133135        // TODO: Destroy the console command
     136
     137        // Undeclare the resources
     138        Loader::unload(resources_.get());
     139        if (PathConfig::isDevelopmentRun())
     140            Loader::unload(extResources_.get());
    134141    }
    135142
     
    241248        }
    242249
    243         boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() / this->ogreConfigFile_);
    244         boost::filesystem::path ogreLogFilepath(Core::getLogPath() / this->ogreLogFile_);
     250        boost::filesystem::path ogreConfigFilepath(PathConfig::getConfigPath() / this->ogreConfigFile_);
     251        boost::filesystem::path ogreLogFilepath(PathConfig::getLogPath() / this->ogreLogFile_);
    245252
    246253        // create a new logManager
     
    313320
    314321        // add console commands
    315         FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
    316         ccPrintScreen_ = createConsoleCommand(functor1->setObject(this), "printScreen");
     322        ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen");
    317323        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
    318324    }
    319325
     326    void GraphicsManager::loadDebugOverlay()
     327    {
     328        // Load debug overlay to show info about fps and tick time
     329        COUT(4) << "Loading Debug Overlay..." << std::endl;
     330        debugOverlay_.reset(new XMLFile("debug.oxo"));
     331        Loader::open(debugOverlay_.get());
     332    }
     333
     334    /**
     335    @note
     336        A note about the Ogre::FrameListener: Even though we don't use them,
     337        they still get called. However, the delta times are not correct (except
     338        for timeSinceLastFrame, which is the most important). A little research
     339        as shown that there is probably only one FrameListener that doesn't even
     340        need the time. So we shouldn't run into problems.
     341    */
    320342    void GraphicsManager::update(const Clock& time)
    321343    {
     
    418440        assert(this->renderWindow_);
    419441       
    420         this->renderWindow_->writeContentsToTimestampedFile(Core::getLogPathString() + "screenShot_", ".jpg");
     442        this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".jpg");
    421443    }
    422444}
  • code/branches/pickup/src/libraries/core/GraphicsManager.h

    r5781 r5935  
    7171
    7272        void upgradeToGraphics();
     73        void loadDebugOverlay();
    7374        bool rendererLoaded() const { return renderWindow_ != NULL; }
    7475
     
    99100        Ogre::Viewport*     viewport_;                 //!< default full size viewport
    100101
    101         // XML files for the resources
     102        // XML files for the resources and the debug overlay
    102103        shared_ptr<XMLFile> resources_;                //!< XML with resource locations
    103104        shared_ptr<XMLFile> extResources_;             //!< XML with resource locations in the external path (only for dev runs)
     105        shared_ptr<XMLFile> debugOverlay_;             //!< XML with various debug overlays
    104106
    105107        // config values
  • code/branches/pickup/src/libraries/core/Identifier.cc

    r5781 r5935  
    3939#include "ConfigValueContainer.h"
    4040#include "ConsoleCommand.h"
    41 #include "Factory.h"
     41#include "ClassFactory.h"
    4242#include "XMLPort.h"
    4343
     
    6161        this->bSetName_ = false;
    6262        this->factory_ = 0;
    63         this->bLoadable_ = true;
     63        this->bLoadable_ = false;
    6464
    6565        this->bHasConfigValues_ = false;
    6666        this->bHasConsoleCommands_ = false;
    6767
    68         this->children_ = new std::set<const Identifier*>();
    69         this->directChildren_ = new std::set<const Identifier*>();
    70 
    7168        // Default network ID is the class ID
    7269        this->networkID_ = this->classID_;
     
    7875    Identifier::~Identifier()
    7976    {
    80         delete this->children_;
    81         delete this->directChildren_;
    8277        delete this->objects_;
    8378
     
    118113            // There is already an entry: return it and delete the proposal
    119114            delete proposal;
    120             return (*it).second;
     115            return it->second;
    121116        }
    122117        else
     
    165160            {
    166161                // Tell the parent we're one of it's children
    167                 (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);
     162                (*it)->children_.insert((*it)->children_.end(), this);
    168163
    169164                // Erase all parents of our parent from our direct-parent-list
     
    187182            {
    188183                // Tell the parent we're one of it's direct children
    189                 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
     184                (*it)->directChildren_.insert((*it)->directChildren_.end(), this);
    190185
    191186                // Create the super-function dependencies
     
    196191
    197192    /**
     193        @brief Creates the class-hierarchy by creating and destroying one object of each type.
     194    */
     195    void Identifier::createClassHierarchy()
     196    {
     197        COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;
     198        Identifier::startCreatingHierarchy();
     199        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
     200        {
     201            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
     202            if (it->second->hasFactory())
     203            {
     204                BaseObject* temp = it->second->fabricate(0);
     205                temp->destroy();
     206            }
     207        }
     208        Identifier::stopCreatingHierarchy();
     209        COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;
     210    }
     211
     212    /**
    198213        @brief Destroys all Identifiers. Called when exiting the program.
    199214    */
     
    214229            this->name_ = name;
    215230            this->bSetName_ = true;
    216             Identifier::getIdentifierMapIntern()[name] = this;
    217             Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
     231            Identifier::getStringIdentifierMapIntern()[name] = this;
     232            Identifier::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this;
     233            Identifier::getIDIdentifierMapIntern()[this->networkID_] = this;
    218234        }
    219235    }
     
    235251            COUT(1) << "Aborting..." << std::endl;
    236252            abort();
    237             return NULL;
    238         }
    239     }
    240 
    241     /**
    242         @brief Sets the network ID to a new value and changes the entry in the Factory.
     253            return 0;
     254        }
     255    }
     256
     257    /**
     258        @brief Sets the network ID to a new value and changes the entry in the ID-Identifier-map.
    243259        @param id The new network ID
    244260    */
    245261    void Identifier::setNetworkID(uint32_t id)
    246262    {
    247         Factory::changeNetworkID(this, this->networkID_, id);
     263//        Identifier::getIDIdentifierMapIntern().erase(this->networkID_);
     264        Identifier::getIDIdentifierMapIntern()[id] = this;
    248265        this->networkID_ = id;
    249266    }
     
    291308    bool Identifier::isParentOf(const Identifier* identifier) const
    292309    {
    293         return (this->children_->find(identifier) != this->children_->end());
     310        return (this->children_.find(identifier) != this->children_.end());
    294311    }
    295312
     
    300317    bool Identifier::isDirectParentOf(const Identifier* identifier) const
    301318    {
    302         return (this->directChildren_->find(identifier) != this->directChildren_->end());
    303     }
    304 
    305     /**
    306         @brief Returns the map that stores all Identifiers.
     319        return (this->directChildren_.find(identifier) != this->directChildren_.end());
     320    }
     321
     322    /**
     323        @brief Returns the map that stores all Identifiers with their names.
    307324        @return The map
    308325    */
    309     std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern()
     326    std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern()
    310327    {
    311328        static std::map<std::string, Identifier*> identifierMap;
     
    314331
    315332    /**
    316         @brief Returns the map that stores all Identifiers.
     333        @brief Returns the map that stores all Identifiers with their names in lowercase.
    317334        @return The map
    318335    */
    319     std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern()
     336    std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern()
    320337    {
    321338        static std::map<std::string, Identifier*> lowercaseIdentifierMap;
    322339        return lowercaseIdentifierMap;
     340    }
     341
     342    /**
     343        @brief Returns the map that stores all Identifiers with their network IDs.
     344        @return The map
     345    */
     346    std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern()
     347    {
     348        static std::map<uint32_t, Identifier*> identifierMap;
     349        return identifierMap;
     350    }
     351
     352    /**
     353        @brief Returns the Identifier with a given name.
     354        @param name The name of the wanted Identifier
     355        @return The Identifier
     356    */
     357    Identifier* Identifier::getIdentifierByString(const std::string& name)
     358    {
     359        std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name);
     360        if (it != Identifier::getStringIdentifierMapIntern().end())
     361            return it->second;
     362        else
     363            return 0;
     364    }
     365
     366    /**
     367        @brief Returns the Identifier with a given name in lowercase.
     368        @param name The name of the wanted Identifier
     369        @return The Identifier
     370    */
     371    Identifier* Identifier::getIdentifierByLowercaseString(const std::string& name)
     372    {
     373        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapIntern().find(name);
     374        if (it != Identifier::getLowercaseStringIdentifierMapIntern().end())
     375            return it->second;
     376        else
     377            return 0;
     378    }
     379
     380    /**
     381        @brief Returns the Identifier with a given network ID.
     382        @param id The network ID of the wanted Identifier
     383        @return The Identifier
     384    */
     385    Identifier* Identifier::getIdentifierByID(const uint32_t id)
     386    {
     387        std::map<uint32_t, Identifier*>::const_iterator it = Identifier::getIDIdentifierMapIntern().find(id);
     388        if (it != Identifier::getIDIdentifierMapIntern().end())
     389            return it->second;
     390        else
     391            return 0;
     392    }
     393
     394    /**
     395        @brief Cleans the NetworkID map (needed on clients for correct initialization)
     396    */
     397    void Identifier::clearNetworkIDs()
     398    {
     399        Identifier::getIDIdentifierMapIntern().clear();
    323400    }
    324401
     
    351428        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname);
    352429        if (it != configValues_.end())
    353             return ((*it).second);
     430            return it->second;
    354431        else
    355432            return 0;
     
    365442        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname);
    366443        if (it != configValues_LC_.end())
    367             return ((*it).second);
     444            return it->second;
    368445        else
    369446            return 0;
     
    404481        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);
    405482        if (it != this->consoleCommands_.end())
    406             return (*it).second;
     483            return it->second;
    407484        else
    408485            return 0;
     
    418495        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);
    419496        if (it != this->consoleCommands_LC_.end())
    420             return (*it).second;
     497            return it->second;
    421498        else
    422499            return 0;
     
    432509        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
    433510        if (it != this->xmlportParamContainers_.end())
    434             return ((*it).second);
     511            return it->second;
    435512        else
    436513            return 0;
     
    463540        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
    464541        if (it != this->xmlportObjectContainers_.end())
    465             return ((*it).second);
     542            return it->second;
    466543        else
    467544            return 0;
     
    483560
    484561        this->xmlportObjectContainers_[sectionname] = container;
    485     }
    486 
    487     /**
    488         @brief Returns a XMLPortEventContainer that attaches an event to this class.
    489         @param sectionname The name of the section that contains the event
    490         @return The container
    491     */
    492     XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)
    493     {
    494         std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
    495         if (it != this->xmlportEventContainers_.end())
    496             return ((*it).second);
    497         else
    498             return 0;
    499     }
    500 
    501     /**
    502         @brief Adds a new XMLPortEventContainer that attaches an event to this class.
    503         @param sectionname The name of the section that contains the event
    504         @param container The container
    505     */
    506     void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)
    507     {
    508         std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
    509         if (it != this->xmlportEventContainers_.end())
    510         {
    511             COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;
    512             delete (it->second);
    513         }
    514 
    515         this->xmlportEventContainers_[eventname] = container;
    516562    }
    517563
     
    525571    {
    526572        for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it)
    527             out << (*it)->getName() << " ";
     573        {
     574            if (it != list.begin())
     575                out << " ";
     576            out << (*it)->getName();
     577        }
    528578
    529579        return out;
  • code/branches/pickup/src/libraries/core/Identifier.h

    r5781 r5935  
    2929/**
    3030    @file
    31     @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes.
     31    @brief Definition of the Identifier class, definition and implementation of the ClassIdentifier class.
    3232
    3333    The Identifier contains all needed information about the class it belongs to:
     
    4545
    4646    Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier.
    47 
    48     SubclassIdentifier is a separated class, acting like an Identifier, but has a given class.
    49     You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier.
    5047*/
    5148
     
    9087    class _CoreExport Identifier
    9188    {
    92         template <class T>
    93         friend class SubclassIdentifier;
    94 
    95         friend class Factory;
    96 
    9789        public:
     90            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
     91            inline const std::string& getName() const { return this->name_; }
     92            void setName(const std::string& name);
     93
     94            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
     95            inline const uint32_t getNetworkID() const { return this->networkID_; }
     96            void setNetworkID(uint32_t id);
     97
     98            /** @brief Returns the unique ID of the class */
     99            FORCEINLINE unsigned int getClassID() const { return this->classID_; }
     100
     101            /** @brief Returns the list of all existing objects of this class. @return The list */
     102            inline ObjectListBase* getObjects() const { return this->objects_; }
     103
    98104            /** @brief Sets the Factory. @param factory The factory to assign */
    99             inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
     105            inline void addFactory(Factory* factory) { this->factory_ = factory; }
     106            /** @brief Returns true if the Identifier has a Factory. */
     107            inline bool hasFactory() const { return (this->factory_ != 0); }
    100108
    101109            BaseObject* fabricate(BaseObject* creator);
     110
     111            /** @brief Returns true if the class can be loaded through XML. */
     112            inline bool isLoadable() const { return this->bLoadable_; }
     113            /** @brief Set the class to be loadable through XML or not. */
     114            inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
     115
    102116            bool isA(const Identifier* identifier) const;
    103117            bool isExactlyA(const Identifier* identifier) const;
     
    107121            bool isDirectParentOf(const Identifier* identifier) const;
    108122
    109             /** @brief Returns true if the class can be loaded through XML. */
    110             inline bool isLoadable() const { return this->bLoadable_; }
    111             /** @brief Set the class to be loadable through XML or not. */
    112             inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
    113 
    114             /** @brief Returns the list of all existing objects of this class. @return The list */
    115             inline ObjectListBase* getObjects() const
    116                 { return this->objects_; }
    117 
    118             /** @brief Returns the name of the class the Identifier belongs to. @return The name */
    119             inline const std::string& getName() const { return this->name_; }
    120             void setName(const std::string& name);
    121 
    122             virtual void updateConfigValues(bool updateChildren = true) const = 0;
     123
     124            /////////////////////////////
     125            ////// Class Hierarchy //////
     126            /////////////////////////////
     127            static void createClassHierarchy();
     128
     129            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
     130            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
    123131
    124132            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
     
    130138
    131139            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
    132             inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); }
     140            inline const std::set<const Identifier*>& getChildren() const { return this->children_; }
    133141            /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */
    134             inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }
     142            inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); }
    135143            /** @brief Returns the end-iterator of the children-list. @return The end-iterator */
    136             inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }
     144            inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); }
    137145
    138146            /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */
     
    144152
    145153            /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */
    146             inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }
     154            inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
    147155            /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */
    148             inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); }
     156            inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); }
    149157            /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */
    150             inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
    151 
    152 
    153             /** @brief Returns the map that stores all Identifiers. @return The map */
    154             static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); }
    155             /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */
    156             static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); }
    157             /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */
    158             static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); }
     158            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); }
     159
     160
     161            //////////////////////////
     162            ///// Identifier Map /////
     163            //////////////////////////
     164            static void destroyAllIdentifiers();
     165
     166            static Identifier* getIdentifierByString(const std::string& name);
     167            static Identifier* getIdentifierByLowercaseString(const std::string& name);
     168            static Identifier* getIdentifierByID(uint32_t id);
     169
     170            static void clearNetworkIDs();
     171
     172            /** @brief Returns the map that stores all Identifiers with their names. @return The map */
     173            static inline const std::map<std::string, Identifier*>& getStringIdentifierMap() { return Identifier::getStringIdentifierMapIntern(); }
     174            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. @return The const_iterator */
     175            static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin() { return Identifier::getStringIdentifierMap().begin(); }
     176            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names. @return The const_iterator */
     177            static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd() { return Identifier::getStringIdentifierMap().end(); }
    159178
    160179            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
    161             static inline const std::map<std::string, Identifier*>& getLowercaseIdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }
     180            static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() { return Identifier::getLowercaseStringIdentifierMapIntern(); }
    162181            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
    163             static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }
     182            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() { return Identifier::getLowercaseStringIdentifierMap().begin(); }
    164183            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
    165             static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); }
    166 
     184            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd() { return Identifier::getLowercaseStringIdentifierMap().end(); }
     185
     186            /** @brief Returns the map that stores all Identifiers with their IDs. @return The map */
     187            static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap() { return Identifier::getIDIdentifierMapIntern(); }
     188            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. @return The const_iterator */
     189            static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin() { return Identifier::getIDIdentifierMap().begin(); }
     190            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. @return The const_iterator */
     191            static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd() { return Identifier::getIDIdentifierMap().end(); }
     192
     193
     194            /////////////////////////
     195            ///// Config Values /////
     196            /////////////////////////
     197            virtual void updateConfigValues(bool updateChildren = true) const = 0;
     198
     199            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
     200            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
    167201
    168202            /** @brief Returns the map that stores all config values. @return The const_iterator */
     
    180214            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
    181215
     216            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
     217            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
     218            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
     219
     220
     221            ////////////////////////////
     222            ///// Console Commands /////
     223            ////////////////////////////
     224            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
     225            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
    182226
    183227            /** @brief Returns the map that stores all console commands. @return The const_iterator */
     
    195239            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
    196240
     241            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
     242            ConsoleCommand* getConsoleCommand(const std::string& name) const;
     243            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
     244
     245
     246            ///////////////////
     247            ///// XMLPort /////
     248            ///////////////////
    197249            /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */
    198250            inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; }
     
    209261            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }
    210262
    211             /** @brief Returns the map that stores all XMLPort events. @return The const_iterator */
    212             inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortEventMap() const { return this->xmlportEventContainers_; }
    213             /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort events. @return The const_iterator */
    214             inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapBegin() const { return this->xmlportEventContainers_.begin(); }
    215             /** @brief Returns a const_iterator to the end of the map that stores all XMLPort events. @return The const_iterator */
    216             inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); }
    217 
    218             /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
    219             inline bool hasConfigValues() const { return this->bHasConfigValues_; }
    220             /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
    221             inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
    222 
    223             /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
    224             inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
    225 
    226             /** @brief Returns the network ID to identify a class through the network. @return the network ID */
    227             inline const uint32_t getNetworkID() const { return this->networkID_; }
    228 
    229             /** @brief Sets the network ID to a new value. @param id The new value */
    230             void setNetworkID(uint32_t id);
    231 
    232             /** @brief Returns the unique ID of the class */
    233             FORCEINLINE unsigned int getClassID() const { return this->classID_; }
    234 
    235             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
    236             ConfigValueContainer* getConfigValueContainer(const std::string& varname);
    237             ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
    238 
    239263            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
    240264            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
     
    243267            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
    244268
    245             void addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container);
    246             XMLPortObjectContainer* getXMLPortEventContainer(const std::string& eventname);
    247 
    248             ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
    249             ConsoleCommand* getConsoleCommand(const std::string& name) const;
    250             ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
    251 
    252             void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
    253 
    254             static void destroyAllIdentifiers();
    255269
    256270        protected:
     
    262276            virtual void createSuperFunctionCaller() const = 0;
    263277
    264             /** @brief Returns the map that stores all Identifiers. @return The map */
    265             static std::map<std::string, Identifier*>& getIdentifierMapIntern();
     278            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     279
     280            /** @brief Returns the map that stores all Identifiers with their names. @return The map */
     281            static std::map<std::string, Identifier*>& getStringIdentifierMapIntern();
    266282            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
    267             static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern();
     283            static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern();
     284            /** @brief Returns the map that stores all Identifiers with their network IDs. @return The map */
     285            static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern();
    268286
    269287            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
    270             inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
     288            inline std::set<const Identifier*>& getChildrenIntern() const { return this->children_; }
    271289            /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
    272             inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
     290            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return this->directChildren_; }
    273291
    274292            ObjectListBase* objects_;                                      //!< The list of all objects of this class
    275293
    276294        private:
    277             /**
    278                 @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
    279             */
    280             inline static void startCreatingHierarchy()
    281             {
    282                 hierarchyCreatingCounter_s++;
    283                 COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
    284             }
    285 
    286             /**
    287                 @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
    288             */
    289             inline static void stopCreatingHierarchy()
    290             {
    291                 hierarchyCreatingCounter_s--;
    292                 COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
    293             }
     295            /** @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. */
     296            inline static void startCreatingHierarchy() { hierarchyCreatingCounter_s++; }
     297            /** @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. */
     298            inline static void stopCreatingHierarchy()  { hierarchyCreatingCounter_s--; }
    294299
    295300            static std::map<std::string, Identifier*>& getTypeIDIdentifierMap();
     
    298303
    299304            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
    300             std::set<const Identifier*>* children_;                        //!< The children of the class the Identifier belongs to
     305            mutable std::set<const Identifier*> children_;                 //!< The children of the class the Identifier belongs to
    301306
    302307            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
    303             std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
     308            mutable std::set<const Identifier*> directChildren_;           //!< The direct children of the class the Identifier belongs to
    304309
    305310            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     
    307312            bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
    308313            std::string name_;                                             //!< The name of the class the Identifier belongs to
    309             BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
     314            Factory* factory_;                                             //!< The Factory, able to create new objects of the given class (if available)
    310315            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
    311316            uint32_t networkID_;                                           //!< The network ID to identify a class through the network
     
    323328            std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
    324329            std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_;   //!< All attachable objects
    325             std::map<std::string, XMLPortObjectContainer*> xmlportEventContainers_;    //!< All events
    326330    };
    327331
     
    348352
    349353        public:
    350             static ClassIdentifier<T> *getIdentifier();
    351             static ClassIdentifier<T> *getIdentifier(const std::string& name);
     354            static ClassIdentifier<T>* getIdentifier();
     355            static ClassIdentifier<T>* getIdentifier(const std::string& name);
    352356
    353357            bool initialiseObject(T* object, const std::string& className, bool bRootClass);
     
    380384    inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
    381385    {
    382         // check if the static field has already been filled
    383         if (ClassIdentifier<T>::classIdentifier_s == 0)
     386        // check if the Identifier already exists
     387        if (!ClassIdentifier<T>::classIdentifier_s)
    384388            ClassIdentifier<T>::initialiseIdentifier();
    385389
     
    508512#endif
    509513    }
    510 
    511 
    512     // ###############################
    513     // ###   SubclassIdentifier    ###
    514     // ###############################
    515     //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
    516     /**
    517         You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>.
    518         If you assign something else, the program aborts.
    519         Because we know the minimum type, a dynamic_cast is done, which makes it easier to create a new object.
    520     */
    521     template <class T>
    522     class SubclassIdentifier
    523     {
    524         public:
    525             /**
    526                 @brief Constructor: Automaticaly assigns the Identifier of the given class.
    527             */
    528             SubclassIdentifier()
    529             {
    530                 this->identifier_ = ClassIdentifier<T>::getIdentifier();
    531             }
    532 
    533             /**
    534                 @brief Copyconstructor: Assigns the given Identifier.
    535                 @param identifier The Identifier
    536             */
    537             SubclassIdentifier(Identifier* identifier)
    538             {
    539                 this->operator=(identifier);
    540             }
    541 
    542             /**
    543                 @brief Overloading of the = operator: assigns the identifier and checks its type.
    544                 @param identifier The Identifier to assign
    545                 @return The SubclassIdentifier itself
    546             */
    547             SubclassIdentifier<T>& operator=(Identifier* identifier)
    548             {
    549                 if (!identifier || !identifier->isA(ClassIdentifier<T>::getIdentifier()))
    550                 {
    551                     COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    552                     if (identifier)
    553                     {
    554                         COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
    555                         COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
    556                     }
    557                     else
    558                     {
    559                         COUT(1) << "Error: Can't assign NULL identifier" << std::endl;
    560                     }
    561                 }
    562                 else
    563                 {
    564                     this->identifier_ = identifier;
    565                 }
    566                 return *this;
    567             }
    568 
    569             /**
    570                 @brief Overloading of the * operator: returns the assigned identifier.
    571             */
    572             inline Identifier* operator*() const
    573             {
    574                 return this->identifier_;
    575             }
    576 
    577             /**
    578                 @brief Overloading of the -> operator: returns the assigned identifier.
    579             */
    580             inline Identifier* operator->() const
    581             {
    582                 return this->identifier_;
    583             }
    584 
    585             /**
    586                 @brief Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*.
    587             */
    588             inline operator Identifier*() const
    589             {
    590                 return this->identifier_;
    591             }
    592 
    593             /**
    594                 @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
    595                 @return The new object
    596             */
    597             T* fabricate(BaseObject* creator) const
    598             {
    599                 BaseObject* newObject = this->identifier_->fabricate(creator);
    600 
    601                 // Check if the creation was successful
    602                 if (newObject)
    603                 {
    604                     return orxonox_cast<T*>(newObject);
    605                 }
    606                 else
    607                 {
    608                     // Something went terribly wrong
    609                     if (this->identifier_)
    610                     {
    611                         COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    612                         COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
    613                         COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
    614                         COUT(1) << "Aborting..." << std::endl;
    615                     }
    616                     else
    617                     {
    618                         COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    619                         COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;
    620                         COUT(1) << "Aborting..." << std::endl;
    621                     }
    622 
    623                     assert(false);
    624                     return 0;
    625                 }
    626             }
    627 
    628             /** @brief Returns the assigned identifier. @return The identifier */
    629             inline Identifier* getIdentifier() const
    630                 { return this->identifier_; }
    631 
    632 //            /** @brief Returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
    633 //            inline bool isA(const Identifier* identifier) const
    634 //                { return this->identifier_->isA(identifier); }
    635 //
    636 //            /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
    637 //            inline bool isExactlyA(const Identifier* identifier) const
    638 //                { return this->identifier_->isExactlyA(identifier); }
    639 //
    640 //            /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
    641 //            inline bool isChildOf(const Identifier* identifier) const
    642 //                { return this->identifier_->isChildOf(identifier); }
    643 //
    644 //            /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */
    645 //            inline bool isDirectChildOf(const Identifier* identifier) const
    646 //                { return this->identifier_->isDirectChildOf(identifier); }
    647 //
    648 //            /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
    649 //            inline bool isParentOf(const Identifier* identifier) const
    650 //                { return this->identifier_->isParentOf(identifier); }
    651 //
    652 //            /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */
    653 //            inline bool isDirectParentOf(const Identifier* identifier) const
    654 //                { return this->identifier_->isDirectParentOf(identifier); }
    655 
    656         private:
    657             Identifier* identifier_;            //!< The assigned identifier
    658     };
    659514}
    660515
  • code/branches/pickup/src/libraries/core/Iterator.h

    r5738 r5935  
    167167
    168168                return (*this);
    169                 return *this;
    170169            }
    171170
     
    193192            inline const Iterator<T>& operator++()
    194193            {
    195                 if (this->element_)
    196                     this->element_ = this->element_->next_;
     194                this->element_ = this->element_->next_;
    197195                return *this;
    198196            }
     
    205203            {
    206204                Iterator<T> copy = *this;
    207                 if (this->element_)
    208                     this->element_ = this->element_->next_;
     205                this->element_ = this->element_->next_;
    209206                return copy;
    210207            }
     
    216213            inline const Iterator<T>& operator--()
    217214            {
    218                 if (this->element_)
    219                     this->element_ = this->element_->prev_;
     215                this->element_ = this->element_->prev_;
    220216                return *this;
    221217            }
     
    228224            {
    229225                Iterator<T> copy = *this;
    230                 if (this->element_)
    231                     this->element_ = this->element_->prev_;
     226                this->element_ = this->element_->prev_;
    232227                return copy;
    233228            }
     
    239234            inline T* operator*() const
    240235            {
    241                 if (this->element_)
    242                     return orxonox_cast<T*>(this->element_->objectBase_);
    243                 else
    244                     return 0;
     236                return orxonox_cast<T*>(this->element_->objectBase_);
    245237            }
    246238
     
    251243            inline T* operator->() const
    252244            {
    253                 if (this->element_)
    254                     return orxonox_cast<T*>(this->element_->objectBase_);
    255                 else
    256                     return 0;
     245                return orxonox_cast<T*>(this->element_->objectBase_);
    257246            }
    258247
  • code/branches/pickup/src/libraries/core/Language.cc

    r5738 r5935  
    3535
    3636#include <fstream>
    37 #include <boost/filesystem.hpp>
    38 
    3937#include "util/Debug.h"
    4038#include "Core.h"
     39#include "PathConfig.h"
    4140
    4241namespace orxonox
     
    200199        COUT(4) << "Read default language file." << std::endl;
    201200
    202         boost::filesystem::path filepath(Core::getConfigPath() / getFilename(this->defaultLanguage_));
     201        std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
    203202
    204203        // This creates the file if it's not existing
    205204        std::ofstream createFile;
    206         createFile.open(filepath.string().c_str(), std::fstream::app);
     205        createFile.open(filepath.c_str(), std::fstream::app);
    207206        createFile.close();
    208207
    209208        // Open the file
    210209        std::ifstream file;
    211         file.open(filepath.string().c_str(), std::fstream::in);
     210        file.open(filepath.c_str(), std::fstream::in);
    212211
    213212        if (!file.is_open())
     
    249248        COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
    250249
    251         boost::filesystem::path filepath(Core::getConfigPath() / getFilename(Core::getLanguage()));
     250        std::string filepath = PathConfig::getConfigPathString() + getFilename(Core::getLanguage());
    252251
    253252        // Open the file
    254253        std::ifstream file;
    255         file.open(filepath.string().c_str(), std::fstream::in);
     254        file.open(filepath.c_str(), std::fstream::in);
    256255
    257256        if (!file.is_open())
     
    303302        COUT(4) << "Language: Write default language file." << std::endl;
    304303
    305         boost::filesystem::path filepath(Core::getConfigPath() / getFilename(this->defaultLanguage_));
     304        std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
    306305
    307306        // Open the file
    308307        std::ofstream file;
    309         file.open(filepath.string().c_str(), std::fstream::out);
     308        file.open(filepath.c_str(), std::fstream::out);
    310309
    311310        if (!file.is_open())
  • code/branches/pickup/src/libraries/core/Loader.cc

    r5781 r5935  
    103103        {
    104104            if (mask.isIncluded(it->getIdentifier()))
    105                 delete (*(it++));
     105                (it++)->destroy();
    106106            else
    107107                ++it;
     
    204204        {
    205205            if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier()))
    206                 delete (*(it++));
     206                (it++)->destroy();
    207207            else
    208208                ++it;
  • code/branches/pickup/src/libraries/core/LuaState.cc

    r5781 r5935  
    3737
    3838#include "util/Debug.h"
    39 #include "Core.h"
    4039#include "Resource.h"
    4140#include "ToluaBindCore.h"
  • code/branches/pickup/src/libraries/core/MemoryArchive.cc

    r5781 r5935  
    6868                continue;
    6969            if (bDirs)
    70                 file = file.parent_path();
     70                file = file.branch_path();
    7171            if (file.empty())
    7272                continue;
    73             if (file.has_parent_path() && !bRecursive)
     73            if (file.has_branch_path() && !bRecursive)
    7474                continue;
    7575            if (simpleList)
     
    8080                fi.archive = this;
    8181                fi.filename = file.string();
    82                 fi.basename = file.filename();
    83                 fi.path = file.parent_path().string();
     82                fi.basename = file.leaf();
     83                fi.path = file.branch_path().string();
    8484                fi.compressedSize = it->second.second;
    8585                fi.uncompressedSize = it->second.second;
     
    119119
    120120    bool MemoryArchive::exists(const String& filename)
    121         {
     121    {
    122122        const FileMap& files = archives_s[this->getName()];
    123123        return files.find(filename) != files.end();
    124         }
     124    }
    125125
    126126    const Ogre::String& MemoryArchiveFactory::getType(void) const
  • code/branches/pickup/src/libraries/core/ObjectListIterator.h

    r5738 r5935  
    123123            inline const ObjectListIterator<T>& operator++()
    124124            {
    125                 if (this->element_)
    126                     this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
     125                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
    127126                return *this;
    128127            }
     
    135134            {
    136135                ObjectListIterator<T> copy = *this;
    137                 if (this->element_)
    138                     this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
     136                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
    139137                return copy;
    140138            }
     
    146144            inline const ObjectListIterator<T>& operator--()
    147145            {
    148                 if (this->element_)
    149                     this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
     146                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
    150147                return *this;
    151148            }
     
    158155            {
    159156                ObjectListIterator<T> copy = *this;
    160                 if (this->element_)
    161                     this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
     157                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
    162158                return copy;
    163159            }
     
    169165            inline T* operator*() const
    170166            {
    171                 if (this->element_)
    172                     return this->element_->object_;
    173                 else
    174                     return 0;
     167                return this->element_->object_;
    175168            }
    176169
     
    181174            inline T* operator->() const
    182175            {
    183                 if (this->element_)
    184                     return this->element_->object_;
    185                 else
    186                     return 0;
     176                return this->element_->object_;
    187177            }
    188178
  • code/branches/pickup/src/libraries/core/OrxonoxClass.cc

    r5738 r5935  
    3636#include "MetaObjectList.h"
    3737#include "Identifier.h"
     38#include "WeakPtr.h"
    3839
    3940namespace orxonox
     
    4546        this->parents_ = 0;
    4647        this->metaList_ = new MetaObjectList();
     48        this->referenceCount_ = 0;
     49        this->requestedDestruction_ = false;
    4750    }
    4851
     
    5053    OrxonoxClass::~OrxonoxClass()
    5154    {
     55//        if (!this->requestedDestruction_)
     56//            COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl;
     57
     58        assert(this->referenceCount_ <= 0);
     59
    5260        delete this->metaList_;
    5361
     
    5563        if (this->parents_)
    5664            delete this->parents_;
     65           
     66        // reset all weak pointers pointing to this object
     67        for (std::set<WeakPtr<OrxonoxClass>*>::iterator it = this->weakPointers_.begin(); it != this->weakPointers_.end(); )
     68            (*(it++))->objectDeleted();
     69    }
     70
     71    /** @brief Deletes the object if no smart pointers point to this object. Otherwise schedules the object to be deleted as soon as possible. */
     72    void OrxonoxClass::destroy()
     73    {
     74        this->requestedDestruction_ = true;
     75        if (this->referenceCount_ == 0)
     76            delete this;
    5777    }
    5878
     
    7898
    7999    /** @brief Returns true if the objects class is of the given type or a derivative. */
    80     template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B>* identifier)
    81         { return this->getIdentifier()->isA(identifier->getIdentifier()); }
    82     /** @brief Returns true if the objects class is exactly of the given type. */
    83     template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B>* identifier)
    84         { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
    85     /** @brief Returns true if the objects class is a child of the given type. */
    86     template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B>* identifier)
    87         { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
    88     /** @brief Returns true if the objects class is a direct child of the given type. */
    89     template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B>* identifier)
    90         { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
    91     /** @brief Returns true if the objects class is a parent of the given type. */
    92     template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B>* identifier)
    93         { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
    94     /** @brief Returns true if the objects class is a direct parent of the given type. */
    95     template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B>* identifier)
    96         { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
    97 
    98 
    99     /** @brief Returns true if the objects class is of the given type or a derivative. */
    100     template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B> identifier)
    101         { return this->getIdentifier()->isA(identifier.getIdentifier()); }
    102     /** @brief Returns true if the objects class is exactly of the given type. */
    103     template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B> identifier)
    104         { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
    105     /** @brief Returns true if the objects class is a child of the given type. */
    106     template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B> identifier)
    107         { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
    108     /** @brief Returns true if the objects class is a direct child of the given type. */
    109     template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B> identifier)
    110         { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
    111     /** @brief Returns true if the objects class is a parent of the given type. */
    112     template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B> identifier)
    113         { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
    114     /** @brief Returns true if the objects class is a direct parent of the given type. */
    115     template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B> identifier)
    116         { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
    117 
    118 
    119     /** @brief Returns true if the objects class is of the given type or a derivative. */
    120100    bool OrxonoxClass::isA(const OrxonoxClass* object)
    121101        { return this->getIdentifier()->isA(object->getIdentifier()); }
  • code/branches/pickup/src/libraries/core/OrxonoxClass.h

    r5738 r5935  
    5555        friend class ClassIdentifier;
    5656
     57        template <class T>
     58        friend class SmartPtr;
     59
     60        template <class T>
     61        friend class WeakPtr;
     62
    5763        public:
    5864            OrxonoxClass();
    5965            virtual ~OrxonoxClass();
     66
     67            void destroy();
    6068
    6169            /** @brief Function to collect the SetConfigValue-macro calls. */
     
    7280            bool isDirectParentOf(const Identifier* identifier);
    7381
    74             template <class B> bool isA(const SubclassIdentifier<B>* identifier);
    75             template <class B> bool isExactlyA(const SubclassIdentifier<B>* identifier);
    76             template <class B> bool isChildOf(const SubclassIdentifier<B>* identifier);
    77             template <class B> bool isDirectChildOf(const SubclassIdentifier<B>* identifier);
    78             template <class B> bool isParentOf(const SubclassIdentifier<B>* identifier);
    79             template <class B> bool isDirectParentOf(const SubclassIdentifier<B>* identifier);
    80 
    81             template <class B> bool isA(const SubclassIdentifier<B> identifier);
    82             template <class B> bool isExactlyA(const SubclassIdentifier<B> identifier);
    83             template <class B> bool isChildOf(const SubclassIdentifier<B> identifier);
    84             template <class B> bool isDirectChildOf(const SubclassIdentifier<B> identifier);
    85             template <class B> bool isParentOf(const SubclassIdentifier<B> identifier);
    86             template <class B> bool isDirectParentOf(const SubclassIdentifier<B> identifier);
     82            template <class B> inline bool isA(const SubclassIdentifier<B>* identifier)
     83                { return this->isA(*identifier); }
     84            template <class B> inline bool isExactlyA(const SubclassIdentifier<B>* identifier)
     85                { return this->isExactlyA(*identifier); }
     86            template <class B> inline bool isChildOf(const SubclassIdentifier<B>* identifier)
     87                { return this->isChildOf(*identifier); }
     88            template <class B> inline bool isDirectChildOf(const SubclassIdentifier<B>* identifier)
     89                { return this->isDirectChildOf(*identifier); }
     90            template <class B> inline bool isParentOf(const SubclassIdentifier<B>* identifier)
     91                { return this->isParentOf(*identifier); }
     92            template <class B> inline bool isDirectParentOf(const SubclassIdentifier<B>* identifier)
     93                { return this->isDirectParentOf(*identifier); }
    8794
    8895            bool isA(const OrxonoxClass* object);
     
    93100            bool isDirectParentOf(const OrxonoxClass* object);
    94101
     102            inline unsigned int getReferenceCount() const
     103                { return this->referenceCount_; }
     104
    95105            /**
    96106            @brief
     
    100110                Returns NULL if the no pointer was found.
    101111            */
    102             template <class T>
    103             FORCEINLINE T* getDerivedPointer(unsigned int classID)
     112            FORCEINLINE void* getDerivedPointer(unsigned int classID)
    104113            {
    105114                for (int i = this->objectPointers_.size() - 1; i >= 0; --i)
    106115                {
    107116                    if (this->objectPointers_[i].first == classID)
    108                         return static_cast<T*>(this->objectPointers_[i].second);
     117                        return this->objectPointers_[i].second;
    109118                }
    110119                return NULL;
    111120            }
    112             //! Const version of getDerivedPointer
    113             template <class T>
    114             FORCEINLINE const T* getDerivedPointer(unsigned int classID) const
    115             {
    116                 return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID);
    117             }
     121
     122            //! Version of getDerivedPointer with template
     123            template <class T> FORCEINLINE T* getDerivedPointer(unsigned int classID)
     124            {   return static_cast<T*>(this->getDerivedPointer(classID));   }
     125            //! Const version of getDerivedPointer with template
     126            template <class T> FORCEINLINE const T* getDerivedPointer(unsigned int classID) const
     127            {   return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID);   }
    118128
    119129        private:
     130            /** @brief Increments the reference counter (for smart pointers). */
     131            inline void incrementReferenceCount()
     132                { ++this->referenceCount_; }
     133            /** @brief Decrements the reference counter (for smart pointers). */
     134            inline void decrementReferenceCount()
     135                { --this->referenceCount_; if (this->referenceCount_ == 0 && this->requestedDestruction_) { delete this; } }
     136               
     137            /** @brief Register a weak pointer which points to this object. */
     138            template <class T>
     139            inline void registerWeakPtr(WeakPtr<T>* pointer)
     140                { this->weakPointers_.insert(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); }
     141            /** @brief Unegister a weak pointer which pointed to this object before. */
     142            template <class T>
     143            inline void unregisterWeakPtr(WeakPtr<T>* pointer)
     144                { this->weakPointers_.erase(reinterpret_cast<WeakPtr<OrxonoxClass>*>(pointer)); }
     145
    120146            Identifier* identifier_;                   //!< The Identifier of the object
    121147            std::set<const Identifier*>* parents_;     //!< List of all parents of the object
    122148            MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     149            int referenceCount_;                       //!< Counts the references from smart pointers to this object
     150            bool requestedDestruction_;                //!< Becomes true after someone called delete on this object
     151            std::set<WeakPtr<OrxonoxClass>*> weakPointers_; //!< All weak pointers which point to this object (and like to get notified if it dies)
     152
    123153            //! 'Fast map' that holds this-pointers of all derived types
    124154            std::vector<std::pair<unsigned int, void*> > objectPointers_;
  • code/branches/pickup/src/libraries/core/Resource.h

    r5781 r5935  
    6464        // Docs by Ogre::ResourceGroupManager.h
    6565    public:
    66                 /**
     66        /**
    6767        @brief
    6868            Open a single resource by name and return a DataStream
     
    8181            Shared pointer to data stream containing the data. Will be
    8282            destroyed automatically when no longer referenced.
    83                 */
     83        */
    8484        static DataStreamPtr open(const std::string& name,
    8585            const std::string& group = Resource::DEFAULT_GROUP,
    8686            bool bSearchGroupsIfNotFound = false);
    8787
    88                 /**
     88        /**
    8989        @brief
    9090            Open all resources matching a given pattern (which can contain
     
    101101            Shared pointer to a data stream list , will be
    102102            destroyed automatically when no longer referenced
    103                 */
     103        */
    104104        static DataStreamListPtr openMulti(const std::string& pattern, const std::string& group = Resource::DEFAULT_GROUP);
    105105
  • code/branches/pickup/src/libraries/core/Shell.cc

    r5781 r5935  
    8888        OutputHandler::getOutStream().setOutputBuffer(0);
    8989        if (this->inputBuffer_)
    90             delete this->inputBuffer_;
     90            this->inputBuffer_->destroy();
    9191    }
    9292
  • code/branches/pickup/src/libraries/core/Super.h

    r5781 r5935  
    250250        SUPER_NOARGS(classname, functionname)
    251251
    252     #define SUPER_processEvent(classname, functionname, ...) \
     252    #define SUPER_XMLEventPort(classname, functionname, ...) \
    253253        SUPER_ARGS(classname, functionname, __VA_ARGS__)
    254254
    255255    #define SUPER_changedScale(classname, functionname, ...) \
    256         SUPER_NOARGS(classname, functionname)
    257 
    258     #define SUPER_changedMainState(classname, functionname, ...) \
    259256        SUPER_NOARGS(classname, functionname)
    260257
     
    497494        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    498495
    499         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, processEvent, true, Event& event)
    500             (event)
     496        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, XMLEventPort, true, Element& xmlelement, XMLPort::Mode mode)
     497            (xmlelement, mode)
    501498        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    502499
     
    505502        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    506503
    507         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedMainState, false)
    508             ()
    509         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    510 
    511         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOwner, false)
    512             ()
    513         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    514 
    515         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedOverlayGroup, false)
    516             ()
    517         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    518 
    519         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedName, false)
    520             ()
    521         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    522 
    523         SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedGametype, false)
     504        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedOwner, false)
     505            ()
     506        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     507
     508        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOverlayGroup, false)
     509            ()
     510        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     511
     512        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedName, false)
     513            ()
     514        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     515
     516        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
    524517            ()
    525518        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     
    571564    SUPER_INTRUSIVE_DECLARATION(changedActivity);
    572565    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
    573     SUPER_INTRUSIVE_DECLARATION(processEvent);
     566    SUPER_INTRUSIVE_DECLARATION(XMLEventPort);
    574567    SUPER_INTRUSIVE_DECLARATION(changedScale);
    575     SUPER_INTRUSIVE_DECLARATION(changedMainState);
    576568    SUPER_INTRUSIVE_DECLARATION(changedOwner);
    577569    SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
  • code/branches/pickup/src/libraries/core/TclBind.cc

    r5781 r5935  
    3939#include "CommandExecutor.h"
    4040#include "ConsoleCommand.h"
    41 #include "Core.h"
     41#include "PathConfig.h"
    4242#include "TclThreadManager.h"
    4343
     
    123123    {
    124124#ifdef DEPENDENCY_PACKAGE_ENABLE
    125         if (Core::isDevelopmentRun())
     125        if (PathConfig::isDevelopmentRun())
    126126            return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl");
    127127        else
    128             return (Core::getRootPathString() + "lib/tcl");
     128            return (PathConfig::getRootPathString() + "lib/tcl");
    129129#else
    130130        return "";
  • code/branches/pickup/src/libraries/core/TclThreadManager.cc

    r5781 r5935  
    3636#include <cpptcl/cpptcl.h>
    3737
     38#include "util/Clock.h"
    3839#include "util/Convert.h"
    3940#include "util/Exception.h"
    40 #include "Clock.h"
    4141#include "CommandExecutor.h"
    4242#include "ConsoleCommand.h"
  • code/branches/pickup/src/libraries/core/XMLPort.h

    r5781 r5935  
    5151#include "util/MultiType.h"
    5252#include "util/OrxAssert.h"
    53 #include "Factory.h"
    5453#include "Identifier.h"
    5554#include "Executor.h"
     
    377376                            this->owner_->xmlAttributes_.clear();
    378377                            // Iterate through the attributes manually in order to make them case insensitive
    379                             Attribute* attribute = xmlelement.FirstAttribute(false);
     378                            ticpp::Attribute* attribute = xmlelement.FirstAttribute(false);
    380379                            while (attribute != 0)
    381380                            {
     
    412411                    }
    413412                }
    414                 else
     413                else if (mode == XMLPort::SaveObject)
    415414                {
    416415                    if (this->saveexecutor_)
     
    548547                            for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
    549548                            {
    550                                 Identifier* identifier = Factory::getIdentifier(child->Value());
     549                                Identifier* identifier = Identifier::getIdentifierByString(child->Value());
    551550                                if (identifier)
    552551                                {
     
    629628                    }
    630629                }
    631                 else
     630                else if (mode == XMLPort::SaveObject)
    632631                {
    633632                }
  • code/branches/pickup/src/libraries/core/input/Button.cc

    r5781 r5935  
    170170
    171171                // evaluate the command
    172                 CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
     172                const CommandEvaluation& eval = CommandExecutor::evaluate(commandStr);
    173173                if (!eval.isValid())
    174174                {
    175                     parseError("Command evaluation failed.", true);
     175                    parseError("Command evaluation of \"" + commandStr + "\"failed.", true);
    176176                    continue;
    177177                }
  • code/branches/pickup/src/libraries/core/input/CMakeLists.txt

    r5781 r5935  
    99  JoyStickQuantityListener.cc
    1010  KeyBinder.cc
     11  KeyBinderManager.cc
    1112  Keyboard.cc
    1213  KeyDetector.cc
  • code/branches/pickup/src/libraries/core/input/InputDevice.h

    r5781 r5935  
    4141#include <ois/OISInputManager.h>
    4242
     43#include "util/Clock.h"
    4344#include "util/Debug.h"
    4445#include "util/Exception.h"
    45 #include "core/Clock.h"
    4646#include "InputState.h"
    4747
  • code/branches/pickup/src/libraries/core/input/InputManager.cc

    r5781 r5935  
    4141#include <boost/foreach.hpp>
    4242
     43#include "util/Clock.h"
    4344#include "util/Convert.h"
    4445#include "util/Exception.h"
    4546#include "util/ScopeGuard.h"
    46 #include "core/Clock.h"
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
     
    5353
    5454#include "InputBuffer.h"
    55 #include "KeyDetector.h"
    5655#include "JoyStick.h"
    5756#include "JoyStickQuantityListener.h"
     
    8887        , oisInputManager_(0)
    8988        , devices_(2)
    90         , bExclusiveMouse_(false)
     89        , mouseMode_(MouseMode::Nonexclusive)
    9190        , emptyState_(0)
    92         , keyDetector_(0)
    9391        , calibratorCallbackHandler_(0)
    9492    {
     
    9997        this->setConfigValues();
    10098
     99        if (GraphicsManager::getInstance().isFullScreen())
     100            mouseMode_ = MouseMode::Exclusive;
    101101        this->loadDevices();
    102102
     
    105105        emptyState_->setHandler(&InputHandler::EMPTY);
    106106        activeStates_[emptyState_->getPriority()] = emptyState_;
    107 
    108         // KeyDetector to evaluate a pressed key's name
    109         InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
    110         // Create a callback to avoid buttonHeld events after the key has been detected
    111         FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);
    112         bufferFunctor->setObject(this);
    113         detector->setLeaveFunctor(bufferFunctor);
    114         keyDetector_ = new KeyDetector();
    115         detector->setHandler(keyDetector_);
    116107
    117108        // Joy stick calibration helper callback
     
    124115        this->updateActiveStates();
    125116
    126         {
    127             // calibrate console command
    128             FunctorMember<InputManager>* functor = createFunctor(&InputManager::calibrate);
    129             functor->setObject(this);
    130             this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "calibrate"), true);
    131         }
    132         {
    133             // reload console command
    134             FunctorMember<InputManager>* functor = createFunctor(&InputManager::reload);
    135             functor->setObject(this);
    136             this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "reload"), false);
    137         }
     117        // calibrate console command
     118        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true);
     119        // reload console command
     120        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false);
    138121
    139122        CCOUT(4) << "Construction complete." << std::endl;
     
    172155        paramList.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND"));
    173156        paramList.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND"));
    174         if (bExclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
     157        if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
    175158        {
    176159            // Disable Windows key plus special keys (like play, stop, next, etc.)
     
    185168        paramList.insert(std::make_pair("XAutoRepeatOn", "true"));
    186169
    187         if (bExclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
     170        if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
    188171        {
    189172            if (CommandLine::getValue("keyboard_no_grab").getBool())
     
    274257    }
    275258
    276     void InputManager::setKeyDetectorCallback(const std::string& command)
    277     {
    278         this->keyDetector_->setCallbackCommand(command);
    279     }
    280 
    281259    // ############################################################
    282260    // #####                    Destruction                   #####
     
    289267
    290268        // Destroy calibrator helper handler and state
    291         delete keyDetector_;
    292269        this->destroyState("calibrator");
    293270        // Destroy KeyDetector and state
    294         delete calibratorCallbackHandler_;
    295         this->destroyState("detector");
     271        calibratorCallbackHandler_->destroy();
    296272        // destroy the empty InputState
    297273        this->destroyStateInternal(this->emptyState_);
     
    528504
    529505        // Check whether we have to change the mouse mode
     506        MouseMode::Value requestedMode = MouseMode::Dontcare;
    530507        std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
    531         if (mouseStates.empty() && bExclusiveMouse_ ||
    532             !mouseStates.empty() && mouseStates.front()->getIsExclusiveMouse() != bExclusiveMouse_)
    533         {
    534             bExclusiveMouse_ = !bExclusiveMouse_;
     508        if (mouseStates.empty())
     509            requestedMode = MouseMode::Nonexclusive;
     510        else
     511            requestedMode = mouseStates.front()->getMouseMode();
     512        if (requestedMode != MouseMode::Dontcare && mouseMode_ != requestedMode)
     513        {
     514            mouseMode_ = requestedMode;
    535515            if (!GraphicsManager::getInstance().isFullScreen())
    536516                this->reloadInternal();
     
    722702        }
    723703        statesByName_.erase(state->getName());
    724         delete state;
     704        state->destroy();
    725705    }
    726706}
  • code/branches/pickup/src/libraries/core/input/InputManager.h

    r5781 r5935  
    161161        // Various getters and setters
    162162        //-------------------------------
    163         //! Sets the the name of the command used by the KeyDetector as callback.
    164         void setKeyDetectorCallback(const std::string& command);
    165163        //! Returns the number of joy stick that have been created since the c'tor or last call to reload().
    166164        unsigned int getJoyStickQuantity() const
     
    193191        OIS::InputManager*                  oisInputManager_;      //!< OIS input manager
    194192        std::vector<InputDevice*>           devices_;              //!< List of all input devices (keyboard, mouse, joy sticks)
    195         bool                                bExclusiveMouse_;      //!< Currently applied mouse mode
     193        MouseMode::Value                    mouseMode_;            //!< Currently applied mouse mode
    196194
    197195        // some internally handled states and handlers
    198196        InputState*                         emptyState_;           //!< Lowest priority states (makes handling easier)
    199         KeyDetector*                        keyDetector_;          //!< KeyDetector instance
    200197        //! InputBuffer that reacts to the Enter key when calibrating the joy sticks
    201198        InputBuffer*                        calibratorCallbackHandler_;
  • code/branches/pickup/src/libraries/core/input/InputState.cc

    r5781 r5935  
    3737        , bAlwaysGetsInput_(bAlwaysGetsInput)
    3838        , bTransparent_(bTransparent)
    39         , bExclusiveMouse_(true)
     39        , mouseMode_(MouseMode::Dontcare)
    4040        , bExpired_(true)
    4141        , handlers_(2)
  • code/branches/pickup/src/libraries/core/input/InputState.h

    r5781 r5935  
    5555        static const int Detector     = HighPriority + 2;
    5656    };
     57
     58    namespace MouseMode
     59    {
     60        enum Value
     61        {
     62            Exclusive,
     63            Nonexclusive,
     64            Dontcare
     65        };
     66    }
    5767
    5868    /**
     
    120130        void setHandler        (InputHandler* handler);
    121131
    122         void setIsExclusiveMouse(bool value) { bExclusiveMouse_ = value; this->bExpired_ = true; }
    123         bool getIsExclusiveMouse() const { return bExclusiveMouse_; }
     132        void setMouseMode(MouseMode::Value value) { mouseMode_ = value; this->bExpired_ = true; }
     133        MouseMode::Value getMouseMode() const { return mouseMode_; }
    124134
    125135        //! Returns the name of the state (which is unique!)
     
    174184        const bool                  bAlwaysGetsInput_;      //!< See class declaration for explanation
    175185        const bool                  bTransparent_;          //!< See class declaration for explanation
    176         bool                        bExclusiveMouse_;       //!< See class declaration for explanation
     186        MouseMode::Value            mouseMode_;             //!< See class declaration for explanation
    177187        int                         priority_;              //!< Current priority (might change)
    178188        bool                        bExpired_;              //!< See hasExpired()
  • code/branches/pickup/src/libraries/core/input/KeyBinder.cc

    r5781 r5935  
    2727 */
    2828
    29 /**
    30  @file
    31  @brief Implementation of the different input handlers.
    32  */
    33 
    3429#include "KeyBinder.h"
    3530
    3631#include "util/Convert.h"
    3732#include "util/Debug.h"
     33#include "util/Exception.h"
    3834#include "core/ConfigValueIncludes.h"
    3935#include "core/CoreIncludes.h"
     
    4844        Constructor that does as little as necessary.
    4945    */
    50     KeyBinder::KeyBinder()
     46    KeyBinder::KeyBinder(const std::string& filename)
    5147        : deriveTime_(0.0f)
     48        , filename_(filename)
    5249    {
    5350        mouseRelative_[0] = 0;
     
    103100        // set them here to use allHalfAxes_
    104101        setConfigValues();
     102
     103        // Load the bindings if filename was given
     104        if (!this->filename_.empty())
     105            this->loadBindings();
    105106    }
    106107
     
    240241    @brief
    241242        Loads the key and button bindings.
    242     @return
    243         True if loading succeeded.
    244     */
    245     void KeyBinder::loadBindings(const std::string& filename)
     243    */
     244    void KeyBinder::loadBindings()
    246245    {
    247246        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
    248247
    249         if (filename.empty())
    250             return;
    251 
    252         if (this->configFile_ == ConfigFileType::NoType)
    253         {
    254             // Get a new ConfigFileType from the ConfigFileManager
    255             this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
    256         }
    257 
    258         ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
     248        // Get a new ConfigFileType from the ConfigFileManager
     249        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
     250
     251        ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_);
    259252
    260253        // Parse bindings and create the ConfigValueContainers if necessary
    261         clearBindings();
    262254        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    263255            it->second->readConfigValue(this->configFile_);
  • code/branches/pickup/src/libraries/core/input/KeyBinder.h

    r5781 r5935  
    2626 *
    2727 */
    28 
    29 /**
    30 @file
    31 @brief
    32     Different definitions of input processing.
    33 */
    3428
    3529#ifndef _KeyBinder_H__
     
    5347    /**
    5448    @brief
    55         Handles mouse, keyboard and joy stick input while in the actual game mode.
    56         Manages the key bindings.
     49        Maps mouse, keyboard and joy stick input to command strings and executes them.
     50
     51        The bindings are stored in ini-files (like the one for configValues) in the config Path.
     52    @remarks
     53        You cannot change the filename because the KeyBinderManager maps these filenames to the
     54        KeyBinders. If you need to load other bindings, just create a new one.
    5755    */
    5856    class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener
    5957    {
    6058    public:
    61         KeyBinder ();
     59        KeyBinder (const std::string& filename);
    6260        virtual ~KeyBinder();
    6361
    64         void loadBindings(const std::string& filename);
    6562        void clearBindings();
    6663        bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
     64        const std::string& getBindingsFilename()
     65            { return this->filename_; }
    6766        void setConfigValues();
    6867        void resetJoyStickAxes();
    6968
    7069    protected: // functions
     70        void loadBindings();
     71        void buttonThresholdChanged();
     72        void initialiseJoyStickBindings();
     73        void compilePointerLists();
     74        // from JoyStickQuantityListener interface
     75        virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
     76
    7177        void allDevicesUpdated(float dt);
    7278        void mouseUpdated(float dt);
     
    7480        // internal
    7581        void tickHalfAxis(HalfAxis& halfAxis);
    76 
    77         void buttonThresholdChanged();
    78         // from JoyStickQuantityListener interface
    79         virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
    80         void initialiseJoyStickBindings();
    81         void compilePointerLists();
    8282
    8383        void buttonPressed (const KeyEvent& evt);
     
    144144        float deriveTime_;
    145145
     146        //! Name of the file used in this KeyBinder (constant!)
     147        const std::string filename_;
    146148        //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
    147149        ConfigFileType configFile_;
     
    171173    };
    172174
     175
    173176    inline void KeyBinder::buttonPressed (const KeyEvent& evt)
    174177    { assert(!keys_[evt.getKeyCode()].name_.empty()); keys_[evt.getKeyCode()].execute(KeybindMode::OnPress); }
  • code/branches/pickup/src/libraries/core/input/KeyDetector.cc

    r5781 r5935  
    2929#include "KeyDetector.h"
    3030
    31 #include "util/Debug.h"
     31#include "core/ConsoleCommand.h"
    3232#include "core/CoreIncludes.h"
     33#include "core/ScopedSingletonManager.h"
    3334#include "Button.h"
     35#include "InputManager.h"
     36#include "InputState.h"
    3437
    3538namespace orxonox
    3639{
    37     /**
    38     @brief
    39         Constructor
    40     */
     40    std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
     41    KeyDetector* KeyDetector::singletonPtr_s = 0;
     42    ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
     43
    4144    KeyDetector::KeyDetector()
     45        : KeyBinder("")
    4246    {
    4347        RegisterObject(KeyDetector);
     48
     49        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
     50        this->assignCommands();
     51
     52        inputState_ = InputManager::getInstance().createInputState("detector", false, false, InputStatePriority::Detector);
     53        // Create a callback to avoid buttonHeld events after the key has been detected
     54        inputState_->setLeaveFunctor(createFunctor(&InputManager::clearBuffers, &InputManager::getInstance()));
     55        inputState_->setHandler(this);
    4456    }
    4557
    46     /**
    47     @brief
    48         Destructor
    49     */
    5058    KeyDetector::~KeyDetector()
    5159    {
     60        inputState_->setHandler(NULL);
     61        InputManager::getInstance().destroyState("detector");
    5262    }
    5363
    54     /**
    55     @brief
    56         Assigns all the buttons 'command' plus the button's name.
    57     */
    58     void KeyDetector::setCallbackCommand(const std::string& command)
     64    void KeyDetector::assignCommands()
    5965    {
    60         callbackCommand_ = command;
     66        // Assign every button/axis the same command, but with its name as argument
    6167        clearBindings();
    6268        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    6369        {
    64             it->second->bindingString_ = callbackCommand_ + it->second->groupName_ + "." + it->second->name_;
     70            it->second->bindingString_ = callbackCommand_s + " " + it->second->groupName_ + "." + it->second->name_;
    6571            it->second->parse();
    6672        }
     73    }
     74
     75    void KeyDetector::callback(const std::string& name)
     76    {
     77        // Call the registered function
     78        if (this->callbackFunction_)
     79            (*this->callbackFunction_)(name);
    6780    }
    6881
     
    7083    {
    7184        KeyBinder::JoyStickQuantityChanged(joyStickList);
    72         if (!callbackCommand_.empty())
    73             setCallbackCommand(callbackCommand_);
     85        this->assignCommands();
    7486    }
    7587}
  • code/branches/pickup/src/libraries/core/input/KeyDetector.h

    r5781 r5935  
    3232#include "InputPrereqs.h"
    3333
    34 #include <string>
     34#include "util/Singleton.h"
    3535#include "KeyBinder.h"
    3636
    3737namespace orxonox
    3838{
    39     class _CoreExport KeyDetector : public KeyBinder
     39    class _CoreExport KeyDetector : public KeyBinder, public Singleton<KeyDetector>
    4040    {
     41        friend class Singleton<KeyDetector>;
     42
    4143    public:
    4244        KeyDetector();
    4345        ~KeyDetector();
    44         void setCallbackCommand(const std::string& command);
    45         void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
     46
     47        void setCallback(Functor* function) { this->callbackFunction_ = function; }
    4648
    4749    private:
    48         std::string callbackCommand_;
     50        KeyDetector(const KeyDetector&);
     51
     52        void callback(const std::string& name);
     53        void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
     54        void assignCommands();
     55
     56        Functor* callbackFunction_;
     57        InputState* inputState_;
     58        static std::string callbackCommand_s;
     59        static KeyDetector* singletonPtr_s;
    4960    };
    5061}
  • code/branches/pickup/src/libraries/core/input/Mouse.cc

    r5781 r5935  
    4848
    4949#ifdef ORXONOX_PLATFORM_LINUX
    50         {
    51             // Mouse grab console command
    52             FunctorMember<Mouse>* functor = createFunctor(&Mouse::grab);
    53             functor->setObject(this);
    54             this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "grab"), false);
    55         }
    56         {
    57             // Mouse ungrab console command
    58             FunctorMember<Mouse>* functor = createFunctor(&Mouse::ungrab);
    59             functor->setObject(this);
    60             this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "ungrab"), false);
    61         }
     50        // Mouse grab console command
     51        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::grab, this), "grab"), false);
     52        // Mouse ungrab console command
     53        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::ungrab, this), "ungrab"), false);
    6254#endif
    6355    }
  • code/branches/pickup/src/libraries/network/Client.cc

    r5781 r5935  
    4343#include <cassert>
    4444
     45#include "util/Clock.h"
    4546#include "util/Debug.h"
    46 #include "core/Clock.h"
    4747#include "synchronisable/Synchronisable.h"
    4848#include "packet/Chat.h"
    4949#include "packet/Gamestate.h"
    5050#include "FunctionCallManager.h"
     51#include "core/CoreIncludes.h"
     52#include "core/Game.h"
    5153
    5254namespace orxonox
     
    158160    return;
    159161  }
     162 
     163  void Client::connectionClosed()
     164  {
     165    ObjectList<Synchronisable>::iterator it;
     166    for(it = ObjectList<Synchronisable>::begin(); it; )
     167    {
     168      if( it->getSyncMode() != 0x0 )
     169        (it++)->destroy();
     170      else
     171      {
     172        ++it;
     173      }
     174    }
     175    Game::getInstance().popState();
     176    Game::getInstance().popState();
     177  }
    160178
    161179}
  • code/branches/pickup/src/libraries/network/Client.h

    r5781 r5935  
    4545
    4646#include <string>
     47
     48#include "util/UtilPrereqs.h"
    4749#include "ClientConnection.h"
    4850#include "GamestateClient.h"
     
    7274
    7375    void update(const Clock& time);
    74 
     76  protected:
     77    virtual void connectionClosed();
    7578  private:
    7679    Client(const Client& copy); // not used
  • code/branches/pickup/src/libraries/network/ClientConnection.cc

    r5781 r5935  
    118118          case ENET_EVENT_TYPE_DISCONNECT:
    119119            COUT(4) << "received disconnect confirmation from server" << endl;
     120            this->connectionClosed();
    120121            return true;
    121122        }
     
    123124    }
    124125    enet_peer_reset( this->server_ );
     126    this->connectionClosed();
    125127    return false;
    126128  }
     
    133135  }
    134136
    135   void ClientConnection::addClient(ENetEvent* event)
     137  void ClientConnection::addPeer(ENetEvent* event)
    136138  {
    137139    assert(0);
    138140  }
    139   void ClientConnection::disconnectPeer(ENetEvent* event)
     141  void ClientConnection::removePeer(ENetEvent* event)
    140142  {
    141143    this->established_=false;
    142144    COUT(1) << "Received disconnect Packet from Server!" << endl;
    143145        // server closed the connection
     146    this->connectionClosed();
    144147  }
    145148
  • code/branches/pickup/src/libraries/network/ClientConnection.h

    r5781 r5935  
    5353    bool addPacket(ENetPacket *packet);
    5454    inline bool isConnected(){ return this->established_; }
     55  protected:
     56    virtual void connectionClosed()=0;
    5557  private:
    56     virtual void addClient(ENetEvent* event);
    57     virtual void disconnectPeer(ENetEvent* event);
     58    virtual void addPeer(ENetEvent* event);
     59    virtual void removePeer(ENetEvent* event);
    5860   
    5961    bool disconnectConnection();
  • code/branches/pickup/src/libraries/network/ClientConnectionListener.cc

    r5781 r5935  
    3333#include "ClientInformation.h"
    3434
    35 namespace orxonox{
     35namespace orxonox
     36{
     37    ClientConnectionListener::ClientConnectionListener()
     38    {
     39        RegisterRootObject(ClientConnectionListener);
     40    }
    3641
    37   ClientConnectionListener::ClientConnectionListener()
    38   {
    39     RegisterRootObject(ClientConnectionListener);
    40   }
     42    void ClientConnectionListener::broadcastClientConnected(unsigned int clientID)
     43    {
     44        for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)
     45            it->clientConnected(clientID);
     46    }
     47   
     48    void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID)
     49    {
     50        for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)
     51            it->clientDisconnected(clientID);
     52    }
    4153
    42   void ClientConnectionListener::getConnectedClients(){
    43     if(GameMode::showsGraphics())
    44       this->clientConnected(0); //server client id
    45     ClientInformation *client = ClientInformation::getBegin();
    46     while(client){
    47       this->clientConnected(client->getID());
    48       client=client->next();
     54    void ClientConnectionListener::getConnectedClients()
     55    {
     56        ClientInformation* client = ClientInformation::getBegin();
     57        while (client)
     58        {
     59            this->clientConnected(client->getID());
     60            client = client->next();
     61        }
    4962    }
    50   }
    51 
    5263}
    5364
  • code/branches/pickup/src/libraries/network/ClientConnectionListener.h

    r5781 r5935  
    3333#include "core/OrxonoxClass.h"
    3434
    35 namespace orxonox{
     35namespace orxonox
     36{
     37    class _NetworkExport ClientConnectionListener : virtual public OrxonoxClass
     38    {
     39        public:
     40            ClientConnectionListener();
     41            virtual ~ClientConnectionListener() {}
     42           
     43            static void broadcastClientConnected(unsigned int clientID);
     44            static void broadcastClientDisconnected(unsigned int clientID);
    3645
    37   class _NetworkExport ClientConnectionListener : virtual public OrxonoxClass
    38   {
    39     friend class Server;
     46            virtual void clientConnected(unsigned int clientID) = 0;
     47            virtual void clientDisconnected(unsigned int clientID) = 0;
    4048
    41   public:
    42     ClientConnectionListener();
    43     virtual ~ClientConnectionListener() {}
    44 
    45     void getConnectedClients();
    46 
    47   protected:
    48     virtual void clientConnected(unsigned int clientID) = 0;
    49     virtual void clientDisconnected(unsigned int clientID) = 0;
    50   };
    51 
     49        protected:
     50            void getConnectedClients();
     51    };
    5252}
    5353
  • code/branches/pickup/src/libraries/network/Connection.cc

    • Property svn:eol-style set to native
    r5781 r5935  
    8383        // log handling ================
    8484        case ENET_EVENT_TYPE_CONNECT:
    85           addClient( &event );
     85          addPeer( &event );
    8686          break;
    8787        case ENET_EVENT_TYPE_DISCONNECT:
    88           disconnectPeer( &event );
     88          removePeer( &event );
    8989          break;
    9090        case ENET_EVENT_TYPE_RECEIVE:
  • code/branches/pickup/src/libraries/network/Connection.h

    • Property svn:eol-style set to native
    r5781 r5935  
    6464   
    6565    int service(ENetEvent* event);
    66     void disconnectPeer(ENetPeer *peer);
     66    virtual void disconnectPeer(ENetPeer *peer);
    6767   
    6868    void processQueue();
    69     virtual void addClient(ENetEvent* event)=0;
    70     virtual void disconnectPeer(ENetEvent* event)=0;
     69    virtual void addPeer(ENetEvent* event)=0;
     70    virtual void removePeer(ENetEvent* event)=0;
    7171    virtual bool processPacket(ENetEvent* event);
    7272   
  • code/branches/pickup/src/libraries/network/GamestateClient.cc

    r5781 r5935  
    108108    ObjectList<Synchronisable>::iterator temp=it;
    109109    ++it;
    110     delete  *temp;
     110    temp->destroy(); // or delete?
    111111  }
    112112
  • code/branches/pickup/src/libraries/network/GamestateManager.cc

    r5781 r5935  
    7777        delete (*it2).second;
    7878    }
    79     delete this->trafficControl_;
     79    this->trafficControl_->destroy();
    8080//     delete this->threadMutex_;
    8181//     delete this->threadPool_;
     
    160160      finishGamestate( cid, &clientGamestates.back(), client, reference );
    161161      //FunctorMember<GamestateManager>* functor =
    162 //       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate) );
    163 //       executor->setObject(this);
     162//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
    164163//       executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
    165164//       (*static_cast<Executor*>(executor))();
  • code/branches/pickup/src/libraries/network/NetworkFunction.cc

    r5781 r5935  
    6060    std::map<std::string, NetworkFunctionBase*>::iterator it;
    6161    for( it=NetworkFunctionBase::nameMap_.begin(); it!=NetworkFunctionBase::nameMap_.end(); ++it )
    62       delete it->second;
     62      it->second->destroy();
    6363  }
    6464 
  • code/branches/pickup/src/libraries/network/NetworkPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the network library
    3233*/
    3334
     
    4041// Shared library settings
    4142//-----------------------------------------------------------------------
     43
    4244#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( NETWORK_STATIC_BUILD )
    4345#  ifdef NETWORK_SHARED_BUILD
     
    5759
    5860//-----------------------------------------------------------------------
    59 // Library global contants
     61// Constants
    6062//-----------------------------------------------------------------------
     63
    6164namespace orxonox
    6265{
    6366  static const unsigned int GAMESTATEID_INITIAL = static_cast<unsigned int>(-1);
    6467  static const unsigned int CLIENTID_UNKNOWN    = static_cast<unsigned int>(-2);
    65   static const uint32_t     OBJECTID_UNKNOWN    = static_cast<uint32_t>(-1);
     68}
     69
     70//-----------------------------------------------------------------------
     71// Enums
     72//-----------------------------------------------------------------------
     73
     74namespace orxonox
     75{
     76  namespace packet
     77  {
     78    namespace PacketFlag
     79    {
     80      enum Value
     81      {
     82        Reliable   = 1,
     83        Unsequence = 2,
     84        NoAllocate = 4
     85      };
     86    }
     87  }
    6688}
    6789
     
    84106namespace orxonox
    85107{
     108  class ChatListener;
    86109  class Client;
    87110  class ClientConnection;
    88111  class ClientConnectionListener;
    89   class ClientFrameListener;
    90112  class ClientInformation;
    91113  class Connection;
    92114  class FunctionCallManager;
    93115  class GamestateClient;
     116  class GamestateHandler;
    94117  class GamestateManager;
    95   class GamestateHandler;
    96   class NetworkCallbackBase;
    97   template <class T> class NetworkCallback;
    98   class NetworkCallbackManager;
     118  class Host;
    99119  class NetworkFunctionBase;
     120  struct NetworkFunctionPointer;
    100121  class NetworkFunctionStatic;
     122  template <class T>
     123  class NetworkMemberFunction;
    101124  class NetworkMemberFunctionBase;
    102   template <class T> class NetworkMemeberFunction;
    103   struct NetworkFunctionPointer;
    104125  class Server;
    105126  class ServerConnection;
    106   class ServerFrameListener;
    107   class Synchronisable;
    108   class SynchronisableVariableBase;
    109   template <class T> class SynchronisableVariable;
    110   template <class T> class SynchronisableVariableBidirectional;
    111   struct ClientList;
    112   struct PacketEnvelope;
    113   struct QueueItem;
    114   struct syncData;
    115127  class TrafficControl;
    116   class obj;
    117   class objInfo;
    118128
     129  // packet
    119130  namespace packet
    120131  {
     
    122133    class Chat;
    123134    class ClassID;
     135    class DeleteObjects;
    124136    class FunctionCalls;
    125137    class FunctionIDs;
    126138    class Gamestate;
    127     class NetworkIDs;
    128139    class Packet;
    129140    class Welcome;
     141  }
    130142
    131     namespace PacketFlag
    132     {
    133       enum Value
    134       {
    135         Reliable   = 1,
    136         Unsequence = 2,
    137         NoAllocate = 4
    138       };
    139     }
    140   }
     143  // synchronisable
     144  template <class T>
     145  class NetworkCallback;
     146  class NetworkCallbackBase;
     147  class NetworkCallbackManager;
     148  class Synchronisable;
     149  class SynchronisableHeader;
     150  template <class T>
     151  class SynchronisableVariable;
     152  class SynchronisableVariableBase;
     153  template <class T>
     154  class SynchronisableVariableBidirectional;
    141155}
    142156
  • code/branches/pickup/src/libraries/network/Server.cc

    r5781 r5935  
    4646#include <string>
    4747
     48#include "util/Clock.h"
    4849#include "util/Debug.h"
    49 #include "core/Clock.h"
    5050#include "core/ObjectList.h"
    5151#include "core/Executor.h"
     
    245245    packet::DeleteObjects *del = new packet::DeleteObjects();
    246246    if(!del->fetchIDs())
     247    {
     248      delete del;
    247249      return true;  //everything ok (no deletes this tick)
     250    }
    248251//     COUT(3) << "sending DeleteObjects" << std::endl;
    249252    while(temp != NULL){
     
    267270
    268271
    269   void Server::addClient(ENetEvent *event){
     272  void Server::addPeer(ENetEvent *event){
    270273    static unsigned int newid=1;
    271274
     
    279282
    280283    // inform all the listeners
    281     ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin();
    282     while(listener){
    283       listener->clientConnected(newid);
    284       listener++;
    285     }
     284    ClientConnectionListener::broadcastClientConnected(newid);
    286285
    287286    ++newid;
     
    290289    createClient(temp->getID());
    291290}
     291
     292  void Server::removePeer(ENetEvent *event)
     293  {
     294    COUT(4) << "removing client from list" << std::endl;
     295    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
     296    if(!client)
     297      return;
     298    else
     299    {
     300      //ServerConnection::disconnectClient( client );
     301      ClientConnectionListener::broadcastClientDisconnected( client->getID() );
     302      delete client;
     303    }
     304  }
    292305
    293306  bool Server::createClient(int clientID){
     
    329342    ServerConnection::disconnectClient( client );
    330343    GamestateManager::removeClient(client);
    331 // inform all the listeners
    332     ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin();
    333     while(listener){
    334       listener->clientDisconnected(client->getID());
    335       ++listener;
    336     }
    337     delete client; //remove client from list
     344    // inform all the listeners
     345    ClientConnectionListener::broadcastClientDisconnected(client->getID());
    338346  }
    339347
  • code/branches/pickup/src/libraries/network/Server.h

    r5781 r5935  
    3232#include "NetworkPrereqs.h"
    3333
     34#include "util/UtilPrereqs.h"
    3435#include "core/CorePrereqs.h"
    3536#include "Host.h"
     
    6566    unsigned int playerID(){return 0;}
    6667   
    67     void addClient(ENetEvent *event);
     68    void addPeer(ENetEvent *event);
     69    void removePeer(ENetEvent *event);
     70   
    6871    bool createClient(int clientID);
    6972    void disconnectClient( ClientInformation *client);
  • code/branches/pickup/src/libraries/network/ServerConnection.cc

    r5781 r5935  
    103103  {
    104104    Connection::disconnectPeer( client->getPeer() );
    105     delete client;
    106   }
    107  
    108   void ServerConnection::disconnectPeer( ENetEvent* event )
    109   {
    110     COUT(4) << "removing client from list" << std::endl;
    111     ClientInformation *client = ClientInformation::findClient(&event->peer->address);
    112     if(!client)
    113       return;
    114     else
    115       ServerConnection::disconnectClient( client );
    116105  }
    117106 
     
    119108    ClientInformation *client = ClientInformation::findClient(clientID);
    120109    if(client)
    121       disconnectClient(client);
     110      ServerConnection::disconnectClient(client);
    122111  }
    123112
     
    126115    ClientInformation *temp = ClientInformation::getBegin();
    127116    while(temp!=0){
    128       disconnectClient( temp );
     117      ServerConnection::disconnectClient( temp );
    129118      temp = temp->next();
    130119    }
     
    141130          break;
    142131        case ENET_EVENT_TYPE_DISCONNECT:
    143           if(ClientInformation::findClient(&(event.peer->address)))
    144             delete ClientInformation::findClient(&(event.peer->address));
     132          removePeer( &event );
    145133          temp = ClientInformation::getBegin();
    146134          break;
  • code/branches/pickup/src/libraries/network/ServerConnection.h

    • Property svn:eol-style set to native
    r5781 r5935  
    5959    static bool addPacketAll(ENetPacket *packet);
    6060    virtual void disconnectClient(ClientInformation *client);
    61     void disconnectPeer( ENetEvent* event );
    6261    void disconnectClient(int clientID);
    6362  protected:
  • code/branches/pickup/src/libraries/network/packet/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(NETWORK_SRC_FILES
     2COMPILATION_BEGIN PacketCompilation.cc
    23  Acknowledgement.cc
    34  Chat.cc
     
    910  Packet.cc
    1011  Welcome.cc
     12COMPILATION_END
    1113)
    1214
  • code/branches/pickup/src/libraries/network/packet/ClassID.cc

    r5781 r5935  
    4949  Identifier *id;
    5050  std::string classname;
    51   unsigned int nrOfClasses=0; 
     51  unsigned int nrOfClasses=0;
    5252  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
    5353  uint32_t network_id;
    5454  flags_ = flags_ | PACKET_FLAGS_CLASSID;
    5555  std::queue<std::pair<uint32_t, std::string> > tempQueue;
    56  
     56
    5757  //calculate total needed size (for all strings and integers)
    58   std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
    59   for(;it != Factory::getFactoryMapEnd();++it){
     58  std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin();
     59  for(;it != Identifier::getStringIdentifierMapEnd();++it){
    6060    id = (*it).second;
    61     if(id == NULL)
     61    if(id == NULL || !id->hasFactory())
    6262      continue;
    6363    classname = id->getName();
    6464    network_id = id->getNetworkID();
    65     if(network_id==0)
    66       COUT(3) << "we got a null class id: " << id->getName() << std::endl;
    6765    // now push the network id and the classname to the stack
    6866    tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) );
     
    7068    packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t);
    7169  }
    72  
     70
    7371  this->data_=new uint8_t[ packetSize ];
    7472  //set the appropriate packet id
    7573  assert(this->data_);
    7674  *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID;
    77  
     75
    7876  uint8_t *temp=data_+sizeof(uint32_t);
    7977  // save the number of all classes
    8078  *(uint32_t*)temp = nrOfClasses;
    8179  temp += sizeof(uint32_t);
    82  
     80
    8381  // now save all classids and classnames
    8482  std::pair<uint32_t, std::string> tempPair;
     
    9189    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
    9290  }
    93  
     91
    9492  COUT(5) << "classid packetSize is " << packetSize << endl;
    95  
     93
    9694}
    9795
     
    111109  temp += sizeof(uint32_t);
    112110  totalsize += sizeof(uint32_t); // storage size for nr of all classes
    113  
     111
    114112  for(unsigned int i=0; i<nrOfClasses; i++){
    115113    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
     
    125123  uint32_t stringsize;
    126124  unsigned char *classname;
    127  
    128  
    129   //clean the map of network ids
    130   Factory::cleanNetworkIDs();
    131  
     125
     126
     127  //clear the map of network ids
     128  Identifier::clearNetworkIDs();
     129
    132130  COUT(4) << "=== processing classids: " << endl;
    133131  std::pair<uint32_t, std::string> tempPair;
     
    136134  nrOfClasses = *(uint32_t*)temp;
    137135  temp += sizeof(uint32_t);
    138  
     136
    139137  for( int i=0; i<nrOfClasses; i++){
    140138    networkID = *(uint32_t*)temp;
  • code/branches/pickup/src/libraries/network/packet/Gamestate.cc

    r5781 r5935  
    378378  rawDiff( dest2, dest, basep, header_->getDataSize(), base->header_->getDataSize() );
    379379  assert( memcmp( dest2, gs, dest_length) == 0 );
     380  delete dest2;
    380381#endif
    381382
  • code/branches/pickup/src/libraries/network/synchronisable/Synchronisable.cc

    r5781 r5935  
    4747  /**
    4848  * Constructor:
    49   * Initializes all Variables and sets the right objectID
     49  * Initializes all Variables and sets the right objectID_
    5050  */
    51   Synchronisable::Synchronisable(BaseObject* creator){
     51  Synchronisable::Synchronisable(BaseObject* creator ){
    5252    RegisterRootObject(Synchronisable);
    5353    static uint32_t idCounter=0;
     
    5555    if ( GameMode::isMaster() || ( Host::running() && Host::isServer() ) )
    5656    {
    57       this->objectID = idCounter++; //this is only needed when running a server
    58     //add synchronisable to the objectMap
    59       objectMap_[this->objectID] = this;
     57      this->setObjectID( idCounter++ );
    6058    }
    6159    else
    6260    {
    63       objectID=OBJECTID_UNKNOWN;
    64       this->setObjectMode(0x0);   //make sure this object doesn't get synchronized
    65     }
    66     classID = static_cast<uint32_t>(-1);
     61      objectID_=OBJECTID_UNKNOWN;
     62    }
     63    classID_ = static_cast<uint32_t>(-1);
    6764   
    6865    // set dataSize to 0
     
    7269
    7370    // get creator id
    74     this->creatorID = OBJECTID_UNKNOWN;
    75 
    76     searchcreatorID:
     71    if( creator )
     72      this->creatorID_ = creator->getSceneID();
     73    else
     74      this->creatorID_ = OBJECTID_UNKNOWN;
     75
     76    /*searchcreatorID:
    7777    if (creator)
    7878    {
     
    8080        if (synchronisable_creator && synchronisable_creator->objectMode_)
    8181        {
    82             this->creatorID = synchronisable_creator->getObjectID();
     82            this->creatorID = synchronisable_creator->getScene()->getObjectID();
    8383        }
    8484        else if (creator != creator->getCreator())
     
    8787            goto searchcreatorID;
    8888        }
    89     }
     89    }*/
    9090  }
    9191
    9292  /**
    9393   * Destructor:
    94    * Delete all callback objects and remove objectID from the objectMap_
     94   * Delete all callback objects and remove objectID_ from the objectMap_
    9595   */
    9696  Synchronisable::~Synchronisable(){
     
    9999      // remove object from the static objectMap
    100100      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
    101         deletedObjects_.push(objectID);
     101        deletedObjects_.push(objectID_);
    102102    }
    103103    // delete all Synchronisable Variables from syncList ( which are also in stringList )
     
    107107    stringList.clear();
    108108    std::map<uint32_t, Synchronisable*>::iterator it;
    109     it = objectMap_.find(objectID);
     109    it = objectMap_.find(objectID_);
    110110    if (it != objectMap_.end())
    111111      objectMap_.erase(it);
     
    172172    Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
    173173    assert(no);
    174     no->objectID=header.getObjectID();
    175     no->creatorID=header.getCreatorID(); //TODO: remove this
    176     no->classID=header.getClassID();
    177     COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
     174    assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
     175    no->setObjectID(header.getObjectID());
     176    //no->creatorID=header.getCreatorID(); //TODO: remove this
     177    no->setClassID(header.getClassID());
     178    assert(no->creatorID_ == header.getCreatorID());
     179    //assert(no->classID_ == header.getClassID());
     180    COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;
    178181          // update data and create object/entity...
    179     assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
    180     Synchronisable::objectMap_[header.getObjectID()] = no;
    181182    bool b = no->updateData(mem, mode, true);
    182183    assert(b);
     
    191192
    192193  /**
    193    * Finds and deletes the Synchronisable with the appropriate objectID
    194    * @param objectID objectID of the Synchronisable
     194   * Finds and deletes the Synchronisable with the appropriate objectID_
     195   * @param objectID_ objectID_ of the Synchronisable
    195196   * @return true/false
    196197   */
    197   bool Synchronisable::deleteObject(uint32_t objectID){
    198     if(!getSynchronisable(objectID))
     198  bool Synchronisable::deleteObject(uint32_t objectID_){
     199    if(!getSynchronisable(objectID_))
    199200      return false;
    200     assert(getSynchronisable(objectID)->objectID==objectID);
    201     Synchronisable *s = getSynchronisable(objectID);
     201    assert(getSynchronisable(objectID_)->objectID_==objectID_);
     202    Synchronisable *s = getSynchronisable(objectID_);
    202203    if(s)
    203       delete s;
     204      s->destroy(); // or delete?
    204205    else
    205206      return false;
     
    208209
    209210  /**
    210    * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
    211    * @param objectID objectID of the Synchronisable
    212    * @return pointer to the Synchronisable with the objectID
    213    */
    214   Synchronisable* Synchronisable::getSynchronisable(uint32_t objectID){
     211   * This function looks up the objectID_ in the objectMap_ and returns a pointer to the right Synchronisable
     212   * @param objectID_ objectID_ of the Synchronisable
     213   * @return pointer to the Synchronisable with the objectID_
     214   */
     215  Synchronisable* Synchronisable::getSynchronisable(uint32_t objectID_){
    215216    std::map<uint32_t, Synchronisable*>::iterator it1;
    216     it1 = objectMap_.find(objectID);
     217    it1 = objectMap_.find(objectID_);
    217218    if (it1 != objectMap_.end())
    218219      return it1->second;
     
    220221//     ObjectList<Synchronisable>::iterator it;
    221222//     for(it = ObjectList<Synchronisable>::begin(); it; ++it){
    222 //       if( it->getObjectID()==objectID ){
    223 //         objectMap_[objectID] = *it;
     223//       if( it->getObjectID()==objectID_ ){
     224//         objectMap_[objectID_] = *it;
    224225//         return *it;
    225226//       }
     
    231232
    232233  /**
    233    * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classID to the given memory
     234   * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID_ and classID_ to the given memory
    234235   * takes a pointer to already allocated memory (must have at least getSize bytes length)
    235236   * structure of the bitstream:
    236    * |totalsize,objectID,classID,var1,var2,string1_length,string1,var3,...|
     237   * |totalsize,objectID_,classID_,var1,var2,string1_length,string1,var3,...|
    237238   * length of varx: size saved int syncvarlist
    238239   * @param mem pointer to allocated memory with enough size
     
    252253    uint32_t tempsize = 0;
    253254#ifndef NDEBUG
    254     if (this->classID==0)
     255    if (this->classID_==0)
    255256      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
    256257#endif
    257258
    258     if (this->classID == static_cast<uint32_t>(-1))
    259         this->classID = this->getIdentifier()->getNetworkID();
    260 
    261     assert(ClassByID(this->classID));
    262     assert(this->classID==this->getIdentifier()->getNetworkID());
     259    if (this->classID_ == static_cast<uint32_t>(-1))
     260        this->classID_ = this->getIdentifier()->getNetworkID();
     261
     262    assert(ClassByID(this->classID_));
     263    assert(this->classID_==this->getIdentifier()->getNetworkID());
     264    assert(this->objectID_!=OBJECTID_UNKNOWN);
    263265    std::vector<SynchronisableVariableBase*>::iterator i;
    264266
     
    269271
    270272
    271     COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << std::endl;
     273    COUT(5) << "Synchronisable getting data from objectID_: " << objectID_ << " classID_: " << classID_ << std::endl;
    272274    // copy to location
    273275    for(i=syncList.begin(); i!=syncList.end(); ++i){
     
    277279   
    278280    tempsize += SynchronisableHeader::getSize();
    279     header.setObjectID( this->objectID );
    280     header.setCreatorID( this->creatorID );
    281     header.setClassID( this->classID );
     281    header.setObjectID( this->objectID_ );
     282    header.setCreatorID( this->creatorID_ );
     283    header.setClassID( this->classID_ );
    282284    header.setDataAvailable( true );
    283285    header.setDataSize( tempsize );
     
    311313    // start extract header
    312314    SynchronisableHeader syncHeader(mem);
    313     assert(syncHeader.getObjectID()==this->objectID);
    314     assert(syncHeader.getCreatorID()==this->creatorID);
    315     assert(syncHeader.getClassID()==this->classID);
     315    assert(syncHeader.getObjectID()==this->objectID_);
     316    assert(syncHeader.getCreatorID()==this->creatorID_);
     317    assert(syncHeader.getClassID()==this->classID_);
    316318    if(syncHeader.isDataAvailable()==false){
    317319      mem += syncHeader.getDataSize();
     
    322324    // stop extract header
    323325
    324     //COUT(5) << "Synchronisable: objectID " << syncHeader.getObjectID() << ", classID " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
     326    //COUT(5) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
    325327    for(i=syncList.begin(); i!=syncList.end(); i++)
    326328    {
     
    361363    if(mode==0x0)
    362364      mode=state_;
    363     return ( (objectMode_&mode)!=0 && (!syncList.empty() ) );
    364   }
    365 
    366   /**
    367    * This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones
     365    return ( (this->objectMode_ & mode)!=0 && (!syncList.empty() ) );
     366  }
     367
     368  /**
     369   * This function looks at the header located in the bytestream and checks wheter objectID_ and classID_ match with the Synchronisables ones
    368370   * @param mem pointer to the bytestream
    369371   */
     
    371373  {
    372374    SynchronisableHeader header(mem);
    373     assert(header.getObjectID()==this->objectID);
     375    assert(header.getObjectID()==this->objectID_);
    374376    return header.isDataAvailable();
    375377  }
     
    383385   * @param mode same as in registerVar
    384386   */
    385   void Synchronisable::setObjectMode(uint8_t mode){
     387  void Synchronisable::setSyncMode(uint8_t mode){
    386388    assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
    387     objectMode_=mode;
     389    this->objectMode_=mode;
    388390  }
    389391
  • code/branches/pickup/src/libraries/network/synchronisable/Synchronisable.h

    r5781 r5935  
    6868   * @brief: stores information about a Synchronisable
    6969   *
    70    * This class stores the information about a Synchronisable (objectID, classID, creatorID, dataSize)
     70   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
    7171   * in an emulated bitset.
    7272   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
    7373   * Bit 32 is a bool and defines whether the data is actually stored or is just filled up with 0
    74    * Byte 5 to 8: objectID
    75    * Byte 9 to 12: classID
    76    * Byte 13 to 16: creatorID
     74   * Byte 5 to 8: objectID_
     75   * Byte 9 to 12: classID_
     76   * Byte 13 to 16: creatorID_
    7777   */
    7878  class _NetworkExport SynchronisableHeader{
     
    9494      inline uint32_t getObjectID() const
    9595        { return *(uint32_t*)(data_+4); }
    96       inline void setObjectID(uint32_t objectID)
    97         { *(uint32_t*)(data_+4) = objectID; }
     96      inline void setObjectID(uint32_t objectID_)
     97        { *(uint32_t*)(data_+4) = objectID_; }
    9898      inline uint32_t getClassID() const
    9999        { return *(uint32_t*)(data_+8); }
    100       inline void setClassID(uint32_t classID)
    101         { *(uint32_t*)(data_+8) = classID; }
     100      inline void setClassID(uint32_t classID_)
     101        { *(uint32_t*)(data_+8) = classID_; }
    102102      inline uint32_t getCreatorID() const
    103103        { return *(uint32_t*)(data_+12); }
    104       inline void setCreatorID(uint32_t creatorID)
    105         { *(uint32_t*)(data_+12) = creatorID; }
     104      inline void setCreatorID(uint32_t creatorID_)
     105        { *(uint32_t*)(data_+12) = creatorID_; }
    106106      inline void operator=(SynchronisableHeader& h)
    107107        { memcpy(data_, h.data_, getSize()); }
     
    122122
    123123    static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
    124     static bool deleteObject(uint32_t objectID);
    125     static Synchronisable *getSynchronisable(uint32_t objectID);
     124    static bool deleteObject(uint32_t objectID_);
     125    static Synchronisable *getSynchronisable(uint32_t objectID_);
    126126    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
    127127    static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    128128
    129     inline uint32_t getObjectID() const {return objectID;}
    130     inline unsigned int getCreatorID() const {return creatorID;}
    131     inline uint32_t getClassID() const {return classID;}
    132     inline unsigned int getPriority() const { return objectFrequency_;}
     129    inline uint32_t getObjectID() const {return this->objectID_;}
     130    inline unsigned int getCreatorID() const {return this->creatorID_;}
     131    inline uint32_t getClassID() const {return this->classID_;}
     132    inline unsigned int getPriority() const { return this->objectFrequency_;}
     133    inline uint8_t getSyncMode() const { return this->objectMode_; }
     134   
     135    void setSyncMode(uint8_t mode);
    133136
    134137  protected:
     
    136139    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    137140    //template <class T> void unregisterVariable(T& var);
    138     void setObjectMode(uint8_t mode);
    139141    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
    140142
     
    146148    bool isMyData(uint8_t* mem);
    147149    bool doSync(int32_t id, uint8_t mode=0x0);
    148 
    149     uint32_t objectID;
    150     uint32_t creatorID;
    151     uint32_t classID;
     150   
     151    inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
     152    inline void setClassID(uint32_t id){ this->classID_ = id; }
     153
     154    uint32_t objectID_;
     155    uint32_t creatorID_;
     156    uint32_t classID_;
    152157
    153158    std::vector<SynchronisableVariableBase*> syncList;
  • code/branches/pickup/src/libraries/tools/CMakeLists.txt

    r5781 r5935  
    1 ADD_SOURCE_FILES(TOOLS_SRC_FILES
     1SET_SOURCE_FILES(TOOLS_SRC_FILES
     2COMPILATION_BEGIN ResourceCompilation.cc
     3  ResourceCollection.cc
     4  ResourceLocation.cc
     5COMPILATION_END
     6  TextureGenerator.cc
     7  Timer.cc
     8COMPILATION_BEGIN OgreCompilation.cc
    29  BillboardSet.cc
    310  DynamicLines.cc
     
    512  Mesh.cc
    613  ParticleInterface.cc
    7   ResourceCollection.cc
    8   ResourceLocation.cc
    914  Shader.cc
    10   TextureGenerator.cc
    11   Timer.cc
     15COMPILATION_END
    1216)
    1317ADD_SUBDIRECTORY(interfaces)
     
    1519ORXONOX_ADD_LIBRARY(tools
    1620  FIND_HEADER_FILES
    17   PCH_FILE
    18     ToolsPrecompiledHeaders.h
    1921  DEFINE_SYMBOL
    2022    "TOOLS_SHARED_BUILD"
  • code/branches/pickup/src/libraries/tools/ResourceLocation.cc

    r5781 r5935  
    3333
    3434#include "util/Exception.h"
    35 #include "core/Core.h"
    3635#include "core/CoreIncludes.h"
     36#include "core/PathConfig.h"
    3737#include "core/XMLFile.h"
    3838#include "core/XMLPort.h"
     
    7171
    7272        // Find the path
    73         boost::filesystem::path path;
    74         if (boost::filesystem::exists(Core::getDataPath() / this->getPath()))
    75             path = Core::getDataPath() / this->getPath();
    76         else if (Core::isDevelopmentRun() && boost::filesystem::exists(Core::getExternalDataPath() / this->getPath()))
    77             path = Core::getExternalDataPath() / this->getPath();
     73        namespace bf = boost::filesystem;
     74        bf::path path;
     75        if (bf::exists(PathConfig::getDataPath() / this->getPath()))
     76            path = PathConfig::getDataPath() / this->getPath();
     77        else if (PathConfig::isDevelopmentRun() && bf::exists(PathConfig::getExternalDataPath() / this->getPath()))
     78            path = PathConfig::getExternalDataPath() / this->getPath();
    7879        else
    7980        {
  • code/branches/pickup/src/libraries/tools/Timer.cc

    r5781 r5935  
    3131#include <set>
    3232
     33#include "util/Clock.h"
    3334#include "core/CoreIncludes.h"
    3435#include "core/ConsoleCommand.h"
    3536#include "core/CommandExecutor.h"
    36 #include "core/Clock.h"
    3737#include "core/Functor.h"
    3838
     
    4242    SetConsoleCommandShortcutExtern(killdelays);
    4343
    44     static std::set<StaticTimer*> delaytimerset;
     44    static std::set<Timer*> delaytimerset;
    4545
    4646    /**
     
    5151    void delay(float delay, const std::string& command)
    5252    {
    53         StaticTimer *delaytimer = new StaticTimer();
     53        Timer* delaytimer = new Timer();
    5454        delaytimerset.insert(delaytimer);
    5555
     
    6464        @param command The command to execute
    6565    */
    66     void executeDelayedCommand(StaticTimer* timer, const std::string& command)
     66    void executeDelayedCommand(Timer* timer, const std::string& command)
    6767    {
    6868        CommandExecutor::execute(command);
    69         delete timer;
     69        timer->destroy();
    7070        delaytimerset.erase(timer);
    7171    }
     
    7676    void killdelays()
    7777    {
    78         for (std::set<StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
    79             delete (*it);
     78        for (std::set<Timer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
     79            (*it)->destroy();
    8080
    8181        delaytimerset.clear();
     
    8585        @brief Constructor: Sets the default-values.
    8686    */
    87     TimerBase::TimerBase()
     87    Timer::Timer()
     88    {
     89        this->init();
     90        RegisterObject(Timer);
     91    }
     92
     93    /**
     94        @brief Constructor: Initializes the Timer with given values.
     95        @param interval The timer-interval in seconds
     96        @param bLoop If true, the function gets called every 'interval' seconds
     97        @param exeuctor A executor of the function to call
     98    */
     99    Timer::Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall)
     100    {
     101        this->init();
     102        RegisterObject(Timer);
     103
     104        this->setTimer(interval, bLoop, executor, bKillAfterCall);
     105    }
     106
     107    /**
     108        @brief Deletes the executor.
     109    */
     110    Timer::~Timer()
     111    {
     112        this->deleteExecutor();
     113    }
     114   
     115    /**
     116        @brief Initializes the Timer
     117    */
     118    void Timer::init()
    88119    {
    89120        this->executor_ = 0;
     
    94125
    95126        this->time_ = 0;
    96 
    97         RegisterObject(TimerBase);
    98     }
    99 
    100     /**
    101         @brief Deletes the executor.
    102     */
    103     TimerBase::~TimerBase()
    104     {
    105         this->deleteExecutor();
    106127    }
    107128
     
    109130        @brief Executes the executor.
    110131    */
    111     void TimerBase::run() const
     132    void Timer::run()
    112133    {
    113134        bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer
     
    116137
    117138        if (temp)
    118             delete this;
     139            this->destroy();
    119140    }
    120141
     
    122143        @brief Deletes the executor.
    123144    */
    124     void TimerBase::deleteExecutor()
     145    void Timer::deleteExecutor()
    125146    {
    126147      if (this->executor_)
     
    131152        @brief Updates the timer before the frames are rendered.
    132153    */
    133     void TimerBase::tick(const Clock& time)
     154    void Timer::tick(const Clock& time)
    134155    {
    135156        if (this->bActive_)
  • code/branches/pickup/src/libraries/tools/Timer.h

    r5781 r5935  
    4040                ClassName();
    4141                void functionName();
    42                 Timer<ClassName> myTimer;
     42                Timer myTimer;
    4343        };
    4444
     
    4848        ClassName::ClassName()
    4949        {
    50             myTimer.setTimer(interval_in_seconds, bLoop, this, createExecutor(createFunctor(&ClassName::functionName)));
     50            myTimer.setTimer(interval_in_seconds, bLoop, createExecutor(createFunctor(&ClassName::functionName, this)));
    5151        }
    5252
     
    6969namespace orxonox
    7070{
    71     class StaticTimer;
    7271    void delay(float delay, const std::string& command);
    7372    void killdelays();
    74     void executeDelayedCommand(StaticTimer* timer, const std::string& command);
     73    void executeDelayedCommand(Timer* timer, const std::string& command);
    7574
    76     //! TimerBase is the parent of the Timer class.
    77     class _ToolsExport TimerBase : public TimeFactorListener
     75    //! The Timer is a callback-object, calling a given function after a given time-interval.
     76    class _ToolsExport Timer : public TimeFactorListener
    7877    {
    7978        public:
    80             ~TimerBase();
     79            Timer();
     80            ~Timer();
    8181
    82             void run() const;
     82            Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false);
     83
     84            /**
     85                @brief Initializes the Timer with given values.
     86                @param interval The timer-interval in seconds
     87                @param bLoop If true, the function gets called every 'interval' seconds
     88                @param object The object owning the timer and the function
     89                @param executor A executor of the function to call
     90            */
     91            void setTimer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false)
     92            {
     93                this->deleteExecutor();
     94
     95                this->setInterval(interval);
     96                this->bLoop_ = bLoop;
     97                this->executor_ = executor;
     98                this->bActive_ = true;
     99
     100                this->time_ = this->interval_;
     101                this->bKillAfterCall_ = bKillAfterCall;
     102            }
     103
     104            void run();
    83105            void deleteExecutor();
    84106
     
    116138            void tick(const Clock& time);
    117139
    118         protected:
    119             TimerBase();
    120 
     140        private:
     141            void init();
     142       
    121143            Executor* executor_;  //!< The executor of the function that should be called when the time expires
    122144
     
    128150            long long time_;      //!< Internal variable, counting the time till the next function-call
    129151    };
    130 
    131     //! The Timer is a callback-object, calling a given function after a given time-interval.
    132     template <class T = BaseObject>
    133     class Timer : public TimerBase
    134     {
    135         public:
    136             Timer() {}
    137 
    138             /**
    139                 @brief Constructor: Initializes the Timer with given values.
    140                 @param interval The timer-interval in seconds
    141                 @param bLoop If true, the function gets called every 'interval' seconds
    142                 @param object The object owning the timer and the function
    143                 @param exeuctor A executor of the function to call
    144             */
    145             Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false)
    146             {
    147                 this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall);
    148             }
    149 
    150             /**
    151                 @brief Initializes the Timer with given values.
    152                 @param interval The timer-interval in seconds
    153                 @param bLoop If true, the function gets called every 'interval' seconds
    154                 @param object The object owning the timer and the function
    155                 @param exeuctor A executor of the function to call
    156             */
    157             void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false)
    158             {
    159                 this->deleteExecutor();
    160 
    161                 this->setInterval(interval);
    162                 this->bLoop_ = bLoop;
    163                 executor->setObject(object);
    164                 this->executor_ = static_cast<Executor*>(executor);
    165                 this->bActive_ = true;
    166 
    167                 this->time_ = this->interval_;
    168                 this->bKillAfterCall_ = bKillAfterCall;
    169             }
    170     };
    171 
    172     //! The StaticTimer is a callback-object, calling a static function after a given time-interval.
    173     class _ToolsExport StaticTimer : public TimerBase
    174     {
    175         public:
    176             StaticTimer() {}
    177 
    178             /**
    179                 @brief Constructor: Initializes the Timer with given values.
    180                 @param interval The timer-interval in seconds
    181                 @param bLoop If true, the function gets called every 'interval' seconds
    182                 @param exeuctor A executor of the function to call
    183             */
    184             StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    185             {
    186                 this->setTimer(interval, bLoop, executor, bKillAfterCall);
    187             }
    188 
    189             /**
    190                 @brief Initializes the Timer with given values.
    191                 @param interval The timer-interval in seconds
    192                 @param bLoop If true, the function gets called every 'interval' seconds
    193                 @param object The object owning the timer and the function
    194                 @param executor A executor of the function to call
    195             */
    196             void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    197             {
    198                 this->deleteExecutor();
    199 
    200                 this->setInterval(interval);
    201                 this->bLoop_ = bLoop;
    202                 this->executor_ = executor;
    203                 this->bActive_ = true;
    204 
    205                 this->time_ = this->interval_;
    206                 this->bKillAfterCall_ = bKillAfterCall;
    207             }
    208     };
    209 
    210152}
    211153
  • code/branches/pickup/src/libraries/tools/ToolsPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the tools module
    3233*/
    3334
     
    4041// Shared library settings
    4142//-----------------------------------------------------------------------
     43
    4244#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4345#  ifdef TOOLS_SHARED_BUILD
     
    5759
    5860//-----------------------------------------------------------------------
    59 // Forward declarations
     61// Enums
    6062//-----------------------------------------------------------------------
    6163
     
    7274        };
    7375    }
     76}
    7477
     78//-----------------------------------------------------------------------
     79// Forward declarations
     80//-----------------------------------------------------------------------
     81
     82namespace orxonox
     83{
    7584    class BillboardSet;
    7685    class Mesh;
    7786    class ParticleInterface;
     87    class ResourceCollection;
     88    class ResourceLocation;
    7889    class Shader;
    79     template <class T>
     90    class Tickable;
     91    class TimeFactorListener;
    8092    class Timer;
    81     class StaticTimer;
    8293}
    8394
  • code/branches/pickup/src/libraries/util/CMakeLists.txt

    r5781 r5935  
    1919
    2020SET_SOURCE_FILES(UTIL_SRC_FILES
    21   Clipboard.cc
    22   CRC32.cc
    2321  Exception.cc
    24   ExprParser.cc
    2522  Math.cc
    2623  MultiType.cc
     24  Scope.cc
     25  StringUtils.cc
     26COMPILATION_BEGIN StableCompilation.cc
     27  Clipboard.cc
     28  Clock.cc
     29  CRC32.cc
     30  ExprParser.cc
    2731  OutputBuffer.cc
    2832  OutputHandler.cc
    29   Scope.cc
    3033  SignalHandler.cc
    3134  Sleep.cc
    32   StringUtils.cc
    3335  SubString.cc
     36COMPILATION_END
    3437)
    3538
  • code/branches/pickup/src/libraries/util/Scope.h

    r5738 r5935  
    3131
    3232#include "UtilPrereqs.h"
     33
    3334#include <cassert>
     35#include <map>
    3436#include <set>
    35 #include <map>
     37
    3638#include "Debug.h"
     39#include "ScopeGuard.h"
    3740
    3841namespace orxonox
    3942{
    40     namespace ScopeID
    41     {
    42         /**
    43             @brief A list of available scopes for the Scope template.
    44         */
    45         enum Value
    46         {
    47             GSRoot,
    48             GSGraphics,
    49             GSLevel
    50         };
    51     }
    52 
    53     class ScopeListener; // Forward declaration
    54 
    5543    /**
    5644        @brief The ScopeManager stores the variables of the scope templates in a statically linked context.
     
    7765        protected:
    7866            //! Constructor: Registers the instance.
    79             ScopeListener(ScopeID::Value scope) : scope_(scope)
     67            ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false)
    8068                { ScopeManager::listeners_s[this->scope_].insert(this); }
    8169            //! Destructor: Unregisters the instance.
     
    9078        private:
    9179            ScopeID::Value scope_; //!< Store the scope to unregister on destruction
     80            bool bActivated_;
    9281    };
    9382
     
    10594            Scope()
    10695            {
    107                 ScopeManager::instanceCounts_s[scope]++;
    108                 assert(ScopeManager::instanceCounts_s[scope] > 0);
    109                 if (ScopeManager::instanceCounts_s[scope] == 1)
     96                try
    11097                {
    111                     for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
    112                         (*(it++))->activated();
     98                    ScopeManager::instanceCounts_s[scope]++;
     99                    assert(ScopeManager::instanceCounts_s[scope] > 0);
     100                    if (ScopeManager::instanceCounts_s[scope] == 1)
     101                    {
     102                        Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateListeners);
     103                        for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
     104                        {
     105                            (*it)->activated();
     106                            (*(it++))->bActivated_ = true;
     107                        }
     108                        deactivator.Dismiss();
     109                    }
     110                }
     111                catch (...)
     112                {
     113                    ScopeManager::instanceCounts_s[scope]--;
     114                    throw;
    113115                }
    114116            }
     
    125127
    126128                if (ScopeManager::instanceCounts_s[scope] == 0)
     129                    this->deactivateListeners();
     130            }
     131
     132            void deactivateListeners()
     133            {
     134                for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
    127135                {
    128                     for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
    129                         (*(it++))->deactivated();
     136                    if ((*it)->bActivated_)
     137                    {
     138                        try
     139                            { (*it)->deactivated(); }
     140                        catch (...)
     141                            { COUT(0) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << std::endl; }
     142                        (*(it++))->bActivated_ = false;
     143                    }
     144                    else
     145                        ++it;
    130146                }
    131147            }
  • code/branches/pickup/src/libraries/util/Singleton.h

    r5738 r5935  
    5555        }
    5656
     57        //! Update method called by ClassSingletonManager (if used)
     58        void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
     59        //! Empty update method for the static polymorphism
     60        void update(const Clock& time) { }
     61
    5762    protected:
    5863        //! Constructor sets the singleton instance pointer
  • code/branches/pickup/src/libraries/util/UtilPrereqs.h

    r5738 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the util library
    3233*/
    3334
     
    4041// Shared library settings
    4142//-----------------------------------------------------------------------
     43
    4244#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( UTIL_STATIC_BUILD )
    4345#  ifdef UTIL_SHARED_BUILD
     
    5658#endif
    5759
     60//-----------------------------------------------------------------------
     61// Enums
     62//-----------------------------------------------------------------------
     63
     64namespace orxonox
     65{
     66    namespace ScopeID
     67    {
     68        //!A list of available scopes for the Scope template.
     69        enum Value
     70        {
     71            Root,
     72            Graphics
     73        };
     74    }
     75}
    5876
    5977//-----------------------------------------------------------------------
     
    6381namespace orxonox
    6482{
     83    class Clock;
    6584    class Exception;
    6685    class ExprParser;
     
    7190    class OutputBufferListener;
    7291    class OutputHandler;
     92    template <ScopeID::Value>
     93    class Scope;
     94    template <class, ScopeID::Value>
     95    class ScopedSingleton;
     96    class ScopeListener;
    7397    class SignalHandler;
     98    template <class T>
     99    class Singleton;
    74100    class SubString;
    75101}
  • code/branches/pickup/src/modules/CMakeLists.txt

    r5781 r5935  
    2727################ Sub Directories ################
    2828
    29 ADD_SUBDIRECTORY(gamestates)
    3029ADD_SUBDIRECTORY(objects)
    3130ADD_SUBDIRECTORY(overlays)
  • code/branches/pickup/src/modules/objects/Attacher.cc

    r5781 r5935  
    5353    void Attacher::processEvent(Event& event)
    5454    {
    55         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    56             (*it)->fireEvent(event);
     55        if (this->target_)
     56            this->target_->processEvent(event);
    5757    }
    5858
     
    102102
    103103        for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
     104        {
    104105            if (it->getName() == this->targetname_)
     106            {
     107                this->target_ = *it;
    105108                this->attachToParent(*it);
     109            }
     110        }
    106111    }
    107112
  • code/branches/pickup/src/modules/objects/ObjectsPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the objects module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
    38 
    3939#include "OrxonoxPrereqs.h"
    4040
     
    4242// Shared library settings
    4343//-----------------------------------------------------------------------
     44
    4445#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4546#  ifdef OBJECTS_SHARED_BUILD
     
    7677
    7778    // eventsystem
     79    class EventDispatcher;
     80    class EventFilter;
    7881    class EventListener;
    79     class EventDispatcher;
     82    class EventName;
    8083    class EventTarget;
    8184
    8285    // triggers
    83     class Trigger;
     86    class CheckPoint;
    8487    class DistanceTrigger;
    8588    class EventTrigger;
    86     class CheckPoint;
     89    class Trigger;
    8790}
    8891
  • code/branches/pickup/src/modules/objects/Planet.cc

    r5781 r5935  
    4747     * @brief Constructor
    4848     */
    49     Planet::Planet(BaseObject* creator): MovableEntity(creator)
     49    Planet::Planet(BaseObject* creator) : MovableEntity(creator)
    5050    {
    5151        RegisterObject(Planet);
     
    6464    void Planet::tick(float dt)
    6565    {
    66         if(!this->isVisible())
     66        if (!this->isVisible())
    6767            return;
    6868
     
    7070        {
    7171            Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
    72             if(activeCamera)
     72            if (activeCamera)
    7373            {
    7474                float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
  • code/branches/pickup/src/modules/objects/eventsystem/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(OBJECTS_SRC_FILES
    22  EventDispatcher.cc
     3  EventFilter.cc
    34  EventListener.cc
     5  EventName.cc
    46  EventTarget.cc
    57)
  • code/branches/pickup/src/modules/objects/eventsystem/EventDispatcher.cc

    r5781 r5935  
    3232#include "core/EventIncludes.h"
    3333#include "core/XMLPort.h"
    34 #include "EventTarget.h"
    3534
    3635namespace orxonox
     
    4645    {
    4746        if (this->isInitialized())
    48             for (std::list<EventTarget*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    49                 delete (*it);
     47            for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     48                (*it)->destroy();
    5049    }
    5150
     
    5453        SUPER(EventDispatcher, XMLPort, xmlelement, mode);
    5554
    56         XMLPortObject(EventDispatcher, EventTarget, "targets", addTarget, getTarget, xmlelement, mode);
     55        XMLPortObject(EventDispatcher, BaseObject, "targets", addTarget, getTarget, xmlelement, mode);
     56
     57        // since we need event sources mapped to any state, we have to parse XML by ourselves
     58        this->loadAllEventStates(xmlelement, mode, this, Class(EventDispatcher));
    5759    }
    5860
    5961    void EventDispatcher::processEvent(Event& event)
    6062    {
    61         for (std::list<EventTarget*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    62             (*it)->fireEvent(event);
     63        for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     64            (*it)->processEvent(event);
    6365    }
    6466
    65     void EventDispatcher::addTarget(EventTarget* target)
     67    void EventDispatcher::addTarget(BaseObject* target)
    6668    {
    6769        this->targets_.push_back(target);
    6870    }
    6971
    70     EventTarget* EventDispatcher::getTarget(unsigned int index) const
     72    BaseObject* EventDispatcher::getTarget(unsigned int index) const
    7173    {
    7274        unsigned int i = 0;
    73         for (std::list<EventTarget*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     75        for (std::list<BaseObject*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    7476        {
    7577            if (i == index)
  • code/branches/pickup/src/modules/objects/eventsystem/EventDispatcher.h

    r5781 r5935  
    4747            virtual void processEvent(Event& event);
    4848
    49             void addTarget(EventTarget* target);
    50             EventTarget* getTarget(unsigned int index) const;
     49            void addTarget(BaseObject* target);
     50            BaseObject* getTarget(unsigned int index) const;
    5151
    5252        private:
    53             std::list<EventTarget*> targets_;
     53            std::list<BaseObject*> targets_;
    5454    };
    5555}
  • code/branches/pickup/src/modules/objects/eventsystem/EventListener.cc

    r5781 r5935  
    6363
    6464        this->bActive_ = true;
    65 
    66         this->fireEvent(event.activate_, event.originator_);
    67 
     65        this->fireEvent(event.activate_, event.originator_, event.name_);
    6866        this->bActive_ = false;
    6967    }
     
    7876        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    7977            if (it->getName() == this->eventName_)
    80                 this->registerAsListener(*it);
     78                this->addEventSource(*it, "");
    8179    }
    8280
     
    8785
    8886        if (object->getName() == this->eventName_)
    89             this->registerAsListener(object);
    90     }
    91 
    92     void EventListener::registerAsListener(BaseObject* object)
    93     {
    94         object->registerEventListener(this, "");
     87            this->addEventSource(object, "");
    9588    }
    9689}
  • code/branches/pickup/src/modules/objects/eventsystem/EventListener.h

    r5781 r5935  
    5454        private:
    5555            virtual void loadedNewXMLName(BaseObject* object);
    56             void registerAsListener(BaseObject* object);
    5756
    5857            std::string eventName_;
  • code/branches/pickup/src/modules/objects/eventsystem/EventTarget.cc

    r5781 r5935  
    2929#include "EventTarget.h"
    3030#include "core/CoreIncludes.h"
     31#include "core/XMLPort.h"
    3132
    3233namespace orxonox
     
    3738    {
    3839        RegisterObject(EventTarget);
     40
     41        this->bActive_ = false;
    3942    }
    4043
     
    4245    {
    4346    }
     47   
     48    void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     49    {
     50        SUPER(EventTarget, XMLPort, xmlelement, mode);
    4451
    45     void EventTarget::changedName()
     52        XMLPortParam(EventTarget, "target", setTargetName, getTargetName, xmlelement, mode);
     53
     54        // since we need event sources mapped to any state, we have to parse XML by ourselves
     55        this->loadAllEventStates(xmlelement, mode, this, Class(EventTarget));
     56    }
     57
     58    void EventTarget::processEvent(Event& event)
    4659    {
    47         SUPER(EventTarget, changedName);
     60        if (this->bActive_)
     61        {
     62            COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl;
     63            return;
     64        }
    4865
     66        this->bActive_ = true;
     67        this->fireEvent(event);
     68        this->bActive_ = false;
     69    }
     70
     71    void EventTarget::setTargetName(const std::string& name)
     72    {
     73        this->target_ = name;
     74       
    4975        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    50             if (it->getName() == this->getName())
    51                 this->addAsEvent(*it);
     76            if (it->getName() == this->target_)
     77                this->addEventTarget(*it);
    5278    }
    5379
    5480    void EventTarget::loadedNewXMLName(BaseObject* object)
    5581    {
    56         if (this->getName() == "")
     82        if (this->target_ == "")
    5783            return;
    5884
    59         if (object->getName() == this->getName())
    60             this->addAsEvent(object);
     85        if (object->getName() == this->target_)
     86            this->addEventTarget(object);
    6187    }
    6288
    63     void EventTarget::addAsEvent(BaseObject* object)
     89    void EventTarget::addEventTarget(BaseObject* object)
    6490    {
    6591        if (object != static_cast<BaseObject*>(this))
    66             object->addEvent(this, "");
     92            object->addEventSource(this, "");
    6793    }
    6894}
  • code/branches/pickup/src/modules/objects/eventsystem/EventTarget.h

    r5781 r5935  
    4242            EventTarget(BaseObject* creator);
    4343            virtual ~EventTarget();
     44           
     45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     46           
     47            virtual void processEvent(Event& event);
    4448
    45             virtual void changedName();
     49            void setTargetName(const std::string& name);
     50            inline const std::string& getTargetName() const
     51                { return this->target_; }
    4652
    4753        private:
    4854            virtual void loadedNewXMLName(BaseObject* object);
    49             void addAsEvent(BaseObject* object);
     55            void addEventTarget(BaseObject* object);
     56           
     57            std::string target_;
     58            bool bActive_;
    5059    };
    5160}
  • code/branches/pickup/src/modules/objects/triggers/CheckPoint.cc

    r5781 r5935  
    8585        DistanceTrigger::triggered(bIsTriggered);
    8686
    87         Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype());
     87        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get());
    8888        if (gametype)
    8989        {
  • code/branches/pickup/src/modules/objects/triggers/EventTrigger.cc

    r5781 r5935  
    4747    }
    4848
    49     void EventTrigger::processEvent(Event& event)
     49    void EventTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    5050    {
    51         SUPER(EventTrigger, processEvent, event);
     51        SUPER(EventTrigger, XMLEventPort, xmlelement, mode);
    5252
    53         ORXONOX_SET_EVENT(EventTrigger, "trigger", trigger, event);
     53        XMLPortEventState(EventTrigger, BaseObject, "trigger", trigger, xmlelement, mode);
    5454    }
    5555
  • code/branches/pickup/src/modules/objects/triggers/EventTrigger.h

    r5781 r5935  
    4141            virtual ~EventTrigger();
    4242
    43             virtual void processEvent(Event& event);
     43            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    4444
    4545            inline void trigger(bool bTriggered)
  • code/branches/pickup/src/modules/objects/triggers/Trigger.cc

    r5781 r5935  
    7272    }
    7373
    74     this->setObjectMode(0x0);
     74    this->setSyncMode(0x0);
    7575  }
    7676
  • code/branches/pickup/src/modules/overlays/FadeoutText.cc

    r5781 r5935  
    4646
    4747        this->bFadingOut_ = false;
    48         this->fadeouttimer_.setTimer(3.0f, false, this, createExecutor(createFunctor(&FadeoutText::fadeout)));
     48        this->fadeouttimer_.setTimer(3.0f, false, createExecutor(createFunctor(&FadeoutText::fadeout, this)));
    4949        this->fadeouttimer_.stopTimer();
    5050
  • code/branches/pickup/src/modules/overlays/FadeoutText.h

    r5781 r5935  
    6868
    6969            bool bFadingOut_;
    70             Timer<FadeoutText> fadeouttimer_;
     70            Timer fadeouttimer_;
    7171
    7272            float initialAlpha_;
  • code/branches/pickup/src/modules/overlays/OverlaysPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the overlays module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
     39#include "OrxonoxPrereqs.h"
    3840
    3941//-----------------------------------------------------------------------
    4042// Shared library settings
    4143//-----------------------------------------------------------------------
     44
    4245#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4346#  ifdef OVERLAYS_SHARED_BUILD
     
    6265namespace orxonox
    6366{
    64     class BarColour;
     67    class FadeoutText;
     68    class GUIOverlay;
     69    class OverlayText;
     70
     71    // debugging
    6572    class DebugFPSText;
    6673    class DebugRTRText;
    67     class GUIOverlay;
     74
     75    // hud
     76    class AnnounceMessage;
     77    class BarColour;
     78    class ChatOverlay;
     79    class DeathMessage;
     80    class GametypeStatus;
    6881    class HUDBar;
     82    class HUDHealthBar;
    6983    class HUDNavigation;
    7084    class HUDRadar;
    7185    class HUDSpeedBar;
    72     class HUDHealthBar;
    7386    class HUDTimer;
    74     class OrxonoxOverlay;
    75     class OverlayGroup;
    76     class OverlayText;
    77     class FadeoutText;
    78     class GametypeStatus;
    79     class AnnounceMessage;
    8087    class KillMessage;
    81     class DeathMessage;
     88    class TeamBaseMatchScore;
     89    class UnderAttackHealthBar;
    8290
     91    // stats
    8392    class CreateLines;
    8493    class Scoreboard;
  • code/branches/pickup/src/modules/overlays/hud/ChatOverlay.cc

    r5781 r5935  
    5858    ChatOverlay::~ChatOverlay()
    5959    {
     60        for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it)
     61            delete (*it);
    6062    }
    6163
     
    8789        COUT(0) << "Chat: " << text << std::endl;
    8890
    89         new Timer<ChatOverlay>(this->displayTime_, false, this, createExecutor(createFunctor(&ChatOverlay::dropMessage)), true);
     91        Timer* timer = new Timer();
     92        this->timers_.insert(timer); // store the timer in a set to destroy it in the destructor
     93        Executor* executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
     94        executor->setDefaultValues(timer);
     95        timer->setTimer(this->displayTime_, false, executor, true);
    9096
    9197        this->updateOverlayText();
    9298    }
    9399
    94     void ChatOverlay::dropMessage()
     100    void ChatOverlay::dropMessage(Timer* timer)
    95101    {
    96102        if (this->messages_.size() > 0)
    97103            this->messages_.pop_front();
    98104        this->updateOverlayText();
     105        this->timers_.erase(timer); // the timer destroys itself, but we have to remove it from the set
    99106    }
    100107
  • code/branches/pickup/src/modules/overlays/hud/ChatOverlay.h

    r5781 r5935  
    5555        private:
    5656            void updateOverlayText();
    57             void dropMessage();
     57            void dropMessage(Timer* timer);
    5858
    5959            float displayTime_;
     60            std::set<Timer*> timers_;
    6061    };
    6162}
  • code/branches/pickup/src/modules/overlays/hud/HUDBar.cc

    r5781 r5935  
    9696    {
    9797        if (this->isInitialized())
     98        {
    9899            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
     100            for (std::vector<BarColour*>::const_iterator it = this->barColours_.begin(); it != this->barColours_.end(); )
     101                (*it++)->destroy();
     102        }
    99103    }
    100104
  • code/branches/pickup/src/modules/overlays/hud/HUDHealthBar.cc

    r5781 r5935  
    5656    {
    5757        if (this->isInitialized())
    58             delete this->textoverlay_;
     58            this->textoverlay_->destroy();
    5959    }
    6060
     
    8484            this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
    8585            this->textoverlay_->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
     86        }
     87        else
     88        {
     89            this->setValue(0);
     90            this->textoverlay_->setCaption("0");
    8691        }
    8792
  • code/branches/pickup/src/modules/overlays/hud/HUDHealthBar.h

    r5781 r5935  
    111111
    112112        private:
    113             Pawn* owner_;
     113            WeakPtr<Pawn> owner_;
    114114            OverlayText* textoverlay_;
    115115            bool bUseBarColour_;
  • code/branches/pickup/src/modules/overlays/hud/HUDNavigation.cc

    r5781 r5935  
    3939#include "core/CoreIncludes.h"
    4040#include "core/XMLPort.h"
     41#include "Scene.h"
    4142#include "Radar.h"
    4243
     
    130131        SUPER(HUDNavigation, tick, dt);
    131132
    132         if (!Radar::getInstance().getFocus())
     133        // Get radar
     134        Radar* radar = this->getOwner()->getScene()->getRadar();
     135
     136        if (!radar->getFocus())
    133137        {
    134138            this->overlay_->hide();
     
    150154*/
    151155        // transform to screen coordinates
    152         Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
     156        Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();
    153157
    154158        bool outOfView;
  • code/branches/pickup/src/modules/overlays/hud/TeamBaseMatchScore.cc

    r5781 r5935  
    118118
    119119        if (this->getOwner() && this->getOwner()->getGametype())
    120             this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype());
     120            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype().get());
    121121        else
    122122            this->owner_ = 0;
  • code/branches/pickup/src/modules/overlays/hud/UnderAttackHealthBar.cc

    r5781 r5935  
    5252        this->text_->setPickPoint(Vector2(0.5, 0));
    5353
    54         this->inittimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&UnderAttackHealthBar::init)));
     54        this->inittimer_.setTimer(0.0f, false, createExecutor(createFunctor(&UnderAttackHealthBar::init, this)));
    5555    }
    5656
     
    5858    {
    5959        if (this->isInitialized())
    60             delete this->text_;
     60            this->text_->destroy();
    6161    }
    6262
     
    7878            this->owner_ = player;
    7979
    80             UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype());
     80            UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get());
    8181            if (ua)
    8282            {
  • code/branches/pickup/src/modules/overlays/hud/UnderAttackHealthBar.h

    r5781 r5935  
    6262            PlayerInfo* owner_;
    6363            OverlayText* text_;
    64             Timer<UnderAttackHealthBar> inittimer_;
     64            Timer inittimer_;
    6565    };
    6666}
  • code/branches/pickup/src/modules/overlays/stats/CreateLines.cc

    r5781 r5935  
    5959    CreateLines::~CreateLines()
    6060    {
    61         delete this->playerNameText_;
    62         delete this->scoreText_;
    63         delete this->deathsText_;
    64         delete this->background_;
     61        this->playerNameText_->destroy();
     62        this->scoreText_->destroy();
     63        this->deathsText_->destroy();
     64        this->background_->destroy();
    6565    }
    6666
  • code/branches/pickup/src/modules/overlays/stats/Scoreboard.cc

    r5781 r5935  
    4444    {
    4545        RegisterObject(Scoreboard);
     46    }
     47
     48    Scoreboard::~Scoreboard()
     49    {
     50        while (this->lines_.size() > 0)
     51        {
     52            // destroy lines
     53            delete this->lines_.back();
     54            this->lines_.pop_back();
     55        }
    4656    }
    4757
  • code/branches/pickup/src/modules/overlays/stats/Scoreboard.h

    r5781 r5935  
    4242    public: // functions
    4343        Scoreboard(BaseObject* creator);
    44         virtual ~Scoreboard() {}
     44        virtual ~Scoreboard();
    4545
    4646        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
  • code/branches/pickup/src/modules/pong/CMakeLists.txt

    r5781 r5935  
    11SET_SOURCE_FILES(PONG_SRC_FILES
     2COMPILATION_BEGIN PongCompilation.cc
    23  Pong.cc
    34  PongAI.cc
     
    78  PongCenterpoint.cc
    89  PongScore.cc
     10COMPILATION_END
    911)
    1012
     
    1214  MODULE
    1315  FIND_HEADER_FILES
    14   PCH_FILE
    15     PongPrecompiledHeaders.h
    16   PCH_NO_DEFAULT
    1716  DEFINE_SYMBOL
    1817    "PONG_SHARED_BUILD"
  • code/branches/pickup/src/modules/pong/Pong.cc

    r5781 r5935  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/EventIncludes.h"
    3233#include "core/Executor.h"
    3334#include "PongCenterpoint.h"
     
    3940namespace orxonox
    4041{
     42    CreateEventName(PongCenterpoint, right);
     43    CreateEventName(PongCenterpoint, left);
     44   
    4145    CreateUnloadableFactory(Pong);
    4246
     
    5256        this->setHUDTemplate("PongHUD");
    5357
    54         this->starttimer_.setTimer(1.0, false, this, createExecutor(createFunctor(&Pong::startBall)));
     58        this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this)));
    5559        this->starttimer_.stopTimer();
    5660
     
    7276            this->ball_->setFieldDimension(this->center_->getFieldDimension());
    7377            this->ball_->setSpeed(0);
     78            this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor());
    7479            this->ball_->setBatLength(this->center_->getBatLength());
    7580
     
    120125        if (this->ball_)
    121126        {
    122             delete this->ball_;
     127            this->ball_->destroy();
    123128            this->ball_ = 0;
    124129        }
     
    155160        if (this->center_)
    156161        {
    157             this->center_->fireEvent();
    158 
     162            if (player == this->getRightPlayer())
     163                this->center_->fireEvent(FireEventName(PongCenterpoint, right));
     164            else if (player == this->getLeftPlayer())
     165                this->center_->fireEvent(FireEventName(PongCenterpoint, left));
     166           
    159167            if (player)
    160                 this->gtinfo_.sendAnnounceMessage(player->getName() + " scored");
     168                this->gtinfo_->sendAnnounceMessage(player->getName() + " scored");
    161169        }
    162170
     
    165173            this->ball_->setPosition(Vector3::ZERO);
    166174            this->ball_->setVelocity(Vector3::ZERO);
     175            this->ball_->setAcceleration(Vector3::ZERO);
    167176            this->ball_->setSpeed(0);
    168177        }
  • code/branches/pickup/src/modules/pong/Pong.h

    r5781 r5935  
    6262            PongBall* ball_;
    6363            PongBat* bat_[2];
    64             Timer<Pong> starttimer_;
     64            Timer starttimer_;
    6565    };
    6666}
  • code/branches/pickup/src/modules/pong/PongAI.cc

    r5781 r5935  
    4949        this->ballEndPosition_ = 0;
    5050        this->randomOffset_ = 0;
     51        this->bChangedRandomOffset_ = false;
    5152        this->relHysteresisOffset_ = 0.02f;
    5253        this->strength_ = 0.5f;
     
    6061    PongAI::~PongAI()
    6162    {
    62         for (std::list<std::pair<Timer<PongAI>*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
    63             delete (*it).first;
     63        for (std::list<std::pair<Timer*, char> >::iterator it = this->reactionTimers_.begin(); it != this->reactionTimers_.end(); ++it)
     64            (*it).first->destroy();
    6465    }
    6566
     
    113114                this->ballEndPosition_ = 0;
    114115                this->randomOffset_ = 0;
     116                this->bChangedRandomOffset_ = false;
    115117
    116118                this->calculateRandomOffset();
     
    129131                this->bOscillationAvoidanceActive_ = false;
    130132            }
     133           
     134            // If the ball is close enough, calculate another random offset to accelerate the ball
     135            if (!this->bChangedRandomOffset_)
     136            {
     137                float timetohit = (-this->ball_->getPosition().x + this->ball_->getFieldDimension().x / 2 * sgn(this->ball_->getVelocity().x)) / this->ball_->getVelocity().x;
     138                if (timetohit < 0.05)
     139                {
     140                    this->bChangedRandomOffset_ = true;
     141                    if (rnd() < this->strength_)
     142                        this->calculateRandomOffset();
     143                }
     144            }
    131145
    132146            // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat)
     
    184198        Vector3 position = this->ball_->getPosition();
    185199        Vector3 velocity = this->ball_->getVelocity();
     200        Vector3 acceleration = this->ball_->getAcceleration();
    186201        Vector2 dimension = this->ball_->getFieldDimension();
    187202
    188         // calculate end-height: current height + slope * distance
    189         this->ballEndPosition_ = position.z + velocity.z / velocity.x * (-position.x + dimension.x / 2 * sgn(velocity.x));
    190 
    191         // Calculate bounces
    192         for (float limit = 0.35f; limit < this->strength_ || this->strength_ > 0.99f; limit += 0.4f)
    193         {
    194             // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
    195             float randomError = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
    196 
    197             // Bounce from the lower bound
    198             if (this->ballEndPosition_ > dimension.y / 2)
    199             {
    200                 // Mirror the predicted position at the upper bound and add some random error
    201                 this->ballEndPosition_ = dimension.y - this->ballEndPosition_ + randomError;
    202                 continue;
    203             }
    204             // Bounce from the upper bound
    205             if (this->ballEndPosition_ < -dimension.y / 2)
    206             {
    207                 // Mirror the predicted position at the lower bound and add some random error
    208                 this->ballEndPosition_ = -dimension.y - this->ballEndPosition_ + randomError;
    209                 continue;
    210             }
    211             // No bounce - break
    212             break;
     203        // Calculate bounces. The number of predicted bounces is limited by the AIs strength
     204        for (float limit = -0.05f; limit < this->strength_ || this->strength_ > 0.99f; limit += 0.4f)
     205        {
     206            // calculate the time until the ball reaches the other side
     207            float totaltime = (-position.x + dimension.x / 2 * sgn(velocity.x)) / velocity.x;
     208           
     209            // calculate wall bounce position (four possible solutions of the equation: pos.z + vel.z*t + acc.z/2*t^2 = +/- dim.z/2)
     210            float bouncetime = totaltime;
     211            bool bUpperWall = false;
     212           
     213            if (acceleration.z == 0)
     214            {
     215                if (velocity.z > 0)
     216                {
     217                    bUpperWall = true;
     218                    bouncetime = (dimension.y/2 - position.z) / velocity.z;
     219                }
     220                else if (velocity.z < 0)
     221                {
     222                    bUpperWall = false;
     223                    bouncetime = (-dimension.y/2 - position.z) / velocity.z;
     224                }
     225            }
     226            else
     227            {
     228                // upper wall
     229                float temp = velocity.z*velocity.z + 2*acceleration.z*(dimension.y/2 - position.z);
     230                if (temp >= 0)
     231                {
     232                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
     233                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
     234                    if (t1 > 0 && t1 < bouncetime)
     235                    {
     236                        bouncetime = t1;
     237                        bUpperWall = true;
     238                    }
     239                    if (t2 > 0 && t2 < bouncetime)
     240                    {
     241                        bouncetime = t2;
     242                        bUpperWall = true;
     243                    }
     244                }
     245                // lower wall
     246                temp = velocity.z*velocity.z - 2*acceleration.z*(dimension.y/2 + position.z);
     247                if (temp >= 0)
     248                {
     249                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
     250                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
     251                    if (t1 > 0 && t1 < bouncetime)
     252                    {
     253                        bouncetime = t1;
     254                        bUpperWall = false;
     255                    }
     256                    if (t2 > 0 && t2 < bouncetime)
     257                    {
     258                        bouncetime = t2;
     259                        bUpperWall = false;
     260                    }
     261                }
     262            }
     263
     264            if (bouncetime < totaltime)
     265            {
     266                // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
     267                float randomErrorX = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
     268                float randomErrorZ = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
     269
     270                // ball bounces after <bouncetime> seconds, update the position and continue
     271                velocity.z = velocity.z + acceleration.z * bouncetime;
     272               
     273                if (bUpperWall)
     274                {
     275                    position.z = dimension.y / 2;
     276                    velocity.z = -fabs(velocity.z) + fabs(randomErrorZ);
     277                }
     278                else
     279                {
     280                    position.z = -dimension.y / 2;
     281                    velocity.z = fabs(velocity.z) - fabs(randomErrorZ);
     282                }
     283                   
     284                position.x = position.x + velocity.x * bouncetime + randomErrorX;
     285                this->ballEndPosition_ = position.z;
     286            }
     287            else
     288            {
     289                // ball doesn't bounce, calculate the end position and return
     290                // calculate end-height: current height + slope * distance incl. acceleration
     291                this->ballEndPosition_ = position.z + velocity.z * totaltime + acceleration.z / 2 * totaltime * totaltime;
     292                return;
     293            }
    213294        }
    214295    }
     
    231312
    232313            // Add a new Timer
    233             Timer<PongAI>* timer = new Timer<PongAI>(delay, false, this, createExecutor(createFunctor(&PongAI::delayedMove)));
    234             this->reactionTimers_.push_back(std::pair<Timer<PongAI>*, char>(timer, direction));
     314            Timer* timer = new Timer(delay, false, createExecutor(createFunctor(&PongAI::delayedMove, this)));
     315            this->reactionTimers_.push_back(std::pair<Timer*, char>(timer, direction));
    235316        }
    236317        else
     
    246327
    247328        // Destroy the timer and remove it from the list
    248         Timer<PongAI>* timer = this->reactionTimers_.front().first;
    249         delete timer;
     329        Timer* timer = this->reactionTimers_.front().first;
     330        timer->destroy();
    250331
    251332        this->reactionTimers_.pop_front();
  • code/branches/pickup/src/modules/pong/PongAI.h

    r5781 r5935  
    6262            float ballEndPosition_;
    6363            float randomOffset_;
     64            bool bChangedRandomOffset_;
    6465            float relHysteresisOffset_;
    6566            float strength_;
    6667
    67             std::list<std::pair<Timer<PongAI>*, char> > reactionTimers_;
     68            std::list<std::pair<Timer*, char> > reactionTimers_;
    6869            char movement_;
    6970            char oldMove_;
  • code/branches/pickup/src/modules/pong/PongBall.cc

    r5781 r5935  
    3333#include "gametypes/Gametype.h"
    3434#include "PongBat.h"
    35 #include "sound/SoundBase.h"
    3635
    3736namespace orxonox
     
    4140    const float PongBall::MAX_REL_Z_VELOCITY = 1.5;
    4241
    43     PongBall::PongBall(BaseObject* creator) : MovableEntity(creator)
     42    PongBall::PongBall(BaseObject* creator)
     43        : MovableEntity(creator)
    4444    {
    4545        RegisterObject(PongBall);
    4646
    4747        this->speed_ = 0;
     48        this->accelerationFactor_ = 1.0f;
    4849        this->bat_ = 0;
    4950        this->batID_ = new unsigned int[2];
     
    5354
    5455        this->registerVariables();
     56    }
    5557
    56         this->sidesound_ = new SoundBase(this);
    57         this->sidesound_->loadFile("sounds/pong_side.wav");
    58 
    59         this->batsound_ = new SoundBase(this);
    60         this->batsound_->loadFile("sounds/pong_bat.wav");
    61 
    62         this->scoresound_ = new SoundBase(this);
    63         this->scoresound_->loadFile("sounds/pong_score.wav");
     58    PongBall::~PongBall()
     59    {
    6460    }
    6561
     
    7975        SUPER(PongBall, tick, dt);
    8076
    81         if (GameMode::isMaster())
     77        Vector3 position = this->getPosition();
     78        Vector3 velocity = this->getVelocity();
     79        Vector3 acceleration = this->getAcceleration();
     80
     81        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    8282        {
    83             Vector3 position = this->getPosition();
    84             Vector3 velocity = this->getVelocity();
     83            velocity.z = -velocity.z;
     84            if (position.z > this->fieldHeight_ / 2)
     85                position.z = this->fieldHeight_ / 2;
     86            if (position.z < -this->fieldHeight_ / 2)
     87                position.z = -this->fieldHeight_ / 2;
    8588
    86             if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     89            this->fireEvent();
     90        }
     91
     92        if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     93        {
     94            float distance = 0;
     95
     96            if (this->bat_)
    8797            {
    88                 velocity.z = -velocity.z;
    89                 this->sidesound_->play();
    90 
    91                 if (position.z > this->fieldHeight_ / 2)
    92                     position.z = this->fieldHeight_ / 2;
    93                 if (position.z < -this->fieldHeight_ / 2)
    94                     position.z = -this->fieldHeight_ / 2;
    95             }
    96 
    97             if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
    98             {
    99                 float distance = 0;
    100 
    101                 if (this->bat_)
     98                if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
    10299                {
    103                     if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
     100                    distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
     101                    if (fabs(distance) <= 1)
    104102                    {
    105                         distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    106                         if (fabs(distance) <= 1)
     103                        position.x = this->fieldWidth_ / 2;
     104                        velocity.x = -velocity.x;
     105                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     106                        acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
     107                       
     108                        this->fireEvent();
     109                    }
     110                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     111                    {
     112                        if (this->getGametype() && this->bat_[0])
    107113                        {
    108                             position.x = this->fieldWidth_ / 2;
    109                             velocity.x = -velocity.x;
    110                             velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    111                             this->batsound_->play();
    112                         }
    113                         else if (position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    114                         {
    115                             if (this->getGametype() && this->bat_[0])
    116                             {
    117                                 this->getGametype()->playerScored(this->bat_[0]->getPlayer());
    118                                 this->scoresound_->play();
    119                                 return;
    120                             }
     114                            this->getGametype()->playerScored(this->bat_[0]->getPlayer());
     115                            return;
    121116                        }
    122117                    }
    123                     if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
     118                }
     119                if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
     120                {
     121                    distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
     122                    if (fabs(distance) <= 1)
    124123                    {
    125                         distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    126                         if (fabs(distance) <= 1)
     124                        position.x = -this->fieldWidth_ / 2;
     125                        velocity.x = -velocity.x;
     126                        velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
     127                        acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1;
     128
     129                        this->fireEvent();
     130                    }
     131                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     132                    {
     133                        if (this->getGametype() && this->bat_[1])
    127134                        {
    128                             position.x = -this->fieldWidth_ / 2;
    129                             velocity.x = -velocity.x;
    130                             velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    131                             this->batsound_->play();
    132                         }
    133                         else if (position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
    134                         {
    135                             if (this->getGametype() && this->bat_[1])
    136                             {
    137                                 this->scoresound_->play();
    138                                 this->getGametype()->playerScored(this->bat_[1]->getPlayer());
    139                                 return;
    140                             }
     135                            this->getGametype()->playerScored(this->bat_[1]->getPlayer());
     136                            return;
    141137                        }
    142138                    }
    143139                }
    144140            }
     141        }
    145142
    146             if (velocity != this->getVelocity())
    147                 this->setVelocity(velocity);
    148             if (position != this->getPosition())
    149                 this->setPosition(position);
    150         }
    151         else
    152         {
    153           Vector3 position = this->getPosition();
    154           Vector3 velocity = this->getVelocity();
    155 
    156           if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    157           {
    158             velocity.z = -velocity.z;
    159             this->sidesound_->play();
    160 
    161             if (position.z > this->fieldHeight_ / 2)
    162               position.z = this->fieldHeight_ / 2;
    163             if (position.z < -this->fieldHeight_ / 2)
    164               position.z = -this->fieldHeight_ / 2;
    165           }
    166 
    167           if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
    168           {
    169             float distance = 0;
    170 
    171             if (this->bat_)
    172             {
    173               if (position.x > this->fieldWidth_ / 2 && this->bat_[1])
    174               {
    175                 distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    176                 if (fabs(distance) <= 1)
    177                 {
    178                   position.x = this->fieldWidth_ / 2;
    179                   velocity.x = -velocity.x;
    180                   this->batsound_->play();
    181                   velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    182                 }
    183               }
    184               if (position.x < -this->fieldWidth_ / 2 && this->bat_[0])
    185               {
    186                 distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
    187                 if (fabs(distance) <= 1)
    188                 {
    189                   position.x = -this->fieldWidth_ / 2;
    190                   velocity.x = -velocity.x;
    191                   this->batsound_->play();
    192                   velocity.z = distance * distance * sgn(distance) * PongBall::MAX_REL_Z_VELOCITY * this->speed_;
    193                 }
    194               }
    195             }
    196           }
    197 
    198           if (velocity != this->getVelocity())
     143        if (acceleration != this->getAcceleration())
     144            this->setAcceleration(acceleration);
     145        if (velocity != this->getVelocity())
    199146            this->setVelocity(velocity);
    200           if (position != this->getPosition())
     147        if (position != this->getPosition())
    201148            this->setPosition(position);
    202         }
    203149    }
    204150
  • code/branches/pickup/src/modules/pong/PongBall.h

    r5781 r5935  
    4141        public:
    4242            PongBall(BaseObject* creator);
    43             virtual ~PongBall() {}
     43            virtual ~PongBall();
    4444
    4545            virtual void tick(float dt);
     
    5858                { return this->speed_; }
    5959
     60            void setAccelerationFactor(float factor)
     61                { this->accelerationFactor_ = factor; }
     62            float getAccelerationFactor() const
     63                { return this->accelerationFactor_; }
     64
    6065            void setBatLength(float batlength)
    6166                { this->batlength_ = batlength; }
     
    7277            float fieldHeight_;
    7378            float speed_;
     79            float accelerationFactor_;
    7480            float batlength_;
    7581            PongBat** bat_;
    7682            unsigned int* batID_;
    7783            float relMercyOffset_;
    78 
    79             SoundBase* sidesound_;
    80             SoundBase* batsound_;
    81             SoundBase* scoresound_;
    8284    };
    8385}
  • code/branches/pickup/src/modules/pong/PongCenterpoint.cc

    r5781 r5935  
    4444        this->height_ = 120;
    4545        this->ballspeed_ = 100;
     46        this->ballaccfactor_ = 1.0;
    4647        this->batspeed_ = 60;
    4748        this->batlength_ = 0.25;
     
    5859        XMLPortParam(PongCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode);
    5960        XMLPortParam(PongCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
     61        XMLPortParam(PongCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
    6062        XMLPortParam(PongCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode);
    6163        XMLPortParam(PongCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode);
     
    7375        if (this->getGametype() && this->getGametype()->isA(Class(Pong)))
    7476        {
    75             Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype());
     77            Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype().get());
    7678            pong_gametype->setCenterpoint(this);
    7779        }
  • code/branches/pickup/src/modules/pong/PongCenterpoint.h

    r5781 r5935  
    6868                { return this->ballspeed_; }
    6969
     70            void setBallAccelerationFactor(float ballaccfactor)
     71                { this->ballaccfactor_ = ballaccfactor; }
     72            float getBallAccelerationFactor() const
     73                { return this->ballaccfactor_; }
     74
    7075            void setBatSpeed(float batspeed)
    7176                { this->batspeed_ = batspeed; }
     
    8590
    8691            float ballspeed_;
     92            float ballaccfactor_;
    8793            float batspeed_;
    8894            float batlength_;
  • code/branches/pickup/src/modules/pong/PongPrereqs.h

    r5794 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the pong module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
     39#include "OrxonoxPrereqs.h"
    3840
    3941//-----------------------------------------------------------------------
    4042// Shared library settings
    4143//-----------------------------------------------------------------------
     44
    4245#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4346#  ifdef PONG_SHARED_BUILD
  • code/branches/pickup/src/modules/pong/PongScore.cc

    r5781 r5935  
    133133
    134134        if (this->getOwner() && this->getOwner()->getGametype())
    135             this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype());
     135            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
    136136        else
    137137            this->owner_ = 0;
  • code/branches/pickup/src/modules/questsystem/QuestEffectBeacon.cc

    r5781 r5935  
    7575        XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode);
    7676
     77        XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode);
     78
    7779        COUT(3) << "New QuestEffectBeacon created." << std::endl;
    7880    }
    7981
    80     /**
    81     @brief
    82         Processes an event for this QuestEffectBeacon.
    83     */
    84     void QuestEffectBeacon::processEvent(Event& event)
    85     {
    86         SUPER(QuestEffectBeacon, processEvent, event);
    87 
    88         ORXONOX_SET_SUBCLASS_EVENT(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
     82    void QuestEffectBeacon::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     83    {
     84        SUPER(QuestEffectBeacon, XMLEventPort, xmlelement, mode);
     85
     86        XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode);
    8987    }
    9088
  • code/branches/pickup/src/modules/questsystem/QuestEffectBeacon.h

    r5781 r5935  
    8686
    8787            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
    88 
    89             virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
     88            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    9089
    9190            bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
  • code/branches/pickup/src/modules/questsystem/QuestGUI.cc

    r5781 r5935  
    7979       
    8080        if(this->root_ != NULL)
    81             delete this->root_;
     81            this->root_->destroy();
    8282    }
    8383
     
    146146            COUT(3) << "Clearing Node '" << *str << "' ..." << std::endl;
    147147            delete str;
    148             delete node;
     148            node->destroy();
    149149        }
    150150        this->nodes_.clear();
  • code/branches/pickup/src/modules/questsystem/QuestManager.cc

    r5781 r5935  
    4141#include "core/ConsoleCommand.h"
    4242#include "core/LuaState.h"
     43#include "core/ScopedSingletonManager.h"
    4344#include "infos/PlayerInfo.h"
    4445#include "overlays/GUIOverlay.h"
     
    5657    //! Pointer to the current (and single) instance of this class.
    5758    /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;
     59    ManageScopedSingleton(QuestManager, ScopeID::Root, false);
    5860
    5961    /**
     
    7678        for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++)
    7779        {
    78             delete (*it).second;
     80            (*it).second->destroy();
    7981        }
    8082        this->questGUIs_.clear();
  • code/branches/pickup/src/modules/questsystem/QuestManager.h

    r5781 r5935  
    4242#include <string>
    4343
    44 #include "util/ScopedSingleton.h"
     44#include "util/Singleton.h"
    4545#include "core/OrxonoxClass.h"
    4646
     
    5050namespace orxonox
    5151{
    52 
    53     typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua
    54 
    5552    /**
    5653    @brief
     
    6057        Damian 'Mozork' Frick
    6158    */
    62     class _QuestsystemExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass
    63     {
     59    class _QuestsystemExport QuestManager
    6460// tolua_end
     61        : public Singleton<QuestManager>, public orxonox::OrxonoxClass
     62    { // tolua_export
    6563
    66             friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
     64            friend class Singleton<QuestManager>;
    6765            friend class QuestGUI;
    6866
     
    7270
    7371            //! Returns a reference to the single instance of the Quest Manager.
    74             static QuestManager& getInstance() { return ScopedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export
     72            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
    7573
    7674            //! Retreive the main window for the GUI.
  • code/branches/pickup/src/modules/questsystem/QuestsystemPrecompiledHeaders.h

    r5781 r5935  
    5151#include <OgreColourValue.h> // 16
    5252
    53 #include <tinyxml/ticpp.h>        // 14
    54 #include "util/ScopedSingleton.h" // 13
     53#include <tinyxml/ticpp.h>   // 14
     54#include "util/Singleton.h" // 13
    5555
    5656///////////////////////////////////////////
  • code/branches/pickup/src/modules/questsystem/QuestsystemPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the questsystem module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
    38 
    3939#include "OrxonoxPrereqs.h"
    4040
     
    4242// Shared library settings
    4343//-----------------------------------------------------------------------
     44
    4445#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4546#  ifdef QUESTSYSTEM_SHARED_BUILD
     
    7677    class QuestEffect;
    7778    class QuestEffectBeacon;
     79    class QuestGUI;
    7880    class QuestGUINode;
    79     class QuestGUI;
    8081    class QuestHint;
    8182    class QuestItem;
     
    8384    class QuestManager;
    8485    class QuestNotification;
    85     class Rewardable;
    8686
     87    // notifications
    8788    class Notification;
    88     class NotificationListener;
    8989    class NotificationManager;
    9090    class NotificationOverlay;
  • code/branches/pickup/src/modules/questsystem/notifications/NotificationManager.cc

    r5781 r5935  
    3737
    3838#include "core/CoreIncludes.h"
     39#include "core/ScopedSingletonManager.h"
    3940#include "Notification.h"
    4041#include "interfaces/NotificationListener.h"
     
    4748
    4849    NotificationManager* NotificationManager::singletonPtr_s = NULL;
     50    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
    4951
    5052    /**
  • code/branches/pickup/src/modules/questsystem/notifications/NotificationManager.h

    r5781 r5935  
    4141#include <string>
    4242
    43 #include "util/ScopedSingleton.h"
     43#include "util/Singleton.h"
    4444#include "core/OrxonoxClass.h"
    4545
    4646namespace orxonox
    4747{
    48 
    4948    /**
    5049    @brief
     
    5453        Damian 'Mozork' Frick
    5554    */
    56     class _QuestsystemExport NotificationManager : public ScopedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass
     55    class _QuestsystemExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
    5756    {
    58             friend class ScopedSingleton<NotificationManager, ScopeID::GSLevel>;
     57            friend class Singleton<NotificationManager>;
    5958        public:
    6059            NotificationManager();
  • code/branches/pickup/src/modules/questsystem/notifications/NotificationQueue.cc

    r5781 r5935  
    426426        this->containers_.erase(container);
    427427        this->overlays_.erase(container->notification);
    428         delete container->overlay;
     428        container->overlay->destroy();
    429429        delete container;
    430430        this->size_= this->size_-1;
  • code/branches/pickup/src/modules/weapons/MuzzleFlash.cc

    r5781 r5935  
    4141        RegisterObject(MuzzleFlash);
    4242        this->setScale(0.1f);
    43        
    44         this->delayTimer_.setTimer(0.1f, false, this, createExecutor(createFunctor(&MuzzleFlash::destroy)));
    4543
     44        this->delayTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&MuzzleFlash::destroy, this)));
    4645    }
    47 
    48     void MuzzleFlash::destroy()
    49     {
    50         delete this;
    51     }
    52  
    5346}
  • code/branches/pickup/src/modules/weapons/MuzzleFlash.h

    r5781 r5935  
    4343            virtual ~MuzzleFlash() {}
    4444
    45 
    46 
    4745        private:
    48             void destroy();
    49             Timer<MuzzleFlash> delayTimer_;
    50 
     46            Timer delayTimer_;
    5147    };
    5248}
  • code/branches/pickup/src/modules/weapons/WeaponsPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the weapons module
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
    38 
    3939#include "OrxonoxPrereqs.h"
    4040
     
    4242// Shared library settings
    4343//-----------------------------------------------------------------------
     44
    4445#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4546#  ifdef WEAPONS_SHARED_BUILD
     
    6465namespace orxonox
    6566{
    66     class LaserFire;
     67    class MuzzleFlash;
     68
     69    // munitions
     70    class FusionMunition;
     71    class LaserMunition;
     72    class ReplenishingMunition;
     73
     74    // projectiles
     75    class BillboardProjectile;
     76    class LightningGunProjectile;
     77    class ParticleProjectile;
     78    class Projectile;
     79
     80    // weaponmodes
     81    class EnergyDrink;
    6782    class FusionFire;
    6883    class HsW01;
     84    class LaserFire;
    6985    class LightningGun;
    70     class EnergyDrink;
    71 
    72     class Projectile;
    73     class BillboardProjectile;
    74     class ParticleProjectile;
    75     class LightningGunProjectile;
    76 
    77     class ReplenishingMunition;
    78     class LaserMunition;
    79     class FusionMunition;
    80 
    81     class MuzzleFlash;
    8286}
    8387
  • code/branches/pickup/src/modules/weapons/munitions/ReplenishingMunition.cc

    r5781 r5935  
    4444        // replenishIntervall_ and replenishMunitionAmount_ will be set in the constructor of the
    4545        // inheriting class, which comes after this constructor)
    46         this->replenishingTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&ReplenishingMunition::initializeTimer)));
     46        this->replenishingTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&ReplenishingMunition::initializeTimer, this)));
    4747    }
    4848
     
    5050    {
    5151        // Initialize the timer
    52         this->replenishingTimer_.setTimer(this->replenishIntervall_, true, this, createExecutor(createFunctor(&ReplenishingMunition::replenish)));
     52        this->replenishingTimer_.setTimer(this->replenishIntervall_, true, createExecutor(createFunctor(&ReplenishingMunition::replenish, this)));
    5353    }
    5454
  • code/branches/pickup/src/modules/weapons/munitions/ReplenishingMunition.h

    r5781 r5935  
    5151            void initializeTimer();
    5252
    53             Timer<ReplenishingMunition> replenishingTimer_;
     53            Timer replenishingTimer_;
    5454    };
    5555}
  • code/branches/pickup/src/modules/weapons/projectiles/LightningGunProjectile.cc

    r5781 r5935  
    4242        this->textureIndex_ = 1;
    4343        this->maxTextureIndex_ = 8;
    44         this->textureTimer_.setTimer(0.01f, true, this, createExecutor(createFunctor(&LightningGunProjectile::changeTexture)));
     44        this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
    4545       
    4646        registerVariables();
  • code/branches/pickup/src/modules/weapons/projectiles/LightningGunProjectile.h

    r5781 r5935  
    5050            unsigned int textureIndex_;
    5151            unsigned int maxTextureIndex_;
    52             Timer<LightningGunProjectile> textureTimer_;
     52            Timer textureTimer_;
    5353            std::string materialBase_;
    5454      private:
  • code/branches/pickup/src/modules/weapons/projectiles/ParticleProjectile.cc

    r5781 r5935  
    5959        {
    6060            this->detachOgreObject(this->particles_->getParticleSystem());
    61             delete this->particles_;
     61            this->particles_->destroy();
    6262        }
    6363    }
  • code/branches/pickup/src/modules/weapons/projectiles/Projectile.cc

    r5781 r5935  
    6161            this->attachCollisionShape(shape);
    6262
    63             this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
     63            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Projectile::destroyObject, this)));
    6464        }
    6565    }
     
    8484
    8585        if (this->bDestroy_)
    86             delete this;
     86            this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick()
    8787    }
    8888
     
    9090    {
    9191        if (GameMode::isMaster())
    92             delete this;
     92            this->destroy();
    9393    }
    9494
     
    133133    }
    134134
    135     void Projectile::destroyedPawn(Pawn* pawn)
     135    void Projectile::setOwner(Pawn* owner)
    136136    {
    137         if (this->owner_ == pawn)
    138             this->owner_ = 0;
     137        this->owner_ = owner;
    139138    }
    140139}
  • code/branches/pickup/src/modules/weapons/projectiles/Projectile.h

    r5781 r5935  
    3333
    3434#include "tools/Timer.h"
    35 #include "interfaces/PawnListener.h"
    3635#include "worldentities/MovableEntity.h"
    3736
    3837namespace orxonox
    3938{
    40     class _WeaponsExport Projectile : public MovableEntity, public PawnListener
     39    class _WeaponsExport Projectile : public MovableEntity
    4140    {
    4241        public:
     
    4948            virtual void tick(float dt);
    5049            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    51             virtual void destroyedPawn(Pawn* pawn);
    5250
    5351            inline void setDamage(float damage)
     
    5654                { return this->damage_; }
    5755
    58             inline void setOwner(Pawn* owner)
    59                 { this->owner_ = owner; }
     56            void setOwner(Pawn* owner);
    6057            inline Pawn* getOwner() const
    6158                { return this->owner_; }
    6259
    6360        private:
    64             Pawn* owner_;
     61            WeakPtr<Pawn> owner_;
    6562            float lifetime_;
    6663            float damage_;
    6764            bool bDestroy_;
    68             Timer<Projectile> destroyTimer_;
     65            Timer destroyTimer_;
    6966    };
    7067}
  • code/branches/pickup/src/modules/weapons/weaponmodes/EnergyDrink.cc

    r5781 r5935  
    5454        this->setMunitionName("FusionMunition");
    5555
    56         this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&EnergyDrink::shot)));
     56        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this)));
    5757        this->delayTimer_.stopTimer();
    5858    }
  • code/branches/pickup/src/modules/weapons/weaponmodes/EnergyDrink.h

    r5781 r5935  
    5959            float speed_;
    6060            float delay_;
    61             Timer<EnergyDrink> delayTimer_;
     61            Timer delayTimer_;
    6262    };
    6363}
  • code/branches/pickup/src/modules/weapons/weaponmodes/HsW01.cc

    r5781 r5935  
    5454        this->setMunitionName("LaserMunition");
    5555
    56         this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&HsW01::shot)));
     56        this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this)));
    5757        this->delayTimer_.stopTimer();
    5858    }
  • code/branches/pickup/src/modules/weapons/weaponmodes/HsW01.h

    r5781 r5935  
    5757            float speed_;
    5858            float delay_;
    59             Timer<HsW01> delayTimer_;
     59            Timer delayTimer_;
    6060    };
    6161}
  • code/branches/pickup/src/orxonox/CMakeLists.txt

    r5781 r5935  
    2525
    2626SET_SOURCE_FILES(ORXONOX_SRC_FILES
     27  Level.cc
     28  LevelManager.cc
    2729  Main.cc
    28 
    29   CameraManager.cc
    30   LevelManager.cc
    3130  PawnManager.cc
    3231  PlayerManager.cc
    33 
    34   Level.cc
    3532  Radar.cc
     33COMPILATION_BEGIN SceneCompilation.cc
     34  CameraManager.cc
    3635  Scene.cc
     36COMPILATION_END
    3737)
    3838
    3939ADD_SUBDIRECTORY(collisionshapes)
    4040ADD_SUBDIRECTORY(controllers)
     41ADD_SUBDIRECTORY(gamestates)
    4142ADD_SUBDIRECTORY(gametypes)
    4243ADD_SUBDIRECTORY(graphics)
  • code/branches/pickup/src/orxonox/CameraManager.cc

    r5781 r5935  
    2626 *
    2727 */
     28
    2829#include "CameraManager.h"
    2930
     
    3435#include "util/StringUtils.h"
    3536#include "core/GameMode.h"
     37#include "core/GraphicsManager.h"
    3638#include "core/GUIManager.h"
    3739#include "core/ObjectList.h"
     40#include "core/ScopedSingletonManager.h"
    3841#include "tools/Shader.h"
    3942#include "graphics/Camera.h"
     
    4346{
    4447    CameraManager* CameraManager::singletonPtr_s = 0;
     48    ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
    4549
    46     CameraManager::CameraManager(Ogre::Viewport* viewport)
    47         : viewport_(viewport)
     50    CameraManager::CameraManager()
     51        : viewport_(GraphicsManager::getInstance().getViewport())
    4852    {
    49         this->fallbackCamera_ = 0;
     53        assert(GameMode::showsGraphics());
    5054    }
    5155
    5256    CameraManager::~CameraManager()
    5357    {
    54         if (this->fallbackCamera_)
    55             this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
     58        GUIManager::getInstance().setCamera(0);
    5659    }
    5760
    5861    Camera* CameraManager::getActiveCamera() const
    5962    {
    60         if (this->cameraList_.size() > 0)
     63        if (!this->cameraList_.empty())
    6164            return this->cameraList_.front();
    6265        else
     
    6669    void CameraManager::requestFocus(Camera* camera)
    6770    {
    68         if (!GameMode::showsGraphics())
    69             return;
    70 
    7171        // notify old camera (if it exists)
    72         if (this->cameraList_.size() > 0)
     72        if (!this->cameraList_.empty())
    7373            this->cameraList_.front()->removeFocus();
    74         else if (this->fallbackCamera_)
    75         {
    76             this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
    77             this->fallbackCamera_ = 0;
    78         }
    7974
    8075        camera->setFocus();
    8176
    8277        // make sure we don't add it twice
    83         for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
     78        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
    8479            if ((*it) == camera)
    85                 return;
    86 
     80                this->cameraList_.erase(it++);
     81            else
     82                ++it;
    8783        // add to list
    8884        this->cameraList_.push_front(camera);
     
    9187    void CameraManager::releaseFocus(Camera* camera)
    9288    {
    93         if (!GameMode::showsGraphics())
    94             return;
    95 
    9689        // notify the cam of releasing the focus
    97         if (this->cameraList_.front() == camera)
     90        if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
    9891        {
    9992            camera->removeFocus();
     
    10194
    10295            // set new focus if possible
    103             if (this->cameraList_.size() > 0)
     96            if (!this->cameraList_.empty())
    10497                this->cameraList_.front()->setFocus();
    105             else
    106             {
    107                 // there are no more cameras, create a fallback
    108                 if (!this->fallbackCamera_)
    109                     this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    110                 this->useCamera(this->fallbackCamera_);
    111             }
    11298        }
    11399        else
    114         {
    115100            this->cameraList_.remove(camera);
    116         }
    117101    }
    118102
  • code/branches/pickup/src/orxonox/CameraManager.h

    r5781 r5935  
    4242#include "util/OgreForwardRefs.h"
    4343#include "util/Singleton.h"
     44#include "core/OrxonoxClass.h"
     45#include "core/SmartPtr.h"
    4446
    4547namespace orxonox
    4648{
    47     class _OrxonoxExport CameraManager : public Singleton<CameraManager>
     49    class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass
    4850    {
    4951            friend class Singleton<CameraManager>;
    5052        public:
    51             CameraManager(Ogre::Viewport* viewport);
     53            CameraManager();
    5254            ~CameraManager();
    5355
     
    6668            std::list<Camera*>    cameraList_;
    6769            Ogre::Viewport*       viewport_;
    68             Ogre::Camera*         fallbackCamera_;
    6970
    7071            static CameraManager* singletonPtr_s;
  • code/branches/pickup/src/orxonox/Level.cc

    r5781 r5935  
    3030
    3131#include "util/Math.h"
    32 #include "core/Core.h"
    3332#include "core/CoreIncludes.h"
    3433#include "core/Loader.h"
     
    4039#include "gametypes/Gametype.h"
    4140#include "overlays/OverlayGroup.h"
    42 #include "sound/SoundBase.h"
    4341#include "LevelManager.h"
    4442
     
    5351        this->registerVariables();
    5452        this->xmlfilename_ = this->getFilename();
     53        this->xmlfile_ = 0;
    5554    }
    5655
     
    6463            if (this->xmlfile_)
    6564                Loader::unload(this->xmlfile_);
    66 
    67             if(this->ambientsound_ != NULL)
    68                 delete this->ambientsound_;
    6965        }
    7066    }
     
    7672        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
    7773        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    78 
    79         XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);
    8074
    8175        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
     
    116110            this->gametype_ = gametype;
    117111
    118 std::cout << "Load Gametype: " << this->gametype_ << std::endl;
    119 
    120112        Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this));
    121113        this->setGametype(rootgametype);
    122 
    123 std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;
    124114
    125115        for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
     
    149139    }
    150140
    151     void Level::loadAmbientSound(const std::string& filename)
    152     {
    153         if(filename == "") return;
    154         else
    155         {
    156             if(this->ambientsound_ == NULL)
    157             {
    158                 this->ambientsound_ = new SoundBase();
    159             }
    160 
    161             this->ambientsound_->loadFile(filename);
    162             this->ambientsound_->play(true);
    163         }
    164     }
    165 
    166141    void Level::playerEntered(PlayerInfo* player)
    167142    {
  • code/branches/pickup/src/orxonox/Level.h

    r5781 r5935  
    5353                { return this->description_; }
    5454
    55             void loadAmbientSound(const std::string& filename);
    56 
    5755            void playerEntered(PlayerInfo* player);
    5856            void playerLeft(PlayerInfo* player);
     
    7371            XMLFile*               xmlfile_;
    7472            std::list<BaseObject*> objects_;
    75 
    76             SoundBase*             ambientsound_;
    7773    };
    7874}
  • code/branches/pickup/src/orxonox/LevelManager.cc

    r5781 r5935  
    3434#include "core/CommandLine.h"
    3535#include "core/ConfigValueIncludes.h"
    36 #include "core/Core.h"
    3736#include "core/CoreIncludes.h"
    3837#include "core/Loader.h"
     38#include "core/ScopedSingletonManager.h"
    3939#include "PlayerManager.h"
    4040#include "Level.h"
    41 #include "infos/HumanPlayer.h"
    4241
    4342namespace orxonox
     
    4645
    4746    LevelManager* LevelManager::singletonPtr_s = 0;
     47    ManageScopedSingleton(LevelManager, ScopeID::Root, false);
    4848
    4949    LevelManager::LevelManager()
  • code/branches/pickup/src/orxonox/Main.cc

    r5781 r5935  
    3131@file
    3232@brief
    33     The main function of Orxonox.
     33    The main function of Orxonox (but not the entry point of the program!)
    3434*/
    3535
    3636#include "OrxonoxPrereqs.h"
    37 #include "SpecialConfig.h"
    3837
    39 #include "util/Exception.h"
    4038#include "core/CommandLine.h"
    4139#include "core/Game.h"
     
    5048SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
    5149SetCommandLineSwitch(standalone).information("Start in standalone mode");
     50SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode");
    5251
    5352DeclareToluaInterface(Orxonox);
     
    5756    /**
    5857    @brief
    59         Main method. Game starts here (except for static initialisations).
     58        Starting point of orxonox (however not the entry point of the program!)
    6059    */
    6160    int main(const std::string& strCmdLine)
     
    6766        " graphics"
    6867        "  mainMenu"
    69         "  standalone"
     68        "  standalone,server,client"
    7069        "   level"
    71         "  server"
    72         "   level"
    73         "  client"
    74         "   level"
    75         " dedicated"
     70        " dedicated,dedicatedClient"
    7671        "  level"
    7772        " ioConsole"
     
    8984        else if (CommandLine::getValue("dedicated").getBool())
    9085            Game::getInstance().requestStates("dedicated, level");
     86        else if (CommandLine::getValue("dedicatedClient").getBool())
     87            Game::getInstance().requestStates("dedicatedClient, level");
    9188        else if (CommandLine::getValue("console").getBool())
    9289            Game::getInstance().requestStates("ioConsole");
  • code/branches/pickup/src/orxonox/OrxonoxPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the orxonox library
    3233*/
    3334
     
    3637
    3738#include "OrxonoxConfig.h"
    38 
    3939#include "tools/ToolsPrereqs.h"
    4040
     
    4242// Shared library settings
    4343//-----------------------------------------------------------------------
     44
    4445#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4546#  ifdef ORXONOX_SHARED_BUILD
     
    6566{
    6667    class CameraManager;
     68    class Level;
    6769    class LevelManager;
    6870    class PawnManager;
    6971    class PlayerManager;
    70 
    71     class Level;
     72    class Radar;
    7273    class Scene;
    73     class Tickable;
     74
     75    // collisionshapes
     76    class CollisionShape;
     77    class CompoundCollisionShape;
     78    class WorldEntityCollisionShape;
     79
     80    // controllers
     81    class AIController;
     82    class ArtificialController;
     83    class Controller;
     84    class HumanController;
     85    class ScriptController;
     86    class WaypointController;
     87    class WaypointPatrolController;
     88
     89    // gametypes
     90    class Asteroids;
     91    class Deathmatch;
     92    class Gametype;
     93    class TeamBaseMatch;
     94    class TeamDeathmatch;
     95    class UnderAttack;
     96
     97    // graphics
     98    class Backlight;
     99    class Billboard;
     100    class BlinkingBillboard;
     101    class Camera;
     102    class FadingBillboard;
     103    class GlobalShader;
     104    class Light;
     105    class Model;
     106    class ParticleEmitter;
     107    class ParticleSpawner;
     108
     109    // infos
     110    class Bot;
     111    class GametypeInfo;
     112    class HumanPlayer;
     113    class Info;
     114    class PlayerInfo;
    74115
    75116    // interfaces
    76117    class GametypeMessageListener;
    77118    class NotificationListener;
    78     class PawnListener;
    79119    class PlayerTrigger;
    80120    class RadarListener;
    81121    class RadarViewable;
    82122    class Rewardable;
    83     class Teamcolourable;
    84 
    85     // worldentities
    86     class WorldEntity;
    87     class StaticEntity;
    88     class MobileEntity;
    89     class ControllableEntity;
    90     class MovableEntity;
    91 
    92     // graphics
    93     class Model;
    94     class Billboard;
    95     class BlinkingBillboard;
    96     class BigExplosion;
    97     class ExplosionChunk;
    98     class FadingBillboard;
    99     class GlobalShader;
    100     class Light;
    101     class Backlight;
    102     class ParticleEmitter;
    103     class ParticleSpawner;
    104     class Camera;
    105 
    106     // mixed
    107     class SpawnPoint;
    108     class TeamSpawnPoint;
    109 
    110     class CameraPosition;
    111     class Sublevel;
    112     class Radar;
    113 
    114     class Test;
    115 
    116     // pawns
    117     class Spectator;
    118     class Pawn;
    119     class SpaceShip;
    120     class TeamBaseMatchBase;
    121     class Destroyer;
    122 
    123     // gametypes
    124     class Gametype;
    125     class Deathmatch;
    126     class TeamDeathmatch;
    127     class Asteroids;
    128     class TeamBaseMatch;
    129     class UnderAttack;
    130 
    131     // pickups
     123    class TeamColourable;
     124
     125    // items
     126    class Engine;
     127    class Item;
     128    class MultiStateEngine;
     129
     130    // overlays
     131    class InGameConsole;
     132    class Map;
     133    class OrxonoxOverlay;
     134    class OverlayGroup;
     135
     136    // pickup
    132137    class BaseItem;
    133138    class DroppedItem;
     
    139144    class PickupSpawner;
    140145    class UsableItem;
    141 
     146    // pickup, items
     147    class HealthImmediate;
     148    class HealthUsable;
    142149    class Jump;
    143     class HealthUsable;
    144     class PassiveItem;
    145 
    146     // items
    147     class Item;
    148     class Engine;
    149     class MultiStateEngine;
    150     class RotatingEngine;
     150
     151    //sound
     152    class AmbientSound;
     153    class BaseSound;
     154    class SoundManager;
     155    class WorldSound;
    151156
    152157    // weaponsystem
    153     class WeaponSystem;
     158    class DefaultWeaponmodeLink;
     159    class Munition;
     160    class Weapon;
     161    class WeaponMode;
     162    class WeaponPack;
    154163    class WeaponSet;
    155164    class WeaponSlot;
    156     class WeaponPack;
    157     class Weapon;
    158     class WeaponMode;
    159     class DefaultWeaponmodeLink;
    160     class Munition;
    161 
    162     // controller
    163     class Controller;
    164     class HumanController;
    165     class ArtificialController;
    166     class AIController;
    167     class ScriptController;
    168     class WaypointController;
    169     class WaypointPatrolController;
    170 
    171     // infos
    172     class Info;
    173     class PlayerInfo;
    174     class HumanPlayer;
    175     class Bot;
    176     class GametypeInfo;
    177 
    178     // collision
    179     class CollisionShape;
    180     class CompoundCollisionShape;
    181     class WorldEntityCollisionShape;
    182 
    183     // overlays
    184     class OverlayGroup;
    185     class OrxonoxOverlay;
    186     class Notification;
    187     class NotificationManager;
    188     class InGameConsole;
    189     class Map;
    190 
    191     //sound
    192     class SoundBase;
    193     class SoundManager;
    194     class SoundMainMenu;
     165    class WeaponSystem;
     166
     167    // worldentities
     168    class BigExplosion;
     169    class CameraPosition;
     170    class ControllableEntity;
     171    class ExplosionChunk;
     172    class MobileEntity;
     173    class MovableEntity;
     174    class SpawnPoint;
     175    class StaticEntity;
     176    class TeamSpawnPoint;
     177    class WorldEntity;
     178    // worldentities, pawns
     179    class Destroyer;
     180    class Pawn;
     181    class SpaceShip;
     182    class Spectator;
     183    class TeamBaseMatchBase;
    195184}
    196185
  • code/branches/pickup/src/orxonox/PawnManager.cc

    r5781 r5935  
    5757        {
    5858            if (!it->isAlive())
    59                 delete (*(it++));
     59                (it++)->destroy();
    6060            else
    6161                ++it;
     
    6363
    6464        if (count == 0)
    65             delete this;
     65            this->destroy();
    6666    }
    6767}
  • code/branches/pickup/src/orxonox/PlayerManager.cc

    r5781 r5935  
    3131#include "core/CoreIncludes.h"
    3232#include "core/GameMode.h"
     33#include "core/ScopedSingletonManager.h"
    3334#include "Level.h"
    3435#include "infos/HumanPlayer.h"
     
    3839{
    3940    PlayerManager* PlayerManager::singletonPtr_s = 0;
     41    ManageScopedSingleton(PlayerManager, ScopeID::Root, false);
    4042
    4143    PlayerManager::PlayerManager()
     
    7476        if (GameMode::isMaster())
    7577        {
    76             COUT(3) << "client disconnected" << std::endl;
     78            if (clientID != 0)
     79                COUT(3) << "client disconnected" << std::endl;
    7780
    7881            // remove from clients-map
     
    8588            // delete PlayerInfo instance
    8689            if (player)
    87                 delete player;
     90                player->destroy();
    8891        }
    8992    }
  • code/branches/pickup/src/orxonox/PlayerManager.h

    r5781 r5935  
    5050                { return this->clients_; }
    5151
    52         private:
    5352            void clientConnected(unsigned int clientID);
    5453            void clientDisconnected(unsigned int clientID);
    5554
     55        private:
    5656            std::map<unsigned int, PlayerInfo*> clients_;
    5757
  • code/branches/pickup/src/orxonox/Radar.cc

    r5781 r5935  
    4343namespace orxonox
    4444{
    45     SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);
    46     SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);
    47 
    48     Radar* Radar::instance_s = 0;
    4945
    5046    Radar::Radar()
     
    5248        , objectTypeCounter_(0)
    5349    {
    54         assert(instance_s == 0);
    55         instance_s = this;
    56 
    5750        // TODO: make this mapping configurable. Maybe there's a possibility with self configured
    5851        //       configValues..
     
    7972    Radar::~Radar()
    8073    {
    81         instance_s = 0;
    8274    }
    8375
    8476    const RadarViewable* Radar::getFocus()
    8577    {
    86         return *(this->itFocus_);
     78        if (this->itFocus_)
     79            return *(this->itFocus_);
     80        else
     81            return 0;
    8782    }
    8883
     
    10196        SUPER(Radar, tick, dt);
    10297
    103         if (this->focus_ != *(this->itFocus_))
     98        if (this->itFocus_ && (this->focus_ != *(this->itFocus_)))
    10499        {
    105100            // focus object was deleted, release focus
     
    191186        }
    192187    }
    193 
    194 
    195     /*static*/ Radar& Radar::getInstance()
    196     {
    197         assert(instance_s);
    198         return *instance_s;
    199     }
    200 
    201     /*static*/ void Radar::cycleNavigationFocus()
    202     {
    203         // avoid using getInstance because of the assert().
    204         // User might call this fuction even if HUDNavigation doesn't exist.
    205         if (instance_s)
    206             instance_s->cycleFocus();
    207     }
    208 
    209     /*static*/ void Radar::releaseNavigationFocus()
    210     {
    211         // avoid using getInstance because of the assert().
    212         // User might call this fuction even if HUDNavigation doesn't exist.
    213         if (instance_s)
    214             instance_s->releaseFocus();
    215     }
    216188}
  • code/branches/pickup/src/orxonox/Radar.h

    r5781 r5935  
    4646namespace orxonox
    4747{
    48     /**
    49     @brief This class merely ensures that no one can inherit from Radar.
    50     */
    51     class _OrxonoxExport RadarBase
    52     {
    53     private:
    54         friend class Radar;
    55         RadarBase() { }
    56     };
    57 
    58     class _OrxonoxExport Radar : public Tickable, private virtual RadarBase
     48    class _OrxonoxExport Radar : public Tickable
    5949    {
    6050    public:
    6151        Radar();
    62         ~Radar();
     52        virtual ~Radar();
    6353
    6454        virtual void tick(float dt);
     
    6959        void listObjects() const;
    7060
    71         static Radar& getInstance();
    72         static Radar* getInstancePtr() { return instance_s; }
    73 
    74         static void cycleNavigationFocus();
    75         static void releaseNavigationFocus();
     61        void releaseFocus();
     62        void cycleFocus();
    7663
    7764    private:
    7865        Radar(Radar& instance);
    7966
    80         void releaseFocus();
    8167        void updateFocus();
    82         void cycleFocus();
    8368
    8469        ObjectListIterator<RadarViewable> itFocus_;
     
    8671        std::map<std::string, RadarViewable::Shape> objectTypes_;
    8772        int objectTypeCounter_;
    88 
    89         static Radar* instance_s;
    9073    };
    9174}
  • code/branches/pickup/src/orxonox/Scene.cc

    r5781 r5935  
    4242#include "core/CoreIncludes.h"
    4343#include "core/GameMode.h"
     44#include "core/GUIManager.h"
    4445#include "core/XMLPort.h"
    4546#include "tools/BulletConversions.h"
     47#include "Radar.h"
    4648#include "worldentities/WorldEntity.h"
    4749
     
    5456        RegisterObject(Scene);
    5557
    56         this->setScene(this);
     58        this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
    5759        this->bShadows_ = true;
    5860
     
    6264            this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
    6365            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     66
     67            this->radar_ = new Radar();
    6468        }
    6569        else
     
    6872            this->sceneManager_ = new Ogre::DefaultSceneManager("");
    6973            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     74
     75            this->radar_ = 0;
    7076        }
    7177
     
    9298            else
    9399                delete this->sceneManager_;
     100
     101            if (this->radar_)
     102                this->radar_->destroy();
    94103
    95104            this->setPhysicalWorld(false);
     
    275284    {
    276285        this->objects_.push_back(object);
    277         object->setScene(this);
     286        object->setScene(this, this->getObjectID());
    278287    }
    279288
  • code/branches/pickup/src/orxonox/Scene.h

    r5781 r5935  
    7171                { return this->bShadows_; }
    7272
     73            inline Radar* getRadar()
     74                { return this->radar_; }
     75           
     76            inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
     77
    7378            virtual void tick(float dt);
    7479
     
    9196            std::list<BaseObject*>   objects_;
    9297            bool                     bShadows_;
     98            Radar*                   radar_;
    9399
    94100
  • code/branches/pickup/src/orxonox/Test.cc

    r5781 r5935  
    6363    setConfigValues();
    6464    registerVariables();
    65                 setObjectMode(0x3);
     65                setSyncMode(0x3);
    6666        }
    6767
  • code/branches/pickup/src/orxonox/collisionshapes/CompoundCollisionShape.cc

    r5781 r5935  
    5656                // make sure that the child doesn't want to detach itself --> speedup because of the missing update
    5757                it->first->notifyDetached();
    58                 delete it->first;
     58                it->first->destroy();
    5959            }
    6060
  • code/branches/pickup/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc

    r5781 r5935  
    4343        this->worldEntityOwner_ = creator;
    4444        // suppress synchronisation
    45         this->setObjectMode(0x0);
     45        this->setSyncMode(0x0);
    4646    }
    4747
  • code/branches/pickup/src/orxonox/controllers/AIController.cc

    r5781 r5935  
    4444        RegisterObject(AIController);
    4545
    46         this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
     46        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&AIController::action, this)));
    4747    }
    4848
  • code/branches/pickup/src/orxonox/controllers/AIController.h

    r5781 r5935  
    5050
    5151        private:
    52             Timer<AIController> actionTimer_;
     52            Timer actionTimer_;
    5353    };
    5454}
  • code/branches/pickup/src/orxonox/controllers/ArtificialController.cc

    r5781 r5935  
    4646        this->bHasTargetPosition_ = false;
    4747        this->targetPosition_ = Vector3::ZERO;
     48       
     49        this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
    4850    }
    4951
     
    162164    }
    163165
    164     void ArtificialController::destroyedPawn(Pawn* ship)
    165     {
    166         if (ship == this->target_)
    167         {
    168             this->forgetTarget();
    169             this->searchRandomTargetPosition();
    170         }
     166    void ArtificialController::abandonTarget(Pawn* target)
     167    {
     168        if (target == this->target_)
     169            this->targetDied();
     170    }
     171
     172    void ArtificialController::targetDied()
     173    {
     174        this->forgetTarget();
     175        this->searchRandomTargetPosition();
    171176    }
    172177
  • code/branches/pickup/src/orxonox/controllers/ArtificialController.h

    r5781 r5935  
    3333
    3434#include "util/Math.h"
    35 #include "interfaces/PawnListener.h"
    3635#include "Controller.h"
    3736
    3837namespace orxonox
    3938{
    40     class _OrxonoxExport ArtificialController : public Controller, public PawnListener
     39    class _OrxonoxExport ArtificialController : public Controller
    4140    {
    4241        public:
    4342            ArtificialController(BaseObject* creator);
    4443            virtual ~ArtificialController();
    45 
    46             virtual void destroyedPawn(Pawn* pawn);
     44           
     45            void abandonTarget(Pawn* target);
    4746
    4847        protected:
     48            void targetDied();
     49
    4950            void moveToPosition(const Vector3& target);
    5051            void moveToTargetPosition();
     
    6566            bool bHasTargetPosition_;
    6667            Vector3 targetPosition_;
    67             Pawn* target_;
     68            WeakPtr<Pawn> target_;
    6869            bool bShooting_;
    6970
  • code/branches/pickup/src/orxonox/controllers/HumanController.cc

    r5781 r5935  
    3636#include "infos/PlayerInfo.h"
    3737#include "overlays/Map.h"
     38#include "graphics/Camera.h"
     39#include "sound/SoundManager.h"
     40#include "Radar.h"
     41#include "Scene.h"
    3842
    3943namespace orxonox
     
    5660    SetConsoleCommand(HumanController, dropItems,     true);
    5761    SetConsoleCommand(HumanController, useItem,       true);
     62    SetConsoleCommand(HumanController, cycleNavigationFocus,   true);
     63    SetConsoleCommand(HumanController, releaseNavigationFocus, true);
    5864
    5965    CreateUnloadableFactory(HumanController);
     
    7177    {
    7278        HumanController::localController_s = 0;
     79    }
     80
     81    void HumanController::tick(float dt)
     82    {
     83        if (GameMode::playsSound() && HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     84        {
     85            // Update sound listener
     86            Camera* camera = HumanController::localController_s->controllableEntity_->getCamera();
     87            if (camera)
     88            {
     89                SoundManager::getInstance().setListenerPosition(camera->getWorldPosition());
     90                SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation());
     91            }
     92            else
     93                COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
     94        }
    7395    }
    7496
     
    200222            return NULL;
    201223    }
     224
     225    void HumanController::cycleNavigationFocus()
     226    {
     227        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     228            HumanController::localController_s->controllableEntity_->getScene()->getRadar()->cycleFocus();
     229    }
     230
     231    void HumanController::releaseNavigationFocus()
     232    {
     233        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     234            HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus();
     235    }
    202236}
  • code/branches/pickup/src/orxonox/controllers/HumanController.h

    r5781 r5935  
    3131
    3232#include "OrxonoxPrereqs.h"
     33
     34#include "tools/interfaces/Tickable.h"
    3335#include "Controller.h"
    3436
    3537namespace orxonox
    3638{
    37     class _OrxonoxExport HumanController : public Controller
     39    class _OrxonoxExport HumanController : public Controller, public Tickable
    3840    {
    3941        public:
    4042            HumanController(BaseObject* creator);
    4143            virtual ~HumanController();
     44
     45            virtual void tick(float dt);
    4246
    4347            static void moveFrontBack(const Vector2& value);
     
    5862            static void dropItems();
    5963            static void useItem();
     64            static void cycleNavigationFocus();
     65            static void releaseNavigationFocus();
    6066
    6167            static void suicide();
  • code/branches/pickup/src/orxonox/controllers/WaypointController.cc

    r5781 r5935  
    5050        {
    5151            for (size_t i = 0; i < this->waypoints_.size(); ++i)
    52                 delete this->waypoints_[i];
     52                this->waypoints_[i]->destroy();
    5353        }
    5454    }
  • code/branches/pickup/src/orxonox/controllers/WaypointPatrolController.cc

    r5781 r5935  
    4545        this->alertnessradius_ = 500;
    4646
    47         this->patrolTimer_.setTimer(rnd(), true, this, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy)));
     47        this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy, this)));
    4848    }
    4949
  • code/branches/pickup/src/orxonox/controllers/WaypointPatrolController.h

    r5781 r5935  
    6161            int team_;
    6262            float alertnessradius_;
    63             Timer<WaypointPatrolController> patrolTimer_;
     63            Timer patrolTimer_;
    6464    };
    6565}
  • code/branches/pickup/src/orxonox/gametypes/Asteroids.cc

    r5781 r5935  
    5454        if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_)
    5555        {
    56             this->gtinfo_.sendAnnounceMessage("Time's up - you have lost the match!");
     56            this->gtinfo_->sendAnnounceMessage("Time's up - you have lost the match!");
    5757            this->end();
    5858        }
     
    6363        if (victim && victim->getPlayer())
    6464        {
    65             this->gtinfo_.sendAnnounceMessage("You're dead - you have lost the match!");
     65            this->gtinfo_->sendAnnounceMessage("You're dead - you have lost the match!");
    6666            this->end();
    6767        }
  • code/branches/pickup/src/orxonox/gametypes/Gametype.cc

    r5781 r5935  
    3333#include "core/ConfigValueIncludes.h"
    3434#include "core/GameMode.h"
     35#include "core/ConsoleCommand.h"
    3536
    3637#include "infos/PlayerInfo.h"
     
    4748    CreateUnloadableFactory(Gametype);
    4849
    49     Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator)
     50    Gametype::Gametype(BaseObject* creator) : BaseObject(creator)
    5051    {
    5152        RegisterObject(Gametype);
    52 
    53         this->setGametype(this);
     53       
     54        this->gtinfo_ = new GametypeInfo(creator);
     55
     56        this->setGametype(SmartPtr<Gametype>(this, false));
    5457
    5558        this->defaultControllableEntity_ = Class(Spectator);
     
    7679        else
    7780            this->scoreboard_ = 0;
     81       
     82        /* HACK HACK HACK */
     83        this->hackAddBots_ = createConsoleCommand( createFunctor(&Gametype::addBots, this), "hackAddBots");
     84        this->hackKillBots_ = createConsoleCommand( createFunctor(&Gametype::killBots, this), "hackKillBots");
     85        CommandExecutor::addConsoleCommandShortcut( this->hackAddBots_ );
     86        CommandExecutor::addConsoleCommandShortcut( this->hackKillBots_ );
     87        /* HACK HACK HACK */
     88    }
     89   
     90    Gametype::~Gametype()
     91    {
     92        if (this->isInitialized())
     93        {
     94            this->gtinfo_->destroy();
     95            if( this->hackAddBots_ )
     96                delete this->hackAddBots_;
     97            if( this->hackKillBots_ )
     98                delete this->hackKillBots_;
     99        }
    78100    }
    79101
     
    100122        }
    101123
    102         if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_)
    103             this->gtinfo_.startCountdown_ -= dt;
    104 
    105         if (!this->gtinfo_.bStarted_)
     124        if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
     125            this->gtinfo_->startCountdown_ -= dt;
     126
     127        if (!this->gtinfo_->bStarted_)
    106128            this->checkStart();
    107         else if (!this->gtinfo_.bEnded_)
     129        else if (!this->gtinfo_->bEnded_)
    108130            this->spawnDeadPlayersIfRequested();
    109131
     
    115137        this->addBots(this->numberOfBots_);
    116138
    117         this->gtinfo_.bStarted_ = true;
     139        this->gtinfo_->bStarted_ = true;
    118140
    119141        this->spawnPlayersIfRequested();
     
    122144    void Gametype::end()
    123145    {
    124         this->gtinfo_.bEnded_ = true;
     146        this->gtinfo_->bEnded_ = true;
    125147
    126148        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    130152                ControllableEntity* oldentity = it->first->getControllableEntity();
    131153
    132                 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator());
     154                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity);
    133155                if (oldentity->getCamera())
    134156                {
     
    243265
    244266                        if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
    245                             this->gtinfo_.sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());
     267                            this->gtinfo_->sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());
    246268                        if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
    247                             this->gtinfo_.sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());
     269                            this->gtinfo_->sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());
    248270                    }
    249271                }
     
    308330                it->second.state_ = PlayerState::Dead;
    309331
    310                 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
     332                if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
    311333                {
    312334                    this->spawnPlayerAsDefaultPawn(it->first);
     
    319341    void Gametype::checkStart()
    320342    {
    321         if (!this->gtinfo_.bStarted_)
    322         {
    323             if (this->gtinfo_.bStartCountdownRunning_)
    324             {
    325                 if (this->gtinfo_.startCountdown_ <= 0)
    326                 {
    327                     this->gtinfo_.bStartCountdownRunning_ = false;
    328                     this->gtinfo_.startCountdown_ = 0;
     343        if (!this->gtinfo_->bStarted_)
     344        {
     345            if (this->gtinfo_->bStartCountdownRunning_)
     346            {
     347                if (this->gtinfo_->startCountdown_ <= 0)
     348                {
     349                    this->gtinfo_->bStartCountdownRunning_ = false;
     350                    this->gtinfo_->startCountdown_ = 0;
    329351                    this->start();
    330352                }
     
    349371                    if (allplayersready && hashumanplayers)
    350372                    {
    351                         this->gtinfo_.startCountdown_ = this->initialStartCountdown_;
    352                         this->gtinfo_.bStartCountdownRunning_ = true;
     373                        this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
     374                        this->gtinfo_->bStartCountdownRunning_ = true;
    353375                    }
    354376                }
     
    419441            if (it->getGametype() == this)
    420442            {
    421                 delete (*(it++));
     443                (it++)->destroy();
    422444                ++i;
    423445            }
     446            else
     447                ++it;
    424448        }
    425449    }
  • code/branches/pickup/src/orxonox/gametypes/Gametype.h

    r5781 r5935  
    3737
    3838#include "core/BaseObject.h"
    39 #include "core/Identifier.h"
     39#include "core/SubclassIdentifier.h"
    4040#include "tools/interfaces/Tickable.h"
    4141#include "infos/GametypeInfo.h"
     
    6868        public:
    6969            Gametype(BaseObject* creator);
    70             virtual ~Gametype() {}
     70            virtual ~Gametype();
    7171
    7272            void setConfigValues();
     
    7575
    7676            inline const GametypeInfo* getGametypeInfo() const
    77                 { return &this->gtinfo_; }
     77                { return this->gtinfo_; }
    7878
    7979            inline bool hasStarted() const
    80                 { return this->gtinfo_.bStarted_; }
     80                { return this->gtinfo_->bStarted_; }
    8181            inline bool hasEnded() const
    82                 { return this->gtinfo_.bEnded_; }
     82                { return this->gtinfo_->bEnded_; }
    8383
    8484            virtual void start();
     
    114114
    115115            inline bool isStartCountdownRunning() const
    116                 { return this->gtinfo_.bStartCountdownRunning_; }
     116                { return this->gtinfo_->bStartCountdownRunning_; }
    117117            inline float getStartCountdown() const
    118                 { return this->gtinfo_.startCountdown_; }
     118                { return this->gtinfo_->startCountdown_; }
    119119
    120120            inline void setHUDTemplate(const std::string& name)
    121                 { this->gtinfo_.hudtemplate_ = name; }
     121                { this->gtinfo_->hudtemplate_ = name; }
    122122            inline const std::string& getHUDTemplate() const
    123                 { return this->gtinfo_.hudtemplate_; }
     123                { return this->gtinfo_->hudtemplate_; }
    124124
    125125            void addBots(unsigned int amount);
     
    163163            virtual void spawnDeadPlayersIfRequested();
    164164
    165             GametypeInfo gtinfo_;
     165            SmartPtr<GametypeInfo> gtinfo_;
    166166
    167167            bool bAutoStart_;
     
    184184            // Config Values
    185185            std::string scoreboardTemplate_;
     186           
     187            /* HACK HACK HACK */
     188            ConsoleCommand* hackAddBots_;
     189            ConsoleCommand* hackKillBots_;
     190            /* HACK HACK HACK */
    186191    };
    187192}
  • code/branches/pickup/src/orxonox/gametypes/TeamBaseMatch.cc

    r5781 r5935  
    4242        RegisterObject(TeamBaseMatch);
    4343
    44         this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));
    45         this->outputTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
     44        this->scoreTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::winPoints, this)));
     45        this->outputTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::showPoints, this)));
    4646
    4747        this->pointsTeam1_ = 0;
     
    6767                {
    6868                    base->setState(BaseState::ControlTeam1);
    69                     this->gtinfo_.sendAnnounceMessage("The red team captured a base");
     69                    this->gtinfo_->sendAnnounceMessage("The red team captured a base");
    7070                }
    7171                if (teamnr == 1)
    7272                {
    7373                    base->setState(BaseState::ControlTeam2);
    74                     this->gtinfo_.sendAnnounceMessage("The blue team captured a base");
     74                    this->gtinfo_->sendAnnounceMessage("The blue team captured a base");
    7575                }
    7676            }
     
    194194
    195195                if (it->second == winningteam)
    196                     this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     196                    this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
    197197                else
    198                     this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     198                    this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    199199            }
    200200
  • code/branches/pickup/src/orxonox/gametypes/TeamBaseMatch.h

    r5781 r5935  
    6565
    6666            std::set<TeamBaseMatchBase*> bases_;
    67             Timer<TeamBaseMatch> scoreTimer_;
    68             Timer<TeamBaseMatch> outputTimer_;
     67            Timer scoreTimer_;
     68            Timer outputTimer_;
    6969
    7070            //points for each team
  • code/branches/pickup/src/orxonox/gametypes/TeamDeathmatch.cc

    r5781 r5935  
    9393
    9494        if (valid_player)
    95             this->players_.erase(player);
     95            this->teamnumbers_.erase(player);
    9696
    9797        return valid_player;
     
    100100    bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator)
    101101    {
    102         return (!this->pawnsAreInTheSameTeam(victim, originator));
     102        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    103103    }
    104104
    105105    bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
    106106    {
    107         return (!this->pawnsAreInTheSameTeam(victim, originator));
     107        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    108108    }
    109109
    110110    bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator)
    111111    {
    112         return (!this->pawnsAreInTheSameTeam(victim, originator));
     112        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    113113    }
    114114
  • code/branches/pickup/src/orxonox/gametypes/UnderAttack.cc

    r5781 r5935  
    4646        this->teams_ = 2;
    4747        this->destroyer_ = 0;
     48        this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this));
    4849        this->gameEnded_ = false;
    4950
     
    6566
    6667
    67     void UnderAttack::destroyedPawn(Pawn* pawn)
     68    void UnderAttack::killedDestroyer()
    6869    {
    69         if (pawn == this->destroyer_)
     70        this->end(); //end gametype
     71        std::string message = "Ship destroyed! Team 0 has won!";
     72        COUT(0) << message << std::endl;
     73        Host::Broadcast(message);
     74        this->gameEnded_ = true;
     75
     76        for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
    7077        {
    71             this->end(); //end gametype
    72             std::string message = "Ship destroyed! Team 0 has won!";
    73             COUT(0) << message << std::endl;
    74             Host::Broadcast(message);
    75             this->gameEnded_ = true;
     78            if (it->first->getClientID() == CLIENTID_UNKNOWN)
     79                continue;
    7680
    77             for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
    78             {
    79                 if (it->first->getClientID() == CLIENTID_UNKNOWN)
    80                     continue;
    81 
    82                 if (it->second == 0)
    83                     this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
    84                 else
    85                     this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    86             }
     81            if (it->second == 0)
     82                this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
     83            else
     84                this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    8785        }
    8886    }
     
    164162
    165163                    if (it->second == 1)
    166                         this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     164                        this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
    167165                    else
    168                         this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     166                        this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    169167                }
    170168            }
     
    178176                Host::Broadcast(message);
    179177*/
    180                 this->gtinfo_.sendAnnounceMessage(message);
     178                this->gtinfo_->sendAnnounceMessage(message);
    181179
    182180                if (timesequence_ >= 30 && timesequence_ <= 60)
  • code/branches/pickup/src/orxonox/gametypes/UnderAttack.h

    r5781 r5935  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "interfaces/PawnListener.h"
    3534#include "TeamDeathmatch.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport UnderAttack : public TeamDeathmatch, public PawnListener
     38    class _OrxonoxExport UnderAttack : public TeamDeathmatch
    4039    {
    4140        public:
     
    5453
    5554        protected:
    56             virtual void destroyedPawn(Pawn* pawn);
     55            virtual void killedDestroyer();
    5756
    58             Destroyer* destroyer_;
     57            WeakPtr<Destroyer> destroyer_;
    5958            unsigned int teams_;
    6059            float gameTime_;
  • code/branches/pickup/src/orxonox/graphics/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    2   Backlight.cc
    32  Billboard.cc
    43  BlinkingBillboard.cc
    5   Camera.cc
    64  FadingBillboard.cc
    75  GlobalShader.cc
    8   Light.cc
    96  Model.cc
    107  ParticleEmitter.cc
    118  ParticleSpawner.cc
     9COMPILATION_BEGIN GraphicsCompilation.cc
     10  Backlight.cc
     11  Camera.cc
     12  Light.cc
     13COMPILATION_END
    1214)
  • code/branches/pickup/src/orxonox/graphics/Camera.cc

    r5781 r5935  
    3838#include "core/CoreIncludes.h"
    3939#include "core/ConfigValueIncludes.h"
     40#include "core/GameMode.h"
     41#include "core/GUIManager.h"
    4042#include "Scene.h"
    4143#include "CameraManager.h"
     
    4951        RegisterObject(Camera);
    5052
     53        if (!GameMode::showsGraphics())
     54            ThrowException(AbortLoading, "Can't create Camera, no graphics.");
    5155        if (!this->getScene())
    5256            ThrowException(AbortLoading, "Can't create Camera, no scene.");
     
    6569        this->nearClipDistance_ = 1;
    6670
    67         this->setObjectMode(0x0);
     71        this->setSyncMode(0x0);
    6872
    6973        this->setConfigValues();
     
    7579        if (this->isInitialized())
    7680        {
     81            if (GUIManager::getInstance().getCamera() == this->camera_)
     82                GUIManager::getInstance().setCamera(NULL);
    7783            this->releaseFocus();
    7884
  • code/branches/pickup/src/orxonox/graphics/FadingBillboard.cc

    r5781 r5935  
    103103        {
    104104            this->changedirection_ = 1;
    105             this->turnonofftimer_.setTimer(this->turnontime_, false, this, createExecutor(createFunctor(&FadingBillboard::stopturnonoff)));
     105            this->turnonofftimer_.setTimer(this->turnontime_, false, createExecutor(createFunctor(&FadingBillboard::stopturnonoff, this)));
    106106
    107107            if (this->isVisible())
     
    111111        {
    112112            this->changedirection_ = -1;
    113             this->turnonofftimer_.setTimer(this->turnofftime_, false, this, createExecutor(createFunctor(&FadingBillboard::stopturnonoff)));
     113            this->turnonofftimer_.setTimer(this->turnofftime_, false, createExecutor(createFunctor(&FadingBillboard::stopturnonoff, this)));
    114114        }
    115115    }
     
    126126            this->fadedColour_ = ColourValue::ZERO;
    127127            this->getBillboardSet().setColour(this->fadedColour_);
    128             this->turnonofftimer_.setTimer(this->postprocessingtime_, false, this, createExecutor(createFunctor(&FadingBillboard::poststopturnonoff)));
     128            this->turnonofftimer_.setTimer(this->postprocessingtime_, false, createExecutor(createFunctor(&FadingBillboard::poststopturnonoff, this)));
    129129        }
    130130        this->changedirection_ = 0;
  • code/branches/pickup/src/orxonox/graphics/FadingBillboard.h

    r5781 r5935  
    7474            float turnofftime_;
    7575            float postprocessingtime_;
    76             Timer<FadingBillboard> turnonofftimer_;
     76            Timer turnonofftimer_;
    7777            char changedirection_;
    7878            ColourValue fadedColour_;
  • code/branches/pickup/src/orxonox/graphics/ParticleEmitter.cc

    r5781 r5935  
    6363        {
    6464            this->detachOgreObject(this->particles_->getParticleSystem());
    65             delete this->particles_;
     65            this->particles_->destroy();
    6666        }
    6767    }
     
    101101        if (this->particles_)
    102102        {
    103             delete this->particles_;
     103            this->particles_->destroy();
    104104            this->particles_ = 0;
    105105        }
  • code/branches/pickup/src/orxonox/graphics/ParticleSpawner.cc

    r5781 r5935  
    7171    }
    7272
    73     void ParticleSpawner::processEvent(Event& event)
     73    void ParticleSpawner::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    7474    {
    75         SUPER(ParticleSpawner, processEvent, event);
     75        SUPER(ParticleSpawner, XMLEventPort, xmlelement, mode);
    7676
    77         ORXONOX_SET_EVENT(ParticleSpawner, "spawn", spawn, event);
     77        XMLPortEventState(ParticleSpawner, BaseObject, "spawn", spawn, xmlelement, mode);
    7878    }
    7979
     
    8888    void ParticleSpawner::startParticleSpawner()
    8989    {
    90         if (!this->particles_)
    91             return;
    92 
    9390        this->setActive(false);
    9491
    9592        if (this->bForceDestroy_ || this->bSuppressStart_)
     93        {
     94            this->timer_.stopTimer();
    9695            return;
     96        }
    9797
    98         this->timer_.setTimer(this->startdelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner)));
     98        this->timer_.setTimer(this->startdelay_, false, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner, this)));
    9999    }
    100100
     
    103103        this->setActive(true);
    104104        if (this->lifetime_ != 0)
    105             this->timer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&ParticleSpawner::stopParticleSpawner)));
     105            this->timer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&ParticleSpawner::stopParticleSpawner, this)));
    106106    }
    107107
     
    116116
    117117            if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_)
    118                 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
     118                this->timer_.setTimer(this->destroydelay_, false, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner, this)));
    119119        }
    120120        else if (this->bLoop_)
    121121        {
    122             this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner)));
     122            this->timer_.setTimer(this->destroydelay_, false, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner, this)));
    123123        }
    124124    }
     
    126126    void ParticleSpawner::destroyParticleSpawner()
    127127    {
    128         delete this;
     128        this->destroy();
    129129    }
    130130}
  • code/branches/pickup/src/orxonox/graphics/ParticleSpawner.h

    r5781 r5935  
    4444
    4545            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    46             virtual void processEvent(Event& event);
     46            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    4747
    48             inline void destroy()
    49                 { this->bForceDestroy_ = true; this->stopParticleSpawner(); }
     48            inline void stop(bool bDestroy)
     49                { this->bForceDestroy_ = bDestroy; this->stopParticleSpawner(); }
    5050            inline void spawn()
    5151                { this->bSuppressStart_ = false; this->startParticleSpawner(); }
     
    8989            void destroyParticleSpawner();
    9090
    91             Timer<ParticleSpawner> timer_;
     91            Timer timer_;
    9292
    9393            bool  bSuppressStart_;
  • code/branches/pickup/src/orxonox/infos/HumanPlayer.cc

    r5781 r5935  
    6464        {
    6565            if (this->humanHud_)
    66                 delete this->humanHud_;
     66                this->humanHud_->destroy();
    6767
    6868            if (this->gametypeHud_)
    69                 delete this->gametypeHud_;
     69                this->gametypeHud_->destroy();
    7070        }
    7171    }
     
    116116
    117117            if (!GameMode::isMaster())
    118                 this->setObjectMode(ObjectDirection::Bidirectional);
     118                this->setSyncMode(ObjectDirection::Bidirectional);
    119119            else
    120120                this->setName(this->nick_);
     
    162162
    163163        if (this->isInitialized() && this->isLocalPlayer())
    164             if (this->getGametype()->getHUDTemplate() != "")
     164        {
     165            if (this->getGametype() && this->getGametype()->getHUDTemplate() != "")
    165166                this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
     167            else
     168                this->setGametypeHUDTemplate("");
     169        }
    166170    }
    167171
     
    170174        if (this->humanHud_)
    171175        {
    172             delete this->humanHud_;
     176            this->humanHud_->destroy();
    173177            this->humanHud_ = 0;
    174178        }
    175179
    176         if (this->isLocalPlayer() && this->humanHudTemplate_ != "")
     180        if (this->isLocalPlayer() && this->humanHudTemplate_ != "" && GameMode::showsGraphics())
    177181        {
    178182            this->humanHud_ = new OverlayGroup(this);
     
    186190        if (this->gametypeHud_)
    187191        {
    188             delete this->gametypeHud_;
     192            this->gametypeHud_->destroy();
    189193            this->gametypeHud_ = 0;
    190194        }
  • code/branches/pickup/src/orxonox/infos/PlayerInfo.cc

    r5781 r5935  
    3535#include "gametypes/Gametype.h"
    3636#include "worldentities/ControllableEntity.h"
     37#include "controllers/Controller.h"
    3738
    3839namespace orxonox
     
    6667            if (this->controller_)
    6768            {
    68                 delete this->controller_;
     69                this->controller_->destroy();
    6970                this->controller_ = 0;
    7071            }
     
    131132        if (this->controller_)
    132133        {
    133             delete this->controller_;
     134            this->controller_->destroy();
    134135            this->controller_ = 0;
    135136        }
  • code/branches/pickup/src/orxonox/infos/PlayerInfo.h

    r5781 r5935  
    3333
    3434#include "Info.h"
    35 #include "core/Identifier.h"
    36 #include "controllers/Controller.h"
     35#include "core/SubclassIdentifier.h"
    3736
    3837namespace orxonox
  • code/branches/pickup/src/orxonox/interfaces/InterfaceCompilation.cc

    r5781 r5935  
    3434
    3535#include "GametypeMessageListener.h"
    36 #include "PawnListener.h"
    3736#include "PlayerTrigger.h"
    3837#include "RadarListener.h"
     
    5150    {
    5251        RegisterRootObject(GametypeMessageListener);
    53     }
    54 
    55     //----------------------------
    56     // PawnListener
    57     //----------------------------
    58     /**
    59         @brief Constructor for the PawnListener.
    60     */
    61     PawnListener::PawnListener()
    62     {
    63         RegisterRootObject(PawnListener);
    6452    }
    6553
  • code/branches/pickup/src/orxonox/interfaces/NotificationListener.h

    r5781 r5935  
    4545namespace orxonox
    4646{
     47    class Notification;
     48
    4749    class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
    4850    {
  • code/branches/pickup/src/orxonox/interfaces/RadarViewable.cc

    r5781 r5935  
    3838#include "worldentities/WorldEntity.h"
    3939#include "Radar.h"
     40#include "Scene.h"
    4041#include "overlays/Map.h"
    4142
     
    135136    void RadarViewable::setRadarObjectDescription(const std::string& str)
    136137    {
    137         Radar* radar = Radar::getInstancePtr();
     138        Radar* radar = this->getWorldEntity()->getScene()->getRadar();
    138139        if (radar)
    139140            this->radarObjectShape_ = radar->addObjectDescription(str);
  • code/branches/pickup/src/orxonox/items/Engine.cc

    r5781 r5935  
    3737#include "pickup/ModifierType.h"
    3838#include "tools/Shader.h"
    39 #include "sound/SoundBase.h"
    4039
    4140namespace orxonox
     
    6867        this->setConfigValues();
    6968        this->registerVariables();
    70 
    71         this->sound_ = NULL;
    7269    }
    7370
     
    7976
    8077            if (this->boostBlur_)
    81                 delete this->boostBlur_;
    82 
    83             if(this->sound_ != NULL)
    84                 delete this->sound_;
     78                this->boostBlur_->destroy();
    8579        }
    8680    }
     
    10296        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    10397        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
    104 
    105         XMLPortParamLoadOnly(Engine, "sound", loadSound, xmlelement, mode);
    10698    }
    10799
     
    237229            if (this->boostBlur_)
    238230            {
    239                 delete this->boostBlur_;
     231                this->boostBlur_->destroy();
    240232                this->boostBlur_ = 0;
    241233            }
    242 
    243             if(this->sound_ != NULL)
    244                 this->sound_->attachToEntity(ship);
    245234        }
    246235    }
     
    253242            return Vector3::ZERO;
    254243    }
    255 
    256     void Engine::loadSound(const std::string filename)
    257     {
    258         if(filename == "") return;
    259         else
    260         {
    261             if(this->sound_ == NULL)
    262             {
    263                 this->sound_ = new SoundBase(this->ship_);
    264             }
    265 
    266             this->sound_->loadFile(filename);
    267             this->sound_->play(true);
    268         }
    269     }
    270244}
  • code/branches/pickup/src/orxonox/items/Engine.h

    r5781 r5935  
    130130            Shader* boostBlur_;
    131131            float blurStrength_;
    132 
    133             SoundBase* sound_;
    134132    };
    135133}
  • code/branches/pickup/src/orxonox/items/MultiStateEngine.cc

    r5781 r5935  
    6060            // We have no ship, so the effects are not attached and won't be destroyed automatically
    6161            for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
    62                 delete (*it);
     62                (*it)->destroy();
    6363            for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it)
    64                 delete (*it);
     64                (*it)->destroy();
    6565            for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it)
    66                 delete (*it);
     66                (*it)->destroy();
    6767            for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it)
    68                 delete (*it);
     68                (*it)->destroy();
    6969        }
    7070    }
     
    9191            if (this->getShip()->hasLocalController())
    9292            {
    93                 this->setObjectMode(ObjectDirection::Bidirectional);
     93                this->setSyncMode(ObjectDirection::Bidirectional);
    9494
    9595                const Vector3& direction = this->getDirection();
  • code/branches/pickup/src/orxonox/overlays/CMakeLists.txt

    r5781 r5935  
    33  OverlayGroup.cc
    44
     5COMPILATION_BEGIN OverlayCompilation.cc
    56  InGameConsole.cc
    67  Map.cc
     8COMPILATION_END
    79)
  • code/branches/pickup/src/orxonox/overlays/InGameConsole.cc

    r5781 r5935  
    4141#include <OgreFont.h>
    4242
     43#include "util/Clock.h"
     44#include "util/Convert.h"
    4345#include "util/Math.h"
    44 #include "util/Convert.h"
    4546#include "util/UTFStringConversions.h"
    46 #include "core/Clock.h"
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
    4949#include "core/ConsoleCommand.h"
     50#include "core/ScopedSingletonManager.h"
    5051#include "core/input/InputManager.h"
    5152#include "core/input/InputState.h"
     
    6162
    6263    InGameConsole* InGameConsole::singletonPtr_s = 0;
     64    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
    6365
    6466    /**
     
    8587
    8688        this->setConfigValues();
     89        this->initialise();
    8790    }
    8891
  • code/branches/pickup/src/orxonox/overlays/InGameConsole.h

    r5781 r5935  
    5050
    5151        void initialise();
    52         void destroy();
    5352        void setConfigValues();
    5453
  • code/branches/pickup/src/orxonox/overlays/Map.cc

    r5781 r5935  
    290290       for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
    291291            it!=ObjectList<orxonox::RadarViewable>::end();
    292             it++)
     292            ++it)
    293293        {
    294294            //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
     
    392392        for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
    393393            it!=ObjectList<orxonox::Map>::end();
    394             it++)
     394            ++it)
    395395        {
    396396        //Map * m = it->getMap();
  • code/branches/pickup/src/orxonox/overlays/OrxonoxOverlay.h

    r5781 r5935  
    213213  };
    214214
    215   SUPER_FUNCTION(7, OrxonoxOverlay, changedOwner, false);
    216   SUPER_FUNCTION(8, OrxonoxOverlay, changedOverlayGroup, false);
     215  SUPER_FUNCTION(6, OrxonoxOverlay, changedOwner, false);
     216  SUPER_FUNCTION(7, OrxonoxOverlay, changedOverlayGroup, false);
    217217}
    218218
  • code/branches/pickup/src/orxonox/overlays/OverlayGroup.cc

    r5781 r5935  
    6161    {
    6262        for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    63             delete (*it);
     63            (*it)->destroy();
    6464    }
    6565
  • code/branches/pickup/src/orxonox/pickup/DroppedItem.cc

    r5902 r5935  
    7575        if (this->item_)
    7676        {
    77             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++) //!< Iterate through all Pawns.
     77            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) //!< Iterate through all Pawns.
    7878            {
    7979                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
     
    9393        {
    9494            COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl;
    95             delete this;
     95            this->destroy();
    9696        }
    9797    }
     
    106106        if (this->timeToLive_ > 0)
    107107        {
    108             ExecutorMember<DroppedItem>* exec = createExecutor(createFunctor(&DroppedItem::timerCallback));
    109             this->timer_.setTimer(this->timeToLive_, false, this, exec, false);
     108            this->timer_.setTimer(this->timeToLive_, false, createExecutor(createFunctor(&DroppedItem::timerCallback, this)), false);
    110109        }
    111110    }
     
    123122        {
    124123            COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << "'" << std::endl;
    125             delete this->item_;
     124            this->item_->destroy();
    126125        }
    127126
    128         delete this;
     127        this->destroy();
    129128    }
    130129
  • code/branches/pickup/src/orxonox/pickup/DroppedItem.h

    r5902 r5935  
    8686        BaseItem* item_;
    8787
    88         Timer<DroppedItem> timer_;
     88        Timer timer_;
    8989    };
    9090}
  • code/branches/pickup/src/orxonox/pickup/ModifierPickup.cc

    r5902 r5935  
    116116            if (this->duration_ > 0.0f)
    117117            {
    118                 ExecutorMember<ModifierPickup>* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback));
     118                Executor* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback, this));
    119119                executor->setDefaultValues(pawn);
    120                 this->timer_.setTimer(this->duration_, false, this, executor);
     120                this->timer_.setTimer(this->duration_, false, executor);
    121121            }
    122122
     
    157157                this->timer_.stopTimer();
    158158
    159             delete this;
     159            this->destroy();
    160160
    161161            return true;
  • code/branches/pickup/src/orxonox/pickup/ModifierPickup.h

    r5902 r5935  
    152152
    153153            float duration_;                                                        //!< Duration of this pickup's effect (0 for unlimited).
    154             Timer<ModifierPickup> timer_;                                           //!< Timer used if the pickup's effect has a time limit.
     154            Timer timer_;                                           //!< Timer used if the pickup's effect has a time limit.
    155155    };
    156156}
  • code/branches/pickup/src/orxonox/pickup/PickupSpawner.cc

    r5902 r5935  
    103103            asItem->addTemplate(this->itemTemplate_);
    104104            PickupInventory::getImageForItem(asItem);
    105             delete newObject;
     105            newObject->destroy();
    106106        }
    107107
     
    148148        if (this->isActive())
    149149        {
    150             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)
     150            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    151151            {
    152152                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
     
    189189                    if (this->respawnTime_ > 0.0f)
    190190                    {
    191                         ExecutorMember<PickupSpawner>* executor = createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback));
    192                         this->respawnTimer_.setTimer(this->respawnTime_, false, this, executor);
     191                        this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
    193192
    194193                        this->setActive(false);
     
    197196                }
    198197                else
    199                     delete newObject;
     198                    newObject->destroy();
    200199            }
    201200        }
  • code/branches/pickup/src/orxonox/pickup/PickupSpawner.h

    r5902 r5935  
    115115
    116116            float respawnTime_;                     //!< Time after which this gets re-actived.
    117             Timer<PickupSpawner> respawnTimer_;     //!< Timer used for re-activating.
     117            Timer respawnTimer_;     //!< Timer used for re-activating.
    118118    };
    119119}
  • code/branches/pickup/src/orxonox/pickup/items/HealthImmediate.cc

    r5902 r5935  
    6868        {
    6969            pawn->addHealth(this->recoveredHealth_);
    70             delete this;
     70            this->destroy();
    7171        }
    7272
  • code/branches/pickup/src/orxonox/pickup/items/HealthUsable.cc

    r5902 r5935  
    8787
    8888            this->removeFrom(pawn);
    89             delete this;
     89            this->destroy();
    9090        }
    9191    }
  • code/branches/pickup/src/orxonox/pickup/items/Jump.cc

    r5781 r5935  
    8484        {
    8585            this->removeFrom(pawn);
    86             delete this;
     86            this->destroy();
    8787        }
    8888    }
  • code/branches/pickup/src/orxonox/sound/CMakeLists.txt

    r5781 r5935  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
     2    AmbientSound.cc
     3    BaseSound.cc
    24    SoundManager.cc
    3     SoundBase.cc
    4     SoundMainMenu.cc
     5    WorldSound.cc
    56)
    67
  • code/branches/pickup/src/orxonox/sound/SoundManager.cc

    r5781 r5935  
    3131#include <AL/alut.h>
    3232
     33#include "util/Exception.h"
    3334#include "util/Math.h"
    34 #include "CameraManager.h"
    35 #include "graphics/Camera.h"
    36 #include "SoundBase.h"
     35#include "util/ScopeGuard.h"
     36#include "core/GameMode.h"
     37#include "core/ScopedSingletonManager.h"
    3738
    3839namespace orxonox
    3940{
    4041    SoundManager* SoundManager::singletonPtr_s = NULL;
     42    ManageScopedSingleton(SoundManager, ScopeID::Graphics, true);
    4143
    42     /**
    43      * Default constructor
    44      */
    4544    SoundManager::SoundManager()
    4645    {
    47         this->device_ = NULL;
    48         this->soundavailable_ = true;
    49         if(!alutInitWithoutContext(NULL,NULL))
     46        if (!alutInitWithoutContext(NULL,NULL))
     47            ThrowException(InitialisationFailed, "OpenAL ALUT error: " << alutGetErrorString(alutGetError()));
     48        Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit);
     49
     50        COUT(3) << "OpenAL: Opening sound device..." << std::endl;
     51        this->device_ = alcOpenDevice(NULL);
     52        if (this->device_ == NULL)
    5053        {
    51             COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
    52             this->soundavailable_ = false;
     54            COUT(0) << "OpenaAL: Could not open sound device. Have you installed OpenAL?" << std::endl;
     55#ifdef ORXONOX_PLATFORM_WINDOWS
     56            COUT(0) << "Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
     57#endif
     58            ThrowException(InitialisationFailed, "OpenAL error: Could not open sound device.");
    5359        }
     60        Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_);
     61
     62        COUT(3) << "OpenAL: Sound device opened" << std::endl;
     63        this->context_ = alcCreateContext(this->device_, NULL);
     64        if (this->context_ == NULL)
     65            ThrowException(InitialisationFailed, "OpenAL error: Could not create sound context");
     66        Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_);
     67
     68        if (alcMakeContextCurrent(this->context_) == AL_TRUE)
     69            COUT(3) << "OpenAL: Context " << this->context_ << " loaded" << std::endl;
     70
     71        COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
     72
     73        const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER);
     74        if (str == NULL)
     75            COUT(2) << "OpenAL ALUT error: " << alutGetErrorString(alutGetError()) << std::endl;
    5476        else
    55         {
    56             assert(this->device_ == NULL);
    57             COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
    58             this->device_ = alcOpenDevice(NULL);
     77            COUT(4) << "OpenAL ALUT supported MIME types: " << str << std::endl;
    5978
    60             if(this->device_ == NULL)
    61             {
    62                 COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl;
    63                 this->soundavailable_ = false;
    64             }
    65             else
    66             {
    67                 COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl;
    68                 this->context_ = alcCreateContext(this->device_, NULL);
    69                 if(this->context_ == NULL)
    70                 {
    71                     COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl;
    72                     this->soundavailable_ = false;
    73                 }
    74                 else
    75                 {
    76                     if(alcMakeContextCurrent(this->context_) == AL_TRUE)
    77                         COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl;
    78 
    79                     COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
    80                     const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER);
    81                     if (str == NULL)
    82                         COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
    83                     else
    84                         COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << str << std::endl;
    85                 }
    86             }
    87         }
     79        GameMode::setPlaysSound(true);
     80        // Disarm guards
     81        alutExitGuard.Dismiss();
     82        closeDeviceGuard.Dismiss();
     83        desroyContextGuard.Dismiss();
    8884    }
    8985
    9086    SoundManager::~SoundManager()
    9187    {
     88        GameMode::setPlaysSound(false);
    9289        alcDestroyContext(this->context_);
    9390        alcCloseDevice(this->device_);
     
    9592    }
    9693
    97     /**
    98      * Add a SoundBase object to the list. Every SoundBase object should be in
    99      * this list.
    100      *
    101      * @param sound Pointer to the SoundBase object to add
    102      */
    103     void SoundManager::addSound(SoundBase* sound)
     94    void SoundManager::setListenerPosition(const Vector3& position)
    10495    {
    105         this->soundlist_.push_back(sound);
     96        alListener3f(AL_POSITION, position.x, position.y, position.z);
     97        ALenum error = alGetError();
     98        if (error == AL_INVALID_VALUE)
     99            COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl;
    106100    }
    107101
    108     /**
    109      * Remove a SoundBase object from the list and destroy it.
    110      */
    111     void SoundManager::removeSound(SoundBase* sound)
     102    void SoundManager::setListenerOrientation(const Quaternion& orientation)
    112103    {
    113         std::list<SoundBase*>::iterator pos = this->soundlist_.end();
    114         for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++)
    115         {
    116             if((*i) == sound)
    117                 pos = i;
    118         }
     104        // update listener orientation
     105        Vector3 up = orientation.xAxis(); // just a wild guess
     106        Vector3 at = orientation.zAxis();
    119107
    120         delete (*pos);
    121         this->soundlist_.erase(pos);
    122     }
     108        ALfloat orient[6] = { at.x, at.y, at.z,
     109                              up.x, up.y, up.z };
    123110
    124     /**
    125      * Tick function, updates listener and registred SoundBase objects
    126      *
    127      * @param dt @see Orxonox::Tickable
    128      */
    129     void SoundManager::tick(float dt)
    130     {
    131         if (!CameraManager::getInstancePtr())
    132             return;
    133 
    134         // update listener position
    135         Camera* camera = CameraManager::getInstance().getActiveCamera();
    136         if(camera == NULL) return;
    137         Vector3 pos = camera->getPosition();
    138         alListener3f(AL_POSITION, pos.x, pos.y, pos.z);
     111        alListenerfv(AL_POSITION, orient);
    139112        ALenum error = alGetError();
    140         if(error == AL_INVALID_VALUE)
    141             COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl;
    142 
    143         // update listener orientation
    144         const Quaternion& orient = camera->getOrientation();
    145         Vector3 up = orient.xAxis(); // just a wild guess
    146         Vector3 at = orient.zAxis();
    147 
    148         ALfloat orientation[6] = { at.x, at.y, at.z,
    149                                  up.x, up.y, up.z };
    150 
    151         alListenerfv(AL_POSITION, orientation);
    152         error = alGetError();
    153         if(error == AL_INVALID_VALUE)
     113        if (error == AL_INVALID_VALUE)
    154114            COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
    155 
    156         // update sounds
    157         for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++)
    158             (*i)->update();
    159     }
    160 
    161     /**
    162     * Check if sound is available
    163     */
    164     bool SoundManager::isSoundAvailable()
    165     {
    166         return this->soundavailable_;
    167115    }
    168116}
  • code/branches/pickup/src/orxonox/sound/SoundManager.h

    r5781 r5935  
    3939    /**
    4040     * The SoundManager class manages the OpenAL device, context and listener
    41      * position. It has a list of all SoundBase objects and calls their update
    42      * function every tick. It is a singleton.
     41     * position. It is a singleton.
    4342     *
    4443     */
    45     class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public Tickable
     44    class _OrxonoxExport SoundManager : public Singleton<SoundManager>
    4645    {
    4746        friend class Singleton<SoundManager>;
     
    4948        SoundManager();
    5049        ~SoundManager();
    51         void addSound(SoundBase* sound);
    52         void removeSound(SoundBase* sound);
    53         void tick(float dt);
    54         bool isSoundAvailable();
     50
     51        void setListenerPosition(const Vector3& position);
     52        void setListenerOrientation(const Quaternion& orientation);
    5553
    5654    private:
    5755        ALCdevice* device_;
    5856        ALCcontext* context_;
    59         std::list<SoundBase*> soundlist_;
    60         bool soundavailable_;
    6157
    6258        static SoundManager* singletonPtr_s;
    63     }; // class SoundManager
    64 } // namespace orxonox
     59    };
     60}
    6561
    6662#endif /* _SoundManager_H__ */
  • code/branches/pickup/src/orxonox/weaponsystem/Munition.cc

    r5781 r5935  
    461461        if (bUseReloadTime && (munition->reloadTime_ > 0 || munition->bStackMunition_))
    462462        {
    463             ExecutorMember<Magazine>* executor = createExecutor(createFunctor(&Magazine::loaded));
     463            Executor* executor = createExecutor(createFunctor(&Magazine::loaded, this));
    464464            executor->setDefaultValues(munition);
    465465
    466             this->loadTimer_.setTimer(munition->reloadTime_, false, this, executor);
     466            this->loadTimer_.setTimer(munition->reloadTime_, false, executor);
    467467        }
    468468        else
  • code/branches/pickup/src/orxonox/weaponsystem/Munition.h

    r5781 r5935  
    4747
    4848                unsigned int munition_;
    49                 Timer<Magazine> loadTimer_;
     49                Timer loadTimer_;
    5050                bool bLoaded_;
    5151
  • code/branches/pickup/src/orxonox/weaponsystem/Weapon.cc

    r5781 r5935  
    5050        this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
    5151
    52         this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&Weapon::reloaded)));
     52        this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&Weapon::reloaded, this)));
    5353        this->reloadTimer_.stopTimer();
    5454    }
     
    6262
    6363            for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
    64                 delete it->second;
     64                it->second->destroy();
    6565        }
    6666    }
  • code/branches/pickup/src/orxonox/weaponsystem/Weapon.h

    r5781 r5935  
    7171            std::multimap<unsigned int, WeaponMode*> weaponmodes_;
    7272
    73             Timer<Weapon> reloadTimer_;
     73            Timer reloadTimer_;
    7474            bool bReloading_;
    7575            unsigned int reloadingWeaponmode_;
  • code/branches/pickup/src/orxonox/weaponsystem/WeaponMode.cc

    r5781 r5935  
    5757        this->bParallelReload_ = true;
    5858
    59         this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&WeaponMode::reloaded)));
     59        this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this)));
    6060        this->reloadTimer_.stopTimer();
    6161
  • code/branches/pickup/src/orxonox/weaponsystem/WeaponMode.h

    r5781 r5935  
    3636#include "util/Math.h"
    3737#include "core/BaseObject.h"
    38 #include "core/Identifier.h"
     38#include "core/SubclassIdentifier.h"
    3939#include "tools/Timer.h"
    4040
     
    150150            std::string munitionname_;
    151151
    152             Timer<WeaponMode> reloadTimer_;
     152            Timer reloadTimer_;
    153153            bool bReloading_;
    154154    };
  • code/branches/pickup/src/orxonox/weaponsystem/WeaponPack.cc

    r5781 r5935  
    5454
    5555            while (!this->weapons_.empty())
    56                 delete (*this->weapons_.begin());
     56                (*this->weapons_.begin())->destroy();
    5757
    5858            for (std::set<DefaultWeaponmodeLink*>::iterator it = this->links_.begin(); it != this->links_.end(); )
    59                 delete (*(it++));
     59                (*(it++))->destroy();
    6060        }
    6161    }
  • code/branches/pickup/src/orxonox/weaponsystem/WeaponSlot.cc

    r5781 r5935  
    4646        this->weapon_ = 0;
    4747
    48         this->setObjectMode(0x0);
     48        this->setSyncMode(0x0);
    4949    }
    5050
  • code/branches/pickup/src/orxonox/weaponsystem/WeaponSystem.cc

    r5781 r5935  
    6262
    6363            while (!this->weaponSets_.empty())
    64                 delete (this->weaponSets_.begin()->second);
     64                this->weaponSets_.begin()->second->destroy();
    6565
    6666            while (!this->weaponPacks_.empty())
    67                 delete (*this->weaponPacks_.begin());
     67                (*this->weaponPacks_.begin())->destroy();
    6868
    6969            while (!this->weaponSlots_.empty())
    70                 delete (*this->weaponSlots_.begin());
     70                (*this->weaponSlots_.begin())->destroy();
    7171
    7272            while (!this->munitions_.empty())
    73                 { delete (this->munitions_.begin()->second); this->munitions_.erase(this->munitions_.begin()); }
     73                { this->munitions_.begin()->second->destroy(); this->munitions_.erase(this->munitions_.begin()); }
    7474        }
    7575    }
  • code/branches/pickup/src/orxonox/worldentities/BigExplosion.cc

    r5781 r5935  
    9090            this->setVelocity(velocity);
    9191
    92             this->destroyTimer_.setTimer(rnd(2, 4), false, this, createExecutor(createFunctor(&BigExplosion::stop)));
     92            this->destroyTimer_.setTimer(rnd(2, 4), false, createExecutor(createFunctor(&BigExplosion::stop, this)));
    9393        }
    9494        this->registerVariables();
     
    226226            {
    227227                this->debris1_->detachOgreObject(this->debrisFire1_->getParticleSystem());
    228                 delete this->debrisFire1_;
     228                this->debrisFire1_->destroy();
    229229            }
    230230            if (this->debrisSmoke1_)
    231231            {
    232232                this->debris1_->detachOgreObject(this->debrisSmoke1_->getParticleSystem());
    233                 delete this->debrisSmoke1_;
     233                this->debrisSmoke1_->destroy();
    234234            }
    235235
     
    237237            {
    238238                this->debris2_->detachOgreObject(this->debrisFire2_->getParticleSystem());
    239                 delete this->debrisFire2_;
     239                this->debrisFire2_->destroy();
    240240            }
    241241            if (this->debrisSmoke2_)
    242242            {
    243243                this->debris2_->detachOgreObject(this->debrisSmoke2_->getParticleSystem());
    244                 delete this->debrisSmoke2_;
     244                this->debrisSmoke2_->destroy();
    245245            }
    246246
     
    248248            {
    249249                this->debris3_->detachOgreObject(this->debrisFire3_->getParticleSystem());
    250                 delete this->debrisFire3_;
     250                this->debrisFire3_->destroy();
    251251            }
    252252            if (this->debrisSmoke3_)
    253253            {
    254254                this->debris3_->detachOgreObject(this->debrisSmoke3_->getParticleSystem());
    255                 delete this->debrisSmoke3_;
     255                this->debrisSmoke3_->destroy();
    256256            }
    257257
     
    259259            {
    260260                this->debris4_->detachOgreObject(this->debrisFire4_->getParticleSystem());
    261                 delete this->debrisFire4_;
     261                this->debrisFire4_->destroy();
    262262            }
    263263            if (this->debrisSmoke4_)
    264264            {
    265265                this->debris4_->detachOgreObject(this->debrisSmoke4_->getParticleSystem());
    266                 delete this->debrisSmoke4_;
     266                this->debrisSmoke4_->destroy();
    267267            }
    268268        }
     
    329329        {
    330330            this->bStop_ = true;
    331             this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&BigExplosion::destroy)));
    332         }
    333     }
    334 
    335     void BigExplosion::destroy()
    336     {
    337         delete this;
     331            this->destroyTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&BigExplosion::destroy, this)));
     332        }
    338333    }
    339334
  • code/branches/pickup/src/orxonox/worldentities/BigExplosion.h

    r5781 r5935  
    5757            void checkStop();
    5858            void stop();
    59             void destroy();
    6059            void init();
    6160            void initZero();
     
    9897            ParticleInterface*    explosionFire_;
    9998
    100             LODParticle::Value      LOD_;
    101             Timer<BigExplosion> destroyTimer_;
     99            LODParticle::Value    LOD_;
     100            Timer                destroyTimer_;
    102101    };
    103102}
  • code/branches/pickup/src/orxonox/worldentities/CameraPosition.cc

    r5781 r5935  
    4646        this->bRenderCamera_ = false;
    4747
    48         this->setObjectMode(0x0);
     48        this->setSyncMode(0x0);
    4949    }
    5050
  • code/branches/pickup/src/orxonox/worldentities/ControllableEntity.cc

    r5781 r5935  
    9696
    9797            if (this->xmlcontroller_)
    98                 delete this->xmlcontroller_;
     98                this->xmlcontroller_->destroy();
    9999
    100100            if (this->hud_)
    101                 delete this->hud_;
     101                this->hud_->destroy();
    102102
    103103            if (this->camera_)
    104                 delete this->camera_;
    105 
    106             for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
    107                 delete (*it);
     104                this->camera_->destroy();
     105
     106            for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     107                (*it)->destroy();
    108108
    109109            if (this->getScene()->getSceneManager())
     
    153153    {
    154154        unsigned int i = 0;
    155         for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     155        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
    156156        {
    157157            if (i == index)
     
    172172            else if (this->cameraPositions_.size() > 0)
    173173            {
    174                 for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     174                for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
    175175                {
    176176                    if ((*it) == this->camera_->getParent())
     
    238238            {
    239239                this->client_overwrite_ = this->server_overwrite_;
    240                 this->setObjectMode(ObjectDirection::Bidirectional);
     240                this->setSyncMode(ObjectDirection::Bidirectional);
    241241            }
    242242        }
     
    254254        this->bHasLocalController_ = false;
    255255        this->bHasHumanController_ = false;
    256         this->setObjectMode(ObjectDirection::ToClient);
     256        this->setSyncMode(ObjectDirection::ToClient);
    257257
    258258        this->changedPlayer();
    259259
    260260        if (this->bDestroyWhenPlayerLeft_)
    261             delete this;
     261            this->destroy();
    262262    }
    263263
     
    275275    void ControllableEntity::startLocalHumanControl()
    276276    {
    277         if (!this->camera_)
     277        if (!this->camera_ && GameMode::showsGraphics())
    278278        {
    279279            this->camera_ = new Camera(this);
     
    287287        }
    288288
    289         if (!this->hud_)
     289        if (!this->hud_ && GameMode::showsGraphics())
    290290        {
    291291            if (this->hudtemplate_ != "")
     
    303303        {
    304304            this->camera_->detachFromParent();
    305             delete this->camera_;
     305            this->camera_->destroy();
    306306            this->camera_ = 0;
    307307        }
     
    309309        if (this->hud_)
    310310        {
    311             delete this->hud_;
     311            this->hud_->destroy();
    312312            this->hud_ = 0;
    313313        }
     
    333333        if (parent)
    334334        {
    335             for (std::list<CameraPosition*>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     335            for (std::list<SmartPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
    336336                if ((*it)->getIsAbsolute())
    337337                    parent->attach((*it));
  • code/branches/pickup/src/orxonox/worldentities/ControllableEntity.h

    r5781 r5935  
    104104            void addCameraPosition(CameraPosition* position);
    105105            CameraPosition* getCameraPosition(unsigned int index) const;
    106             inline const std::list<CameraPosition*>& getCameraPositions() const
     106            inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const
    107107                { return this->cameraPositions_; }
    108108
     
    198198            float mouseLookSpeed_;
    199199            Ogre::SceneNode* cameraPositionRootNode_;
    200             std::list<CameraPosition*> cameraPositions_;
     200            std::list<SmartPtr<CameraPosition> > cameraPositions_;
    201201            std::string cameraPositionTemplate_;
    202202            Controller* xmlcontroller_;
  • code/branches/pickup/src/orxonox/worldentities/ExplosionChunk.cc

    r5781 r5935  
    7979            this->setVelocity(velocity);
    8080
    81             this->destroyTimer_.setTimer(rnd(1, 2), false, this, createExecutor(createFunctor(&ExplosionChunk::stop)));
     81            this->destroyTimer_.setTimer(rnd(1, 2), false, createExecutor(createFunctor(&ExplosionChunk::stop, this)));
    8282        }
    8383
     
    9292            {
    9393                this->detachOgreObject(this->fire_->getParticleSystem());
    94                 delete this->fire_;
     94                this->fire_->destroy();
    9595            }
    9696            if (this->smoke_)
    9797            {
    9898                this->detachOgreObject(this->smoke_->getParticleSystem());
    99                 delete this->smoke_;
     99                this->smoke_->destroy();
    100100            }
    101101        }
     
    132132        {
    133133            this->bStop_ = true;
    134             this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&ExplosionChunk::destroy)));
     134            this->destroyTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&ExplosionChunk::destroy, this)));
    135135        }
    136     }
    137 
    138     void ExplosionChunk::destroy()
    139     {
    140         delete this;
    141136    }
    142137
  • code/branches/pickup/src/orxonox/worldentities/ExplosionChunk.h

    r5781 r5935  
    5555            void checkStop();
    5656            void stop();
    57             void destroy();
    5857
    5958            bool                  bStop_;
    6059            ParticleInterface*    fire_;
    6160            ParticleInterface*    smoke_;
    62             LODParticle::Value      LOD_;
    63             Timer<ExplosionChunk> destroyTimer_;
     61            LODParticle::Value    LOD_;
     62            Timer                destroyTimer_;
    6463    };
    6564}
  • code/branches/pickup/src/orxonox/worldentities/MovableEntity.cc

    r5781 r5935  
    6161        if (this->isInitialized())
    6262            if (this->continuousResynchroTimer_)
    63                 delete this->continuousResynchroTimer_;
     63                this->continuousResynchroTimer_->destroy();
    6464    }
    6565
     
    9898    void MovableEntity::clientConnected(unsigned int clientID)
    9999    {
    100         this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)));
     100        this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, createExecutor(createFunctor(&MovableEntity::resynchronize, this)));
    101101    }
    102102
     
    110110        {
    111111            // Resynchronise every few seconds because we only work with velocities (no positions)
    112             continuousResynchroTimer_ = new Timer<MovableEntity>(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1),
    113                 true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false);
     112            continuousResynchroTimer_ = new Timer(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1),
     113                true, createExecutor(createFunctor(&MovableEntity::resynchronize, this)), false);
    114114        }
    115115
  • code/branches/pickup/src/orxonox/worldentities/MovableEntity.h

    r5781 r5935  
    9696            Quaternion overwrite_orientation_;
    9797
    98             Timer<MovableEntity> resynchronizeTimer_;
    99             Timer<MovableEntity>* continuousResynchroTimer_;
     98            Timer resynchronizeTimer_;
     99            Timer* continuousResynchroTimer_;
    100100
    101101            Pawn* owner_;
  • code/branches/pickup/src/orxonox/worldentities/SpawnPoint.cc

    r5781 r5935  
    5050            COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl;
    5151
    52         this->setObjectMode(0x0);
     52        this->setSyncMode(0x0);
    5353    }
    5454
  • code/branches/pickup/src/orxonox/worldentities/SpawnPoint.h

    r5781 r5935  
    3333
    3434#include <string>
    35 #include "core/Identifier.h"
     35#include "core/SubclassIdentifier.h"
    3636#include "worldentities/StaticEntity.h"
    3737
  • code/branches/pickup/src/orxonox/worldentities/WorldEntity.cc

    r5781 r5935  
    119119            {
    120120                if ((*it)->getDeleteWithParent())
    121                     delete (*(it++));
     121                    (*(it++))->destroy();
    122122                else
    123123                {
     
    132132                delete this->physicalBody_;
    133133            }
    134             delete this->collisionShape_;
     134            this->collisionShape_->destroy();
    135135
    136136            this->node_->detachAllObjects();
     
    175175    void WorldEntity::registerVariables()
    176176    {
    177         registerVariable(this->mainStateName_,  VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
     177        registerVariable(this->mainStateName_,  VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainStateName));
    178178
    179179        registerVariable(this->bActive_,        VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
  • code/branches/pickup/src/orxonox/worldentities/pawns/Destroyer.cc

    r5781 r5935  
    4040        RegisterObject(Destroyer);
    4141
    42         UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype());
     42        UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype().get());
    4343        if (gametype)
    4444        {
  • code/branches/pickup/src/orxonox/worldentities/pawns/Pawn.cc

    r5781 r5935  
    3636#include "network/NetworkFunction.h"
    3737
    38 #include "interfaces/PawnListener.h"
    3938#include "PawnManager.h"
    4039#include "infos/PlayerInfo.h"
     
    9392        if (this->isInitialized())
    9493        {
    95             for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
    96                 it->destroyedPawn(this);
    97 
    9894            if (this->weaponSystem_)
    99                 delete this->weaponSystem_;
     95                this->weaponSystem_->destroy();
    10096        }
    10197    }
  • code/branches/pickup/src/orxonox/worldentities/pawns/SpaceShip.cc

    r5781 r5935  
    7575    {
    7676        if (this->isInitialized() && this->engine_)
    77             delete this->engine_;
     77            this->engine_->destroy();
    7878    }
    7979
     
    207207                    else
    208208                    {
    209                         delete object;
     209                        object->destroy();
    210210                    }
    211211                }
  • code/branches/pickup/src/orxonox/worldentities/pawns/Spectator.cc

    r5781 r5935  
    145145        ControllableEntity::setPlayer(player);
    146146
    147 //        this->setObjectMode(ObjectDirection::ToClient);
     147//        this->setSyncMode(ObjectDirection::ToClient);
    148148    }
    149149
  • code/branches/pickup/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc

    r5781 r5935  
    3131
    3232#include "core/CoreIncludes.h"
    33 #include "interfaces/PawnListener.h"
     33#include "controllers/ArtificialController.h"
    3434#include "interfaces/TeamColourable.h"
    3535#include "gametypes/TeamBaseMatch.h"
     
    4545        this->state_ = BaseState::Uncontrolled;
    4646
    47         TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype());
     47        TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype().get());
    4848        if (gametype)
    4949        {
     
    5858        this->fireEvent();
    5959
    60         TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype());
     60        TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype().get());
    6161        if (!gametype)
    6262            return;
     
    9292
    9393        // Call this so bots stop shooting at the base after they converted it
    94         for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
    95             it->destroyedPawn(this);
     94        for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)
     95            it->abandonTarget(this);
    9696    }
    9797}
Note: See TracChangeset for help on using the changeset viewer.