ソースを参照

Minor fixes and optimizations across the application.

Iñigo Valentin 3 年 前
コミット
d9f9865904
68 ファイル変更1068 行追加2187 行削除
  1. 7 18
      CMakeLists.txt
  2. 53 53
      V-Gears-Installer/src/KernelDataInstaller.cpp
  3. 0 1
      V-Gears-Installer/src/MediaDataInstaller.cpp
  4. 3 3
      V-Gears-Installer/src/common/BinGZipFile.cpp
  5. 4 11
      V-Gears-Installer/src/common/FontFile.cpp
  6. 0 2
      V-Gears-Installer/src/common/OgreBase.cpp
  7. 4 4
      V-Gears/CMakeLists.txt
  8. 81 38
      V-Gears/include/core/EntityManager.h
  9. 7 9
      V-Gears/include/core/GameFrameListener.h
  10. 2 3
      V-Gears/include/core/UiTextArea.h
  11. 32 49
      V-Gears/include/core/UiWidget.h
  12. 24 41
      V-Gears/include/core/Utilites.h
  13. 8 8
      V-Gears/include/core/Walkmesh.h
  14. 16 28
      V-Gears/include/core/XmlFile.h
  15. 2 3
      V-Gears/include/core/XmlMapFile.h
  16. 3 4
      V-Gears/include/core/XmlMapsFile.h
  17. 1 3
      V-Gears/include/core/XmlPrototypesFile.h
  18. 1 3
      V-Gears/include/core/XmlScreenFile.h
  19. 0 0
      V-Gears/include/core/particles/emitters/PointEmitter.h
  20. 7 11
      V-Gears/include/core/particles/emitters/PointEmitterFactory.h
  21. 1 1
      V-Gears/src/Main.cpp
  22. 4 4
      V-Gears/src/common/File.cpp
  23. 13 14
      V-Gears/src/common/LzsFile.cpp
  24. 14 33
      V-Gears/src/core/AudioManager.cpp
  25. 7 4
      V-Gears/src/core/Background2D.cpp
  26. 6 18
      V-Gears/src/core/ConfigVar.cpp
  27. 7 13
      V-Gears/src/core/ConfigVarManager.cpp
  28. 85 156
      V-Gears/src/core/Console.cpp
  29. 78 198
      V-Gears/src/core/DebugDraw.cpp
  30. 59 178
      V-Gears/src/core/DialogsManager.cpp
  31. 70 170
      V-Gears/src/core/Entity.cpp
  32. 85 265
      V-Gears/src/core/EntityManager.cpp
  33. 17 46
      V-Gears/src/core/GameFrameListener.cpp
  34. 2 2
      V-Gears/src/core/TextManager.cpp
  35. 12 66
      V-Gears/src/core/UiSprite.cpp
  36. 25 39
      V-Gears/src/core/UiTextArea.cpp
  37. 46 111
      V-Gears/src/core/UiWidget.cpp
  38. 23 48
      V-Gears/src/core/Utilites.cpp
  39. 14 51
      V-Gears/src/core/Walkmesh.cpp
  40. 23 50
      V-Gears/src/core/XmlBackground2DFile.cpp
  41. 9 21
      V-Gears/src/core/XmlFile.cpp
  42. 7 12
      V-Gears/src/core/XmlFontFile.cpp
  43. 2 6
      V-Gears/src/core/XmlFontsFile.cpp
  44. 5 16
      V-Gears/src/core/XmlMapsFile.cpp
  45. 2 7
      V-Gears/src/core/XmlMusicsFile.cpp
  46. 1 4
      V-Gears/src/core/XmlPrototypesFile.cpp
  47. 71 171
      V-Gears/src/core/XmlScreenFile.cpp
  48. 4 14
      V-Gears/src/core/XmlScreensFile.cpp
  49. 4 16
      V-Gears/src/core/XmlScriptsFile.cpp
  50. 4 13
      V-Gears/src/core/XmlTextFile.cpp
  51. 6 22
      V-Gears/src/core/XmlTextsFile.cpp
  52. 4 7
      V-Gears/src/core/XmlWalkmeshFile.cpp
  53. 13 30
      V-Gears/src/core/particles/ParticleRendererTranslator.cpp
  54. 1 1
      V-Gears/src/core/particles/ParticleSystem.cpp
  55. 2 1
      V-Gears/src/core/particles/ParticleSystemManager.cpp
  56. 30 54
      V-Gears/src/core/particles/ParticleTechnique.cpp
  57. 2 4
      V-Gears/src/core/particles/emitters/PointEmitter.cpp
  58. 39 0
      V-Gears/src/core/particles/emitters/PointEmitterFactory.cpp
  59. 0 6
      V-Gears/src/data/VGearsBackgroundFile.cpp
  60. 3 3
      V-Gears/src/data/VGearsCameraMatrixFileSerializer.cpp
  61. 0 1
      V-Gears/src/data/VGearsFLevelFileSerializer.cpp
  62. 5 5
      V-Gears/src/data/VGearsHRCFileSerializer.cpp
  63. 1 1
      V-Gears/src/data/VGearsPFile.cpp
  64. 1 1
      V-Gears/src/data/VGearsTexCodec.cpp
  65. 1 4
      V-Gears/src/data/VGearsTexFile.cpp
  66. 2 5
      V-Gears/src/data/worldmap/TxzFileSerializer.cpp
  67. 2 2
      V-Gears/src/map/FinalFantasy7/FF7WalkmeshFileSerializer.cpp
  68. 1 1
      data/data/scripts/field.lua

+ 7 - 18
CMakeLists.txt

@@ -105,12 +105,6 @@ endif()
 find_package(Qt5Widgets REQUIRED)
 find_package(ZLIB REQUIRED)
 find_package(OGRE REQUIRED)
-#find_package(OIS REQUIRED)
-
-
-#if(NOT OIS_FOUND)
-    #message(SEND_ERROR "Failed to find OIS.")
-#endif()
 
 # Find Boost
 if(NOT OGRE_BUILD_PLATFORM_IPHONE)
@@ -180,7 +174,6 @@ if(NOT OGRE_BUILD_PLATFORM_IPHONE)
             ${OGRE_LIBRARIES}
             ${Boost_LIBRARIES}
         )
-        #message(STATUS "Test libs = ${VGears_TEST_LIBRARIES}")
         # Enable CTest.
         enable_testing()
         endif()
