Changeset 5935 for code/branches/pickup
- Timestamp:
- Oct 13, 2009, 5:05:17 PM (15 years ago)
- Location:
- code/branches/pickup
- Files:
-
- 15 deleted
- 281 edited
- 47 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup
- Property svn:mergeinfo changed
-
code/branches/pickup/bin/CMakeLists.txt
r5781 r5935 26 26 27 27 # Create run scripts for Windows to manually add the DLL path when executing 28 SET(RUN_SCRIPTS run standalone client1 client2 server dedicated )28 SET(RUN_SCRIPTS run standalone client1 client2 server dedicated dedicatedClient) 29 29 IF(WIN32) 30 30 FOREACH(_script ${RUN_SCRIPTS}) -
code/branches/pickup/bin/vld.ini.in
r3196 r5935 56 56 ; Default: None. 57 57 ; 58 ForceIncludeModules = 58 ForceIncludeModules = 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 59 59 60 60 ; Maximum number of data bytes to display for each leaked block. If zero, then … … 66 66 ; Default: 4294967295 67 67 ; 68 MaxDataDump = 68 MaxDataDump = 0 69 69 70 70 ; Maximum number of call stack frames to trace back during leak detection. -
code/branches/pickup/cmake/CompilerConfigMSVC.cmake
r5695 r5935 70 70 71 71 # 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)72 SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -MP2 -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) 76 76 77 77 # Use Link time code generation for Release config if ORXONOX_RELEASE is defined -
code/branches/pickup/cmake/PackageConfig.cmake
r5781 r5935 26 26 27 27 # 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). 33 SET(ALLOWED_MINIMUM_VERSIONS 3.1 4.0) 34 31 35 IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt) 32 36 SET(DEPENDENCY_VERSION 1.0) … … 44 48 45 49 INCLUDE(CompareVersionStrings) 46 COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${DEPENDENCY_VERSION_REQUIRED} _result TRUE) 47 IF(NOT _result EQUAL 0) 50 SET(_version_match FALSE) 51 FOREACH(_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() 61 ENDFOREACH(_version) 62 IF(NOT _version_match) 48 63 MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n" 49 " Required version: ${DEPENDENCY_VERSION_REQUIRED}\n"50 64 "Possible required versions: ${ALLOWED_MINIMUM_VERSIONS}\n" 65 "You can get a new version from www.orxonox.net") 51 66 ENDIF() 52 67 -
code/branches/pickup/cmake/ParseMacroArguments.cmake
r5695 r5935 39 39 # Using LIST(FIND ...) speeds up the process 40 40 SET(_keywords ${_switches} ${_list_names}) 41 42 # Reset all arguments 43 FOREACH(_arg ${_switches} ${_list_names}) 44 SET(_arg_${_arg}) 45 ENDFOREACH(_arg) 41 46 42 47 # Parse all the arguments and set the corresponding variable -
code/branches/pickup/cmake/PrecompiledHeaderFiles.cmake
r3251 r5935 110 110 GET_GCC_COMPILER_FLAGS(${_target_name} _pch_gcc_flags) 111 111 # 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}") 113 113 SET(_INTERNAL_${_target_name}_PCH_GCC_FLAGS "${_pch_gcc_flags}" CACHE INTERNAL "") 114 114 FILE(WRITE ${_pch_dep_helper_file} "/* ${_pch_gcc_flags} */") -
code/branches/pickup/cmake/SourceFileUtilities.cmake
r2710 r5935 24 24 # [ADD/SET]_SOURCE_FILES - Writes source files to the cache by force and 25 25 # 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. 27 32 # GENERATE_SOURCE_GROUPS - Set Visual Studio source groups. 28 33 # 29 34 35 FUNCTION(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) 76 ENDFUNCTION(PREPARE_SOURCE_FILES) 77 78 30 79 # Adds source files with the full path to a list 31 80 FUNCTION(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}) 38 82 # Write into the cache to avoid variable scoping in subdirs 39 83 SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit") … … 43 87 # Sets source files with the full path 44 88 FUNCTION(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}) 51 90 # Write into the cache to avoid variable scoping in subdirs 52 91 SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit") … … 66 105 GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION) 67 106 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() 71 115 ENDFOREACH(_file) 72 116 -
code/branches/pickup/cmake/TargetUtilities.cmake
r5695 r5935 67 67 ENDIF() 68 68 69 FUNCTION(ORXONOX_ADD_LIBRARY _target_name)69 MACRO(ORXONOX_ADD_LIBRARY _target_name) 70 70 TU_ADD_TARGET(${_target_name} LIBRARY "STATIC;SHARED" ${ARGN}) 71 END FUNCTION(ORXONOX_ADD_LIBRARY)72 73 FUNCTION(ORXONOX_ADD_EXECUTABLE _target_name)71 ENDMACRO(ORXONOX_ADD_LIBRARY) 72 73 MACRO(ORXONOX_ADD_EXECUTABLE _target_name) 74 74 TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN}) 75 END FUNCTION(ORXONOX_ADD_EXECUTABLE)76 77 78 FUNCTION(TU_ADD_TARGET _target_name _target_type _additional_switches)75 ENDMACRO(ORXONOX_ADD_EXECUTABLE) 76 77 78 MACRO(TU_ADD_TARGET _target_name _target_type _additional_switches) 79 79 CAPITALISE_NAME(${_target_name} _target_name_capitalised) 80 80 … … 88 88 89 89 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 91 102 IF(_arg_FIND_HEADER_FILES) 92 GET_ALL_HEADER_FILES(_${ target_name}_header_files)103 GET_ALL_HEADER_FILES(_${_target_name}_header_files) 93 104 ENDIF() 94 105 95 106 # 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}) 97 108 LIST(REMOVE_DUPLICATES _${_target_name}_files) 98 109 … … 141 152 ENDIF() 142 153 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 143 160 # Set default linking if required 144 161 IF(NOT _arg_SHARED AND NOT _arg_STATIC) … … 156 173 SET(_arg_STATIC) 157 174 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) 158 182 159 183 # Add the library/executable … … 164 188 ADD_EXECUTABLE(${_target_name} ${_arg_WIN32} ${_arg_EXCLUDE_FROM_ALL} 165 189 ${_${_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 ) 166 197 ENDIF() 167 198 … … 216 247 ENDIF() 217 248 218 END FUNCTION(TU_ADD_TARGET)249 ENDMACRO(TU_ADD_TARGET) 219 250 220 251 -
code/branches/pickup/data/defaultConfig/keybindings.ini
r5781 r5935 25 25 KeyEscape="exit" 26 26 KeyF="scale -1 moveUpDown" 27 KeyF1= 27 KeyF1="OverlayGroup toggleVisibility Debug" 28 28 KeyF10= 29 29 KeyF11= … … 41 41 KeyF9= 42 42 KeyG=greet 43 KeyGrave= 43 KeyGrave="openConsole" 44 44 KeyH= 45 KeyHome= showGUI45 KeyHome= 46 46 KeyI= 47 47 KeyInsert= … … 126 126 KeyU= 127 127 KeyUP="scale 1 moveFrontBack" 128 KeyUnassigned= 128 KeyUnassigned="openConsole" 129 129 KeyUnderline= 130 130 KeyUnlabeled= -
code/branches/pickup/data/levels/old/physicstest2.oxw
r5781 r5935 243 243 <!--EventDispatcher> 244 244 <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 /> 248 248 </targets> 249 249 <events> -
code/branches/pickup/data/levels/old/princessaeryn.oxw
r5781 r5935 264 264 <EventDispatcher> 265 265 <targets> 266 <EventTarget name=trail />266 <EventTarget target=trail /> 267 267 </targets> 268 268 <events> -
code/branches/pickup/data/levels/old/sample4.oxw
r5781 r5935 123 123 <EventDispatcher> 124 124 <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 /> 128 128 </targets> 129 129 <events> -
code/branches/pickup/data/levels/presentation.oxw
r5781 r5935 151 151 <EventDispatcher> 152 152 <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 /> 156 156 </targets> 157 157 <events> -
code/branches/pickup/data/levels/presentation09b.oxw
r5781 r5935 111 111 <EventDispatcher> 112 112 <targets> 113 <EventTarget name=pirates />113 <EventTarget target=pirates /> 114 114 </targets> 115 115 <events> … … 163 163 <EventDispatcher> 164 164 <targets> 165 <EventTarget name=attacker />165 <EventTarget target=attacker /> 166 166 </targets> 167 167 <events> -
code/branches/pickup/data/levels/presentation_pong.oxw
r5781 r5935 32 32 <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" /> 33 33 <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> 35 39 </PongBall> 36 40 </Template> … … 42 46 gametype = Pong 43 47 > 48 <AmbientSound source="ambient/mainmenu.wav" playOnLoad=true /> 49 44 50 <Scene 45 51 ambientlight = "0.5, 0.5, 0.5" … … 58 64 <MovableEntity rotationrate=5 rotationaxis="0,0,1"> 59 65 <attached> 60 <PongCenterpoint name=pongcenter dimension="200,120" balltemplate=pongball battemplate=pongbat ballspeed=200 ba tspeed=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> 61 67 <attached> 62 68 <Model position="0,0,60" mesh="cube.mesh" scale3D="105,1,1" /> 63 69 <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 96 for i = 1, 15, 1 97 do ?> 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 100 end 101 ?> 102 76 103 </attached> 77 104 </PongCenterpoint> … … 81 108 <EventDispatcher> 82 109 <targets> 83 <EventTarget name=scoreeffect /> 110 <EventTarget target=scoreeffect_right /> 111 <EventTarget target=scoreeffect_center /> 84 112 </targets> 85 113 <events> 86 114 <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> 88 137 </spawn> 89 138 </events> -
code/branches/pickup/data/levels/princessaeryn.oxw
r5781 r5935 6 6 7 7 <?lua 8 dofile(" ../../media/levels/includes/CuboidSpaceStation.lua")8 dofile("includes/CuboidSpaceStation.lua") 9 9 ?> 10 10 … … 227 227 <EventDispatcher> 228 228 <targets> 229 <EventTarget name=trail />229 <EventTarget target=trail /> 230 230 </targets> 231 231 <events> -
code/branches/pickup/data/particle/ExplosionComp1.particle
r5781 r5935 41 41 repeat_delay_max 2.5 42 42 width 20 43 h ight 2043 height 20 44 44 depth 0 45 45 } -
code/branches/pickup/src/Orxonox.cc
r5752 r5935 63 63 for (int i = 1; i < argc; ++i) 64 64 strCmdLine += argv[i] + std::string(" "); 65 #endif 65 66 66 67 return orxonox::main(strCmdLine); 67 #endif68 68 } 69 69 catch (...) -
code/branches/pickup/src/OrxonoxConfig.cmake
r5695 r5935 38 38 OPTION(PCH_ENABLE "Global PCH switch" TRUE) 39 39 ENDIF() 40 41 # Global switch to disable multiple file compilations 42 OPTION(DISABLE_COMPILATIONS "Global multi-file compilation switch" FALSE) 40 43 41 44 # Use WinMain() or main()? -
code/branches/pickup/src/external/bullet/BulletCollision/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(BULLET_FILES 2 3 COMPILATION_BEGIN BulletCollisionCompilation.cpp 4 2 5 BroadphaseCollision/btAxisSweep3.cpp 3 6 BroadphaseCollision/btBroadphaseProxy.cpp … … 68 71 Gimpact/btContactProcessing.cpp 69 72 Gimpact/btGImpactShape.cpp 70 Gimpact/gim_contact.cpp71 73 Gimpact/btGImpactBvh.cpp 72 74 Gimpact/btGenericPoolAllocator.cpp 73 Gimpact/gim_memory.cpp74 75 Gimpact/btGImpactCollisionAlgorithm.cpp 75 76 Gimpact/btTriangleShapeEx.cpp 76 Gimpact/gim_tri_collision.cpp77 77 Gimpact/btGImpactQuantizedBvh.cpp 78 Gimpact/gim_box_set.cpp79 78 80 79 NarrowPhaseCollision/btContinuousConvexCollision.cpp … … 89 88 NarrowPhaseCollision/btSubSimplexConvexCast.cpp 90 89 NarrowPhaseCollision/btVoronoiSimplexSolver.cpp 90 91 COMPILATION_END 92 93 COMPILATION_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 98 COMPILATION_END 91 99 92 100 # Headers -
code/branches/pickup/src/external/bullet/BulletDynamics/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(BULLET_FILES 2 3 COMPILATION_BEGIN BulletDynamicsCompilation.cpp 4 2 5 ConstraintSolver/btContactConstraint.cpp 3 6 ConstraintSolver/btConeTwistConstraint.cpp … … 19 22 20 23 Character/btKinematicCharacterController.cpp 24 25 COMPILATION_END 21 26 22 27 # Headers -
code/branches/pickup/src/external/bullet/CMakeLists.txt
r5781 r5935 27 27 ADD_SUBDIRECTORY(LinearMath) 28 28 29 # No warnings needed from third party libraries30 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)31 ADD_COMPILER_FLAGS("-w")32 33 29 ORXONOX_ADD_LIBRARY(bullet_orxonox 34 30 ORXONOX_EXTERNAL 35 31 NO_DLL_INTERFACE 36 PCH_FILE37 BulletPrecompiledHeaders.h38 32 VERSION 39 33 2.74 -
code/branches/pickup/src/external/bullet/LinearMath/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(BULLET_FILES 2 3 COMPILATION_BEGIN BulletLinearMathCompilation.cpp 2 4 btConvexHull.cpp 3 5 btQuickprof.cpp 4 6 btGeometryUtil.cpp 5 7 btAlignedAllocator.cpp 8 COMPILATION_END 6 9 7 10 # Headers -
code/branches/pickup/src/external/ceguilua/CMakeLists.txt
r5781 r5935 67 67 ) 68 68 69 # No warnings needed from third party libraries70 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)71 ADD_COMPILER_FLAGS("-w")72 73 69 SOURCE_GROUP("Source" FILES ${CEGUILUA_FILES}) 74 70 -
code/branches/pickup/src/external/cpptcl/CMakeLists.txt
r5781 r5935 32 32 ) 33 33 34 # No warnings needed from third party libraries35 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)36 ADD_COMPILER_FLAGS("-w")37 38 34 ORXONOX_ADD_LIBRARY(cpptcl_orxonox 39 35 ORXONOX_EXTERNAL -
code/branches/pickup/src/external/ogreceguirenderer/CMakeLists.txt
r5781 r5935 18 18 # 19 19 20 SET (OCR_FILES20 SET_SOURCE_FILES(OCR_FILES 21 21 OgreCEGUIRenderer.h 22 22 OgreCEGUIResourceProvider.h 23 23 OgreCEGUITexture.h 24 24 25 COMPILATION_BEGIN OgreCEGUIRendererCompilation.cpp 25 26 OgreCEGUIRenderer.cpp 26 27 OgreCEGUIResourceProvider.cpp 27 28 OgreCEGUITexture.cpp 29 COMPILATION_END 28 30 ) 29 30 # No warnings needed from third party libraries31 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)32 ADD_COMPILER_FLAGS("-w")33 31 34 32 ORXONOX_ADD_LIBRARY(ogreceguirenderer_orxonox -
code/branches/pickup/src/external/ois/CMakeLists.txt
r5781 r5935 34 34 OISPrereqs.h 35 35 36 COMPILATION_BEGIN OISCompilation.cpp 36 37 OISEffect.cpp 37 38 OISException.cpp … … 41 42 OISKeyboard.cpp 42 43 OISObject.cpp 44 COMPILATION_END 43 45 ) 44 46 IF(WIN32) … … 49 51 ADD_SUBDIRECTORY(linux) 50 52 ENDIF() 51 52 # No warnings needed from third party libraries53 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)54 ADD_COMPILER_FLAGS("-w")55 53 56 54 INCLUDE_DIRECTORIES(.) -
code/branches/pickup/src/external/ois/changes_orxonox.diff
r5781 r5935 23 23 24 24 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 8 8 LinuxPrereqs.h 9 9 10 COMPILATION_BEGIN OISLinuxCompilation.cpp 10 11 EventHelpers.cpp 11 12 LinuxForceFeedback.cpp … … 14 15 LinuxKeyboard.cpp 15 16 LinuxMouse.cpp 17 COMPILATION_END 16 18 ) -
code/branches/pickup/src/external/ois/mac/CMakeLists.txt
r5781 r5935 7 7 MacPrereqs.h 8 8 9 COMPILATION_BEGIN OISMacCompilation.cpp 9 10 MacHelpers.cpp 10 11 MacHIDManager.cpp … … 12 13 MacKeyboard.cpp 13 14 MacMouse.cpp 15 COMPILATION_END 14 16 ) -
code/branches/pickup/src/external/ois/win32/CMakeLists.txt
r5781 r5935 7 7 Win32Prereqs.h 8 8 9 COMPILATION_BEGIN OISWin32Compilation.cpp 9 10 Win32ForceFeedback.cpp 10 11 Win32InputManager.cpp … … 12 13 Win32KeyBoard.cpp 13 14 Win32Mouse.cpp 15 COMPILATION_END 14 16 ) -
code/branches/pickup/src/external/ois/win32/Win32ForceFeedback.cpp
r5781 r5935 26 26 27 27 // 0 = No trace; 1 = Important traces; 2 = Debug traces 28 #define OIS_WIN32_JOYFF_DEBUG 128 #define OIS_WIN32_JOYFF_DEBUG 0 29 29 30 30 #if (defined (_DEBUG) || defined(OIS_WIN32_JOYFF_DEBUG)) -
code/branches/pickup/src/external/tinyxml/CMakeLists.txt
r5781 r5935 18 18 # 19 19 20 SET (TINYXML++_FILES20 SET_SOURCE_FILES(TINYXML++_FILES 21 21 ticpp.h 22 22 ticpprc.h … … 24 24 tinyxml.h 25 25 26 COMPILATION_BEGIN TicppCompilation.cpp 26 27 ticpp.cpp 27 28 tinystr.cpp … … 29 30 tinyxmlerror.cpp 30 31 tinyxmlparser.cpp 32 COMPILATION_END 31 33 ) 32 33 # No warnings needed from third party libraries34 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)35 ADD_COMPILER_FLAGS("-w")36 34 37 35 ORXONOX_ADD_LIBRARY(tinyxml++_orxonox -
code/branches/pickup/src/external/tolua/CMakeLists.txt
r5738 r5935 20 20 ################### Tolua++ library ################### 21 21 22 SET (TOLUA++_FILES22 SET_SOURCE_FILES(TOLUA++_FILES 23 23 tolua_event.h 24 24 tolua++.h 25 25 COMPILATION_BEGIN ToluaCompilation.c 26 26 tolua_event.c 27 27 tolua_is.c … … 29 29 tolua_push.c 30 30 tolua_to.c 31 COMPILATION_END 31 32 ) 32 GENERATE_SOURCE_GROUPS(${TOLUA++_FILES})33 34 # No warnings needed from third party libraries35 REMOVE_COMPILER_FLAGS("-W3 -W4" MSVC)36 ADD_COMPILER_FLAGS("-w")37 33 38 34 ORXONOX_ADD_LIBRARY(tolua++_orxonox -
code/branches/pickup/src/libraries/CMakeLists.txt
r5781 r5935 25 25 ################ Sub Directories ################ 26 26 27 ADD_SUBDIRECTORY(util) 27 28 ADD_SUBDIRECTORY(core) 28 29 ADD_SUBDIRECTORY(network) 29 30 ADD_SUBDIRECTORY(tools) 30 ADD_SUBDIRECTORY(util) -
code/branches/pickup/src/libraries/core/ArgumentCompletionFunctions.cc
r5781 r5935 100 100 ArgumentCompletionList classlist; 101 101 102 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::get IdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)102 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it) 103 103 if ((*it).second->hasConfigValues()) 104 104 classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first))); … … 110 110 { 111 111 ArgumentCompletionList configvalues; 112 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::get IdentifierMap().find(classname);112 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getStringIdentifierMap().find(classname); 113 113 114 if (identifier != Identifier::get IdentifierMapEnd() && (*identifier).second->hasConfigValues())114 if (identifier != Identifier::getStringIdentifierMapEnd() && (*identifier).second->hasConfigValues()) 115 115 { 116 116 for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it) … … 124 124 { 125 125 ArgumentCompletionList oldvalue; 126 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercase IdentifierMap().find(getLowercase(classname));127 if (identifier != Identifier::getLowercase IdentifierMapEnd())126 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname)); 127 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 128 128 { 129 129 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); -
code/branches/pickup/src/libraries/core/BaseObject.cc
r5781 r5935 63 63 this->bVisible_ = true; 64 64 this->oldGametype_ = 0; 65 this->bRegisteredEventStates_ = false; 65 66 66 67 this->lastLoadedXMLElement_ = 0; 67 68 68 this->functorSetMainState_ = 0; 69 this->functorGetMainState_ = 0; 69 this->mainStateFunctor_ = 0; 70 70 71 71 this->setCreator(creator); … … 74 74 this->setFile(this->creator_->getFile()); 75 75 this->setNamespace(this->creator_->getNamespace()); 76 this->setScene(this->creator_->getScene() );76 this->setScene(this->creator_->getScene(), this->creator_->getSceneID()); 77 77 this->setGametype(this->creator_->getGametype()); 78 78 } … … 82 82 this->namespace_ = 0; 83 83 this->scene_ = 0; 84 this->sceneID_ = OBJECTID_UNKNOWN; 84 85 this->gametype_ = 0; 85 86 } … … 93 94 if (this->isInitialized()) 94 95 { 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; 105 104 } 106 105 } … … 110 109 @param xmlelement The XML-element 111 110 @param loading Loading (true) or saving (false) 112 @return The XML-element113 111 */ 114 112 void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 120 118 121 119 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 {} 125 127 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; 157 143 } 158 144 … … 220 206 } 221 207 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 234 232 { 235 233 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 238 239 if (i == index) 239 return (*it);240 return it->first; 240 241 ++i; 241 242 } … … 243 244 } 244 245 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; 251 281 delete (it->second); 252 282 } 253 283 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()) 261 294 return ((*it).second); 262 295 else … … 264 297 } 265 298 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 */ 288 333 void BaseObject::fireEvent(Event& event) 289 334 { 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 */ 294 343 void BaseObject::processEvent(Event& event) 295 344 { 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 */ 315 363 void BaseObject::setMainState(bool state) 316 364 { 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 } 319 377 else 320 378 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl; 321 379 } 322 380 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 } 341 460 } 342 461 } -
code/branches/pickup/src/libraries/core/BaseObject.h
r5781 r5935 37 37 #define _BaseObject_H__ 38 38 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 47 39 #include "CorePrereqs.h" 48 40 … … 53 45 #include "OrxonoxClass.h" 54 46 #include "Super.h" 47 #include "SmartPtr.h" 55 48 56 49 namespace orxonox … … 68 61 virtual ~BaseObject(); 69 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 70 64 71 65 /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */ … … 110 104 111 105 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. */ 115 117 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(); 117 120 118 121 /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */ … … 134 137 inline BaseObject* getCreator() const { return this->creator_; } 135 138 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) 140 144 { 141 145 if (gametype != this->gametype_) … … 146 150 } 147 151 } 148 inline Gametype*getGametype() const { return this->gametype_; }152 inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; } 149 153 inline Gametype* getOldGametype() const { return this->oldGametype_; } 150 154 virtual void changedGametype() {} 151 155 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 = ""); 155 166 void fireEvent(Event& event); 156 167 157 168 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;170 169 171 170 /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */ … … 173 172 /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */ 174 173 inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; } 174 175 static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier); 175 176 176 177 protected: 178 void addEventState(const std::string& name, EventState* container); 179 EventState* getEventState(const std::string& name) const; 180 177 181 std::string name_; //!< The name of the object 178 182 std::string oldName_; //!< The old name of the object … … 180 184 mbool bVisible_; //!< True = the object is visible 181 185 std::string mainStateName_; 182 Functor* functorSetMainState_; 183 Functor* functorGetMainState_; 186 Functor* mainStateFunctor_; 184 187 185 188 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 186 196 void setXMLName(const std::string& name); 187 197 Template* getTemplate(unsigned int index) const; 198 void registerEventStates(); 188 199 189 200 bool bInitialized_; //!< True if the object was initialized (passed the object registration) … … 194 205 Namespace* namespace_; 195 206 BaseObject* creator_; 196 Scene* scene_; 197 Gametype* gametype_; 207 SmartPtr<Scene> scene_; 208 uint32_t sceneID_; 209 SmartPtr<Gametype> gametype_; 198 210 Gametype* oldGametype_; 199 211 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) 203 218 }; 204 219 … … 206 221 SUPER_FUNCTION(2, BaseObject, changedActivity, false); 207 222 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); 212 226 } 213 227 -
code/branches/pickup/src/libraries/core/CMakeLists.txt
r5781 r5935 19 19 20 20 SET_SOURCE_FILES(CORE_SRC_FILES 21 Clock.cc22 ConfigFileManager.cc23 21 ConfigValueContainer.cc 24 22 Core.cc … … 33 31 Language.cc 34 32 LuaState.cc 35 MemoryArchive.cc36 33 ObjectListBase.cc 37 34 OrxonoxClass.cc 38 35 Resource.cc 36 ScopedSingletonManager.cc 39 37 WindowEventListener.cc 40 38 41 39 # command 42 ArgumentCompletionFunctions.cc43 40 CommandEvaluation.cc 44 41 CommandExecutor.cc … … 49 46 50 47 # hierarchy 51 Factory.cc52 48 Identifier.cc 53 49 MetaObjectList.cc … … 67 63 Shell.cc 68 64 TclBind.cc 65 66 COMPILATION_BEGIN FilesystemCompilation.cc 67 ArgumentCompletionFunctions.cc 68 ConfigFileManager.cc 69 MemoryArchive.cc 70 PathConfig.cc 71 COMPILATION_END 72 73 # multithreading 74 ThreadPool.cc 75 COMPILATION_BEGIN ThreadCompilation.cc 69 76 TclThreadManager.cc 70 71 # multithreading72 77 Thread.cc 73 ThreadPool.cc 78 COMPILATION_END 74 79 ) 80 75 81 ADD_SUBDIRECTORY(input) 76 82 -
code/branches/pickup/src/libraries/core/ClassFactory.h
r5781 r5935 42 42 43 43 #include "util/Debug.h" 44 #include "Factory.h"45 44 #include "Identifier.h" 46 45 47 46 namespace orxonox 48 47 { 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 49 59 // ############################### 50 60 // ### ClassFactory ### … … 52 62 //! The ClassFactory is able to create new objects of a specific class. 53 63 template <class T> 54 class ClassFactory : public BaseFactory64 class ClassFactory : public Factory 55 65 { 56 66 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 } 59 78 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 } 66 87 }; 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 class71 @param bLoadable True if the class can be loaded through XML72 @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 object88 */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 object98 */99 template <class T>100 inline T* ClassFactory<T>::createNewObject(BaseObject* creator)101 {102 return new T(creator);103 }104 88 } 105 89 -
code/branches/pickup/src/libraries/core/ClassTreeMask.cc
r5781 r5935 488 488 489 489 // Remove the redundant subnode from the current node 490 delete (*it); 490 491 node->subnodes_.erase(it++); 491 492 } -
code/branches/pickup/src/libraries/core/ClassTreeMask.h
r5781 r5935 265 265 266 266 /** @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); } 268 268 /** @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); } 270 270 /** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */ 271 271 inline operator bool() const { return (this->objectIterator_); } -
code/branches/pickup/src/libraries/core/CommandExecutor.cc
r5781 r5935 468 468 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear(); 469 469 std::string lowercase = getLowercase(fragment); 470 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercase IdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)470 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it) 471 471 if ((*it).second->hasConsoleCommands()) 472 472 if ((*it).first.find(lowercase) == 0 || fragment == "") … … 516 516 { 517 517 std::string lowercase = getLowercase(name); 518 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercase IdentifierMap().find(lowercase);519 if ((it != Identifier::getLowercase IdentifierMapEnd()) && (*it).second->hasConsoleCommands())518 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase); 519 if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands()) 520 520 return (*it).second; 521 521 -
code/branches/pickup/src/libraries/core/CommandLine.cc
r5738 r5935 31 31 #include <algorithm> 32 32 #include <sstream> 33 #include <boost/filesystem.hpp>34 33 35 34 #include "util/Convert.h" … … 38 37 #include "util/StringUtils.h" 39 38 #include "util/SubString.h" 40 #include " Core.h"39 #include "PathConfig.h" 41 40 42 41 namespace orxonox … … 285 284 } 286 285 286 infoStr << std::endl; 287 287 infoStr << "Usage: orxonox [options]" << std::endl; 288 288 infoStr << "Available options:" << std::endl; … … 348 348 { 349 349 std::string filename = CommandLine::getValue("optionsFile").getString(); 350 boost::filesystem::path filepath(Core::getConfigPath() / filename);351 350 352 351 // look for additional arguments in given file or start.ini as default 353 352 // They will not overwrite the arguments given directly 354 353 std::ifstream file; 355 file.open( filepath.string().c_str());354 file.open((PathConfig::getConfigPathString() + filename).c_str()); 356 355 std::vector<std::string> args; 357 356 if (file) -
code/branches/pickup/src/libraries/core/ConfigFileManager.cc
r5781 r5935 36 36 #include "ConsoleCommand.h" 37 37 #include "ConfigValueContainer.h" 38 #include " Core.h"38 #include "PathConfig.h" 39 39 40 40 namespace orxonox … … 48 48 bool config(const std::string& classname, const std::string& varname, const std::string& value) 49 49 { 50 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercase IdentifierMap().find(getLowercase(classname));51 if (identifier != Identifier::getLowercase IdentifierMapEnd())50 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname)); 51 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 52 52 { 53 53 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); … … 60 60 bool tconfig(const std::string& classname, const std::string& varname, const std::string& value) 61 61 { 62 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercase IdentifierMap().find(getLowercase(classname));63 if (identifier != Identifier::getLowercase IdentifierMapEnd())62 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname)); 63 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 64 64 { 65 65 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); … … 222 222 223 223 // 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_); 225 225 if (!boost::filesystem::exists(filepath)) 226 226 { 227 227 // 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_); 229 229 if (boost::filesystem::exists(defaultFilepath)) 230 230 { … … 336 336 { 337 337 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); 339 339 file.setf(std::ios::fixed, std::ios::floatfield); 340 340 file.precision(6); … … 376 376 for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); ) 377 377 { 378 std::map<std::string, Identifier*>::const_iterator it2 = Identifier::get IdentifierMap().find((*it1)->getName());379 if (it2 != Identifier::get IdentifierMapEnd() && (*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()) 380 380 { 381 381 // The section exists, delete comment … … 455 455 if (this->type_ == ConfigFileType::Settings) 456 456 { 457 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::get IdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)457 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it) 458 458 { 459 459 if (it->second->hasConfigValues()) -
code/branches/pickup/src/libraries/core/Core.cc
r5781 r5935 37 37 38 38 #include <cassert> 39 #include <fstream> 40 #include <cstdlib> 41 #include <cstdio> 42 #include <boost/version.hpp> 43 #include <boost/filesystem.hpp> 39 #include <vector> 44 40 45 41 #ifdef ORXONOX_PLATFORM_WINDOWS … … 50 46 # undef min 51 47 # 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>58 48 #endif 59 49 60 #include " SpecialConfig.h"50 #include "util/Clock.h" 61 51 #include "util/Debug.h" 62 52 #include "util/Exception.h" 63 53 #include "util/SignalHandler.h" 64 #include " Clock.h"54 #include "PathConfig.h" 65 55 #include "CommandExecutor.h" 66 56 #include "CommandLine.h" … … 69 59 #include "CoreIncludes.h" 70 60 #include "DynLibManager.h" 71 #include "Factory.h"72 61 #include "GameMode.h" 73 62 #include "GraphicsManager.h" … … 76 65 #include "Language.h" 77 66 #include "LuaState.h" 67 #include "ScopedSingletonManager.h" 78 68 #include "Shell.h" 79 69 #include "TclBind.h" … … 81 71 #include "input/InputManager.h" 82 72 83 // Boost 1.36 has some issues with deprecated functions that have been omitted84 #if (BOOST_VERSION == 103600)85 # define BOOST_LEAF_FUNCTION filename86 #else87 # define BOOST_LEAF_FUNCTION leaf88 #endif89 90 73 namespace orxonox 91 74 { … … 93 76 Core* Core::singletonPtr_s = 0; 94 77 95 SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");96 SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");97 78 SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file"); 98 79 #ifdef ORXONOX_PLATFORM_WINDOWS … … 117 98 RegisterRootObject(CoreConfiguration); 118 99 this->setConfigValues(); 119 120 // External data directory only exists for dev runs121 if (Core::isDevelopmentRun())122 {123 // Possible data path override by the command line124 if (!CommandLine::getArgument("externalDataPath")->hasDefaultValue())125 tsetExternalDataPath(CommandLine::getValue("externalDataPath"));126 }127 100 } 128 101 … … 194 167 } 195 168 196 /**197 @brief198 Temporary sets the external data path199 @param path200 The new data path201 */202 void tsetExternalDataPath(const std::string& path)203 {204 externalDataPath_ = boost::filesystem::path(path);205 }206 207 169 void initializeRandomNumberGenerator() 208 170 { … … 222 184 std::string language_; //!< The language 223 185 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 pahts226 boost::filesystem::path rootPath_;227 boost::filesystem::path executablePath_; //!< Path to the executable228 boost::filesystem::path modulePath_; //!< Path to the modules229 boost::filesystem::path dataPath_; //!< Path to the data file folder230 boost::filesystem::path externalDataPath_; //!< Path to the external data file folder231 boost::filesystem::path configPath_; //!< Path to the config file folder232 boost::filesystem::path logPath_; //!< Path to the log file folder233 186 }; 234 187 … … 240 193 , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands) 241 194 , configuration_(new CoreConfiguration()) // Don't yet create config values! 242 , bDevRun_(false)243 195 , bGraphicsLoaded_(false) 244 196 { 245 197 // Set the hard coded fixed paths 246 this-> setFixedPaths();198 this->pathConfig_.reset(new PathConfig()); 247 199 248 200 // Create a new dynamic library manager … … 250 202 251 203 // 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 270 208 { 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); 294 210 } 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 } 299 215 } 300 216 … … 303 219 304 220 // Set configurable paths like log, config and media 305 this-> setConfigurablePaths();221 this->pathConfig_->setConfigurablePaths(); 306 222 307 223 // create a signal handler (only active for linux) 308 224 // This call is placed as soon as possible, but after the directories are set 309 225 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"); 311 227 312 228 // 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()); 314 230 315 231 // Parse additional options file now that we know its path … … 334 250 335 251 // creates the class hierarchy for all classes with factories 336 Factory::createClassHierarchy();252 Identifier::createClassHierarchy(); 337 253 338 254 // Do this soon after the ConfigFileManager has been created to open up the … … 344 260 345 261 // initialise Tcl 346 this->tclBind_.reset(new TclBind( Core::getDataPathString()));262 this->tclBind_.reset(new TclBind(PathConfig::getDataPathString())); 347 263 this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter())); 348 264 349 265 // create a shell 350 266 this->shell_.reset(new Shell()); 267 268 // Create singletons that always exist (in other libraries) 269 this->rootScope_.reset(new Scope<ScopeID::Root>()); 351 270 } 352 271 … … 370 289 inputManager_.reset(new InputManager()); 371 290 372 // load the CEGUI interface291 // Load the CEGUI interface 373 292 guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(), 374 293 inputManager_->getMousePosition(), graphicsManager_->isFullScreen())); 375 294 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 376 304 unloader.Dismiss(); 377 378 bGraphicsLoaded_ = true;379 305 } 380 306 381 307 void Core::unloadGraphics() 382 308 { 383 this->guiManager_.reset();; 384 this->inputManager_.reset();; 309 this->graphicsScope_.reset(); 310 this->guiManager_.reset(); 311 this->inputManager_.reset(); 385 312 this->graphicsManager_.reset(); 386 313 … … 397 324 398 325 bGraphicsLoaded_ = false; 326 GameMode::bShowsGraphics_s = false; 399 327 } 400 328 … … 457 385 } 458 386 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 509 387 /** 510 388 @note … … 553 431 } 554 432 555 /**556 @brief557 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 we560 don't write the logs and config files to ~/.orxonox561 @throw562 GeneralException563 */564 void Core::setFixedPaths()565 {566 //////////////////////////567 // FIND EXECUTABLE PATH //568 //////////////////////////569 570 #ifdef ORXONOX_PLATFORM_WINDOWS571 // get executable module572 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 sure590 what the proper response is here.591 Since it really is an assert-like condition, aborting the592 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 #endif607 608 configuration_->executablePath_ = boost::filesystem::path(buffer);609 #ifndef ORXONOX_PLATFORM_APPLE610 configuration_->executablePath_ = configuration_->executablePath_.branch_path(); // remove executable name611 #endif612 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 else624 {625 626 #ifdef INSTALL_COPYABLE // --> relative paths627 628 // Also set the root path629 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 well638 configuration_->modulePath_ = configuration_->rootPath_ / specialConfig::defaultModulePath;639 640 #else641 642 // There is no root path, so don't set it at all643 // Module path is fixed as well644 configuration_->modulePath_ = specialConfig::moduleInstallDirectory;645 646 #endif647 }648 }649 650 /**651 @brief652 Sets config, log and media path and creates folders if necessary.653 @throws654 GeneralException655 */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 else666 {667 668 #ifdef INSTALL_COPYABLE // --> relative paths669 670 // Using paths relative to the install prefix, complete them671 configuration_->dataPath_ = configuration_->rootPath_ / specialConfig::defaultDataPath;672 configuration_->configPath_ = configuration_->rootPath_ / specialConfig::defaultConfigPath;673 configuration_->logPath_ = configuration_->rootPath_ / specialConfig::defaultLogPath;674 675 #else676 677 configuration_->dataPath_ = specialConfig::dataInstallDirectory;678 679 // Get user directory680 # ifdef ORXONOX_PLATFORM_UNIX /* Apple? */681 char* userDataPathPtr(getenv("HOME"));682 # else683 char* userDataPathPtr(getenv("APPDATA"));684 # endif685 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 #endif694 695 }696 697 // Option to put all the config and log files in a separate folder698 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 725 433 void Core::preUpdate(const Clock& time) 726 434 { 435 // singletons from other libraries 436 ScopedSingletonManager::update<ScopeID::Root>(time); 727 437 if (this->bGraphicsLoaded_) 728 438 { … … 731 441 // process gui events 732 442 this->guiManager_->update(time); 443 // graphics singletons from other libraries 444 ScopedSingletonManager::update<ScopeID::Graphics>(time); 733 445 } 734 446 // process thread commands -
code/branches/pickup/src/libraries/core/Core.h
r5781 r5935 28 28 */ 29 29 30 /**31 @file32 @brief33 Declaration of the Core class.34 @details35 The Core class is a singleton, only used to configure some variables36 in the core through the config-file.37 */38 39 30 #ifndef _Core_H__ 40 31 #define _Core_H__ … … 45 36 #include <boost/scoped_ptr.hpp> 46 37 #include "util/OutputHandler.h" 38 #include "util/Scope.h" 47 39 #include "util/ScopeGuard.h" 48 40 #include "util/Singleton.h" … … 55 47 @brief 56 48 The Core class is a singleton used to configure the program basics. 57 @details58 The class provides information about the data, config and log path.59 It determines those by the use of platform specific functions.60 49 @remark 61 50 You should only create this singleton once because it destroys the identifiers! … … 85 74 static void resetLanguage(); 86 75 87 static void tsetExternalDataPath(const std::string& path);88 //! Returns the path to the data files as boost::filesystem::path89 static const boost::filesystem::path& getDataPath();90 //! Returns the path to the external data files as boost::filesystem::path91 static const boost::filesystem::path& getExternalDataPath();92 //! Returns the path to the config files as boost::filesystem::path93 static const boost::filesystem::path& getConfigPath();94 //! Returns the path to the log files as boost::filesystem::path95 static const boost::filesystem::path& getLogPath();96 //! Returns the path to the root folder as boost::filesystem::path97 static const boost::filesystem::path& getRootPath();98 //! Returns the path to the data files as std::string99 static std::string getDataPathString();100 //! Returns the path to the external data files as std::string101 static std::string getExternalDataPathString();102 //! Returns the path to the config files as std::string103 static std::string getConfigPathString();104 //! Returns the path to the log files as std::string105 static std::string getLogPathString();106 //! Returns the path to the root folder as std::string107 static std::string getRootPathString();108 109 static bool isDevelopmentRun() { return getInstance().bDevRun_; }110 111 76 private: 112 77 Core(const Core&); //!< Don't use (undefined symbol) … … 118 83 void unloadGraphics(); 119 84 120 void setFixedPaths();121 void setConfigurablePaths();122 85 void setThreadAffinity(int limitToCPU); 123 86 124 87 // Mind the order for the destruction! 88 scoped_ptr<PathConfig> pathConfig_; 125 89 scoped_ptr<DynLibManager> dynLibManager_; 126 90 scoped_ptr<SignalHandler> signalHandler_; … … 137 101 scoped_ptr<InputManager> inputManager_; //!< Interface to OIS 138 102 scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI 103 scoped_ptr<Scope<ScopeID::Root> > rootScope_; 104 scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_; 139 105 140 bool bDevRun_; //!< True for runs in the build directory (not installed)141 106 bool bGraphicsLoaded_; 142 143 107 static Core* singletonPtr_s; 144 108 }; -
code/branches/pickup/src/libraries/core/CoreIncludes.h
r5781 r5935 29 29 /** 30 30 @file 31 @brief Definition of macros for Identifier and Factory.31 @brief Definition of macros for Identifiers 32 32 33 33 Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface … … 45 45 #include "util/Debug.h" 46 46 #include "Identifier.h" 47 #include " Factory.h"47 #include "SubclassIdentifier.h" 48 48 #include "ClassFactory.h" 49 49 #include "ObjectList.h" … … 76 76 77 77 /** 78 @brief Creates the entry in theFactory.78 @brief Creates the Factory. 79 79 @param ClassName The name of the class 80 80 */ 81 81 #define CreateFactory(ClassName) \ 82 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true)82 Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, true) 83 83 84 84 /** 85 @brief Creates the entry in theFactory for classes which should not be loaded through XML.85 @brief Creates the Factory for classes which should not be loaded through XML. 86 86 @param ClassName The name of the class 87 87 */ 88 88 #define CreateUnloadableFactory(ClassName) \ 89 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false)89 Factory* _##ClassName##Factory = new orxonox::ClassFactory<ClassName>(#ClassName, false) 90 90 91 91 /** … … 100 100 { 101 101 /** 102 @brief Returns the Identifier with a given name through the factory.102 @brief Returns the Identifier with a given name. 103 103 @param String The name of the class 104 104 */ 105 105 inline Identifier* ClassByString(const std::string& name) 106 106 { 107 return Factory::getIdentifier(name);107 return Identifier::getIdentifierByString(name); 108 108 } 109 109 110 110 /** 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. 112 121 @param networkID The network ID of the class 113 122 */ 114 123 inline Identifier* ClassByID(uint32_t id) 115 124 { 116 return Factory::getIdentifier(id);125 return Identifier::getIdentifierByID(id); 117 126 } 118 127 } -
code/branches/pickup/src/libraries/core/CorePrereqs.h
r5738 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 40 41 // Shared library settings 41 42 //----------------------------------------------------------------------- 43 42 44 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( CORE_STATIC_BUILD ) 43 45 # ifdef CORE_SHARED_BUILD … … 56 58 #endif 57 59 58 59 //----------------------------------------------------------------------- 60 // Forward declarations 61 //----------------------------------------------------------------------- 60 //----------------------------------------------------------------------- 61 // Constants 62 //----------------------------------------------------------------------- 63 64 namespace orxonox 65 { 66 static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1); 67 } 68 69 //----------------------------------------------------------------------- 70 // Enums 71 //----------------------------------------------------------------------- 72 62 73 namespace orxonox 63 74 { … … 66 77 enum Mode 67 78 { 79 NOP, 68 80 LoadObject, 69 81 SaveObject, … … 82 94 }; 83 95 }; 84 96 } 97 98 //----------------------------------------------------------------------- 99 // Forward declarations 100 //----------------------------------------------------------------------- 101 102 namespace orxonox 103 { 85 104 typedef std::string LanguageEntryLabel; 86 105 87 106 class ArgumentCompleter; 88 107 class ArgumentCompletionListElement; 89 class BaseFactory;90 class BaseMetaObjectListElement;91 108 class BaseObject; 92 109 template <class T> … … 98 115 class ClassTreeMaskNode; 99 116 class ClassTreeMaskObjectIterator; 100 class Clock;101 117 class CommandEvaluation; 102 class CommandExecutor;103 118 class CommandLine; 104 119 class CommandLineArgument; … … 109 124 class ConfigFileManager; 110 125 class ConfigFileSection; 126 struct ConfigFileType; 111 127 class ConfigValueContainer; 112 128 class ConsoleCommand; … … 115 131 class DynLibManager; 116 132 struct Event; 117 class Event Container;133 class EventState; 118 134 class Executor; 119 135 template <class T> … … 125 141 class FunctorMember; 126 142 class FunctorStatic; 143 class Game; 144 class GameState; 145 struct GameStateInfo; 146 struct GameStateTreeNode; 127 147 class GraphicsManager; 128 148 class GUIManager; … … 131 151 template <class T> 132 152 class Iterator; 133 class IteratorBase;134 153 class Language; 135 class LanguageEntry;136 class Loader;137 154 class LuaState; 138 155 class MemoryArchive; … … 152 169 class OgreWindowEventListener; 153 170 class OrxonoxClass; 171 class PathConfig; 154 172 struct ResourceInfo; 155 173 class Shell; 156 174 class ShellListener; 157 175 template <class T> 176 class SmartPtr; 177 template <class T> 158 178 class SubclassIdentifier; 159 179 class TclBind; … … 163 183 class TclThreadManager; 164 184 class Template; 185 class Thread; 186 class ThreadPool; 187 template <class T> 188 class WeakPtr; 165 189 class WindowEventListener; 166 190 class XMLFile; … … 173 197 class XMLPortParamContainer; 174 198 175 // game states 176 class Game; 177 class GameState; 178 struct GameStateInfo; 179 struct GameStateTreeNode; 180 181 // input 199 // Input 182 200 class BaseCommand; 183 201 class BufferedParamCommand; 184 202 class Button; 185 class CalibratorCallback;186 203 class HalfAxis; 187 204 class InputBuffer; … … 192 209 class InputManager; 193 210 class InputState; 211 struct InputStatePriority; 212 class JoyStickQuantityListener; 194 213 class JoyStick; 214 class KeyBinder; 215 class KeyBinderManager; 216 class Keyboard; 217 class KeyDetector; 218 class KeyEvent; 195 219 class Mouse; 196 class Keyboard;197 class KeyBinder;198 class KeyDetector;199 220 class ParamCommand; 200 221 class SimpleCommand; 201 202 203 // multithreading204 class Thread;205 class ThreadPool;206 222 } 207 223 … … 282 298 namespace orxonox 283 299 { 284 using ticpp::Document;285 300 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 } 293 302 294 303 #endif /* _CorePrereqs_H__ */ -
code/branches/pickup/src/libraries/core/Event.cc
r5781 r5935 30 30 31 31 #include "BaseObject.h" 32 #include " Executor.h"32 #include "Identifier.h" 33 33 34 34 namespace orxonox 35 35 { 36 EventContainer::~EventContainer() 36 /** 37 @brief Destructor: Deletes the functor of the event state. 38 */ 39 EventState::~EventState() 37 40 { 38 delete this->eventfunction_; 41 if (this->statefunction_) 42 delete this->statefunction_; 39 43 } 40 44 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) 42 52 { 43 if (this->b Active_)53 if (this->bProcessingEvent_) 44 54 { 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; 46 56 return; 47 57 } 48 58 49 this->b Active_ = true;59 this->bProcessingEvent_ = true; 50 60 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_)) 52 63 { 53 if (event.originator_->isA(this->subclass_)) 64 // actualize the activationcounter 65 if (event.activate_) 66 ++this->activeEvents_; 67 else 54 68 { 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) 58 84 { 59 --this->activeEvents_; 60 61 if (this->activeEvents_ < 0) 62 this->activeEvents_ = 0; 85 // one argument: just the eventstate 86 (*this->statefunction_)(this->activeEvents_); 63 87 } 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) 68 89 { 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 } 73 102 } 74 103 } 75 104 } 76 105 77 this->b Active_ = false;106 this->bProcessingEvent_ = false; 78 107 } 79 108 } -
code/branches/pickup/src/libraries/core/Event.h
r5781 r5935 35 35 namespace orxonox 36 36 { 37 /** 38 @brief The Event struct contains information about a fired Event. 39 */ 37 40 struct _CoreExport Event 38 41 { 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) {} 40 43 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 45 48 }; 46 49 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 48 66 { 49 67 public: 50 Event Container(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}51 virtual ~Event Container();68 EventState(Functor* statefunction, Identifier* subclass) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass) {} 69 virtual ~EventState(); 52 70 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_; } 54 75 55 76 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) 62 81 }; 63 82 } -
code/branches/pickup/src/libraries/core/EventIncludes.h
r5781 r5935 32 32 #include "CorePrereqs.h" 33 33 #include "Executor.h" 34 #include "XMLPort.h" 34 35 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) 37 54 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) 40 66 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 43 72 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 46 81 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 71 88 #endif /* _EventIncludes_H__ */ -
code/branches/pickup/src/libraries/core/Functor.h
r5738 r5935 191 191 192 192 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 218 224 219 225 … … 317 323 318 324 #define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \ 319 FUNCTOR_TEMPLATE(0, returnvalue, numparams ) \325 FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \ 320 326 class FunctorStatic##returnvalue##numparams : public FunctorStatic \ 321 327 { \ … … 347 353 \ 348 354 \ 349 FUNCTOR_TEMPLATE(0, returnvalue, numparams ) \355 FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \ 350 356 inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \ 351 357 { \ … … 358 364 359 365 #define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \ 360 FUNCTOR_TEMPLATE(1, returnvalue, numparams ) \366 FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \ 361 367 class FunctorMember##returnvalue##numparams : public FunctorMember<T> \ 362 368 { \ … … 391 397 \ 392 398 \ 393 FUNCTOR_TEMPLATE(1, returnvalue, numparams ) \399 FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \ 394 400 class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \ 395 401 { \ … … 423 429 \ 424 430 \ 425 FUNCTOR_TEMPLATE(1, returnvalue, numparams ) \431 FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \ 426 432 inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \ 427 433 { \ … … 430 436 \ 431 437 \ 432 FUNCTOR_TEMPLATE(1, returnvalue, numparams ) \438 FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \ 433 439 inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \ 434 440 { \ 435 441 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; \ 436 459 } 437 460 -
code/branches/pickup/src/libraries/core/GUIManager.cc
r5781 r5935 49 49 #endif 50 50 51 #include "util/Clock.h" 51 52 #include "util/Debug.h" 52 53 #include "util/Exception.h" 53 54 #include "util/OrxAssert.h" 54 55 #include "Core.h" 55 #include "Clock.h"56 56 #include "LuaState.h" 57 #include "PathConfig.h" 57 58 #include "Resource.h" 58 59 … … 62 63 { 63 64 public: 64 65 void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) 65 66 { 66 67 int orxonoxLevel = CEGUI::Standard; … … 100 101 : renderWindow_(renderWindow) 101 102 , resourceProvider_(0) 103 , camera_(NULL) 102 104 { 103 105 using namespace CEGUI; … … 116 118 // Create our own logger to specify the filepath 117 119 std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 118 ceguiLogger->setLogFilename( Core::getLogPathString() + "cegui.log");120 ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log"); 119 121 // set the log level according to ours (translate by subtracting 1) 120 122 ceguiLogger->setLoggingLevel( … … 173 175 void GUIManager::setCamera(Ogre::Camera* camera) 174 176 { 177 this->camera_ = camera; 175 178 if (camera == NULL) 176 179 this->guiRenderer_->setTargetSceneManager(0); -
code/branches/pickup/src/libraries/core/GUIManager.h
r5781 r5935 71 71 72 72 void setCamera(Ogre::Camera* camera); 73 Ogre::Camera* getCamera() { return this->camera_; } 73 74 74 75 static GUIManager* getInstancePtr() { return singletonPtr_s; } … … 101 102 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 102 103 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 103 105 104 106 static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager -
code/branches/pickup/src/libraries/core/Game.cc
r5781 r5935 38 38 #include <boost/weak_ptr.hpp> 39 39 40 #include "util/Clock.h" 40 41 #include "util/Debug.h" 41 42 #include "util/Exception.h" … … 43 44 #include "util/Sleep.h" 44 45 #include "util/SubString.h" 45 #include "Clock.h"46 46 #include "CommandLine.h" 47 47 #include "ConsoleCommand.h" … … 57 57 { Game::getInstance().stop(); } 58 58 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"); 59 65 60 66 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; … … 111 117 Game::Game(const std::string& cmdLine) 112 118 // 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) 114 120 { 115 121 this->bAbort_ = false; … … 410 416 requestedNodes.push_back(currentNode); 411 417 } 418 if (currentNode == NULL) 419 requestedNodes.clear(); 412 420 } 413 421 … … 457 465 { 458 466 // 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; 460 468 size_t pos = 0; 461 469 size_t startPos = 0; 462 470 while (pos < str.size()) 463 471 { 464 unsignedindentation = 0;472 int indentation = 0; 465 473 while(pos < str.size() && str[pos] == ' ') 466 474 ++indentation, ++pos; … … 470 478 stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation)); 471 479 } 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_) 481 503 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 } 505 522 506 523 void Game::loadGraphics() 507 524 { 508 if (!GameMode:: bShowsGraphics_s)525 if (!GameMode::showsGraphics()) 509 526 { 510 527 core_->loadGraphics(); 511 528 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics); 512 GameMode::bShowsGraphics_s = true;513 529 514 530 // Construct all the GameStates that require graphics … … 531 547 void Game::unloadGraphics() 532 548 { 533 if (GameMode:: bShowsGraphics_s)549 if (GameMode::showsGraphics()) 534 550 { 535 551 // Destroy all the GameStates that require graphics … … 543 559 544 560 core_->unloadGraphics(); 545 GameMode::bShowsGraphics_s = false;546 561 } 547 562 } … … 607 622 } 608 623 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 } 610 629 611 630 /*static*/ shared_ptr<GameState> Game::GameStateFactory::fabricate(const GameStateInfo& info) 612 631 { 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()); 615 634 return it->second->fabricateInternal(info); 616 635 } -
code/branches/pickup/src/libraries/core/Game.h
r5747 r5935 117 117 template <class T> 118 118 static void createFactory(const std::string& className) 119 { factories_s[className].reset(new TemplateGameStateFactory<T>()); }119 { getFactories()[className].reset(new TemplateGameStateFactory<T>()); } 120 120 121 121 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(); 123 123 }; 124 124 template <class T> … … 143 143 void unloadGraphics(); 144 144 145 void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode); 145 146 bool checkState(const std::string& name) const; 146 147 void loadState(const std::string& name); -
code/branches/pickup/src/libraries/core/GameMode.cc
r5781 r5935 27 27 */ 28 28 29 /**30 @file31 @brief Implementation of the GameMode class.32 */33 34 29 #include "GameMode.h" 35 30 … … 37 32 { 38 33 bool GameMode::bShowsGraphics_s = false; 34 bool GameMode::bPlaysSound_s = false; 39 35 bool GameMode::bHasServer_s = false; 40 36 bool GameMode::bIsClient_s = false; -
code/branches/pickup/src/libraries/core/GameMode.h
r5781 r5935 41 41 class _CoreExport GameMode 42 42 { 43 friend class Game;43 friend class Core; 44 44 45 45 public: 46 46 static bool showsGraphics() { return bShowsGraphics_s; } 47 static bool playsSound() { return bPlaysSound_s; } 47 48 static bool hasServer() { return bHasServer_s; } 48 49 static bool isClient() { return bIsClient_s; } … … 50 51 static bool isMaster() { return bIsMaster_s; } 51 52 53 static void setPlaysSound (bool val) { bPlaysSound_s = val; } 52 54 static void setHasServer (bool val) { bHasServer_s = val; updateIsMaster(); } 53 55 static void setIsClient (bool val) { bIsClient_s = val; updateIsMaster(); } … … 65 67 66 68 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 67 70 static bool bHasServer_s; //!< global variable that tells whether this is a server 68 71 static bool bIsClient_s; -
code/branches/pickup/src/libraries/core/GameState.h
r5738 r5935 40 40 #include <map> 41 41 #include <string> 42 #include "util/UtilPrereqs.h" 42 43 43 44 namespace orxonox -
code/branches/pickup/src/libraries/core/GraphicsManager.cc
r5781 r5935 48 48 49 49 #include "SpecialConfig.h" 50 #include "util/Clock.h" 50 51 #include "util/Exception.h" 51 52 #include "util/StringUtils.h" 52 53 #include "util/SubString.h" 53 #include "Clock.h"54 54 #include "ConsoleCommand.h" 55 55 #include "ConfigValueIncludes.h" 56 56 #include "CoreIncludes.h" 57 #include "Core.h"58 57 #include "Game.h" 59 58 #include "GameMode.h" 60 59 #include "Loader.h" 61 60 #include "MemoryArchive.h" 61 #include "PathConfig.h" 62 62 #include "WindowEventListener.h" 63 63 #include "XMLFile.h" … … 102 102 103 103 // 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); 105 105 // Load resources 106 106 resources_.reset(new XMLFile("resources.oxr", "dataRoot")); … … 109 109 110 110 // 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); 114 114 extResources_.reset(new XMLFile("resources.oxr", "externalDataRoot")); 115 115 extResources_->setLuaSupport(false); … … 130 130 GraphicsManager::~GraphicsManager() 131 131 { 132 Loader::unload(debugOverlay_.get()); 133 132 134 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get()); 133 135 // TODO: Destroy the console command 136 137 // Undeclare the resources 138 Loader::unload(resources_.get()); 139 if (PathConfig::isDevelopmentRun()) 140 Loader::unload(extResources_.get()); 134 141 } 135 142 … … 241 248 } 242 249 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_); 245 252 246 253 // create a new logManager … … 313 320 314 321 // 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"); 317 323 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 318 324 } 319 325 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 */ 320 342 void GraphicsManager::update(const Clock& time) 321 343 { … … 418 440 assert(this->renderWindow_); 419 441 420 this->renderWindow_->writeContentsToTimestampedFile( Core::getLogPathString() + "screenShot_", ".jpg");442 this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".jpg"); 421 443 } 422 444 } -
code/branches/pickup/src/libraries/core/GraphicsManager.h
r5781 r5935 71 71 72 72 void upgradeToGraphics(); 73 void loadDebugOverlay(); 73 74 bool rendererLoaded() const { return renderWindow_ != NULL; } 74 75 … … 99 100 Ogre::Viewport* viewport_; //!< default full size viewport 100 101 101 // XML files for the resources 102 // XML files for the resources and the debug overlay 102 103 shared_ptr<XMLFile> resources_; //!< XML with resource locations 103 104 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 104 106 105 107 // config values -
code/branches/pickup/src/libraries/core/Identifier.cc
r5781 r5935 39 39 #include "ConfigValueContainer.h" 40 40 #include "ConsoleCommand.h" 41 #include " Factory.h"41 #include "ClassFactory.h" 42 42 #include "XMLPort.h" 43 43 … … 61 61 this->bSetName_ = false; 62 62 this->factory_ = 0; 63 this->bLoadable_ = true;63 this->bLoadable_ = false; 64 64 65 65 this->bHasConfigValues_ = false; 66 66 this->bHasConsoleCommands_ = false; 67 67 68 this->children_ = new std::set<const Identifier*>();69 this->directChildren_ = new std::set<const Identifier*>();70 71 68 // Default network ID is the class ID 72 69 this->networkID_ = this->classID_; … … 78 75 Identifier::~Identifier() 79 76 { 80 delete this->children_;81 delete this->directChildren_;82 77 delete this->objects_; 83 78 … … 118 113 // There is already an entry: return it and delete the proposal 119 114 delete proposal; 120 return (*it).second;115 return it->second; 121 116 } 122 117 else … … 165 160 { 166 161 // 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); 168 163 169 164 // Erase all parents of our parent from our direct-parent-list … … 187 182 { 188 183 // 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); 190 185 191 186 // Create the super-function dependencies … … 196 191 197 192 /** 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 /** 198 213 @brief Destroys all Identifiers. Called when exiting the program. 199 214 */ … … 214 229 this->name_ = name; 215 230 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; 218 234 } 219 235 } … … 235 251 COUT(1) << "Aborting..." << std::endl; 236 252 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. 243 259 @param id The new network ID 244 260 */ 245 261 void Identifier::setNetworkID(uint32_t id) 246 262 { 247 Factory::changeNetworkID(this, this->networkID_, id); 263 // Identifier::getIDIdentifierMapIntern().erase(this->networkID_); 264 Identifier::getIDIdentifierMapIntern()[id] = this; 248 265 this->networkID_ = id; 249 266 } … … 291 308 bool Identifier::isParentOf(const Identifier* identifier) const 292 309 { 293 return (this->children_ ->find(identifier) != this->children_->end());310 return (this->children_.find(identifier) != this->children_.end()); 294 311 } 295 312 … … 300 317 bool Identifier::isDirectParentOf(const Identifier* identifier) const 301 318 { 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. 307 324 @return The map 308 325 */ 309 std::map<std::string, Identifier*>& Identifier::get IdentifierMapIntern()326 std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern() 310 327 { 311 328 static std::map<std::string, Identifier*> identifierMap; … … 314 331 315 332 /** 316 @brief Returns the map that stores all Identifiers .333 @brief Returns the map that stores all Identifiers with their names in lowercase. 317 334 @return The map 318 335 */ 319 std::map<std::string, Identifier*>& Identifier::getLowercase IdentifierMapIntern()336 std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern() 320 337 { 321 338 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 322 339 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(); 323 400 } 324 401 … … 351 428 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname); 352 429 if (it != configValues_.end()) 353 return ((*it).second);430 return it->second; 354 431 else 355 432 return 0; … … 365 442 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname); 366 443 if (it != configValues_LC_.end()) 367 return ((*it).second);444 return it->second; 368 445 else 369 446 return 0; … … 404 481 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name); 405 482 if (it != this->consoleCommands_.end()) 406 return (*it).second;483 return it->second; 407 484 else 408 485 return 0; … … 418 495 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name); 419 496 if (it != this->consoleCommands_LC_.end()) 420 return (*it).second;497 return it->second; 421 498 else 422 499 return 0; … … 432 509 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname); 433 510 if (it != this->xmlportParamContainers_.end()) 434 return ((*it).second);511 return it->second; 435 512 else 436 513 return 0; … … 463 540 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname); 464 541 if (it != this->xmlportObjectContainers_.end()) 465 return ((*it).second);542 return it->second; 466 543 else 467 544 return 0; … … 483 560 484 561 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 event490 @return The container491 */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 else498 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 event504 @param container The container505 */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;516 562 } 517 563 … … 525 571 { 526 572 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 } 528 578 529 579 return out; -
code/branches/pickup/src/libraries/core/Identifier.h
r5781 r5935 29 29 /** 30 30 @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. 32 32 33 33 The Identifier contains all needed information about the class it belongs to: … … 45 45 46 46 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.50 47 */ 51 48 … … 90 87 class _CoreExport Identifier 91 88 { 92 template <class T>93 friend class SubclassIdentifier;94 95 friend class Factory;96 97 89 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 98 104 /** @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); } 100 108 101 109 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 102 116 bool isA(const Identifier* identifier) const; 103 117 bool isExactlyA(const Identifier* identifier) const; … … 107 121 bool isDirectParentOf(const Identifier* identifier) const; 108 122 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); } 123 131 124 132 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ … … 130 138 131 139 /** @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_; } 133 141 /** @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(); } 135 143 /** @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(); } 137 145 138 146 /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */ … … 144 152 145 153 /** @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_; } 147 155 /** @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(); } 149 157 /** @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(); } 159 178 160 179 /** @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*>& getLowercase IdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }180 static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() { return Identifier::getLowercaseStringIdentifierMapIntern(); } 162 181 /** @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 getLowercase IdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }182 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() { return Identifier::getLowercaseStringIdentifierMap().begin(); } 164 183 /** @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_; } 167 201 168 202 /** @brief Returns the map that stores all config values. @return The const_iterator */ … … 180 214 inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); } 181 215 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_; } 182 226 183 227 /** @brief Returns the map that stores all console commands. @return The const_iterator */ … … 195 239 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); } 196 240 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 /////////////////// 197 249 /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */ 198 250 inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; } … … 209 261 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); } 210 262 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 239 263 void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container); 240 264 XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname); … … 243 267 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname); 244 268 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();255 269 256 270 protected: … … 262 276 virtual void createSuperFunctionCaller() const = 0; 263 277 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(); 266 282 /** @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(); 268 286 269 287 /** @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_; } 271 289 /** @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_; } 273 291 274 292 ObjectListBase* objects_; //!< The list of all objects of this class 275 293 276 294 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--; } 294 299 295 300 static std::map<std::string, Identifier*>& getTypeIDIdentifierMap(); … … 298 303 299 304 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 to305 mutable std::set<const Identifier*> children_; //!< The children of the class the Identifier belongs to 301 306 302 307 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 to308 mutable std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to 304 309 305 310 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) … … 307 312 bool bLoadable_; //!< False = it's not permitted to load the object through XML 308 313 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) 310 315 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) 311 316 uint32_t networkID_; //!< The network ID to identify a class through the network … … 323 328 std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_; //!< All loadable parameters 324 329 std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_; //!< All attachable objects 325 std::map<std::string, XMLPortObjectContainer*> xmlportEventContainers_; //!< All events326 330 }; 327 331 … … 348 352 349 353 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); 352 356 353 357 bool initialiseObject(T* object, const std::string& className, bool bRootClass); … … 380 384 inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 381 385 { 382 // check if the static field has already been filled383 if ( ClassIdentifier<T>::classIdentifier_s == 0)386 // check if the Identifier already exists 387 if (!ClassIdentifier<T>::classIdentifier_s) 384 388 ClassIdentifier<T>::initialiseIdentifier(); 385 389 … … 508 512 #endif 509 513 } 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 SubclassIdentifier523 {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 Identifier536 */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 assign545 @return The SubclassIdentifier itself546 */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 else558 {559 COUT(1) << "Error: Can't assign NULL identifier" << std::endl;560 }561 }562 else563 {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*() const573 {574 return this->identifier_;575 }576 577 /**578 @brief Overloading of the -> operator: returns the assigned identifier.579 */580 inline Identifier* operator->() const581 {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*() const589 {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 object596 */597 T* fabricate(BaseObject* creator) const598 {599 BaseObject* newObject = this->identifier_->fabricate(creator);600 601 // Check if the creation was successful602 if (newObject)603 {604 return orxonox_cast<T*>(newObject);605 }606 else607 {608 // Something went terribly wrong609 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 else617 {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() const630 { 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) const634 // { 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) const638 // { 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) const642 // { 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) const646 // { 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) const650 // { 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) const654 // { return this->identifier_->isDirectParentOf(identifier); }655 656 private:657 Identifier* identifier_; //!< The assigned identifier658 };659 514 } 660 515 -
code/branches/pickup/src/libraries/core/Iterator.h
r5738 r5935 167 167 168 168 return (*this); 169 return *this;170 169 } 171 170 … … 193 192 inline const Iterator<T>& operator++() 194 193 { 195 if (this->element_) 196 this->element_ = this->element_->next_; 194 this->element_ = this->element_->next_; 197 195 return *this; 198 196 } … … 205 203 { 206 204 Iterator<T> copy = *this; 207 if (this->element_) 208 this->element_ = this->element_->next_; 205 this->element_ = this->element_->next_; 209 206 return copy; 210 207 } … … 216 213 inline const Iterator<T>& operator--() 217 214 { 218 if (this->element_) 219 this->element_ = this->element_->prev_; 215 this->element_ = this->element_->prev_; 220 216 return *this; 221 217 } … … 228 224 { 229 225 Iterator<T> copy = *this; 230 if (this->element_) 231 this->element_ = this->element_->prev_; 226 this->element_ = this->element_->prev_; 232 227 return copy; 233 228 } … … 239 234 inline T* operator*() const 240 235 { 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_); 245 237 } 246 238 … … 251 243 inline T* operator->() const 252 244 { 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_); 257 246 } 258 247 -
code/branches/pickup/src/libraries/core/Language.cc
r5738 r5935 35 35 36 36 #include <fstream> 37 #include <boost/filesystem.hpp>38 39 37 #include "util/Debug.h" 40 38 #include "Core.h" 39 #include "PathConfig.h" 41 40 42 41 namespace orxonox … … 200 199 COUT(4) << "Read default language file." << std::endl; 201 200 202 boost::filesystem::path filepath(Core::getConfigPath() / getFilename(this->defaultLanguage_));201 std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_); 203 202 204 203 // This creates the file if it's not existing 205 204 std::ofstream createFile; 206 createFile.open(filepath. string().c_str(), std::fstream::app);205 createFile.open(filepath.c_str(), std::fstream::app); 207 206 createFile.close(); 208 207 209 208 // Open the file 210 209 std::ifstream file; 211 file.open(filepath. string().c_str(), std::fstream::in);210 file.open(filepath.c_str(), std::fstream::in); 212 211 213 212 if (!file.is_open()) … … 249 248 COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl; 250 249 251 boost::filesystem::path filepath(Core::getConfigPath() / getFilename(Core::getLanguage()));250 std::string filepath = PathConfig::getConfigPathString() + getFilename(Core::getLanguage()); 252 251 253 252 // Open the file 254 253 std::ifstream file; 255 file.open(filepath. string().c_str(), std::fstream::in);254 file.open(filepath.c_str(), std::fstream::in); 256 255 257 256 if (!file.is_open()) … … 303 302 COUT(4) << "Language: Write default language file." << std::endl; 304 303 305 boost::filesystem::path filepath(Core::getConfigPath() / getFilename(this->defaultLanguage_));304 std::string filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_); 306 305 307 306 // Open the file 308 307 std::ofstream file; 309 file.open(filepath. string().c_str(), std::fstream::out);308 file.open(filepath.c_str(), std::fstream::out); 310 309 311 310 if (!file.is_open()) -
code/branches/pickup/src/libraries/core/Loader.cc
r5781 r5935 103 103 { 104 104 if (mask.isIncluded(it->getIdentifier())) 105 delete (*(it++));105 (it++)->destroy(); 106 106 else 107 107 ++it; … … 204 204 { 205 205 if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier())) 206 delete (*(it++));206 (it++)->destroy(); 207 207 else 208 208 ++it; -
code/branches/pickup/src/libraries/core/LuaState.cc
r5781 r5935 37 37 38 38 #include "util/Debug.h" 39 #include "Core.h"40 39 #include "Resource.h" 41 40 #include "ToluaBindCore.h" -
code/branches/pickup/src/libraries/core/MemoryArchive.cc
r5781 r5935 68 68 continue; 69 69 if (bDirs) 70 file = file. parent_path();70 file = file.branch_path(); 71 71 if (file.empty()) 72 72 continue; 73 if (file.has_ parent_path() && !bRecursive)73 if (file.has_branch_path() && !bRecursive) 74 74 continue; 75 75 if (simpleList) … … 80 80 fi.archive = this; 81 81 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(); 84 84 fi.compressedSize = it->second.second; 85 85 fi.uncompressedSize = it->second.second; … … 119 119 120 120 bool MemoryArchive::exists(const String& filename) 121 121 { 122 122 const FileMap& files = archives_s[this->getName()]; 123 123 return files.find(filename) != files.end(); 124 124 } 125 125 126 126 const Ogre::String& MemoryArchiveFactory::getType(void) const -
code/branches/pickup/src/libraries/core/ObjectListIterator.h
r5738 r5935 123 123 inline const ObjectListIterator<T>& operator++() 124 124 { 125 if (this->element_) 126 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_); 125 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_); 127 126 return *this; 128 127 } … … 135 134 { 136 135 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_); 139 137 return copy; 140 138 } … … 146 144 inline const ObjectListIterator<T>& operator--() 147 145 { 148 if (this->element_) 149 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_); 146 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_); 150 147 return *this; 151 148 } … … 158 155 { 159 156 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_); 162 158 return copy; 163 159 } … … 169 165 inline T* operator*() const 170 166 { 171 if (this->element_) 172 return this->element_->object_; 173 else 174 return 0; 167 return this->element_->object_; 175 168 } 176 169 … … 181 174 inline T* operator->() const 182 175 { 183 if (this->element_) 184 return this->element_->object_; 185 else 186 return 0; 176 return this->element_->object_; 187 177 } 188 178 -
code/branches/pickup/src/libraries/core/OrxonoxClass.cc
r5738 r5935 36 36 #include "MetaObjectList.h" 37 37 #include "Identifier.h" 38 #include "WeakPtr.h" 38 39 39 40 namespace orxonox … … 45 46 this->parents_ = 0; 46 47 this->metaList_ = new MetaObjectList(); 48 this->referenceCount_ = 0; 49 this->requestedDestruction_ = false; 47 50 } 48 51 … … 50 53 OrxonoxClass::~OrxonoxClass() 51 54 { 55 // if (!this->requestedDestruction_) 56 // COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl; 57 58 assert(this->referenceCount_ <= 0); 59 52 60 delete this->metaList_; 53 61 … … 55 63 if (this->parents_) 56 64 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; 57 77 } 58 78 … … 78 98 79 99 /** @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. */120 100 bool OrxonoxClass::isA(const OrxonoxClass* object) 121 101 { return this->getIdentifier()->isA(object->getIdentifier()); } -
code/branches/pickup/src/libraries/core/OrxonoxClass.h
r5738 r5935 55 55 friend class ClassIdentifier; 56 56 57 template <class T> 58 friend class SmartPtr; 59 60 template <class T> 61 friend class WeakPtr; 62 57 63 public: 58 64 OrxonoxClass(); 59 65 virtual ~OrxonoxClass(); 66 67 void destroy(); 60 68 61 69 /** @brief Function to collect the SetConfigValue-macro calls. */ … … 72 80 bool isDirectParentOf(const Identifier* identifier); 73 81 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); } 87 94 88 95 bool isA(const OrxonoxClass* object); … … 93 100 bool isDirectParentOf(const OrxonoxClass* object); 94 101 102 inline unsigned int getReferenceCount() const 103 { return this->referenceCount_; } 104 95 105 /** 96 106 @brief … … 100 110 Returns NULL if the no pointer was found. 101 111 */ 102 template <class T> 103 FORCEINLINE T* getDerivedPointer(unsigned int classID) 112 FORCEINLINE void* getDerivedPointer(unsigned int classID) 104 113 { 105 114 for (int i = this->objectPointers_.size() - 1; i >= 0; --i) 106 115 { 107 116 if (this->objectPointers_[i].first == classID) 108 return static_cast<T*>(this->objectPointers_[i].second);117 return this->objectPointers_[i].second; 109 118 } 110 119 return NULL; 111 120 } 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); } 118 128 119 129 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 120 146 Identifier* identifier_; //!< The Identifier of the object 121 147 std::set<const Identifier*>* parents_; //!< List of all parents of the object 122 148 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 123 153 //! 'Fast map' that holds this-pointers of all derived types 124 154 std::vector<std::pair<unsigned int, void*> > objectPointers_; -
code/branches/pickup/src/libraries/core/Resource.h
r5781 r5935 64 64 // Docs by Ogre::ResourceGroupManager.h 65 65 public: 66 66 /** 67 67 @brief 68 68 Open a single resource by name and return a DataStream … … 81 81 Shared pointer to data stream containing the data. Will be 82 82 destroyed automatically when no longer referenced. 83 83 */ 84 84 static DataStreamPtr open(const std::string& name, 85 85 const std::string& group = Resource::DEFAULT_GROUP, 86 86 bool bSearchGroupsIfNotFound = false); 87 87 88 88 /** 89 89 @brief 90 90 Open all resources matching a given pattern (which can contain … … 101 101 Shared pointer to a data stream list , will be 102 102 destroyed automatically when no longer referenced 103 103 */ 104 104 static DataStreamListPtr openMulti(const std::string& pattern, const std::string& group = Resource::DEFAULT_GROUP); 105 105 -
code/branches/pickup/src/libraries/core/Shell.cc
r5781 r5935 88 88 OutputHandler::getOutStream().setOutputBuffer(0); 89 89 if (this->inputBuffer_) 90 delete this->inputBuffer_;90 this->inputBuffer_->destroy(); 91 91 } 92 92 -
code/branches/pickup/src/libraries/core/Super.h
r5781 r5935 250 250 SUPER_NOARGS(classname, functionname) 251 251 252 #define SUPER_ processEvent(classname, functionname, ...) \252 #define SUPER_XMLEventPort(classname, functionname, ...) \ 253 253 SUPER_ARGS(classname, functionname, __VA_ARGS__) 254 254 255 255 #define SUPER_changedScale(classname, functionname, ...) \ 256 SUPER_NOARGS(classname, functionname)257 258 #define SUPER_changedMainState(classname, functionname, ...) \259 256 SUPER_NOARGS(classname, functionname) 260 257 … … 497 494 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 498 495 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) 501 498 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 502 499 … … 505 502 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 506 503 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) 524 517 () 525 518 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; … … 571 564 SUPER_INTRUSIVE_DECLARATION(changedActivity); 572 565 SUPER_INTRUSIVE_DECLARATION(changedVisibility); 573 SUPER_INTRUSIVE_DECLARATION( processEvent);566 SUPER_INTRUSIVE_DECLARATION(XMLEventPort); 574 567 SUPER_INTRUSIVE_DECLARATION(changedScale); 575 SUPER_INTRUSIVE_DECLARATION(changedMainState);576 568 SUPER_INTRUSIVE_DECLARATION(changedOwner); 577 569 SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup); -
code/branches/pickup/src/libraries/core/TclBind.cc
r5781 r5935 39 39 #include "CommandExecutor.h" 40 40 #include "ConsoleCommand.h" 41 #include " Core.h"41 #include "PathConfig.h" 42 42 #include "TclThreadManager.h" 43 43 … … 123 123 { 124 124 #ifdef DEPENDENCY_PACKAGE_ENABLE 125 if ( Core::isDevelopmentRun())125 if (PathConfig::isDevelopmentRun()) 126 126 return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl"); 127 127 else 128 return ( Core::getRootPathString() + "lib/tcl");128 return (PathConfig::getRootPathString() + "lib/tcl"); 129 129 #else 130 130 return ""; -
code/branches/pickup/src/libraries/core/TclThreadManager.cc
r5781 r5935 36 36 #include <cpptcl/cpptcl.h> 37 37 38 #include "util/Clock.h" 38 39 #include "util/Convert.h" 39 40 #include "util/Exception.h" 40 #include "Clock.h"41 41 #include "CommandExecutor.h" 42 42 #include "ConsoleCommand.h" -
code/branches/pickup/src/libraries/core/XMLPort.h
r5781 r5935 51 51 #include "util/MultiType.h" 52 52 #include "util/OrxAssert.h" 53 #include "Factory.h"54 53 #include "Identifier.h" 55 54 #include "Executor.h" … … 377 376 this->owner_->xmlAttributes_.clear(); 378 377 // 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); 380 379 while (attribute != 0) 381 380 { … … 412 411 } 413 412 } 414 else 413 else if (mode == XMLPort::SaveObject) 415 414 { 416 415 if (this->saveexecutor_) … … 548 547 for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++) 549 548 { 550 Identifier* identifier = Factory::getIdentifier(child->Value());549 Identifier* identifier = Identifier::getIdentifierByString(child->Value()); 551 550 if (identifier) 552 551 { … … 629 628 } 630 629 } 631 else 630 else if (mode == XMLPort::SaveObject) 632 631 { 633 632 } -
code/branches/pickup/src/libraries/core/input/Button.cc
r5781 r5935 170 170 171 171 // evaluate the command 172 CommandEvaluationeval = CommandExecutor::evaluate(commandStr);172 const CommandEvaluation& eval = CommandExecutor::evaluate(commandStr); 173 173 if (!eval.isValid()) 174 174 { 175 parseError("Command evaluation failed.", true);175 parseError("Command evaluation of \"" + commandStr + "\"failed.", true); 176 176 continue; 177 177 } -
code/branches/pickup/src/libraries/core/input/CMakeLists.txt
r5781 r5935 9 9 JoyStickQuantityListener.cc 10 10 KeyBinder.cc 11 KeyBinderManager.cc 11 12 Keyboard.cc 12 13 KeyDetector.cc -
code/branches/pickup/src/libraries/core/input/InputDevice.h
r5781 r5935 41 41 #include <ois/OISInputManager.h> 42 42 43 #include "util/Clock.h" 43 44 #include "util/Debug.h" 44 45 #include "util/Exception.h" 45 #include "core/Clock.h"46 46 #include "InputState.h" 47 47 -
code/branches/pickup/src/libraries/core/input/InputManager.cc
r5781 r5935 41 41 #include <boost/foreach.hpp> 42 42 43 #include "util/Clock.h" 43 44 #include "util/Convert.h" 44 45 #include "util/Exception.h" 45 46 #include "util/ScopeGuard.h" 46 #include "core/Clock.h"47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" … … 53 53 54 54 #include "InputBuffer.h" 55 #include "KeyDetector.h"56 55 #include "JoyStick.h" 57 56 #include "JoyStickQuantityListener.h" … … 88 87 , oisInputManager_(0) 89 88 , devices_(2) 90 , bExclusiveMouse_(false)89 , mouseMode_(MouseMode::Nonexclusive) 91 90 , emptyState_(0) 92 , keyDetector_(0)93 91 , calibratorCallbackHandler_(0) 94 92 { … … 99 97 this->setConfigValues(); 100 98 99 if (GraphicsManager::getInstance().isFullScreen()) 100 mouseMode_ = MouseMode::Exclusive; 101 101 this->loadDevices(); 102 102 … … 105 105 emptyState_->setHandler(&InputHandler::EMPTY); 106 106 activeStates_[emptyState_->getPriority()] = emptyState_; 107 108 // KeyDetector to evaluate a pressed key's name109 InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);110 // Create a callback to avoid buttonHeld events after the key has been detected111 FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);112 bufferFunctor->setObject(this);113 detector->setLeaveFunctor(bufferFunctor);114 keyDetector_ = new KeyDetector();115 detector->setHandler(keyDetector_);116 107 117 108 // Joy stick calibration helper callback … … 124 115 this->updateActiveStates(); 125 116 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); 138 121 139 122 CCOUT(4) << "Construction complete." << std::endl; … … 172 155 paramList.insert(std::make_pair("w32_keyboard", "DISCL_FOREGROUND")); 173 156 paramList.insert(std::make_pair("w32_mouse", "DISCL_FOREGROUND")); 174 if ( bExclusiveMouse_|| GraphicsManager::getInstance().isFullScreen())157 if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen()) 175 158 { 176 159 // Disable Windows key plus special keys (like play, stop, next, etc.) … … 185 168 paramList.insert(std::make_pair("XAutoRepeatOn", "true")); 186 169 187 if ( bExclusiveMouse_|| GraphicsManager::getInstance().isFullScreen())170 if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen()) 188 171 { 189 172 if (CommandLine::getValue("keyboard_no_grab").getBool()) … … 274 257 } 275 258 276 void InputManager::setKeyDetectorCallback(const std::string& command)277 {278 this->keyDetector_->setCallbackCommand(command);279 }280 281 259 // ############################################################ 282 260 // ##### Destruction ##### … … 289 267 290 268 // Destroy calibrator helper handler and state 291 delete keyDetector_;292 269 this->destroyState("calibrator"); 293 270 // Destroy KeyDetector and state 294 delete calibratorCallbackHandler_; 295 this->destroyState("detector"); 271 calibratorCallbackHandler_->destroy(); 296 272 // destroy the empty InputState 297 273 this->destroyStateInternal(this->emptyState_); … … 528 504 529 505 // Check whether we have to change the mouse mode 506 MouseMode::Value requestedMode = MouseMode::Dontcare; 530 507 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; 535 515 if (!GraphicsManager::getInstance().isFullScreen()) 536 516 this->reloadInternal(); … … 722 702 } 723 703 statesByName_.erase(state->getName()); 724 delete state;704 state->destroy(); 725 705 } 726 706 } -
code/branches/pickup/src/libraries/core/input/InputManager.h
r5781 r5935 161 161 // Various getters and setters 162 162 //------------------------------- 163 //! Sets the the name of the command used by the KeyDetector as callback.164 void setKeyDetectorCallback(const std::string& command);165 163 //! Returns the number of joy stick that have been created since the c'tor or last call to reload(). 166 164 unsigned int getJoyStickQuantity() const … … 193 191 OIS::InputManager* oisInputManager_; //!< OIS input manager 194 192 std::vector<InputDevice*> devices_; //!< List of all input devices (keyboard, mouse, joy sticks) 195 bool bExclusiveMouse_;//!< Currently applied mouse mode193 MouseMode::Value mouseMode_; //!< Currently applied mouse mode 196 194 197 195 // some internally handled states and handlers 198 196 InputState* emptyState_; //!< Lowest priority states (makes handling easier) 199 KeyDetector* keyDetector_; //!< KeyDetector instance200 197 //! InputBuffer that reacts to the Enter key when calibrating the joy sticks 201 198 InputBuffer* calibratorCallbackHandler_; -
code/branches/pickup/src/libraries/core/input/InputState.cc
r5781 r5935 37 37 , bAlwaysGetsInput_(bAlwaysGetsInput) 38 38 , bTransparent_(bTransparent) 39 , bExclusiveMouse_(true)39 , mouseMode_(MouseMode::Dontcare) 40 40 , bExpired_(true) 41 41 , handlers_(2) -
code/branches/pickup/src/libraries/core/input/InputState.h
r5781 r5935 55 55 static const int Detector = HighPriority + 2; 56 56 }; 57 58 namespace MouseMode 59 { 60 enum Value 61 { 62 Exclusive, 63 Nonexclusive, 64 Dontcare 65 }; 66 } 57 67 58 68 /** … … 120 130 void setHandler (InputHandler* handler); 121 131 122 void set IsExclusiveMouse(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_; } 124 134 125 135 //! Returns the name of the state (which is unique!) … … 174 184 const bool bAlwaysGetsInput_; //!< See class declaration for explanation 175 185 const bool bTransparent_; //!< See class declaration for explanation 176 bool bExclusiveMouse_;//!< See class declaration for explanation186 MouseMode::Value mouseMode_; //!< See class declaration for explanation 177 187 int priority_; //!< Current priority (might change) 178 188 bool bExpired_; //!< See hasExpired() -
code/branches/pickup/src/libraries/core/input/KeyBinder.cc
r5781 r5935 27 27 */ 28 28 29 /**30 @file31 @brief Implementation of the different input handlers.32 */33 34 29 #include "KeyBinder.h" 35 30 36 31 #include "util/Convert.h" 37 32 #include "util/Debug.h" 33 #include "util/Exception.h" 38 34 #include "core/ConfigValueIncludes.h" 39 35 #include "core/CoreIncludes.h" … … 48 44 Constructor that does as little as necessary. 49 45 */ 50 KeyBinder::KeyBinder( )46 KeyBinder::KeyBinder(const std::string& filename) 51 47 : deriveTime_(0.0f) 48 , filename_(filename) 52 49 { 53 50 mouseRelative_[0] = 0; … … 103 100 // set them here to use allHalfAxes_ 104 101 setConfigValues(); 102 103 // Load the bindings if filename was given 104 if (!this->filename_.empty()) 105 this->loadBindings(); 105 106 } 106 107 … … 240 241 @brief 241 242 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() 246 245 { 247 246 COUT(3) << "KeyBinder: Loading key bindings..." << std::endl; 248 247 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_); 259 252 260 253 // Parse bindings and create the ConfigValueContainers if necessary 261 clearBindings();262 254 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 263 255 it->second->readConfigValue(this->configFile_); -
code/branches/pickup/src/libraries/core/input/KeyBinder.h
r5781 r5935 26 26 * 27 27 */ 28 29 /**30 @file31 @brief32 Different definitions of input processing.33 */34 28 35 29 #ifndef _KeyBinder_H__ … … 53 47 /** 54 48 @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. 57 55 */ 58 56 class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener 59 57 { 60 58 public: 61 KeyBinder ( );59 KeyBinder (const std::string& filename); 62 60 virtual ~KeyBinder(); 63 61 64 void loadBindings(const std::string& filename);65 62 void clearBindings(); 66 63 bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false); 64 const std::string& getBindingsFilename() 65 { return this->filename_; } 67 66 void setConfigValues(); 68 67 void resetJoyStickAxes(); 69 68 70 69 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 71 77 void allDevicesUpdated(float dt); 72 78 void mouseUpdated(float dt); … … 74 80 // internal 75 81 void tickHalfAxis(HalfAxis& halfAxis); 76 77 void buttonThresholdChanged();78 // from JoyStickQuantityListener interface79 virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);80 void initialiseJoyStickBindings();81 void compilePointerLists();82 82 83 83 void buttonPressed (const KeyEvent& evt); … … 144 144 float deriveTime_; 145 145 146 //! Name of the file used in this KeyBinder (constant!) 147 const std::string filename_; 146 148 //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded. 147 149 ConfigFileType configFile_; … … 171 173 }; 172 174 175 173 176 inline void KeyBinder::buttonPressed (const KeyEvent& evt) 174 177 { assert(!keys_[evt.getKeyCode()].name_.empty()); keys_[evt.getKeyCode()].execute(KeybindMode::OnPress); } -
code/branches/pickup/src/libraries/core/input/KeyDetector.cc
r5781 r5935 29 29 #include "KeyDetector.h" 30 30 31 #include " util/Debug.h"31 #include "core/ConsoleCommand.h" 32 32 #include "core/CoreIncludes.h" 33 #include "core/ScopedSingletonManager.h" 33 34 #include "Button.h" 35 #include "InputManager.h" 36 #include "InputState.h" 34 37 35 38 namespace orxonox 36 39 { 37 /**38 @brief39 Constructor40 */ 40 std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed"; 41 KeyDetector* KeyDetector::singletonPtr_s = 0; 42 ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false); 43 41 44 KeyDetector::KeyDetector() 45 : KeyBinder("") 42 46 { 43 47 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); 44 56 } 45 57 46 /**47 @brief48 Destructor49 */50 58 KeyDetector::~KeyDetector() 51 59 { 60 inputState_->setHandler(NULL); 61 InputManager::getInstance().destroyState("detector"); 52 62 } 53 63 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() 59 65 { 60 callbackCommand_ = command;66 // Assign every button/axis the same command, but with its name as argument 61 67 clearBindings(); 62 68 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 63 69 { 64 it->second->bindingString_ = callbackCommand_ + it->second->groupName_ + "." + it->second->name_;70 it->second->bindingString_ = callbackCommand_s + " " + it->second->groupName_ + "." + it->second->name_; 65 71 it->second->parse(); 66 72 } 73 } 74 75 void KeyDetector::callback(const std::string& name) 76 { 77 // Call the registered function 78 if (this->callbackFunction_) 79 (*this->callbackFunction_)(name); 67 80 } 68 81 … … 70 83 { 71 84 KeyBinder::JoyStickQuantityChanged(joyStickList); 72 if (!callbackCommand_.empty()) 73 setCallbackCommand(callbackCommand_); 85 this->assignCommands(); 74 86 } 75 87 } -
code/branches/pickup/src/libraries/core/input/KeyDetector.h
r5781 r5935 32 32 #include "InputPrereqs.h" 33 33 34 #include <string>34 #include "util/Singleton.h" 35 35 #include "KeyBinder.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _CoreExport KeyDetector : public KeyBinder 39 class _CoreExport KeyDetector : public KeyBinder, public Singleton<KeyDetector> 40 40 { 41 friend class Singleton<KeyDetector>; 42 41 43 public: 42 44 KeyDetector(); 43 45 ~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; } 46 48 47 49 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; 49 60 }; 50 61 } -
code/branches/pickup/src/libraries/core/input/Mouse.cc
r5781 r5935 48 48 49 49 #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); 62 54 #endif 63 55 } -
code/branches/pickup/src/libraries/network/Client.cc
r5781 r5935 43 43 #include <cassert> 44 44 45 #include "util/Clock.h" 45 46 #include "util/Debug.h" 46 #include "core/Clock.h"47 47 #include "synchronisable/Synchronisable.h" 48 48 #include "packet/Chat.h" 49 49 #include "packet/Gamestate.h" 50 50 #include "FunctionCallManager.h" 51 #include "core/CoreIncludes.h" 52 #include "core/Game.h" 51 53 52 54 namespace orxonox … … 158 160 return; 159 161 } 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 } 160 178 161 179 } -
code/branches/pickup/src/libraries/network/Client.h
r5781 r5935 45 45 46 46 #include <string> 47 48 #include "util/UtilPrereqs.h" 47 49 #include "ClientConnection.h" 48 50 #include "GamestateClient.h" … … 72 74 73 75 void update(const Clock& time); 74 76 protected: 77 virtual void connectionClosed(); 75 78 private: 76 79 Client(const Client& copy); // not used -
code/branches/pickup/src/libraries/network/ClientConnection.cc
r5781 r5935 118 118 case ENET_EVENT_TYPE_DISCONNECT: 119 119 COUT(4) << "received disconnect confirmation from server" << endl; 120 this->connectionClosed(); 120 121 return true; 121 122 } … … 123 124 } 124 125 enet_peer_reset( this->server_ ); 126 this->connectionClosed(); 125 127 return false; 126 128 } … … 133 135 } 134 136 135 void ClientConnection::add Client(ENetEvent* event)137 void ClientConnection::addPeer(ENetEvent* event) 136 138 { 137 139 assert(0); 138 140 } 139 void ClientConnection:: disconnectPeer(ENetEvent* event)141 void ClientConnection::removePeer(ENetEvent* event) 140 142 { 141 143 this->established_=false; 142 144 COUT(1) << "Received disconnect Packet from Server!" << endl; 143 145 // server closed the connection 146 this->connectionClosed(); 144 147 } 145 148 -
code/branches/pickup/src/libraries/network/ClientConnection.h
r5781 r5935 53 53 bool addPacket(ENetPacket *packet); 54 54 inline bool isConnected(){ return this->established_; } 55 protected: 56 virtual void connectionClosed()=0; 55 57 private: 56 virtual void add Client(ENetEvent* event);57 virtual void disconnectPeer(ENetEvent* event);58 virtual void addPeer(ENetEvent* event); 59 virtual void removePeer(ENetEvent* event); 58 60 59 61 bool disconnectConnection(); -
code/branches/pickup/src/libraries/network/ClientConnectionListener.cc
r5781 r5935 33 33 #include "ClientInformation.h" 34 34 35 namespace orxonox{ 35 namespace orxonox 36 { 37 ClientConnectionListener::ClientConnectionListener() 38 { 39 RegisterRootObject(ClientConnectionListener); 40 } 36 41 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 } 41 53 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 } 49 62 } 50 }51 52 63 } 53 64 -
code/branches/pickup/src/libraries/network/ClientConnectionListener.h
r5781 r5935 33 33 #include "core/OrxonoxClass.h" 34 34 35 namespace orxonox{ 35 namespace 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); 36 45 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; 40 48 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 }; 52 52 } 53 53 -
code/branches/pickup/src/libraries/network/Connection.cc
- Property svn:eol-style set to native
r5781 r5935 83 83 // log handling ================ 84 84 case ENET_EVENT_TYPE_CONNECT: 85 add Client( &event );85 addPeer( &event ); 86 86 break; 87 87 case ENET_EVENT_TYPE_DISCONNECT: 88 disconnectPeer( &event );88 removePeer( &event ); 89 89 break; 90 90 case ENET_EVENT_TYPE_RECEIVE: -
code/branches/pickup/src/libraries/network/Connection.h
- Property svn:eol-style set to native
r5781 r5935 64 64 65 65 int service(ENetEvent* event); 66 v oid disconnectPeer(ENetPeer *peer);66 virtual void disconnectPeer(ENetPeer *peer); 67 67 68 68 void processQueue(); 69 virtual void add Client(ENetEvent* event)=0;70 virtual void disconnectPeer(ENetEvent* event)=0;69 virtual void addPeer(ENetEvent* event)=0; 70 virtual void removePeer(ENetEvent* event)=0; 71 71 virtual bool processPacket(ENetEvent* event); 72 72 -
code/branches/pickup/src/libraries/network/GamestateClient.cc
r5781 r5935 108 108 ObjectList<Synchronisable>::iterator temp=it; 109 109 ++it; 110 delete *temp;110 temp->destroy(); // or delete? 111 111 } 112 112 -
code/branches/pickup/src/libraries/network/GamestateManager.cc
r5781 r5935 77 77 delete (*it2).second; 78 78 } 79 delete this->trafficControl_;79 this->trafficControl_->destroy(); 80 80 // delete this->threadMutex_; 81 81 // delete this->threadPool_; … … 160 160 finishGamestate( cid, &clientGamestates.back(), client, reference ); 161 161 //FunctorMember<GamestateManager>* functor = 162 // ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate) ); 163 // executor->setObject(this); 162 // ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) ); 164 163 // executor->setDefaultValues( cid, &clientGamestates.back(), client, reference ); 165 164 // (*static_cast<Executor*>(executor))(); -
code/branches/pickup/src/libraries/network/NetworkFunction.cc
r5781 r5935 60 60 std::map<std::string, NetworkFunctionBase*>::iterator it; 61 61 for( it=NetworkFunctionBase::nameMap_.begin(); it!=NetworkFunctionBase::nameMap_.end(); ++it ) 62 delete it->second;62 it->second->destroy(); 63 63 } 64 64 -
code/branches/pickup/src/libraries/network/NetworkPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 40 41 // Shared library settings 41 42 //----------------------------------------------------------------------- 43 42 44 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( NETWORK_STATIC_BUILD ) 43 45 # ifdef NETWORK_SHARED_BUILD … … 57 59 58 60 //----------------------------------------------------------------------- 59 // Library global contants61 // Constants 60 62 //----------------------------------------------------------------------- 63 61 64 namespace orxonox 62 65 { 63 66 static const unsigned int GAMESTATEID_INITIAL = static_cast<unsigned int>(-1); 64 67 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 74 namespace 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 } 66 88 } 67 89 … … 84 106 namespace orxonox 85 107 { 108 class ChatListener; 86 109 class Client; 87 110 class ClientConnection; 88 111 class ClientConnectionListener; 89 class ClientFrameListener;90 112 class ClientInformation; 91 113 class Connection; 92 114 class FunctionCallManager; 93 115 class GamestateClient; 116 class GamestateHandler; 94 117 class GamestateManager; 95 class GamestateHandler; 96 class NetworkCallbackBase; 97 template <class T> class NetworkCallback; 98 class NetworkCallbackManager; 118 class Host; 99 119 class NetworkFunctionBase; 120 struct NetworkFunctionPointer; 100 121 class NetworkFunctionStatic; 122 template <class T> 123 class NetworkMemberFunction; 101 124 class NetworkMemberFunctionBase; 102 template <class T> class NetworkMemeberFunction;103 struct NetworkFunctionPointer;104 125 class Server; 105 126 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;115 127 class TrafficControl; 116 class obj;117 class objInfo;118 128 129 // packet 119 130 namespace packet 120 131 { … … 122 133 class Chat; 123 134 class ClassID; 135 class DeleteObjects; 124 136 class FunctionCalls; 125 137 class FunctionIDs; 126 138 class Gamestate; 127 class NetworkIDs;128 139 class Packet; 129 140 class Welcome; 141 } 130 142 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; 141 155 } 142 156 -
code/branches/pickup/src/libraries/network/Server.cc
r5781 r5935 46 46 #include <string> 47 47 48 #include "util/Clock.h" 48 49 #include "util/Debug.h" 49 #include "core/Clock.h"50 50 #include "core/ObjectList.h" 51 51 #include "core/Executor.h" … … 245 245 packet::DeleteObjects *del = new packet::DeleteObjects(); 246 246 if(!del->fetchIDs()) 247 { 248 delete del; 247 249 return true; //everything ok (no deletes this tick) 250 } 248 251 // COUT(3) << "sending DeleteObjects" << std::endl; 249 252 while(temp != NULL){ … … 267 270 268 271 269 void Server::add Client(ENetEvent *event){272 void Server::addPeer(ENetEvent *event){ 270 273 static unsigned int newid=1; 271 274 … … 279 282 280 283 // 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); 286 285 287 286 ++newid; … … 290 289 createClient(temp->getID()); 291 290 } 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 } 292 305 293 306 bool Server::createClient(int clientID){ … … 329 342 ServerConnection::disconnectClient( client ); 330 343 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()); 338 346 } 339 347 -
code/branches/pickup/src/libraries/network/Server.h
r5781 r5935 32 32 #include "NetworkPrereqs.h" 33 33 34 #include "util/UtilPrereqs.h" 34 35 #include "core/CorePrereqs.h" 35 36 #include "Host.h" … … 65 66 unsigned int playerID(){return 0;} 66 67 67 void addClient(ENetEvent *event); 68 void addPeer(ENetEvent *event); 69 void removePeer(ENetEvent *event); 70 68 71 bool createClient(int clientID); 69 72 void disconnectClient( ClientInformation *client); -
code/branches/pickup/src/libraries/network/ServerConnection.cc
r5781 r5935 103 103 { 104 104 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 else115 ServerConnection::disconnectClient( client );116 105 } 117 106 … … 119 108 ClientInformation *client = ClientInformation::findClient(clientID); 120 109 if(client) 121 disconnectClient(client);110 ServerConnection::disconnectClient(client); 122 111 } 123 112 … … 126 115 ClientInformation *temp = ClientInformation::getBegin(); 127 116 while(temp!=0){ 128 disconnectClient( temp );117 ServerConnection::disconnectClient( temp ); 129 118 temp = temp->next(); 130 119 } … … 141 130 break; 142 131 case ENET_EVENT_TYPE_DISCONNECT: 143 if(ClientInformation::findClient(&(event.peer->address))) 144 delete ClientInformation::findClient(&(event.peer->address)); 132 removePeer( &event ); 145 133 temp = ClientInformation::getBegin(); 146 134 break; -
code/branches/pickup/src/libraries/network/ServerConnection.h
- Property svn:eol-style set to native
r5781 r5935 59 59 static bool addPacketAll(ENetPacket *packet); 60 60 virtual void disconnectClient(ClientInformation *client); 61 void disconnectPeer( ENetEvent* event );62 61 void disconnectClient(int clientID); 63 62 protected: -
code/branches/pickup/src/libraries/network/packet/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(NETWORK_SRC_FILES 2 COMPILATION_BEGIN PacketCompilation.cc 2 3 Acknowledgement.cc 3 4 Chat.cc … … 9 10 Packet.cc 10 11 Welcome.cc 12 COMPILATION_END 11 13 ) 12 14 -
code/branches/pickup/src/libraries/network/packet/ClassID.cc
r5781 r5935 49 49 Identifier *id; 50 50 std::string classname; 51 unsigned int nrOfClasses=0; 51 unsigned int nrOfClasses=0; 52 52 unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses 53 53 uint32_t network_id; 54 54 flags_ = flags_ | PACKET_FLAGS_CLASSID; 55 55 std::queue<std::pair<uint32_t, std::string> > tempQueue; 56 56 57 57 //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){ 60 60 id = (*it).second; 61 if(id == NULL )61 if(id == NULL || !id->hasFactory()) 62 62 continue; 63 63 classname = id->getName(); 64 64 network_id = id->getNetworkID(); 65 if(network_id==0)66 COUT(3) << "we got a null class id: " << id->getName() << std::endl;67 65 // now push the network id and the classname to the stack 68 66 tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) ); … … 70 68 packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); 71 69 } 72 70 73 71 this->data_=new uint8_t[ packetSize ]; 74 72 //set the appropriate packet id 75 73 assert(this->data_); 76 74 *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID; 77 75 78 76 uint8_t *temp=data_+sizeof(uint32_t); 79 77 // save the number of all classes 80 78 *(uint32_t*)temp = nrOfClasses; 81 79 temp += sizeof(uint32_t); 82 80 83 81 // now save all classids and classnames 84 82 std::pair<uint32_t, std::string> tempPair; … … 91 89 temp+=2*sizeof(uint32_t)+tempPair.second.size()+1; 92 90 } 93 91 94 92 COUT(5) << "classid packetSize is " << packetSize << endl; 95 93 96 94 } 97 95 … … 111 109 temp += sizeof(uint32_t); 112 110 totalsize += sizeof(uint32_t); // storage size for nr of all classes 113 111 114 112 for(unsigned int i=0; i<nrOfClasses; i++){ 115 113 totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); … … 125 123 uint32_t stringsize; 126 124 unsigned char *classname; 127 128 129 //clea nthe map of network ids130 Factory::cleanNetworkIDs();131 125 126 127 //clear the map of network ids 128 Identifier::clearNetworkIDs(); 129 132 130 COUT(4) << "=== processing classids: " << endl; 133 131 std::pair<uint32_t, std::string> tempPair; … … 136 134 nrOfClasses = *(uint32_t*)temp; 137 135 temp += sizeof(uint32_t); 138 136 139 137 for( int i=0; i<nrOfClasses; i++){ 140 138 networkID = *(uint32_t*)temp; -
code/branches/pickup/src/libraries/network/packet/Gamestate.cc
r5781 r5935 378 378 rawDiff( dest2, dest, basep, header_->getDataSize(), base->header_->getDataSize() ); 379 379 assert( memcmp( dest2, gs, dest_length) == 0 ); 380 delete dest2; 380 381 #endif 381 382 -
code/branches/pickup/src/libraries/network/synchronisable/Synchronisable.cc
r5781 r5935 47 47 /** 48 48 * Constructor: 49 * Initializes all Variables and sets the right objectID 49 * Initializes all Variables and sets the right objectID_ 50 50 */ 51 Synchronisable::Synchronisable(BaseObject* creator ){51 Synchronisable::Synchronisable(BaseObject* creator ){ 52 52 RegisterRootObject(Synchronisable); 53 53 static uint32_t idCounter=0; … … 55 55 if ( GameMode::isMaster() || ( Host::running() && Host::isServer() ) ) 56 56 { 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++ ); 60 58 } 61 59 else 62 60 { 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); 67 64 68 65 // set dataSize to 0 … … 72 69 73 70 // 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: 77 77 if (creator) 78 78 { … … 80 80 if (synchronisable_creator && synchronisable_creator->objectMode_) 81 81 { 82 this->creatorID = synchronisable_creator->get ObjectID();82 this->creatorID = synchronisable_creator->getScene()->getObjectID(); 83 83 } 84 84 else if (creator != creator->getCreator()) … … 87 87 goto searchcreatorID; 88 88 } 89 } 89 }*/ 90 90 } 91 91 92 92 /** 93 93 * Destructor: 94 * Delete all callback objects and remove objectID from the objectMap_94 * Delete all callback objects and remove objectID_ from the objectMap_ 95 95 */ 96 96 Synchronisable::~Synchronisable(){ … … 99 99 // remove object from the static objectMap 100 100 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer())) 101 deletedObjects_.push(objectID );101 deletedObjects_.push(objectID_); 102 102 } 103 103 // delete all Synchronisable Variables from syncList ( which are also in stringList ) … … 107 107 stringList.clear(); 108 108 std::map<uint32_t, Synchronisable*>::iterator it; 109 it = objectMap_.find(objectID );109 it = objectMap_.find(objectID_); 110 110 if (it != objectMap_.end()) 111 111 objectMap_.erase(it); … … 172 172 Synchronisable *no = orxonox_cast<Synchronisable*>(bo); 173 173 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; 178 181 // update data and create object/entity... 179 assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );180 Synchronisable::objectMap_[header.getObjectID()] = no;181 182 bool b = no->updateData(mem, mode, true); 182 183 assert(b); … … 191 192 192 193 /** 193 * Finds and deletes the Synchronisable with the appropriate objectID 194 * @param objectID objectIDof the Synchronisable194 * Finds and deletes the Synchronisable with the appropriate objectID_ 195 * @param objectID_ objectID_ of the Synchronisable 195 196 * @return true/false 196 197 */ 197 bool Synchronisable::deleteObject(uint32_t objectID ){198 if(!getSynchronisable(objectID ))198 bool Synchronisable::deleteObject(uint32_t objectID_){ 199 if(!getSynchronisable(objectID_)) 199 200 return false; 200 assert(getSynchronisable(objectID )->objectID==objectID);201 Synchronisable *s = getSynchronisable(objectID );201 assert(getSynchronisable(objectID_)->objectID_==objectID_); 202 Synchronisable *s = getSynchronisable(objectID_); 202 203 if(s) 203 delete s;204 s->destroy(); // or delete? 204 205 else 205 206 return false; … … 208 209 209 210 /** 210 * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable211 * @param objectID objectIDof the Synchronisable212 * @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_){ 215 216 std::map<uint32_t, Synchronisable*>::iterator it1; 216 it1 = objectMap_.find(objectID );217 it1 = objectMap_.find(objectID_); 217 218 if (it1 != objectMap_.end()) 218 219 return it1->second; … … 220 221 // ObjectList<Synchronisable>::iterator it; 221 222 // 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; 224 225 // return *it; 225 226 // } … … 231 232 232 233 /** 233 * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classIDto the given memory234 * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID_ and classID_ to the given memory 234 235 * takes a pointer to already allocated memory (must have at least getSize bytes length) 235 236 * structure of the bitstream: 236 * |totalsize,objectID ,classID,var1,var2,string1_length,string1,var3,...|237 * |totalsize,objectID_,classID_,var1,var2,string1_length,string1,var3,...| 237 238 * length of varx: size saved int syncvarlist 238 239 * @param mem pointer to allocated memory with enough size … … 252 253 uint32_t tempsize = 0; 253 254 #ifndef NDEBUG 254 if (this->classID ==0)255 if (this->classID_==0) 255 256 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl; 256 257 #endif 257 258 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); 263 265 std::vector<SynchronisableVariableBase*>::iterator i; 264 266 … … 269 271 270 272 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; 272 274 // copy to location 273 275 for(i=syncList.begin(); i!=syncList.end(); ++i){ … … 277 279 278 280 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_ ); 282 284 header.setDataAvailable( true ); 283 285 header.setDataSize( tempsize ); … … 311 313 // start extract header 312 314 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_); 316 318 if(syncHeader.isDataAvailable()==false){ 317 319 mem += syncHeader.getDataSize(); … … 322 324 // stop extract header 323 325 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; 325 327 for(i=syncList.begin(); i!=syncList.end(); i++) 326 328 { … … 361 363 if(mode==0x0) 362 364 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 classIDmatch with the Synchronisables ones365 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 368 370 * @param mem pointer to the bytestream 369 371 */ … … 371 373 { 372 374 SynchronisableHeader header(mem); 373 assert(header.getObjectID()==this->objectID );375 assert(header.getObjectID()==this->objectID_); 374 376 return header.isDataAvailable(); 375 377 } … … 383 385 * @param mode same as in registerVar 384 386 */ 385 void Synchronisable::set ObjectMode(uint8_t mode){387 void Synchronisable::setSyncMode(uint8_t mode){ 386 388 assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3); 387 objectMode_=mode;389 this->objectMode_=mode; 388 390 } 389 391 -
code/branches/pickup/src/libraries/network/synchronisable/Synchronisable.h
r5781 r5935 68 68 * @brief: stores information about a Synchronisable 69 69 * 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) 71 71 * in an emulated bitset. 72 72 * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream 73 73 * 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_ 77 77 */ 78 78 class _NetworkExport SynchronisableHeader{ … … 94 94 inline uint32_t getObjectID() const 95 95 { 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_; } 98 98 inline uint32_t getClassID() const 99 99 { 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_; } 102 102 inline uint32_t getCreatorID() const 103 103 { 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_; } 106 106 inline void operator=(SynchronisableHeader& h) 107 107 { memcpy(data_, h.data_, getSize()); } … … 122 122 123 123 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_); 126 126 static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); } 127 127 static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; } 128 128 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); 133 136 134 137 protected: … … 136 139 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 137 140 //template <class T> void unregisterVariable(T& var); 138 void setObjectMode(uint8_t mode);139 141 void setPriority(unsigned int freq){ objectFrequency_ = freq; } 140 142 … … 146 148 bool isMyData(uint8_t* mem); 147 149 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_; 152 157 153 158 std::vector<SynchronisableVariableBase*> syncList; -
code/branches/pickup/src/libraries/tools/CMakeLists.txt
r5781 r5935 1 ADD_SOURCE_FILES(TOOLS_SRC_FILES 1 SET_SOURCE_FILES(TOOLS_SRC_FILES 2 COMPILATION_BEGIN ResourceCompilation.cc 3 ResourceCollection.cc 4 ResourceLocation.cc 5 COMPILATION_END 6 TextureGenerator.cc 7 Timer.cc 8 COMPILATION_BEGIN OgreCompilation.cc 2 9 BillboardSet.cc 3 10 DynamicLines.cc … … 5 12 Mesh.cc 6 13 ParticleInterface.cc 7 ResourceCollection.cc8 ResourceLocation.cc9 14 Shader.cc 10 TextureGenerator.cc 11 Timer.cc 15 COMPILATION_END 12 16 ) 13 17 ADD_SUBDIRECTORY(interfaces) … … 15 19 ORXONOX_ADD_LIBRARY(tools 16 20 FIND_HEADER_FILES 17 PCH_FILE18 ToolsPrecompiledHeaders.h19 21 DEFINE_SYMBOL 20 22 "TOOLS_SHARED_BUILD" -
code/branches/pickup/src/libraries/tools/ResourceLocation.cc
r5781 r5935 33 33 34 34 #include "util/Exception.h" 35 #include "core/Core.h"36 35 #include "core/CoreIncludes.h" 36 #include "core/PathConfig.h" 37 37 #include "core/XMLFile.h" 38 38 #include "core/XMLPort.h" … … 71 71 72 72 // 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(); 78 79 else 79 80 { -
code/branches/pickup/src/libraries/tools/Timer.cc
r5781 r5935 31 31 #include <set> 32 32 33 #include "util/Clock.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/ConsoleCommand.h" 35 36 #include "core/CommandExecutor.h" 36 #include "core/Clock.h"37 37 #include "core/Functor.h" 38 38 … … 42 42 SetConsoleCommandShortcutExtern(killdelays); 43 43 44 static std::set< StaticTimer*> delaytimerset;44 static std::set<Timer*> delaytimerset; 45 45 46 46 /** … … 51 51 void delay(float delay, const std::string& command) 52 52 { 53 StaticTimer *delaytimer = new StaticTimer();53 Timer* delaytimer = new Timer(); 54 54 delaytimerset.insert(delaytimer); 55 55 … … 64 64 @param command The command to execute 65 65 */ 66 void executeDelayedCommand( StaticTimer* timer, const std::string& command)66 void executeDelayedCommand(Timer* timer, const std::string& command) 67 67 { 68 68 CommandExecutor::execute(command); 69 delete timer;69 timer->destroy(); 70 70 delaytimerset.erase(timer); 71 71 } … … 76 76 void killdelays() 77 77 { 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(); 80 80 81 81 delaytimerset.clear(); … … 85 85 @brief Constructor: Sets the default-values. 86 86 */ 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() 88 119 { 89 120 this->executor_ = 0; … … 94 125 95 126 this->time_ = 0; 96 97 RegisterObject(TimerBase);98 }99 100 /**101 @brief Deletes the executor.102 */103 TimerBase::~TimerBase()104 {105 this->deleteExecutor();106 127 } 107 128 … … 109 130 @brief Executes the executor. 110 131 */ 111 void Timer Base::run() const132 void Timer::run() 112 133 { 113 134 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer … … 116 137 117 138 if (temp) 118 delete this;139 this->destroy(); 119 140 } 120 141 … … 122 143 @brief Deletes the executor. 123 144 */ 124 void Timer Base::deleteExecutor()145 void Timer::deleteExecutor() 125 146 { 126 147 if (this->executor_) … … 131 152 @brief Updates the timer before the frames are rendered. 132 153 */ 133 void Timer Base::tick(const Clock& time)154 void Timer::tick(const Clock& time) 134 155 { 135 156 if (this->bActive_) -
code/branches/pickup/src/libraries/tools/Timer.h
r5781 r5935 40 40 ClassName(); 41 41 void functionName(); 42 Timer <ClassName>myTimer;42 Timer myTimer; 43 43 }; 44 44 … … 48 48 ClassName::ClassName() 49 49 { 50 myTimer.setTimer(interval_in_seconds, bLoop, this, createExecutor(createFunctor(&ClassName::functionName)));50 myTimer.setTimer(interval_in_seconds, bLoop, createExecutor(createFunctor(&ClassName::functionName, this))); 51 51 } 52 52 … … 69 69 namespace orxonox 70 70 { 71 class StaticTimer;72 71 void delay(float delay, const std::string& command); 73 72 void killdelays(); 74 void executeDelayedCommand( StaticTimer* timer, const std::string& command);73 void executeDelayedCommand(Timer* timer, const std::string& command); 75 74 76 //! T imerBase is the parent of the Timer class.77 class _ToolsExport Timer Base: public TimeFactorListener75 //! The Timer is a callback-object, calling a given function after a given time-interval. 76 class _ToolsExport Timer : public TimeFactorListener 78 77 { 79 78 public: 80 ~TimerBase(); 79 Timer(); 80 ~Timer(); 81 81 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(); 83 105 void deleteExecutor(); 84 106 … … 116 138 void tick(const Clock& time); 117 139 118 pr otected:119 TimerBase();120 140 private: 141 void init(); 142 121 143 Executor* executor_; //!< The executor of the function that should be called when the time expires 122 144 … … 128 150 long long time_; //!< Internal variable, counting the time till the next function-call 129 151 }; 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 TimerBase134 {135 public:136 Timer() {}137 138 /**139 @brief Constructor: Initializes the Timer with given values.140 @param interval The timer-interval in seconds141 @param bLoop If true, the function gets called every 'interval' seconds142 @param object The object owning the timer and the function143 @param exeuctor A executor of the function to call144 */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 seconds153 @param bLoop If true, the function gets called every 'interval' seconds154 @param object The object owning the timer and the function155 @param exeuctor A executor of the function to call156 */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 TimerBase174 {175 public:176 StaticTimer() {}177 178 /**179 @brief Constructor: Initializes the Timer with given values.180 @param interval The timer-interval in seconds181 @param bLoop If true, the function gets called every 'interval' seconds182 @param exeuctor A executor of the function to call183 */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 seconds192 @param bLoop If true, the function gets called every 'interval' seconds193 @param object The object owning the timer and the function194 @param executor A executor of the function to call195 */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 210 152 } 211 153 -
code/branches/pickup/src/libraries/tools/ToolsPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 40 41 // Shared library settings 41 42 //----------------------------------------------------------------------- 43 42 44 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 43 45 # ifdef TOOLS_SHARED_BUILD … … 57 59 58 60 //----------------------------------------------------------------------- 59 // Forward declarations61 // Enums 60 62 //----------------------------------------------------------------------- 61 63 … … 72 74 }; 73 75 } 76 } 74 77 78 //----------------------------------------------------------------------- 79 // Forward declarations 80 //----------------------------------------------------------------------- 81 82 namespace orxonox 83 { 75 84 class BillboardSet; 76 85 class Mesh; 77 86 class ParticleInterface; 87 class ResourceCollection; 88 class ResourceLocation; 78 89 class Shader; 79 template <class T> 90 class Tickable; 91 class TimeFactorListener; 80 92 class Timer; 81 class StaticTimer;82 93 } 83 94 -
code/branches/pickup/src/libraries/util/CMakeLists.txt
r5781 r5935 19 19 20 20 SET_SOURCE_FILES(UTIL_SRC_FILES 21 Clipboard.cc22 CRC32.cc23 21 Exception.cc 24 ExprParser.cc25 22 Math.cc 26 23 MultiType.cc 24 Scope.cc 25 StringUtils.cc 26 COMPILATION_BEGIN StableCompilation.cc 27 Clipboard.cc 28 Clock.cc 29 CRC32.cc 30 ExprParser.cc 27 31 OutputBuffer.cc 28 32 OutputHandler.cc 29 Scope.cc30 33 SignalHandler.cc 31 34 Sleep.cc 32 StringUtils.cc33 35 SubString.cc 36 COMPILATION_END 34 37 ) 35 38 -
code/branches/pickup/src/libraries/util/Scope.h
r5738 r5935 31 31 32 32 #include "UtilPrereqs.h" 33 33 34 #include <cassert> 35 #include <map> 34 36 #include <set> 35 #include <map> 37 36 38 #include "Debug.h" 39 #include "ScopeGuard.h" 37 40 38 41 namespace orxonox 39 42 { 40 namespace ScopeID41 {42 /**43 @brief A list of available scopes for the Scope template.44 */45 enum Value46 {47 GSRoot,48 GSGraphics,49 GSLevel50 };51 }52 53 class ScopeListener; // Forward declaration54 55 43 /** 56 44 @brief The ScopeManager stores the variables of the scope templates in a statically linked context. … … 77 65 protected: 78 66 //! Constructor: Registers the instance. 79 ScopeListener(ScopeID::Value scope) : scope_(scope) 67 ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false) 80 68 { ScopeManager::listeners_s[this->scope_].insert(this); } 81 69 //! Destructor: Unregisters the instance. … … 90 78 private: 91 79 ScopeID::Value scope_; //!< Store the scope to unregister on destruction 80 bool bActivated_; 92 81 }; 93 82 … … 105 94 Scope() 106 95 { 107 ScopeManager::instanceCounts_s[scope]++; 108 assert(ScopeManager::instanceCounts_s[scope] > 0); 109 if (ScopeManager::instanceCounts_s[scope] == 1) 96 try 110 97 { 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; 113 115 } 114 116 } … … 125 127 126 128 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(); ) 127 135 { 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; 130 146 } 131 147 } -
code/branches/pickup/src/libraries/util/Singleton.h
r5738 r5935 55 55 } 56 56 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 57 62 protected: 58 63 //! Constructor sets the singleton instance pointer -
code/branches/pickup/src/libraries/util/UtilPrereqs.h
r5738 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 40 41 // Shared library settings 41 42 //----------------------------------------------------------------------- 43 42 44 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( UTIL_STATIC_BUILD ) 43 45 # ifdef UTIL_SHARED_BUILD … … 56 58 #endif 57 59 60 //----------------------------------------------------------------------- 61 // Enums 62 //----------------------------------------------------------------------- 63 64 namespace 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 } 58 76 59 77 //----------------------------------------------------------------------- … … 63 81 namespace orxonox 64 82 { 83 class Clock; 65 84 class Exception; 66 85 class ExprParser; … … 71 90 class OutputBufferListener; 72 91 class OutputHandler; 92 template <ScopeID::Value> 93 class Scope; 94 template <class, ScopeID::Value> 95 class ScopedSingleton; 96 class ScopeListener; 73 97 class SignalHandler; 98 template <class T> 99 class Singleton; 74 100 class SubString; 75 101 } -
code/branches/pickup/src/modules/CMakeLists.txt
r5781 r5935 27 27 ################ Sub Directories ################ 28 28 29 ADD_SUBDIRECTORY(gamestates)30 29 ADD_SUBDIRECTORY(objects) 31 30 ADD_SUBDIRECTORY(overlays) -
code/branches/pickup/src/modules/objects/Attacher.cc
r5781 r5935 53 53 void Attacher::processEvent(Event& event) 54 54 { 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); 57 57 } 58 58 … … 102 102 103 103 for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it) 104 { 104 105 if (it->getName() == this->targetname_) 106 { 107 this->target_ = *it; 105 108 this->attachToParent(*it); 109 } 110 } 106 111 } 107 112 -
code/branches/pickup/src/modules/objects/ObjectsPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "OrxonoxPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef OBJECTS_SHARED_BUILD … … 76 77 77 78 // eventsystem 79 class EventDispatcher; 80 class EventFilter; 78 81 class EventListener; 79 class Event Dispatcher;82 class EventName; 80 83 class EventTarget; 81 84 82 85 // triggers 83 class Trigger;86 class CheckPoint; 84 87 class DistanceTrigger; 85 88 class EventTrigger; 86 class CheckPoint;89 class Trigger; 87 90 } 88 91 -
code/branches/pickup/src/modules/objects/Planet.cc
r5781 r5935 47 47 * @brief Constructor 48 48 */ 49 Planet::Planet(BaseObject* creator) : MovableEntity(creator)49 Planet::Planet(BaseObject* creator) : MovableEntity(creator) 50 50 { 51 51 RegisterObject(Planet); … … 64 64 void Planet::tick(float dt) 65 65 { 66 if (!this->isVisible())66 if (!this->isVisible()) 67 67 return; 68 68 … … 70 70 { 71 71 Camera* activeCamera = CameraManager::getInstance().getActiveCamera(); 72 if (activeCamera)72 if (activeCamera) 73 73 { 74 74 float distance = this->getPosition().distance( activeCamera->getWorldPosition() ); -
code/branches/pickup/src/modules/objects/eventsystem/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(OBJECTS_SRC_FILES 2 2 EventDispatcher.cc 3 EventFilter.cc 3 4 EventListener.cc 5 EventName.cc 4 6 EventTarget.cc 5 7 ) -
code/branches/pickup/src/modules/objects/eventsystem/EventDispatcher.cc
r5781 r5935 32 32 #include "core/EventIncludes.h" 33 33 #include "core/XMLPort.h" 34 #include "EventTarget.h"35 34 36 35 namespace orxonox … … 46 45 { 47 46 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(); 50 49 } 51 50 … … 54 53 SUPER(EventDispatcher, XMLPort, xmlelement, mode); 55 54 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)); 57 59 } 58 60 59 61 void EventDispatcher::processEvent(Event& event) 60 62 { 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); 63 65 } 64 66 65 void EventDispatcher::addTarget( EventTarget* target)67 void EventDispatcher::addTarget(BaseObject* target) 66 68 { 67 69 this->targets_.push_back(target); 68 70 } 69 71 70 EventTarget* EventDispatcher::getTarget(unsigned int index) const72 BaseObject* EventDispatcher::getTarget(unsigned int index) const 71 73 { 72 74 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) 74 76 { 75 77 if (i == index) -
code/branches/pickup/src/modules/objects/eventsystem/EventDispatcher.h
r5781 r5935 47 47 virtual void processEvent(Event& event); 48 48 49 void addTarget( EventTarget* target);50 EventTarget* getTarget(unsigned int index) const;49 void addTarget(BaseObject* target); 50 BaseObject* getTarget(unsigned int index) const; 51 51 52 52 private: 53 std::list< EventTarget*> targets_;53 std::list<BaseObject*> targets_; 54 54 }; 55 55 } -
code/branches/pickup/src/modules/objects/eventsystem/EventListener.cc
r5781 r5935 63 63 64 64 this->bActive_ = true; 65 66 this->fireEvent(event.activate_, event.originator_); 67 65 this->fireEvent(event.activate_, event.originator_, event.name_); 68 66 this->bActive_ = false; 69 67 } … … 78 76 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 79 77 if (it->getName() == this->eventName_) 80 this-> registerAsListener(*it);78 this->addEventSource(*it, ""); 81 79 } 82 80 … … 87 85 88 86 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, ""); 95 88 } 96 89 } -
code/branches/pickup/src/modules/objects/eventsystem/EventListener.h
r5781 r5935 54 54 private: 55 55 virtual void loadedNewXMLName(BaseObject* object); 56 void registerAsListener(BaseObject* object);57 56 58 57 std::string eventName_; -
code/branches/pickup/src/modules/objects/eventsystem/EventTarget.cc
r5781 r5935 29 29 #include "EventTarget.h" 30 30 #include "core/CoreIncludes.h" 31 #include "core/XMLPort.h" 31 32 32 33 namespace orxonox … … 37 38 { 38 39 RegisterObject(EventTarget); 40 41 this->bActive_ = false; 39 42 } 40 43 … … 42 45 { 43 46 } 47 48 void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 { 50 SUPER(EventTarget, XMLPort, xmlelement, mode); 44 51 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) 46 59 { 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 } 48 65 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 49 75 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 50 if (it->getName() == this-> getName())51 this->add AsEvent(*it);76 if (it->getName() == this->target_) 77 this->addEventTarget(*it); 52 78 } 53 79 54 80 void EventTarget::loadedNewXMLName(BaseObject* object) 55 81 { 56 if (this-> getName()== "")82 if (this->target_ == "") 57 83 return; 58 84 59 if (object->getName() == this-> getName())60 this->add AsEvent(object);85 if (object->getName() == this->target_) 86 this->addEventTarget(object); 61 87 } 62 88 63 void EventTarget::add AsEvent(BaseObject* object)89 void EventTarget::addEventTarget(BaseObject* object) 64 90 { 65 91 if (object != static_cast<BaseObject*>(this)) 66 object->addEvent (this, "");92 object->addEventSource(this, ""); 67 93 } 68 94 } -
code/branches/pickup/src/modules/objects/eventsystem/EventTarget.h
r5781 r5935 42 42 EventTarget(BaseObject* creator); 43 43 virtual ~EventTarget(); 44 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 47 virtual void processEvent(Event& event); 44 48 45 virtual void changedName(); 49 void setTargetName(const std::string& name); 50 inline const std::string& getTargetName() const 51 { return this->target_; } 46 52 47 53 private: 48 54 virtual void loadedNewXMLName(BaseObject* object); 49 void addAsEvent(BaseObject* object); 55 void addEventTarget(BaseObject* object); 56 57 std::string target_; 58 bool bActive_; 50 59 }; 51 60 } -
code/branches/pickup/src/modules/objects/triggers/CheckPoint.cc
r5781 r5935 85 85 DistanceTrigger::triggered(bIsTriggered); 86 86 87 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype() );87 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get()); 88 88 if (gametype) 89 89 { -
code/branches/pickup/src/modules/objects/triggers/EventTrigger.cc
r5781 r5935 47 47 } 48 48 49 void EventTrigger:: processEvent(Event& event)49 void EventTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 50 50 { 51 SUPER(EventTrigger, processEvent, event);51 SUPER(EventTrigger, XMLEventPort, xmlelement, mode); 52 52 53 ORXONOX_SET_EVENT(EventTrigger, "trigger", trigger, event);53 XMLPortEventState(EventTrigger, BaseObject, "trigger", trigger, xmlelement, mode); 54 54 } 55 55 -
code/branches/pickup/src/modules/objects/triggers/EventTrigger.h
r5781 r5935 41 41 virtual ~EventTrigger(); 42 42 43 virtual void processEvent(Event& event);43 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 44 44 45 45 inline void trigger(bool bTriggered) -
code/branches/pickup/src/modules/objects/triggers/Trigger.cc
r5781 r5935 72 72 } 73 73 74 this->set ObjectMode(0x0);74 this->setSyncMode(0x0); 75 75 } 76 76 -
code/branches/pickup/src/modules/overlays/FadeoutText.cc
r5781 r5935 46 46 47 47 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))); 49 49 this->fadeouttimer_.stopTimer(); 50 50 -
code/branches/pickup/src/modules/overlays/FadeoutText.h
r5781 r5935 68 68 69 69 bool bFadingOut_; 70 Timer <FadeoutText>fadeouttimer_;70 Timer fadeouttimer_; 71 71 72 72 float initialAlpha_; -
code/branches/pickup/src/modules/overlays/OverlaysPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 39 #include "OrxonoxPrereqs.h" 38 40 39 41 //----------------------------------------------------------------------- 40 42 // Shared library settings 41 43 //----------------------------------------------------------------------- 44 42 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 43 46 # ifdef OVERLAYS_SHARED_BUILD … … 62 65 namespace orxonox 63 66 { 64 class BarColour; 67 class FadeoutText; 68 class GUIOverlay; 69 class OverlayText; 70 71 // debugging 65 72 class DebugFPSText; 66 73 class DebugRTRText; 67 class GUIOverlay; 74 75 // hud 76 class AnnounceMessage; 77 class BarColour; 78 class ChatOverlay; 79 class DeathMessage; 80 class GametypeStatus; 68 81 class HUDBar; 82 class HUDHealthBar; 69 83 class HUDNavigation; 70 84 class HUDRadar; 71 85 class HUDSpeedBar; 72 class HUDHealthBar;73 86 class HUDTimer; 74 class OrxonoxOverlay;75 class OverlayGroup;76 class OverlayText;77 class FadeoutText;78 class GametypeStatus;79 class AnnounceMessage;80 87 class KillMessage; 81 class DeathMessage; 88 class TeamBaseMatchScore; 89 class UnderAttackHealthBar; 82 90 91 // stats 83 92 class CreateLines; 84 93 class Scoreboard; -
code/branches/pickup/src/modules/overlays/hud/ChatOverlay.cc
r5781 r5935 58 58 ChatOverlay::~ChatOverlay() 59 59 { 60 for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it) 61 delete (*it); 60 62 } 61 63 … … 87 89 COUT(0) << "Chat: " << text << std::endl; 88 90 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); 90 96 91 97 this->updateOverlayText(); 92 98 } 93 99 94 void ChatOverlay::dropMessage( )100 void ChatOverlay::dropMessage(Timer* timer) 95 101 { 96 102 if (this->messages_.size() > 0) 97 103 this->messages_.pop_front(); 98 104 this->updateOverlayText(); 105 this->timers_.erase(timer); // the timer destroys itself, but we have to remove it from the set 99 106 } 100 107 -
code/branches/pickup/src/modules/overlays/hud/ChatOverlay.h
r5781 r5935 55 55 private: 56 56 void updateOverlayText(); 57 void dropMessage( );57 void dropMessage(Timer* timer); 58 58 59 59 float displayTime_; 60 std::set<Timer*> timers_; 60 61 }; 61 62 } -
code/branches/pickup/src/modules/overlays/hud/HUDBar.cc
r5781 r5935 96 96 { 97 97 if (this->isInitialized()) 98 { 98 99 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 } 99 103 } 100 104 -
code/branches/pickup/src/modules/overlays/hud/HUDHealthBar.cc
r5781 r5935 56 56 { 57 57 if (this->isInitialized()) 58 delete this->textoverlay_;58 this->textoverlay_->destroy(); 59 59 } 60 60 … … 84 84 this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth()); 85 85 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"); 86 91 } 87 92 -
code/branches/pickup/src/modules/overlays/hud/HUDHealthBar.h
r5781 r5935 111 111 112 112 private: 113 Pawn*owner_;113 WeakPtr<Pawn> owner_; 114 114 OverlayText* textoverlay_; 115 115 bool bUseBarColour_; -
code/branches/pickup/src/modules/overlays/hud/HUDNavigation.cc
r5781 r5935 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/XMLPort.h" 41 #include "Scene.h" 41 42 #include "Radar.h" 42 43 … … 130 131 SUPER(HUDNavigation, tick, dt); 131 132 132 if (!Radar::getInstance().getFocus()) 133 // Get radar 134 Radar* radar = this->getOwner()->getScene()->getRadar(); 135 136 if (!radar->getFocus()) 133 137 { 134 138 this->overlay_->hide(); … … 150 154 */ 151 155 // transform to screen coordinates 152 Vector3 pos = /*transformationMatrix * */ Radar::getInstance().getFocus()->getRVWorldPosition();156 Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition(); 153 157 154 158 bool outOfView; -
code/branches/pickup/src/modules/overlays/hud/TeamBaseMatchScore.cc
r5781 r5935 118 118 119 119 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()); 121 121 else 122 122 this->owner_ = 0; -
code/branches/pickup/src/modules/overlays/hud/UnderAttackHealthBar.cc
r5781 r5935 52 52 this->text_->setPickPoint(Vector2(0.5, 0)); 53 53 54 this->inittimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&UnderAttackHealthBar::init)));54 this->inittimer_.setTimer(0.0f, false, createExecutor(createFunctor(&UnderAttackHealthBar::init, this))); 55 55 } 56 56 … … 58 58 { 59 59 if (this->isInitialized()) 60 delete this->text_;60 this->text_->destroy(); 61 61 } 62 62 … … 78 78 this->owner_ = player; 79 79 80 UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype() );80 UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get()); 81 81 if (ua) 82 82 { -
code/branches/pickup/src/modules/overlays/hud/UnderAttackHealthBar.h
r5781 r5935 62 62 PlayerInfo* owner_; 63 63 OverlayText* text_; 64 Timer <UnderAttackHealthBar>inittimer_;64 Timer inittimer_; 65 65 }; 66 66 } -
code/branches/pickup/src/modules/overlays/stats/CreateLines.cc
r5781 r5935 59 59 CreateLines::~CreateLines() 60 60 { 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(); 65 65 } 66 66 -
code/branches/pickup/src/modules/overlays/stats/Scoreboard.cc
r5781 r5935 44 44 { 45 45 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 } 46 56 } 47 57 -
code/branches/pickup/src/modules/overlays/stats/Scoreboard.h
r5781 r5935 42 42 public: // functions 43 43 Scoreboard(BaseObject* creator); 44 virtual ~Scoreboard() {}44 virtual ~Scoreboard(); 45 45 46 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); -
code/branches/pickup/src/modules/pong/CMakeLists.txt
r5781 r5935 1 1 SET_SOURCE_FILES(PONG_SRC_FILES 2 COMPILATION_BEGIN PongCompilation.cc 2 3 Pong.cc 3 4 PongAI.cc … … 7 8 PongCenterpoint.cc 8 9 PongScore.cc 10 COMPILATION_END 9 11 ) 10 12 … … 12 14 MODULE 13 15 FIND_HEADER_FILES 14 PCH_FILE15 PongPrecompiledHeaders.h16 PCH_NO_DEFAULT17 16 DEFINE_SYMBOL 18 17 "PONG_SHARED_BUILD" -
code/branches/pickup/src/modules/pong/Pong.cc
r5781 r5935 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "core/EventIncludes.h" 32 33 #include "core/Executor.h" 33 34 #include "PongCenterpoint.h" … … 39 40 namespace orxonox 40 41 { 42 CreateEventName(PongCenterpoint, right); 43 CreateEventName(PongCenterpoint, left); 44 41 45 CreateUnloadableFactory(Pong); 42 46 … … 52 56 this->setHUDTemplate("PongHUD"); 53 57 54 this->starttimer_.setTimer(1.0, false, this, createExecutor(createFunctor(&Pong::startBall)));58 this->starttimer_.setTimer(1.0, false, createExecutor(createFunctor(&Pong::startBall, this))); 55 59 this->starttimer_.stopTimer(); 56 60 … … 72 76 this->ball_->setFieldDimension(this->center_->getFieldDimension()); 73 77 this->ball_->setSpeed(0); 78 this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor()); 74 79 this->ball_->setBatLength(this->center_->getBatLength()); 75 80 … … 120 125 if (this->ball_) 121 126 { 122 delete this->ball_;127 this->ball_->destroy(); 123 128 this->ball_ = 0; 124 129 } … … 155 160 if (this->center_) 156 161 { 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 159 167 if (player) 160 this->gtinfo_ .sendAnnounceMessage(player->getName() + " scored");168 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored"); 161 169 } 162 170 … … 165 173 this->ball_->setPosition(Vector3::ZERO); 166 174 this->ball_->setVelocity(Vector3::ZERO); 175 this->ball_->setAcceleration(Vector3::ZERO); 167 176 this->ball_->setSpeed(0); 168 177 } -
code/branches/pickup/src/modules/pong/Pong.h
r5781 r5935 62 62 PongBall* ball_; 63 63 PongBat* bat_[2]; 64 Timer <Pong>starttimer_;64 Timer starttimer_; 65 65 }; 66 66 } -
code/branches/pickup/src/modules/pong/PongAI.cc
r5781 r5935 49 49 this->ballEndPosition_ = 0; 50 50 this->randomOffset_ = 0; 51 this->bChangedRandomOffset_ = false; 51 52 this->relHysteresisOffset_ = 0.02f; 52 53 this->strength_ = 0.5f; … … 60 61 PongAI::~PongAI() 61 62 { 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(); 64 65 } 65 66 … … 113 114 this->ballEndPosition_ = 0; 114 115 this->randomOffset_ = 0; 116 this->bChangedRandomOffset_ = false; 115 117 116 118 this->calculateRandomOffset(); … … 129 131 this->bOscillationAvoidanceActive_ = false; 130 132 } 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 } 131 145 132 146 // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat) … … 184 198 Vector3 position = this->ball_->getPosition(); 185 199 Vector3 velocity = this->ball_->getVelocity(); 200 Vector3 acceleration = this->ball_->getAcceleration(); 186 201 Vector2 dimension = this->ball_->getFieldDimension(); 187 202 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 } 213 294 } 214 295 } … … 231 312 232 313 // 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)); 235 316 } 236 317 else … … 246 327 247 328 // 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(); 250 331 251 332 this->reactionTimers_.pop_front(); -
code/branches/pickup/src/modules/pong/PongAI.h
r5781 r5935 62 62 float ballEndPosition_; 63 63 float randomOffset_; 64 bool bChangedRandomOffset_; 64 65 float relHysteresisOffset_; 65 66 float strength_; 66 67 67 std::list<std::pair<Timer <PongAI>*, char> > reactionTimers_;68 std::list<std::pair<Timer*, char> > reactionTimers_; 68 69 char movement_; 69 70 char oldMove_; -
code/branches/pickup/src/modules/pong/PongBall.cc
r5781 r5935 33 33 #include "gametypes/Gametype.h" 34 34 #include "PongBat.h" 35 #include "sound/SoundBase.h"36 35 37 36 namespace orxonox … … 41 40 const float PongBall::MAX_REL_Z_VELOCITY = 1.5; 42 41 43 PongBall::PongBall(BaseObject* creator) : MovableEntity(creator) 42 PongBall::PongBall(BaseObject* creator) 43 : MovableEntity(creator) 44 44 { 45 45 RegisterObject(PongBall); 46 46 47 47 this->speed_ = 0; 48 this->accelerationFactor_ = 1.0f; 48 49 this->bat_ = 0; 49 50 this->batID_ = new unsigned int[2]; … … 53 54 54 55 this->registerVariables(); 56 } 55 57 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 { 64 60 } 65 61 … … 79 75 SUPER(PongBall, tick, dt); 80 76 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) 82 82 { 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; 85 88 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_) 87 97 { 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]) 102 99 { 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) 104 102 { 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]) 107 113 { 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; 121 116 } 122 117 } 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) 124 123 { 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]) 127 134 { 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; 141 137 } 142 138 } 143 139 } 144 140 } 141 } 145 142 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()) 199 146 this->setVelocity(velocity); 200 147 if (position != this->getPosition()) 201 148 this->setPosition(position); 202 }203 149 } 204 150 -
code/branches/pickup/src/modules/pong/PongBall.h
r5781 r5935 41 41 public: 42 42 PongBall(BaseObject* creator); 43 virtual ~PongBall() {}43 virtual ~PongBall(); 44 44 45 45 virtual void tick(float dt); … … 58 58 { return this->speed_; } 59 59 60 void setAccelerationFactor(float factor) 61 { this->accelerationFactor_ = factor; } 62 float getAccelerationFactor() const 63 { return this->accelerationFactor_; } 64 60 65 void setBatLength(float batlength) 61 66 { this->batlength_ = batlength; } … … 72 77 float fieldHeight_; 73 78 float speed_; 79 float accelerationFactor_; 74 80 float batlength_; 75 81 PongBat** bat_; 76 82 unsigned int* batID_; 77 83 float relMercyOffset_; 78 79 SoundBase* sidesound_;80 SoundBase* batsound_;81 SoundBase* scoresound_;82 84 }; 83 85 } -
code/branches/pickup/src/modules/pong/PongCenterpoint.cc
r5781 r5935 44 44 this->height_ = 120; 45 45 this->ballspeed_ = 100; 46 this->ballaccfactor_ = 1.0; 46 47 this->batspeed_ = 60; 47 48 this->batlength_ = 0.25; … … 58 59 XMLPortParam(PongCenterpoint, "battemplate", setBattemplate, getBattemplate, xmlelement, mode); 59 60 XMLPortParam(PongCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode); 61 XMLPortParam(PongCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode); 60 62 XMLPortParam(PongCenterpoint, "batspeed", setBatSpeed, getBatSpeed, xmlelement, mode); 61 63 XMLPortParam(PongCenterpoint, "batlength", setBatLength, getBatLength, xmlelement, mode); … … 73 75 if (this->getGametype() && this->getGametype()->isA(Class(Pong))) 74 76 { 75 Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype() );77 Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype().get()); 76 78 pong_gametype->setCenterpoint(this); 77 79 } -
code/branches/pickup/src/modules/pong/PongCenterpoint.h
r5781 r5935 68 68 { return this->ballspeed_; } 69 69 70 void setBallAccelerationFactor(float ballaccfactor) 71 { this->ballaccfactor_ = ballaccfactor; } 72 float getBallAccelerationFactor() const 73 { return this->ballaccfactor_; } 74 70 75 void setBatSpeed(float batspeed) 71 76 { this->batspeed_ = batspeed; } … … 85 90 86 91 float ballspeed_; 92 float ballaccfactor_; 87 93 float batspeed_; 88 94 float batlength_; -
code/branches/pickup/src/modules/pong/PongPrereqs.h
r5794 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 39 #include "OrxonoxPrereqs.h" 38 40 39 41 //----------------------------------------------------------------------- 40 42 // Shared library settings 41 43 //----------------------------------------------------------------------- 44 42 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 43 46 # ifdef PONG_SHARED_BUILD -
code/branches/pickup/src/modules/pong/PongScore.cc
r5781 r5935 133 133 134 134 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()); 136 136 else 137 137 this->owner_ = 0; -
code/branches/pickup/src/modules/questsystem/QuestEffectBeacon.cc
r5781 r5935 75 75 XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode); 76 76 77 XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode); 78 77 79 COUT(3) << "New QuestEffectBeacon created." << std::endl; 78 80 } 79 81 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); 89 87 } 90 88 -
code/branches/pickup/src/modules/questsystem/QuestEffectBeacon.h
r5781 r5935 86 86 87 87 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); 90 89 91 90 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. -
code/branches/pickup/src/modules/questsystem/QuestGUI.cc
r5781 r5935 79 79 80 80 if(this->root_ != NULL) 81 delete this->root_;81 this->root_->destroy(); 82 82 } 83 83 … … 146 146 COUT(3) << "Clearing Node '" << *str << "' ..." << std::endl; 147 147 delete str; 148 delete node;148 node->destroy(); 149 149 } 150 150 this->nodes_.clear(); -
code/branches/pickup/src/modules/questsystem/QuestManager.cc
r5781 r5935 41 41 #include "core/ConsoleCommand.h" 42 42 #include "core/LuaState.h" 43 #include "core/ScopedSingletonManager.h" 43 44 #include "infos/PlayerInfo.h" 44 45 #include "overlays/GUIOverlay.h" … … 56 57 //! Pointer to the current (and single) instance of this class. 57 58 /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL; 59 ManageScopedSingleton(QuestManager, ScopeID::Root, false); 58 60 59 61 /** … … 76 78 for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++) 77 79 { 78 delete (*it).second;80 (*it).second->destroy(); 79 81 } 80 82 this->questGUIs_.clear(); -
code/branches/pickup/src/modules/questsystem/QuestManager.h
r5781 r5935 42 42 #include <string> 43 43 44 #include "util/S copedSingleton.h"44 #include "util/Singleton.h" 45 45 #include "core/OrxonoxClass.h" 46 46 … … 50 50 namespace orxonox 51 51 { 52 53 typedef ScopedSingleton<QuestManager, ScopeID::GSLevel> ScopedSingletonQuestManagerGSLevel; // workaround for tolua54 55 52 /** 56 53 @brief … … 60 57 Damian 'Mozork' Frick 61 58 */ 62 class _QuestsystemExport QuestManager : public ScopedSingletonQuestManagerGSLevel, public orxonox::OrxonoxClass 63 { 59 class _QuestsystemExport QuestManager 64 60 // tolua_end 61 : public Singleton<QuestManager>, public orxonox::OrxonoxClass 62 { // tolua_export 65 63 66 friend class S copedSingleton<QuestManager, ScopeID::GSLevel>;64 friend class Singleton<QuestManager>; 67 65 friend class QuestGUI; 68 66 … … 72 70 73 71 //! Returns a reference to the single instance of the Quest Manager. 74 static QuestManager& getInstance() { return S copedSingleton<QuestManager, ScopeID::GSLevel>::getInstance(); } // tolua_export72 static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export 75 73 76 74 //! Retreive the main window for the GUI. -
code/branches/pickup/src/modules/questsystem/QuestsystemPrecompiledHeaders.h
r5781 r5935 51 51 #include <OgreColourValue.h> // 16 52 52 53 #include <tinyxml/ticpp.h> 54 #include "util/S copedSingleton.h"// 1353 #include <tinyxml/ticpp.h> // 14 54 #include "util/Singleton.h" // 13 55 55 56 56 /////////////////////////////////////////// -
code/branches/pickup/src/modules/questsystem/QuestsystemPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "OrxonoxPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef QUESTSYSTEM_SHARED_BUILD … … 76 77 class QuestEffect; 77 78 class QuestEffectBeacon; 79 class QuestGUI; 78 80 class QuestGUINode; 79 class QuestGUI;80 81 class QuestHint; 81 82 class QuestItem; … … 83 84 class QuestManager; 84 85 class QuestNotification; 85 class Rewardable;86 86 87 // notifications 87 88 class Notification; 88 class NotificationListener;89 89 class NotificationManager; 90 90 class NotificationOverlay; -
code/branches/pickup/src/modules/questsystem/notifications/NotificationManager.cc
r5781 r5935 37 37 38 38 #include "core/CoreIncludes.h" 39 #include "core/ScopedSingletonManager.h" 39 40 #include "Notification.h" 40 41 #include "interfaces/NotificationListener.h" … … 47 48 48 49 NotificationManager* NotificationManager::singletonPtr_s = NULL; 50 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 49 51 50 52 /** -
code/branches/pickup/src/modules/questsystem/notifications/NotificationManager.h
r5781 r5935 41 41 #include <string> 42 42 43 #include "util/S copedSingleton.h"43 #include "util/Singleton.h" 44 44 #include "core/OrxonoxClass.h" 45 45 46 46 namespace orxonox 47 47 { 48 49 48 /** 50 49 @brief … … 54 53 Damian 'Mozork' Frick 55 54 */ 56 class _QuestsystemExport NotificationManager : public S copedSingleton<NotificationManager, ScopeID::GSLevel>, public OrxonoxClass55 class _QuestsystemExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass 57 56 { 58 friend class S copedSingleton<NotificationManager, ScopeID::GSLevel>;57 friend class Singleton<NotificationManager>; 59 58 public: 60 59 NotificationManager(); -
code/branches/pickup/src/modules/questsystem/notifications/NotificationQueue.cc
r5781 r5935 426 426 this->containers_.erase(container); 427 427 this->overlays_.erase(container->notification); 428 delete container->overlay;428 container->overlay->destroy(); 429 429 delete container; 430 430 this->size_= this->size_-1; -
code/branches/pickup/src/modules/weapons/MuzzleFlash.cc
r5781 r5935 41 41 RegisterObject(MuzzleFlash); 42 42 this->setScale(0.1f); 43 44 this->delayTimer_.setTimer(0.1f, false, this, createExecutor(createFunctor(&MuzzleFlash::destroy)));45 43 44 this->delayTimer_.setTimer(0.1f, false, createExecutor(createFunctor(&MuzzleFlash::destroy, this))); 46 45 } 47 48 void MuzzleFlash::destroy()49 {50 delete this;51 }52 53 46 } -
code/branches/pickup/src/modules/weapons/MuzzleFlash.h
r5781 r5935 43 43 virtual ~MuzzleFlash() {} 44 44 45 46 47 45 private: 48 void destroy(); 49 Timer<MuzzleFlash> delayTimer_; 50 46 Timer delayTimer_; 51 47 }; 52 48 } -
code/branches/pickup/src/modules/weapons/WeaponsPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "OrxonoxPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef WEAPONS_SHARED_BUILD … … 64 65 namespace orxonox 65 66 { 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; 67 82 class FusionFire; 68 83 class HsW01; 84 class LaserFire; 69 85 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;82 86 } 83 87 -
code/branches/pickup/src/modules/weapons/munitions/ReplenishingMunition.cc
r5781 r5935 44 44 // replenishIntervall_ and replenishMunitionAmount_ will be set in the constructor of the 45 45 // 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))); 47 47 } 48 48 … … 50 50 { 51 51 // 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))); 53 53 } 54 54 -
code/branches/pickup/src/modules/weapons/munitions/ReplenishingMunition.h
r5781 r5935 51 51 void initializeTimer(); 52 52 53 Timer <ReplenishingMunition>replenishingTimer_;53 Timer replenishingTimer_; 54 54 }; 55 55 } -
code/branches/pickup/src/modules/weapons/projectiles/LightningGunProjectile.cc
r5781 r5935 42 42 this->textureIndex_ = 1; 43 43 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))); 45 45 46 46 registerVariables(); -
code/branches/pickup/src/modules/weapons/projectiles/LightningGunProjectile.h
r5781 r5935 50 50 unsigned int textureIndex_; 51 51 unsigned int maxTextureIndex_; 52 Timer <LightningGunProjectile>textureTimer_;52 Timer textureTimer_; 53 53 std::string materialBase_; 54 54 private: -
code/branches/pickup/src/modules/weapons/projectiles/ParticleProjectile.cc
r5781 r5935 59 59 { 60 60 this->detachOgreObject(this->particles_->getParticleSystem()); 61 delete this->particles_;61 this->particles_->destroy(); 62 62 } 63 63 } -
code/branches/pickup/src/modules/weapons/projectiles/Projectile.cc
r5781 r5935 61 61 this->attachCollisionShape(shape); 62 62 63 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));63 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Projectile::destroyObject, this))); 64 64 } 65 65 } … … 84 84 85 85 if (this->bDestroy_) 86 delete this;86 this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick() 87 87 } 88 88 … … 90 90 { 91 91 if (GameMode::isMaster()) 92 delete this;92 this->destroy(); 93 93 } 94 94 … … 133 133 } 134 134 135 void Projectile:: destroyedPawn(Pawn* pawn)135 void Projectile::setOwner(Pawn* owner) 136 136 { 137 if (this->owner_ == pawn) 138 this->owner_ = 0; 137 this->owner_ = owner; 139 138 } 140 139 } -
code/branches/pickup/src/modules/weapons/projectiles/Projectile.h
r5781 r5935 33 33 34 34 #include "tools/Timer.h" 35 #include "interfaces/PawnListener.h"36 35 #include "worldentities/MovableEntity.h" 37 36 38 37 namespace orxonox 39 38 { 40 class _WeaponsExport Projectile : public MovableEntity , public PawnListener39 class _WeaponsExport Projectile : public MovableEntity 41 40 { 42 41 public: … … 49 48 virtual void tick(float dt); 50 49 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 51 virtual void destroyedPawn(Pawn* pawn);52 50 53 51 inline void setDamage(float damage) … … 56 54 { return this->damage_; } 57 55 58 inline void setOwner(Pawn* owner) 59 { this->owner_ = owner; } 56 void setOwner(Pawn* owner); 60 57 inline Pawn* getOwner() const 61 58 { return this->owner_; } 62 59 63 60 private: 64 Pawn*owner_;61 WeakPtr<Pawn> owner_; 65 62 float lifetime_; 66 63 float damage_; 67 64 bool bDestroy_; 68 Timer <Projectile>destroyTimer_;65 Timer destroyTimer_; 69 66 }; 70 67 } -
code/branches/pickup/src/modules/weapons/weaponmodes/EnergyDrink.cc
r5781 r5935 54 54 this->setMunitionName("FusionMunition"); 55 55 56 this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&EnergyDrink::shot)));56 this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this))); 57 57 this->delayTimer_.stopTimer(); 58 58 } -
code/branches/pickup/src/modules/weapons/weaponmodes/EnergyDrink.h
r5781 r5935 59 59 float speed_; 60 60 float delay_; 61 Timer <EnergyDrink>delayTimer_;61 Timer delayTimer_; 62 62 }; 63 63 } -
code/branches/pickup/src/modules/weapons/weaponmodes/HsW01.cc
r5781 r5935 54 54 this->setMunitionName("LaserMunition"); 55 55 56 this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&HsW01::shot)));56 this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this))); 57 57 this->delayTimer_.stopTimer(); 58 58 } -
code/branches/pickup/src/modules/weapons/weaponmodes/HsW01.h
r5781 r5935 57 57 float speed_; 58 58 float delay_; 59 Timer <HsW01>delayTimer_;59 Timer delayTimer_; 60 60 }; 61 61 } -
code/branches/pickup/src/orxonox/CMakeLists.txt
r5781 r5935 25 25 26 26 SET_SOURCE_FILES(ORXONOX_SRC_FILES 27 Level.cc 28 LevelManager.cc 27 29 Main.cc 28 29 CameraManager.cc30 LevelManager.cc31 30 PawnManager.cc 32 31 PlayerManager.cc 33 34 Level.cc35 32 Radar.cc 33 COMPILATION_BEGIN SceneCompilation.cc 34 CameraManager.cc 36 35 Scene.cc 36 COMPILATION_END 37 37 ) 38 38 39 39 ADD_SUBDIRECTORY(collisionshapes) 40 40 ADD_SUBDIRECTORY(controllers) 41 ADD_SUBDIRECTORY(gamestates) 41 42 ADD_SUBDIRECTORY(gametypes) 42 43 ADD_SUBDIRECTORY(graphics) -
code/branches/pickup/src/orxonox/CameraManager.cc
r5781 r5935 26 26 * 27 27 */ 28 28 29 #include "CameraManager.h" 29 30 … … 34 35 #include "util/StringUtils.h" 35 36 #include "core/GameMode.h" 37 #include "core/GraphicsManager.h" 36 38 #include "core/GUIManager.h" 37 39 #include "core/ObjectList.h" 40 #include "core/ScopedSingletonManager.h" 38 41 #include "tools/Shader.h" 39 42 #include "graphics/Camera.h" … … 43 46 { 44 47 CameraManager* CameraManager::singletonPtr_s = 0; 48 ManageScopedSingleton(CameraManager, ScopeID::Graphics, false); 45 49 46 CameraManager::CameraManager( Ogre::Viewport* viewport)47 : viewport_( viewport)50 CameraManager::CameraManager() 51 : viewport_(GraphicsManager::getInstance().getViewport()) 48 52 { 49 this->fallbackCamera_ = 0;53 assert(GameMode::showsGraphics()); 50 54 } 51 55 52 56 CameraManager::~CameraManager() 53 57 { 54 if (this->fallbackCamera_) 55 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 58 GUIManager::getInstance().setCamera(0); 56 59 } 57 60 58 61 Camera* CameraManager::getActiveCamera() const 59 62 { 60 if ( this->cameraList_.size() > 0)63 if (!this->cameraList_.empty()) 61 64 return this->cameraList_.front(); 62 65 else … … 66 69 void CameraManager::requestFocus(Camera* camera) 67 70 { 68 if (!GameMode::showsGraphics())69 return;70 71 71 // notify old camera (if it exists) 72 if ( this->cameraList_.size() > 0)72 if (!this->cameraList_.empty()) 73 73 this->cameraList_.front()->removeFocus(); 74 else if (this->fallbackCamera_)75 {76 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);77 this->fallbackCamera_ = 0;78 }79 74 80 75 camera->setFocus(); 81 76 82 77 // 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();) 84 79 if ((*it) == camera) 85 return; 86 80 this->cameraList_.erase(it++); 81 else 82 ++it; 87 83 // add to list 88 84 this->cameraList_.push_front(camera); … … 91 87 void CameraManager::releaseFocus(Camera* camera) 92 88 { 93 if (!GameMode::showsGraphics())94 return;95 96 89 // notify the cam of releasing the focus 97 if ( this->cameraList_.front() == camera)90 if (!this->cameraList_.empty() && this->cameraList_.front() == camera) 98 91 { 99 92 camera->removeFocus(); … … 101 94 102 95 // set new focus if possible 103 if ( this->cameraList_.size() > 0)96 if (!this->cameraList_.empty()) 104 97 this->cameraList_.front()->setFocus(); 105 else106 {107 // there are no more cameras, create a fallback108 if (!this->fallbackCamera_)109 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());110 this->useCamera(this->fallbackCamera_);111 }112 98 } 113 99 else 114 {115 100 this->cameraList_.remove(camera); 116 }117 101 } 118 102 -
code/branches/pickup/src/orxonox/CameraManager.h
r5781 r5935 42 42 #include "util/OgreForwardRefs.h" 43 43 #include "util/Singleton.h" 44 #include "core/OrxonoxClass.h" 45 #include "core/SmartPtr.h" 44 46 45 47 namespace orxonox 46 48 { 47 class _OrxonoxExport CameraManager : public Singleton<CameraManager> 49 class _OrxonoxExport CameraManager : public Singleton<CameraManager>, public OrxonoxClass 48 50 { 49 51 friend class Singleton<CameraManager>; 50 52 public: 51 CameraManager( Ogre::Viewport* viewport);53 CameraManager(); 52 54 ~CameraManager(); 53 55 … … 66 68 std::list<Camera*> cameraList_; 67 69 Ogre::Viewport* viewport_; 68 Ogre::Camera* fallbackCamera_;69 70 70 71 static CameraManager* singletonPtr_s; -
code/branches/pickup/src/orxonox/Level.cc
r5781 r5935 30 30 31 31 #include "util/Math.h" 32 #include "core/Core.h"33 32 #include "core/CoreIncludes.h" 34 33 #include "core/Loader.h" … … 40 39 #include "gametypes/Gametype.h" 41 40 #include "overlays/OverlayGroup.h" 42 #include "sound/SoundBase.h"43 41 #include "LevelManager.h" 44 42 … … 53 51 this->registerVariables(); 54 52 this->xmlfilename_ = this->getFilename(); 53 this->xmlfile_ = 0; 55 54 } 56 55 … … 64 63 if (this->xmlfile_) 65 64 Loader::unload(this->xmlfile_); 66 67 if(this->ambientsound_ != NULL)68 delete this->ambientsound_;69 65 } 70 66 } … … 76 72 XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode); 77 73 XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype"); 78 79 XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);80 74 81 75 XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false); … … 116 110 this->gametype_ = gametype; 117 111 118 std::cout << "Load Gametype: " << this->gametype_ << std::endl;119 120 112 Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this)); 121 113 this->setGametype(rootgametype); 122 123 std::cout << "root gametype: " << rootgametype->getIdentifier()->getName() << std::endl;124 114 125 115 for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it) … … 149 139 } 150 140 151 void Level::loadAmbientSound(const std::string& filename)152 {153 if(filename == "") return;154 else155 {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 166 141 void Level::playerEntered(PlayerInfo* player) 167 142 { -
code/branches/pickup/src/orxonox/Level.h
r5781 r5935 53 53 { return this->description_; } 54 54 55 void loadAmbientSound(const std::string& filename);56 57 55 void playerEntered(PlayerInfo* player); 58 56 void playerLeft(PlayerInfo* player); … … 73 71 XMLFile* xmlfile_; 74 72 std::list<BaseObject*> objects_; 75 76 SoundBase* ambientsound_;77 73 }; 78 74 } -
code/branches/pickup/src/orxonox/LevelManager.cc
r5781 r5935 34 34 #include "core/CommandLine.h" 35 35 #include "core/ConfigValueIncludes.h" 36 #include "core/Core.h"37 36 #include "core/CoreIncludes.h" 38 37 #include "core/Loader.h" 38 #include "core/ScopedSingletonManager.h" 39 39 #include "PlayerManager.h" 40 40 #include "Level.h" 41 #include "infos/HumanPlayer.h"42 41 43 42 namespace orxonox … … 46 45 47 46 LevelManager* LevelManager::singletonPtr_s = 0; 47 ManageScopedSingleton(LevelManager, ScopeID::Root, false); 48 48 49 49 LevelManager::LevelManager() -
code/branches/pickup/src/orxonox/Main.cc
r5781 r5935 31 31 @file 32 32 @brief 33 The main function of Orxonox .33 The main function of Orxonox (but not the entry point of the program!) 34 34 */ 35 35 36 36 #include "OrxonoxPrereqs.h" 37 #include "SpecialConfig.h"38 37 39 #include "util/Exception.h"40 38 #include "core/CommandLine.h" 41 39 #include "core/Game.h" … … 50 48 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode"); 51 49 SetCommandLineSwitch(standalone).information("Start in standalone mode"); 50 SetCommandLineSwitch(dedicatedClient).information("Start in dedicated client mode"); 52 51 53 52 DeclareToluaInterface(Orxonox); … … 57 56 /** 58 57 @brief 59 Main method. Game starts here (except for static initialisations).58 Starting point of orxonox (however not the entry point of the program!) 60 59 */ 61 60 int main(const std::string& strCmdLine) … … 67 66 " graphics" 68 67 " mainMenu" 69 " standalone "68 " standalone,server,client" 70 69 " level" 71 " server" 72 " level" 73 " client" 74 " level" 75 " dedicated" 70 " dedicated,dedicatedClient" 76 71 " level" 77 72 " ioConsole" … … 89 84 else if (CommandLine::getValue("dedicated").getBool()) 90 85 Game::getInstance().requestStates("dedicated, level"); 86 else if (CommandLine::getValue("dedicatedClient").getBool()) 87 Game::getInstance().requestStates("dedicatedClient, level"); 91 88 else if (CommandLine::getValue("console").getBool()) 92 89 Game::getInstance().requestStates("ioConsole"); -
code/branches/pickup/src/orxonox/OrxonoxPrereqs.h
r5781 r5935 28 28 29 29 /** 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 32 33 */ 33 34 … … 36 37 37 38 #include "OrxonoxConfig.h" 38 39 39 #include "tools/ToolsPrereqs.h" 40 40 … … 42 42 // Shared library settings 43 43 //----------------------------------------------------------------------- 44 44 45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 45 46 # ifdef ORXONOX_SHARED_BUILD … … 65 66 { 66 67 class CameraManager; 68 class Level; 67 69 class LevelManager; 68 70 class PawnManager; 69 71 class PlayerManager; 70 71 class Level; 72 class Radar; 72 73 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; 74 115 75 116 // interfaces 76 117 class GametypeMessageListener; 77 118 class NotificationListener; 78 class PawnListener;79 119 class PlayerTrigger; 80 120 class RadarListener; 81 121 class RadarViewable; 82 122 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 132 137 class BaseItem; 133 138 class DroppedItem; … … 139 144 class PickupSpawner; 140 145 class UsableItem; 141 146 // pickup, items 147 class HealthImmediate; 148 class HealthUsable; 142 149 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; 151 156 152 157 // weaponsystem 153 class WeaponSystem; 158 class DefaultWeaponmodeLink; 159 class Munition; 160 class Weapon; 161 class WeaponMode; 162 class WeaponPack; 154 163 class WeaponSet; 155 164 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; 195 184 } 196 185 -
code/branches/pickup/src/orxonox/PawnManager.cc
r5781 r5935 57 57 { 58 58 if (!it->isAlive()) 59 delete (*(it++));59 (it++)->destroy(); 60 60 else 61 61 ++it; … … 63 63 64 64 if (count == 0) 65 delete this;65 this->destroy(); 66 66 } 67 67 } -
code/branches/pickup/src/orxonox/PlayerManager.cc
r5781 r5935 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/GameMode.h" 33 #include "core/ScopedSingletonManager.h" 33 34 #include "Level.h" 34 35 #include "infos/HumanPlayer.h" … … 38 39 { 39 40 PlayerManager* PlayerManager::singletonPtr_s = 0; 41 ManageScopedSingleton(PlayerManager, ScopeID::Root, false); 40 42 41 43 PlayerManager::PlayerManager() … … 74 76 if (GameMode::isMaster()) 75 77 { 76 COUT(3) << "client disconnected" << std::endl; 78 if (clientID != 0) 79 COUT(3) << "client disconnected" << std::endl; 77 80 78 81 // remove from clients-map … … 85 88 // delete PlayerInfo instance 86 89 if (player) 87 delete player;90 player->destroy(); 88 91 } 89 92 } -
code/branches/pickup/src/orxonox/PlayerManager.h
r5781 r5935 50 50 { return this->clients_; } 51 51 52 private:53 52 void clientConnected(unsigned int clientID); 54 53 void clientDisconnected(unsigned int clientID); 55 54 55 private: 56 56 std::map<unsigned int, PlayerInfo*> clients_; 57 57 -
code/branches/pickup/src/orxonox/Radar.cc
r5781 r5935 43 43 namespace orxonox 44 44 { 45 SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);46 SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);47 48 Radar* Radar::instance_s = 0;49 45 50 46 Radar::Radar() … … 52 48 , objectTypeCounter_(0) 53 49 { 54 assert(instance_s == 0);55 instance_s = this;56 57 50 // TODO: make this mapping configurable. Maybe there's a possibility with self configured 58 51 // configValues.. … … 79 72 Radar::~Radar() 80 73 { 81 instance_s = 0;82 74 } 83 75 84 76 const RadarViewable* Radar::getFocus() 85 77 { 86 return *(this->itFocus_); 78 if (this->itFocus_) 79 return *(this->itFocus_); 80 else 81 return 0; 87 82 } 88 83 … … 101 96 SUPER(Radar, tick, dt); 102 97 103 if (this-> focus_ != *(this->itFocus_))98 if (this->itFocus_ && (this->focus_ != *(this->itFocus_))) 104 99 { 105 100 // focus object was deleted, release focus … … 191 186 } 192 187 } 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 }216 188 } -
code/branches/pickup/src/orxonox/Radar.h
r5781 r5935 46 46 namespace orxonox 47 47 { 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 59 49 { 60 50 public: 61 51 Radar(); 62 ~Radar();52 virtual ~Radar(); 63 53 64 54 virtual void tick(float dt); … … 69 59 void listObjects() const; 70 60 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(); 76 63 77 64 private: 78 65 Radar(Radar& instance); 79 66 80 void releaseFocus();81 67 void updateFocus(); 82 void cycleFocus();83 68 84 69 ObjectListIterator<RadarViewable> itFocus_; … … 86 71 std::map<std::string, RadarViewable::Shape> objectTypes_; 87 72 int objectTypeCounter_; 88 89 static Radar* instance_s;90 73 }; 91 74 } -
code/branches/pickup/src/orxonox/Scene.cc
r5781 r5935 42 42 #include "core/CoreIncludes.h" 43 43 #include "core/GameMode.h" 44 #include "core/GUIManager.h" 44 45 #include "core/XMLPort.h" 45 46 #include "tools/BulletConversions.h" 47 #include "Radar.h" 46 48 #include "worldentities/WorldEntity.h" 47 49 … … 54 56 RegisterObject(Scene); 55 57 56 this->setScene( this);58 this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN); 57 59 this->bShadows_ = true; 58 60 … … 62 64 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC); 63 65 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 66 67 this->radar_ = new Radar(); 64 68 } 65 69 else … … 68 72 this->sceneManager_ = new Ogre::DefaultSceneManager(""); 69 73 this->rootSceneNode_ = this->sceneManager_->getRootSceneNode(); 74 75 this->radar_ = 0; 70 76 } 71 77 … … 92 98 else 93 99 delete this->sceneManager_; 100 101 if (this->radar_) 102 this->radar_->destroy(); 94 103 95 104 this->setPhysicalWorld(false); … … 275 284 { 276 285 this->objects_.push_back(object); 277 object->setScene(this );286 object->setScene(this, this->getObjectID()); 278 287 } 279 288 -
code/branches/pickup/src/orxonox/Scene.h
r5781 r5935 71 71 { return this->bShadows_; } 72 72 73 inline Radar* getRadar() 74 { return this->radar_; } 75 76 inline virtual uint32_t getSceneID() const { return this->getObjectID(); } 77 73 78 virtual void tick(float dt); 74 79 … … 91 96 std::list<BaseObject*> objects_; 92 97 bool bShadows_; 98 Radar* radar_; 93 99 94 100 -
code/branches/pickup/src/orxonox/Test.cc
r5781 r5935 63 63 setConfigValues(); 64 64 registerVariables(); 65 set ObjectMode(0x3);65 setSyncMode(0x3); 66 66 } 67 67 -
code/branches/pickup/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r5781 r5935 56 56 // make sure that the child doesn't want to detach itself --> speedup because of the missing update 57 57 it->first->notifyDetached(); 58 delete it->first;58 it->first->destroy(); 59 59 } 60 60 -
code/branches/pickup/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
r5781 r5935 43 43 this->worldEntityOwner_ = creator; 44 44 // suppress synchronisation 45 this->set ObjectMode(0x0);45 this->setSyncMode(0x0); 46 46 } 47 47 -
code/branches/pickup/src/orxonox/controllers/AIController.cc
r5781 r5935 44 44 RegisterObject(AIController); 45 45 46 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));46 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&AIController::action, this))); 47 47 } 48 48 -
code/branches/pickup/src/orxonox/controllers/AIController.h
r5781 r5935 50 50 51 51 private: 52 Timer <AIController>actionTimer_;52 Timer actionTimer_; 53 53 }; 54 54 } -
code/branches/pickup/src/orxonox/controllers/ArtificialController.cc
r5781 r5935 46 46 this->bHasTargetPosition_ = false; 47 47 this->targetPosition_ = Vector3::ZERO; 48 49 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 48 50 } 49 51 … … 162 164 } 163 165 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(); 171 176 } 172 177 -
code/branches/pickup/src/orxonox/controllers/ArtificialController.h
r5781 r5935 33 33 34 34 #include "util/Math.h" 35 #include "interfaces/PawnListener.h"36 35 #include "Controller.h" 37 36 38 37 namespace orxonox 39 38 { 40 class _OrxonoxExport ArtificialController : public Controller , public PawnListener39 class _OrxonoxExport ArtificialController : public Controller 41 40 { 42 41 public: 43 42 ArtificialController(BaseObject* creator); 44 43 virtual ~ArtificialController(); 45 46 v irtual void destroyedPawn(Pawn* pawn);44 45 void abandonTarget(Pawn* target); 47 46 48 47 protected: 48 void targetDied(); 49 49 50 void moveToPosition(const Vector3& target); 50 51 void moveToTargetPosition(); … … 65 66 bool bHasTargetPosition_; 66 67 Vector3 targetPosition_; 67 Pawn*target_;68 WeakPtr<Pawn> target_; 68 69 bool bShooting_; 69 70 -
code/branches/pickup/src/orxonox/controllers/HumanController.cc
r5781 r5935 36 36 #include "infos/PlayerInfo.h" 37 37 #include "overlays/Map.h" 38 #include "graphics/Camera.h" 39 #include "sound/SoundManager.h" 40 #include "Radar.h" 41 #include "Scene.h" 38 42 39 43 namespace orxonox … … 56 60 SetConsoleCommand(HumanController, dropItems, true); 57 61 SetConsoleCommand(HumanController, useItem, true); 62 SetConsoleCommand(HumanController, cycleNavigationFocus, true); 63 SetConsoleCommand(HumanController, releaseNavigationFocus, true); 58 64 59 65 CreateUnloadableFactory(HumanController); … … 71 77 { 72 78 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 } 73 95 } 74 96 … … 200 222 return NULL; 201 223 } 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 } 202 236 } -
code/branches/pickup/src/orxonox/controllers/HumanController.h
r5781 r5935 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "tools/interfaces/Tickable.h" 33 35 #include "Controller.h" 34 36 35 37 namespace orxonox 36 38 { 37 class _OrxonoxExport HumanController : public Controller 39 class _OrxonoxExport HumanController : public Controller, public Tickable 38 40 { 39 41 public: 40 42 HumanController(BaseObject* creator); 41 43 virtual ~HumanController(); 44 45 virtual void tick(float dt); 42 46 43 47 static void moveFrontBack(const Vector2& value); … … 58 62 static void dropItems(); 59 63 static void useItem(); 64 static void cycleNavigationFocus(); 65 static void releaseNavigationFocus(); 60 66 61 67 static void suicide(); -
code/branches/pickup/src/orxonox/controllers/WaypointController.cc
r5781 r5935 50 50 { 51 51 for (size_t i = 0; i < this->waypoints_.size(); ++i) 52 delete this->waypoints_[i];52 this->waypoints_[i]->destroy(); 53 53 } 54 54 } -
code/branches/pickup/src/orxonox/controllers/WaypointPatrolController.cc
r5781 r5935 45 45 this->alertnessradius_ = 500; 46 46 47 this->patrolTimer_.setTimer(rnd(), true, this, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy)));47 this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy, this))); 48 48 } 49 49 -
code/branches/pickup/src/orxonox/controllers/WaypointPatrolController.h
r5781 r5935 61 61 int team_; 62 62 float alertnessradius_; 63 Timer <WaypointPatrolController>patrolTimer_;63 Timer patrolTimer_; 64 64 }; 65 65 } -
code/branches/pickup/src/orxonox/gametypes/Asteroids.cc
r5781 r5935 54 54 if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_) 55 55 { 56 this->gtinfo_ .sendAnnounceMessage("Time's up - you have lost the match!");56 this->gtinfo_->sendAnnounceMessage("Time's up - you have lost the match!"); 57 57 this->end(); 58 58 } … … 63 63 if (victim && victim->getPlayer()) 64 64 { 65 this->gtinfo_ .sendAnnounceMessage("You're dead - you have lost the match!");65 this->gtinfo_->sendAnnounceMessage("You're dead - you have lost the match!"); 66 66 this->end(); 67 67 } -
code/branches/pickup/src/orxonox/gametypes/Gametype.cc
r5781 r5935 33 33 #include "core/ConfigValueIncludes.h" 34 34 #include "core/GameMode.h" 35 #include "core/ConsoleCommand.h" 35 36 36 37 #include "infos/PlayerInfo.h" … … 47 48 CreateUnloadableFactory(Gametype); 48 49 49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) , gtinfo_(creator)50 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 50 51 { 51 52 RegisterObject(Gametype); 52 53 this->setGametype(this); 53 54 this->gtinfo_ = new GametypeInfo(creator); 55 56 this->setGametype(SmartPtr<Gametype>(this, false)); 54 57 55 58 this->defaultControllableEntity_ = Class(Spectator); … … 76 79 else 77 80 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 } 78 100 } 79 101 … … 100 122 } 101 123 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_) 106 128 this->checkStart(); 107 else if (!this->gtinfo_ .bEnded_)129 else if (!this->gtinfo_->bEnded_) 108 130 this->spawnDeadPlayersIfRequested(); 109 131 … … 115 137 this->addBots(this->numberOfBots_); 116 138 117 this->gtinfo_ .bStarted_ = true;139 this->gtinfo_->bStarted_ = true; 118 140 119 141 this->spawnPlayersIfRequested(); … … 122 144 void Gametype::end() 123 145 { 124 this->gtinfo_ .bEnded_ = true;146 this->gtinfo_->bEnded_ = true; 125 147 126 148 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 130 152 ControllableEntity* oldentity = it->first->getControllableEntity(); 131 153 132 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity ->getCreator());154 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity); 133 155 if (oldentity->getCamera()) 134 156 { … … 243 265 244 266 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()); 246 268 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()); 248 270 } 249 271 } … … 308 330 it->second.state_ = PlayerState::Dead; 309 331 310 if (!it->first->isReadyToSpawn() || !this->gtinfo_ .bStarted_)332 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_) 311 333 { 312 334 this->spawnPlayerAsDefaultPawn(it->first); … … 319 341 void Gametype::checkStart() 320 342 { 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; 329 351 this->start(); 330 352 } … … 349 371 if (allplayersready && hashumanplayers) 350 372 { 351 this->gtinfo_ .startCountdown_ = this->initialStartCountdown_;352 this->gtinfo_ .bStartCountdownRunning_ = true;373 this->gtinfo_->startCountdown_ = this->initialStartCountdown_; 374 this->gtinfo_->bStartCountdownRunning_ = true; 353 375 } 354 376 } … … 419 441 if (it->getGametype() == this) 420 442 { 421 delete (*(it++));443 (it++)->destroy(); 422 444 ++i; 423 445 } 446 else 447 ++it; 424 448 } 425 449 } -
code/branches/pickup/src/orxonox/gametypes/Gametype.h
r5781 r5935 37 37 38 38 #include "core/BaseObject.h" 39 #include "core/ Identifier.h"39 #include "core/SubclassIdentifier.h" 40 40 #include "tools/interfaces/Tickable.h" 41 41 #include "infos/GametypeInfo.h" … … 68 68 public: 69 69 Gametype(BaseObject* creator); 70 virtual ~Gametype() {}70 virtual ~Gametype(); 71 71 72 72 void setConfigValues(); … … 75 75 76 76 inline const GametypeInfo* getGametypeInfo() const 77 { return &this->gtinfo_; }77 { return this->gtinfo_; } 78 78 79 79 inline bool hasStarted() const 80 { return this->gtinfo_ .bStarted_; }80 { return this->gtinfo_->bStarted_; } 81 81 inline bool hasEnded() const 82 { return this->gtinfo_ .bEnded_; }82 { return this->gtinfo_->bEnded_; } 83 83 84 84 virtual void start(); … … 114 114 115 115 inline bool isStartCountdownRunning() const 116 { return this->gtinfo_ .bStartCountdownRunning_; }116 { return this->gtinfo_->bStartCountdownRunning_; } 117 117 inline float getStartCountdown() const 118 { return this->gtinfo_ .startCountdown_; }118 { return this->gtinfo_->startCountdown_; } 119 119 120 120 inline void setHUDTemplate(const std::string& name) 121 { this->gtinfo_ .hudtemplate_ = name; }121 { this->gtinfo_->hudtemplate_ = name; } 122 122 inline const std::string& getHUDTemplate() const 123 { return this->gtinfo_ .hudtemplate_; }123 { return this->gtinfo_->hudtemplate_; } 124 124 125 125 void addBots(unsigned int amount); … … 163 163 virtual void spawnDeadPlayersIfRequested(); 164 164 165 GametypeInfogtinfo_;165 SmartPtr<GametypeInfo> gtinfo_; 166 166 167 167 bool bAutoStart_; … … 184 184 // Config Values 185 185 std::string scoreboardTemplate_; 186 187 /* HACK HACK HACK */ 188 ConsoleCommand* hackAddBots_; 189 ConsoleCommand* hackKillBots_; 190 /* HACK HACK HACK */ 186 191 }; 187 192 } -
code/branches/pickup/src/orxonox/gametypes/TeamBaseMatch.cc
r5781 r5935 42 42 RegisterObject(TeamBaseMatch); 43 43 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))); 46 46 47 47 this->pointsTeam1_ = 0; … … 67 67 { 68 68 base->setState(BaseState::ControlTeam1); 69 this->gtinfo_ .sendAnnounceMessage("The red team captured a base");69 this->gtinfo_->sendAnnounceMessage("The red team captured a base"); 70 70 } 71 71 if (teamnr == 1) 72 72 { 73 73 base->setState(BaseState::ControlTeam2); 74 this->gtinfo_ .sendAnnounceMessage("The blue team captured a base");74 this->gtinfo_->sendAnnounceMessage("The blue team captured a base"); 75 75 } 76 76 } … … 194 194 195 195 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()); 197 197 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()); 199 199 } 200 200 -
code/branches/pickup/src/orxonox/gametypes/TeamBaseMatch.h
r5781 r5935 65 65 66 66 std::set<TeamBaseMatchBase*> bases_; 67 Timer <TeamBaseMatch>scoreTimer_;68 Timer <TeamBaseMatch>outputTimer_;67 Timer scoreTimer_; 68 Timer outputTimer_; 69 69 70 70 //points for each team -
code/branches/pickup/src/orxonox/gametypes/TeamDeathmatch.cc
r5781 r5935 93 93 94 94 if (valid_player) 95 this-> players_.erase(player);95 this->teamnumbers_.erase(player); 96 96 97 97 return valid_player; … … 100 100 bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator) 101 101 { 102 return (!this->pawnsAreInTheSameTeam(victim, originator) );102 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 103 103 } 104 104 105 105 bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator) 106 106 { 107 return (!this->pawnsAreInTheSameTeam(victim, originator) );107 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 108 108 } 109 109 110 110 bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator) 111 111 { 112 return (!this->pawnsAreInTheSameTeam(victim, originator) );112 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 113 113 } 114 114 -
code/branches/pickup/src/orxonox/gametypes/UnderAttack.cc
r5781 r5935 46 46 this->teams_ = 2; 47 47 this->destroyer_ = 0; 48 this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this)); 48 49 this->gameEnded_ = false; 49 50 … … 65 66 66 67 67 void UnderAttack:: destroyedPawn(Pawn* pawn)68 void UnderAttack::killedDestroyer() 68 69 { 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) 70 77 { 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; 76 80 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()); 87 85 } 88 86 } … … 164 162 165 163 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()); 167 165 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()); 169 167 } 170 168 } … … 178 176 Host::Broadcast(message); 179 177 */ 180 this->gtinfo_ .sendAnnounceMessage(message);178 this->gtinfo_->sendAnnounceMessage(message); 181 179 182 180 if (timesequence_ >= 30 && timesequence_ <= 60) -
code/branches/pickup/src/orxonox/gametypes/UnderAttack.h
r5781 r5935 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "interfaces/PawnListener.h"35 34 #include "TeamDeathmatch.h" 36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport UnderAttack : public TeamDeathmatch , public PawnListener38 class _OrxonoxExport UnderAttack : public TeamDeathmatch 40 39 { 41 40 public: … … 54 53 55 54 protected: 56 virtual void destroyedPawn(Pawn* pawn);55 virtual void killedDestroyer(); 57 56 58 Destroyer*destroyer_;57 WeakPtr<Destroyer> destroyer_; 59 58 unsigned int teams_; 60 59 float gameTime_; -
code/branches/pickup/src/orxonox/graphics/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 Backlight.cc3 2 Billboard.cc 4 3 BlinkingBillboard.cc 5 Camera.cc6 4 FadingBillboard.cc 7 5 GlobalShader.cc 8 Light.cc9 6 Model.cc 10 7 ParticleEmitter.cc 11 8 ParticleSpawner.cc 9 COMPILATION_BEGIN GraphicsCompilation.cc 10 Backlight.cc 11 Camera.cc 12 Light.cc 13 COMPILATION_END 12 14 ) -
code/branches/pickup/src/orxonox/graphics/Camera.cc
r5781 r5935 38 38 #include "core/CoreIncludes.h" 39 39 #include "core/ConfigValueIncludes.h" 40 #include "core/GameMode.h" 41 #include "core/GUIManager.h" 40 42 #include "Scene.h" 41 43 #include "CameraManager.h" … … 49 51 RegisterObject(Camera); 50 52 53 if (!GameMode::showsGraphics()) 54 ThrowException(AbortLoading, "Can't create Camera, no graphics."); 51 55 if (!this->getScene()) 52 56 ThrowException(AbortLoading, "Can't create Camera, no scene."); … … 65 69 this->nearClipDistance_ = 1; 66 70 67 this->set ObjectMode(0x0);71 this->setSyncMode(0x0); 68 72 69 73 this->setConfigValues(); … … 75 79 if (this->isInitialized()) 76 80 { 81 if (GUIManager::getInstance().getCamera() == this->camera_) 82 GUIManager::getInstance().setCamera(NULL); 77 83 this->releaseFocus(); 78 84 -
code/branches/pickup/src/orxonox/graphics/FadingBillboard.cc
r5781 r5935 103 103 { 104 104 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))); 106 106 107 107 if (this->isVisible()) … … 111 111 { 112 112 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))); 114 114 } 115 115 } … … 126 126 this->fadedColour_ = ColourValue::ZERO; 127 127 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))); 129 129 } 130 130 this->changedirection_ = 0; -
code/branches/pickup/src/orxonox/graphics/FadingBillboard.h
r5781 r5935 74 74 float turnofftime_; 75 75 float postprocessingtime_; 76 Timer <FadingBillboard>turnonofftimer_;76 Timer turnonofftimer_; 77 77 char changedirection_; 78 78 ColourValue fadedColour_; -
code/branches/pickup/src/orxonox/graphics/ParticleEmitter.cc
r5781 r5935 63 63 { 64 64 this->detachOgreObject(this->particles_->getParticleSystem()); 65 delete this->particles_;65 this->particles_->destroy(); 66 66 } 67 67 } … … 101 101 if (this->particles_) 102 102 { 103 delete this->particles_;103 this->particles_->destroy(); 104 104 this->particles_ = 0; 105 105 } -
code/branches/pickup/src/orxonox/graphics/ParticleSpawner.cc
r5781 r5935 71 71 } 72 72 73 void ParticleSpawner:: processEvent(Event& event)73 void ParticleSpawner::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 74 74 { 75 SUPER(ParticleSpawner, processEvent, event);75 SUPER(ParticleSpawner, XMLEventPort, xmlelement, mode); 76 76 77 ORXONOX_SET_EVENT(ParticleSpawner, "spawn", spawn, event);77 XMLPortEventState(ParticleSpawner, BaseObject, "spawn", spawn, xmlelement, mode); 78 78 } 79 79 … … 88 88 void ParticleSpawner::startParticleSpawner() 89 89 { 90 if (!this->particles_)91 return;92 93 90 this->setActive(false); 94 91 95 92 if (this->bForceDestroy_ || this->bSuppressStart_) 93 { 94 this->timer_.stopTimer(); 96 95 return; 96 } 97 97 98 this->timer_.setTimer(this->startdelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner)));98 this->timer_.setTimer(this->startdelay_, false, createExecutor(createFunctor(&ParticleSpawner::fireParticleSpawner, this))); 99 99 } 100 100 … … 103 103 this->setActive(true); 104 104 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))); 106 106 } 107 107 … … 116 116 117 117 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))); 119 119 } 120 120 else if (this->bLoop_) 121 121 { 122 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner)));122 this->timer_.setTimer(this->destroydelay_, false, createExecutor(createFunctor(&ParticleSpawner::startParticleSpawner, this))); 123 123 } 124 124 } … … 126 126 void ParticleSpawner::destroyParticleSpawner() 127 127 { 128 delete this;128 this->destroy(); 129 129 } 130 130 } -
code/branches/pickup/src/orxonox/graphics/ParticleSpawner.h
r5781 r5935 44 44 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 virtual void processEvent(Event& event);46 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 47 47 48 inline void destroy()49 { this->bForceDestroy_ = true; this->stopParticleSpawner(); }48 inline void stop(bool bDestroy) 49 { this->bForceDestroy_ = bDestroy; this->stopParticleSpawner(); } 50 50 inline void spawn() 51 51 { this->bSuppressStart_ = false; this->startParticleSpawner(); } … … 89 89 void destroyParticleSpawner(); 90 90 91 Timer <ParticleSpawner>timer_;91 Timer timer_; 92 92 93 93 bool bSuppressStart_; -
code/branches/pickup/src/orxonox/infos/HumanPlayer.cc
r5781 r5935 64 64 { 65 65 if (this->humanHud_) 66 delete this->humanHud_;66 this->humanHud_->destroy(); 67 67 68 68 if (this->gametypeHud_) 69 delete this->gametypeHud_;69 this->gametypeHud_->destroy(); 70 70 } 71 71 } … … 116 116 117 117 if (!GameMode::isMaster()) 118 this->set ObjectMode(ObjectDirection::Bidirectional);118 this->setSyncMode(ObjectDirection::Bidirectional); 119 119 else 120 120 this->setName(this->nick_); … … 162 162 163 163 if (this->isInitialized() && this->isLocalPlayer()) 164 if (this->getGametype()->getHUDTemplate() != "") 164 { 165 if (this->getGametype() && this->getGametype()->getHUDTemplate() != "") 165 166 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate()); 167 else 168 this->setGametypeHUDTemplate(""); 169 } 166 170 } 167 171 … … 170 174 if (this->humanHud_) 171 175 { 172 delete this->humanHud_;176 this->humanHud_->destroy(); 173 177 this->humanHud_ = 0; 174 178 } 175 179 176 if (this->isLocalPlayer() && this->humanHudTemplate_ != "" )180 if (this->isLocalPlayer() && this->humanHudTemplate_ != "" && GameMode::showsGraphics()) 177 181 { 178 182 this->humanHud_ = new OverlayGroup(this); … … 186 190 if (this->gametypeHud_) 187 191 { 188 delete this->gametypeHud_;192 this->gametypeHud_->destroy(); 189 193 this->gametypeHud_ = 0; 190 194 } -
code/branches/pickup/src/orxonox/infos/PlayerInfo.cc
r5781 r5935 35 35 #include "gametypes/Gametype.h" 36 36 #include "worldentities/ControllableEntity.h" 37 #include "controllers/Controller.h" 37 38 38 39 namespace orxonox … … 66 67 if (this->controller_) 67 68 { 68 delete this->controller_;69 this->controller_->destroy(); 69 70 this->controller_ = 0; 70 71 } … … 131 132 if (this->controller_) 132 133 { 133 delete this->controller_;134 this->controller_->destroy(); 134 135 this->controller_ = 0; 135 136 } -
code/branches/pickup/src/orxonox/infos/PlayerInfo.h
r5781 r5935 33 33 34 34 #include "Info.h" 35 #include "core/Identifier.h" 36 #include "controllers/Controller.h" 35 #include "core/SubclassIdentifier.h" 37 36 38 37 namespace orxonox -
code/branches/pickup/src/orxonox/interfaces/InterfaceCompilation.cc
r5781 r5935 34 34 35 35 #include "GametypeMessageListener.h" 36 #include "PawnListener.h"37 36 #include "PlayerTrigger.h" 38 37 #include "RadarListener.h" … … 51 50 { 52 51 RegisterRootObject(GametypeMessageListener); 53 }54 55 //----------------------------56 // PawnListener57 //----------------------------58 /**59 @brief Constructor for the PawnListener.60 */61 PawnListener::PawnListener()62 {63 RegisterRootObject(PawnListener);64 52 } 65 53 -
code/branches/pickup/src/orxonox/interfaces/NotificationListener.h
r5781 r5935 45 45 namespace orxonox 46 46 { 47 class Notification; 48 47 49 class _OrxonoxExport NotificationListener : virtual public OrxonoxClass 48 50 { -
code/branches/pickup/src/orxonox/interfaces/RadarViewable.cc
r5781 r5935 38 38 #include "worldentities/WorldEntity.h" 39 39 #include "Radar.h" 40 #include "Scene.h" 40 41 #include "overlays/Map.h" 41 42 … … 135 136 void RadarViewable::setRadarObjectDescription(const std::string& str) 136 137 { 137 Radar* radar = Radar::getInstancePtr();138 Radar* radar = this->getWorldEntity()->getScene()->getRadar(); 138 139 if (radar) 139 140 this->radarObjectShape_ = radar->addObjectDescription(str); -
code/branches/pickup/src/orxonox/items/Engine.cc
r5781 r5935 37 37 #include "pickup/ModifierType.h" 38 38 #include "tools/Shader.h" 39 #include "sound/SoundBase.h"40 39 41 40 namespace orxonox … … 68 67 this->setConfigValues(); 69 68 this->registerVariables(); 70 71 this->sound_ = NULL;72 69 } 73 70 … … 79 76 80 77 if (this->boostBlur_) 81 delete this->boostBlur_; 82 83 if(this->sound_ != NULL) 84 delete this->sound_; 78 this->boostBlur_->destroy(); 85 79 } 86 80 } … … 102 96 XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode); 103 97 XMLPortParam(Engine, "accelerationupdown", setAccelerationUpDown, setAccelerationUpDown, xmlelement, mode); 104 105 XMLPortParamLoadOnly(Engine, "sound", loadSound, xmlelement, mode);106 98 } 107 99 … … 237 229 if (this->boostBlur_) 238 230 { 239 delete this->boostBlur_;231 this->boostBlur_->destroy(); 240 232 this->boostBlur_ = 0; 241 233 } 242 243 if(this->sound_ != NULL)244 this->sound_->attachToEntity(ship);245 234 } 246 235 } … … 253 242 return Vector3::ZERO; 254 243 } 255 256 void Engine::loadSound(const std::string filename)257 {258 if(filename == "") return;259 else260 {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 }270 244 } -
code/branches/pickup/src/orxonox/items/Engine.h
r5781 r5935 130 130 Shader* boostBlur_; 131 131 float blurStrength_; 132 133 SoundBase* sound_;134 132 }; 135 133 } -
code/branches/pickup/src/orxonox/items/MultiStateEngine.cc
r5781 r5935 60 60 // We have no ship, so the effects are not attached and won't be destroyed automatically 61 61 for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it) 62 delete (*it);62 (*it)->destroy(); 63 63 for (std::list<WorldEntity*>::const_iterator it = this->forwardEffects_.begin(); it != this->forwardEffects_.end(); ++it) 64 delete (*it);64 (*it)->destroy(); 65 65 for (std::list<WorldEntity*>::const_iterator it = this->boostEffects_.begin(); it != this->boostEffects_.end(); ++it) 66 delete (*it);66 (*it)->destroy(); 67 67 for (std::list<WorldEntity*>::const_iterator it = this->brakeEffects_.begin(); it != this->brakeEffects_.end(); ++it) 68 delete (*it);68 (*it)->destroy(); 69 69 } 70 70 } … … 91 91 if (this->getShip()->hasLocalController()) 92 92 { 93 this->set ObjectMode(ObjectDirection::Bidirectional);93 this->setSyncMode(ObjectDirection::Bidirectional); 94 94 95 95 const Vector3& direction = this->getDirection(); -
code/branches/pickup/src/orxonox/overlays/CMakeLists.txt
r5781 r5935 3 3 OverlayGroup.cc 4 4 5 COMPILATION_BEGIN OverlayCompilation.cc 5 6 InGameConsole.cc 6 7 Map.cc 8 COMPILATION_END 7 9 ) -
code/branches/pickup/src/orxonox/overlays/InGameConsole.cc
r5781 r5935 41 41 #include <OgreFont.h> 42 42 43 #include "util/Clock.h" 44 #include "util/Convert.h" 43 45 #include "util/Math.h" 44 #include "util/Convert.h"45 46 #include "util/UTFStringConversions.h" 46 #include "core/Clock.h"47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" 49 49 #include "core/ConsoleCommand.h" 50 #include "core/ScopedSingletonManager.h" 50 51 #include "core/input/InputManager.h" 51 52 #include "core/input/InputState.h" … … 61 62 62 63 InGameConsole* InGameConsole::singletonPtr_s = 0; 64 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); 63 65 64 66 /** … … 85 87 86 88 this->setConfigValues(); 89 this->initialise(); 87 90 } 88 91 -
code/branches/pickup/src/orxonox/overlays/InGameConsole.h
r5781 r5935 50 50 51 51 void initialise(); 52 void destroy();53 52 void setConfigValues(); 54 53 -
code/branches/pickup/src/orxonox/overlays/Map.cc
r5781 r5935 290 290 for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin(); 291 291 it!=ObjectList<orxonox::RadarViewable>::end(); 292 it++)292 ++it) 293 293 { 294 294 //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl; … … 392 392 for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin(); 393 393 it!=ObjectList<orxonox::Map>::end(); 394 it++)394 ++it) 395 395 { 396 396 //Map * m = it->getMap(); -
code/branches/pickup/src/orxonox/overlays/OrxonoxOverlay.h
r5781 r5935 213 213 }; 214 214 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); 217 217 } 218 218 -
code/branches/pickup/src/orxonox/overlays/OverlayGroup.cc
r5781 r5935 61 61 { 62 62 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 63 delete (*it);63 (*it)->destroy(); 64 64 } 65 65 -
code/branches/pickup/src/orxonox/pickup/DroppedItem.cc
r5902 r5935 75 75 if (this->item_) 76 76 { 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. 78 78 { 79 79 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); … … 93 93 { 94 94 COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl; 95 delete this;95 this->destroy(); 96 96 } 97 97 } … … 106 106 if (this->timeToLive_ > 0) 107 107 { 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); 110 109 } 111 110 } … … 123 122 { 124 123 COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << "'" << std::endl; 125 delete this->item_;124 this->item_->destroy(); 126 125 } 127 126 128 delete this;127 this->destroy(); 129 128 } 130 129 -
code/branches/pickup/src/orxonox/pickup/DroppedItem.h
r5902 r5935 86 86 BaseItem* item_; 87 87 88 Timer <DroppedItem>timer_;88 Timer timer_; 89 89 }; 90 90 } -
code/branches/pickup/src/orxonox/pickup/ModifierPickup.cc
r5902 r5935 116 116 if (this->duration_ > 0.0f) 117 117 { 118 Executor Member<ModifierPickup>* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback));118 Executor* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback, this)); 119 119 executor->setDefaultValues(pawn); 120 this->timer_.setTimer(this->duration_, false, this,executor);120 this->timer_.setTimer(this->duration_, false, executor); 121 121 } 122 122 … … 157 157 this->timer_.stopTimer(); 158 158 159 delete this;159 this->destroy(); 160 160 161 161 return true; -
code/branches/pickup/src/orxonox/pickup/ModifierPickup.h
r5902 r5935 152 152 153 153 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. 155 155 }; 156 156 } -
code/branches/pickup/src/orxonox/pickup/PickupSpawner.cc
r5902 r5935 103 103 asItem->addTemplate(this->itemTemplate_); 104 104 PickupInventory::getImageForItem(asItem); 105 delete newObject;105 newObject->destroy(); 106 106 } 107 107 … … 148 148 if (this->isActive()) 149 149 { 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) 151 151 { 152 152 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); … … 189 189 if (this->respawnTime_ > 0.0f) 190 190 { 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))); 193 192 194 193 this->setActive(false); … … 197 196 } 198 197 else 199 delete newObject;198 newObject->destroy(); 200 199 } 201 200 } -
code/branches/pickup/src/orxonox/pickup/PickupSpawner.h
r5902 r5935 115 115 116 116 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. 118 118 }; 119 119 } -
code/branches/pickup/src/orxonox/pickup/items/HealthImmediate.cc
r5902 r5935 68 68 { 69 69 pawn->addHealth(this->recoveredHealth_); 70 delete this;70 this->destroy(); 71 71 } 72 72 -
code/branches/pickup/src/orxonox/pickup/items/HealthUsable.cc
r5902 r5935 87 87 88 88 this->removeFrom(pawn); 89 delete this;89 this->destroy(); 90 90 } 91 91 } -
code/branches/pickup/src/orxonox/pickup/items/Jump.cc
r5781 r5935 84 84 { 85 85 this->removeFrom(pawn); 86 delete this;86 this->destroy(); 87 87 } 88 88 } -
code/branches/pickup/src/orxonox/sound/CMakeLists.txt
r5781 r5935 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 AmbientSound.cc 3 BaseSound.cc 2 4 SoundManager.cc 3 SoundBase.cc 4 SoundMainMenu.cc 5 WorldSound.cc 5 6 ) 6 7 -
code/branches/pickup/src/orxonox/sound/SoundManager.cc
r5781 r5935 31 31 #include <AL/alut.h> 32 32 33 #include "util/Exception.h" 33 34 #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" 37 38 38 39 namespace orxonox 39 40 { 40 41 SoundManager* SoundManager::singletonPtr_s = NULL; 42 ManageScopedSingleton(SoundManager, ScopeID::Graphics, true); 41 43 42 /**43 * Default constructor44 */45 44 SoundManager::SoundManager() 46 45 { 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) 50 53 { 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."); 53 59 } 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; 54 76 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; 59 78 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(); 88 84 } 89 85 90 86 SoundManager::~SoundManager() 91 87 { 88 GameMode::setPlaysSound(false); 92 89 alcDestroyContext(this->context_); 93 90 alcCloseDevice(this->device_); … … 95 92 } 96 93 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) 104 95 { 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; 106 100 } 107 101 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) 112 103 { 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(); 119 107 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 }; 123 110 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); 139 112 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) 154 114 COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl; 155 156 // update sounds157 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 available163 */164 bool SoundManager::isSoundAvailable()165 {166 return this->soundavailable_;167 115 } 168 116 } -
code/branches/pickup/src/orxonox/sound/SoundManager.h
r5781 r5935 39 39 /** 40 40 * 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. 43 42 * 44 43 */ 45 class _OrxonoxExport SoundManager : public Singleton<SoundManager> , public Tickable44 class _OrxonoxExport SoundManager : public Singleton<SoundManager> 46 45 { 47 46 friend class Singleton<SoundManager>; … … 49 48 SoundManager(); 50 49 ~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); 55 53 56 54 private: 57 55 ALCdevice* device_; 58 56 ALCcontext* context_; 59 std::list<SoundBase*> soundlist_;60 bool soundavailable_;61 57 62 58 static SoundManager* singletonPtr_s; 63 }; // class SoundManager64 } // namespace orxonox59 }; 60 } 65 61 66 62 #endif /* _SoundManager_H__ */ -
code/branches/pickup/src/orxonox/weaponsystem/Munition.cc
r5781 r5935 461 461 if (bUseReloadTime && (munition->reloadTime_ > 0 || munition->bStackMunition_)) 462 462 { 463 Executor Member<Magazine>* executor = createExecutor(createFunctor(&Magazine::loaded));463 Executor* executor = createExecutor(createFunctor(&Magazine::loaded, this)); 464 464 executor->setDefaultValues(munition); 465 465 466 this->loadTimer_.setTimer(munition->reloadTime_, false, this,executor);466 this->loadTimer_.setTimer(munition->reloadTime_, false, executor); 467 467 } 468 468 else -
code/branches/pickup/src/orxonox/weaponsystem/Munition.h
r5781 r5935 47 47 48 48 unsigned int munition_; 49 Timer <Magazine>loadTimer_;49 Timer loadTimer_; 50 50 bool bLoaded_; 51 51 -
code/branches/pickup/src/orxonox/weaponsystem/Weapon.cc
r5781 r5935 50 50 this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED; 51 51 52 this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&Weapon::reloaded)));52 this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&Weapon::reloaded, this))); 53 53 this->reloadTimer_.stopTimer(); 54 54 } … … 62 62 63 63 for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it) 64 delete it->second;64 it->second->destroy(); 65 65 } 66 66 } -
code/branches/pickup/src/orxonox/weaponsystem/Weapon.h
r5781 r5935 71 71 std::multimap<unsigned int, WeaponMode*> weaponmodes_; 72 72 73 Timer <Weapon>reloadTimer_;73 Timer reloadTimer_; 74 74 bool bReloading_; 75 75 unsigned int reloadingWeaponmode_; -
code/branches/pickup/src/orxonox/weaponsystem/WeaponMode.cc
r5781 r5935 57 57 this->bParallelReload_ = true; 58 58 59 this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&WeaponMode::reloaded)));59 this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this))); 60 60 this->reloadTimer_.stopTimer(); 61 61 -
code/branches/pickup/src/orxonox/weaponsystem/WeaponMode.h
r5781 r5935 36 36 #include "util/Math.h" 37 37 #include "core/BaseObject.h" 38 #include "core/ Identifier.h"38 #include "core/SubclassIdentifier.h" 39 39 #include "tools/Timer.h" 40 40 … … 150 150 std::string munitionname_; 151 151 152 Timer <WeaponMode>reloadTimer_;152 Timer reloadTimer_; 153 153 bool bReloading_; 154 154 }; -
code/branches/pickup/src/orxonox/weaponsystem/WeaponPack.cc
r5781 r5935 54 54 55 55 while (!this->weapons_.empty()) 56 delete (*this->weapons_.begin());56 (*this->weapons_.begin())->destroy(); 57 57 58 58 for (std::set<DefaultWeaponmodeLink*>::iterator it = this->links_.begin(); it != this->links_.end(); ) 59 delete (*(it++));59 (*(it++))->destroy(); 60 60 } 61 61 } -
code/branches/pickup/src/orxonox/weaponsystem/WeaponSlot.cc
r5781 r5935 46 46 this->weapon_ = 0; 47 47 48 this->set ObjectMode(0x0);48 this->setSyncMode(0x0); 49 49 } 50 50 -
code/branches/pickup/src/orxonox/weaponsystem/WeaponSystem.cc
r5781 r5935 62 62 63 63 while (!this->weaponSets_.empty()) 64 delete (this->weaponSets_.begin()->second);64 this->weaponSets_.begin()->second->destroy(); 65 65 66 66 while (!this->weaponPacks_.empty()) 67 delete (*this->weaponPacks_.begin());67 (*this->weaponPacks_.begin())->destroy(); 68 68 69 69 while (!this->weaponSlots_.empty()) 70 delete (*this->weaponSlots_.begin());70 (*this->weaponSlots_.begin())->destroy(); 71 71 72 72 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()); } 74 74 } 75 75 } -
code/branches/pickup/src/orxonox/worldentities/BigExplosion.cc
r5781 r5935 90 90 this->setVelocity(velocity); 91 91 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))); 93 93 } 94 94 this->registerVariables(); … … 226 226 { 227 227 this->debris1_->detachOgreObject(this->debrisFire1_->getParticleSystem()); 228 delete this->debrisFire1_;228 this->debrisFire1_->destroy(); 229 229 } 230 230 if (this->debrisSmoke1_) 231 231 { 232 232 this->debris1_->detachOgreObject(this->debrisSmoke1_->getParticleSystem()); 233 delete this->debrisSmoke1_;233 this->debrisSmoke1_->destroy(); 234 234 } 235 235 … … 237 237 { 238 238 this->debris2_->detachOgreObject(this->debrisFire2_->getParticleSystem()); 239 delete this->debrisFire2_;239 this->debrisFire2_->destroy(); 240 240 } 241 241 if (this->debrisSmoke2_) 242 242 { 243 243 this->debris2_->detachOgreObject(this->debrisSmoke2_->getParticleSystem()); 244 delete this->debrisSmoke2_;244 this->debrisSmoke2_->destroy(); 245 245 } 246 246 … … 248 248 { 249 249 this->debris3_->detachOgreObject(this->debrisFire3_->getParticleSystem()); 250 delete this->debrisFire3_;250 this->debrisFire3_->destroy(); 251 251 } 252 252 if (this->debrisSmoke3_) 253 253 { 254 254 this->debris3_->detachOgreObject(this->debrisSmoke3_->getParticleSystem()); 255 delete this->debrisSmoke3_;255 this->debrisSmoke3_->destroy(); 256 256 } 257 257 … … 259 259 { 260 260 this->debris4_->detachOgreObject(this->debrisFire4_->getParticleSystem()); 261 delete this->debrisFire4_;261 this->debrisFire4_->destroy(); 262 262 } 263 263 if (this->debrisSmoke4_) 264 264 { 265 265 this->debris4_->detachOgreObject(this->debrisSmoke4_->getParticleSystem()); 266 delete this->debrisSmoke4_;266 this->debrisSmoke4_->destroy(); 267 267 } 268 268 } … … 329 329 { 330 330 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 } 338 333 } 339 334 -
code/branches/pickup/src/orxonox/worldentities/BigExplosion.h
r5781 r5935 57 57 void checkStop(); 58 58 void stop(); 59 void destroy();60 59 void init(); 61 60 void initZero(); … … 98 97 ParticleInterface* explosionFire_; 99 98 100 LODParticle::Value 101 Timer <BigExplosion>destroyTimer_;99 LODParticle::Value LOD_; 100 Timer destroyTimer_; 102 101 }; 103 102 } -
code/branches/pickup/src/orxonox/worldentities/CameraPosition.cc
r5781 r5935 46 46 this->bRenderCamera_ = false; 47 47 48 this->set ObjectMode(0x0);48 this->setSyncMode(0x0); 49 49 } 50 50 -
code/branches/pickup/src/orxonox/worldentities/ControllableEntity.cc
r5781 r5935 96 96 97 97 if (this->xmlcontroller_) 98 delete this->xmlcontroller_;98 this->xmlcontroller_->destroy(); 99 99 100 100 if (this->hud_) 101 delete this->hud_;101 this->hud_->destroy(); 102 102 103 103 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(); 108 108 109 109 if (this->getScene()->getSceneManager()) … … 153 153 { 154 154 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) 156 156 { 157 157 if (i == index) … … 172 172 else if (this->cameraPositions_.size() > 0) 173 173 { 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) 175 175 { 176 176 if ((*it) == this->camera_->getParent()) … … 238 238 { 239 239 this->client_overwrite_ = this->server_overwrite_; 240 this->set ObjectMode(ObjectDirection::Bidirectional);240 this->setSyncMode(ObjectDirection::Bidirectional); 241 241 } 242 242 } … … 254 254 this->bHasLocalController_ = false; 255 255 this->bHasHumanController_ = false; 256 this->set ObjectMode(ObjectDirection::ToClient);256 this->setSyncMode(ObjectDirection::ToClient); 257 257 258 258 this->changedPlayer(); 259 259 260 260 if (this->bDestroyWhenPlayerLeft_) 261 delete this;261 this->destroy(); 262 262 } 263 263 … … 275 275 void ControllableEntity::startLocalHumanControl() 276 276 { 277 if (!this->camera_ )277 if (!this->camera_ && GameMode::showsGraphics()) 278 278 { 279 279 this->camera_ = new Camera(this); … … 287 287 } 288 288 289 if (!this->hud_ )289 if (!this->hud_ && GameMode::showsGraphics()) 290 290 { 291 291 if (this->hudtemplate_ != "") … … 303 303 { 304 304 this->camera_->detachFromParent(); 305 delete this->camera_;305 this->camera_->destroy(); 306 306 this->camera_ = 0; 307 307 } … … 309 309 if (this->hud_) 310 310 { 311 delete this->hud_;311 this->hud_->destroy(); 312 312 this->hud_ = 0; 313 313 } … … 333 333 if (parent) 334 334 { 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) 336 336 if ((*it)->getIsAbsolute()) 337 337 parent->attach((*it)); -
code/branches/pickup/src/orxonox/worldentities/ControllableEntity.h
r5781 r5935 104 104 void addCameraPosition(CameraPosition* position); 105 105 CameraPosition* getCameraPosition(unsigned int index) const; 106 inline const std::list< CameraPosition*>& getCameraPositions() const106 inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const 107 107 { return this->cameraPositions_; } 108 108 … … 198 198 float mouseLookSpeed_; 199 199 Ogre::SceneNode* cameraPositionRootNode_; 200 std::list< CameraPosition*> cameraPositions_;200 std::list<SmartPtr<CameraPosition> > cameraPositions_; 201 201 std::string cameraPositionTemplate_; 202 202 Controller* xmlcontroller_; -
code/branches/pickup/src/orxonox/worldentities/ExplosionChunk.cc
r5781 r5935 79 79 this->setVelocity(velocity); 80 80 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))); 82 82 } 83 83 … … 92 92 { 93 93 this->detachOgreObject(this->fire_->getParticleSystem()); 94 delete this->fire_;94 this->fire_->destroy(); 95 95 } 96 96 if (this->smoke_) 97 97 { 98 98 this->detachOgreObject(this->smoke_->getParticleSystem()); 99 delete this->smoke_;99 this->smoke_->destroy(); 100 100 } 101 101 } … … 132 132 { 133 133 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))); 135 135 } 136 }137 138 void ExplosionChunk::destroy()139 {140 delete this;141 136 } 142 137 -
code/branches/pickup/src/orxonox/worldentities/ExplosionChunk.h
r5781 r5935 55 55 void checkStop(); 56 56 void stop(); 57 void destroy();58 57 59 58 bool bStop_; 60 59 ParticleInterface* fire_; 61 60 ParticleInterface* smoke_; 62 LODParticle::Value 63 Timer <ExplosionChunk>destroyTimer_;61 LODParticle::Value LOD_; 62 Timer destroyTimer_; 64 63 }; 65 64 } -
code/branches/pickup/src/orxonox/worldentities/MovableEntity.cc
r5781 r5935 61 61 if (this->isInitialized()) 62 62 if (this->continuousResynchroTimer_) 63 delete this->continuousResynchroTimer_;63 this->continuousResynchroTimer_->destroy(); 64 64 } 65 65 … … 98 98 void MovableEntity::clientConnected(unsigned int clientID) 99 99 { 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))); 101 101 } 102 102 … … 110 110 { 111 111 // 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); 114 114 } 115 115 -
code/branches/pickup/src/orxonox/worldentities/MovableEntity.h
r5781 r5935 96 96 Quaternion overwrite_orientation_; 97 97 98 Timer <MovableEntity>resynchronizeTimer_;99 Timer <MovableEntity>* continuousResynchroTimer_;98 Timer resynchronizeTimer_; 99 Timer* continuousResynchroTimer_; 100 100 101 101 Pawn* owner_; -
code/branches/pickup/src/orxonox/worldentities/SpawnPoint.cc
r5781 r5935 50 50 COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl; 51 51 52 this->set ObjectMode(0x0);52 this->setSyncMode(0x0); 53 53 } 54 54 -
code/branches/pickup/src/orxonox/worldentities/SpawnPoint.h
r5781 r5935 33 33 34 34 #include <string> 35 #include "core/ Identifier.h"35 #include "core/SubclassIdentifier.h" 36 36 #include "worldentities/StaticEntity.h" 37 37 -
code/branches/pickup/src/orxonox/worldentities/WorldEntity.cc
r5781 r5935 119 119 { 120 120 if ((*it)->getDeleteWithParent()) 121 delete (*(it++));121 (*(it++))->destroy(); 122 122 else 123 123 { … … 132 132 delete this->physicalBody_; 133 133 } 134 delete this->collisionShape_;134 this->collisionShape_->destroy(); 135 135 136 136 this->node_->detachAllObjects(); … … 175 175 void WorldEntity::registerVariables() 176 176 { 177 registerVariable(this->mainStateName_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState ));177 registerVariable(this->mainStateName_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainStateName)); 178 178 179 179 registerVariable(this->bActive_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); -
code/branches/pickup/src/orxonox/worldentities/pawns/Destroyer.cc
r5781 r5935 40 40 RegisterObject(Destroyer); 41 41 42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype() );42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype().get()); 43 43 if (gametype) 44 44 { -
code/branches/pickup/src/orxonox/worldentities/pawns/Pawn.cc
r5781 r5935 36 36 #include "network/NetworkFunction.h" 37 37 38 #include "interfaces/PawnListener.h"39 38 #include "PawnManager.h" 40 39 #include "infos/PlayerInfo.h" … … 93 92 if (this->isInitialized()) 94 93 { 95 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)96 it->destroyedPawn(this);97 98 94 if (this->weaponSystem_) 99 delete this->weaponSystem_;95 this->weaponSystem_->destroy(); 100 96 } 101 97 } -
code/branches/pickup/src/orxonox/worldentities/pawns/SpaceShip.cc
r5781 r5935 75 75 { 76 76 if (this->isInitialized() && this->engine_) 77 delete this->engine_;77 this->engine_->destroy(); 78 78 } 79 79 … … 207 207 else 208 208 { 209 delete object;209 object->destroy(); 210 210 } 211 211 } -
code/branches/pickup/src/orxonox/worldentities/pawns/Spectator.cc
r5781 r5935 145 145 ControllableEntity::setPlayer(player); 146 146 147 // this->set ObjectMode(ObjectDirection::ToClient);147 // this->setSyncMode(ObjectDirection::ToClient); 148 148 } 149 149 -
code/branches/pickup/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r5781 r5935 31 31 32 32 #include "core/CoreIncludes.h" 33 #include " interfaces/PawnListener.h"33 #include "controllers/ArtificialController.h" 34 34 #include "interfaces/TeamColourable.h" 35 35 #include "gametypes/TeamBaseMatch.h" … … 45 45 this->state_ = BaseState::Uncontrolled; 46 46 47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype() );47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype().get()); 48 48 if (gametype) 49 49 { … … 58 58 this->fireEvent(); 59 59 60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype() );60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype().get()); 61 61 if (!gametype) 62 62 return; … … 92 92 93 93 // 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); 96 96 } 97 97 }
Note: See TracChangeset
for help on using the changeset viewer.