@@ -199,7 +192,7 @@ set(VGears_INCLUDE_DIRS
     ${CMAKE_CURRENT_SOURCE_DIR}/V-Gears/include/
     ${OIS_INCLUDE_DIRS}
     ${OGRE_Overlay_INCLUDE_DIRS}
-    ${OGRE_SAMPLES_INCLUDEPATH}
+    #${OGRE_SAMPLES_INCLUDEPATH}
     ${CMAKE_CURRENT_SOURCE_DIR}/lib
     ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit
     ${CMAKE_CURRENT_SOURCE_DIR}/lib/luajit/src
@@ -208,7 +201,7 @@ set(VGears_INCLUDE_DIRS
     ${CMAKE_CURRENT_SOURCE_DIR}/lib/tinyxml
 )
 
-# C++20
+# C++14
 # TODO: Try to remove PIC
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC")
 if (MSVC)
@@ -216,9 +209,6 @@ if (MSVC)
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zm193")
     # Shut up about insecure functions, as this is cross platform code we can't use the Win32 specifc functions
     add_definitions( -D_CRT_SECURE_NO_WARNINGS )
-else()
-    # Enable C++11, you may need to use -std=c++0x if using an older gcc compiler
-    #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
 endif()
 
 if (UNIX AND $ENV{COVERAGE}==1)
@@ -227,13 +217,12 @@ if (UNIX AND $ENV{COVERAGE}==1)
       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") # enabling coverage
 endif()
 
-#DEBUG, no optimizations
+#TODO: Force DEBUG, no optimizations for now.
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -rdynamic -O0")
 
 add_definitions(-DTIXML_USE_STL)
 add_subdirectory(lib)
 add_subdirectory(V-Gears)
-#add_subdirectory(SupportedGames)
 
 if(VGears_BUILD_PLUGINS)
     add_subdirectory(PlugIns)
@@ -334,10 +323,10 @@ elseif(UNIX)
     install(FILES ${PROJECT_SOURCE_DIR}/output/resources.cfg_linux DESTINATION share/v-gears/ RENAME resources.cfg PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_WRITE WORLD_READ)
     install(FILES ${PROJECT_SOURCE_DIR}/output/v-gears.cfg_linux DESTINATION share/v-gears/ RENAME v-gears.cfg PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE WORLD_WRITE WORLD_READ)
         
-    if(EXISTS "/usr/lib/x86_64-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0")
-        install(FILES /usr/lib/x86_64-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0 DESTINATION lib/v-gears/plugins/ )
-    elseif(EXISTS "/usr/lib/i386-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0")
-        install(FILES /usr/lib/i386-linux-gnu/OGRE-1.9.0/RenderSystem_GL.so.1.9.0 DESTINATION lib/v-gears/plugins/ )
+    if(EXISTS "/usr/lib/x86_64-linux-gnu/OGRE/RenderSystem_GL.so.1.12.10")
+        install(FILES /usr/lib/x86_64-linux-gnu/OGRE/RenderSystem_GL.so.1.12.10 DESTINATION lib/v-gears/plugins/ )
+    elseif(EXISTS "/usr/lib/i386-linux-gnu/OGRE/RenderSystem_GL.so.1.12.10")
+        install(FILES /usr/lib/i386-linux-gnu/OGRE/RenderSystem_GL.so.1.12.10 DESTINATION lib/v-gears/plugins/ )
     endif()
         
     SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")

+ 53 - 53
V-Gears-Installer/src/KernelDataInstaller.cpp

@@ -44,8 +44,6 @@ int KernelDataInstaller::ReadCommands(){
     File command_file = kernel_.ExtractGZip(KERNEL_COMMAND_DATA);
     File command_name_file = kernel_.ExtractGZip(KERNEL_COMMAND_NAMES);
     File command_desc_file = kernel_.ExtractGZip(KERNEL_COMMAND_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int command_count = 0;
 
     // There are exactly 32 commands. Some of them are blank, so there is not really a
@@ -53,6 +51,8 @@ int KernelDataInstaller::ReadCommands(){
     for (int i = 0; i < 32; i ++){
 
         CommandData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -85,9 +85,9 @@ int KernelDataInstaller::ReadCommands(){
                     // The offset goes backwards from the position of the 0xF9 byte.
                     u8 comp_offset = command_desc_file.GetU8(desc_offset + 1) & 63;
 
-                    for (int i = 0; i < comp_size; i ++){
+                    for (int c = 0; c < comp_size; c ++){
                         data.description += ENGLISH_CHARS[
-                          command_desc_file.GetU8(desc_offset - 1 - comp_offset + i)
+                          command_desc_file.GetU8(desc_offset - 1 - comp_offset + c)
                         ];
                     }
                     desc_offset ++;
@@ -518,7 +518,7 @@ void KernelDataInstaller::ReadGrowth(){
     for (int i = 0; i < 12; i ++) growth_.bonus_mp[i] = growth_file.readU8();
     for (int i = 0; i < 64; i ++){
         growth_.curves[i].id = i;
-        if (i >=0 && i < 37) growth_.curves[i].type = CURVE_PRIMARY;
+        if (i < 37) growth_.curves[i].type = CURVE_PRIMARY;
         else if (i >=37 && i < 46) growth_.curves[i].type = CURVE_HP;
         else if (i >=46 && i < 55) growth_.curves[i].type = CURVE_MP;
         else growth_.curves[i].type = CURVE_EXP;
@@ -564,13 +564,13 @@ int KernelDataInstaller::ReadItems(){
     File items_file = kernel_.ExtractGZip(KERNEL_ITEM_DATA);
     File items_name_file = kernel_.ExtractGZip(KERNEL_ITEM_NAMES);
     File items_desc_file = kernel_.ExtractGZip(KERNEL_ITEM_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int item_count = 0;
 
     for (int i = 0; i < 128; i ++){
 
         ItemData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -603,9 +603,9 @@ int KernelDataInstaller::ReadItems(){
                     // The offset goes backwards from the position of the 0xF9 byte.
                     u8 comp_offset = items_desc_file.GetU8(desc_offset + 1) & 63;
 
-                    for (int i = 0; i < comp_size; i ++){
+                    for (int c = 0; c < comp_size; c ++){
                         data.description += ENGLISH_CHARS[
-                          items_desc_file.GetU8(desc_offset - 1 - comp_offset + i)
+                          items_desc_file.GetU8(desc_offset - 1 - comp_offset + c)
                         ];
                     }
                     desc_offset ++;
@@ -827,13 +827,13 @@ int KernelDataInstaller::ReadWeapons(){
     File weapons_file = kernel_.ExtractGZip(KERNEL_WEAPON_DATA);
     File weapons_name_file = kernel_.ExtractGZip(KERNEL_WEAPON_NAMES);
     File weapons_desc_file = kernel_.ExtractGZip(KERNEL_WEAPON_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int weapon_count = 0;
 
     for (int i = 0; i < 128; i ++){
 
         WeaponData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -866,9 +866,9 @@ int KernelDataInstaller::ReadWeapons(){
                     // The offset goes backwards from the position of the 0xF9 byte.
                     u8 comp_offset = weapons_desc_file.GetU8(desc_offset + 1) & 63;
 
-                    for (int i = 0; i < comp_size; i ++){
+                    for (int c = 0; c < comp_size; c ++){
                         data.description += ENGLISH_CHARS[
-                          weapons_desc_file.GetU8(desc_offset - 1 - comp_offset + i)
+                          weapons_desc_file.GetU8(desc_offset - 1 - comp_offset + c)
                         ];
                     }
                     desc_offset ++;
@@ -900,9 +900,9 @@ int KernelDataInstaller::ReadWeapons(){
         data.equip_raw = weapons_file.readU16LE();
         data.element_raw = weapons_file.readU16LE();
         data.unused_3 = weapons_file.readU16LE();
-        for (int i = 0; i < 4; i ++) data.stat_raw[i] = weapons_file.readU8();
-        for (int i = 0; i < 4; i ++) data.stat_bonus_raw[i] = weapons_file.readU8();
-        for (int i = 0; i < 8; i ++) data.slots_raw[i] = weapons_file.readU8();
+        for (int s = 0; s < 4; s ++) data.stat_raw[s] = weapons_file.readU8();
+        for (int s = 0; s < 4; s ++) data.stat_bonus_raw[s] = weapons_file.readU8();
+        for (int s = 0; s < 8; s ++) data.slots_raw[s] = weapons_file.readU8();
         data.sound = weapons_file.readU8();
         data.sound_critical = weapons_file.readU8();
         data.sound_miss = weapons_file.readU8();
@@ -949,21 +949,21 @@ int KernelDataInstaller::ReadWeapons(){
         if (data.equip_raw == (data.equip_raw | 0x0100)) data.equip.push_back(8);
         if (data.equip_raw == (data.equip_raw | 0x0200)) data.equip.push_back(9);
         if (data.equip_raw == (data.equip_raw | 0x0400)) data.equip.push_back(10);
-        for (int i = 0; i < 4; i ++){
-            if (data.stat_raw[i] < 0XFF && data.stat_bonus_raw[i] > 0){
+        for (int s = 0; s < 4; s ++){
+            if (data.stat_raw[s] < 0XFF && data.stat_bonus_raw[s] > 0){
                 StatBonus stat_bonus;
-                stat_bonus.stat = data.stat_raw[i];
-                stat_bonus.bonus = data.stat_bonus_raw[i];
+                stat_bonus.stat = data.stat_raw[s];
+                stat_bonus.bonus = data.stat_bonus_raw[s];
                 data.stat_bonus.push_back(stat_bonus);
             }
         }
-        for (int i = 0; i < 8; i ++){
-            if (data.slots_raw[i] == 1 || data.slots_raw[i] == 5){
+        for (int s = 0; s < 8; s ++){
+            if (data.slots_raw[s] == 1 || data.slots_raw[s] == 5){
                 data.materia_slots.push_back(SLOT_UNLINKED);
             }
             else if (
-              data.slots_raw[i] == 2 || data.slots_raw[i] == 3
-              || data.slots_raw[i] == 6 || data.slots_raw[i] == 7
+              data.slots_raw[s] == 2 || data.slots_raw[s] == 3
+              || data.slots_raw[s] == 6 || data.slots_raw[s] == 7
             ){
                 data.materia_slots.push_back(SLOT_LINKED);
             }
@@ -1056,13 +1056,13 @@ int KernelDataInstaller::ReadArmors(){
     File armor_file = kernel_.ExtractGZip(KERNEL_ARMOR_DATA);
     File armor_name_file = kernel_.ExtractGZip(KERNEL_ARMOR_NAMES);
     File armor_desc_file = kernel_.ExtractGZip(KERNEL_ARMOR_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int armor_count = 0;
 
     for (int i = 0; i < 32; i ++){ // There are exactly 32.
 
         ArmorData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -1095,9 +1095,9 @@ int KernelDataInstaller::ReadArmors(){
                     // The offset goes backwards from the position of the 0xF9 byte.
                     u8 comp_offset = armor_desc_file.GetU8(desc_offset + 1) & 63;
 
-                    for (int i = 0; i < comp_size; i ++){
+                    for (int c = 0; c < comp_size; c ++){
                         data.description += ENGLISH_CHARS[
-                          armor_desc_file.GetU8(desc_offset - 1 - comp_offset + i)
+                          armor_desc_file.GetU8(desc_offset - 1 - comp_offset + c)
                         ];
                     }
                     desc_offset ++;
@@ -1121,13 +1121,13 @@ int KernelDataInstaller::ReadArmors(){
         data.m_evasion = armor_file.readU8();
         data.status = armor_file.readU8();
         data.unknown_1 = armor_file.readU16LE();
-        for (int i = 0; i < 8; i ++) data.slots_raw[i] = armor_file.readU8();
+        for (int s = 0; s < 8; s ++) data.slots_raw[s] = armor_file.readU8();
         data.growth = armor_file.readU8();
         data.equip_raw = armor_file.readU16LE();
         data.element_raw = armor_file.readU16LE();
         data.unknown_2 = armor_file.readU16LE();
-        for (int i = 0; i < 4; i ++) data.stat_raw[i] = armor_file.readU8();
-        for (int i = 0; i < 4; i ++) data.stat_bonus_raw[i] = armor_file.readU8();
+        for (int s = 0; s < 4; s ++) data.stat_raw[s] = armor_file.readU8();
+        for (int s = 0; s < 4; s ++) data.stat_bonus_raw[s] = armor_file.readU8();
         data.restrict_raw = armor_file.readU16LE();
         data.unknown_3 = armor_file.readU16LE();
 
@@ -1148,11 +1148,11 @@ int KernelDataInstaller::ReadArmors(){
         if (data.equip_raw == (data.equip_raw | 0x0100)) data.equip.push_back(8);
         if (data.equip_raw == (data.equip_raw | 0x0200)) data.equip.push_back(9);
         if (data.equip_raw == (data.equip_raw | 0x0400)) data.equip.push_back(10);
-        for (int i = 0; i < 4; i ++){
-            if (data.stat_raw[i] < 0XFF && data.stat_bonus_raw[i] > 0){
+        for (int s = 0; s < 4; s ++){
+            if (data.stat_raw[s] < 0XFF && data.stat_bonus_raw[s] > 0){
                 StatBonus stat_bonus;
-                stat_bonus.stat = data.stat_raw[i];
-                stat_bonus.bonus = data.stat_bonus_raw[i];
+                stat_bonus.stat = data.stat_raw[s];
+                stat_bonus.bonus = data.stat_bonus_raw[s];
                 data.stat_bonus.push_back(stat_bonus);
             }
         }
@@ -1255,13 +1255,13 @@ int KernelDataInstaller::ReadAccessories(){
     File accessory_file = kernel_.ExtractGZip(KERNEL_ACCESSORY_DATA);
     File accessory_name_file = kernel_.ExtractGZip(KERNEL_ACCESSORY_NAMES);
     File accessory_desc_file = kernel_.ExtractGZip(KERNEL_ACCESSORY_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int accessory_count = 0;
 
     for (int i = 0; i < 32; i ++){ // There are exactly 32.
 
         AccessoryData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -1294,9 +1294,9 @@ int KernelDataInstaller::ReadAccessories(){
                     // The offset goes backwards from the position of the 0xF9 byte.
                     u8 comp_offset = accessory_desc_file.GetU8(desc_offset + 1) & 63;
 
-                    for (int i = 0; i < comp_size; i ++){
+                    for (int c = 0; c < comp_size; c ++){
                         data.description += ENGLISH_CHARS[
-                          accessory_desc_file.GetU8(desc_offset - 1 - comp_offset + i)
+                          accessory_desc_file.GetU8(desc_offset - 1 - comp_offset + c)
                         ];
                     }
                     desc_offset ++;
@@ -1312,8 +1312,8 @@ int KernelDataInstaller::ReadAccessories(){
         if ("" == data.name) break;
 
         // Read data from the accessory data section.
-        for (int i = 0; i < 2; i ++) data.stat_raw[i] = accessory_file.readU8();
-        for (int i = 0; i < 2; i ++) data.stat_bonus_raw[i] = accessory_file.readU8();
+        for (int s = 0; s < 2; s ++) data.stat_raw[s] = accessory_file.readU8();
+        for (int s = 0; s < 2; s ++) data.stat_bonus_raw[s] = accessory_file.readU8();
         data.element_defense_mode = accessory_file.readU8();
         data.effect = accessory_file.readU8();
         data.element_raw = accessory_file.readU16LE();
@@ -1369,11 +1369,11 @@ int KernelDataInstaller::ReadAccessories(){
         if (data.equip_raw == (data.equip_raw | 0x0100)) data.equip.push_back(8);
         if (data.equip_raw == (data.equip_raw | 0x0200)) data.equip.push_back(9);
         if (data.equip_raw == (data.equip_raw | 0x0400)) data.equip.push_back(10);
-        for (int i = 0; i < 2; i ++){
-            if (data.stat_raw[i] < 0XFF && data.stat_bonus_raw[i] > 0){
+        for (int s = 0; s < 2; s ++){
+            if (data.stat_raw[s] < 0XFF && data.stat_bonus_raw[s] > 0){
                 StatBonus stat_bonus;
-                stat_bonus.stat = data.stat_raw[i];
-                stat_bonus.bonus = data.stat_bonus_raw[i];
+                stat_bonus.stat = data.stat_raw[s];
+                stat_bonus.bonus = data.stat_bonus_raw[s];
                 data.stat_bonus.push_back(stat_bonus);
             }
         }
@@ -1457,13 +1457,13 @@ int KernelDataInstaller::ReadMateria(){
     File materia_file = kernel_.ExtractGZip(KERNEL_MATERIA_DATA);
     File materia_name_file = kernel_.ExtractGZip(KERNEL_MATERIA_NAMES);
     File materia_desc_file = kernel_.ExtractGZip(KERNEL_MATERIA_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int materia_count = 0;
 
     for (int i = 0; i < 96; i ++){ // There are exactly 96.
 
         MateriaData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -1496,9 +1496,9 @@ int KernelDataInstaller::ReadMateria(){
                     // The offset goes backwards from the position of the 0xF9 byte.
                     u8 comp_offset = materia_desc_file.GetU8(desc_offset + 1) & 63;
 
-                    for (int i = 0; i < comp_size; i ++){
+                    for (int c = 0; c < comp_size; c ++){
                         data.description += ENGLISH_CHARS[
-                          materia_desc_file.GetU8(desc_offset - 1 - comp_offset + i)
+                          materia_desc_file.GetU8(desc_offset - 1 - comp_offset + c)
                         ];
                     }
                     desc_offset ++;
@@ -1740,13 +1740,13 @@ int KernelDataInstaller::ReadKeyItems(){
 
     File key_items_name_file = kernel_.ExtractGZip(KERNEL_KEY_ITEM_NAMES);
     File key_items_desc_file = kernel_.ExtractGZip(KERNEL_KEY_ITEM_DESCRIPTIONS);
-    int name_offset = 0;
-    int desc_offset = 0;
     int key_item_count = 0;
 
     for (int i = 0; i < 128; i ++){
 
         KeyItemData data;
+        int name_offset;
+        int desc_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -1823,12 +1823,12 @@ int KernelDataInstaller::ReadSummonNames(){
     key_items_.clear();
 
     File summon_name_file = kernel_.ExtractGZip(KERNEL_SUMMON_ATTACK_NAMES);
-    int name_offset = 0;
     int summon_count = 0;
 
     for (int i = 0; i < 16; i ++){ // There are exactly 16.
 
         SummonNameData data;
+        int name_offset;
 
         // From the current name file offset, read 16 bytes.
         // This is the pointer to the offset for the item name.
@@ -1980,8 +1980,8 @@ void KernelDataInstaller::WriteInitialSaveMap(std::string file_name){
     std::fstream file;
     file.open(file_name, std::ios::out);
     if (!file) return;
-    int total_count = 0; // Utility to count in loops.
     for (int c = 0; c < 9; c ++){
+        int total_count; // Utility to count in loops.
         SaveMap::Character character = savemap_.characters[c];
         file
           << "Characters[" << c << "] = {\n"

+ 0 - 1
V-Gears-Installer/src/MediaDataInstaller.cpp

@@ -50,7 +50,6 @@ void MediaDataInstaller::InstallSprites(){
         VGears::LGPArchive::FileEntry f = files.at(i);
         if (
           f.file_name != "barre.tex"
-          && f.file_name != "barre.tex"
           && f.file_name != "bins.tex"
           && f.file_name != "cido.tex"
           && f.file_name != "cloud.tex"

+ 3 - 3
V-Gears-Installer/src/common/BinGZipFile.cpp

@@ -41,7 +41,7 @@ BinGZipFile::~BinGZipFile(){}
 File* BinGZipFile::ExtractGZip(u32 file_index){
     if (file_index >= file_count_) return NULL;
     u32 extract_size = 256 * 1024;
-    u8* extract_buffer = (u8*)malloc(extract_size);
+    u8* extract_buffer = static_cast<u8*>(malloc(extract_size));
     int ret;
     z_stream strm;
     u32 offset = InnerGetFileOffset(file_index);
@@ -106,7 +106,7 @@ File* BinGZipFile::ExtractGZip(u32 file_index){
         }
 
         if (ret != Z_STREAM_END){
-            extract_buffer = (u8*) realloc(extract_buffer, extract_size * 2);
+            extract_buffer = static_cast<u8*>(realloc(extract_buffer, extract_size * 2));
             if (extract_buffer == NULL){
                 inflateEnd(&strm);
                 LOGGER->Log(
@@ -114,7 +114,7 @@ File* BinGZipFile::ExtractGZip(u32 file_index){
                 );
                 return NULL;
             }
-            strm.next_out = (u8*)extract_buffer + extract_size;
+            strm.next_out = static_cast<u8*>(extract_buffer + extract_size);
             strm.avail_out = extract_size;
             extract_size *= 2;
         }

+ 4 - 11
V-Gears-Installer/src/common/FontFile.cpp

@@ -39,7 +39,6 @@ FontFile::~FontFile(void){}
 Surface* FontFile::GetSurface(void){
     int width = 512;
     int height = 4096;
-    int chars = 0;
     int char_num = 6165;
     Surface* ret = CreateSurface(width, height);
     int x_16 = 0;
@@ -74,24 +73,18 @@ Surface* FontFile::GetSurface(void){
     };
 
     ClutColor color;
-    color.r = 0;
-    color.g = 0;
-    color.b = 0;
-    color.a = 255;
-    u8 data = 0;
-
 
     for (int chars = 0; chars < char_num; ++chars){
         Surface* glyth = CreateSurface(16, 16);
         for (int y = 0; y < 16; ++ y){
-            data = (y < 11) ? GetU8(0xE + chars * 22 + y * 2 + 0) : 0;
+            u8 data = (y < 11) ? GetU8(0xE + chars * 22 + y * 2 + 0) : 0;
             //LOGGER->Log(LOGGER_INFO, "%x, %02x", y, data);
             int j = 0;
             for (int i = 7; i >= 0; -- i){
                 color.r = (((data >> i) & 0x01) == 1) ? 0 : 255;
                 color.g = (((data >> i) & 0x01) == 1) ? 0 : 255;
                 color.b = (((data >> i) & 0x01) == 1) ? 0 : 255;
-                color.a = (((data >> i) & 0x01) == 1) ? 255 : 255;
+                color.a = 255;
                 memcpy(
                   glyth->pixels.data() + 64 * y + j, &color, sizeof(ClutColor)
                 );
@@ -103,7 +96,7 @@ Surface* FontFile::GetSurface(void){
                 color.r = (((data >> i) & 0x01) == 1) ? 0 : 255;
                 color.g = (((data >> i) & 0x01) == 1) ? 0 : 255;
                 color.b = (((data >> i) & 0x01) == 1) ? 0 : 255;
-                color.a = (((data >> i) & 0x01) == 1) ? 255 : 255;
+                color.a = 255;
                 memcpy(
                   glyth->pixels.data() + 64 * y + j, &color, sizeof(ClutColor)
                 );
@@ -131,7 +124,7 @@ Surface* FontFile::GetSurface(void){
     for (auto y = 0; y < ret->height; ++ y){
         // IVV type cast
         auto* data = static_cast<unsigned int*> (
-          (unsigned int *)(pb.data) + y * pb.rowPitch
+          reinterpret_cast<unsigned int *>(pb.data) + y * pb.rowPitch
         );
         for (auto x = 0; x < ret->width; ++ x){
             auto clut

+ 0 - 2
V-Gears-Installer/src/common/OgreBase.cpp

@@ -98,8 +98,6 @@ void InitializeOgreBase(const Ogre::String& name){
     Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     Ogre::SceneManager* scene_manager;
     Ogre::Viewport* viewport;
-    Ogre::FontManager* fmgr = new Ogre::FontManager;
-    Ogre::OverlayManager* overlay = new Ogre::OverlayManager();
     frame_listener = new DisplayFrameListener(window);
     root->addFrameListener(frame_listener);
     scene_manager = root->createSceneManager(Ogre::ST_GENERIC, "Scene");

+ 4 - 4
V-Gears/CMakeLists.txt

@@ -21,8 +21,8 @@ set(HEADER_FILES
     include/LuaIncludes.h
     include/VGearsGameState.h
     include/VGearsPrerequisites.h
-    include/core/particles/emitters/ParticlePointEmitter.h
-    include/core/particles/emitters/ParticlePointEmitterFactory.h
+    include/core/particles/emitters/PointEmitter.h
+    include/core/particles/emitters/PointEmitterFactory.h
     include/core/particles/renderer/ParticleEntityAdditionalData.h
     include/core/particles/renderer/ParticleEntityRenderer.h
     include/core/particles/renderer/ParticleEntityRendererDictionary.h
@@ -221,7 +221,8 @@ set(SOURCE_FILES
     src/common/LzsFile.cpp
     src/common/File.cpp
     src/common/FileSystem.cpp
-    src/core/particles/emitters/ParticlePointEmitter.cpp
+    src/core/particles/emitters/PointEmitter.cpp
+    src/core/particles/emitters/PointEmitterFactory.cpp
     src/core/particles/Particle.cpp
     src/core/particles/ParticleEmitter.cpp
     src/core/particles/ParticleEmitterDictionary.cpp
@@ -290,7 +291,6 @@ set(SOURCE_FILES
     src/map/VGearsWalkmeshFile.cpp
     src/map/VGearsWalkmeshFileManager.cpp
     src/map/VGearsWalkmeshFileXMLSerializer.cpp
-    #src/viewer/ViewerModule.cpp
     src/VGearsGameState.cpp
     src/data/VGearsXMLSerializer.cpp
     src/common/FinalFantasy7/FF7NameLookup.cpp

+ 81 - 38
V-Gears/include/core/EntityManager.h

@@ -161,8 +161,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * @param[in] rotation The point orientation.
          */
         void AddEntityPoint(
-          const Ogre::String& name, const Ogre::Vector3& position,
-          const float rotation
+          const Ogre::String& name, const Ogre::Vector3& position, const float rotation
         );
 
         /**
@@ -183,8 +182,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * Retrieves an entity by name.
          *
          * @param[in] name Name of the entity to retrieve.
-         * @return The entity by the specified name, or nullptr if there is no
-         * one.
+         * @return The entity by the specified name, or nullptr if there is no one.
          */
         Entity* GetEntity(const Ogre::String& name) const;
 
@@ -200,8 +198,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * Retrieves an entity by it's assigned character ID.
          *
          * @param[in] id Character ID of the entity to retrieve.
-         * @return The entity assigned to the character, or nullptr if there
-         * is no one.
+         * @return The entity assigned to the character, or nullptr if there is no one.
          */
         Entity* GetEntityFromCharacterId(const int id) const;
 
@@ -209,8 +206,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * Retrieves an entity by name.
          *
          * @param[in] name Name of the entity to retrieve.
-         * @return The entity by the specified name, or nullptr if there is no
-         * one.
+         * @return The entity by the specified name, or nullptr if there is no one.
          */
         Entity* ScriptGetEntity(const char* name) const;
 
@@ -218,17 +214,15 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * Retrieves an entity point by name.
          *
          * @param[in] name Name of the entity point to retrieve.
-         * @return The entity point by the specified name, or nullptr if there
-         * is no one.
+         * @return The entity point by the specified name, or nullptr if there is no one.
          */
         EntityPoint* ScriptGetEntityPoint(const char* name) const;
 
         /**
          * Sets the playable entity.
          *
-         * If no entities are found by name, no one will be assigned, the
-         * previous playable entity will remain so, and no warning will be
-         * issued.
+         * If no entities are found by name, no one will be assigned, the previous playable entity
+         * will remain so, and no warning will be issued.
          *
          * @param[in] name Name of the entity to make playable.
          */
@@ -271,8 +265,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
         /**
          * Enables or disables random encounters in the field.
          *
-         * @param[in] active True to enable encounters, false to deactivate
-         * them.
+         * @param[in] active True to enable encounters, false to deactivate them.
          */
         void SetRandomEncounters(bool active);
 
@@ -294,8 +287,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * Starts a battle.
          *
          * @param[in] formation The enemy formation to fight.
-         * @return True if the battle victory conditions are met, false
-         * otherwise.
+         * @return True if the battle victory conditions are met, false otherwise.
          * @todo Implement
          */
         bool StartBattleForResult(unsigned int formation);
@@ -334,17 +326,72 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
 
     private:
 
+        /**
+         * Calculates the point elevation over a plane.
+         *
+         * @param[in] point Point to calculate the elevation of.
+         * @param[in] a First point of the plane.
+         * @param[in] b Second point of the plane.
+         * @param[in] c Third  point of the plane.
+         * @return The elevation of the point.
+         */
+        static float PointElevation(
+          const Ogre::Vector2& point,
+          const Ogre::Vector3& a, const Ogre::Vector3& b, const Ogre::Vector3& c
+        );
+
+        /**
+         * Determines at which side of a line a point is.
+         *
+         * @param[in] point The point to evaluate.
+         * @param[in] p1 The first point of the line.
+         * @param[in] p2 The second point of the line.
+         * @return A negative value if the point is on the "left" of the line vector, a positive
+         * value if the point is on the "right" of the vector line, or 0 if the point is part of
+         * the line. "Left" and "right" are determined by going from p1 to p2.
+         */
+        static float SideOfVector(
+          const Ogre::Vector2& point, const Ogre::Vector2& p1, const Ogre::Vector2& p2
+        );
+
+        /**
+         * Calculates the square distance between a point and a line.
+         *
+         * The calculated distance is the vector orthogonal to the line that passes by the point,
+         * i.e. the shortest distance.
+         *
+         * @param[in] point The point.
+         * @param[in] point_a First point of the line.
+         * @param[in] point_b Second point of the line.
+         * @param[out] proj Vector representing the shortest distance.
+         * @return The distance from the point to the line.
+         */
+        static float SquareDistanceToLine(
+          const Ogre::Vector3& point, const Ogre::Vector3& point_a, const Ogre::Vector3& point_b,
+          Ogre::Vector3& proj
+        );
+
+        /**
+         * Calculates the direction degree between to points.
+         *
+         * @param[in] current_point Origin point.
+         * @param[in] direction_point Next point in the direction.
+         * @return Degrees between the two points
+         */
+        static Ogre::Degree GetDirectionToPoint(
+          const Ogre::Vector3& current_point, const Ogre::Vector3& direction_point
+        );
+
         /**
          * Attaches an entity to the walkmesh.
          *
-         * It sets the triangle from the entity position coordinates. To
-         * account for multiple triangles on different levels, it uses only
-         * the X and Y coordinates, and automatically sets the Z one to the
-         * closest triangle.
+         * It sets the triangle from the entity position coordinates. To account for multiple
+         * triangles on different levels, it uses only the X and Y coordinates, and automatically
+         * sets the Z one to the closest triangle.
          *
          * @param[in] entity Entity to attach.
-         * @return True if the entity was assigned to a walkmesh triangle,
-         * false if the entity is not in a triangle.
+         * @return True if the entity was assigned to a walkmesh triangle, false if the entity is
+         * not in a triangle.
          */
         bool SetEntityOnWalkmesh(Entity* entity);
 
@@ -353,8 +400,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          *
          * @param[in] entity Entity to move.
          * @param[in] speed Movement speed.
-         * @return True if the movement was possible and the entity was moved,
-         * false otherwise.
+         * @return True if the movement was possible and the entity was moved, false otherwise.
          */
         bool PerformWalkmeshMove(Entity* entity, const float speed);
 
@@ -364,8 +410,7 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * @param[in] entity Entity to check.
          * @param[in] position The position. @todo document more.
          * @param[in] move_vector The move vector. @todo document more.
-         * @return True if the entity is crossing a triangle border, false
-         * otherwise.
+         * @return True if the entity is crossing a triangle border, false otherwise.
          */
         bool WalkmeshBorderCross(
           Entity* entity, Ogre::Vector3& position, const Ogre::Vector2& move_vector
@@ -376,8 +421,8 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          *
          * @param[in] entity Entity to check for collisions.
          * @param[in] position Position of the entity.
-         * @return True if the entity is colliding with another, false
-         * otherwise. If the entity is not solid, always false.
+         * @return True if the entity is colliding with another, false otherwise. If the entity is
+         * not solid, always false.
          */
         bool CheckSolidCollisions(Entity* entity, Ogre::Vector3& position);
 
@@ -392,10 +437,9 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
         /**
          * Checks for entity triggers near a entity.
          *
-         * If there are triggers, and the conditions are met, the appropriate
-         * trigger function will be added to the queue. This must be tested
-         * every time an entity moves. If the entity is not solid, it will do
-         * nothing.
+         * If there are triggers, and the conditions are met, the appropriate trigger function will
+         * be added to the queue. This must be tested every time an entity moves. If the entity is
+         * not solid, it will do nothing.
          *
          * @param[in] entity Entity to check for nearby triggers.
          * @param[in] position The position of the entity.
@@ -405,15 +449,14 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
         /**
          * Checks if an entity can be interacted.
          *
-         * It checks if there are entities that can be interacted with from the
-         * players current position and orientation. If there are, the most
-         * appropriate one is selected and, if it has an on_interact script, it
-         * is run.
+         * It checks if there are entities that can be interacted with from the players current
+         * position and orientation. If there are, the most appropriate one is selected and, if it
+         * has an on_interact script, it is run.
          */
         void CheckEntityInteract();
 
         /**
-         * Calculates the next offset step for an entity
+         * Calculates the next offset step for an entity.
          *
          * @param[in] entity The entity.
          */

+ 7 - 9
V-Gears/include/core/GameFrameListener.h

@@ -48,19 +48,17 @@ class GameFrameListener :
          *
          * This event happens before any render targets have begun updating.
          *
-         * @return True to go ahead, false to abort rendering and drop out of
-         * the rendering loop.
+         * @return True to go ahead, false to abort rendering and drop out of the rendering loop.
          */
         bool frameStarted(const Ogre::FrameEvent& evt);
 
         /**
          * Called just after a frame has been rendered.
          *
-         * This event happens after all render targets have been fully updated
-         * and the buffers switched.
+         * This event happens after all render targets have been fully updated and the buffers
+         * switched.
          *
-         * @return True to continue with the next frame, false to drop out of
-         * the rendering loop.
+         * @return True to continue with the next frame, false to drop out of the rendering loop.
          */
         bool frameEnded(const Ogre::FrameEvent& evt);
 
@@ -139,16 +137,16 @@ class GameFrameListener :
         /**
          * The input manager.
          */
-        OIS::InputManager*  input_manager_;
+        OIS::InputManager* input_manager_;
 
         /**
          * The keyboard.
          */
-        OIS::Keyboard*      keyboard_;
+        OIS::Keyboard* keyboard_;
 
         /**
          * The mouse.
          */
-        OIS::Mouse*         mouse_;
+        OIS::Mouse* mouse_;
 };
 

+ 2 - 3
V-Gears/include/core/UiTextArea.h

@@ -176,8 +176,7 @@ class UiTextArea : public UiWidget{
          *
          * @param[in] name Name for the textarea.
          * @param[in] path_name Path for the widget.
-         * @param[in] parent Pointer to the widget that will parent the
-         * UiTextArea.
+         * @param[in] parent Pointer to the widget that will parent the UiTextArea.
          */
         UiTextArea(const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent);
 
@@ -288,7 +287,7 @@ class UiTextArea : public UiWidget{
         void TextClear();
 
         /**
-         * @todo Understand and document.
+         * Removes the prites from the text.
          *
          * @param[in] end @todo Understand and document.
          */

+ 32 - 49
V-Gears/include/core/UiWidget.h

@@ -68,8 +68,7 @@ class UiWidget{
         /**
          * Handles resizing events.
          *
-         * Recalculates the widget geometry and calls OnResize for all the
-         * widget children.
+         * Recalculates the widget geometry and calls OnResize for all the widget children.
          */
         void OnResize();
 
@@ -81,8 +80,7 @@ class UiWidget{
         /**
          * Toggles the widget visibility.
          *
-         * @param[in] visible True to make the widget visible, false to make it
-         * invisible.
+         * @param[in] visible True to make the widget visible, false to make it invisible.
          */
         void SetVisible(const bool visible);
 
@@ -111,8 +109,8 @@ class UiWidget{
          * Retrieves a children by name.
          *
          * @param[in] name Name of the children widget to retrieve.
-         * @return The children widget by the specified name. NULL if the
-         * widgets has no direct children by that name.
+         * @return The children widget by the specified name. NULL if the widgets has no direct
+         * children by that name.
          */
         UiWidget* GetChild(const Ogre::String& name);
 
@@ -120,8 +118,8 @@ class UiWidget{
          * Retrieves a children by ID.
          *
          * @param[in] id ID of the children widget to retrieve.
-         * @return The children widget by the specified name. NULL if the
-         * widgets has no direct children by that ID.
+         * @return The children widget by the specified name. NULL if the widgets has no direct
+         * children by that ID.
          */
         UiWidget* GetChild(const unsigned int id);
 
@@ -147,8 +145,7 @@ class UiWidget{
         /**
          * Retrieves the current animation name.
          *
-         * @return The current animation name. A blankstring if there is no set
-         * default animation.
+         * @return The current animation name. A blankstring if there is no animation.
          */
         const Ogre::String& GetCurrentAnimationName() const;
 
@@ -165,8 +162,7 @@ class UiWidget{
          * @param[in] animation Animation to play.
          * @param[in] state Initial animation state.
          * @param[in] start Seconds at which to start the animation.
-         * @param[in] end Seconds at which to end the animation. -1 to play
-         * it in full.
+         * @param[in] end Seconds at which to end the animation. -1 to play it in full.
          */
         void PlayAnimation(
           const Ogre::String& animation, UiAnimation::State state,
@@ -179,17 +175,15 @@ class UiWidget{
          * The animation will be played from the start for it's full length.
          *
          * @param[in] name The name of the animation to play.
-         * @todo It uses the parameter UiAnimation::DEFAULT. What does it do?
-         * Does it play the animation in a loop, or uses a default value of the
-         * specific animation.
+         * @todo It uses the parameter UiAnimation::DEFAULT. What does it do? Does it play the
+         * animation in a loop, or uses a default value of the specific animation.
          */
         void ScriptPlayAnimation(const char* name);
 
         /**
          * Plays an animation.
          *
-         * The animation will be played from the start for it's full length,
-         * only once.
+         * The animation will be played from the start for it's full length, only once.
          *
          * @param[in] name The name of the animation to play.
          */
@@ -198,11 +192,9 @@ class UiWidget{
         /**
          * @param[in] name Name of the animation to play.
          * @param[in] start Seconds at which to start the animation.
-         * @param[in] end Seconds at which to end the animation. -1 to play
-         * it in full.
-         * @todo It uses the parameter UiAnimation::DEFAULT. Whats does it do?
-         * Does it play the animation in a loop, or uses a default value of the
-         * specific animation.
+         * @param[in] end Seconds at which to end the animation. -1 to play it in full.
+         * @todo It uses the parameter UiAnimation::DEFAULT. Whats does it do? Does it play the
+         * animation in a loop, or uses a default value of the specific animation.
          */
         void ScriptPlayAnimation(const char* name, const float start, const float end);
 
@@ -458,19 +450,18 @@ class UiWidget{
         /**
          * Sets the widget scissor area.
          *
-         * @param[in] percent_x1 @todo Undersnd and document.
-         * @param[in] x1 @todo Undersnd and document.
-         * @param[in] percent_y1 @todo Undersnd and document.
-         * @param[in] y1 @todo Undersnd and document.
-         * @param[in] percent_x2 @todo Undersnd and document.
-         * @param[in] x2 @todo Undersnd and document.
-         * @param[in] percent_y2 @todo Undersnd and document.
-         * @param[in] y2 @todo Undersnd and document.
+         * @param[in] percent_x1 @todo Understand and document.
+         * @param[in] x1 @todo Understand and document.
+         * @param[in] percent_y1 @todo Understand and document.
+         * @param[in] y1 @todo Understand and document.
+         * @param[in] percent_x2 @todo Understand and document.
+         * @param[in] x2 @todo Understand and document.
+         * @param[in] percent_y2 @todo Understand and document.
+         * @param[in] y2 @todo Understand and document.
          */
         void SetScissorArea(
-          const float percent_x1, const float x1, const float percent_y1,
-          const float y1, const float percent_x2, const float x2,
-          const float percent_y2, const float y2
+          const float percent_x1, const float x1, const float percent_y1, const float y1,
+          const float percent_x2, const float x2, const float percent_y2, const float y2
         );
 
         /**
@@ -492,28 +483,20 @@ class UiWidget{
         /**
          * Sets the widget colour.
          *
-         * It set the same colours for each corner, and blends it in the
-         * interior.
+         * It set the same colours for each corner, and blends it in the interior.
          *
          * @param[in] r1 Colour red component for the top-left corner (0-255).
-         * @param[in] g1 Colour green component for the top-left corner
-         * (0-255).
+         * @param[in] g1 Colour green component for the top-left corner (0-255).
          * @param[in] b1 Colour blue component for the top-left corner (0-255).
          * @param[in] r2 Colour red component for the top-right corner (0-255).
-         * @param[in] g2 Colour green component for the top-right corner
-         * (0-255).
+         * @param[in] g2 Colour green component for the top-right corner (0-255).
          * @param[in] b2 Colour blue component for the top-right corner (0-255).
          * @param[in] r3 Colour red component for the bottom-right corner (0-255).
-         * @param[in] g3 Colour green component for the bottom-right corner
-         * (0-255).
-         * @param[in] b3 Colour blue component for the bottom-right corner
-         * (0-255).
-         * @param[in] r4 Colour red component for the bottom-left corner
-         * (0-255).
-         * @param[in] g4 Colour green component for the bottom-left corner
-         * (0-255).
-         * @param[in] b4 Colour blue component for the bottom-left corner
-         * (0-255).
+         * @param[in] g3 Colour green component for the bottom-right corner (0-255).
+         * @param[in] b3 Colour blue component for the bottom-right corner (0-255).
+         * @param[in] r4 Colour red component for the bottom-left corner (0-255).
+         * @param[in] g4 Colour green component for the bottom-left corner (0-255).
+         * @param[in] b4 Colour blue component for the bottom-left corner (0-255).
          */
         void SetColours(
           const float r1, const float g1, const float b1,

+ 24 - 41
V-Gears/include/core/Utilites.h

@@ -26,16 +26,15 @@
 
 // TODO: All the methods defined here that refer to XML files are implemented
 // as methods of XmlFile. Can they be deleted from here?
+// TODO: Also, a lot of functions are never actually called.
 
 /**
  * Retrieves a boolean from an XMl tag.
  *
  * @param[in] node The XML node.
  * @param[in] tag The name of the tag.
- * @param[in] def Default value, in case the tag is not found or it's not a
- * boolean value.
- * @return Boolean value of the tag. If it's not found or it's not a boolean,
- * def is returned.
+ * @param[in] def Default value, in case the tag is not found or it's not a boolean value.
+ * @return Boolean value of the tag. If it's not found or it's not a boolean, def is returned.
  */
 bool GetBool(TiXmlNode* node, const Ogre::String& tag, bool def = false);
 
@@ -44,10 +43,8 @@ bool GetBool(TiXmlNode* node, const Ogre::String& tag, bool def = false);
  *
  * @param[in] node The XML node.
  * @param[in] tag The name of the tag.
- * @param[in] def Default value, in case the tag is not found or it's not a
- * numeric value.
- * @return Integer value of the tag. If it's not found or it's not a number,
- * def is returned.
+ * @param[in] def Default value, in case the tag is not found or it's not a numeric value.
+ * @return Integer value of the tag. If it's not found or it's not a number, def is returned.
  */
 int GetInt(TiXmlNode* node, const Ogre::String& tag, int def = 0);
 
@@ -56,10 +53,8 @@ int GetInt(TiXmlNode* node, const Ogre::String& tag, int def = 0);
  *
  * @param[in] node The XML node.
  * @param[in] tag The name of the tag.
- * @param[in] def Default value, in case the tag is not found or it's not a
- * numeric value.
- * @return Floating value of the tag. If it's not found or it's not a number,
- * def is returned.
+ * @param[in] def Default value, in case the tag is not found or it's not a numeric value.
+ * @return Floating value of the tag. If it's not found or it's not a number, def is returned.
  */
 float GetFloat(TiXmlNode* node, const Ogre::String& tag, float def = 0.0f);
 
@@ -96,8 +91,7 @@ const Ogre::UTFString GetUTFString(
  * @return Vector in the tag. If it's not found, def is returned.
  */
 const Ogre::Vector2 GetVector2(
-  TiXmlNode* node, const Ogre::String& tag,
-  const Ogre::Vector2& def = Ogre::Vector2::ZERO
+  TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def = Ogre::Vector2::ZERO
 );
 
 /**
@@ -109,8 +103,7 @@ const Ogre::Vector2 GetVector2(
  * @return Vector in the tag. If it's not found, def is returned.
  */
 const Ogre::Vector3 GetVector3(
-  TiXmlNode* node, const Ogre::String& tag,
-  const Ogre::Vector3& def = Ogre::Vector3::ZERO
+  TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def = Ogre::Vector3::ZERO
 );
 
 /**
@@ -122,8 +115,7 @@ const Ogre::Vector3 GetVector3(
  * @return Vector in the tag. If it's not found, def is returned.
  */
 const Ogre::Vector4 GetVector4(
-  TiXmlNode* node, const Ogre::String& tag,
-  const Ogre::Vector4& def = Ogre::Vector4::ZERO
+  TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def = Ogre::Vector4::ZERO
 );
 
 /**
@@ -135,8 +127,7 @@ const Ogre::Vector4 GetVector4(
  * @return Martix in the tag. If it's not found, def is returned.
  */
 const Ogre::Matrix4 GetMatrix4(
-  TiXmlNode* node, const Ogre::String& tag,
-  const Ogre::Matrix4& def = Ogre::Matrix4::IDENTITY
+  TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def = Ogre::Matrix4::IDENTITY
 );
 
 /**
@@ -148,8 +139,7 @@ const Ogre::Matrix4 GetMatrix4(
  * @return quaternion in the tag. If it's not found, def is returned.
  */
 const Ogre::Quaternion GetQuaternion(
-  TiXmlNode* node, const Ogre::String& tag,
-  const Ogre::Quaternion& def = Ogre::Quaternion::IDENTITY
+  TiXmlNode* node, const Ogre::String& tag, const Ogre::Quaternion& def = Ogre::Quaternion::IDENTITY
 );
 
 /**
@@ -161,15 +151,13 @@ const Ogre::Quaternion GetQuaternion(
  * @return Colour in the tag. If it's not found, def is returned.
  */
 const Ogre::ColourValue GetColourValue(
-  TiXmlNode* node, const Ogre::String& tag,
-  const Ogre::ColourValue& def = Ogre::ColourValue::ZERO
+  TiXmlNode* node, const Ogre::String& tag, const Ogre::ColourValue& def = Ogre::ColourValue::ZERO
 );
 
 /**
  * Parses percentage strings
  *
- * Accepts strings in the formats "A" "A%" "A%B", where A and B are real
- * values.
+ * Accepts strings in the formats "A" "A%" "A%B", where A and B are real values.
  *
  * Examples:
  *   "80.4%" -> value = 0, percent_value = 80.4
@@ -180,15 +168,12 @@ const Ogre::ColourValue GetColourValue(
  * @param[out] value String numeric value.
  * @param[in] string Input string.
  */
-void ParsePercent(
-  float& value_percent, float& value, const Ogre::String& string
-);
+void ParsePercent(float& value_percent, float& value, const Ogre::String& string);
 
 /**
  * Parses a keyframe time string.
  *
- * It acceps input string of numeric values and numeric values followed by a
- * percentage sign.
+ * It accepts input string of numeric values and numeric values followed by a percentage sign.
  *
  * Examples:
  *   "7.2" -> 7.2
@@ -213,8 +198,8 @@ const Ogre::String CreateAutoName(const Ogre::String prefix);
  * Obtains a name from a key code.
  *
  * @param[in] key Key code.
- * @return Human readable name assigned to the key code. "UNASSIGNED" if there
- * is no name for the key code.
+ * @return Human readable name assigned to the key code. "UNASSIGNED" if there is no name for the
+ * key code.
  */
 Ogre::String KeyToString(OIS::KeyCode key);
 
@@ -222,8 +207,8 @@ Ogre::String KeyToString(OIS::KeyCode key);
  * Obtains a key code from a name.
  *
  * @param[in] str Key name.
- * @return Key code assigned to the name. OIS::KC_UNASSIGNED  if there is no
- * keycode with the specified name.
+ * @return Key code assigned to the name. OIS::KC_UNASSIGNED  if there is no keycode with the
+ * specified name.
  */
 OIS::KeyCode StringToKey(const Ogre::String& str);
 
@@ -231,13 +216,11 @@ OIS::KeyCode StringToKey(const Ogre::String& str);
  * Tokenizes a string.
  *
  * @param[in] str Input string.
- * @param[in] delimiters Token delimiters. They will be stripped from the
- * string.
- * @param[in] delimiters_preserve More token delimiters. They will be returned
- * as individual tokens.
+ * @param[in] delimiters Token delimiters. They will be stripped from the string.
+ * @param[in] delimiters_preserve More token delimiters. They will be returned as individual tokens.
  * @param[in] quote @todo Understand and document.
- * @param[in] esc Accepted escape characters. Escaped characters won't be
- * considered delimiters of any kind.
+ * @param[in] esc Accepted escape characters. Escaped characters won't be considered delimiters of
+ * any kind.
  * @return Tokens of the original string.
  */
 Ogre::StringVector StringTokenise(

+ 8 - 8
V-Gears/include/core/Walkmesh.h

@@ -62,6 +62,9 @@ namespace VGears{
     typedef Ogre::SharedPtr<class WalkmeshFile> WalkmeshFilePtr;
 }
 
+/**
+ * A walkmesh.
+ */
 class Walkmesh{
 
     public:
@@ -98,8 +101,8 @@ class Walkmesh{
          *
          * @param[in] triangle_id Triangle.
          * @param[in] side The side index in the triangle.
-         * @return The id of the triangle accessed from the indicated triangle
-         * and side, or -1 if no triangle can be accessed.
+         * @return The id of the triangle accessed from the indicated triangle and side, or -1 if
+         * no triangle can be accessed.
          */
         int GetAccessSide(unsigned int triangle_id, unsigned char side) const;
 
@@ -107,8 +110,7 @@ class Walkmesh{
          * Retrieves the first side of a triangle.
          *
          * @param[in] triangle_id ID of the triangle.
-         * @return The side of the triangle. Ogre::Vector3::ZERO if the
-         * triangle doesn't exist.
+         * @return The side of the triangle. Ogre::Vector3::ZERO if the triangle doesn't exist.
          */
         const Ogre::Vector3& GetA(unsigned int triangle_id) const;
 
@@ -116,8 +118,7 @@ class Walkmesh{
          * Retrieves the second side of a triangle.
          *
          * @param[in] triangle_id ID of the triangle.
-         * @return The side of the triangle. Ogre::Vector3::ZERO if the
-         * triangle doesn't exist.
+         * @return The side of the triangle. Ogre::Vector3::ZERO if the triangle doesn't exist.
          */
         const Ogre::Vector3& GetB(unsigned int triangle_id) const;
 
@@ -125,8 +126,7 @@ class Walkmesh{
          * Retrieves the third side of a triangle.
          *
          * @param[in] triangle_id ID of the triangle.
-         * @return The side of the triangle. Ogre::Vector3::ZERO if the
-         * triangle doesn't exist.
+         * @return The side of the triangle. Ogre::Vector3::ZERO if the triangle doesn't exist.
          */
         const Ogre::Vector3& GetC(unsigned int triangle_id) const;
 

+ 16 - 28
V-Gears/include/core/XmlFile.h

@@ -47,24 +47,20 @@ class XmlFile{
          *
          * @param[in] node The XML node.
          * @param[in] tag The name of the tag.
-         * @param[in] def Default value, in case the tag is not found or it's
-         * not a boolean value.
-         * @return Boolean value of the tag. If it's not found or it's not a
-         * boolean, def is returned.
+         * @param[in] def Default value, in case the tag is not found or it's not a boolean value.
+         * @return Boolean value of the tag. If it's not found or it's not a boolean, def is
+         * returned.
          */
-        bool GetBool(
-          TiXmlNode* node, const Ogre::String& tag, bool def = false
-        ) const;
+        bool GetBool(TiXmlNode* node, const Ogre::String& tag, bool def = false) const;
 
         /**
          * Retrieves an integer from an XMl tag.
          *
          * @param[in] node The XML node.
          * @param[in] tag The name of the tag.
-         * @param[in] def Default value, in case the tag is not found or it's
-         * not a numeric value.
-         * @return Integer value of the tag. If it's not found or it's not a
-         * number, def is returned.
+         * @param[in] def Default value, in case the tag is not found or it's not a numeric value.
+         * @return Integer value of the tag. If it's not found or it's not a number, def is
+         * returned.
          */
         int GetInt(TiXmlNode* node, const Ogre::String& tag, int def = 0) const;
 
@@ -73,14 +69,11 @@ class XmlFile{
          *
          * @param[in] node The XML node.
          * @param[in] tag The name of the tag.
-         * @param[in] def Default value, in case the tag is not found or it's
-         * not a numeric value.
-         * @return Decimal value of the tag. If it's not found or it's not a
-         * number, def is returned.
+         * @param[in] def Default value, in case the tag is not found or it's not a numeric value.
+         * @return Decimal value of the tag. If it's not found or it's not a number, def is
+         * returned.
          */
-        float GetFloat(
-          TiXmlNode* node, const Ogre::String& tag, float def = 0.0f
-        ) const;
+        float GetFloat(TiXmlNode* node, const Ogre::String& tag, float def = 0.0f) const;
 
         /**
          * Retrieves a string from an XMl tag.
@@ -100,12 +93,10 @@ class XmlFile{
          * @param[in] node The XML node.
          * @param[in] tag The name of the tag.
          * @param[in] def Default value, in case the tag is not found.
-         * @return String value of the tag, in UFT8. If not found, def is
-         * returned.
+         * @return String value of the tag, in UFT8. If not found, def is returned.
          */
         const Ogre::UTFString GetUTFString(
-          TiXmlNode* node, const Ogre::String& tag,
-          const Ogre::UTFString& def = ""
+          TiXmlNode* node, const Ogre::String& tag, const Ogre::UTFString& def = ""
         ) const;
 
         /**
@@ -117,8 +108,7 @@ class XmlFile{
          * @return Vector in the tag. If it's not found, def is returned.
          */
         const Ogre::Vector2 GetVector2(
-          TiXmlNode* node, const Ogre::String& tag,
-          const Ogre::Vector2& def = Ogre::Vector2::ZERO
+          TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def = Ogre::Vector2::ZERO
         ) const;
 
         /**
@@ -130,8 +120,7 @@ class XmlFile{
          * @return Vector in the tag. If it's not found, def is returned.
          */
         const Ogre::Vector3 GetVector3(
-          TiXmlNode* node, const Ogre::String& tag,
-          const Ogre::Vector3& def = Ogre::Vector3::ZERO
+          TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def = Ogre::Vector3::ZERO
         ) const;
 
         /**
@@ -143,8 +132,7 @@ class XmlFile{
          * @return Vector in the tag. If it's not found, def is returned.
          */
         const Ogre::Vector4 GetVector4(
-          TiXmlNode* node, const Ogre::String& tag,
-          const Ogre::Vector4& def = Ogre::Vector4::ZERO
+          TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def = Ogre::Vector4::ZERO
         ) const;
 
         /**

+ 2 - 3
V-Gears/include/core/XmlMapFile.h

@@ -44,9 +44,8 @@ class XmlMapFile : public XmlFile{
         /**
          * Retrieves the path to the map walkmesh file.
          *
-         * @return The path to the map walkmesh file. If there is no walkmesh
-         * associated to the map, an error  message will be written to console
-         * and an empty string will be returned.
+         * @return The path to the map walkmesh file. If there is no walkmesh associated to the
+         * map, an error  message will be written to console and an empty string will be returned.
          */
         const Ogre::String GetWalkmeshFileName();
 };

+ 3 - 4
V-Gears/include/core/XmlMapsFile.h

@@ -41,16 +41,15 @@ class XmlMapsFile : public XmlFile{
          * Retrieves a map file by map name.
          *
          * @param[in] name Name of the map to look for.
-         * @return Path to the specified map file, or an empty string if there
-         * is no file for such map.
+         * @return Path to the specified map file, or an empty string if there is no file for such
+         * map.
          */
         const Ogre::String GetMapFileNameByName(const Ogre::String& name);
 
         /**
          * Retrieves a list of map names.
          *
-         * @param[out] complete_params The list of map names will be loaded
-         * here.
+         * @param[out] complete_params The list of map names will be loaded here.
          */
         void GetMapNames(Ogre::StringVector& complete_params);
 };

+ 1 - 3
V-Gears/include/core/XmlPrototypesFile.h

@@ -18,9 +18,7 @@
 #include "XmlFile.h"
 
 /**
- * Handles the main prototypes file.
- *
- * @todo What are prototypes? What's in the file?
+ * Handles the main XML prototypes file.
  */
 class XmlPrototypesFile : public XmlFile{
 

+ 1 - 3
V-Gears/include/core/XmlScreenFile.h

@@ -49,7 +49,5 @@ class XmlScreenFile : public XmlFile{
          * @param[in] base_name Name for the top widget in the XML node.
          * @param[in] widget Top parent widget.
          */
-        void LoadScreenRecursive(
-          TiXmlNode* node, const Ogre::String& base_name, UiWidget* widget
-        );
+        void LoadScreenRecursive(TiXmlNode* node, const Ogre::String& base_name, UiWidget* widget);
 };

+ 0 - 0
V-Gears/include/core/particles/emitters/ParticlePointEmitter.h → V-Gears/include/core/particles/emitters/PointEmitter.h


+ 7 - 11
V-Gears/include/core/particles/emitters/ParticlePointEmitterFactory.h → V-Gears/include/core/particles/emitters/PointEmitterFactory.h

@@ -15,11 +15,11 @@
 
 #pragma once
 
-#include "ParticlePointEmitter.h"
-#include "../ParticleEmitterFactory.h"
+#include "core/particles/ParticleEmitterFactory.h"
+#include "PointEmitter.h"
 
 /**
- * A particle emitter factory.
+ * A point emitter factory.
  */
 class PointEmitterFactory : public ParticleEmitterFactory{
 
@@ -28,28 +28,24 @@ class PointEmitterFactory : public ParticleEmitterFactory{
         /**
          * Constructor.
          */
-        PointEmitterFactory(){};
+        PointEmitterFactory();
 
         /**
          * Destructor.
          */
-        virtual ~PointEmitterFactory(){};
+        virtual ~PointEmitterFactory();
 
         /**
          * Retrieves the emitter type.
          *
          * @return The emitter type (always "Point").
          */
-        Ogre::String GetEmitterType() const{
-            return "Point";
-        }
+        Ogre::String GetEmitterType() const;
 
         /**
          * Creates an emitter.
          *
          * @return A new {@see PointEmitter}.
          */
-        ParticleEmitter* CreateEmitter(){
-            return CreateEmitter_<PointEmitter>();
-        }
+        ParticleEmitter* CreateEmitter();
 };

+ 1 - 1
V-Gears/src/Main.cpp

@@ -81,7 +81,7 @@ int main(int argc, char *argv[]){
         directionalLight->setSpecularColour(Ogre::ColourValue(0.0, 0.0, 0.0));
         directionalLight->setDirection(Ogre::Vector3(0, 1, 0));
         // auto fontManager = std::make_unique<Ogre::FontManager>();
-        VGears::MapFileManager* worldManager = new VGears::MapFileManager();
+        //VGears::MapFileManager* worldManager = new VGears::MapFileManager();
 
         // Initialize resources.
         // TODO: Use correct file location in the end, now is OK for testing

+ 4 - 4
V-Gears/src/common/File.cpp

@@ -27,7 +27,7 @@ File::File(const Ogre::String& file):
 {
     LOG_TRIVIAL("Loading file: " + file_name_ + "\n");
     buffer_size_ = FileSystem::GetFileSize(file_name_);
-    buffer_ = (u8*) malloc(sizeof(u8) * buffer_size_);
+    buffer_ = static_cast<u8*>(malloc(sizeof(u8) * buffer_size_));
     if (!FileSystem::ReadFile(file_name_, buffer_, 0, buffer_size_))
         LOG_TRIVIAL("Warning: " + file_name_ + " not found!\n");
 }
@@ -37,7 +37,7 @@ File::File(const File* file, u32 offset, u32 length):
 {
     assert(file != nullptr);
     file_name_ = file->GetFileName();
-    buffer_ = (u8 *) malloc(sizeof(u8) * buffer_size_);
+    buffer_ = static_cast<u8*>(malloc(sizeof(u8) * buffer_size_));
     file->GetFileBuffer(buffer_, offset_, buffer_size_);
 }
 
@@ -45,7 +45,7 @@ File::File(const u8* buffer, u32 offset, u32 length):
   file_name_("BUFFER"), buffer_(nullptr), buffer_size_(length), offset_(offset)
 {
     assert(buffer != nullptr);
-    buffer_ = (u8*) malloc(sizeof(u8) * buffer_size_);
+    buffer_ = static_cast<u8*>(malloc(sizeof(u8) * buffer_size_));
     memcpy(buffer_, buffer + offset, buffer_size_);
 }
 
@@ -53,7 +53,7 @@ File::File(const File* file){
     assert(file != nullptr);
     buffer_size_ = file->GetFileSize();
     file_name_   = file->GetFileName();
-    buffer_ = (u8*) malloc(sizeof(u8) * buffer_size_);
+    buffer_ = static_cast<u8*>(malloc(sizeof(u8) * buffer_size_));
     file->GetFileBuffer(buffer_, 0, buffer_size_);
 }
 

+ 13 - 14
V-Gears/src/common/LzsFile.cpp

@@ -45,45 +45,44 @@ void LzsFile::ExtractLzs(){
         return;
     }
     u32 extract_size = (buffer_size_ + 255) & ~255;
-    u8* extractbuffer_ = (u8*) malloc(extract_size);
+    u8* extractbuffer_ = static_cast<u8*>(malloc(extract_size));
     unsigned int inputoffset_ = 4;
     int outputoffset_ = 0;
     u8 control_byte = 0;
     u8 control_bit = 0;
     while (inputoffset_ < buffer_size_){
         if (control_bit == 0){
-            control_byte = ((u8*) buffer_)[inputoffset_ ++];
+            control_byte = (static_cast<u8*>(buffer_))[inputoffset_ ++];
             control_bit = 8;
         }
 
         if (control_byte & 1){
-            ((u8*) extractbuffer_) [outputoffset_ ++] =
-              ((u8*) buffer_) [inputoffset_ ++];
+            (static_cast<u8*>(extractbuffer_))[outputoffset_ ++] =
+              (static_cast<u8*>(buffer_))[inputoffset_ ++];
             if (outputoffset_ == extract_size){
                 extract_size += 256;
-                extractbuffer_ = (u8*) realloc(extractbuffer_, extract_size);
+                extractbuffer_ = static_cast<u8*>(realloc(extractbuffer_, extract_size));
             }
         }
         else{
-            u8 reference1 = ((u8*) buffer_)[inputoffset_++];
-            u8 reference2 = ((u8*) buffer_)[inputoffset_++];
+            u8 reference1 = (static_cast<u8*>(buffer_))[inputoffset_++];
+            u8 reference2 = (static_cast<u8*>(buffer_))[inputoffset_++];
             u16 referenceoffset_ = reference1 | ((reference2 & 0xF0) << 4);
             u8 reference_length = (reference2 & 0xF) + 3;
-            int realoffset_ =
-              outputoffset_
-              - ((outputoffset_ - 18 - referenceoffset_) & 0xFFF);
+            int realoffset_
+              = outputoffset_ - ((outputoffset_ - 18 - referenceoffset_) & 0xFFF);
             for (int j = 0; j < reference_length; ++ j){
                 if (realoffset_ < 0){
-                    ((u8*)extractbuffer_)[outputoffset_++] = 0;
+                    (static_cast<u8*>(extractbuffer_))[outputoffset_++] = 0;
                 }
                 else{
-                    ((u8*)extractbuffer_)[outputoffset_++] =
-                      ((u8*)extractbuffer_)[realoffset_];
+                    (static_cast<u8*>(extractbuffer_))[outputoffset_++] =
+                      (static_cast<u8*>(extractbuffer_))[realoffset_];
                 }
                 if (outputoffset_ == extract_size){
                     extract_size += 256;
                     extractbuffer_ =
-                      (u8*) realloc(extractbuffer_, extract_size);
+                      static_cast<u8*>(realloc(extractbuffer_, extract_size));
                 }
                 ++ realoffset_;
             }

+ 14 - 33
V-Gears/src/core/AudioManager.cpp

@@ -25,10 +25,7 @@ ALsizei AudioManager::channel_buffer_number_ = 2;
 int AudioManager::channel_buffer_size_ = 96 * 1024;
 
 AudioManager::AudioManager():
-    initialized_(false),
-    thread_continue_(true),
-    update_mutex_(),
-    music_(&update_mutex_)
+  initialized_(false), thread_continue_(true), update_mutex_(), music_(&update_mutex_)
 {
     al_device_ = alcOpenDevice(nullptr);
     if (al_device_ != nullptr){
@@ -49,16 +46,11 @@ AudioManager::AudioManager():
         }
         else{
             LOG_ERROR(
-              "AudioManager failed to initialised. "
-              + "Could not create context for sound device."
+              "AudioManager failed to initialised. Could not create context for sound device."
             );
         }
     }
-    else{
-        LOG_ERROR(
-          "AudioManager failed to initialised. There's no default sound device."
-        );
-    }
+    else LOG_ERROR("AudioManager failed to initialised. There's no default sound device.");
 
     // Load musics
     XmlMusicsFile musics("./data/musics.xml");
@@ -137,9 +129,7 @@ void AudioManager::AddMusic(const AudioManager::Music& music){
 AudioManager::Music* AudioManager::GetMusic(const Ogre::String& name){
     boost::recursive_mutex::scoped_lock lock(update_mutex_);
     for (auto it = music_list_.begin(); it != music_list_.end(); ++ it){
-        if (it->name == name){
-            return &(*it);
-        }
+        if (it->name == name) return &(*it);
     }
     return nullptr;
 }
@@ -162,11 +152,8 @@ const char* AudioManager::ALCError(const ALCdevice* device){
 }
 
 AudioManager::Player::Player(boost::recursive_mutex* mutex):
-    loop_(-1.0),
-    vorbis_info_(nullptr),
-    vorbis_section_(0),
-    stream_finished_(false),
-    update_mutex_(mutex)
+  loop_(-1.0), vorbis_info_(nullptr), vorbis_section_(0),
+  stream_finished_(false), update_mutex_(mutex)
 {}
 
 AudioManager::Player::~Player(){Stop();}
@@ -197,10 +184,9 @@ void AudioManager::Player::Play(const Ogre::String &file){
         ALsizei buffer_size = FillBuffer();
         if (buffer_size){
             alBufferData(
-              buffers[i], vorbis_info_->channels == 1 ?
-                AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
-              (const ALvoid*)AudioManager::getSingleton().buffer_,
-              (ALsizei)buffer_size, (ALsizei)vorbis_info_->rate
+              buffers[i], vorbis_info_->channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
+              static_cast<const ALvoid*>(AudioManager::getSingleton().buffer_),
+              static_cast<ALsizei>(buffer_size), static_cast<ALsizei>(vorbis_info_->rate)
             );
             alSourceQueueBuffers(source_, 1, &buffers[i]);
         }
@@ -250,8 +236,8 @@ void AudioManager::Player::Update(){
             alBufferData(
               buffer_id, vorbis_info_->channels == 1 ?
                 AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
-              (const ALvoid*)AudioManager::getSingleton().buffer_,
-              (ALsizei)buffer_size, (ALsizei)vorbis_info_->rate
+              static_cast<const ALvoid*>(AudioManager::getSingleton().buffer_),
+              static_cast<ALsizei>(buffer_size), static_cast<ALsizei>(vorbis_info_->rate)
             );
             alSourceQueueBuffers(source_, 1, &buffer_id);
         }
@@ -266,7 +252,6 @@ void AudioManager::Player::Update(){
     alGetSourcei(source_, AL_BUFFERS_PROCESSED, &processed);
     int queued;
     alGetSourcei(source_, AL_BUFFERS_QUEUED, &queued);
-
     if (stream_finished_ && processed == queued) Stop();
     else{
         ALenum source_state;
@@ -282,8 +267,7 @@ ALsizei AudioManager::Player::FillBuffer(){
     bool finished = false;
     do{
         long result = ov_read(
-          &vorbis_file_, buffer + read, channel_buffer_size_ - read,
-          0, 2, 1, &vorbis_section_
+          &vorbis_file_, buffer + read, channel_buffer_size_ - read, 0, 2, 1, &vorbis_section_
         );
 
         switch(result){
@@ -297,8 +281,7 @@ ALsizei AudioManager::Player::FillBuffer(){
             // End of stream
             case 0:
                 // If there isn't loop point or can't seek
-                if (loop_ < 0.0f || ov_time_seek(&vorbis_file_, loop_))
-                    finished = true;
+                if (loop_ < 0.0f || ov_time_seek(&vorbis_file_, loop_)) finished = true;
             break;
             // Readed "result" bytes
             default:
@@ -317,9 +300,7 @@ float AudioManager::Player::GetPosition(){
     return (
       ov_pcm_tell(&vorbis_file_)
       - (
-        channel_buffer_number_ * channel_buffer_size_
-        / vorbis_info_->channels
-        / sizeof(int16_t)
+        channel_buffer_number_ * channel_buffer_size_ / vorbis_info_->channels / sizeof(int16_t)
         - play_offset
       )
     ) * 1000 / vorbis_info_->rate;

+ 7 - 4
V-Gears/src/core/Background2D.cpp

@@ -216,7 +216,8 @@ void Background2D::OnResize(){
             vertex_buffer = add_vertex_buffer_;
         else if(tiles_[i].blending == VGears::B_SUBTRACT)
             vertex_buffer = subtract_vertex_buffer_;
-        float* write_iterator = (float*) vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+        float* write_iterator
+          = static_cast<float*>(vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL));
         write_iterator += tiles_[i].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
         *write_iterator ++ = new_x1;
         *write_iterator ++ = new_y1;
@@ -448,7 +449,7 @@ void Background2D::AddTile(
     tile.height = height;
     tile.start_vertex_index = render_op.vertexData->vertexCount;
     tile.blending = blending;
-    size_t index(tiles_.size());
+    //size_t index(tiles_.size());
     tiles_.push_back(tile);
     Ogre::Vector2 top_left(static_cast<Ogre::Real>(x), static_cast<Ogre::Real>(-y));
     Ogre::Vector2 top_right(
@@ -471,7 +472,8 @@ void Background2D::AddTile(
     float new_y3 = bottom_right.y;
     float new_x4 = bottom_left.x;
     float new_y4 = bottom_left.y;
-    float* write_iterator = (float*) vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float* write_iterator
+      = static_cast<float*>(vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL));
     write_iterator += render_op.vertexData->vertexCount * TILE_VERTEX_INDEX_SIZE;
 
     // TODO: Can use WriteGlyph
@@ -547,7 +549,8 @@ void Background2D::UpdateTileUV(
         vertex_buffer = add_vertex_buffer_;
     else if(tiles_[tile_id].blending == VGears::B_SUBTRACT)
         vertex_buffer = subtract_vertex_buffer_;
-    float* write_iterator = (float*) vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float* write_iterator
+      = static_cast<float*>(vertex_buffer->lock(Ogre::HardwareBuffer::HBL_NORMAL));
     write_iterator += tiles_[tile_id].start_vertex_index * TILE_VERTEX_INDEX_SIZE;
     write_iterator += 7;
     *write_iterator ++ = u1;

+ 6 - 18
V-Gears/src/core/ConfigVar.cpp

@@ -22,30 +22,19 @@ ConfigVar* ConfigVar::static_config_var_list_ = nullptr;
 ConfigVar::ConfigVar(
   const Ogre::String& name, const Ogre::String& description, const Ogre::String& default_value
 ):
-  name_(name),
-  description_(description),
-  default_value_(default_value),
-  value_s_(default_value)
+  name_(name), description_(description), default_value_(default_value), value_s_(default_value)
 {
     VGEARS_ASSERT(name != "", "name_ of ConfigVar can't be empty!");
-    VGEARS_ASSERT(
-      default_value != "", "default_value_ of ConfigVar can't be empty!"
-    );
-    VGEARS_ASSERT(
-      description != "", "description_ of ConfigVar can't be empty!"
-    );
+    VGEARS_ASSERT(default_value != "", "default_value_ of ConfigVar can't be empty!");
+    VGEARS_ASSERT(description != "", "description_ of ConfigVar can't be empty!");
     UpdateVariables();
 
-    // TODO: I don't understand this code
-    if (static_config_var_list_ != (ConfigVar*) 0xffffffff){
+    // TODO: Properly cast this
+    if (reinterpret_cast<std::uintptr_t>(&static_config_var_list_) != 0xffffffff){
         previous_ = static_config_var_list_;
         static_config_var_list_ = this;
     }
-    else{
-        VGEARS_ASSERT(
-          false, "ConfigVar declared after RegisterCvars were called!"
-        );
-    }
+    else VGEARS_ASSERT(false, "ConfigVar declared after RegisterCvars were called!");
 }
 
 int ConfigVar::GetI() const{return value_i_;}
@@ -80,7 +69,6 @@ const Ogre::String& ConfigVar::GetName() const{return name_;}
 
 const Ogre::String& ConfigVar::GetDescription() const{return description_;}
 
-
 const Ogre::String& ConfigVar::GetDefaultValue() const{return default_value_;}
 
 void ConfigVar::UpdateVariables(){

+ 7 - 13
V-Gears/src/core/ConfigVarManager.cpp

@@ -18,15 +18,12 @@
 template<>ConfigVarManager *Ogre::Singleton<ConfigVarManager>::msSingleton = nullptr;
 
 ConfigVarManager::ConfigVarManager(){
-    if(ConfigVar::static_config_var_list_ != (ConfigVar*) 0xffffffff){
-        for (
-          ConfigVar* cvar = ConfigVar::static_config_var_list_;
-          cvar;
-          cvar = cvar->previous_
-        ){
+    // TODO: Properly cast this.
+    if (reinterpret_cast<std::uintptr_t>(&ConfigVar::static_config_var_list_) != 0xffffffff){
+        for (ConfigVar* cvar = ConfigVar::static_config_var_list_; cvar; cvar = cvar->previous_)
             config_vars_.push_back(cvar);
-        }
-        ConfigVar::static_config_var_list_ = (ConfigVar*) 0xffffffff;
+        // TODO: Properly cast this.
+        ConfigVar::static_config_var_list_ = reinterpret_cast<ConfigVar*>(0xffffffff);
     }
 }
 
@@ -36,11 +33,8 @@ ConfigVar* ConfigVarManager::Find(const Ogre::String& name) const{
     return nullptr;
 }
 
-unsigned int ConfigVarManager::GetConfigVarNumber() const{
-    return config_vars_.size();
-}
+unsigned int ConfigVarManager::GetConfigVarNumber() const{return config_vars_.size();}
 
 ConfigVar* ConfigVarManager::GetConfigVar(const unsigned int i) const{
-    if (i < config_vars_.size()) return config_vars_[i];
-    return nullptr;
+    if (i < config_vars_.size()) return config_vars_[i]; return nullptr;
 }

+ 85 - 156
V-Gears/src/core/Console.cpp

@@ -48,17 +48,12 @@ Console::Console():
   auto_completition_line_(0)
 {
 
-    Ogre::FontPtr font
-      = Ogre::FontManager::getSingleton().getByName("CourierNew");
-    if (font != nullptr)
-        letter_width_ = static_cast<int>(font->getGlyphAspectRatio('_') * 16);
-    else
-        LOG_ERROR("Console::frameStarted: Font for console not found.");
+    Ogre::FontPtr font = Ogre::FontManager::getSingleton().getByName("CourierNew");
+    if (font != nullptr) letter_width_ = static_cast<int>(font->getGlyphAspectRatio('_') * 16);
+    else LOG_ERROR("Console::frameStarted: Font for console not found.");
 
     // Calculate width and height of console depending on size of application
-    Ogre::RenderTarget *render_target(
-      VGears::Application::getSingleton().getRenderWindow()
-    );
+    Ogre::RenderTarget *render_target( VGears::Application::getSingleton().getRenderWindow());
     console_width_ = render_target->getWidth();
     console_height_ = static_cast<int>(render_target->getHeight() / 2.5f);
     line_width_ = (console_width_ - 20) / 8;
@@ -66,14 +61,13 @@ Console::Console():
       "Created console width " + Ogre::StringConverter::toString(console_width_)
       + ", height " + Ogre::StringConverter::toString(console_height_)
     );
-
-    // Add as frame and log listener
+    // Add as frame and log listener.
     Ogre::LogManager::getSingleton().getDefaultLog()->addListener(this);
     LoadHistory();
 }
 
 Console::~Console(){
-    // Remove as listener
+    // Remove as listener.
     Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
     SaveHistory();
 }
@@ -92,7 +86,7 @@ void Console::SaveHistory(){
         LOG_ERROR("Failed to open console_history.txt for writing");
         return;
     }
-    for (auto& historyLine : history_) file << historyLine << "\r\n";
+    for (const auto& historyLine : history_) file << historyLine << "\r\n";
 }
 
 void Console::AddToHistory(const Ogre::String& history){
@@ -103,13 +97,12 @@ void Console::AddToHistory(const Ogre::String& history){
 
 void Console::Input(const VGears::Event& event){
     if (visible_ != true){
-        // Add console
-        if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE)
-            SetToVisible();
+        // Add console.
+        if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE) SetToVisible();
         return;
     }
 
-    // input command
+    // Input command.
     else if (
       event.type == VGears::ET_KEY_PRESS && (
         event.param1 == OIS::KC_RETURN || event.param1 == OIS::KC_NUMPADENTER
@@ -119,10 +112,10 @@ void Console::Input(const VGears::Event& event){
             input_line_ += auto_completition_[auto_completition_line_];
         AddTextToOutput(input_line_);
         AddInputToHistory();
-        // Backslashed text are console commands, otherwise - script commands
+        // Backslashed text are console commands, otherwise - script commands.
         if ('\\' == input_line_[0] || '/' == input_line_[0]){
             if (input_line_.size() > 1){
-                // Remove backslash
+                // Remove backslash.
                 input_line_.erase(0, 1);
                 ExecuteCommand(input_line_);
             }
@@ -132,20 +125,13 @@ void Console::Input(const VGears::Event& event){
         cursor_position_ = 0;
         ResetAutoCompletion();
     }
-    else if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_TAB)
-        CompleteInput();
-    // Remove console
-    else if (
-      event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE
-    ){
-        SetToHide();
-    }
+    else if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_TAB) CompleteInput();
+    // Remove console.
+    else if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_GRAVE) SetToHide();
     // History up
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_UP
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_UP
     ){
         if (history_line_cycle_index_ < (int)history_.size() - 1){
             ++ history_line_cycle_index_;
@@ -154,50 +140,40 @@ void Console::Input(const VGears::Event& event){
     }
     // History down
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_DOWN
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_DOWN
     ){
         if (history_line_cycle_index_ > 0){
             -- history_line_cycle_index_;
             SetInputLineFromHistory();
         }
     }
-    // Scroll display to previous row
+    // Scroll display to previous row.
     else if (event.type == VGears::ET_MOUSE_SCROLL && event.param1 > 0){
         if (display_line_ > 0) display_line_ -= 1;
     }
-    // Scroll display to next row
+    // Scroll display to next row.
     else if (event.type == VGears::ET_MOUSE_SCROLL && event.param1 < 0){
         if (display_line_ < output_line_.size()) display_line_ += 1;
-
     }
-    // Scroll display to previous row
+    // Scroll display to previous row.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_PGUP
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_PGUP
     ){
         if (display_line_ > 0) display_line_ -= 1;
-
     }
-    // Scroll display to next row
+    // Scroll display to next row.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_PGDOWN
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_PGDOWN
     ){
         if (display_line_ < output_line_.size()) display_line_ += 1;
     }
-    // Delete character after cursor
+    // Delete character after cursor.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_DELETE
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_DELETE
     ){
         if (auto_completition_.size() > 0) ResetAutoCompletion();
         else{
@@ -205,12 +181,10 @@ void Console::Input(const VGears::Event& event){
                 input_line_.erase(cursor_position_, 1);
         }
     }
-    // Delete character before cursor
+    // Delete character before cursor.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_BACK
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_BACK
     ){
         if (auto_completition_.size() > 0) ResetAutoCompletion();
         else{
@@ -220,12 +194,10 @@ void Console::Input(const VGears::Event& event){
             }
         }
     }
-    // Move cursor to left
+    // Move cursor to left.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_LEFT
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_LEFT
     ){
         if (auto_completition_.size() > 0){
             input_line_ += auto_completition_[auto_completition_line_];
@@ -233,12 +205,10 @@ void Console::Input(const VGears::Event& event){
         }
         if (cursor_position_ > 0) -- cursor_position_;
     }
-    // Move cursor to right
+    // Move cursor to right.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && event.param1 == OIS::KC_RIGHT
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && event.param1 == OIS::KC_RIGHT
     ){
         if (auto_completition_.size() > 0){
             input_line_ += auto_completition_[auto_completition_line_];
@@ -246,24 +216,20 @@ void Console::Input(const VGears::Event& event){
         }
         if (cursor_position_ <  input_line_.size()) ++ cursor_position_;
     }
-    else if (
-      event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_ESCAPE
-    ){
+    else if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_ESCAPE){
         input_line_.clear();
         cursor_position_ = 0;
         ResetAutoCompletion();
     }
-    // Move cursor to start of string
-    else if (
-      event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_HOME
-    ){
+    // Move cursor to start of string.
+    else if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_HOME){
         cursor_position_ = 0;
         if (auto_completition_.size() > 0){
             input_line_ += auto_completition_[auto_completition_line_];
             ResetAutoCompletion();
         }
     }
-    // Move cursor to end of string
+    // Move cursor to end of string.
     else if (event.type == VGears::ET_KEY_PRESS && event.param1 == OIS::KC_END){
         if (auto_completition_.size() > 0){
             input_line_ += auto_completition_[auto_completition_line_];
@@ -271,12 +237,10 @@ void Console::Input(const VGears::Event& event){
         }
         cursor_position_ = input_line_.size();
     }
-    // Input Ascii character
+    // Input Ascii character.
     else if (
-      (
-        event.type == VGears::ET_KEY_PRESS
-        || event.type == VGears::ET_KEY_REPEAT_WAIT
-      ) && input_line_.size() < line_width_
+      (event.type == VGears::ET_KEY_PRESS || event.type == VGears::ET_KEY_REPEAT_WAIT)
+      && input_line_.size() < line_width_
     ){
         char legalchars[]
           = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
@@ -284,8 +248,7 @@ void Console::Input(const VGears::Event& event){
         char txt = TranslateNumpad(event);
         for (unsigned int c = 0; c < sizeof(legalchars) - 1; ++ c){
             if (legalchars[c] == txt){
-                std::string::iterator i
-                  = input_line_.begin() + cursor_position_;
+                std::string::iterator i = input_line_.begin() + cursor_position_;
                 input_line_.insert(i, txt);
                 ++ cursor_position_;
                 ResetAutoCompletion();
@@ -321,8 +284,7 @@ void Console::Update(){
     if (to_visible_ == true && height_ < console_height_){
         // TODO: Convert this to a constant.
         height_ += delta_time * 1500;
-        if (height_ >= console_height_)
-            height_ = static_cast<float>(console_height_);
+        if (height_ >= console_height_) height_ = static_cast<float>(console_height_);
     }
     else if (to_visible_ == false && height_ > 0){
         height_ -= delta_time * 1500;
@@ -363,7 +325,7 @@ void Console::UpdateDraw(){
     }
     if (display_line_ != output_line_.size()){
         Ogre::String temp = "";
-        for (unsigned int i = 0; i < line_width_; ++ i) temp += "^";
+        for (unsigned int w = 0; w < line_width_; ++ w) temp += "^";
         DEBUG_DRAW.SetColour(Ogre::ColourValue(1.0f, 0.0f, 0.0f, 1.0f));
         DEBUG_DRAW.Text(5.0f, static_cast<float>(y), temp);
     }
@@ -400,9 +362,7 @@ void Console::UpdateNotification(){
     int y = (output_line_.size() > 10) ? 160 : output_line_.size() * 16;
     int line = 0;
     float max_time = 3.0f;
-    for (
-      i = output_line_.rbegin(); i != output_line_.rend() && line < 10; ++ i
-    ){
+    for (i = output_line_.rbegin(); i != output_line_.rend() && line < 10; ++ i){
         float time = Timer::getSingleton().GetSystemTimeTotal() - (*i).time;
         if (time < max_time){
             Ogre::ColourValue colour = (*i).colour;
@@ -417,18 +377,15 @@ void Console::UpdateNotification(){
 
 void Console::OnResize(){
     // Calculate width and height of console depending on size of application
-    Ogre::RenderTarget *render_target(
-      VGears::Application::getSingleton().getRenderWindow()
-    );
+    Ogre::RenderTarget *render_target(VGears::Application::getSingleton().getRenderWindow());
     console_width_ = render_target->getWidth();
     console_height_ = static_cast<int>(render_target->getHeight() / 2.5f);
     line_width_ = (console_width_ - 20) / 8;
     LOG_TRIVIAL(
-      "Resized console width to "
-      + Ogre::StringConverter::toString(console_width_) + ", height to "
-      + Ogre::StringConverter::toString(console_height_)
+      "Resized console width to " + Ogre::StringConverter::toString(console_width_)
+      + ", height to " + Ogre::StringConverter::toString(console_height_)
     );
-    // Update height of already opened console
+    // Update height of already opened console.
     height_ = (height_ > console_height_) ? console_height_ : height_;
 }
 
@@ -441,17 +398,15 @@ void Console::SetToHide(){to_visible_ = false;}
 
 bool Console::IsVisible() const{return visible_;}
 
-void Console::AddTextToOutput(
-  const Ogre::String& text, const Ogre::ColourValue& colour
-){
-    // Go through line and add it to output correctly
+void Console::AddTextToOutput(const Ogre::String& text, const Ogre::ColourValue& colour){
+    // Go through line and add it to output correctly.
     const char* str = text.c_str();
     Ogre::String output_line;
     unsigned int string_size = 0;
     bool indent = false;
     unsigned int c = 0;
     for (; c < text.size(); ++ c){
-        // Add space at start of string if we want indent
+        // Add space at start of string if it's to be indented.
         if (string_size == 0 && indent == true){
             output_line.push_back(' ');
             ++ string_size;
@@ -460,13 +415,10 @@ void Console::AddTextToOutput(
             output_line.push_back(str[c]);
             ++ string_size;
         }
-        if (
-          str[c] == '\n' || string_size >= line_width_ || c >= text.size() - 1
-        ){
-            // If string is larger than output size than add indent
+        if (str[c] == '\n' || string_size >= line_width_ || c >= text.size() - 1){
+            // If string is larger than output size than add indent.
             indent = (string_size >= line_width_) ? true : false;
-            if (output_line_.size() >= max_output_line_)
-                output_line_.pop_front();
+            if (output_line_.size() >= max_output_line_) output_line_.pop_front();
             if (output_line_.size() == display_line_) ++ display_line_;
             OutputLine line;
             line.text = output_line;
@@ -492,7 +444,6 @@ void Console::AddTextToOutput(
 void Console::ExecuteCommand(const Ogre::String& command){
     bool handled = false;
     Ogre::StringVector params = StringTokenise(command);
-
     // Is it cvar?
     ConfigVar* cvar = ConfigVarManager::getSingleton().Find(params[0]);
     if (cvar != nullptr){
@@ -503,9 +454,8 @@ void Console::ExecuteCommand(const Ogre::String& command){
         }
         else{
             AddTextToOutput(
-              params[0] + " = \"" + cvar->GetS() + "\".\n" + " default:\""
-              + cvar->GetDefaultValue() + "\".\n" + " description: "
-              + cvar->GetDescription() + ".\n"
+              params[0] + " = \"" + cvar->GetS() + "\".\n" + " default:\"" + cvar->GetDefaultValue()
+              + "\".\n" + " description: " + cvar->GetDescription() + ".\n"
             );
         }
     }
@@ -520,35 +470,26 @@ void Console::ExecuteCommand(const Ogre::String& command){
     }
 }
 
-void Console::ExecuteScript(){
-    ScriptManager::getSingleton().RunString(input_line_);
-}
+void Console::ExecuteScript(){ScriptManager::getSingleton().RunString(input_line_);}
 
 void Console::CompleteInput(){
-    bool add_slash = false;
     if (auto_completition_.size() == 0){
+        bool add_slash = false;
         // remove backslash
-        if (
-          input_line_.size() > 0
-          && ('\\' == input_line_[0]
-          || '/' == input_line_[0])
-        ){
+        if (input_line_.size() > 0 && ('\\' == input_line_[0] || '/' == input_line_[0]))
             input_line_.erase(0, 1);
-        }
         size_t input_size = input_line_.size();
         Ogre::StringVector params = StringTokenise(input_line_);
         if (params.size() == 0){
-            // Add cvars
-            int num_vars
-              = ConfigVarManager::getSingleton().GetConfigVarNumber();
+            // Add cvars.
+            int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
             for (int i = 0; i < num_vars; ++ i){
                 auto_completition_.push_back(
                   ConfigVarManager::getSingleton().GetConfigVar(i)->GetName()
                 );
             }
-            // Add commands
-            int num_cmds
-              = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
+            // Add commands.
+            int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
             for (int i = 0; i < num_cmds; ++i){
                 auto_completition_.push_back(
                   ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName()
@@ -558,52 +499,44 @@ void Console::CompleteInput(){
         }
         else if (params.size() == 1){
             input_line_ = params[0];
-            // add Cvars
-            int num_vars
-              = ConfigVarManager::getSingleton().GetConfigVarNumber();
+            // Add Cvars.
+            int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
             for (int i = 0; i < num_vars; ++ i){
-                Ogre::String name =
-                  ConfigVarManager::getSingleton().GetConfigVar(i)->GetName();
+                Ogre::String name = ConfigVarManager::getSingleton().GetConfigVar(i)->GetName();
                 unsigned int pos = name.find(input_line_);
                 if (pos == 0){
                     add_slash = true;
                     if (input_size != name.size()){
-                        Ogre::String part
-                          = name.substr(input_size, name.size() - input_size);
+                        Ogre::String part = name.substr(input_size, name.size() - input_size);
                         auto_completition_.push_back(part);
                     }
                 }
             }
-            // Add commands
-            int num_cmds
-              = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
+            // Add commands.
+            int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
             for (int i = 0; i < num_cmds; ++ i){
-                Ogre::String name
-                  = ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName();
+                Ogre::String name = ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName();
                 int pos = name.find(input_line_);
                 if (pos == 0){
                     add_slash = true;
                     if (name != params[0]){
-                        Ogre::String part
-                          = name.substr(input_size, name.size() - input_size);
+                        Ogre::String part = name.substr(input_size, name.size() - input_size);
                         auto_completition_.push_back(part);
                     }
                     else if (
-                      ConfigCmdManager::getSingleton().GetConfigCmd(i)
-                      ->GetCompletion()
-                      != nullptr
+                      ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion() != nullptr
                     ){
                         input_line_ += " ";
-                        ConfigCmdManager::getSingleton().GetConfigCmd(i)->
-                          GetCompletion()(auto_completition_);
+                        ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion()(
+                          auto_completition_
+                        );
                     }
                 }
             }
         }
         else if (params.size() > 1){
             Ogre::String all_params = params[1];
-            for (size_t i = 2; i < params.size(); ++ i)
-                all_params += " " + params[i];
+            for (size_t i = 2; i < params.size(); ++ i) all_params += " " + params[i];
             // Add commands arguments
             ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
             if (cmd != nullptr){
@@ -617,8 +550,7 @@ void Console::CompleteInput(){
                             int pos = full_complete[i].find(all_params);
                             if (pos == 0 && all_params != full_complete[i]){
                                 Ogre::String part = full_complete[i].substr(
-                                  all_params.size(),
-                                  full_complete[i].size() - all_params.size()
+                                  all_params.size(), full_complete[i].size() - all_params.size()
                                 );
                                 auto_completition_.push_back(part);
                             }
@@ -642,8 +574,7 @@ void Console::CompleteInput(){
         if (auto_completition_.size() > 0) AddTextToOutput("\n");
     }
     else{
-        if (auto_completition_line_ < auto_completition_.size() - 1)
-            ++auto_completition_line_;
+        if (auto_completition_line_ < auto_completition_.size() - 1) ++auto_completition_line_;
         else auto_completition_line_ = 0;
     }
 }
@@ -653,9 +584,7 @@ void Console::ResetAutoCompletion(){
     auto_completition_line_ = 0;
 }
 
-void Console::AddInputToHistory(){
-    AddToHistory(input_line_);
-}
+void Console::AddInputToHistory(){AddToHistory(input_line_);}
 
 void Console::SetInputLineFromHistory(){
     ResetAutoCompletion();

+ 78 - 198
V-Gears/src/core/DebugDraw.cpp

@@ -45,8 +45,7 @@ DebugDraw::DebugDraw():
     CreateTriangle3dVertexBuffer();
     CreateQuadVertexBuffer();
     CreateTextVertexBuffer();
-    material_
-      = Ogre::MaterialManager::getSingleton().create("DebugDraw", "General");
+    material_ = Ogre::MaterialManager::getSingleton().create("DebugDraw", "General");
     Ogre::Pass* pass = material_->getTechnique(0)->getPass(0);
     pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
     pass->setCullingMode(Ogre::CULL_NONE);
@@ -54,8 +53,7 @@ DebugDraw::DebugDraw():
     pass->setDepthWriteEnabled(true);
     pass->setLightingEnabled(false);
     pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
-    material_3d_
-      = Ogre::MaterialManager::getSingleton().create("DebugDraw3d", "General");
+    material_3d_ = Ogre::MaterialManager::getSingleton().create("DebugDraw3d", "General");
     pass = material_3d_->getTechnique(0)->getPass(0);
     pass->setVertexColourTracking(Ogre::TVC_AMBIENT);
     pass->setCullingMode(Ogre::CULL_NONE);
@@ -93,9 +91,7 @@ DebugDraw::~DebugDraw(){
 
 void DebugDraw::SetColour(const Ogre::ColourValue& colour){colour_ = colour;}
 
-void DebugDraw::SetScreenSpace(const bool screen_space){
-    screen_space_ = screen_space;
-}
+void DebugDraw::SetScreenSpace(const bool screen_space){screen_space_ = screen_space;}
 
 void DebugDraw::SetZ(const float z){z_coordinate_ = z;}
 
@@ -104,13 +100,9 @@ void DebugDraw::SetFadeDistance(const float fade_s, const float fade_e){
     fade_end_square_ = fade_e * fade_e;
 }
 
-void DebugDraw::SetTextAlignment(TextAlignment alignment){
-    text_alignment_ = alignment;
-}
+void DebugDraw::SetTextAlignment(TextAlignment alignment){text_alignment_ = alignment;}
 
-void DebugDraw::Line(
-  const float x1, const float y1, const float x2, const float y2
-){
+void DebugDraw::Line(const float x1, const float y1, const float x2, const float y2){
     if (line_render_operation_.vertexData->vertexCount + 2 > line_max_vertex_){
         LOG_ERROR(
           "Max number of lines reached. Can't create more than "
@@ -122,17 +114,16 @@ void DebugDraw::Line(
     float width = static_cast<float>(viewport->getActualWidth());
     float height = static_cast<float>(viewport->getActualHeight());
     float new_x1 = (screen_space_ == true) ?  ((int) x1 / width) * 2 - 1 : x1;
-    float new_y1
-      = (screen_space_ == true) ? -(((int) y1 / height) * 2 - 1) : y1;
+    float new_y1 = (screen_space_ == true) ? -(((int) y1 / height) * 2 - 1) : y1;
     float new_x2 = (screen_space_ == true) ?  ((int) x2 / width) * 2 - 1 : x2;
-    float new_y2
-      = (screen_space_ == true) ? -(((int) y2 / height) * 2 - 1) : y2;
+    float new_y2 = (screen_space_ == true) ? -(((int) y2 / height) * 2 - 1) : y2;
 
-    float* write_iterator =
-      (float*) line_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float* write_iterator = static_cast<float*>(
+      line_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL)
+    );
     write_iterator += line_render_operation_.vertexData->vertexCount * 7;
 
-    // TODO: This and the method below could be refactored
+    // TODO: This and the method below could be refactored.
     *write_iterator ++ = new_x1;
     *write_iterator ++ = new_y1;
     *write_iterator ++ = z_coordinate_;
@@ -152,22 +143,17 @@ void DebugDraw::Line(
 }
 
 
-void DebugDraw::Line3d(
-  const Ogre::Vector3& point1, const Ogre::Vector3& point2
-){
-    if (
-      line_3d_render_operation_.vertexData->vertexCount + 2
-      > line_3d_max_vertex_
-    ){
+void DebugDraw::Line3d(const Ogre::Vector3& point1, const Ogre::Vector3& point2){
+    if (line_3d_render_operation_.vertexData->vertexCount + 2 > line_3d_max_vertex_){
         LOG_ERROR(
           "Max number of 3d lines reached. Can't create more than "
-          + Ogre::StringConverter::toString(line_3d_max_vertex_ / 2)
-          + " 3d lines."
+          + Ogre::StringConverter::toString(line_3d_max_vertex_ / 2) + " 3d lines."
         );
         return;
     }
-    float* write_iterator
-      = (float*) line_3d_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float* write_iterator = static_cast<float*>(
+      line_3d_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL)
+    );
     write_iterator += line_3d_render_operation_.vertexData->vertexCount * 7;
     *write_iterator ++ = point1.x;
     *write_iterator ++ = point1.y;
@@ -189,24 +175,18 @@ void DebugDraw::Line3d(
 
 
 void DebugDraw::Triangle3d(
-  const Ogre::Vector3& point1, const Ogre::Vector3& point2,
-  const Ogre::Vector3& point3
+  const Ogre::Vector3& point1, const Ogre::Vector3& point2, const Ogre::Vector3& point3
 ){
-    if (
-      triangle_3d_render_operation_.vertexData->vertexCount + 3
-      > triangle_3d_max_vertex_
-    ){
+    if (triangle_3d_render_operation_.vertexData->vertexCount + 3 > triangle_3d_max_vertex_){
         LOG_ERROR(
           "Max number of 3d triangles reached. Can't create more than "
-          + Ogre::StringConverter::toString(triangle_3d_max_vertex_ / 3)
-          + " 3d triangles."
+          + Ogre::StringConverter::toString(triangle_3d_max_vertex_ / 3) + " 3d triangles."
         );
         return;
     }
-    float* write_iterator
-      = (float*) triangle_3d_vertex_buffer_->lock(
+    float* write_iterator = static_cast<float*>(triangle_3d_vertex_buffer_->lock(
         Ogre::HardwareBuffer::HBL_NORMAL
-    );
+    ));
     write_iterator += triangle_3d_render_operation_.vertexData->vertexCount * 7;
     *write_iterator ++ = point1.x;
     *write_iterator ++ = point1.y;
@@ -248,18 +228,16 @@ void DebugDraw::Quad(
     float width = static_cast<float>(viewport->getActualWidth());
     float height = static_cast<float>(viewport->getActualHeight());
     float new_x1 = (screen_space_ == true) ?  ((int) x1 / width) * 2 - 1 : x1;
-    float new_y1
-      = (screen_space_ == true) ? -(((int) y1 / height) * 2 - 1) : y1;
+    float new_y1 = (screen_space_ == true) ? -(((int) y1 / height) * 2 - 1) : y1;
     float new_x2 = (screen_space_ == true) ?  ((int) x2 / width) * 2 - 1 : x2;
     float new_y2 = (screen_space_ == true) ? -((y2 / height) * 2 - 1) : y2;
     float new_x3 = (screen_space_ == true) ?  ((int) x3 / width) * 2 - 1 : x3;
-    float new_y3
-      = (screen_space_ == true) ? -(((int) y3 / height) * 2 - 1) : y3;
+    float new_y3 = (screen_space_ == true) ? -(((int) y3 / height) * 2 - 1) : y3;
     float new_x4 = (screen_space_ == true) ?  ((int) x4 / width) * 2 - 1 : x4;
-    float new_y4
-      = (screen_space_ == true) ? -(((int) y4 / height) * 2 - 1) : y4;
-    float* write_iterator
-      = (float*) quad_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float new_y4 = (screen_space_ == true) ? -(((int) y4 / height) * 2 - 1) : y4;
+    float* write_iterator = static_cast<float*>(
+      quad_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL)
+    );
     write_iterator += quad_render_operation_.vertexData->vertexCount * 7;
     *write_iterator ++ = new_x1;
     *write_iterator ++ = new_y1;
@@ -309,10 +287,7 @@ void DebugDraw::Quad(
 
 
 void DebugDraw::Text(const float x, const float y, const Ogre::String& text){
-    if (
-      text_render_operation_.vertexData->vertexCount + text.size() * 6
-      > text_max_vertex_
-    ){
+    if (text_render_operation_.vertexData->vertexCount + text.size() * 6 > text_max_vertex_){
         LOG_ERROR(
           "Max number of text reached. Can't add text \"" + text
           + "\". Max number of letters is "
@@ -320,29 +295,25 @@ void DebugDraw::Text(const float x, const float y, const Ogre::String& text){
         );
         return;
     }
-    float* write_iterator
-      = (float*) text_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float* write_iterator = static_cast<float*>(
+      text_vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL)
+    );
     write_iterator += text_render_operation_.vertexData->vertexCount * 9;
     Ogre::Viewport *viewport(CameraManager::getSingleton().getViewport());
     float width = static_cast<float>(viewport->getActualWidth());
     float height = static_cast<float>(viewport->getActualHeight());
     float length = 0;
     if (text_alignment_ != LEFT){
-        for (auto &c : text){
-            length
-              += ((font_->getGlyphAspectRatio(c) * font_height_) / width) * 2;
-        }
+        for (auto &c : text) length += ((font_->getGlyphAspectRatio(c) * font_height_) / width) * 2;
         if (text_alignment_ == CENTER) length /= 2;
     }
 
     float current_x = (screen_space_ == true) ? ((int) x / width) * 2 - 1 : x;
     current_x -= length;
-    float current_y
-      = (screen_space_ == true) ? -(((int) y / height) * 2 - 1) : y;
+    float current_y  = (screen_space_ == true) ? -(((int) y / height) * 2 - 1) : y;
     float char_height = -(font_height_ / height) * 2;
     for (unsigned int i = 0; i < text.size(); ++ i){
-        float char_width
-          = ((font_->getGlyphAspectRatio(text[i]) * font_height_) / width) * 2;
+        float char_width = ((font_->getGlyphAspectRatio(text[i]) * font_height_) / width) * 2;
         float new_x1 = current_x;
         float new_y1 = current_y;
         float new_x2 = current_x + char_width;
@@ -409,16 +380,13 @@ void DebugDraw::Text(const float x, const float y, const Ogre::String& text){
         *write_iterator ++ = uv.bottom;
         text_render_operation_.vertexData->vertexCount += 6;
     }
-
     text_vertex_buffer_->unlock();
 }
 
 void DebugDraw::Text(
-  const Ogre::Vector3& point, const float x, const float y,
-  const Ogre::String& text
+  const Ogre::Vector3& point, const float x, const float y, const Ogre::String& text
 ){
-    Ogre::Vector3 point2d
-      = CameraManager::getSingleton().ProjectPointToScreen(point);
+    Ogre::Vector3 point2d = CameraManager::getSingleton().ProjectPointToScreen(point);
     if (point2d.z <= 0){
         float dist_sq = point.squaredDistance(
           CameraManager::getSingleton().GetCurrentCamera()->getPosition()
@@ -433,11 +401,8 @@ void DebugDraw::Text(
         if (dist_sq < fade_end_square_){
             float a
               = (dist_sq > fade_start_square_)
-              ? (
-                1.0f - (dist_sq - fade_start_square_) /
-                (fade_end_square_ - fade_start_square_)
-              )
-              : 1.0f;
+                ? (1.0f - (dist_sq - fade_start_square_) / (fade_end_square_ - fade_start_square_))
+                : 1.0f;
             Ogre::ColourValue colour = colour_;
             colour.a = a;
             SetColour(colour);
@@ -447,42 +412,29 @@ void DebugDraw::Text(
 }
 
 void DebugDraw::renderQueueEnded(
-  Ogre::uint8 queueGroupId, const Ogre::String& invocation,
-  bool& repeatThisInvocation
+  Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation
 ){
     if (queueGroupId == Ogre::RENDER_QUEUE_OVERLAY){
         render_system_->clearFrameBuffer(Ogre::FBT_DEPTH);
-        auto renderParams= render_system_->getFixedFunctionParams(
-          Ogre::TVC_NONE, Ogre::FOG_NONE
-        );
-        renderParams->setConstant(
+        auto render_params= render_system_->getFixedFunctionParams(Ogre::TVC_NONE, Ogre::FOG_NONE);
+        render_params->setConstant(
           Ogre::GpuProgramParameters::ACT_WORLD_MATRIX, Ogre::Matrix4::IDENTITY
         );
-        renderParams->setConstant(
-          Ogre::GpuProgramParameters::ACT_PROJECTION_MATRIX,
-          Ogre::Matrix4::IDENTITY
+        render_params->setConstant(
+          Ogre::GpuProgramParameters::ACT_PROJECTION_MATRIX, Ogre::Matrix4::IDENTITY
         );
-        renderParams->setConstant(
+        render_params->setConstant(
           Ogre::GpuProgramParameters::ACT_VIEW_MATRIX, Ogre::Matrix4::IDENTITY
         );
-        render_system_->applyFixedFunctionParams(
-          renderParams, Ogre::GPV_GLOBAL
-        );
-        /*render_system_->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
-        render_system_->_setViewMatrix(Ogre::Matrix4::IDENTITY);
-        render_system_->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);*/
+        render_system_->applyFixedFunctionParams(render_params, Ogre::GPV_GLOBAL);
 
         if (line_render_operation_.vertexData->vertexCount != 0){
-            scene_manager_->_setPass(
-              material_->getTechnique(0)->getPass(0), true, false
-            );
+            scene_manager_->_setPass(material_->getTechnique(0)->getPass(0), true, false);
             render_system_->_render(line_render_operation_);
             line_render_operation_.vertexData->vertexCount = 0;
         }
         if (quad_render_operation_.vertexData->vertexCount != 0){
-            scene_manager_->_setPass(
-              material_->getTechnique(0)->getPass(0), true, false
-            );
+            scene_manager_->_setPass(material_->getTechnique(0)->getPass(0), true, false);
             render_system_->_render(quad_render_operation_);
             quad_render_operation_.vertexData->vertexCount = 0;
         }
@@ -500,43 +452,16 @@ void DebugDraw::renderQueueEnded(
           CameraManager::getSingleton().GetCurrentCamera()->getViewMatrix()
         );
         render_system_->_setProjectionMatrix(
-          CameraManager::getSingleton().GetCurrentCamera()
-          ->getProjectionMatrix()
-        );
-        // TODO: Debug this. Above lines work, below ones don't render entities
-        /*
-        render_system_->clearFrameBuffer(Ogre::FBT_DEPTH);
-        auto renderParams= render_system_->getFixedFunctionParams(
-          Ogre::TVC_NONE, Ogre::FOG_NONE
+          CameraManager::getSingleton().GetCurrentCamera()->getProjectionMatrix()
         );
-        renderParams->setConstant(
-          Ogre::GpuProgramParameters::ACT_WORLD_MATRIX, Ogre::Matrix4::IDENTITY
-        );
-        renderParams->setConstant(
-          Ogre::GpuProgramParameters::ACT_PROJECTION_MATRIX,
-          CameraManager::getSingleton().GetCurrentCamera()
-            ->getProjectionMatrix()
-        );
-        renderParams->setConstant(
-          Ogre::GpuProgramParameters::ACT_VIEW_MATRIX,
-          CameraManager::getSingleton().GetCurrentCamera()->getViewMatrix()
-        );
-        render_system_->applyFixedFunctionParams(
-          renderParams, Ogre::GPV_GLOBAL
-        );
-        */
         if (line_3d_render_operation_.vertexData->vertexCount != 0){
-            scene_manager_->_setPass(
-              material_3d_->getTechnique(0)->getPass(0), true, false
-            );
+            scene_manager_->_setPass(material_3d_->getTechnique(0)->getPass(0), true, false);
             render_system_->_render(line_3d_render_operation_);
             line_3d_render_operation_.vertexData->vertexCount = 0;
         }
 
         if (triangle_3d_render_operation_.vertexData->vertexCount != 0){
-            scene_manager_->_setPass(
-              material_3d_->getTechnique(0)->getPass(0), true, false
-            );
+            scene_manager_->_setPass(material_3d_->getTechnique(0)->getPass(0), true, false);
             render_system_->_render(triangle_3d_render_operation_);
             triangle_3d_render_operation_.vertexData->vertexCount = 0;
         }
@@ -547,26 +472,17 @@ void DebugDraw::CreateLineVertexBuffer(){
     line_max_vertex_ = 1024 * 2;
     line_render_operation_.vertexData = new Ogre::VertexData;
     line_render_operation_.vertexData->vertexStart = 0;
-
     Ogre::VertexDeclaration* vertex_declaration
       = line_render_operation_.vertexData->vertexDeclaration;
-
     size_t offset = 0;
     vertex_declaration->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE
-    );
-
-    line_vertex_buffer_
-      = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
-        vertex_declaration->getVertexSize(0), line_max_vertex_,
-        Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
-    );
-
-    line_render_operation_.vertexData->vertexBufferBinding->setBinding(
-      0, line_vertex_buffer_
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
+    line_vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
+      vertex_declaration->getVertexSize(0), line_max_vertex_,
+      Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
     );
+    line_render_operation_.vertexData->vertexBufferBinding->setBinding(0, line_vertex_buffer_);
     line_render_operation_.operationType = Ogre::RenderOperation::OT_LINE_LIST;
     line_render_operation_.useIndexes = false;
 }
@@ -582,28 +498,22 @@ void DebugDraw::CreateLine3dVertexBuffer(){
     line_3d_max_vertex_ = 1024 * 2;
     line_3d_render_operation_.vertexData = new Ogre::VertexData;
     line_3d_render_operation_.vertexData->vertexStart = 0;
-
     Ogre::VertexDeclaration* vertex_declaration
       = line_3d_render_operation_.vertexData->vertexDeclaration;
-
     size_t offset = 0;
     vertex_declaration->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE
-    );
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
 
-    line_3d_vertex_buffer_
-      = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
-        vertex_declaration->getVertexSize(0), line_3d_max_vertex_,
-        Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
+    line_3d_vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
+      vertex_declaration->getVertexSize(0), line_3d_max_vertex_,
+      Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
     );
 
     line_3d_render_operation_.vertexData->vertexBufferBinding->setBinding(
       0, line_3d_vertex_buffer_
     );
-    line_3d_render_operation_.operationType
-      = Ogre::RenderOperation::OT_LINE_LIST;
+    line_3d_render_operation_.operationType = Ogre::RenderOperation::OT_LINE_LIST;
     line_3d_render_operation_.useIndexes = false;
 }
 
@@ -618,28 +528,22 @@ void DebugDraw::CreateTriangle3dVertexBuffer(){
     triangle_3d_max_vertex_ = 128 * 3;
     triangle_3d_render_operation_.vertexData = new Ogre::VertexData;
     triangle_3d_render_operation_.vertexData->vertexStart = 0;
-
     Ogre::VertexDeclaration* vertex_declaration
       = triangle_3d_render_operation_.vertexData->vertexDeclaration;
-
     size_t offset = 0;
     vertex_declaration->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE
-    );
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
 
-    triangle_3d_vertex_buffer_
-      = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
-        vertex_declaration->getVertexSize(0), triangle_3d_max_vertex_,
-        Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
+    triangle_3d_vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
+      vertex_declaration->getVertexSize(0), triangle_3d_max_vertex_,
+      Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
     );
 
     triangle_3d_render_operation_.vertexData->vertexBufferBinding->setBinding(
       0, triangle_3d_vertex_buffer_
     );
-    triangle_3d_render_operation_.operationType
-      = Ogre::RenderOperation::OT_TRIANGLE_LIST;
+    triangle_3d_render_operation_.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     triangle_3d_render_operation_.useIndexes = false;
 }
 
@@ -654,30 +558,18 @@ void DebugDraw::CreateQuadVertexBuffer(){
     quad_max_vertex_ = 128 * 6;
     quad_render_operation_.vertexData = new Ogre::VertexData;
     quad_render_operation_.vertexData->vertexStart = 0;
-
     Ogre::VertexDeclaration* vertex_declaration
       = quad_render_operation_.vertexData->vertexDeclaration;
-
     size_t offset = 0;
-    vertex_declaration->addElement(
-      0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION
-    );
+    vertex_declaration->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE
-    );
-
-    quad_vertex_buffer_
-      = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
+    quad_vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
         vertex_declaration->getVertexSize(0), quad_max_vertex_,
         Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
     );
-
-    quad_render_operation_.vertexData->vertexBufferBinding->setBinding(
-      0, quad_vertex_buffer_
-    );
-    quad_render_operation_.operationType
-      = Ogre::RenderOperation::OT_TRIANGLE_LIST;
+    quad_render_operation_.vertexData->vertexBufferBinding->setBinding(0, quad_vertex_buffer_);
+    quad_render_operation_.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     quad_render_operation_.useIndexes = false;
 }
 
@@ -692,32 +584,20 @@ void DebugDraw::CreateTextVertexBuffer(){
     text_max_vertex_ = 4096 * 6;
     text_render_operation_.vertexData = new Ogre::VertexData;
     text_render_operation_.vertexData->vertexStart = 0;
-
     Ogre::VertexDeclaration* vertex_declaration
       = text_render_operation_.vertexData->vertexDeclaration;
-
     size_t offset = 0;
     vertex_declaration->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE
-    );
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES
-    );
-
-    text_vertex_buffer_
-      = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
-        vertex_declaration->getVertexSize(0), text_max_vertex_,
-        Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
-    );
-
-    text_render_operation_.vertexData->vertexBufferBinding->setBinding(
-      0, text_vertex_buffer_
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
+    text_vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
+      vertex_declaration->getVertexSize(0), text_max_vertex_,
+      Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
     );
-    text_render_operation_.operationType
-      = Ogre::RenderOperation::OT_TRIANGLE_LIST;
+    text_render_operation_.vertexData->vertexBufferBinding->setBinding(0, text_vertex_buffer_);
+    text_render_operation_.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     text_render_operation_.useIndexes = false;
 }
 

+ 59 - 178
V-Gears/src/core/DialogsManager.cpp

@@ -35,9 +35,7 @@ DialogsManager::DialogsManager():
   up_pressed_(false),
   down_pressed_(false),
   limit_area_(NULL)
-{
-    LOG_TRIVIAL("DialogsManager created.");
-}
+{LOG_TRIVIAL("DialogsManager created.");}
 
 DialogsManager::~DialogsManager(){
     for (unsigned int i = 0; i < messages_.size(); ++i) delete messages_[i];
@@ -47,27 +45,24 @@ DialogsManager::~DialogsManager(){
 void DialogsManager::Initialise(){
     UiWidget* g_widget = UiManager::getSingletonPtr()->GetWidget("Dialog");
     if (g_widget == NULL){
-        LOG_ERROR(
-          "Can't create DialogsManager because Widget \"Dialog\" not founded."
-        );
+        LOG_ERROR("Can't create DialogsManager because Widget 'Dialog' not founded.");
         return;
     }
     limit_area_ = g_widget->GetChild("LimitArea");
     if (limit_area_ == NULL){
         LOG_ERROR(
-          "Can't create DialogsManager because Widget \"LimitArea\" "
-          + "not founded in Widget \"Dialog\"."
+          "Can't create DialogsManager because Widget 'LimitArea' not founded in Widget 'Dialog'."
         );
         return;
     }
     unsigned int num = limit_area_->GetNumberOfChildren();
     for (unsigned int i = 0; i < num; ++i){
         UiWidget* widget = limit_area_->GetChild(i);
-        UiTextArea* text_area = (UiTextArea*) widget->GetChild("TextArea");
+        UiTextArea* text_area = static_cast<UiTextArea*>(widget->GetChild("TextArea"));
         if (text_area == NULL){
             LOG_ERROR(
-              "Can't create dialog \"" +widget->GetName()
-              + "\" because because text_area with name \"TextArea\" missing."
+              "Can't create dialog '" +widget->GetName()
+              + "' because because text_area with name 'TextArea' is missing."
             );
             continue;
         }
@@ -80,31 +75,19 @@ void DialogsManager::Initialise(){
         //data->text_area->SetTextScrollTime(0.267f);
         data->text_area->SetTextScrollTime(0.1f);
         data->cursor = widget->GetChild("Cursor");
-        if (data->cursor != NULL)
-            data->cursor->GetY(data->cursor_percent_y, data->cursor_y);
+        if (data->cursor != NULL) data->cursor->GetY(data->cursor_percent_y, data->cursor_y);
         messages_.push_back(data);
     }
     LOG_TRIVIAL("DialogsManager initialized.");
 }
 
 void DialogsManager::Input(const VGears::Event& input){
-    if ((input.type == VGears::ET_KEY_PRESS) && (input.event == "message_ok"))
-        next_pressed_ = true;
-    else if (
-      (input.type == VGears::ET_KEY_REPEAT) && (input.event == "message_ok")
-    ){
+    if (input.type == VGears::ET_KEY_PRESS && input.event == "message_ok") next_pressed_ = true;
+    else if (input.type == VGears::ET_KEY_REPEAT && input.event == "message_ok")
         next_repeated_ = true;
-    }
-    else if (
-      (input.type == VGears::ET_KEY_PRESS) && (input.event == "message_up")
-    ){
-        up_pressed_ = true;
-    }
-    else if (
-      (input.type == VGears::ET_KEY_PRESS) && (input.event == "message_down")
-    ){
+    else if (input.type == VGears::ET_KEY_PRESS && input.event == "message_up") up_pressed_ = true;
+    else if (input.type == VGears::ET_KEY_PRESS && input.event == "message_down")
         down_pressed_ = true;
-    }
 }
 
 void DialogsManager::Update(){
@@ -114,14 +97,9 @@ void DialogsManager::Update(){
                 {
                     if (
                       (messages_[i]->window == NULL)
-                      || (
-                        messages_[i]->window->GetCurrentAnimationName()
-                          == Ogre::BLANKSTRING
-                      )
+                      || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
                     ){
-                        messages_[i]->text_area->PlayAnimation(
-                          "Show", UiAnimation::ONCE, 0, -1
-                        );
+                        messages_[i]->text_area->PlayAnimation("Show", UiAnimation::ONCE, 0, -1);
                         messages_[i]->text_area->SetVisible(true);
                         messages_[i]->state = MS_SHOW_TEXT;
                     }
@@ -130,23 +108,16 @@ void DialogsManager::Update(){
             case MS_SHOW_TEXT:{
                 if (AutoCloseCheck(i) == true) break;
                 if (messages_[i]->clickable == true){
-                    if (next_pressed_ == true)
-                        messages_[i]->text_area->InputPressed();
-                    if (next_repeated_ == true)
-                        messages_[i]->text_area->InputRepeated();
+                    if (next_pressed_ == true) messages_[i]->text_area->InputPressed();
+                    if (next_repeated_ == true) messages_[i]->text_area->InputRepeated();
                 }
 
                 if (messages_[i]->text_area->GetTextState() == TS_DONE){
                     messages_[i]->state = MS_OPENED;
-
-                    if (
-                      (messages_[i]->cursor != NULL)
-                      && (messages_[i]->show_cursor == true)
-                    ){
+                    if (messages_[i]->cursor != NULL && messages_[i]->show_cursor == true){
                         messages_[i]->cursor->SetY(
                           messages_[i]->cursor_percent_y,
-                          messages_[i]->cursor_y
-                            + messages_[i]->cursor_row_current
+                          messages_[i]->cursor_y + messages_[i]->cursor_row_current
                             * messages_[i]->text_area->GetFont()->GetHeight()
                         );
                         messages_[i]->cursor->SetVisible(true);
@@ -156,18 +127,11 @@ void DialogsManager::Update(){
                 break;
             case MS_OPENED:
                 {
-                    if (
-                      messages_[i]->clickable == true
-                      && next_pressed_ == true
-                    ){
+                    if (messages_[i]->clickable == true && next_pressed_ == true){
                         messages_[i]->auto_close = true;
-                        if (
-                          (messages_[i]->cursor != NULL)
-                          && (messages_[i]->show_cursor == true)
-                        ){
+                        if ((messages_[i]->cursor != NULL) && (messages_[i]->show_cursor == true)){
                             messages_[i]->show_cursor = false;
-                            messages_[i]->cursor_row_selected
-                              = messages_[i]->cursor_row_current;
+                            messages_[i]->cursor_row_selected = messages_[i]->cursor_row_current;
                             messages_[i]->cursor->SetVisible(false);
                         }
                     }
@@ -177,30 +141,18 @@ void DialogsManager::Update(){
                       && (messages_[i]->show_cursor == true)
                       && (messages_[i]->clickable == true)
                     ){
-                        if (up_pressed_ == true)
-                            messages_[i]->cursor_row_current -= 1;
-                        else if (down_pressed_ == true)
-                            messages_[i]->cursor_row_current += 1;
-                        messages_[i]->cursor_row_current
-                          = (
-                            messages_[i]->cursor_row_current
-                            < messages_[i]->cursor_row_first
-                          )
-                          ? messages_[i]->cursor_row_last
-                          : messages_[i]->cursor_row_current;
-                        messages_[i]->cursor_row_current
-                          = (
-                            messages_[i]->cursor_row_current
-                            > messages_[i]->cursor_row_last
-                          )
-                          ? messages_[i]->cursor_row_first
-                          : messages_[i]->cursor_row_current;
-
+                        if (up_pressed_ == true) messages_[i]->cursor_row_current -= 1;
+                        else if (down_pressed_ == true) messages_[i]->cursor_row_current += 1;
+                        messages_[i]->cursor_row_current =
+                          (messages_[i]->cursor_row_current < messages_[i]->cursor_row_first)
+                            ? messages_[i]->cursor_row_last : messages_[i]->cursor_row_current;
+                        messages_[i]->cursor_row_current =
+                          (messages_[i]->cursor_row_current > messages_[i]->cursor_row_last)
+                            ? messages_[i]->cursor_row_first : messages_[i]->cursor_row_current;
                         messages_[i]->cursor->SetY(
                           messages_[i]->cursor_percent_y,
-                          messages_[i]->cursor_y
-                          + messages_[i]->cursor_row_current
-                          * messages_[i]->text_area->GetFont()->GetHeight()
+                          messages_[i]->cursor_y + messages_[i]->cursor_row_current
+                            * messages_[i]->text_area->GetFont()->GetHeight()
                         );
                     }
                 }
@@ -208,10 +160,7 @@ void DialogsManager::Update(){
             case MS_HIDE_WINDOW:{
                     if (
                       (messages_[i]->window == NULL)
-                      || (
-                        messages_[i]->window->GetCurrentAnimationName()
-                          == Ogre::BLANKSTRING
-                      )
+                      || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
                     ){
                         HideMessage(i);
                     }
@@ -227,26 +176,20 @@ void DialogsManager::Update(){
         int y = 34;
         for (unsigned int i = 0; i < messages_.size(); ++ i){
             Ogre::String caption;
-            caption
-              += "Message " + Ogre::StringConverter::toString(i) + ": "
+            caption += "Message " + Ogre::StringConverter::toString(i) + ": "
               + message_state_string[messages_[i]->state];
 
             if (messages_[i]->state == MS_SHOW_TEXT){
                 caption += " ("
-                  + Ogre::StringConverter::toString(
-                    int(messages_[i]->text_area->GetTextLimit())
-                  ) + "/"
-                  + Ogre::StringConverter::toString(
-                    messages_[i]->text_area->GetTextSize()
-                  );
+                  + Ogre::StringConverter::toString(int(messages_[i]->text_area->GetTextLimit()))
+                  + "/" + Ogre::StringConverter::toString(messages_[i]->text_area->GetTextSize());
 
                 switch(messages_[i]->text_area->GetTextState()){
                     case TS_PAUSE_OK: caption += " pause ok"; break;
                     case TS_PAUSE_TIME:
-                        caption += " pause time "
-                          + Ogre::StringConverter::toString(
-                            int(messages_[i]->text_area->GetPauseTime())
-                          );
+                        caption += " pause time " + Ogre::StringConverter::toString(
+                          int(messages_[i]->text_area->GetPauseTime())
+                        );
                         break;
                     case TS_OVERFLOW: caption += " overflow"; break;
                     case TS_NEXT_PAGE: caption += " next page"; break;
@@ -264,28 +207,18 @@ void DialogsManager::Update(){
     down_pressed_ = false;
 }
 
-
-
-void DialogsManager::Clear(){
-    for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);
-}
-
-
+void DialogsManager::Clear(){for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);}
 
 void DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] dialog_open: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("dialog_open: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return;
     }
     MessageData* data = messages_[id];
     if (data->state != MS_CLOSED){
         LOG_TRIVIAL(
-          "[SCRIPT] dialog_open: dialog \"" + Ogre::String(d_name)
-          + " already created. Close it first."
+          "dialog_open: dialog '" + Ogre::String(d_name) + "' already created. Close it first."
         );
         return;
     }
@@ -293,10 +226,8 @@ void DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h){
     data->y = y;
     data->w = w;
     data->h = h;
-
     LOG_TRIVIAL(
-      "[SCRIPT] dialog_open: dialog("
-      + std::to_string(x) + "," + std::to_string(y) + ","
+      "dialog_open: dialog(" + std::to_string(x) + "," + std::to_string(y) + ","
       + std::to_string(w) + "," + std::to_string(h) + ")"
     );
 }
@@ -304,19 +235,14 @@ void DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h){
 void DialogsManager::SetText(const char* d_name, const char* text){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] show_text: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("[SCRIPT] show_text: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return;
     }
     MessageData* data = messages_[id];
-
     // XML data can change dialog w/h VS what is in the lua script
     float width = 0.0f;
     float height = 0.0f;
-    TiXmlNode* xmlText
-      = TextManager::getSingleton().GetDialog(text, width, height);
+    TiXmlNode* xmlText = TextManager::getSingleton().GetDialog(text, width, height);
     if (xmlText != NULL){
         messages_[id]->text_area->SetText(xmlText);
         ShowMessage(
@@ -326,21 +252,15 @@ void DialogsManager::SetText(const char* d_name, const char* text){
         );
     }
     else{
-        messages_[id]->text_area->SetText(
-          std::string("[ERROR string not found:] ") + text
-        );
+        messages_[id]->text_area->SetText(std::string("[ERROR string not found:] ") + text);
         ShowMessage(id, data->x, data->y, data->w, data->h);
     }
-
 }
 
 int DialogsManager::Sync(const char* d_name){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] sync: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("sync: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return 1;
     }
 
@@ -349,36 +269,23 @@ int DialogsManager::Sync(const char* d_name){
     return -1;
 }
 
-
 void DialogsManager::Hide(const char* d_name){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] hide: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("hide: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return;
     }
     if (messages_[id]->state == MS_CLOSED){
-        LOG_TRIVIAL(
-          "[SCRIPT ERROR] hide: dialog \"" + Ogre::String(d_name)
-          + "\" already closed. Open it first."
-        );
+        LOG_TRIVIAL("hide: dialog '" + Ogre::String(d_name) + "' already closed. Open it first.");
         return;
     }
     messages_[id]->auto_close = true;
 }
 
-
-void DialogsManager::SetVariable(
-  const char* d_name, const char* name, const char* value
-){
+void DialogsManager::SetVariable(const char* d_name, const char* name, const char* value){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] set_variable: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("set_variable: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return;
     }
     messages_[id]->text_area->SetVariable(name, value);
@@ -387,32 +294,21 @@ void DialogsManager::SetVariable(
 void DialogsManager::SetClickable(const char* d_name, const bool clickable){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] set_clickable: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("set_clickable: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return;
     }
     messages_[id]->clickable = clickable;
 }
 
-
-
-void DialogsManager::SetCursor(
-  const char* d_name, const int first_row, const int last_row
-){
+void DialogsManager::SetCursor(const char* d_name, const int first_row, const int last_row){
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] set_cursor: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("set_cursor: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return;
     }
     if (messages_[id]->state != MS_CLOSED){
         LOG_TRIVIAL(
-          "[SCRIPT] set_cursor: dialog \"" + Ogre::String(d_name)
-          + "\" already shown. Close it first."
+          "set_cursor: dialog '" + Ogre::String(d_name) + "' already shown. Close it first."
         );
         return;
     }
@@ -425,17 +321,12 @@ void DialogsManager::SetCursor(
 int DialogsManager::GetCursor(const char* d_name) const{
     int id = GetMessageId(d_name);
     if (id == -1){
-        LOG_TRIVIAL(
-          "[SCRIPT] get_cursor: dialog \"" + Ogre::String(d_name)
-          + "\" doesn't exist."
-        );
+        LOG_TRIVIAL("get_cursor: dialog '" + Ogre::String(d_name) + "' doesn't exist.");
         return 0;
     }
     return messages_[id]->cursor_row_selected;
 }
 
-
-
 void DialogsManager::ShowMessage(
   const int id, const int x, const int y, const int width, const int height
 ){
@@ -454,7 +345,6 @@ void DialogsManager::ShowMessage(
     messages_[id]->widget->SetHeight(0, height);
     messages_[id]->widget->SetVisible(true);
     messages_[id]->auto_close = false;
-
     if (messages_[id]->window != NULL && messages_[id]->show_window == true){
         messages_[id]->window->SetVisible(true);
         messages_[id]->window->PlayAnimation("Show", UiAnimation::ONCE, 0, -1);
@@ -469,11 +359,8 @@ void DialogsManager::HideMessage(const int id){
     if (messages_[id]->cursor != NULL) messages_[id]->cursor->SetVisible(false);
     messages_[id]->text_area->SetVisible(false);
     messages_[id]->widget->SetVisible(false);
-    for (unsigned int i = 0; i < messages_[id]->sync.size(); ++ i){
-        ScriptManager::getSingleton().ContinueScriptExecution(
-          messages_[id]->sync[i]
-        );
-    }
+    for (unsigned int i = 0; i < messages_[id]->sync.size(); ++ i)
+        ScriptManager::getSingleton().ContinueScriptExecution(messages_[id]->sync[i]);
     messages_[id]->sync.clear();
 }
 
@@ -485,17 +372,11 @@ int DialogsManager::GetMessageId(const char* d_name) const{
 
 bool DialogsManager::AutoCloseCheck(const unsigned int id){
     if (messages_[id]->auto_close == true){
-        messages_[id]->text_area->PlayAnimation(
-          "Hide", UiAnimation::ONCE, 0, -1
-        );
-        if (messages_[id]->window != NULL){
-            messages_[id]->window->PlayAnimation(
-              "Hide", UiAnimation::ONCE, 0, -1
-            );
-        }
+        messages_[id]->text_area->PlayAnimation("Hide", UiAnimation::ONCE, 0, -1);
+        if (messages_[id]->window != NULL)
+            messages_[id]->window->PlayAnimation("Hide", UiAnimation::ONCE, 0, -1);
         messages_[id]->state = MS_HIDE_WINDOW;
         return true;
     }
-
     return false;
 }

+ 70 - 170
V-Gears/src/core/Entity.cpp

@@ -81,43 +81,33 @@ Entity::Entity(const Ogre::String& name, Ogre::SceneNode* node):
     direction_->setMaterial(mat_direction);
     direction_node_ = scene_node_->createChildSceneNode();
     direction_node_->attachObject(direction_);
-
     solid_collision_ = new EntityCollision();
     //solid_collision_->setMaterial("entity/solid_collision");
     Ogre::MaterialPtr mat_solid_collision
-      = Ogre::MaterialManager::getSingleton().getByName(
-        "entity/solid_collision"
-      );
+      = Ogre::MaterialManager::getSingleton().getByName("entity/solid_collision");
     solid_collision_->setMaterial(mat_solid_collision);
-
     solid_collision_node_ = scene_node_->createChildSceneNode();
     solid_collision_node_->setScale(solid_radius_, solid_radius_, height_);
     solid_collision_node_->attachObject(solid_collision_);
-
     talk_collision_ = new EntityCollision();
     //talk_collision_->setMaterial("entity/talk_collision");
     Ogre::MaterialPtr mat_talk_collision
-      = Ogre::MaterialManager::getSingleton().getByName(
-        "entity/talk_collision"
-      );
+      = Ogre::MaterialManager::getSingleton().getByName("entity/talk_collision");
     solid_collision_->setMaterial(mat_talk_collision);
-
     talk_collision_node_ = scene_node_->createChildSceneNode();
     talk_collision_node_->setScale(talk_radius_, talk_radius_, height_);
     talk_collision_node_->attachObject(talk_collision_);
-
     model_root_node_->setPosition(Ogre::Vector3::ZERO);
     model_node_->setPosition(Ogre::Vector3::ZERO);
     scene_node_->setPosition(Ogre::Vector3::ZERO);
-
-    LOG_TRIVIAL("Entity \"" + name_ + "\" created.");
+    LOG_TRIVIAL("Entity '" + name_ + "' created.");
 }
 
 Entity::~Entity(){
     delete solid_collision_;
     delete talk_collision_;
     scene_node_->removeAndDestroyAllChildren();
-    LOG_TRIVIAL("Entity \"" + name_ + "\" destroyed.");
+    LOG_TRIVIAL("Entity '" + name_ + "' destroyed.");
 }
 
 void Entity::Update() {
@@ -148,19 +138,12 @@ void Entity::UpdateDebug(){
         DEBUG_DRAW.Text(entity_pos, 0, 12, animation_current_name_);
 
         if (debug > 1){
-            static Ogre::String move_state_string[]
-              = { "NONE", "WALKMESH", "LINEAR", "JUMP" };
-
+            Ogre::String move_state_string[] = {"NONE", "WALKMESH", "LINEAR", "JUMP"};
+            DEBUG_DRAW.Text(entity_pos, 0, 24, Ogre::StringConverter::toString(entity_pos));
             DEBUG_DRAW.Text(
-              entity_pos, 0, 24, Ogre::StringConverter::toString(entity_pos)
-            );
-            DEBUG_DRAW.Text(
-              entity_pos, 0, 36,
-              "Triangle: " + Ogre::StringConverter::toString(move_triangle_id_)
-            );
-            DEBUG_DRAW.Text(
-              entity_pos, 0, 48, "Move state: " + move_state_string[state_]
+              entity_pos, 0, 36, "Triangle: " + Ogre::StringConverter::toString(move_triangle_id_)
             );
+            DEBUG_DRAW.Text(entity_pos, 0, 48, "Move state: " + move_state_string[state_]);
             switch(state_){
                 case Entity::WALKMESH:
                     DEBUG_DRAW.Line3d(entity_pos, move_position_);
@@ -171,19 +154,16 @@ void Entity::UpdateDebug(){
                       "Start: " + Ogre::StringConverter::toString(linear_start_)
                     );
                     DEBUG_DRAW.Text(
-                      linear_end_, 0, 0,
-                      "End: " + Ogre::StringConverter::toString(linear_end_)
+                      linear_end_, 0, 0, "End: " + Ogre::StringConverter::toString(linear_end_)
                     );
                     DEBUG_DRAW.Line3d(linear_start_, linear_end_);
                     break;
                 case Entity::JUMP:
                     DEBUG_DRAW.Text(
-                      jump_start_, 0, 0,
-                      "Start: " + Ogre::StringConverter::toString(jump_start_)
+                      jump_start_, 0, 0, "Start: " + Ogre::StringConverter::toString(jump_start_)
                     );
                     DEBUG_DRAW.Text(
-                      jump_end_, 0, 0,
-                      "End: " + Ogre::StringConverter::toString(jump_end_)
+                      jump_end_, 0, 0, "End: " + Ogre::StringConverter::toString(jump_end_)
                     );
                     Ogre::Vector3 distance = jump_end_ - jump_start_;
                     Ogre::Vector3 pos1, pos2, pos3;
@@ -217,20 +197,16 @@ void Entity::UpdateDebug(){
 
 const Ogre::String& Entity::GetName() const{return name_;}
 
-void Entity::SetPosition(const Ogre::Vector3& position){
-    scene_node_->setPosition(position);
-}
+void Entity::SetPosition(const Ogre::Vector3& position){scene_node_->setPosition(position);}
 
 void Entity::ScriptSetPosition(const float x, const float y, const float z){
     SetPosition(Ogre::Vector3(x, y, z));
     // If set from a script:
-    // reset walkmesh triangle to reattach entity to walkmesh again if needed
+    // Reset walkmesh triangle to reattach entity to walkmesh again if needed.
     move_triangle_id_ = -1;
 }
 
-const Ogre::Vector3 Entity::GetPosition() const{
-    return scene_node_->getPosition();
-}
+const Ogre::Vector3 Entity::GetPosition() const{return scene_node_->getPosition();}
 
 void Entity::ScriptGetPosition() const{
     Ogre::Vector3 position = scene_node_->getPosition();
@@ -252,8 +228,7 @@ const Ogre::Vector3 Entity::GetOffset() const{
 void Entity::SetRotation(const Ogre::Degree& rotation){
     assert(model_root_node_);
     float angle
-      = rotation.valueDegrees()
-      - Ogre::Math::Floor(rotation.valueDegrees() / 360.0f) * 360.0f;
+      = rotation.valueDegrees() - Ogre::Math::Floor(rotation.valueDegrees() / 360.0f) * 360.0f;
     if (angle < 0) angle = 360 + angle;
     Ogre::Quaternion q;
     Ogre::Vector3 vec = Ogre::Vector3::UNIT_Z;
@@ -262,9 +237,7 @@ void Entity::SetRotation(const Ogre::Degree& rotation){
     direction_node_->setOrientation(q);
 }
 
-void Entity::ScriptSetRotation(const float rotation){
-    SetRotation(Ogre::Degree(rotation));
-}
+void Entity::ScriptSetRotation(const float rotation){SetRotation(Ogre::Degree(rotation));}
 
 Ogre::Degree Entity::GetRotation() const{
     assert(model_root_node_);
@@ -334,40 +307,27 @@ void Entity::SetMoveRunSpeed(const float speed){move_run_speed_ = speed;}
 
 float Entity::GetMoveRunSpeed() const{return move_run_speed_;}
 
-void Entity::SetMovePosition(const Ogre::Vector3& target){
-    move_position_ = target;
-}
+void Entity::SetMovePosition(const Ogre::Vector3& target){move_position_ = target;}
 
 const Ogre::Vector3& Entity::GetMovePosition() const{return move_position_;}
 
 float Entity::GetMoveStopDistance() const{return move_stop_distance_;}
 
-void Entity::SetMoveTriangleId(const int triangle){
-    move_triangle_id_ = triangle;
-}
+void Entity::SetMoveTriangleId(const int triangle){move_triangle_id_ = triangle;}
 
 int Entity::GetMoveTriangleId() const{return move_triangle_id_;}
 
-void Entity::SetMoveAutoRotation(const bool rotate){
-    move_auto_rotation_ = rotate;
-}
+void Entity::SetMoveAutoRotation(const bool rotate){move_auto_rotation_ = rotate;}
 
 bool Entity::GetMoveAutoRotation() const{return move_auto_rotation_;}
 
-void Entity::SetMoveAutoAnimation(const bool animate){
-    move_auto_animation_ = animate;
-}
+void Entity::SetMoveAutoAnimation(const bool animate){move_auto_animation_ = animate;}
 
 bool Entity::GetMoveAutoAnimation() const{return move_auto_animation_;}
 
+const Ogre::String& Entity::GetMoveAnimationWalkName() const{return move_animation_walk_;}
 
-const Ogre::String& Entity::GetMoveAnimationWalkName() const{
-    return move_animation_walk_;
-}
-
-const Ogre::String& Entity::GetMoveAnimationRunName() const{
-    return move_animation_run_;
-}
+const Ogre::String& Entity::GetMoveAnimationRunName() const{return move_animation_run_;}
 
 void Entity::ScriptMoveToPosition(const float x, const float y){
     state_ = Entity::WALKMESH;
@@ -375,8 +335,8 @@ void Entity::ScriptMoveToPosition(const float x, const float y){
     move_entity_ = nullptr;
     move_stop_distance_ = 0;
     LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" set move to walkmesh position \""
-      + Ogre::StringConverter::toString(move_position_) + "\"."
+      "Entity '" + name_ + "' set move to walkmesh position '"
+      + Ogre::StringConverter::toString(move_position_) + "'."
     );
 }
 
@@ -385,18 +345,15 @@ void Entity::ScriptMoveToEntity(Entity* entity){
     move_position_ = entity->GetPosition();
     move_entity_ = entity;
     move_stop_distance_ = GetSolidRadius() + entity->GetSolidRadius();
-    LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" set move to entity \""
-      + entity->GetName() + "\"."
-    );
+    LOG_TRIVIAL("Entity '" + name_ + "' set move to entity '" + entity->GetName() + "'.");
 }
 
 int Entity::ScriptMoveSync(){
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     sync_.push_back(script);
     LOG_TRIVIAL(
-      "[SCRIPT] Wait entity \"" + name_ + "\" move for function \""
-      + script.function + "\" in script entity \"" + script.entity + "\"."
+      "Wait entity '" + name_ + "' move for function '"
+      + script.function + "' in script entity '" + script.entity + "'."
     );
     return -1;
 }
@@ -405,8 +362,7 @@ void Entity::UnsetMove(){
     state_ = Entity::NONE;
     move_entity_ = nullptr;
     move_stop_distance_ = 0;
-    for (const auto &script : sync_)
-        ScriptManager::getSingleton().ContinueScriptExecution(script);
+    for (const auto &script : sync_) ScriptManager::getSingleton().ContinueScriptExecution(script);
     sync_.clear();
 }
 
@@ -417,17 +373,16 @@ void Entity::ScriptLinearToPosition(
     Ogre::Vector3 pos = Ogre::Vector3(x, y, z);
     SetLinear(pos, movement, animation, orientation, dest_triangle);
     LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" set linear move to position \""
-      + Ogre::StringConverter::toString(pos) + "\" with animation \""
-      + animation + "\"."
+      "Entity '" + name_ + "' set linear move to position '"
+      + Ogre::StringConverter::toString(pos) + "' with animation '" + animation + "'."
     );
 }
 
 int Entity::ScriptLinearSync(){
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     LOG_TRIVIAL(
-      "[SCRIPT] Wait entity \"" + name_ + "\" linear move for function \""
-      + script.function + "\" in script entity \"" + script.entity + "\"."
+      "Wait entity '" + name_ + "' linear move for function '"
+      + script.function + "' in script entity '" + script.entity + "'."
     );
     sync_.push_back(script);
     return -1;
@@ -443,11 +398,9 @@ void Entity::SetLinear(
     linear_start_ = GetPosition();
     linear_end_ = end;
     linear_dest_triangle_ = dest_triangle;
-
     // Linear animation.
     animation_auto_play_ = false;
     PlayAnimation(animation, Entity::AUTO_ANIMATION, Entity::PLAY_LOOPED, 0, -1);
-
     // While moving, the entity is not in a triangle.
     move_triangle_id_ = -1;
 }
@@ -479,17 +432,16 @@ void Entity::ScriptJumpToPosition(
     Ogre::Vector3 jump_to(x, y, new_z);
     SetJump(jump_to, seconds, dest_triangle);
     LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" set jump to position \""
-      + Ogre::StringConverter::toString(jump_to) + "\" in "
-      + Ogre::StringConverter::toString(seconds) + " seconds."
+      "Entity '" + name_ + "' set jump to position '" + Ogre::StringConverter::toString(jump_to)
+      + "' in " + Ogre::StringConverter::toString(seconds) + " seconds."
     );
 }
 
 int Entity::ScriptJumpSync(){
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     LOG_TRIVIAL(
-      "[SCRIPT] Wait entity \"" + name_ + "\" jump for function \""
-      + script.function + "\" in script entity \"" + script.entity + "\"."
+      "Wait entity '" + name_ + "' jump for function '"
+      + script.function + "' in script entity '" + script.entity + "'."
     );
     sync_.push_back(script);
     return -1;
@@ -523,20 +475,17 @@ const Ogre::Vector3& Entity::GetJumpEnd() const{return jump_end_;}
 
 float Entity::GetJumpSeconds() const{return jump_seconds_;}
 
-void Entity::SetJumpCurrentSeconds(const float seconds){
-    jump_current_seconds_ = seconds;
-}
+void Entity::SetJumpCurrentSeconds(const float seconds){jump_current_seconds_ = seconds;}
 
 float Entity::GetJumpCurrentSeconds() const{ return jump_current_seconds_;}
 
 const int Entity::GetJumpDestTriangle() const{return jump_dest_triangle_;}
 
 void Entity::ScriptOffsetToPosition(
-  const float x, const float y, const float z,
-  const ActionType type, const float seconds
+  const float x, const float y, const float z, const ActionType type, const float seconds
 ){
     LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" set offset to position \""
+      "Entity '" + name_ + "' set offset to position '"
       + Ogre::StringConverter::toString(Ogre::Vector3(x, y, z)) + "'."
     );
     Ogre::Vector3 position = Ogre::Vector3(x, y, z);
@@ -554,8 +503,8 @@ void Entity::ScriptOffsetToPosition(
 int Entity::ScriptOffsetSync(){
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     LOG_TRIVIAL(
-      "[SCRIPT] Wait entity \"" + name_ + "\" offset for function \""
-      + script.function + "\" in script entity \"" + script.entity + "\"."
+      "Wait entity '" + name_ + "' offset for function '"
+      + script.function + "' in script entity '" + script.entity + "'."
     );
     offset_sync_.push_back(script);
     return -1;
@@ -568,21 +517,15 @@ void Entity::UnsetOffset(){
     offset_sync_.clear();
 }
 
-const Ogre::Vector3& Entity::GetOffsetPositionStart() const{
-    return offset_position_start_;
-}
+const Ogre::Vector3& Entity::GetOffsetPositionStart() const{return offset_position_start_;}
 
-const Ogre::Vector3& Entity::GetOffsetPositionEnd() const{
-    return offset_position_end_;
-}
+const Ogre::Vector3& Entity::GetOffsetPositionEnd() const{return offset_position_end_;}
 
 ActionType Entity::GetOffsetType() const{return offset_type_;}
 
 float Entity::GetOffsetSeconds() const{return offset_seconds_;}
 
-void Entity::SetOffsetCurrentSeconds(const float seconds){
-    offset_current_seconds_ = seconds;
-}
+void Entity::SetOffsetCurrentSeconds(const float seconds){offset_current_seconds_ = seconds;}
 
 float Entity::GetOffsetCurrentSeconds() const{return offset_current_seconds_;}
 
@@ -590,47 +533,36 @@ void Entity::ScriptTurnToDirection(
   const float direction, const TurnDirection turn_direction,
   const ActionType turn_type, const float seconds
 ){
-    SetTurn(
-      Ogre::Degree(direction), nullptr, turn_direction, turn_type, seconds
-    );
+    SetTurn(Ogre::Degree(direction), nullptr, turn_direction, turn_type, seconds);
     LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" turn to angle \""
-      + Ogre::StringConverter::toString(direction) + "\"."
+      "Entity '" + name_ + "' turn to angle '" + Ogre::StringConverter::toString(direction) + "'."
     );
 }
 
 void
-Entity::ScriptTurnToEntity(
-  Entity* entity, const TurnDirection turn_direction, const float seconds
-){
+Entity::ScriptTurnToEntity(Entity* entity, const TurnDirection turn_direction, const float seconds){
     if (entity == nullptr || entity == this){
-        LOG_ERROR(
-          "[SCRIPT] Turn to entity: Invalid entity pointer (NULL or this)."
-        );
+        LOG_ERROR("Turn to entity: Invalid entity pointer (NULL or self).");
         return;
     }
     Ogre::Degree angle = GetDirectionToEntity(entity);
     SetTurn(angle, entity, turn_direction, AT_SMOOTH, seconds);
-    LOG_TRIVIAL(
-      "[SCRIPT] Entity \"" + name_ + "\" turn to entity \""
-      + entity->GetName() + "."
-    );
+    LOG_TRIVIAL("Entity '" + name_ + "' turn to entity '" + entity->GetName() + ".");
 }
 
 int Entity::ScriptTurnSync(){
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     LOG_TRIVIAL(
-      "[SCRIPT] Wait entity \"" + name_ + "\" turn for function \""
-      + script.function + "\" in script entity \"" + script.entity + "\"."
+      "Wait entity '" + name_ + "' turn for function '"
+      + script.function + "' in script entity '" + script.entity + "'."
     );
     turn_sync_.push_back(script);
     return -1;
 }
 
 void Entity::SetTurn(
-  const Ogre::Degree& direction_to, Entity* entity,
-  const TurnDirection turn_direction, const ActionType turn_type,
-  const float seconds
+  const Ogre::Degree& direction_to, Entity* entity, const TurnDirection turn_direction,
+  const ActionType turn_type, const float seconds
 ){
     if (turn_type == AT_NONE){
         SetRotation(direction_to);
@@ -654,9 +586,7 @@ void Entity::UnsetTurn(){
     turn_sync_.clear();
 }
 
-Ogre::Degree Entity::CalculateTurnAngle(
-  const Ogre::Degree& start, const Ogre::Degree& end
-) const{
+Ogre::Degree Entity::CalculateTurnAngle(const Ogre::Degree& start, const Ogre::Degree& end) const{
     Ogre::Degree ret = end;
     switch(turn_direction_){
         case TD_CLOCKWISE:
@@ -677,9 +607,7 @@ Ogre::Degree Entity::CalculateTurnAngle(
     return ret;
 }
 
-Ogre::Degree Entity::GetTurnDirectionStart() const{
-    return turn_direction_start_;
-}
+Ogre::Degree Entity::GetTurnDirectionStart() const{return turn_direction_start_;}
 
 Ogre::Degree Entity::GetTurnDirectionEnd() const{return turn_direction_end_;}
 
@@ -687,58 +615,34 @@ ActionType Entity::GetTurnType() const{return turn_type_;}
 
 float Entity::GetTurnSeconds() const{return turn_seconds_;}
 
-void Entity::SetTurnCurrentSeconds(const float seconds){
-    turn_current_seconds_ = seconds;
-}
+void Entity::SetTurnCurrentSeconds(const float seconds){turn_current_seconds_ = seconds;}
 
 float Entity::GetTurnCurrentSeconds() const{return turn_current_seconds_;}
 
-void Entity::ScriptSetAnimationSpeed(const float speed){
-    animation_speed_ = speed;
-}
+void Entity::ScriptSetAnimationSpeed(const float speed){animation_speed_ = speed;}
 
-const Ogre::String& Entity::GetDefaultAnimationName() const{
-    return animation_default_;
-}
+const Ogre::String& Entity::GetDefaultAnimationName() const{return animation_default_;}
 
-const Ogre::String& Entity::GetCurrentAnimationName() const{
-    return animation_current_name_;
-}
+const Ogre::String& Entity::GetCurrentAnimationName() const{return animation_current_name_;}
 
-Entity::AnimationState Entity::GetAnimationState() const{
-    return animation_state_;
-}
+Entity::AnimationState Entity::GetAnimationState() const{return animation_state_;}
 
 void Entity::ScriptPlayAnimation(const char* name){
-    PlayAnimation(
-      Ogre::String(name), Entity::REQUESTED_ANIMATION,
-      Entity::PLAY_DEFAULT, 0, -1
-    );
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_DEFAULT, 0, -1);
 }
 
 void Entity::ScriptPlayAnimationStop(const char* name){
-    PlayAnimation(
-      Ogre::String(name), Entity::REQUESTED_ANIMATION,
-      Entity::PLAY_ONCE, 0, -1
-    );
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_ONCE, 0, -1);
 }
 
-void Entity::ScriptPlayAnimation(
-  const char* name, const float start, const float end
-){
+void Entity::ScriptPlayAnimation(const char* name, const float start, const float end){
     PlayAnimation(
-      Ogre::String(name), Entity::REQUESTED_ANIMATION,
-      Entity::PLAY_DEFAULT, start, end
+      Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_DEFAULT, start, end
     );
 }
 
-void Entity::ScriptPlayAnimationStop(
-  const char* name, const float start, const float end
-){
-    PlayAnimation(
-      Ogre::String(name), Entity::REQUESTED_ANIMATION,
-      Entity::PLAY_ONCE, start, end
-    );
+void Entity::ScriptPlayAnimationStop(const char* name, const float start, const float end){
+    PlayAnimation(Ogre::String(name), Entity::REQUESTED_ANIMATION, Entity::PLAY_ONCE, start, end);
 }
 
 void Entity::ScriptSetDefaultAnimation(const char* animation){
@@ -748,8 +652,8 @@ void Entity::ScriptSetDefaultAnimation(const char* animation){
 int Entity::ScriptAnimationSync(){
     ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();
     LOG_TRIVIAL(
-      "[SCRIPT] Wait entity \"" + name_ + "\" animation for function \""
-      + script.function + "\" in script entity \"" + script.entity + "\"."
+      "Wait entity '" + name_ + "' animation for function '"
+      + script.function + "' in script entity '" + script.entity + "'."
     );
     animation_sync_.push_back(script);
     return -1;
@@ -771,12 +675,8 @@ Ogre::Degree Entity::GetDirectionToEntity(Entity* entity) const{
     Ogre::Vector3 current_point = GetPosition();
     Ogre::Vector3 direction_point = entity->GetPosition();
     Ogre::Vector2 up(0.0f, -1.0f);
-    Ogre::Vector2 dir(
-      direction_point.x - current_point.x, direction_point.y - current_point.y
-    );
+    Ogre::Vector2 dir(direction_point.x - current_point.x, direction_point.y - current_point.y);
     // Angle between vectors
-    Ogre::Degree angle(
-      Ogre::Radian(acosf(dir.dotProduct(up) / (dir.length() * up.length())))
-    );
+    Ogre::Degree angle(Ogre::Radian(acosf(dir.dotProduct(up) / (dir.length() * up.length()))));
     return (dir.x < 0) ? Ogre::Degree(360) - angle : angle;
 }

+ 85 - 265
V-Gears/src/core/EntityManager.cpp

@@ -34,20 +34,9 @@ template<>EntityManager *Ogre::Singleton<EntityManager>::msSingleton = nullptr;
 ConfigVar cv_debug_grid("debug_grid", "Draw debug grid", "false");
 ConfigVar cv_debug_axis("debug_axis", "Draw debug axis", "false");
 
-/**
- * Calculates the point elevation over a plane.
- *
- * @param[in] point Point to calculate the elevation of.
- * @param[in] a First point of the plane.
- * @param[in] b Second point of the plane.
- * @param[in] c Third  point of the plane.
- * @return The elevation of the point.
- */
-float PointElevation(
-  const Ogre::Vector2& point,
-  const Ogre::Vector3& a, const Ogre::Vector3& b, const Ogre::Vector3& c
+float EntityManager::PointElevation(
+  const Ogre::Vector2& point, const Ogre::Vector3& a, const Ogre::Vector3& b, const Ogre::Vector3& c
 ){
-    // TODO: Declare function in header file.
     float _a = a.z * (b.y - c.y) + b.z * (c.y - a.y) + c.z * (a.y - b.y);
     float _b = a.y * (b.x - c.x) + b.y * (c.x - a.x) + c.y * (a.x - b.x);
     float _c = a.x * (b.z - c.z) + b.x * (c.z - a.z) + c.x * (a.z - b.z);
@@ -57,40 +46,16 @@ float PointElevation(
     return (_d - _c * point.y - _a * point.x) / _b;
 }
 
-/**
- * @todo Understand and document.
- *
- * @param[in] point @todo
- * @param[in] p1 @todo
- * @param[in] p2 @todo
- * @return @todo
- */
-float SideOfVector(
-  const Ogre::Vector2& point, const Ogre::Vector2& p1, const Ogre::Vector2& p2
-){
-    // TODO: Declare function in header file.
+float EntityManager::SideOfVector(const Ogre::Vector2& point, const Ogre::Vector2& p1, const Ogre::Vector2& p2){
     Ogre::Vector2 AB = p2    - p1;
     Ogre::Vector2 AP = point - p1;
     return AB.x * AP.y - AB.y * AP.x;
 }
 
-/**
- * Calculates the square distance between a point and a line.
- *
- * The calculated distance is the vector orthogonal to the line that
- * passes by the point, i.e. the shortest distance.
- *
- * @param[in] point The point.
- * @param[in] point_a First point of the line.
- * @param[in] point_b Second point of the line.
- * @param[out] proj Vector representing the shortest distance.
- * @return The distance from the point to the line.
- */
-float SquareDistanceToLine(
+float EntityManager::SquareDistanceToLine(
   const Ogre::Vector3& point, const Ogre::Vector3& point_a, const Ogre::Vector3& point_b,
   Ogre::Vector3& proj
 ){
-    // TODO: Declare function in header file.
     float temp =
       -((point_a.x - point.x) * (point_b.x - point_a.x) + (point_a.y - point.y)
       * (point_b.y - point_a.y) + (point_a.z - point.z) * (point_b.z - point_a.z))
@@ -105,33 +70,22 @@ float SquareDistanceToLine(
       ((point_a.x >= proj.x && point_b.x <= proj.x) || (point_a.x < proj.x && point_b.x >= proj.x))
       && (
         (point_a.y >= proj.y && point_b.y <= proj.y) || (point_a.y < proj.y && point_b.y >= proj.y)
-     )
-   ){
+      )
+    ){
         return (proj.x - point.x) * (proj.x - point.x) + (proj.y - point.y)
           * (proj.y - point.y) + (proj.z - point.z) * (proj.z - point.z);
     }
     return -1;
 }
 
-/**
- * Calculates the direction degree between to points.
- *
- * @param[in] current_point Origin point.
- * @param[in] direction_point Next point in the direction.
- * @return Degrees between the two points
- */
-Ogre::Degree GetDirectionToPoint(
+Ogre::Degree EntityManager::GetDirectionToPoint(
   const Ogre::Vector3& current_point, const Ogre::Vector3& direction_point
 ){
     // TODO: Declare function in header file.
     Ogre::Vector2 up(0.0f, -1.0f);
-    Ogre::Vector2 dir(
-      direction_point.x - current_point.x, direction_point.y - current_point.y
-   );
+    Ogre::Vector2 dir(direction_point.x - current_point.x, direction_point.y - current_point.y);
     // Angle between vectors
-    Ogre::Degree angle(
-      Ogre::Radian(acosf(dir.dotProduct(up) / (dir.length() * up.length())))
-   );
+    Ogre::Degree angle(Ogre::Radian(acosf(dir.dotProduct(up) / (dir.length() * up.length()))));
     return (dir.x < 0) ? Ogre::Degree(360) - angle : angle;
 }
 
@@ -151,55 +105,35 @@ EntityManager::EntityManager():
 
     //grid_ = Ogre::Root::getSingleton().getSceneManager("Scene")
     //  ->createEntity("Grid", "system/grid.mesh");
-    grid_ = Ogre::Root::getSingleton().getSceneManager("Scene")
-      ->createEntity("Grid", "grid.mesh");
+    grid_ = Ogre::Root::getSingleton().getSceneManager("Scene")->createEntity("Grid", "grid.mesh");
     scene_node_->attachObject(grid_);
     //axis_ = Ogre::Root::getSingleton().getSceneManager("Scene")
     //  ->createEntity("Axis", "system/axis.mesh");
-    axis_ = Ogre::Root::getSingleton().getSceneManager("Scene")
-      ->createEntity("Axis", "axis.mesh");
+    axis_ = Ogre::Root::getSingleton().getSceneManager("Scene")->createEntity("Axis", "axis.mesh");
     scene_node_->attachObject(axis_);
 }
 
 EntityManager::~EntityManager(){
-    if (grid_ != nullptr){
-        Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(
-          grid_
-        );
-    }
-    if (axis_ != nullptr){
-        Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(
-          axis_
-        );
-    }
+    if (grid_ != nullptr) Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(grid_);
+    if (axis_ != nullptr) Ogre::Root::getSingleton().getSceneManager("Scene")->destroyEntity(axis_);
     Clear();
-    Ogre::Root::getSingleton().getSceneManager("Scene")->getRootSceneNode()
-      ->removeAndDestroyChild("EntityManager");
+    Ogre::Root::getSingleton().getSceneManager("Scene")->getRootSceneNode()->removeAndDestroyChild(
+      "EntityManager"
+    );
     LOG_TRIVIAL("EntityManager destroyed.");
 }
 
 void EntityManager::Input(const VGears::Event& event){
     background_2d_.InputDebug(event);
     if (paused_ == true) return;
-
     if (player_entity_ != NULL && player_lock_ == false){
-        if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_left")
-            player_move_.x = -1;
-        else if (
-          event.type == VGears::ET_KEY_REPEAT && event.event == "walk_right"
-        ){
+        if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_left") player_move_.x = -1;
+        else if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_right")
             player_move_.x = 1;
-        }
-        if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_down")
-            player_move_.y = -1;
-        else if (
-          event.type == VGears::ET_KEY_REPEAT && event.event == "walk_up"
-        ){
+        if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_down") player_move_.y = -1;
+        else if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_up")
             player_move_.y = 1;
-        }
-        if (event.type == VGears::ET_KEY_REPEAT && event.event == "run")
-            player_run_ = true;
-
+        if (event.type == VGears::ET_KEY_REPEAT && event.event == "run") player_run_ = true;
         if (event.type == VGears::ET_KEY_PRESS && event.event == "interact"){
             CheckEntityInteract();
             for (unsigned int i = 0; i < entity_triggers_.size(); ++ i){
@@ -207,18 +141,17 @@ void EntityManager::Input(const VGears::Event& event){
                   entity_triggers_[i]->IsEnabled() == true
                   && entity_triggers_[i]->IsActivator(player_entity_) == true
                 ){
-                    ScriptEntity* scr_entity
-                      = ScriptManager::getSingleton().GetScriptEntityByName(
-                        ScriptManager::ENTITY, entity_triggers_[i]->GetName()
-                      );
+                    ScriptEntity* scr_entity = ScriptManager::getSingleton().GetScriptEntityByName(
+                      ScriptManager::ENTITY, entity_triggers_[i]->GetName()
+                    );
                     bool added = ScriptManager::getSingleton().ScriptRequest(
                       scr_entity, "on_interact", 1, "", "", false, false
                     );
                     if (added == false){
+                        // TODO: This pop's in almost any trigger, but it still works. Check it out.
                         LOG_WARNING(
-                          "Script \"on_interact\" for entity \""
-                          + entity_triggers_[i]->GetName()
-                          + "\" doesn't exist."
+                          "Script 'on_interact' for entity '" + entity_triggers_[i]->GetName()
+                          + "' doesn't exist."
                         );
                     }
                 }
@@ -243,11 +176,8 @@ void EntityManager::Update(){
         Entity::State state = player_entity_->GetState();
         if (state == Entity::WALKMESH || state == Entity::NONE){
             player_move_
-              *= player_entity_->GetMoveWalkSpeed()
-              * Timer::getSingleton().GetGameTimeDelta();
-            player_entity_->SetMovePosition(
-              player_entity_->GetPosition() + player_move_
-            );
+              *= player_entity_->GetMoveWalkSpeed() * Timer::getSingleton().GetGameTimeDelta();
+            player_entity_->SetMovePosition(player_entity_->GetPosition() + player_move_);
             player_entity_->SetState(Entity::WALKMESH);
         }
 
@@ -265,13 +195,11 @@ void EntityManager::Update(){
         // if time is stopped)
         if (Timer::getSingleton().GetGameTimeDelta() == 0) continue;
 
-        // update screen scroll
+        // Update screen scroll.
         Entity* scroll_entity = background_2d_.GetAutoScrollEntity();
         if (scroll_entity == entity_[i]){
             CameraManager &camera_manager(CameraManager::getSingleton());
-            Ogre::Vector3 view = camera_manager.ProjectPointToScreen(
-              scroll_entity->GetPosition()
-            );
+            Ogre::Vector3 view = camera_manager.ProjectPointToScreen(scroll_entity->GetPosition());
             Ogre::Vector2 pos = background_2d_.GetScreenScroll();
             Ogre::Viewport *viewport(camera_manager.getViewport());
             float width = float(viewport->getActualWidth());
@@ -280,40 +208,35 @@ void EntityManager::Update(){
             view.y = view.y - height / 2 - pos.y;
             background_2d_.SetScreenScroll(Ogre::Vector2(-view.x, -view.y));
         }
-
-        // Update offseting
-        if (entity_[i]->GetOffsetType() != AT_NONE)
-            SetNextOffsetStep(entity_[i]);
-
-        // Update turning
+        // Update offset.
+        if (entity_[i]->GetOffsetType() != AT_NONE) SetNextOffsetStep(entity_[i]);
+        // Update turn.
         if (entity_[i]->GetTurnType() != AT_NONE) SetNextTurnStep(entity_[i]);
-
-        // Update movement
+        // Update movement.
         switch(entity_[i]->GetState()){
             case Entity::WALKMESH:
                 {
-                    bool is_move = false;
-
-                    // Try set entity on walkmesh if it's still don't has triangle
+                    // Try set entity on walkmesh if it's still don't has triangle.
                     if (entity_[i]->GetMoveTriangleId() == -1){
                         if (SetEntityOnWalkmesh(entity_[i]) == false){
                             LOG_TRIVIAL(
-                              "Can't set entity \"" + entity_[i]->GetName()
-                              + "\" on walkmesh. Finish move."
+                              "Can't set entity '" + entity_[i]->GetName()
+                              + "' on walkmesh. Finish move."
                             );
                             entity_[i]->UnsetMove();
                         }
                     }
-
                     // Perform move
                     if (entity_[i]->GetState() == Entity::WALKMESH){
                         float speed = 0;
                         if (player_lock_ == false && player_entity_ == entity_[i]){
                             speed = entity_[i]->GetMoveWalkSpeed();
+                            // TODO: Set as a constant.
+                            // Or even better, as a configurable variable.
                             if (player_run_ == true) speed *= 4;
                         }
                         else speed = entity_[i]->GetMoveAutoSpeed();
-                        is_move = PerformWalkmeshMove(entity_[i], speed);
+                        bool is_move = PerformWalkmeshMove(entity_[i], speed);
                         if (entity_[i]->GetMoveAutoAnimation() == true){
                             if (is_move == true){
                                 if (speed >= entity_[i]->GetMoveRunSpeed()){
@@ -328,8 +251,7 @@ void EntityManager::Update(){
                                 }
                             }
                             else if (
-                              entity_[i]->GetAnimationState()
-                              != Entity::REQUESTED_ANIMATION
+                              entity_[i]->GetAnimationState() != Entity::REQUESTED_ANIMATION
                             ){
                                 entity_[i]->PlayAnimationContinue(
                                   entity_[i]->GetDefaultAnimationName()
@@ -339,20 +261,16 @@ void EntityManager::Update(){
                     }
                 }
                 break;
-
             case Entity::LINEAR:
                 CheckTriggers(entity_[i], entity_[i]->GetPosition());
                 SetNextLinearStep(entity_[i]);
                 break;
-
             case Entity::JUMP:
                 SetNextJumpStep(entity_[i]);
                 break;
-
             case Entity::NEEDS_TO_REATTACH:
                 if (SetEntityOnWalkmesh(entity_[i])) entity_[i]->SetState(Entity::WALKMESH);
                 else entity_[i]->SetState(Entity::NONE);
-
             case Entity::NONE:
                 CheckTriggers(entity_[i], entity_[i]->GetPosition());
                 if (entity_[i]->GetAnimationState() != Entity::REQUESTED_ANIMATION)
@@ -360,26 +278,19 @@ void EntityManager::Update(){
                 break;
         }
     }
-
     // Reset player move. It already must be handled in update
     player_move_ = Ogre::Vector3::ZERO;
     player_run_ = false;
-
-    if (background_2d_.GetScrollType() != Background2D::NONE)
-        SetNextScrollStep();
+    if (background_2d_.GetScrollType() != Background2D::NONE) SetNextScrollStep();
     background_2d_.Update();
 }
 
-
 void EntityManager::UpdateDebug(){
     grid_->setVisible(cv_debug_grid.GetB());
     axis_->setVisible(cv_debug_axis.GetB());
-    for (unsigned int i = 0; i < entity_.size(); ++ i)
-        entity_[i]->UpdateDebug();
-    for (unsigned int i = 0; i < entity_triggers_.size(); ++ i)
-        entity_triggers_[i]->UpdateDebug();
-    for (unsigned int i = 0; i < entity_points_.size(); ++ i)
-        entity_points_[i]->UpdateDebug();
+    for (unsigned int i = 0; i < entity_.size(); ++ i) entity_[i]->UpdateDebug();
+    for (unsigned int i = 0; i < entity_triggers_.size(); ++ i) entity_triggers_[i]->UpdateDebug();
+    for (unsigned int i = 0; i < entity_points_.size(); ++ i) entity_points_[i]->UpdateDebug();
     walkmesh_.UpdateDebug();
     background_2d_.UpdateDebug();
 }
@@ -391,9 +302,7 @@ void EntityManager::Clear(){
     background_2d_.Clear();
     DialogsManager::getSingleton().Clear();
     for (unsigned int i = 0; i < entity_.size(); ++ i){
-        ScriptManager::getSingleton().RemoveEntity(
-          ScriptManager::ENTITY, entity_[i]->GetName()
-        );
+        ScriptManager::getSingleton().RemoveEntity(ScriptManager::ENTITY, entity_[i]->GetName());
         delete entity_[i];
     }
     entity_.clear();
@@ -401,7 +310,6 @@ void EntityManager::Clear(){
     player_move_ = Ogre::Vector3::ZERO;
     player_move_rotation_ = 0;
     player_lock_ = false;
-
     for (unsigned int i = 0; i < entity_triggers_.size(); ++ i){
         ScriptManager::getSingleton().RemoveEntity(
           ScriptManager::ENTITY, entity_triggers_[i]->GetName()
@@ -409,17 +317,10 @@ void EntityManager::Clear(){
         delete entity_triggers_[i];
     }
     entity_triggers_.clear();
-
-    for (unsigned int i = 0; i < entity_points_.size(); ++ i)
-        delete entity_points_[i];
+    for (unsigned int i = 0; i < entity_points_.size(); ++ i) delete entity_points_[i];
     entity_points_.clear();
-
-    for (unsigned int i = 0; i < entity_scripts_.size(); ++ i){
-        ScriptManager::getSingleton().RemoveEntity(
-          ScriptManager::ENTITY, entity_scripts_[i]
-        );
-    }
-
+    for (unsigned int i = 0; i < entity_scripts_.size(); ++ i)
+        ScriptManager::getSingleton().RemoveEntity(ScriptManager::ENTITY, entity_scripts_[i]);
     scene_node_->removeAndDestroyAllChildren();
 }
 
@@ -440,9 +341,9 @@ void EntityManager::AddEntity(
 }
 
 void EntityManager::AddEntity(
-  const Ogre::String& name, const Ogre::String& file_name,
-  const Ogre::Vector3& position, const Ogre::Degree& rotation,
-  const Ogre::Vector3& scale, const Ogre::Quaternion& root_orientation, int index
+  const Ogre::String& name, const Ogre::String& file_name, const Ogre::Vector3& position,
+  const Ogre::Degree& rotation, const Ogre::Vector3& scale,
+  const Ogre::Quaternion& root_orientation, int index
 ){
     Ogre::SceneNode* node = scene_node_->createChildSceneNode("Model_" + name);
     EntityModel* entity = new EntityModel(name, file_name, node);
@@ -452,17 +353,13 @@ void EntityManager::AddEntity(
     entity->SetIndex(index);
     entity->setRootOrientation(root_orientation);
     entity_.push_back(entity);
-    ScriptManager::getSingleton().AddEntity(
-      ScriptManager::ENTITY, entity->GetName(), entity
-    );
+    ScriptManager::getSingleton().AddEntity(ScriptManager::ENTITY, entity->GetName(), entity);
 }
 
 void EntityManager::ScriptAddEntity(
   const char* name, const char* file_name,
   const float x, const float y, const float z, const float rotation, int index
-){
-    AddEntity(name, file_name, Ogre::Vector3(x, y, z), Ogre::Degree(rotation), index);
-}
+){AddEntity(name, file_name, Ogre::Vector3(x, y, z), Ogre::Degree(rotation), index);}
 
 void EntityManager::AddEntityTrigger(
   const Ogre::String& name,
@@ -472,9 +369,7 @@ void EntityManager::AddEntityTrigger(
     trigger->SetPoints(point1, point2);
     trigger->SetEnabled(enabled);
     entity_triggers_.push_back(trigger);
-    ScriptManager::getSingleton().AddEntity(
-      ScriptManager::ENTITY, trigger->GetName(), nullptr
-    );
+    ScriptManager::getSingleton().AddEntity(ScriptManager::ENTITY, trigger->GetName(), nullptr);
 }
 
 void EntityManager::AddEntityPoint(
@@ -486,37 +381,28 @@ void EntityManager::AddEntityPoint(
     entity_points_.push_back(entity_point);
 }
 
-
 void EntityManager::AddEntityScript(const Ogre::String& name){
     entity_scripts_.push_back(name);
-    ScriptManager::getSingleton().AddEntity(
-      ScriptManager::ENTITY, name, nullptr
-    );
+    ScriptManager::getSingleton().AddEntity(ScriptManager::ENTITY, name, nullptr);
 }
 
-void EntityManager::ScriptAddEntityScript(const char* name){
-    AddEntityScript(name);
-}
+void EntityManager::ScriptAddEntityScript(const char* name){AddEntityScript(name);}
 
 Entity* EntityManager::GetEntity(const Ogre::String& name) const{
-    for (unsigned int i = 0; i < entity_.size(); ++ i){
+    for (unsigned int i = 0; i < entity_.size(); ++ i)
         if (entity_[i]->GetName() == name) return entity_[i];
-    }
     return nullptr;
 }
 
 Entity* EntityManager::GetEntityFromIndex(const int index) const{
-    for (unsigned int i = 0; i < entity_.size(); ++ i){
+    for (unsigned int i = 0; i < entity_.size(); ++ i)
         if (entity_[i]->GetIndex() == index) return entity_[i];
-    }
     return nullptr;
 }
 
 Entity* EntityManager::GetEntityFromCharacterId(const int id) const{
-    for (unsigned int i = 0; i < entity_.size(); ++ i){
-        if (entity_[i]->IsCharacter() && entity_[i]->GetCharacterId() == id)
-            return entity_[i];
-    }
+    for (unsigned int i = 0; i < entity_.size(); ++ i)
+        if (entity_[i]->IsCharacter() && entity_[i]->GetCharacterId() == id) return entity_[i];
     return nullptr;
 }
 
@@ -526,16 +412,14 @@ Entity* EntityManager::ScriptGetEntity(const char* name) const{
 
 
 EntityPoint* EntityManager::ScriptGetEntityPoint(const char* name) const{
-    for (unsigned int i = 0; i < entity_points_.size(); ++ i){
+    for (unsigned int i = 0; i < entity_points_.size(); ++ i)
         if (entity_points_[i]->GetName() == name) return entity_points_[i];
-    }
     return nullptr;
 }
 
 void EntityManager::ScriptSetPlayerEntity(const char* name){
-    for (unsigned int i = 0; i < entity_.size(); ++ i){
+    for (unsigned int i = 0; i < entity_.size(); ++ i)
         if (entity_[i]->GetName() == name) player_entity_ = entity_[i];
-    }
 }
 
 Entity* EntityManager::ScriptGetPlayerEntity() const{return player_entity_;}
@@ -553,9 +437,7 @@ void EntityManager::SetPlayerMoveRotation(const Ogre::Radian rotation){
 
 bool EntityManager::GetRandomEncounters(){return random_encounters_;}
 
-void EntityManager::SetRandomEncounters(bool active){
-  random_encounters_ = active;
-}
+void EntityManager::SetRandomEncounters(bool active){random_encounters_ = active;}
 
 float EntityManager::GetEncounterRate(){return encounter_rate_;}
 
@@ -575,29 +457,24 @@ void EntityManager::StartBattle(unsigned int formation){
 bool EntityManager::IsKeyOn(unsigned int key_code){
     // If the player is locked, always false.
     // TODO: Maybe this will interfere with something down the road?
-    // Some scene where the player can't move but muts press a button?
+    // Some scene where the player can't move but must press a button?
     if (player_lock_) return false;
     unsigned int code = key_code;
     // Translate keycodes to game key codes.
     // For example 32 is standard for "Enter", but in game is "Circle/Action".
-    // TODO: Finish this list
+    // TODO: Finish this list.
     switch (key_code){
         case 32: code = OIS::KC_SPACE; break;
     }
     bool pressed = InputManager::getSingleton().IsButtonPressed(code);
-    //std::cout << "[IsKeyOn] Key " << key_code << " pressed: "
-    // << std::to_string(pressed) << std::endl;
     return pressed;
 }
 
 bool EntityManager::IsKeyOff(unsigned int key_code){return !IsKeyOn(key_code);}
 
 void EntityManager::SetEntityToCharacter(const char* entity_name, unsigned int char_id){
-    for (unsigned int i = 0; i < entity_.size(); ++ i){
-        if (entity_[i]->GetName() == entity_name){
-            entity_[i]->SetCharacter(char_id);
-        }
-    }
+    for (unsigned int i = 0; i < entity_.size(); ++ i)
+        if (entity_[i]->GetName() == entity_name) entity_[i]->SetCharacter(char_id);
 }
 
 bool EntityManager::SetEntityOnWalkmesh(Entity* entity){
@@ -606,7 +483,6 @@ bool EntityManager::SetEntityOnWalkmesh(Entity* entity){
     position2.x = position3.x;
     position2.y = position3.y;
     std::vector<std::pair<int, float>> triangles;
-
     // Search for possible triangles.
     for (int i = 0; i < walkmesh_.GetNumberOfTriangles(); ++ i){
         Ogre::Vector3 A3 = walkmesh_.GetA(i);
@@ -615,27 +491,23 @@ bool EntityManager::SetEntityOnWalkmesh(Entity* entity){
         Ogre::Vector2 A2(A3.x, A3.y);
         Ogre::Vector2 B2(B3.x, B3.y);
         Ogre::Vector2 C2(C3.x, C3.y);
-
         if (Ogre::Math::pointInTri2D(position2, A2, B2, C2) == true){
             triangles.push_back(std::make_pair(i, PointElevation(
               position2, walkmesh_.GetA(i), walkmesh_.GetB(i), walkmesh_.GetC(i)
             )));
         }
     }
-
     // If the coordinates doesn't match any triangle, exit.
     if (triangles.size() == 0){
         LOG_ERROR(
-          "Can't find any triangle to place entity \"" + entity->GetName() + "\" on walkmesh."
+          "Can't find any triangle to place entity '" + entity->GetName() + "' on walkmesh."
         );
         return false;
     }
-
     // From the possible triangles, select the closest one (on the Z edge).
     int closest_z_triangle = -1;
     float closest_z_distance = 9999.0f;
     float pos_z = position3.z;
-    int triangle_id = -1;
     for (size_t i = 0; i < triangles.size(); ++ i){
         if (std::abs(pos_z - triangles[i].second) < closest_z_distance){
             closest_z_triangle = triangles[i].first;
@@ -644,7 +516,7 @@ bool EntityManager::SetEntityOnWalkmesh(Entity* entity){
     }
     if (closest_z_triangle == -1){
         LOG_ERROR(
-          "Can't find nearby triangle to place entity \"" + entity->GetName() + "\" on walkmesh."
+          "Can't find nearby triangle to place entity '" + entity->GetName() + "' on walkmesh."
         );
         return false;
     }
@@ -660,20 +532,16 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
     direction.normalise();
     direction *= Timer::getSingleton().GetGameTimeDelta();
     direction *= speed;
-
-    // If movement is still needed but speed or time don't allow it, just
-    // return for now.
+    // If movement is still needed but speed or time don't allow it, just return for now.
     if (direction.isZeroLength() == true){
         CheckTriggers(entity, entity->GetPosition());
         return false;
     }
-
     int current_triangle = entity->GetMoveTriangleId();
     if (current_triangle == -1){
-        LOG_ERROR("Entity \"" + entity->GetName() + "\" not placed on walkmesh and can't move.");
+        LOG_ERROR("Entity '" + entity->GetName() + "' not placed on walkmesh and can't move.");
         return false;
     }
-
     Ogre::Vector3 rotation(0.0f, 0.0f, 0.0f);
     Ogre::Quaternion q1(0.0f, 0.0f, 0.0f, 1.0f);
     Ogre::Vector3 end_point(0.0f, 0.0f, 0.0f);
@@ -685,21 +553,18 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
     bool first_entity_check = false;
     bool second_entity_check = false;
     bool third_entity_check = false;
-
     // Shorten move vector by triangle angle
     end_point.x = start_point.x + direction.x;
     end_point.y = start_point.y + direction.y;
     Ogre::Vector3 A3 = walkmesh_.GetA(current_triangle);
     Ogre::Vector3 B3 = walkmesh_.GetB(current_triangle);
     Ogre::Vector3 C3 = walkmesh_.GetC(current_triangle);
-
     end_point.z = PointElevation(Ogre::Vector2(end_point.x, end_point.y), A3, B3, C3);
     Ogre::Vector3 temp = end_point - start_point;
     temp.normalise();
     temp = temp * direction.length();
     direction.x = temp.x;
     direction.y = temp.y;
-
     // Set the direction for the entity if it has to move.
     if (entity->GetMoveAutoRotation() == true){
         Ogre::Vector2 up(0.0f, -1.0f);
@@ -710,12 +575,9 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
         angle = (direction.x < 0) ? Ogre::Degree(360) - angle : angle;
         entity->SetRotation(Ogre::Degree(angle));
     }
-
     float solid = (entity->IsSolid() == true) ? entity->GetSolidRadius() : 0.01f;
-
     // Get ending point.
     end_point.z = start_point.z;
-
     for (
       int i = 0;
       (entity == player_entity_ && i < 16)
@@ -726,7 +588,6 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
         end_point = Ogre::Vector3(
           start_point.x + direction.x, start_point.y + direction.y, start_point.z
         );
-
         // 1st check.
         // Rotate move_vector +45.
         q1.FromAngleAxis(Ogre::Radian(Ogre::Degree(45)), Ogre::Vector3::UNIT_Z);
@@ -735,17 +596,13 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
         rotation.z = 0;
         rotation.normalise();
         rotation = q1 * rotation;
-
         // Multiply move_vector by solid range
         rotation = rotation * solid;
         end_point2.x = end_point.x + rotation.x;
         end_point2.y = end_point.y + rotation.y;
-
         // Check_triangle.
-        first_triangle_check
-          = WalkmeshBorderCross(entity, end_point2, direction);
+        first_triangle_check = WalkmeshBorderCross(entity, end_point2, direction);
         entity->SetMoveTriangleId(current_triangle);
-
         // Model check.
         first_entity_check = CheckSolidCollisions(entity, end_point2);
 
@@ -757,16 +614,13 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
         rotation.z = 0;
         rotation.normalise();
         rotation = q1 * rotation;
-
         // Multiply move_vector by solid range.
         rotation = rotation * solid;
         end_point2.x = end_point.x + rotation.x;
         end_point2.y = end_point.y + rotation.y;
-
         // Check triangle.
         second_triangle_check = WalkmeshBorderCross(entity, end_point2, direction);
         entity->SetMoveTriangleId(current_triangle);
-
         // Model check.
         second_entity_check = CheckSolidCollisions(entity, end_point2);
 
@@ -778,11 +632,9 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
         rotation = rotation * solid;
         end_point2.x = end_point.x + rotation.x;
         end_point2.y = end_point.y + rotation.y;
-
         // Check triangle.
         third_triangle_check = WalkmeshBorderCross(entity, end_point2, direction);
         entity->SetMoveTriangleId(current_triangle);
-
         // Model check.
         third_entity_check = CheckSolidCollisions(entity, end_point2);
 
@@ -794,7 +646,6 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
         ){
             // Only for NPC.
             if (entity != player_entity_){
-
                 // If the entity collides only directly into a triangle border.
                 if (
                   first_triangle_check  == false
@@ -808,7 +659,6 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
                     direction.x = rotation.x;
                     direction.y = rotation.y;
                 }
-
                 // Or if the entity only collides into other entity directly.
                 else if (
                   first_entity_check == false && second_entity_check == false
@@ -865,10 +715,7 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
                 ){
                     // If not both left and right check failed
                     if (first_triangle_check == false || second_triangle_check == false){
-                        if (
-                          (first_triangle_check == false && first_entity_check != false)
-                          || (first_triangle_check != false && second_triangle_check == false)
-                        ){
+                        if (first_triangle_check != false && second_triangle_check == false){
                             q1.FromAngleAxis(
                               Ogre::Radian(Ogre::Degree(-11.25f)), Ogre::Vector3::UNIT_Z
                             );
@@ -879,11 +726,7 @@ bool EntityManager::PerformWalkmeshMove(Entity* entity, const float speed){
                             direction.y = rotation.y;
                         }
 
-                        if (
-                          first_triangle_check == false
-                          && first_entity_check == false
-                          && (second_triangle_check != false || second_entity_check != false)
-                        ){
+                        if (first_triangle_check == false && second_triangle_check != false){
                             q1.FromAngleAxis(
                               Ogre::Radian(Ogre::Degree(11.25f)), Ogre::Vector3::UNIT_Z
                             );
@@ -932,9 +775,7 @@ bool EntityManager::WalkmeshBorderCross(
 ){
     int current_triangle = entity->GetMoveTriangleId();
     if (current_triangle == -1) return true;
-
     Ogre::Vector2 pos = Ogre::Vector2(position.x, position.y);
-
     for (;;){
         Ogre::Vector3 A3 = walkmesh_.GetA(current_triangle);
         Ogre::Vector3 B3 = walkmesh_.GetB(current_triangle);
@@ -946,19 +787,14 @@ bool EntityManager::WalkmeshBorderCross(
         float sign2 = SideOfVector(pos, C, B);
         float sign3 = SideOfVector(pos, A, C);
         int next_triangle = -1;
-
-        if (sign1 < 0)
-            next_triangle = walkmesh_.GetAccessSide(current_triangle, 0);
-        else if (sign2 < 0)
-            next_triangle = walkmesh_.GetAccessSide(current_triangle, 1);
-        else if (sign3 < 0)
-            next_triangle = walkmesh_.GetAccessSide(current_triangle, 2);
+        if (sign1 < 0) next_triangle = walkmesh_.GetAccessSide(current_triangle, 0);
+        else if (sign2 < 0) next_triangle = walkmesh_.GetAccessSide(current_triangle, 1);
+        else if (sign3 < 0) next_triangle = walkmesh_.GetAccessSide(current_triangle, 2);
         else{
             position.z = PointElevation(pos, A3, B3, C3);
             entity->SetMoveTriangleId(current_triangle);
             return false;
         }
-
         if (next_triangle >= 0){
             bool lock = walkmesh_.IsLocked(next_triangle);
             if (lock == false){
@@ -966,18 +802,14 @@ bool EntityManager::WalkmeshBorderCross(
                 continue;
             }
         }
-
         position.z = PointElevation(pos, A3, B3, C3);
         entity->SetMoveTriangleId(current_triangle);
         return true;
     }
 }
 
-bool EntityManager::CheckSolidCollisions(
-  Entity* entity, Ogre::Vector3& position
-){
+bool EntityManager::CheckSolidCollisions(Entity* entity, Ogre::Vector3& position){
     if (entity->IsSolid() == false) return false;
-
     for (size_t i = 0; i < entity_.size(); ++ i){
         if (entity_[i]->IsSolid() == false) continue;
         if (entity_[i] == entity) continue;
@@ -985,14 +817,12 @@ bool EntityManager::CheckSolidCollisions(
         float solid_range = entity_[i]->GetSolidRadius();
         solid_range *= solid_range;
         float height = (pos1.z < position.z) ? entity_[i]->GetHeight() : entity->GetHeight();
-
         if (
           ((pos1.z - position.z + height) < (height * 2)) && ((pos1.z - position.z + height) >= 0)
         ){
             float distance
               = (pos1.x - position.x) * (pos1.x - position.x)
               + (pos1.y - position.y) * (pos1.y - position.y);
-
             if (distance < solid_range) return true;
         }
     }
@@ -1001,7 +831,6 @@ bool EntityManager::CheckSolidCollisions(
 
 void EntityManager::CheckTriggers(Entity* entity, const Ogre::Vector3& position){
     if (entity->IsSolid() == false) return;
-
     bool is_moving = true;
     if (
       std::fabs(entity->GetPosition().x - position.x) < 0.01f
@@ -1076,8 +905,8 @@ void EntityManager::CheckTriggers(Entity* entity, const Ogre::Vector3& position)
                       trigger, "on_cross_line", 1, entity->GetName(), "", true, true
                     );
                     // Test on_cross_line_once.
-                    // Same conditions that on_cross_line, but triggered only once (i.e. if the entity
-                    // has not been registered as an activator.
+                    // Same conditions that on_cross_line, but triggered only once (i.e. if the
+                    // entity has not been registered as an activator.
                     //std::cout << "    [TRIGGER] " << entity->GetName()
                     //  << " on_cross_line_once " << entity_triggers_[i]->GetName() << std::endl;
                     if (entity_triggers_[i]->IsActivator(entity) == false){
@@ -1110,33 +939,26 @@ void EntityManager::CheckTriggers(Entity* entity, const Ogre::Vector3& position)
 void EntityManager::CheckEntityInteract(){
     if (player_entity_ == NULL || player_lock_ == true || player_entity_->IsSolid() == false)
         return;
-
     Ogre::Degree angle_pc = player_entity_->GetRotation();
     Entity* entity_to_interact = NULL;
     Ogre::Degree less_angle(90);
-
     for (unsigned int i = 0; i < entity_.size(); ++ i){
         if (entity_[i]->IsTalkable() == false) continue;
         if (entity_[i] == player_entity_) continue;
-
         Ogre::Vector3 pos1 =  entity_[i]->GetPosition();
         float interact_range =  entity_[i]->GetTalkRadius();
         Ogre::Vector3 pos2 = player_entity_->GetPosition();
         float solid_range = player_entity_->GetSolidRadius();
-
         int height = (pos1.z < pos2.z) ? entity_[i]->GetHeight() : player_entity_->GetHeight();
-
         if (((pos1.z - pos2.z + height) < (height * 2)) && ((pos1.z - pos2.z + height) >= 0)){
             interact_range = (interact_range + solid_range) * (interact_range + solid_range);
             float distance
               = (pos1.x - pos2.x) * (pos1.x - pos2.x) + (pos1.y - pos2.y) * (pos1.y - pos2.y);
-
             if (distance < interact_range + solid_range){
                 Ogre::Degree angle_to_model = GetDirectionToPoint(pos2, pos1);
                 Ogre::Degree angle = angle_pc - angle_to_model;
                 angle = (angle < Ogre::Degree(0)) ? -angle : angle;
                 angle = (angle >= Ogre::Degree(180)) ? Ogre::Degree(360) - angle : angle;
-
                 if (angle < less_angle){
                     angle = less_angle;
                     entity_to_interact = entity_[i];
@@ -1144,7 +966,6 @@ void EntityManager::CheckEntityInteract(){
             }
         }
     }
-
     if (entity_to_interact != NULL && entity_to_interact->IsLine() == false){
         Ogre::String name = entity_to_interact->GetName();
         ScriptEntity* scr_entity = ScriptManager::getSingleton().GetScriptEntityByName(
@@ -1154,7 +975,7 @@ void EntityManager::CheckEntityInteract(){
           scr_entity, "on_interact", 1, "", "", false, false
         );
         if (added == false){
-            LOG_WARNING("Script \"on_interact\" for entity \"" +  name + "\" doesn't exist.");
+            LOG_WARNING("Script 'on_interact' for entity '" +  name + "' doesn't exist.");
         }
     }
 }
@@ -1167,8 +988,8 @@ void EntityManager::SetNextOffsetStep(Entity* entity){
     current = (current > total) ? total : current;
     Ogre::Vector3 start = entity->GetOffsetPositionStart();
     Ogre::Vector3 end = entity->GetOffsetPositionEnd();
+    // TODO: Prevent division by 0:
     float x = current / total;
-    // Prevent division by 0:
     if (std::isnan(x)) x = 0.0f;
     float smooth_modifier = (type == AT_SMOOTH) ? -2 * x * x * x + 3 * x * x : x;
     Ogre::Vector3 offset = start + (end - start) * smooth_modifier;
@@ -1185,6 +1006,7 @@ void EntityManager::SetNextTurnStep(Entity* entity){
     current = (current > total) ? total : current;
     Ogre::Degree start = entity->GetTurnDirectionStart();
     Ogre::Degree end = entity->GetTurnDirectionEnd();
+    // TODO: Prevent division by 0:
     float x = current / total;
     float smooth_modifier = (type == AT_SMOOTH) ? -2 * x * x * x + 3 * x * x : x;
     Ogre::Degree rotation = start + (end - start) * smooth_modifier;
@@ -1199,7 +1021,6 @@ void EntityManager::SetNextLinearStep(Entity* entity){
     Ogre::Vector3 start = entity->GetLinearStart();
     Ogre::Vector3 end = entity->GetLinearEnd();
     Ogre::Vector3 current = entity->GetPosition();
-
     float delta = Timer::getSingleton().GetGameTimeDelta();
     if (entity == player_entity_){
         LinearMovement move = entity->GetLinearMovement();
@@ -1264,7 +1085,6 @@ void EntityManager::SetNextLinearStep(Entity* entity){
                 SetEntityOnWalkmesh(entity);
             }
         }
-
         entity->SetPosition(position);
         entity->UpdateAnimation((to_end == true) ? delta : -delta);
     }

+ 17 - 46
V-Gears/src/core/GameFrameListener.cpp

@@ -14,8 +14,8 @@
  */
 
 #include <OgreStringConverter.h>
-#include "../../include/core/GameFrameListener.h"
 #include "VGearsGameState.h"
+#include "core/GameFrameListener.h"
 #include "core/CameraManager.h"
 #include "core/ConfigVar.h"
 #include "core/Console.h"
@@ -31,11 +31,8 @@
 ConfigVar cv_debug_fps("debug_fps", "Debug FPS", "false");
 
 GameFrameListener::GameFrameListener(Ogre::RenderWindow* win):
-  window_(win),
-  input_manager_(0),
-  keyboard_(0)
+  window_(win), input_manager_(0), keyboard_(0)
 {
-    // TODO: Focus stealing problem must be here
     OIS::ParamList pl;
     size_t windowHnd = 0;
     std::ostringstream windowHndStr;
@@ -43,34 +40,21 @@ GameFrameListener::GameFrameListener(Ogre::RenderWindow* win):
     windowHndStr << windowHnd;
     pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
 #if defined __WIN32__
-    pl.insert(
-      std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND"))
-    );
-    pl.insert(std::make_pair(
-      std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")
-    ));
+    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
 #else
-    pl.insert(
-      std::make_pair(std::string("x11_mouse_grab"), std::string("false"))
-    );
-    pl.insert(
-      std::make_pair(std::string("x11_mouse_hide"), std::string("false"))
-    );
-    // pl.insert(
-    //  std::make_pair(std::string("x11_keyboard_grab"), std::string("false"))
-    //);
+    pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
+    pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
+    pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
 #endif
     input_manager_ = OIS::InputManager::createInputSystem(pl);
     keyboard_ = static_cast<OIS::Keyboard*>(
       input_manager_->createInputObject(OIS::OISKeyboard, true)
     );
     keyboard_->setEventCallback(this);
-    mouse_ = static_cast<OIS::Mouse*>(
-      input_manager_->createInputObject(OIS::OISMouse, true)
-    );
+    mouse_ = static_cast<OIS::Mouse*>(input_manager_->createInputObject(OIS::OISMouse, true));
     mouse_->setEventCallback(this);
-    windowResized(window_);
-
+    this->windowResized(window_);
     //Register as a Window listener
     Ogre::WindowEventUtilities::addWindowEventListener(window_, this);
 }
@@ -81,7 +65,7 @@ GameFrameListener::~GameFrameListener(){
     OIS::InputManager::destroyInputSystem(input_manager_);
     //Remove ourself as a Window listener
     Ogre::WindowEventUtilities::removeWindowEventListener(window_, this);
-    windowClosed(window_);
+    this->windowClosed(window_);
 }
 
 bool GameFrameListener::frameStarted(const Ogre::FrameEvent& evt){
@@ -90,7 +74,7 @@ bool GameFrameListener::frameStarted(const Ogre::FrameEvent& evt){
     if(keyboard_) keyboard_->capture();
     if(mouse_) mouse_->capture();
     InputManager::getSingleton().Update();
-    static InputEventArray input_event_array;
+    InputEventArray input_event_array;
     input_event_array.clear();
     InputManager::getSingleton().GetInputEvents(input_event_array);
     bool console_active = Console::getSingleton().IsVisible();
@@ -100,9 +84,7 @@ bool GameFrameListener::frameStarted(const Ogre::FrameEvent& evt){
             EntityManager::getSingleton().Input(input_event_array[ i ]);
             DialogsManager::getSingleton().Input( input_event_array[ i ] );
             ScriptManager::getSingleton().Input(input_event_array[ i ]);
-            CameraManager::getSingleton().Input(
-              input_event_array[ i ], evt.timeSinceLastFrame
-            );
+            CameraManager::getSingleton().Input(input_event_array[ i ], evt.timeSinceLastFrame);
         }
     }
     Console::getSingleton().Update();
@@ -120,10 +102,7 @@ bool GameFrameListener::frameEnded(const Ogre::FrameEvent& evt){
         DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
         DEBUG_DRAW.SetScreenSpace(true);
         DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
-        DEBUG_DRAW.Text(
-          10, 10,
-          "Current FPS:" + Ogre::StringConverter::toString(stats.lastFPS)
-        );
+        DEBUG_DRAW.Text(10, 10, "Current FPS:" + Ogre::StringConverter::toString(stats.lastFPS));
     }
     return true;
 }
@@ -161,25 +140,17 @@ bool GameFrameListener::keyReleased(const OIS::KeyEvent& event){
 
 
 bool GameFrameListener::mouseMoved(const OIS::MouseEvent& e){
-    if(e.state.Z.rel != 0)
-        InputManager::getSingleton().MouseScrolled(e.state.Z.rel);
-    else
-        InputManager::getSingleton().MouseMoved(e.state.X.rel, e.state.Y.rel);
-
+    if(e.state.Z.rel != 0) InputManager::getSingleton().MouseScrolled(e.state.Z.rel);
+    else InputManager::getSingleton().MouseMoved(e.state.X.rel, e.state.Y.rel);
     return true;
 }
 
-bool GameFrameListener::mousePressed(
-  const OIS::MouseEvent& e, OIS::MouseButtonID id
-){
+bool GameFrameListener::mousePressed(const OIS::MouseEvent& e, OIS::MouseButtonID id){
     InputManager::getSingleton().MousePressed(id, true);
     return true;
 }
 
-
-bool GameFrameListener::mouseReleased(
-  const OIS::MouseEvent& e, OIS::MouseButtonID id
-){
+bool GameFrameListener::mouseReleased(const OIS::MouseEvent& e, OIS::MouseButtonID id){
     InputManager::getSingleton().MousePressed(id, false);
     return true;
 }

+ 2 - 2
V-Gears/src/core/TextManager.cpp

@@ -23,7 +23,7 @@ template<>TextManager* Ogre::Singleton< TextManager >::msSingleton = NULL;
 
 TextManager::TextManager(): language_(""){
     for (int i = 0; i < 3; i ++) current_party_[i] = -1;
-    for (int i = 0; i < 11; i ++) character_names_[i] = "CHAR_" + i;
+    for (int i = 0; i < 11; i ++) character_names_[i] = std::string("CHAR_") + std::to_string(i);
     InitCmd();
 }
 
@@ -64,7 +64,7 @@ void TextManager::AddDialog(
 TiXmlNode* TextManager::GetText(const Ogre::String& name) const{
     for (unsigned int i = 0; i < texts_.size(); ++ i)
         if (texts_[i].name == name) return texts_[i].node;
-    LOG_WARNING("Can't find text \"" + name + "\".");
+    LOG_WARNING("Can't find text '" + name + "'.");
     return NULL;
 }
 

+ 12 - 66
V-Gears/src/core/UiSprite.cpp

@@ -20,14 +20,9 @@
 #include "core/UiSprite.h"
 
 
-UiSprite::UiSprite(const Ogre::String& name):
-  UiWidget(name)
-{Initialise();}
-
+UiSprite::UiSprite(const Ogre::String& name): UiWidget(name){Initialise();}
 
-UiSprite::UiSprite(
-  const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent
-):
+UiSprite::UiSprite(const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent):
   UiWidget(name, path_name, parent)
 {Initialise();}
 
@@ -63,9 +58,7 @@ void UiSprite::Render(){
             render_system_->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
             render_system_->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
             render_system_->_setViewMatrix(Ogre::Matrix4::IDENTITY);
-            scene_manager_->_setPass(
-              material_->getTechnique(0)->getPass(0), true, false
-            );
+            scene_manager_->_setPass(material_->getTechnique(0)->getPass(0), true, false);
             render_system_->setScissorTest(
               true, scissor_left_, scissor_top_, scissor_right_, scissor_bottom_
             );
@@ -109,24 +102,9 @@ void UiSprite::UpdateGeometry(){
     float x = final_translate_.x;
     float y = final_translate_.y;
     int x1, y1, x2, y2, x3, y3, x4, y4;
-    //LOG_ERROR(
-    //  name_ + ", rotation = " + Ogre::StringConverter::toString(rotation)
-    //);
-    //LOG_ERROR(
-    //  "local_x1 = " + Ogre::StringConverter::toString(local_x1)
-    //  + ", local_y1 = " + Ogre::StringConverter::toString(local_y1)
-    //);
-    //LOG_ERROR(
-    //  "local_x2 = " + Ogre::StringConverter::toString(local_x2)
-    //  + ", local_y2 = " + Ogre::StringConverter::toString(local_y2)
-    //);
-
     if(final_rotation_ != 0){
-        float cos
-          = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
-        float sin
-          = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
-
+        float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
+        float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
         x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
         y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
         x2 = static_cast<int>(local_x2 * cos - local_y1 * sin + x);
@@ -146,24 +124,6 @@ void UiSprite::UpdateGeometry(){
         x4 = static_cast<int>(local_x1 + x);
         y4 = static_cast<int>(local_y2 + y);
     }
-
-    //LOG_ERROR(
-    //  "x1 = " + Ogre::StringConverter::toString(x1) + ", y1 = "
-    // + Ogre::StringConverter::toString(y1)
-    //);
-    //LOG_ERROR(
-    //  "x2 = " + Ogre::StringConverter::toString(x2) + ", y2 = "
-    //  + Ogre::StringConverter::toString(y2)
-    //);
-    //LOG_ERROR(
-    //  "x3 = " + Ogre::StringConverter::toString(x3) + ", y3 = "
-    //  + Ogre::StringConverter::toString(y3)
-    //);
-    //LOG_ERROR(
-    //  "x4 = " + Ogre::StringConverter::toString(x4) + ", y4 = "
-    //  + Ogre::StringConverter::toString(y4)
-    //);
-
     float new_x1 = (x1 / screen_width_) * 2 - 1;
     float new_y1 = -((y1 / screen_height_) * 2 - 1);
     float new_x2 = (x2 / screen_width_) * 2 - 1;
@@ -174,8 +134,7 @@ void UiSprite::UpdateGeometry(){
     float new_y4 = -((y4 / screen_height_) * 2 - 1);
 
     float* write_iterator
-      = (float*) vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
-    // TODO: use WriteGlyph (should probably rename and move to utils)
+      = static_cast<float*>(vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL));
     *write_iterator ++ = new_x1;
     *write_iterator ++ = new_y1;
     *write_iterator ++ = final_z_;
@@ -237,36 +196,23 @@ void UiSprite::UpdateGeometry(){
     *write_iterator ++ = 1;
 
     render_operation_.vertexData->vertexCount = 6;
-
     vertex_buffer_->unlock();
 }
 
 void UiSprite::CreateVertexBuffer(){
     render_operation_.vertexData = new Ogre::VertexData;
     render_operation_.vertexData->vertexStart = 0;
-    Ogre::VertexDeclaration* vertex_declaration
-      = render_operation_.vertexData->vertexDeclaration;
-
+    Ogre::VertexDeclaration* vertex_declaration = render_operation_.vertexData->vertexDeclaration;
     size_t offset = 0;
     vertex_declaration->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE
-    );
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
-    vertex_declaration->addElement(
-      0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES
-    );
-
-    vertex_buffer_
-      = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
-        vertex_declaration->getVertexSize(0), 6,
-        Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
-        );
-
-    render_operation_.vertexData->vertexBufferBinding->setBinding(
-      0, vertex_buffer_
+    vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
+    vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
+      vertex_declaration->getVertexSize(0), 6, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false
     );
+    render_operation_.vertexData->vertexBufferBinding->setBinding(0, vertex_buffer_);
     render_operation_.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
     render_operation_.useIndexes = false;
 }

+ 25 - 39
V-Gears/src/core/UiTextArea.cpp

@@ -79,10 +79,8 @@ void UiTextArea::Update(){
             if (time != timer_time_){
                 timer_time_ = time;
                 Ogre::String time_string = "";
-                //time_string += Ogre::StringConverter::toString(timer_time_ / 60, 2, '0');
                 time_string += Ogre::StringUtil::format("%2d", timer_time_ / 60);
                 time_string += (timer_time_ & 1) ? ":" : ";";
-                //time_string += Ogre::StringConverter::toString(timer_time_ % 60, 2, '0');
                 time_string += Ogre::StringUtil::format("%2d", timer_time_ % 60);
                 SetVariable("UITextAreaTimer", time_string);
             }
@@ -94,9 +92,8 @@ void UiTextArea::Update(){
                     float time = Timer::getSingleton().GetGameTimeDelta() * 30;
                     float addition;
                     float limit;
-                    if (next_pressed_ == true || next_repeated_ == true){
+                    if (next_pressed_ == true || next_repeated_ == true)
                         text_print_speed_mod_ += (text_print_speed_mod_ >= 128) ? 0 : 1.0f * time;
-                    }
                     else text_print_speed_mod_ -= (text_print_speed_mod_ <= 1) ? 0 : 1.0f * time;
                     if (text_print_speed_ < 128){
                         addition = ((128 - text_print_speed_) / 32) + 2;
@@ -176,13 +173,7 @@ void UiTextArea::Render(){
               Ogre::GpuProgramParameters::ACT_VIEW_MATRIX, Ogre::Matrix4::IDENTITY
             );
             render_system_->applyFixedFunctionParams(render_parameters, Ogre::GPV_GLOBAL);
-            //render_system_->_setWorldMatrix(Ogre::Matrix4::IDENTITY);
-            //render_system_->_setProjectionMatrix(Ogre::Matrix4::IDENTITY);
-            //render_system_->_setViewMatrix(Ogre::Matrix4::IDENTITY);
             scene_manager_->_setPass(material_->getTechnique(0)->getPass(0), true, false);
-            //render_system_->setScissorTest(
-            //  true, scissor_left_, scissor_top_, scissor_right_, scissor_bottom_
-            //);
             render_system_->setScissorTest(true, Ogre::Rect(
               scissor_left_, scissor_top_, scissor_right_, scissor_bottom_
             ));
@@ -223,7 +214,7 @@ void UiTextArea::SetText(const Ogre::UTFString& text){
     Ogre::UTFString xml_text = "<container>" + text + "</container>";
     doc.Parse(xml_text.asUTF8_c_str(), 0, TIXML_ENCODING_UTF8);
     if (doc.Error() == true){
-        LOG_ERROR("Can't parse text \"" + text + "\". TinyXml Error: " + doc.ErrorDesc());
+        LOG_ERROR("Can't parse text '" + text + "'. TinyXml Error: " + doc.ErrorDesc());
         return;
     }
     SetText(doc.RootElement());
@@ -234,7 +225,6 @@ void UiTextArea::SetText(TiXmlNode* text){
         LOG_ERROR("Text pointer is NULL.");
         return;
     }
-
     // Reload font if language was changed.
     if (font_ != NULL){
         Ogre::String language = font_->GetLanguage();
@@ -248,7 +238,7 @@ void UiTextArea::SetText(TiXmlNode* text){
     if (text_.size() > max_letters_){
         text_.clear();
         LOG_ERROR(
-          "Max number of text reached in \"" + path_name_ + "\". Can't render text from node. "
+          "Max number of text reached in '" + path_name_ + "'. Can't render text from node. "
           + "Max number of letters is " + Ogre::StringConverter::toString(max_letters_) + "."
         );
     }
@@ -280,7 +270,7 @@ void UiTextArea::RemoveSpritesFromText(const unsigned int end){
 void UiTextArea::SetFont(const Ogre::String& font){
     font_ = UiManager::getSingleton().GetFont(font);
     if (font_ == nullptr){
-        LOG_ERROR("Could not find font \"" + font + "\" for \"" + path_name_ + "\".");
+        LOG_ERROR("Could not find font '" + font + "' for '" + path_name_ + "'.");
         return;
     }
     material_ = Ogre::MaterialManager::getSingleton().getByName(
@@ -368,7 +358,7 @@ float UiTextArea::GetPauseTime() const{return pause_time_;}
 
 void UiTextArea::UpdateGeometry(){
     if (font_ == NULL){
-        LOG_ERROR("Font for \"" + path_name_ + "\" if not set.");
+        LOG_ERROR("Font for '" + path_name_ + "' if not set.");
         return;
     }
     float width = 0;
@@ -376,9 +366,9 @@ void UiTextArea::UpdateGeometry(){
         width = GetTextWidth();
         if (text_align_ == CENTER) width /= 2;
     }
-    float* write_iterator = (float*) vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
+    float* write_iterator
+      = static_cast<float*>(vertex_buffer_->lock(Ogre::HardwareBuffer::HBL_NORMAL));
     render_operation_.vertexData->vertexCount = 0;
-
     float local_x_start
       = -final_origin_.x - (width - padding_left_) * final_scale_.x * screen_height_ / 720.0f;
     float local_x1 = local_x_start;
@@ -410,13 +400,13 @@ void UiTextArea::UpdateGeometry(){
         }
         else if (text_[i].sprite != NULL){
             float width_percent = 0;
-            float width = 0;
-            text_[i].sprite->GetWidth(width_percent, width);
+            float img_width = 0;
+            text_[i].sprite->GetWidth(width_percent, img_width);
             text_[i].sprite->SetX(0, local_x1 / (final_scale_.x * screen_height_ / 720.0f));
-            local_x1 += width * final_scale_.x * screen_height_ / 720.0f;
+            local_x1 += img_width * final_scale_.x * screen_height_ / 720.0f;
             float height_percent = 0;
-            float height = 0;
-            text_[i].sprite->GetHeight(height_percent, height);
+            float img_height = 0;
+            text_[i].sprite->GetHeight(height_percent, img_height);
             text_[i].sprite->SetY(
               0, text_[i].sprite_y + (local_y1 / (final_scale_.y * screen_height_ / 720.0f))
             );
@@ -451,7 +441,6 @@ void UiTextArea::UpdateGeometry(){
             break;
         }
         int x1, y1, x2, y2, x3, y3, x4, y4;
-
         if (final_rotation_ != 0){
             float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
             float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
@@ -483,12 +472,12 @@ void UiTextArea::UpdateGeometry(){
         float new_x4 = (x4 / screen_width_) * 2 - 1;
         float new_y4 = -((y4 / screen_height_) * 2 - 1);
         local_x1 += (char_data.width + char_data.post) * final_scale_.x * screen_height_ / 720.0f;
-        float width = font_->GetImageWidth();
-        float height = font_->GetImageHeight();
-        float left = (float)char_data.x / width;
-        float right = (float)(char_data.x + char_data.width) / width;
-        float top = (float)char_data.y / height;
-        float bottom = (float)(char_data.y + char_data.height) / height;
+        float img_width = font_->GetImageWidth();
+        float img_height = font_->GetImageHeight();
+        float left = (float)char_data.x / img_width;
+        float right = (float)(char_data.x + char_data.width) / img_width;
+        float top = (float)char_data.y / img_height;
+        float bottom = (float)(char_data.y + char_data.height) / img_height;
 
         *write_iterator ++ = new_x1;
         *write_iterator ++ = new_y1;
@@ -646,24 +635,23 @@ void UiTextArea::PrepareTextFromNode(TiXmlNode* node, const Ogre::ColourValue& c
                     }
                     else if (name == "character"){
                         const std::string* id = node->ToElement()->Attribute(Ogre::String("id"));
-                        const std::string name = TextManager::getSingleton().GetCharacterName(
+                        const std::string char_name = TextManager::getSingleton().GetCharacterName(
                           std::stoi(*id)
                         );
-                        for (unsigned int i = 0; i < name.length(); ++ i){
+                        for (unsigned int i = 0; i < char_name.length(); ++ i){
                             TextChar text_char;
-                            text_char.char_code = name.at(i);
+                            text_char.char_code = char_name.at(i);
                             text_char.colour = colour;
                             text_.push_back(text_char);
                         }
                     }
                     else if (name == "party"){
                         const std::string* pos = node->ToElement()->Attribute(Ogre::String("pos"));
-                        const std::string name = TextManager::getSingleton().GetPartyCharacterName(
-                          std::stoi(*pos)
-                        );
-                        for (unsigned int i = 0; i < name.length(); ++ i){
+                        const std::string char_name
+                          = TextManager::getSingleton().GetPartyCharacterName(std::stoi(*pos));
+                        for (unsigned int i = 0; i < char_name.length(); ++ i){
                             TextChar text_char;
-                            text_char.char_code = name.at(i);
+                            text_char.char_code = char_name.at(i);
                             text_char.colour = colour;
                             text_.push_back(text_char);
                         }
@@ -726,7 +714,6 @@ void UiTextArea::PrepareTextFromNode(TiXmlNode* node, const Ogre::ColourValue& c
                                             break;
                                         }
                                     }
-
                                     sprites = sprites->NextSibling();
                                 }
                             }
@@ -763,7 +750,6 @@ void UiTextArea::CreateVertexBuffer(){
     vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT4, Ogre::VES_DIFFUSE);
     offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
     vertex_declaration->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
-
     vertex_buffer_ = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
       vertex_declaration->getVertexSize(0), max_letters_ * 6,
       Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, false

+ 46 - 111
V-Gears/src/core/UiWidget.cpp

@@ -28,23 +28,17 @@
 ConfigVar cv_debug_ui("debug_ui", "Draw ui debug info", "0");
 
 
-UiWidget::UiWidget(const Ogre::String& name):
-  name_(name),
-  path_name_(name),
-  parent_(nullptr)
+UiWidget::UiWidget(const Ogre::String& name): name_(name), path_name_(name), parent_(nullptr)
 {Initialise();}
 
 
 UiWidget::UiWidget(const Ogre::String& name, const Ogre::String& path_name, UiWidget* parent):
-  name_(name),
-  path_name_(path_name),
-  parent_(parent)
+  name_(name), path_name_(path_name), parent_(parent)
 {Initialise();}
 
 
 UiWidget::~UiWidget(){
-    for (unsigned int i = 0; i < animations_.size(); ++ i)
-        delete animations_[i];
+    for (unsigned int i = 0; i < animations_.size(); ++ i) delete animations_[i];
     ScriptManager::getSingleton().RemoveEntity(ScriptManager::UI, path_name_);
     RemoveAllChildren();
 }
@@ -100,37 +94,25 @@ void UiWidget::Initialise(){
     colour_2_ = Ogre::ColourValue(1, 1, 1, 1);
     colour_3_ = Ogre::ColourValue(1, 1, 1, 1);
     colour_4_ = Ogre::ColourValue(1, 1, 1, 1);
-    ScriptManager::getSingleton().AddEntity(
-      ScriptManager::UI, path_name_, nullptr
-    );
+    ScriptManager::getSingleton().AddEntity(ScriptManager::UI, path_name_, nullptr);
 }
 
 void UiWidget::Update(){
     if (visible_ != true) return;
-
     if (animation_current_ != nullptr){
         float delta_time = Timer::getSingleton().GetGameTimeDelta();
         float time = animation_current_->GetTime();
-
-        // If animation has ended
+        // If animation has ended.
         if (time + delta_time >= animation_end_time_){
             if (time != animation_end_time_)
                 animation_current_->AddTime(animation_end_time_ - time);
-            for (unsigned int i = 0; i < animation_sync_.size(); ++ i){
-                ScriptManager::getSingleton().ContinueScriptExecution(
-                  animation_sync_[i]
-                );
-            }
+            for (unsigned int i = 0; i < animation_sync_.size(); ++ i)
+                ScriptManager::getSingleton().ContinueScriptExecution(animation_sync_[i]);
             animation_sync_.clear();
-            if (
-              animation_state_ == UiAnimation::DEFAULT && animation_default_
-              != ""
-            ){
+            if (animation_state_ == UiAnimation::DEFAULT && animation_default_ != ""){
                 // In case of cycled default, it's required to sync with end.
                 time = time + delta_time - animation_current_->GetLength();
-                PlayAnimation(
-                  animation_default_, UiAnimation::DEFAULT, time, -1
-                );
+                PlayAnimation(animation_default_, UiAnimation::DEFAULT, time, -1);
             }
             else animation_current_ = NULL;
         }
@@ -142,12 +124,8 @@ void UiWidget::Update(){
     ){
         PlayAnimation(animation_default_, UiAnimation::DEFAULT, 0, -1);
     }
-
     if (update_transformation_ == true) UpdateTransformation();
-
-    for (unsigned int i = 0; i < children_.size(); ++ i)
-        children_[i]->Update();
-
+    for (unsigned int i = 0; i < children_.size(); ++ i) children_[i]->Update();
 
     // Debug output
     if (cv_debug_ui.GetI() >= 1){
@@ -162,10 +140,8 @@ void UiWidget::Update(){
         int x1, y1, x2, y2, x3, y3, x4, y4;
 
         if (final_rotation_ != 0){
-            float cos
-              = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
-            float sin
-              = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
+            float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
+            float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
             x2 = static_cast<int>(local_x2 * cos - local_y1 * sin + x);
@@ -207,11 +183,9 @@ void UiWidget::Update(){
         // Draw translation.
         DEBUG_DRAW.SetColour(Ogre::ColourValue(0, 1, 0, 1));
         Ogre::Vector2 area_origin
-          = (parent_ != nullptr)
-            ? parent_->GetFinalOrigin() : Ogre::Vector2::ZERO;
+          = (parent_ != nullptr) ? parent_->GetFinalOrigin() : Ogre::Vector2::ZERO;
         Ogre::Vector2 area_translate
-          = (parent_ != nullptr)
-            ? parent_->GetFinalTranslate() : Ogre::Vector2::ZERO;
+          = (parent_ != nullptr) ? parent_->GetFinalTranslate() : Ogre::Vector2::ZERO;
         Ogre::Vector2 pos = area_translate - area_origin;
         DEBUG_DRAW.Line(pos.x, pos.y, x, y);
         DEBUG_DRAW.Quad(x - 2, y - 2, x + 2, y - 2, x + 2, y + 2, x - 2, y + 2);
@@ -219,20 +193,15 @@ void UiWidget::Update(){
         if (cv_debug_ui.GetI() >= 2){
             DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
             DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+            DEBUG_DRAW.Text(static_cast<float>(x1 + 3), static_cast<float>(y1), path_name_);
             DEBUG_DRAW.Text(
-              static_cast<float>(x1 + 3), static_cast<float>(y1), path_name_
-            );
-            DEBUG_DRAW.Text(
-              static_cast<float>(x1 + 3), static_cast<float>(y1 + 12),
-              GetCurrentAnimationName()
+              static_cast<float>(x1 + 3), static_cast<float>(y1 + 12), GetCurrentAnimationName()
             );
         }
 
         // Draw the origin.
         DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
-        DEBUG_DRAW.Line(
-          x, y, static_cast<float>(x1), static_cast<float>(y1 + 1)
-        );
+        DEBUG_DRAW.Line(x, y, static_cast<float>(x1), static_cast<float>(y1 + 1));
     }
 }
 
@@ -245,8 +214,7 @@ void UiWidget::OnResize(){
 }
 
 void UiWidget::Render(){
-    if (visible_ == true)
-        for (size_t i = 0; i < children_.size(); ++ i) children_[i]->Render();
+    if (visible_ == true) for (size_t i = 0; i < children_.size(); ++ i) children_[i]->Render();
 }
 
 void UiWidget::SetVisible(const bool visible){visible_ = visible;}
@@ -275,9 +243,7 @@ void UiWidget::RemoveAllChildren(){
     children_.clear();
 }
 
-void UiWidget::AddAnimation(UiAnimation* animation){
-    animations_.push_back(animation);
-}
+void UiWidget::AddAnimation(UiAnimation* animation){animations_.push_back(animation);}
 
 const Ogre::String& UiWidget::GetCurrentAnimationName() const{
     if (animation_current_ != nullptr) return animation_current_->GetName();
@@ -285,29 +251,22 @@ const Ogre::String& UiWidget::GetCurrentAnimationName() const{
 }
 
 void UiWidget::PlayAnimation(
-  const Ogre::String& animation, UiAnimation::State state,
-  const float start, const float end
+  const Ogre::String& animation, UiAnimation::State state, const float start, const float end
 ){
     for (size_t i = 0; i < animations_.size(); ++ i){
         if (animations_[i]->GetName() == animation){
             animation_current_ = animations_[i];
-            animation_current_->SetTime(
-              (start == -1) ? animation_current_->GetLength() : start
-            );
+            animation_current_->SetTime((start == -1) ? animation_current_->GetLength() : start);
             animation_current_->AddTime(0);
-            animation_end_time_
-              = (end == -1) ? animation_current_->GetLength() : end;
+            animation_end_time_ = (end == -1) ? animation_current_->GetLength() : end;
             animation_state_ = state;
             return;
         }
     }
-
     // Stop current state and animation.
     animation_current_ = nullptr;
     animation_state_ = UiAnimation::ONCE;
-    LOG_ERROR(
-      "Widget '" + name_ + "' doesn't has animation '" + animation + "'."
-    );
+    LOG_ERROR("Widget '" + name_ + "' doesn't has animation '" + animation + "'.");
 }
 
 void UiWidget::ScriptPlayAnimation(const char* name){
@@ -318,15 +277,11 @@ void UiWidget::ScriptPlayAnimationStop(const char* name){
     PlayAnimation(Ogre::String(name), UiAnimation::ONCE, 0, -1);
 }
 
-void UiWidget::ScriptPlayAnimation(
-  const char* name, const float start, const float end
-){
+void UiWidget::ScriptPlayAnimation(const char* name, const float start, const float end){
     PlayAnimation(Ogre::String(name), UiAnimation::DEFAULT, start, end);
 }
 
-void UiWidget::ScriptPlayAnimationStop(
-  const char* name, const float start, const float end
-){
+void UiWidget::ScriptPlayAnimationStop(const char* name, const float start, const float end){
     PlayAnimation(Ogre::String(name), UiAnimation::ONCE, start, end);
 }
 
@@ -342,8 +297,7 @@ int UiWidget::ScriptAnimationSync(){
 }
 
 void UiWidget::SetUpdateTransformation(){
-    for (unsigned int i = 0; i < children_.size(); ++ i)
-        children_[i]->SetUpdateTransformation();
+    for (unsigned int i = 0; i < children_.size(); ++ i) children_[i]->SetUpdateTransformation();
     update_transformation_ = true;
 }
 
@@ -353,20 +307,17 @@ void UiWidget::UpdateTransformation(){
     Ogre::Vector2 area_origin
       = (parent_ != nullptr) ? parent_->GetFinalOrigin() : Ogre::Vector2::ZERO;
     Ogre::Vector2 area_translate
-      = (parent_ != nullptr)
-        ? parent_->GetFinalTranslate() : Ogre::Vector2::ZERO;
+      = (parent_ != nullptr) ? parent_->GetFinalTranslate() : Ogre::Vector2::ZERO;
     Ogre::Vector2 area_size
       = (parent_ != nullptr)
-        ? parent_->GetFinalSize()
-        : Ogre::Vector2(screen_width_, screen_height_);
-    float area_rotation
-      = (parent_ != nullptr) ? parent_->GetFinalRotation() : 0;
+        ? parent_->GetFinalSize() : Ogre::Vector2(screen_width_, screen_height_);
+    float area_rotation = (parent_ != nullptr) ? parent_->GetFinalRotation() : 0;
     float local_x
       = ((area_size.x * x_percent_) / 100.0f + (x_ * screen_height_ / 720.0f)
-      * area_scale.x) - area_origin.x;
+        * area_scale.x) - area_origin.x;
     float local_y
       = ((area_size.y * y_percent_) / 100.0f + (y_ * screen_height_ / 720.0f)
-      * area_scale.y) - area_origin.y;
+        * area_scale.y) - area_origin.y;
     float x = local_x;
     float y = local_y;
     if (area_rotation != 0){
@@ -378,16 +329,12 @@ void UiWidget::UpdateTransformation(){
 
     final_translate_.x = area_translate.x;
     if (align_ == RIGHT) final_translate_.x = area_translate.x + area_size.x;
-    else if (align_ == CENTER)
-        final_translate_.x = area_translate.x + area_size.x / 2;
+    else if (align_ == CENTER) final_translate_.x = area_translate.x + area_size.x / 2;
     final_translate_.x += x;
     final_translate_.y = area_translate.y;
-    if (vertical_align_ == BOTTOM)
-        final_translate_.y = area_translate.y + area_size.y;
-    else if (vertical_align_ == MIDDLE)
-        final_translate_.y = area_translate.y + area_size.y / 2;
+    if (vertical_align_ == BOTTOM) final_translate_.y = area_translate.y + area_size.y;
+    else if (vertical_align_ == MIDDLE) final_translate_.y = area_translate.y + area_size.y / 2;
     final_translate_.y += y;
-
     final_z_ = (parent_ != NULL) ? parent_->GetFinalZ() + z_ : z_;
     final_scale_ = area_scale * scale_;
     final_size_.x
@@ -408,29 +355,23 @@ void UiWidget::UpdateTransformation(){
     if (local_scissor_ == true){
         float local_x1
           = final_size_.x * scissor_x_percent_top_ / 100.0f
-            + scissor_x_top_ * screen_height_ * final_scale_.x / 720.0f
-            - final_origin_.x;
+            + scissor_x_top_ * screen_height_ * final_scale_.x / 720.0f - final_origin_.x;
         float local_y1
           = final_size_.y * scissor_y_percent_left_ / 100.0f
-            + scissor_y_left_ * screen_height_ * final_scale_.y / 720.0f
-            - final_origin_.y;
+            + scissor_y_left_ * screen_height_ * final_scale_.y / 720.0f - final_origin_.y;
         float local_x2
           = final_size_.x * scissor_x_percent_bottom_ / 100.0f
-            + scissor_x_bottom_ * screen_height_ * final_scale_.x / 720.0f
-            - final_origin_.x;
+            + scissor_x_bottom_ * screen_height_ * final_scale_.x / 720.0f - final_origin_.x;
         float local_y2
           = final_size_.y * scissor_y_percent_right_ / 100.0f
-            + scissor_y_right_ * screen_height_ * final_scale_.y / 720.0f
-            - final_origin_.y;
-        float x = final_translate_.x;
-        float y = final_translate_.y;
+            + scissor_y_right_ * screen_height_ * final_scale_.y / 720.0f - final_origin_.y;
+        x = final_translate_.x;
+        y = final_translate_.y;
 
         int x1, y1, x2, y2, x3, y3, x4, y4;
         if (final_rotation_ != 0){
-            float cos
-              = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
-            float sin
-              = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
+            float cos = Ogre::Math::Cos(Ogre::Radian(Ogre::Degree(final_rotation_)));
+            float sin = Ogre::Math::Sin(Ogre::Radian(Ogre::Degree(final_rotation_)));
             x1 = static_cast<int>(local_x1 * cos - local_y1 * sin + x);
             y1 = static_cast<int>(local_x1 * sin + local_y1 * cos + y);
             x2 = static_cast<int>(local_x2 * cos - local_y1 * sin + x);
@@ -475,15 +416,12 @@ void UiWidget::UpdateTransformation(){
             }
         }
     }
-
     update_transformation_ = false;
 }
 
 void UiWidget::SetAlign(const UiWidget::Align align){align_ = align;}
 
-void UiWidget::SetVerticalAlign(const UiWidget::VerticalAlign valign){
-    vertical_align_ = valign;
-}
+void UiWidget::SetVerticalAlign(const UiWidget::VerticalAlign valign){vertical_align_ = valign;}
 
 float UiWidget::GetFinalZ() const{return final_z_;}
 
@@ -498,9 +436,7 @@ Ogre::Vector2 UiWidget::GetFinalScale() const{return final_scale_;}
 Ogre::Vector4 UiWidget::GetFinalScissor(bool& scissor) const{
     if (scissor_ == true){
         scissor = true;
-        return Ogre::Vector4(
-          scissor_top_, scissor_bottom_, scissor_left_, scissor_right_
-        );
+        return Ogre::Vector4(scissor_top_, scissor_bottom_, scissor_left_, scissor_right_);
     }
     scissor = false;
     return Ogre::Vector4::ZERO;
@@ -580,9 +516,8 @@ void UiWidget::SetRotation(const float degree){
 }
 
 void UiWidget::SetScissorArea(
-  const float percent_x1, const float x1, const float percent_y1,
-  const float y1, const float percent_x2, const float x2,
-  const float percent_y2, const float y2
+  const float percent_x1, const float x1, const float percent_y1, const float y1,
+  const float percent_x2, const float x2, const float percent_y2, const float y2
 ){
     local_scissor_ = true;
     scissor_x_percent_top_ = percent_x1;

+ 23 - 48
V-Gears/src/core/Utilites.cpp

@@ -16,8 +16,7 @@
 #include <OgreStringConverter.h>
 #include "core/Utilites.h"
 
-bool
-GetBool(TiXmlNode* node, const Ogre::String& tag, bool def){
+bool GetBool(TiXmlNode* node, const Ogre::String& tag, bool def){
     bool ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
@@ -67,9 +66,7 @@ const Ogre::UTFString GetUTFString(
     return ret;
 }
 
-const Ogre::Vector2 GetVector2(
-  TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def
-){
+const Ogre::Vector2 GetVector2(TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector2& def){
     Ogre::Vector2 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
@@ -78,9 +75,7 @@ const Ogre::Vector2 GetVector2(
     return ret;
 }
 
-const Ogre::Vector3 GetVector3(
-  TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def
-){
+const Ogre::Vector3 GetVector3(TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector3& def){
     Ogre::Vector3 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
@@ -89,9 +84,7 @@ const Ogre::Vector3 GetVector3(
     return ret;
 }
 
-const Ogre::Vector4 GetVector4(
-  TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def
-){
+const Ogre::Vector4 GetVector4(TiXmlNode* node, const Ogre::String& tag, const Ogre::Vector4& def){
     Ogre::Vector4 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
@@ -100,9 +93,7 @@ const Ogre::Vector4 GetVector4(
     return ret;
 }
 
-const Ogre::Matrix4 GetMatrix4(
-  TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def
-){
+const Ogre::Matrix4 GetMatrix4(TiXmlNode* node, const Ogre::String& tag, const Ogre::Matrix4& def){
     Ogre::Matrix4 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
@@ -117,8 +108,7 @@ const Ogre::Quaternion GetQuaternion(
     Ogre::Quaternion ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != NULL)
-            ret = Ogre::StringConverter::parseQuaternion(*string);
+        if (string != NULL) ret = Ogre::StringConverter::parseQuaternion(*string);
     }
     return ret;
 }
@@ -129,19 +119,14 @@ const Ogre::ColourValue GetColourValue(
     Ogre::ColourValue ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != NULL)
-            ret = Ogre::StringConverter::parseColourValue(*string);
+        if (string != NULL) ret = Ogre::StringConverter::parseColourValue(*string);
     }
     return ret;
 }
 
-void ParsePercent(
-  float& value_percent, float& value, const Ogre::String& string
-){
+void ParsePercent(float& value_percent, float& value, const Ogre::String& string){
     if (string.at(string.size() - 1) == '%'){
-        value_percent = Ogre::StringConverter::parseReal(
-          string.substr(0, string.size() - 1)
-        );
+        value_percent = Ogre::StringConverter::parseReal(string.substr(0, string.size() - 1));
         value = 0;
     }
     else{
@@ -159,21 +144,15 @@ void ParsePercent(
 
 float ParseKeyFrameTime(const float length, const Ogre::String& string){
     float res = 0;
-    if (string.at(string.size() - 1) == '%'){
-        res
-          = length
-            * Ogre::StringConverter::parseReal(
-              string.substr(0, string.size() - 1)
-            )
-            / 100;
-    }
+    if (string.at(string.size() - 1) == '%')
+        res = length * Ogre::StringConverter::parseReal(string.substr(0, string.size() - 1)) / 100;
     else res = Ogre::StringConverter::parseReal(string);
     return res;
 }
 
 const Ogre::String CreateAutoName(const Ogre::String prefix){
     static int enumerator = 0;
-    return prefix + Ogre::StringConverter::toString(enumerator++);
+    return prefix + Ogre::StringConverter::toString(enumerator ++);
 }
 
 /**
@@ -192,7 +171,9 @@ struct KeyName {
     OIS::KeyCode key;
 };
 
-
+/**
+ * Define names for keyboard keys.
+ */
 KeyName key_names[] = {
     {"Enter", OIS::KC_RETURN},
     {"Escape", OIS::KC_ESCAPE},
@@ -284,7 +265,6 @@ Ogre::String KeyToString(OIS::KeyCode key){
 
 OIS::KeyCode StringToKey(const Ogre::String& str){
     if (str == "") return OIS::KC_UNASSIGNED;
-
     // find key by string
     for (KeyName* kn = key_names; kn->name != "UNASSIGNED"; ++ kn)
         if (kn->name == str) return kn->key;
@@ -292,24 +272,23 @@ OIS::KeyCode StringToKey(const Ogre::String& str){
 }
 
 Ogre::StringVector StringTokenise(
-  const Ogre::String& str, const Ogre::String& delimiters,
-  const Ogre::String& delimiters_preserve, const Ogre::String& quote,
-  const Ogre::String& esc
+  const Ogre::String& str, const Ogre::String& delimiters, const Ogre::String& delimiters_preserve,
+  const Ogre::String& quote, const Ogre::String& esc
 ){
     Ogre::StringVector ret;
     Ogre::String::size_type pos = 0; // Current position (char) in the string.
-    char ch = 0; // Buffer for the current character.
-    char delimiter = 0; // The buffer for the delimiter char which will be
-                        // added to the tokens if the delimiter is preserved.
     char current_quote = 0; // The char of the currently open quote.
     bool quoted = false; // Indicator for an open quote.
     Ogre::String token;  // String buffer for the token.
-    bool token_complete = false; // Indicates if the current token is ready to
-                                 // be added to the result vector.
+    bool token_complete = false; // Indicates if the current token is ready to be added to the
+                                 // result vector.
     Ogre::String::size_type len = str.length();  // Length of the input string.
 
     // For every char in the input string.
     while (len > pos){
+        char ch; // Buffer for the current character.
+        char delimiter; // The buffer for the delimiter char which will be added to the tokens
+                        //if the delimiter is preserved.
         // Get the character of the string and reset the delimiter buffer.
         ch = str.at(pos);
         delimiter = 0;
@@ -325,7 +304,6 @@ Ogre::StringVector StringTokenise(
                 if (pos < len){ // If there are more chars left...
                     // ... get the next one...
                     ch = str.at(pos);
-
                     // ... and add the escaped character to the token.
                     add_char = true;
                 }
@@ -378,10 +356,7 @@ Ogre::StringVector StringTokenise(
 
         // If the delimiter is preserved, add it as a token.
         bool add_delimiter = false;
-        if (
-          delimiters_preserve.empty() == false
-          && escaped == false && quoted == false
-        ){
+        if (delimiters_preserve.empty() == false && escaped == false && quoted == false){
             // If a delimiter which will be preserved is provided and the char
             // isn't protected by quote or escape char.
             if (delimiters_preserve.find_first_of(ch) != std::string::npos){

+ 14 - 51
V-Gears/src/core/Walkmesh.cpp

@@ -34,51 +34,29 @@ void Walkmesh::UpdateDebug(){
         DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.CENTER);
 
         for (const auto &triangle : triangles_){
-            if (triangle.access_side[0] == -1)
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
-            else
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+            if (triangle.access_side[0] == -1) DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
+            else DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             DEBUG_DRAW.Line3d(triangle.a, triangle.b);
-            if (triangle.access_side[1] == -1)
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
-            else
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+            if (triangle.access_side[1] == -1) DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
+            else DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             DEBUG_DRAW.Line3d(triangle.b, triangle.c);
-            if (triangle.access_side[2] == -1)
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
-            else
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
+            if (triangle.access_side[2] == -1) DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 1));
+            else DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             DEBUG_DRAW.Line3d(triangle.c, triangle.a);
-
-            /*
-            if (triangles_[i].locked == false)
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 0.5));
-            else
-                DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 0, 0, 0.5));
-            */
-            //DEBUG_DRAW.Triangle3d(
-            //  triangles_[i].a, triangles_[i].b, triangles_[i].c
-            //);
             DEBUG_DRAW.SetColour(Ogre::ColourValue(1, 1, 1, 1));
             DEBUG_DRAW.SetFadeDistance(40, 50);
-            Ogre::Vector3 triangle_pos
-              = (triangle.a + triangle.b + triangle.c) / 3;
+            Ogre::Vector3 triangle_pos = (triangle.a + triangle.b + triangle.c) / 3;
         }
     }
 }
 
 void Walkmesh::Clear(){triangles_.clear();}
 
-void Walkmesh::AddTriangle(const WalkmeshTriangle& triangle){
-    triangles_.push_back(triangle);
-}
+void Walkmesh::AddTriangle(const WalkmeshTriangle& triangle){triangles_.push_back(triangle);}
 
 int Walkmesh::GetAccessSide(unsigned int triangle_id, unsigned char side) const{
     if (triangle_id >= triangles_.size()){
-        LOG_ERROR(
-          "Triangle_id greater than number of triangles in walkmesh "
-          + "or less than zero."
-        );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return -1;
     }
     if (side >= 3){
@@ -90,10 +68,7 @@ int Walkmesh::GetAccessSide(unsigned int triangle_id, unsigned char side) const{
 
 const Ogre::Vector3& Walkmesh::GetA(unsigned int triangle_id) const{
     if (triangle_id >= triangles_.size()){
-        LOG_ERROR(
-          "Triangle_id greater than number of triangles in walkmesh "
-          + "or less than zero."
-        );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return Ogre::Vector3::ZERO;
     }
     return triangles_[triangle_id].a;
@@ -101,10 +76,7 @@ const Ogre::Vector3& Walkmesh::GetA(unsigned int triangle_id) const{
 
 const Ogre::Vector3& Walkmesh::GetB(unsigned int triangle_id) const{
     if (triangle_id >= triangles_.size()){
-        LOG_ERROR(
-          "Triangle_id greater than number of triangles in walkmesh "
-          + "or less than zero."
-        );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return Ogre::Vector3::ZERO;
     }
     return triangles_[triangle_id].b;
@@ -112,10 +84,7 @@ const Ogre::Vector3& Walkmesh::GetB(unsigned int triangle_id) const{
 
 const Ogre::Vector3& Walkmesh::GetC(unsigned int triangle_id) const{
     if (triangle_id >= triangles_.size()){
-        LOG_ERROR(
-          "Triangle_id greater than number of triangles in walkmesh "
-          + "or less than zero."
-        );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return Ogre::Vector3::ZERO;
     }
     return triangles_[triangle_id].c;
@@ -125,10 +94,7 @@ int Walkmesh::GetNumberOfTriangles() const{return triangles_.size();}
 
 void Walkmesh::LockWalkmesh(unsigned int triangle_id, bool lock){
     if (triangle_id >= triangles_.size()){
-        LOG_ERROR(
-          "Triangle_id greater than number of triangles in walkmesh "
-          + "or less than zero."
-        );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return;
     }
     triangles_[triangle_id].locked = lock;
@@ -136,10 +102,7 @@ void Walkmesh::LockWalkmesh(unsigned int triangle_id, bool lock){
 
 bool Walkmesh::IsLocked(unsigned int triangle_id) const{
     if (triangle_id >= triangles_.size()){
-        LOG_ERROR(
-          "Triangle_id greater than number of triangles in walkmesh "
-          + "or less than zero."
-        );
+        LOG_ERROR("Triangle_id greater than number of triangles in walkmesh or less than zero.");
         return false;
     }
     return triangles_[triangle_id].locked;

+ 23 - 50
V-Gears/src/core/XmlBackground2DFile.cpp

@@ -20,15 +20,10 @@
 #include "core/Logger.h"
 #include "core/XmlBackground2DFile.h"
 
-
-XmlBackground2DFile::XmlBackground2DFile(const Ogre::String& file):
-  XmlFile(file)
-{}
-
+XmlBackground2DFile::XmlBackground2DFile(const Ogre::String& file): XmlFile(file){}
 
 XmlBackground2DFile::~XmlBackground2DFile(){}
 
-
 void XmlBackground2DFile::Load(){
     TiXmlNode* node = file_.RootElement();
     Background2D* background = EntityManager::getSingleton().GetBackground2D();
@@ -45,12 +40,8 @@ void XmlBackground2DFile::Load(){
         Ogre::Quaternion range = GetQuaternion(
           node, "range", Ogre::Quaternion(-100000, -100000, 100000, 100000)
         );
-        background->SetRange(
-          (int)range.w, (int)range.x, (int)range.y, (int)range.z
-        );
-        Ogre::Vector3 position = GetVector3(
-          node, "position", Ogre::Vector3::ZERO
-        );
+        background->SetRange((int)range.w, (int)range.x, (int)range.y, (int)range.z);
+        Ogre::Vector3 position = GetVector3(node, "position", Ogre::Vector3::ZERO);
         Ogre::Quaternion orientation = GetQuaternion(
           node, "orientation", Ogre::Quaternion::IDENTITY
         );
@@ -61,24 +52,16 @@ void XmlBackground2DFile::Load(){
         int tile_id = 0;
         node = node->FirstChild();
         while (node != nullptr){
-            if (
-              node->Type() == TiXmlNode::TINYXML_ELEMENT
-              && node->ValueStr() == "tile"
-            ){
+            if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "tile"){
                 int width = GetInt(node, "width", 0);
                 int height = GetInt(node, "height", 0);
-                Ogre::Vector2 destination = GetVector2(
-                  node, "destination", Ogre::Vector2::ZERO
-                );
+                Ogre::Vector2 destination = GetVector2(node, "destination", Ogre::Vector2::ZERO);
                 Ogre::Vector4 uv = GetVector4(node, "uv", Ogre::Vector4::ZERO);
                 float depth = GetFloat(node, "depth", 0);
-                Ogre::String blending_str = GetString(
-                  node, "blending", "alpha"
-                );
+                Ogre::String blending_str = GetString(node, "blending", "alpha");
                 VGears::Blending blending;
                 if (blending_str == "add") blending = VGears::B_ADD;
-                else if (blending_str == "subtract")
-                    blending = VGears::B_SUBTRACT;
+                else if (blending_str == "subtract") blending = VGears::B_SUBTRACT;
                 else blending = VGears::B_ALPHA;
                 Ogre::Vector4 distance = Ogre::Vector4(0, 0, -depth, 1);
                 Ogre::Vector4 res
@@ -86,8 +69,7 @@ void XmlBackground2DFile::Load(){
                     ->getProjectionMatrixWithRSDepth() * distance;
                 res = res / res.w;
                 background->AddTile(
-                  static_cast<int>(destination.x),
-                  static_cast<int>(destination.y),
+                  static_cast<int>(destination.x), static_cast<int>(destination.y),
                   width, height, res.z, uv.x, uv.y, uv.z, uv.w, blending
                 );
                 TiXmlNode* node2 = node->FirstChild();
@@ -98,35 +80,26 @@ void XmlBackground2DFile::Load(){
                     ){
                         Ogre::String name = GetString(node2, "name", "");
                         if (name != ""){
-                            Background2DAnimation* animation
-                              = new Background2DAnimation(
-                                name, background, tile_id
-                              );
+                            Background2DAnimation* animation = new Background2DAnimation(
+                              name, background, tile_id
+                            );
                             animation->SetLength(GetFloat(node2, "length", 0));
-                            Ogre::String uv = GetString(node2, "uv", "");
-                            if (uv != ""){
-                                Ogre::StringVector key_frame
-                                  = Ogre::StringUtil::split(uv, ",");
-                                for (
-                                  unsigned int i = 0; i < key_frame.size(); ++ i
-                                ){
+                            Ogre::String uv_node2 = GetString(node2, "uv", "");
+                            if (uv_node2 != ""){
+                                Ogre::StringVector key_frame = Ogre::StringUtil::split(
+                                  uv_node2, ","
+                                );
+                                for (unsigned int i = 0; i < key_frame.size(); ++ i){
                                     Ogre::StringUtil::trim(key_frame[i]);
-                                    Ogre::StringVector data
-                                      = Ogre::StringUtil::split(
-                                        key_frame[i], ":"
-                                      );
+                                    Ogre::StringVector data = Ogre::StringUtil::split(
+                                      key_frame[i], ":"
+                                    );
                                     if (data.size() > 1){
-                                        float time
-                                          = Ogre::StringConverter::parseReal(
-                                            data[0]
-                                          );
+                                        float time = Ogre::StringConverter::parseReal(data[0]);
                                         Ogre::Vector4 value
-                                          = Ogre::StringConverter::parseVector4(
-                                            data[1]
-                                          );
+                                          = Ogre::StringConverter::parseVector4(data[1]);
                                         animation->AddUVKeyFrame(
-                                          time,
-                                          value.x, value.y, value.z, value.w
+                                          time, value.x, value.y, value.z, value.w
                                         );
                                     }
                                 }

+ 9 - 21
V-Gears/src/core/XmlFile.cpp

@@ -17,15 +17,11 @@
 #include "core/Logger.h"
 #include "core/XmlFile.h"
 
-XmlFile::XmlFile(const Ogre::String& file):
-  file_(file)
-{
+XmlFile::XmlFile(const Ogre::String& file): file_(file){
     file_.SetCondenseWhiteSpace(false);
     normal_file_ = file_.LoadFile();
     if (normal_file_ == false)
-        LOG_ERROR(
-          "Can't open " + file + ". TinyXml Error: " + file_.ErrorDesc()
-        );
+        LOG_ERROR("Can't open " + file + ". TinyXml Error: " + file_.ErrorDesc());
 }
 
 XmlFile::~XmlFile(){}
@@ -48,9 +44,7 @@ int XmlFile::GetInt(TiXmlNode* node, const Ogre::String& tag, int def) const{
     return ret;
 }
 
-float XmlFile::GetFloat(
-  TiXmlNode* node, const Ogre::String& tag, float def
-) const{
+float XmlFile::GetFloat(TiXmlNode* node, const Ogre::String& tag, float def) const{
     float ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
@@ -87,8 +81,7 @@ const Ogre::Vector2 XmlFile::GetVector2(
     Ogre::Vector2 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != nullptr)
-            ret = Ogre::StringConverter::parseVector2(*string);
+        if (string != nullptr) ret = Ogre::StringConverter::parseVector2(*string);
     }
     return ret;
 }
@@ -99,8 +92,7 @@ const Ogre::Vector3 XmlFile::GetVector3(
     Ogre::Vector3 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != nullptr)
-            ret = Ogre::StringConverter::parseVector3(*string);
+        if (string != nullptr) ret = Ogre::StringConverter::parseVector3(*string);
     }
     return ret;
 }
@@ -111,8 +103,7 @@ const Ogre::Vector4 XmlFile::GetVector4(
     Ogre::Vector4 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != nullptr)
-            ret = Ogre::StringConverter::parseVector4(*string);
+        if (string != nullptr) ret = Ogre::StringConverter::parseVector4(*string);
     }
     return ret;
 }
@@ -123,8 +114,7 @@ const Ogre::Matrix4 XmlFile::GetMatrix4(
     Ogre::Matrix4 ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != nullptr)
-            ret = Ogre::StringConverter::parseMatrix4(*string);
+        if (string != nullptr) ret = Ogre::StringConverter::parseMatrix4(*string);
     }
     return ret;
 }
@@ -135,8 +125,7 @@ const Ogre::Quaternion XmlFile::GetQuaternion(
     Ogre::Quaternion ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != nullptr)
-            ret = Ogre::StringConverter::parseQuaternion(*string);
+        if (string != nullptr) ret = Ogre::StringConverter::parseQuaternion(*string);
     }
     return ret;
 }
@@ -148,8 +137,7 @@ const Ogre::ColourValue XmlFile::GetColourValue(
     Ogre::ColourValue ret = def;
     if (node->Type() == TiXmlNode::TINYXML_ELEMENT){
         const std::string* string = node->ToElement()->Attribute(tag);
-        if (string != nullptr)
-            ret = Ogre::StringConverter::parseColourValue(*string);
+        if (string != nullptr) ret = Ogre::StringConverter::parseColourValue(*string);
     }
     return ret;
 }

+ 7 - 12
V-Gears/src/core/XmlFontFile.cpp

@@ -27,29 +27,24 @@ XmlFontFile::~XmlFontFile(){}
 void XmlFontFile::LoadFont(){
     TiXmlNode* node = file_.RootElement();
     if (node == nullptr || node->ValueStr() != "font"){
-        LOG_ERROR(
-          file_.ValueStr() + " is not a valid font file! No <font> in root."
-        );
+        LOG_ERROR(file_.ValueStr() + " is not a valid font file! No <font> in root.");
         return;
     }
     Ogre::String name = GetString(node, "name", "");
-    Ogre::String language = GetString( node, "language", "" );
+    Ogre::String language = GetString( node, "language", "");
     Ogre::String image = GetString(node, "image", "");
     Ogre::Vector2 size = GetVector2(node, "image_size", Ogre::Vector2::ZERO);
     int height = GetInt(node, "height", 0);
     if (name != "" && image != "" && size.x != 0 && size.y != 0){
-        UiFont* font = new UiFont( name, language );
-        font->SetImage(image, (int)size.x, (int)size.y);
+        UiFont* font = new UiFont(name, language);
+        font->SetImage(image, static_cast<int>(size.x), static_cast<int>(size.y));
         font->SetHeight(height);
         node = node->FirstChild();
         while (node != nullptr){
-            if (
-              node->Type() == TiXmlNode::TINYXML_ELEMENT
-              && node->ValueStr() == "char"
-            ){
+            if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "char"){
                 UiCharData data;
-                Ogre::UTFString name = GetUTFString(node, "name", "");
-                if (name != "") data.char_code = *(name.c_str());
+                Ogre::UTFString node_name = GetUTFString(node, "name", "");
+                if (node_name != "") data.char_code = *(node_name.c_str());
                 data.x = GetInt(node, "x", 0);
                 data.y = GetInt(node, "y", 0);
                 data.width = GetInt(node, "width", 0);

+ 2 - 6
V-Gears/src/core/XmlFontsFile.cpp

@@ -25,17 +25,13 @@ void XmlFontsFile::LoadFonts(){
     TiXmlNode* node = file_.RootElement();
     if (node == nullptr || node->ValueStr() != "fonts"){
         LOG_ERROR(
-          "UI XML Manager: " + file_.ValueStr()
-          + " is not a valid fonts file! No <fonts> in root."
+          "UI XML Manager: " + file_.ValueStr() + " is not a valid fonts file! No <fonts> in root."
         );
         return;
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "font"
-         ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "font"){
             XmlFontFile font("./data/" + GetString(node, "file_name"));
             font.LoadFont();
         }

+ 5 - 16
V-Gears/src/core/XmlMapsFile.cpp

@@ -24,20 +24,14 @@ const Ogre::String XmlMapsFile::GetMapFileNameByName(const Ogre::String& name){
     TiXmlNode* node = file_.RootElement();
     if (node == nullptr || node->ValueStr() != "maps"){
         LOG_ERROR(
-          "Field XML Manager: " + file_.ValueStr()
-          + " is not a valid maps file! No <maps> in root."
+          "Field XML Manager: " + file_.ValueStr() + " is not a valid maps file! No <maps> in root."
         );
         return "";
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "map"
-        ){
-            if (GetString(node, "name") == name)
-                return GetString(node, "file_name");
-        }
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "map")
+            if (GetString(node, "name") == name) return GetString(node, "file_name");
         node = node->NextSibling();
     }
     LOG_WARNING("Can't find map \"" + name + "\" in " + file_.ValueStr() + ".");
@@ -48,19 +42,14 @@ void XmlMapsFile::GetMapNames(Ogre::StringVector& complete_params){
     TiXmlNode* node = file_.RootElement();
     if (node == nullptr || node->ValueStr() != "maps"){
         LOG_ERROR(
-          "Field XML Manager: " + file_.ValueStr()
-          + " is not a valid maps file! No <maps> in root."
+          "Field XML Manager: " + file_.ValueStr() + " is not a valid maps file! No <maps> in root."
         );
         return;
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "map"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "map")
             complete_params.push_back(GetString(node, "name"));
-        }
         node = node->NextSibling();
     }
 }

+ 2 - 7
V-Gears/src/core/XmlMusicsFile.cpp

@@ -24,17 +24,12 @@ XmlMusicsFile::~XmlMusicsFile(){}
 void XmlMusicsFile::LoadMusics(){
     TiXmlNode* node = file_.RootElement();
     if (node == nullptr || node->ValueStr() != "musics"){
-        LOG_ERROR(
-          file_.ValueStr() + " is not a valid musics file! No <musics> in root."
-        );
+        LOG_ERROR(file_.ValueStr() + " is not a valid musics file! No <musics> in root.");
         return;
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "music"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "music"){
             AudioManager::Music music;
             music.name = GetString(node, "name");
             music.file = "./data/" + GetString(node, "file_name");

+ 1 - 4
V-Gears/src/core/XmlPrototypesFile.cpp

@@ -32,10 +32,7 @@ void XmlPrototypesFile::LoadPrototypes(){
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "prototype"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "prototype"){
             Ogre::String name = GetString(node, "name");
             UiManager::getSingleton().AddPrototype(name, node->Clone());
         }

+ 71 - 171
V-Gears/src/core/XmlScreenFile.cpp

@@ -30,9 +30,7 @@ XmlScreenFile::~XmlScreenFile(){}
 void XmlScreenFile::LoadScreen(){
     TiXmlNode* node = file_.RootElement();
     if (node == nullptr || node->ValueStr() != "screen"){
-        LOG_ERROR(
-          file_.ValueStr() + " is not a valid screen file! No <screen> in root."
-       );
+        LOG_ERROR(file_.ValueStr() + " is not a valid screen file! No <screen> in root.");
         return;
     }
     Ogre::String base_name = GetString(node, "name");
@@ -57,17 +55,15 @@ void XmlScreenFile::LoadScreenRecursive(
             || node->ValueStr() == "sprite"
             || node->ValueStr() == "text_area"
             || node->ValueStr() == "prototype"
-         )
-       ){
+          )
+        ){
             if (node->ValueStr() == "prototype"){
                 Ogre::String name = GetString(node, "name");
-                if (name != "") {
-                    TiXmlNode* node2
-                      = UiManager::getSingleton().GetPrototype(name);
+                if (name != ""){
+                    TiXmlNode* node2 = UiManager::getSingleton().GetPrototype(name);
                     if (node != nullptr){
                         node2 = node2->FirstChild();
-                        if (node2 != nullptr)
-                            LoadScreenRecursive(node2, base_name, widget);
+                        if (node2 != nullptr) LoadScreenRecursive(node2, base_name, widget);
                     }
                 }
             }
@@ -75,95 +71,64 @@ void XmlScreenFile::LoadScreenRecursive(
                 Ogre::String name = GetString(node, "name");
                 if (name != ""){
                     UiWidget* widget2;
-                    if (node->ValueStr() == "sprite"){
-                        widget2 = new UiSprite(
-                          name, base_name + "." + name, widget
-                       );
-                    }
-                    else if (node->ValueStr() == "text_area"){
-                        widget2 = new UiTextArea(
-                          name, base_name + "." + name, widget
-                       );
-                    }
-                    else{
-                        widget2 = new UiWidget(
-                          name, base_name + "." + name, widget
-                       );
-                    }
+                    if (node->ValueStr() == "sprite")
+                        widget2 = new UiSprite(name, base_name + "." + name, widget);
+                    else if (node->ValueStr() == "text_area")
+                        widget2 = new UiTextArea(name, base_name + "." + name, widget);
+                    else
+                        widget2 = new UiWidget(name, base_name + "." + name, widget);
                     if (node->ValueStr() == "sprite"){
                         Ogre::String image = GetString(node, "image");
-                        if (image != "") ((UiSprite*)widget2)->SetImage(image);
-                        Ogre::String vertex_shader
-                          = GetString(node, "vertex_shader");
-                        if (vertex_shader != ""){
-                            ((UiSprite*) widget2)->SetVertexShader(
-                              vertex_shader
-                           );
-                        }
-                        Ogre::String fragment_shader = GetString(
-                          node, "fragment_shader"
-                       );
-                        if (fragment_shader != ""){
-                            ((UiSprite*) widget2)->SetFragmentShader(
-                              fragment_shader
-                           );
-                        }
+                        if (image != "") (static_cast<UiSprite*>(widget2))->SetImage(image);
+                        Ogre::String vertex_shader = GetString(node, "vertex_shader");
+                        if (vertex_shader != "")
+                            static_cast<UiSprite*>(widget2)->SetVertexShader(vertex_shader);
+                        Ogre::String fragment_shader = GetString(node, "fragment_shader");
+                        if (fragment_shader != "")
+                            static_cast<UiSprite*>(widget2)->SetFragmentShader(fragment_shader);
                     }
-
                     if (node->ValueStr() == "text_area"){
                         Ogre::String text = GetString(node, "text_name", "");
                         if (text != ""){
-                            TiXmlNode* utf
-                              = TextManager::getSingleton().GetText(text);
-                            if (utf != nullptr)
-                                ((UiTextArea*) widget2)->SetText(utf);
+                            TiXmlNode* utf = TextManager::getSingleton().GetText(text);
+                            if (utf != nullptr) static_cast<UiTextArea*>(widget2)->SetText(utf);
                         }
                         Ogre::String font = GetString(node, "font", "");
-                        if (font != "") ((UiTextArea*) widget2)->SetFont(font);
+                        if (font != "") static_cast<UiTextArea*>(widget2)->SetFont(font);
                         Ogre::String align = GetString(node, "text_align", "");
                         if (align != ""){
-                            ((UiTextArea*) widget2)->SetTextAlign(
-                              (align == "center")
+                            static_cast<UiTextArea*>(widget2)->SetTextAlign(
+                              align == "center"
                                 ? UiTextArea::CENTER
-                                : (
-                                  (align == "right")
-                                  ? UiTextArea::RIGHT : UiTextArea::LEFT
-                               )
+                                : (align == "right" ? UiTextArea::RIGHT : UiTextArea::LEFT)
                             );
                         }
-                        Ogre::Vector4 padding = GetVector4(
-                          node, "padding", Ogre::Vector4::ZERO);
+                        Ogre::Vector4 padding = GetVector4(node, "padding", Ogre::Vector4::ZERO);
                         if (padding != Ogre::Vector4::ZERO){
-                            ((UiTextArea*) widget2)->SetPadding(
+                            static_cast<UiTextArea*>(widget2)->SetPadding(
                               padding.x, padding.y, padding.z, padding.w
                            );
                         }
                     }
                     Ogre::String colours = GetString(node, "colours", "");
                     if (colours != ""){
-                        Ogre::StringVector colour_string
-                          = Ogre::StringUtil::split(colours, ",");
+                        Ogre::StringVector colour_string = Ogre::StringUtil::split(colours, ",");
                         Ogre::Vector3 colour[4];
                         for (unsigned int i = 0; i < 4; ++ i){
                             Ogre::StringUtil::trim(colour_string[i]);
-                            colour[i]
-                              = (i < colour_string.size())
-                                ? Ogre::StringConverter::parseVector3(
-                                  colour_string[i]
-                               )
-                                : Ogre::Vector3(1, 1, 1);
+                            colour[i] = (i < colour_string.size())
+                              ? Ogre::StringConverter::parseVector3(colour_string[i])
+                              : Ogre::Vector3(1, 1, 1);
                         }
                         widget2->SetColours(
                           colour[0].x, colour[0].y, colour[0].z,
                           colour[1].x, colour[1].y, colour[1].z,
                           colour[2].x, colour[2].y, colour[2].z,
                           colour[3].x, colour[3].y, colour[3].z
-                       );
+                        );
                     }
                     else{
-                        Ogre::Vector3 colour = GetVector3(
-                          node, "colour", Ogre::Vector3(1, 1, 1)
-                       );
+                        Ogre::Vector3 colour = GetVector3(node, "colour", Ogre::Vector3(1, 1, 1));
                         widget2->SetColour(colour.x, colour.y, colour.z);
                     }
                     float alpha = GetFloat(node, "alpha", 1);
@@ -171,24 +136,18 @@ void XmlScreenFile::LoadScreenRecursive(
                     Ogre::String align = GetString(node, "align");
                     if (align != ""){
                         widget2->SetAlign(
-                          (align == "center")
-                          ? UiWidget::CENTER
-                          : (
-                            (align == "right")
-                            ? UiWidget::RIGHT : UiWidget::LEFT
-                         )
-                       );
+                          align == "center"
+                            ? UiWidget::CENTER
+                            : (align == "right" ? UiWidget::RIGHT : UiWidget::LEFT)
+                        );
                     }
                     Ogre::String valign = GetString(node, "valign");
                     if (valign != ""){
                         widget2->SetVerticalAlign(
-                          (valign == "middle")
-                          ? UiWidget::MIDDLE
-                          : (
-                            (valign == "bottom")
-                            ? UiWidget::BOTTOM : UiWidget::TOP
-                         )
-                       );
+                          valign == "middle"
+                            ? UiWidget::MIDDLE
+                            : (valign == "bottom" ? UiWidget::BOTTOM : UiWidget::TOP)
+                        );
                     }
                     Ogre::String origin_x_str = GetString(node, "origin_x");
                     if (origin_x_str != ""){
@@ -232,16 +191,12 @@ void XmlScreenFile::LoadScreenRecursive(
                         ParsePercent(height_percent, height, height_str);
                         widget2->SetHeight(height_percent, height);
                     }
-                    Ogre::Vector2 scale = GetVector2(
-                      node, "scale", Ogre::Vector2(1.0f, 1.0f)
-                   );
+                    Ogre::Vector2 scale = GetVector2(node, "scale", Ogre::Vector2(1.0f, 1.0f));
                     widget2->SetScale(scale);
                     widget2->SetRotation(GetFloat(node, "rotation", 0.0f));
                     Ogre::String scissor_area  = GetString(node, "scissor_area");
                     if (scissor_area != ""){
-                        Ogre::StringVector coords = Ogre::StringUtil::split(
-                          scissor_area, " "
-                       );
+                        Ogre::StringVector coords = Ogre::StringUtil::split(scissor_area, " ");
                         if (coords.size() == 4){
                             float percent_x1, x1, percent_y1, y1;
                             float percent_x2, x2, percent_y2, y2 = 0;
@@ -250,39 +205,26 @@ void XmlScreenFile::LoadScreenRecursive(
                             ParsePercent(percent_x2, x2, coords[2]);
                             ParsePercent(percent_y2, y2, coords[3]);
                             widget2->SetScissorArea(
-                              percent_x1, x1, percent_y1, y1,
-                              percent_x2, x2, percent_y2, y2
+                              percent_x1, x1, percent_y1, y1, percent_x2, x2, percent_y2, y2
                            );
                         }
                     }
-                    widget2->SetGlobalScissor(
-                      GetBool(node, "global_scissor", true)
-                   );
+                    widget2->SetGlobalScissor(GetBool(node, "global_scissor", true));
                     widget2->SetVisible(GetBool(node, "visible", false));
                     if (node->ValueStr() == "sprite")
-                        ((UiSprite*) widget2)->UpdateGeometry();
+                        static_cast<UiSprite*>(widget2)->UpdateGeometry();
                     else if (node->ValueStr() == "text_area")
-                        ((UiTextArea*) widget2)->UpdateGeometry();
+                        static_cast<UiTextArea*>(widget2)->UpdateGeometry();
                     widget->AddChild(widget2);
                     TiXmlNode* node2 = node->FirstChild();
-                    if (node2 != nullptr){
-                        LoadScreenRecursive(
-                          node2, base_name + "." + name, widget2
-                       );
-                    }
-                }
-                else{
-                    LOG_ERROR(
-                      "There is no name in entity with base name " + base_name
-                   );
+                    if (node2 != nullptr)
+                        LoadScreenRecursive(node2, base_name + "." + name, widget2);
                 }
+                else LOG_ERROR("There is no name in entity with base name " + base_name);
             }
         }
         // Parse animation data for widget.
-        else if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "animation"
-       ){
+        else if (node->Type() == TiXmlNode::TINYXML_ELEMENT&& node->ValueStr() == "animation"){
             Ogre::String name = GetString(node, "name", "");
             if (name != ""){
                 UiAnimation* animation = new UiAnimation(name, widget);
@@ -290,34 +232,24 @@ void XmlScreenFile::LoadScreenRecursive(
                 animation->SetLength(anim_length);
                 Ogre::String scale = GetString(node, "scale", "");
                 if (scale != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      scale, ","
-                   );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(scale, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                       );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameVector2 key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
-                            key.value = Ogre::StringConverter::parseVector2(
-                              data[1]
-                           );
+                            key.value = Ogre::StringConverter::parseVector2(data[1]);
                             animation->AddScaleKeyFrame(key);
                         }
                     }
                 }
                 Ogre::String x = GetString(node, "x", "");
                 if (x != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      x, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(x, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameVector2 key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
@@ -328,14 +260,10 @@ void XmlScreenFile::LoadScreenRecursive(
                 }
                 Ogre::String y = GetString(node, "y", "");
                 if (y != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      y, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(y, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameVector2 key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
@@ -346,14 +274,10 @@ void XmlScreenFile::LoadScreenRecursive(
                 }
                 Ogre::String width = GetString(node, "width", "");
                 if (width != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      width, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(width, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameVector2 key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
@@ -364,14 +288,10 @@ void XmlScreenFile::LoadScreenRecursive(
                 }
                 Ogre::String height = GetString(node, "height", "");
                 if (height != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      height, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(height, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameVector2 key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
@@ -382,14 +302,10 @@ void XmlScreenFile::LoadScreenRecursive(
                 }
                 Ogre::String rotation = GetString(node, "rotation", "");
                 if (rotation != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      rotation, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(rotation, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameFloat key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
@@ -400,52 +316,36 @@ void XmlScreenFile::LoadScreenRecursive(
                 }
                 Ogre::String alpha = GetString(node, "alpha", "");
                 if (alpha != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      alpha, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(alpha, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameFloat key;
                             key.time = ParseKeyFrameTime(anim_length, data[0]);
-                            key.value = Ogre::StringConverter::parseReal(
-                              data[1]
-                            );
+                            key.value = Ogre::StringConverter::parseReal(data[1]);
                             animation->AddAlphaKeyFrame(key);
                         }
                     }
                 }
                 Ogre::String scissor_area = GetString(node, "scissor_area", "");
                 if (scissor_area != ""){
-                    Ogre::StringVector key_frame = Ogre::StringUtil::split(
-                      scissor_area, ","
-                    );
+                    Ogre::StringVector key_frame = Ogre::StringUtil::split(scissor_area, ",");
                     for (unsigned int i = 0; i < key_frame.size(); ++ i){
                         Ogre::StringUtil::trim(key_frame[i]);
-                        Ogre::StringVector data = Ogre::StringUtil::split(
-                          key_frame[i], ":"
-                        );
+                        Ogre::StringVector data = Ogre::StringUtil::split(key_frame[i], ":");
                         if (data.size() > 1){
                             UiKeyFrameVector2 key1, key2, key3, key4;
                             key1.time = ParseKeyFrameTime(anim_length, data[0]);
                             key2.time = key1.time;
                             key3.time = key1.time;
                             key4.time = key1.time;
-                            Ogre::StringVector keys = Ogre::StringUtil::split(
-                              data[1], " "
-                            );
-                            float percent_x1, x1, percent_y1, y1;
-                            float percent_x2, x2, percent_y2, y2 = 0;
+                            Ogre::StringVector keys = Ogre::StringUtil::split(data[1], " ");
                             ParsePercent(key1.value.x, key1.value.y, keys[0]);
                             ParsePercent(key2.value.x, key2.value.y, keys[1]);
                             ParsePercent(key3.value.x, key3.value.y, keys[2]);
                             ParsePercent(key4.value.x, key4.value.y, keys[3]);
-                            animation->AddScissorKeyFrame(
-                              key1, key2, key3, key4
-                            );
+                            animation->AddScissorKeyFrame(key1, key2, key3, key4);
                         }
                     }
                 }

+ 4 - 14
V-Gears/src/core/XmlScreensFile.cpp

@@ -24,23 +24,16 @@ XmlScreensFile::~XmlScreensFile(){}
 
 void XmlScreensFile::LoadScreens(){
     TiXmlNode* node = file_.RootElement();
-
     if (node == nullptr || node->ValueStr() != "ui"){
         LOG_ERROR(
-          "UI XML Manager: " + file_.ValueStr()
-          + " is not a valid ui file! No <ui> in root."
+          "UI XML Manager: " + file_.ValueStr() + " is not a valid ui file! No <ui> in root."
         );
         return;
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "prototype"
-        ){
-            XmlPrototypesFile prototypes(
-              "./data/" + GetString(node, "file_name")
-            );
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT&& node->ValueStr() == "prototype"){
+            XmlPrototypesFile prototypes("./data/" + GetString(node, "file_name"));
             prototypes.LoadPrototypes();
         }
         node = node->NextSibling();
@@ -48,10 +41,7 @@ void XmlScreensFile::LoadScreens(){
     node = file_.RootElement();
     node = node->FirstChild();
     while (node != NULL){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "screen"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "screen"){
             XmlScreenFile screen("./data/" + GetString(node, "file_name"));
             screen.LoadScreen();
         }

+ 4 - 16
V-Gears/src/core/XmlScriptsFile.cpp

@@ -24,30 +24,18 @@ XmlScriptsFile::~XmlScriptsFile(){}
 void XmlScriptsFile::LoadScripts(){
     TiXmlNode* node = file_.RootElement();
     if(node == nullptr || node->ValueStr() != "scripts"){
-        LOG_ERROR(
-          file_.ValueStr()
-          + " is not a valid scripts file! No <scripts> in root."
-        );
+        LOG_ERROR(file_.ValueStr() + " is not a valid scripts file! No <scripts> in root.");
         return;
     }
     node = node->FirstChild();
     ScriptManager &script_manager(ScriptManager::getSingleton());
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "script"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "script")
             script_manager.RunFile(GetString(node, "file"));
-        }
-        else if(
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "system_script"
-        ){
+        else if(node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "system_script"){
             Ogre::String name = GetString(node, "name");
             if (name == ""){
-                LOG_ERROR(
-                  "There is no name specified for <system_script> tag."
-                );
+                LOG_ERROR("There is no name specified for <system_script> tag.");
                 continue;
             }
             script_manager.AddEntity(ScriptManager::SYSTEM, name, nullptr);

+ 4 - 13
V-Gears/src/core/XmlTextFile.cpp

@@ -26,30 +26,21 @@ void XmlTextFile::LoadTexts(){
     TiXmlNode* node = file_.RootElement();
     if(node == nullptr || node->ValueStr() != "texts"){
         LOG_ERROR(
-          "Text Manager: " + file_.ValueStr()
-          + " is not a valid text file! No <texts> in root."
+          "Text Manager: " + file_.ValueStr() + " is not a valid text file! No <texts> in root."
         );
         return;
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "text"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "text"){
             Ogre::String name = GetString(node, "name");
             TextManager::getSingleton().AddText(name, node->Clone());
         }
-        else if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "dialog"
-        ){
+        else if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "dialog"){
             Ogre::String name = GetString( node, "name" );
             float width = GetFloat( node, "width", 0.0f );
             float height = GetFloat( node, "height", 0.0f );
-            TextManager::getSingleton().AddDialog(
-              name, node->Clone(), width, height
-            );
+            TextManager::getSingleton().AddDialog(name, node->Clone(), width, height);
         }
         node = node->NextSibling();
     }

+ 6 - 22
V-Gears/src/core/XmlTextsFile.cpp

@@ -26,19 +26,14 @@ void XmlTextsFile::GetAvailableLanguages(Ogre::StringVector& languages){
     TiXmlNode* node = file_.RootElement();
     if (node == NULL || node->ValueStr() != "texts"){
         LOG_ERROR(
-          "UI Text Manager: " + file_.ValueStr()
-          + " is not a valid texts file! No <texts> in root."
+          "UI Text Manager: " + file_.ValueStr() + " is not a valid texts file! No <texts> in root."
         );
         return;
     }
     node = node->FirstChild();
     while (node != NULL){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "language"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "language")
             languages.push_back(GetString(node, "name"));
-        }
         node = node->NextSibling();
     }
 }
@@ -47,35 +42,24 @@ void XmlTextsFile::LoadTexts(){
     TiXmlNode* node = file_.RootElement();
     if (node == NULL || node->ValueStr() != "texts"){
         LOG_ERROR(
-          "Text Manager: " + file_.ValueStr()
-          + " is not a valid texts file! No <texts> in root."
+          "Text Manager: " + file_.ValueStr() + " is not a valid texts file! No <texts> in root."
         );
         return;
     }
     Ogre::String language = TextManager::getSingleton().GetLanguage();
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "language"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "language"){
             if (GetString(node, "name") == language){
                 TiXmlNode* node2 = node->FirstChild();
                 while (node2 != nullptr){
-                    if (
-                      node2->Type() == TiXmlNode::TINYXML_ELEMENT
-                      && node2->ValueStr() == "text"
-                    ){
+                    if (node2->Type() == TiXmlNode::TINYXML_ELEMENT && node2->ValueStr() == "text"){
                         Ogre::String file = GetString(node2, "file");
                         if (file != ""){
                             XmlTextFile text("./data/" + file);
                             text.LoadTexts();
                         }
-                        else{
-                            LOG_ERROR(
-                              "Empty filename in language " + language + "."
-                            );
-                        }
+                        else LOG_ERROR("Empty filename in language " + language + ".");
                     }
                     node2 = node2->NextSibling();
                 }

+ 4 - 7
V-Gears/src/core/XmlWalkmeshFile.cpp

@@ -34,17 +34,14 @@ void XmlWalkmeshFile::Load(){
     }
     node = node->FirstChild();
     while (node != nullptr){
-        if (
-          node->Type() == TiXmlNode::TINYXML_ELEMENT
-          && node->ValueStr() == "triangle"
-        ){
+        if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "triangle"){
             WalkmeshTriangle triangle;
             triangle.a = GetVector3(node, "a");
             triangle.b = GetVector3(node, "b");
             triangle.c = GetVector3(node, "c");
-            triangle.access_side[ 0 ] = GetInt(node, "a_b");
-            triangle.access_side[ 1 ] = GetInt(node, "b_c");
-            triangle.access_side[ 2 ] = GetInt(node, "c_a");
+            triangle.access_side[0] = GetInt(node, "a_b");
+            triangle.access_side[1] = GetInt(node, "b_c");
+            triangle.access_side[2] = GetInt(node, "c_a");
             walkmesh->AddTriangle(triangle);
         }
         node = node->NextSibling();

+ 13 - 30
V-Gears/src/core/particles/ParticleRendererTranslator.cpp

@@ -25,20 +25,14 @@ void ParticleRendererTranslator::translate(
 
     // name can't be empty because we get renderer type from it
     if(obj->name.empty()){
-        compiler->addError(
-          Ogre::ScriptCompiler::CE_OBJECTNAMEEXPECTED, obj->file, obj->line
-        );
+        compiler->addError(Ogre::ScriptCompiler::CE_OBJECTNAMEEXPECTED, obj->file, obj->line);
         return;
     }
-    ParticleTechnique* tech = Ogre::any_cast<ParticleTechnique*>(
-      obj->parent->context
-    );
+    ParticleTechnique* tech = Ogre::any_cast<ParticleTechnique*>(obj->parent->context);
 
     ParticleRenderer* rend = tech->CreateRenderer(obj->name);
     if (rend == nullptr) {
-        compiler->addError(
-          Ogre::ScriptCompiler::CE_OBJECTALLOCATIONERROR, obj->file, obj->line
-        );
+        compiler->addError(Ogre::ScriptCompiler::CE_OBJECTALLOCATIONERROR, obj->file, obj->line);
         return;
     }
     Ogre::LogManager::getSingletonPtr()->logMessage(
@@ -46,9 +40,7 @@ void ParticleRendererTranslator::translate(
     );
 
     for (
-      Ogre::AbstractNodeList::iterator i = obj->children.begin();
-      i != obj->children.end();
-      ++ i
+      Ogre::AbstractNodeList::iterator i = obj->children.begin(); i != obj->children.end(); ++ i
     ){
         if ((*i)->type == Ogre::ANT_PROPERTY){
             Ogre::PropertyAbstractNode *prop =
@@ -57,37 +49,28 @@ void ParticleRendererTranslator::translate(
 
             // Glob the values together
             for (
-              Ogre::AbstractNodeList::iterator i = prop->values.begin();
-              i != prop->values.end();
-              ++ i
+              Ogre::AbstractNodeList::iterator j = prop->values.begin();
+              j != prop->values.end();
+              ++ j
             ){
-                if((*i)->type == Ogre::ANT_ATOM){
-                    if (value.empty()){
-                        value = ((Ogre::AtomAbstractNode*)(*i).get())->value;
-                    }
-                    else{
-                        value =
-                          value + " "
-                          + ((Ogre::AtomAbstractNode*)(*i).get())->value;
-                    }
+                if((*j)->type == Ogre::ANT_ATOM){
+                    if (value.empty()) value = ((Ogre::AtomAbstractNode*)(*j).get())->value;
+                    else value = value + " " + ((Ogre::AtomAbstractNode*)(*j).get())->value;
                 }
                 else{
                     compiler->addError(
-                      Ogre::ScriptCompiler::CE_INVALIDPARAMETERS,
-                      prop->file, prop->line
+                      Ogre::ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line
                     );
                     break;
                 }
             }
 
             Ogre::LogManager::getSingletonPtr()->logMessage(
-              "ParticleRendererTranslator: Set param '"
-              + prop->name + "' to '" + value + "'."
+              "ParticleRendererTranslator: Set param '" + prop->name + "' to '" + value + "'."
             );
             if (!rend->setParameter(prop->name, value)){
                 compiler->addError(
-                  Ogre::ScriptCompiler::CE_INVALIDPARAMETERS,
-                  prop->file, prop->line
+                  Ogre::ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line
                 );
             }
         }

+ 1 - 1
V-Gears/src/core/particles/ParticleSystem.cpp

@@ -43,7 +43,7 @@ void ParticleSystem::CopyAttributesTo(ParticleSystem* ps){
 }
 
 const Ogre::String& ParticleSystem::getMovableType() const{
-    static Ogre::String type = "ParticleSystem";
+    Ogre::String type = "ParticleSystem";
     return type;
 }
 

+ 2 - 1
V-Gears/src/core/particles/ParticleSystemManager.cpp

@@ -16,8 +16,9 @@
 #include <OgreLogManager.h>
 #include <OgreRoot.h>
 #include "core/particles/ParticleSystemManager.h"
+
+#include "../../../include/core/particles/emitters/PointEmitterFactory.h"
 #include "core/particles/ParticleSystemFactory.h"
-#include "core/particles/emitters/ParticlePointEmitterFactory.h"
 #include "core/particles/renderer/ParticleEntityRendererFactory.h"
 
 template<> ParticleSystemManager*

+ 30 - 54
V-Gears/src/core/particles/ParticleTechnique.cpp

@@ -21,11 +21,11 @@
 
 
 ParticleTechnique::ParticleTechnique():
-    renderer_(nullptr),
-    visual_particle_quota_(10),
-    visual_particle_pool_increased_(false),
-    emitted_emitter_quota_(10),
-    particle_emitter_pool_increased_(false)
+  renderer_(nullptr),
+  visual_particle_quota_(10),
+  visual_particle_pool_increased_(false),
+  emitted_emitter_quota_(10),
+  particle_emitter_pool_increased_(false)
 {}
 
 ParticleTechnique::~ParticleTechnique(){
@@ -47,9 +47,8 @@ void ParticleTechnique::CopyAttributesTo(ParticleTechnique* technique){
     technique->emitted_emitter_quota_ = emitted_emitter_quota_;
     technique->particle_emitter_pool_increased_ = false;
     // Copy all emitters
-    ParticleEmitter* cloned_emitter;
     for (unsigned int i = 0; i < emitters_.size(); ++ i){
-        cloned_emitter = ParticleSystemManager::getSingletonPtr()->CloneEmitter(
+        ParticleEmitter* cloned_emitter = ParticleSystemManager::getSingletonPtr()->CloneEmitter(
           emitters_[i]
         );
         technique->AddEmitter( cloned_emitter );
@@ -63,8 +62,7 @@ void ParticleTechnique::UpdateRenderQueue(Ogre::RenderQueue* queue){
 }
 
 void ParticleTechnique::Initialize(){
-    if (renderer_ && renderer_->IsRendererInitialised() == false)
-        renderer_->Initialize();
+    if (renderer_ && renderer_->IsRendererInitialised() == false) renderer_->Initialize();
     // Create new visual particles if the quota has been increased
     if (visual_particle_pool_increased_ == false){
         int old_size = visual_particles_pool_.GetSize();
@@ -87,8 +85,7 @@ void ParticleTechnique::Initialize(){
             // in the technique and which are marked for emission.
             int number_of_emitted_emitters = GetNumEmittableEmitters();
             if (number_of_emitted_emitters == 0) return;
-            ParticleEmitter* existing_emitter = 0;
-            ParticleEmitter* cloned_emitter = 0;
+            ParticleEmitter* cloned_emitter;
             // Distribute size equally
             int increment = emitted_emitter_quota_ / number_of_emitted_emitters;
             // Run through emitters of the technique
@@ -96,8 +93,9 @@ void ParticleTechnique::Initialize(){
                 if( emitters_[ i ]->IsEmittable() ){
                     // Clone the emitter 'increment' times and add to the pool
                     for (int j = 0; j < increment; ++ j){
-                        cloned_emitter =ParticleSystemManager::getSingletonPtr()
-                          ->CloneEmitter(emitters_[i]);
+                        cloned_emitter = ParticleSystemManager::getSingletonPtr()->CloneEmitter(
+                          emitters_[i]
+                        );
                         cloned_emitter->SetEmittable(true);
                         particle_emitter_pool_.AddElement(
                           cloned_emitter->GetName(), cloned_emitter
@@ -111,18 +109,16 @@ void ParticleTechnique::Initialize(){
 }
 
 void ParticleTechnique::Update(Ogre::Real time_elapsed){
-    // Perform some initialisation type of activities (if needed). This must be
-    // done within the update-loop, because settings could be changed (i.e.
-    // changing quota), which must trigger a re-initialisation.
+    // Perform some initialisation type of activities (if needed). This must be done within the
+    // update-loop, because settings could be changed (i.e. changing quota), which must trigger a
+    // re-initialisation.
     Initialize();
-    // Process the emitters
+    // Process the emitters.
     for (unsigned int i = 0; i < emitters_.size(); ++ i){
-        // emitted particles handled in pool update
+        // Wmitted particles handled in pool update.
         if (emitters_[ i ]->IsEmittable() == false){
             ExecuteEmitParticles(
-              emitters_[i],
-              emitters_[i]->CalculateRequestedParticles(time_elapsed),
-              time_elapsed
+              emitters_[i], emitters_[i]->CalculateRequestedParticles(time_elapsed), time_elapsed
             );
         }
     }
@@ -131,9 +127,7 @@ void ParticleTechnique::Update(Ogre::Real time_elapsed){
         VisualParticle* particle = visual_particles_pool_.GetFirst();
         while (!visual_particles_pool_.End()){
             if (particle != nullptr){
-                if (particle->time_to_live > time_elapsed){
-                    particle->Update(time_elapsed);
-                }
+                if (particle->time_to_live > time_elapsed) particle->Update(time_elapsed);
                 else{
                     particle->InitForExpiration();
                     visual_particles_pool_.LockLatestElement();
@@ -152,9 +146,7 @@ void ParticleTechnique::Update(Ogre::Real time_elapsed){
                 if (particle->time_to_live > time_elapsed){
                     particle->Update(time_elapsed);
                     ExecuteEmitParticles(
-                      particle,
-                      particle->CalculateRequestedParticles(time_elapsed),
-                      time_elapsed
+                      particle, particle->CalculateRequestedParticles(time_elapsed), time_elapsed
                     );
                 }
                 else{
@@ -169,14 +161,10 @@ void ParticleTechnique::Update(Ogre::Real time_elapsed){
     }
 }
 
-ParticleRenderer* ParticleTechnique::CreateRenderer(
-  const Ogre::String& renderer_type
-){
+ParticleRenderer* ParticleTechnique::CreateRenderer(const Ogre::String& renderer_type){
     if (renderer_) DestroyRenderer();
     if (renderer_type != Ogre::BLANKSTRING){
-        renderer_ = ParticleSystemManager::getSingletonPtr()->CreateRenderer(
-          renderer_type
-        );
+        renderer_ = ParticleSystemManager::getSingletonPtr()->CreateRenderer(renderer_type);
         renderer_->SetParentTechnique(this);
         renderer_->SetRendererInitialised(false);
     }
@@ -197,13 +185,10 @@ void ParticleTechnique::DestroyRenderer(){
     }
 }
 
-ParticleEmitter* ParticleTechnique::CreateEmitter(
-  const Ogre::String& emitter_type
-){
+ParticleEmitter* ParticleTechnique::CreateEmitter(const Ogre::String& emitter_type){
     ParticleEmitter* emitter = nullptr;
     if (emitter_type != Ogre::BLANKSTRING){
-        emitter =
-          ParticleSystemManager::getSingletonPtr()->CreateEmitter(emitter_type);
+        emitter = ParticleSystemManager::getSingletonPtr()->CreateEmitter(emitter_type);
         emitters_.push_back(emitter);
         emitter->SetParentTechnique(this);
         EmissionChange();
@@ -227,25 +212,20 @@ void ParticleTechnique::DestroyAllEmitters(){
 
 int ParticleTechnique::GetNumEmittableEmitters() const{
     int count = 0;
-    for (unsigned int i = 0; i < emitters_.size(); ++ i){
-        if (emitters_[i]->IsEmittable()) count++;
-    }
+    for (unsigned int i = 0; i < emitters_.size(); ++ i) if (emitters_[i]->IsEmittable()) count++;
     return count;
 }
 
 void ParticleTechnique::EmissionChange() {
     // Run through all emitters and set MarkedForEmission to false.
-    for (unsigned int i = 0; i < emitters_.size(); ++ i)
-        emitters_[i]->SetEmittable(false);
+    for (unsigned int i = 0; i < emitters_.size(); ++ i) emitters_[i]->SetEmittable(false);
     // Run through all emitters and determine which objects each one emits.
     for (unsigned int i = 0; i < emitters_.size(); ++ i){
         Ogre::String name = emitters_[i]->GetEmitsName();
         if (name != emitters_[i]->GetName()){
             // Search the emitter to be emitted
-            for (unsigned int j = 0; j < emitters_.size(); ++ j){
-                if (emitters_[j]->GetName() == name)
-                    emitters_[j]->SetEmittable(true);
-            }
+            for (unsigned int j = 0; j < emitters_.size(); ++ j)
+                if (emitters_[j]->GetName() == name) emitters_[j]->SetEmittable(true);
         }
     }
 }
@@ -267,17 +247,13 @@ void ParticleTechnique::ExecuteEmitParticles(
                 particle = visual_particles_pool_.ReleaseElement();
                 break;
             case Particle::PT_EMITTER:
-                particle = particle_emitter_pool_.ReleaseElement(
-                  emitter->GetEmitsName()
-                );
+                particle = particle_emitter_pool_.ReleaseElement(emitter->GetEmitsName());
                 break;
         }
-        // Return if there is no particle left anymore, or the name cannot be
-        // found
+        // Return if there is no particle left anymore, or the name cannot be found.
         if (particle == nullptr){
             Ogre::LogManager::getSingletonPtr()->logMessage(
-              "ParticleTechnique::ExecuteEmitParticles request there are no "
-              "particles left."
+              "ParticleTechnique::ExecuteEmitParticles request there are no particles left."
             );
             return;
         }

+ 2 - 4
V-Gears/src/core/particles/emitters/ParticlePointEmitter.cpp → V-Gears/src/core/particles/emitters/PointEmitter.cpp

@@ -13,11 +13,9 @@
  * GNU General Public License for more details.
  */
 
-#include "core/particles/emitters/ParticlePointEmitter.h"
+#include "core/particles/emitters/PointEmitter.h"
 
-PointEmitter::PointEmitter():ParticleEmitter(){
-    emitter_type_ = "Point";
-}
+PointEmitter::PointEmitter():ParticleEmitter(){emitter_type_ = "Point";}
 
 void PointEmitter::CopyAttributesTo(ParticleEmitter* emitter){
     ParticleEmitter::CopyAttributesTo(emitter);

+ 39 - 0
V-Gears/src/core/particles/emitters/PointEmitterFactory.cpp

@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+
+#include "core/particles/emitters/PointEmitterFactory.h"
+
+
+PointEmitterFactory::PointEmitterFactory(){};
+
+/**
+ * Destructor.
+ */
+PointEmitterFactory::~PointEmitterFactory(){};
+
+/**
+ * Retrieves the emitter type.
+ *
+ * @return The emitter type (always "Point").
+ */
+Ogre::String PointEmitterFactory::GetEmitterType() const{return "Point";}
+
+/**
+ * Creates an emitter.
+ *
+ * @return A new {@see PointEmitter}.
+ */
+ParticleEmitter* PointEmitterFactory::CreateEmitter(){return CreateEmitter_<PointEmitter>();}

+ 0 - 6
V-Gears/src/data/VGearsBackgroundFile.cpp

@@ -94,12 +94,10 @@ namespace VGears{
         assert(palette != nullptr);
         SpritePtrList sprites;
         AddAllSprites(sprites);
-        size_t sprite_count(sprites.size());
         size_t width(1024);
         size_t row_pitch(width);
         size_t height(width);
         size_t pixel_count(width * height);
-        row_pitch = width;
         Ogre::PixelFormat format(Ogre::PF_A8R8G8B8);
         size_t memory_size(
           Ogre::PixelUtil::getMemorySize(width, height, 1, format)
@@ -107,10 +105,6 @@ namespace VGears{
         Ogre::MemoryDataStream *buffer(new Ogre::MemoryDataStream(memory_size));
         uint32 *color(reinterpret_cast<uint32*>(buffer->getPtr()));
 
-        /*
-        Ogre::LogManager::getSingleton().stream() << "Image Size: " << width
-          << " x " << height << " sprite_count " << sprite_count;
-        */
         int dst_x(0), dst_y(0);
         int dst_x_16(0), dst_y_16(0);
         int dst_x_32(0), dst_y_32(0);

+ 3 - 3
V-Gears/src/data/VGearsCameraMatrixFileSerializer.cpp

@@ -61,9 +61,9 @@ namespace VGears{
         orientation.FromRotationMatrix(camera_matrix);
         position = orientation * (position / 128.0f);
         // Matrix fix up.
-        camera_matrix[0][0] = camera_matrix[0][0];
-        camera_matrix[1][0] = camera_matrix[1][0];
-        camera_matrix[2][0] = camera_matrix[2][0];
+        //camera_matrix[0][0] = camera_matrix[0][0];
+        //camera_matrix[1][0] = camera_matrix[1][0];
+        //camera_matrix[2][0] = camera_matrix[2][0];
         camera_matrix[0][1] = -camera_matrix[0][1];
         camera_matrix[1][1] = -camera_matrix[1][1];
         camera_matrix[2][1] = -camera_matrix[2][1];

+ 0 - 1
V-Gears/src/data/VGearsFLevelFileSerializer.cpp

@@ -51,7 +51,6 @@ namespace VGears{
         std::vector<uint32> section_sizesVec(header_.section_count);
         readInts(stream, section_offsetsVec.data(), header_.section_count);
         // Now calculate section sizes
-        size_t fileSize = stream->size();
         for (size_t i = 0; i < section_offsetsVec.size(); i ++){
             if (i+1 == section_offsetsVec.size()){
                 // The file size is needed to calculate this, since it's not

+ 5 - 5
V-Gears/src/data/VGearsHRCFileSerializer.cpp

@@ -99,12 +99,12 @@ namespace VGears{
         );
         String rsd_names("");
         for (
-          Ogre::StringVector::const_iterator it(++rsd_list.begin());
-          it != rsd_list.end();
-          ++ it
+          Ogre::StringVector::const_iterator rsd_it(++ rsd_list.begin());
+          rsd_it != rsd_list.end();
+          ++ rsd_it
         ){
-            dest.rsd_names.push_back(*it);
-            rsd_names += *it + " ";
+            dest.rsd_names.push_back(*rsd_it);
+            rsd_names += *rsd_it + " ";
         }
 
         if(rsd_count != dest.rsd_names.size()){

+ 1 - 1
V-Gears/src/data/VGearsPFile.cpp

@@ -81,7 +81,7 @@ namespace VGears{
         size_t normal_count(normals_.size());
         size_t edge_count  (edges_.size());
         for (size_t p(polygon_definitions_.size()); p --;){
-            PolygonDefinition& def(polygon_definitions_[p]);
+            const PolygonDefinition& def(polygon_definitions_[p]);
             for (int i(3); i --;){
                 if (def.vertex[i] >= vertex_count){
                     log << "Error: index to vertex is out of Bounds "

+ 1 - 1
V-Gears/src/data/VGearsTexCodec.cpp

@@ -93,7 +93,7 @@ namespace VGears{
 
     void TexCodec::uninstall(){
         if (tex_codec_ != nullptr){
-            OGRE_DELETE tex_codec_;
+            delete tex_codec_;
             tex_codec_ = nullptr;
         }
     }

+ 1 - 4
V-Gears/src/data/VGearsTexFile.cpp

@@ -125,7 +125,6 @@ namespace VGears{
 
     void TexFile::FlipEndian(void * pData, size_t size, size_t count) const{
 #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
-        std::cout << "FLIP ENDIAN 1\n";
         for (unsigned int index = 0; index < count; index ++)
             FlipEndian((void *)((long)pData + (index * size)), size);
 #endif
@@ -133,10 +132,8 @@ namespace VGears{
 
     void TexFile::FlipEndian(void * pData, size_t size) const{
 #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
-        std::cout << "FLIP ENDIAN 2\n";
-        char swap_byte;
         for(unsigned int byteIndex = 0; byteIndex < size/2; byteIndex ++){
-            swap_byte = *(char *)((long)pData + byteIndex);
+            char swap_byte = *(char *)((long)pData + byteIndex);
             *(char *)((long)pData + byteIndex)
               = *(char *)((long)pData + size - byteIndex - 1);
             *(char *)((long)pData + size - byteIndex - 1) = swap_byte;

+ 2 - 5
V-Gears/src/data/worldmap/TxzFileSerializer.cpp

@@ -65,9 +65,6 @@ namespace VGears {
         for (auto& section_offset : section_offsets)
             ReadUInt32(stream, section_offset);
 
-        std::cout
-          << "Got " << section_offsets.size() << " blocks " << std::endl;
-
         // Section 2 is the world map textures.
         if (section_offsets.size() >= 2){
             // Skip 4 to get the real start position.
@@ -107,7 +104,7 @@ namespace VGears {
             std::ofstream s(ss.str().c_str(), std::ios::binary);
             if (s.is_open()){
                 s.write(
-                  (const char*) tmp_block.pixels.data(),
+                  reinterpret_cast<const char*>(tmp_block.pixels.data()),
                   tmp_block.pixels.size()
                 );
             }
@@ -633,7 +630,7 @@ namespace VGears {
         //int entry_count = 20;
         for (int i = 0; i < entry_count; i ++){
             // Get the hard coded pre-baked known record.
-            harcoded_texture_info2& info = hardcoded_textures[i];
+            const harcoded_texture_info2& info = hardcoded_textures[i];
             // Grab the WM texture for it
             const WorldMapTexture& wm_texture = pallete_table[info.id];
             // From the wm texture grab the pallete data

+ 2 - 2
V-Gears/src/map/FinalFantasy7/FF7WalkmeshFileSerializer.cpp

@@ -48,8 +48,8 @@ namespace VGears{
         triangle_list.clear();
         triangle_list.reserve(triangle_count);
         for (uint32 i(0); i < triangle_count; ++ i){
-            Triangle &in_triangle(triangles[i]);
-            Access &in_access(access[i]);
+            const Triangle &in_triangle(triangles[i]);
+            const Access &in_access(access[i]);
             WalkmeshTriangle tmp_triangle;
             tmp_triangle.a = in_triangle.a;
             tmp_triangle.b = in_triangle.b;

+ 1 - 1
data/data/scripts/field.lua

@@ -92,7 +92,7 @@ split_party = function(ax, ay, ar, bx, by, br, speed)
                 -- Approximated speed, good enough for now.
                 -- TODO: Calculate speed based on time, as the orignal opcode.
                 character:set_move_auto_speed(speed / 16)
-                if charater:is_visible() == false then
+                if character:is_visible() == false then
                     -- In theory, a member is never visible before a split, but some maps
                     -- are wrong. In these cases, don't change position and move the entity
                     -- from it's current position.