diff --git a/3rdparty/c55lib/c55/filesys.cpp b/3rdparty/c55lib/c55/filesys.cpp index 5169b76..de360bd 100644 --- a/3rdparty/c55lib/c55/filesys.cpp +++ b/3rdparty/c55lib/c55/filesys.cpp @@ -46,7 +46,7 @@ std::string stripFilename(const std::string &path) return ""; } -#ifdef _WIN32 // WINDOWS +#ifdef _WIN32 // WINDOWS #define _WIN32_WINNT 0x0501 #include @@ -188,7 +188,7 @@ bool RecursiveDelete(std::string path) return true; } -#else // POSIX +#else // POSIX #include #include @@ -348,6 +348,6 @@ bool CreateAllDirs(std::string path) return true; } -} // namespace fs +} // namespace fs // vim: set noet ts=4 sw=4: diff --git a/3rdparty/c55lib/c55/filesys.h b/3rdparty/c55lib/c55/filesys.h index c724b1f..263d230 100644 --- a/3rdparty/c55lib/c55/filesys.h +++ b/3rdparty/c55lib/c55/filesys.h @@ -49,7 +49,7 @@ namespace c55fs // Only pass full paths to this one. True on success. bool RecursiveDeleteContent(std::string path); -} //fs +} //fs #endif diff --git a/3rdparty/c55lib/c55/interval_loop.h b/3rdparty/c55lib/c55/interval_loop.h index c277741..f462eff 100644 --- a/3rdparty/c55lib/c55/interval_loop.h +++ b/3rdparty/c55lib/c55/interval_loop.h @@ -2,16 +2,16 @@ // Copyright 2014 Perttu Ahola #pragma once #include -#include // memset() -#include // usleep() -#include "os.h" // get_timeofday_us() +#include // memset() +#include // usleep() +#include "os.h" // get_timeofday_us() #include "log.h" // If f() returns false, loop ends void interval_loop(int interval_us, std::function f) { int64_t t_scheduled_tick_start = get_timeofday_us(); - t_scheduled_tick_start /= interval_us; // Align to round numbers + t_scheduled_tick_start /= interval_us; // Align to round numbers t_scheduled_tick_start *= interval_us; float load_sum = 0; const int load_avg_length = interval_us < 500000 ? 5000000 / interval_us : 1; diff --git a/builtin/client_file/client_file.cpp b/builtin/client_file/client_file.cpp index 55fded7..04cb806 100644 --- a/builtin/client_file/client_file.cpp +++ b/builtin/client_file/client_file.cpp @@ -22,7 +22,7 @@ struct FileInfo { ss_ name; ss_ content; ss_ hash; - ss_ path; // Empty if not a physical file + ss_ path; // Empty if not a physical file FileInfo(const ss_ &name, const ss_ &content, const ss_ &hash, const ss_ &path): name(name), content(content), hash(hash), path(path){} }; diff --git a/builtin/loader/loader.cpp b/builtin/loader/loader.cpp index 77a3843..bbe5e8c 100644 --- a/builtin/loader/loader.cpp +++ b/builtin/loader/loader.cpp @@ -128,13 +128,13 @@ struct ResolveState if(m_promised_modules.count(dep.module)){ log_w(MODULE, "%s: Reverse dependency %s ignored (already " "marked to be loaded)", cs(name), cs(dep.module)); - continue; // Adding the dependency would have no effect + continue; // Adding the dependency would have no effect } // Store dependency information interface::ModuleDependency forward_dep; - forward_dep = dep; // Base dependency on reverted one - forward_dep.module = name; // The other module depends now on this + forward_dep = dep; // Base dependency on reverted one + forward_dep.module = name; // The other module depends now on this // dep.module is the other module which should depeend on this one m_reverse_dependencies[dep.module].push_back(forward_dep); @@ -257,7 +257,7 @@ struct ResolveState set_error("Missing dependencies"); } - return !m_failed; // Make sure to return any leftover failure as false + return !m_failed; // Make sure to return any leftover failure as false } }; @@ -265,7 +265,7 @@ struct Module: public interface::Module, public loader::Interface { interface::Server *m_server; bool m_activated = false; - sv_ m_module_load_paths; // In order of preference + sv_ m_module_load_paths; // In order of preference Module(interface::Server *server): interface::Module("loader"), diff --git a/builtin/network/network.cpp b/builtin/network/network.cpp index fa28f9c..127060f 100644 --- a/builtin/network/network.cpp +++ b/builtin/network/network.cpp @@ -16,7 +16,7 @@ #include #endif #include -#include // strerror() +#include // strerror() using interface::Event; diff --git a/builtin/replicate/replicate.cpp b/builtin/replicate/replicate.cpp index 6c4a9ea..7499d65 100644 --- a/builtin/replicate/replicate.cpp +++ b/builtin/replicate/replicate.cpp @@ -462,7 +462,7 @@ struct Module: public interface::Module, public replicate::Interface sv_ find_peers_that_know_node(uint node_id) { sv_ result; - for(auto &pair: m_scene_states){ + for(auto &pair : m_scene_states){ PeerId peer_id = pair.first; magic::SceneReplicationState &scene_state = pair.second; auto &node_states = scene_state.nodeStates_; diff --git a/builtin/voxelworld/api.h b/builtin/voxelworld/api.h index 0b7c941..265dcc6 100644 --- a/builtin/voxelworld/api.h +++ b/builtin/voxelworld/api.h @@ -27,7 +27,7 @@ namespace voxelworld pv::Vector3DInt16 section_p; GenerationRequest(const pv::Vector3DInt16 §ion_p): - section_p(section_p) + section_p(section_p) {} }; diff --git a/builtin/voxelworld/voxelworld.cpp b/builtin/voxelworld/voxelworld.cpp index 97e4320..a45d800 100644 --- a/builtin/voxelworld/voxelworld.cpp +++ b/builtin/voxelworld/voxelworld.cpp @@ -93,7 +93,7 @@ static inline int container_coord(int x, int d) return (x>=0 ? x : x-d+1) / d; } static inline pv::Vector3DInt32 container_coord( - const pv::Vector3DInt32 &p, const pv::Vector3DInt32 &d) + const pv::Vector3DInt32 &p, const pv::Vector3DInt32 &d) { return pv::Vector3DInt32( container_coord(p.getX(), d.getX()), @@ -101,7 +101,7 @@ static inline pv::Vector3DInt32 container_coord( container_coord(p.getZ(), d.getZ())); } static inline pv::Vector3DInt32 container_coord( - const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d) + const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d) { return pv::Vector3DInt32( container_coord(p.getX(), d.getX()), @@ -109,7 +109,7 @@ static inline pv::Vector3DInt32 container_coord( container_coord(p.getZ(), d.getZ())); } static inline pv::Vector3DInt16 container_coord16( - const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d) + const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d) { return pv::Vector3DInt16( container_coord(p.getX(), d.getX()), @@ -127,9 +127,9 @@ struct ChunkBuffer struct Section { - pv::Vector3DInt16 section_p;// Position in sections + pv::Vector3DInt16 section_p; // Position in sections pv::Vector3DInt16 chunk_size; - pv::Region contained_chunks;// Position and size in chunks + pv::Region contained_chunks; // Position and size in chunks // Static voxel nodes (each contains one chunk); Initialized to 0. sp_> node_ids; size_t num_chunks = 0; @@ -157,8 +157,8 @@ struct Section contained_chunks(contained_chunks), node_ids(new pv::RawVolume(contained_chunks)), num_chunks(contained_chunks.getWidthInVoxels() * - contained_chunks.getHeightInVoxels() * - contained_chunks.getDepthInVoxels()) + contained_chunks.getHeightInVoxels() * + contained_chunks.getDepthInVoxels()) { chunk_buffers.resize(num_chunks); // Cache these for speed @@ -186,7 +186,7 @@ size_t Section::get_chunk_i(const pv::Vector3DInt32 &chunk_p) // global chunk_p size_t i = local_z * h * w + local_y * w + local_x; if(i >= num_chunks) // NOTE: This is not accurate but it is safe and fast throw Exception(ss_()+"get_chunk_i: Section "+cs(section_p)+ - " does not contain chunk"+cs(chunk_p)); + " does not contain chunk"+cs(chunk_p)); return i; } @@ -222,7 +222,8 @@ ChunkBuffer& Section::get_buffer(const pv::Vector3DInt32 &chunk_p, { Node *n = scene->GetNode(node_id); if(!n){ - log_w("voxelworld", "Section::get_buffer(): Node %i not found in scene " + log_w("voxelworld", + "Section::get_buffer(): Node %i not found in scene " "for chunk " PV3I_FORMAT " in section " PV3I_FORMAT, node_id, PV3I_PARAMS(chunk_p), PV3I_PARAMS(section_p)); return; @@ -231,10 +232,11 @@ ChunkBuffer& Section::get_buffer(const pv::Vector3DInt32 &chunk_p, const PODVector &rawbuf = var.GetBuffer(); ss_ data((const char*)&rawbuf[0], rawbuf.Size()); up_> volume = - interface::deserialize_volume(data); + interface::deserialize_volume(data); buf.volume = sp_>(std::move(volume)); if(!buf.volume){ - log_w("voxelworld", "Section::get_buffer(): Voxel volume could not be " + log_w("voxelworld", + "Section::get_buffer(): Voxel volume could not be " "loaded from node %i for chunk " PV3I_FORMAT " in section " PV3I_FORMAT, node_id, PV3I_PARAMS(chunk_p), PV3I_PARAMS(section_p)); @@ -337,7 +339,7 @@ struct Module: public interface::Module, public voxelworld::Interface seg.select_segment = magic::IntVector2(0, 0); } vdef.edge_material_id = interface::EDGEMATERIALID_EMPTY; - m_voxel_reg->add_voxel(vdef); // id 1 + m_voxel_reg->add_voxel(vdef); // id 1 } { interface::VoxelDefinition vdef; @@ -356,7 +358,7 @@ struct Module: public interface::Module, public voxelworld::Interface } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 2 + m_voxel_reg->add_voxel(vdef); // id 2 } { interface::VoxelDefinition vdef; @@ -375,7 +377,7 @@ struct Module: public interface::Module, public voxelworld::Interface } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 3 + m_voxel_reg->add_voxel(vdef); // id 3 } { interface::VoxelDefinition vdef; @@ -394,7 +396,7 @@ struct Module: public interface::Module, public voxelworld::Interface } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 4 + m_voxel_reg->add_voxel(vdef); // id 4 } { interface::VoxelDefinition vdef; @@ -413,7 +415,7 @@ struct Module: public interface::Module, public voxelworld::Interface } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 5 + m_voxel_reg->add_voxel(vdef); // id 5 } } @@ -475,8 +477,8 @@ struct Module: public interface::Module, public voxelworld::Interface // Remove everything managed by us from the scene m_server->access_scene([&](Scene *scene) { - for(auto §or_pair : m_sections){ - for(auto §ion_pair : sector_pair.second){ + for(auto §or_pair: m_sections){ + for(auto §ion_pair: sector_pair.second){ Section §ion = section_pair.second; auto region = section.node_ids->getEnclosingRegion(); @@ -520,7 +522,7 @@ struct Module: public interface::Module, public voxelworld::Interface log_v(MODULE, "on_tick(): Doing %zu lazy node physics updates", m_nodes_needing_physics_update.size()); } - for(QueuedNodePhysicsUpdate &update : m_nodes_needing_physics_update){ + for(QueuedNodePhysicsUpdate &update: m_nodes_needing_physics_update){ uint node_id = update.node_id; sp_> volume = update.volume; Node *n = scene->GetNode(node_id); @@ -586,7 +588,7 @@ struct Module: public interface::Module, public voxelworld::Interface ar((int32_t)event.node_id); } network::access(m_server, [&](network::Interface *inetwork){ - for(auto &peer_id : peers){ + for(auto &peer_id: peers){ inetwork->send(peer_id, "voxelworld:node_voxel_data_updated", os.str()); } @@ -652,11 +654,11 @@ struct Module: public interface::Module, public voxelworld::Interface Vector3 node_p( chunk_p.getX() * m_chunk_size_voxels.getX() + - m_chunk_size_voxels.getX() / 2.0f, + m_chunk_size_voxels.getX() / 2.0f, chunk_p.getY() * m_chunk_size_voxels.getY() + - m_chunk_size_voxels.getY() / 2.0f, + m_chunk_size_voxels.getY() / 2.0f, chunk_p.getZ() * m_chunk_size_voxels.getZ() + - m_chunk_size_voxels.getZ() / 2.0f + m_chunk_size_voxels.getZ() / 2.0f ); log_t(MODULE, "create_chunk_node(): node_p=(%f, %f, %f)", node_p.x_, node_p.y_, node_p.z_); @@ -694,7 +696,7 @@ struct Module: public interface::Module, public voxelworld::Interface ss_ data = interface::serialize_volume_compressed(volume); n->SetVar(StringHash("buildat_voxel_data"), Variant( - PODVector((const uint8_t*)data.c_str(), data.size()))); + PODVector((const uint8_t*)data.c_str(), data.size()))); // There are no collision shapes initially, but add the rigid body now RigidBody *body = n->CreateComponent(LOCAL); @@ -750,8 +752,8 @@ struct Module: public interface::Module, public voxelworld::Interface { QueuedNodePhysicsUpdate update(node_id, volume); auto it = std::lower_bound(m_nodes_needing_physics_update.begin(), - m_nodes_needing_physics_update.end(), update, - std::greater()); + m_nodes_needing_physics_update.end(), update, + std::greater()); if(it == m_nodes_needing_physics_update.end()){ m_nodes_needing_physics_update.insert(it, update); } else if(it->node_id != node_id){ @@ -776,11 +778,11 @@ struct Module: public interface::Module, public voxelworld::Interface { pv::Vector3DInt32 p0 = pv::Vector3DInt32( section_p.getX() * m_section_size_chunks.getX() * - m_chunk_size_voxels.getX(), + m_chunk_size_voxels.getX(), section_p.getY() * m_section_size_chunks.getY() * - m_chunk_size_voxels.getY(), + m_chunk_size_voxels.getY(), section_p.getZ() * m_section_size_chunks.getZ() * - m_chunk_size_voxels.getZ() + m_chunk_size_voxels.getZ() ); pv::Vector3DInt32 p1 = p0 + pv::Vector3DInt32( m_section_size_chunks.getX() * m_chunk_size_voxels.getX() - 1, @@ -830,15 +832,15 @@ struct Module: public interface::Module, public voxelworld::Interface const PODVector &buf = var.GetBuffer(); ss_ data((const char*)&buf[0], buf.Size()); volume = sp_>(std::move( - interface::deserialize_volume(data) - )); + interface::deserialize_volume(data) + )); // NOTE: +1 offset needed for mesh generation pv::Vector3DInt32 voxel_p( - p.getX() - chunk_p.getX() * m_chunk_size_voxels.getX() + 1, - p.getY() - chunk_p.getY() * m_chunk_size_voxels.getY() + 1, - p.getZ() - chunk_p.getZ() * m_chunk_size_voxels.getZ() + 1 - ); + p.getX() - chunk_p.getX() * m_chunk_size_voxels.getX() + 1, + p.getY() - chunk_p.getY() * m_chunk_size_voxels.getY() + 1, + p.getZ() - chunk_p.getZ() * m_chunk_size_voxels.getZ() + 1 + ); log_t(MODULE, "set_voxel_direct() p=" PV3I_FORMAT ", v=%i: " "Chunk " PV3I_FORMAT " in section " PV3I_FORMAT "; internal position " PV3I_FORMAT, @@ -849,8 +851,8 @@ struct Module: public interface::Module, public voxelworld::Interface ss_ new_data = interface::serialize_volume_compressed(*volume); n->SetVar(StringHash("buildat_voxel_data"), Variant( - PODVector((const uint8_t*)new_data.c_str(), - new_data.size()))); + PODVector((const uint8_t*)new_data.c_str(), + new_data.size()))); }); // Mark node for collision box update @@ -862,7 +864,7 @@ struct Module: public interface::Module, public voxelworld::Interface { // Don't log here; this is a too busy place for even ignored log calls /*log_t(MODULE, "set_voxel() p=" PV3I_FORMAT ", v=%i", - PV3I_PARAMS(p), v.data);*/ + PV3I_PARAMS(p), v.data);*/ pv::Vector3DInt32 chunk_p = container_coord(p, m_chunk_size_voxels); pv::Vector3DInt16 section_p = container_coord16(chunk_p, m_section_size_chunks); @@ -901,8 +903,8 @@ struct Module: public interface::Module, public voxelworld::Interface // Set section buffer loaded flag auto it = std::lower_bound(m_sections_with_loaded_buffers.begin(), - m_sections_with_loaded_buffers.end(), section, - std::greater()); // position in descending order + m_sections_with_loaded_buffers.end(), section, + std::greater()); // position in descending order if(it == m_sections_with_loaded_buffers.end() || *it != section) m_sections_with_loaded_buffers.insert(it, section); } @@ -952,15 +954,15 @@ struct Module: public interface::Module, public voxelworld::Interface } n->SetVar(StringHash("buildat_voxel_data"), Variant( - PODVector((const uint8_t*)new_data.c_str(), - new_data.size()))); + PODVector((const uint8_t*)new_data.c_str(), + new_data.size()))); }); // Tell replicate to emit events once it has done its job replicate::access(m_server, [&](replicate::Interface *ireplicate){ ireplicate->emit_after_next_sync(Event( - "voxelworld:node_voxel_data_updated", - new NodeVoxelDataUpdatedEvent(node_id))); + "voxelworld:node_voxel_data_updated", + new NodeVoxelDataUpdatedEvent(node_id))); }); // Mark node for collision box update @@ -1028,8 +1030,8 @@ struct Module: public interface::Module, public voxelworld::Interface // Set section buffer loaded flag auto it = std::lower_bound(m_sections_with_loaded_buffers.begin(), - m_sections_with_loaded_buffers.end(), section, - std::greater()); // position in descending order + m_sections_with_loaded_buffers.end(), section, + std::greater()); // position in descending order if(it == m_sections_with_loaded_buffers.end() || *it != section) m_sections_with_loaded_buffers.insert(it, section); diff --git a/games/digger/main/main.cpp b/games/digger/main/main.cpp index 1bd096c..7729c2e 100644 --- a/games/digger/main/main.cpp +++ b/games/digger/main/main.cpp @@ -118,14 +118,15 @@ struct Module: public interface::Module voxelworld::access(m_server, [&](voxelworld::Interface *ivoxelworld) { - interface::VoxelRegistry *voxel_reg = ivoxelworld->get_voxel_reg(); + interface::VoxelRegistry *voxel_reg = + ivoxelworld->get_voxel_reg(); Node *n = scene->CreateChild("Testbox"); n->SetPosition(Vector3(30.0f, 30.0f, 40.0f)); n->SetScale(Vector3(1.0f, 1.0f, 1.0f)); - /*int w = 1, h = 1, d = 1; - ss_ data = "1";*/ + /*int w = 1, h = 1, d = 1; + ss_ data = "1";*/ int w = 2, h = 2, d = 1; ss_ data = "1333"; @@ -136,8 +137,8 @@ struct Module: public interface::Module } n->SetVar(StringHash("simple_voxel_data"), Variant( - PODVector((const uint8_t*)data.c_str(), - data.size()))); + PODVector((const uint8_t*)data.c_str(), + data.size()))); n->SetVar(StringHash("simple_voxel_w"), Variant(w)); n->SetVar(StringHash("simple_voxel_h"), Variant(h)); n->SetVar(StringHash("simple_voxel_d"), Variant(d)); @@ -152,7 +153,8 @@ struct Module: public interface::Module RigidBody *body = n->CreateComponent(LOCAL); body->SetFriction(0.75f); body->SetMass(1.0); - CollisionShape *shape = n->CreateComponent(LOCAL); + CollisionShape *shape = + n->CreateComponent(LOCAL); shape->SetConvexHull(model, 0, Vector3::ONE); //shape->SetTriangleMesh(model, 0, Vector3::ONE); //shape->SetBox(Vector3::ONE); @@ -171,9 +173,9 @@ struct Module: public interface::Module void on_tick(const interface::TickEvent &event) { /*m_server->access_scene([&](Scene *scene){ - Node *n = scene->GetChild("Testbox"); - auto p = n->GetPosition(); - log_v(MODULE, "Testbox: (%f, %f, %f)", p.x_, p.y_, p.z_); + Node *n = scene->GetChild("Testbox"); + auto p = n->GetPosition(); + log_v(MODULE, "Testbox: (%f, %f, %f)", p.x_, p.y_, p.z_); });*/ static uint a = 0; if(((a++) % 100) == 0){ @@ -201,7 +203,8 @@ struct Module: public interface::Module voxelworld::access(m_server, [&](voxelworld::Interface *ivoxelworld) { const pv::Vector3DInt16 §ion_p = event.section_p; - pv::Region region = ivoxelworld->get_section_region_voxels(section_p); + pv::Region region = ivoxelworld->get_section_region_voxels( + section_p); pv::Vector3DInt32 p0 = region.getLowerCorner(); pv::Vector3DInt32 p1 = region.getUpperCorner(); @@ -211,7 +214,7 @@ struct Module: public interface::Module log_t(MODULE, "on_generation_request(): p1: (%i, %i, %i)", p1.getX(), p1.getY(), p1.getZ()); - interface::NoiseParams np(0, 35, interface::v3f(160,160,160), + interface::NoiseParams np(0, 35, interface::v3f(160, 160, 160), 1, 6, 0.475); auto lc = region.getLowerCorner(); @@ -253,27 +256,27 @@ struct Module: public interface::Module } // Add random trees - auto extent = uc - lc + pv::Vector3DInt32(1,1,1); + auto extent = uc - lc + pv::Vector3DInt32(1, 1, 1); int area = extent.getX() * extent.getZ(); auto pr = interface::PseudoRandom(13241); for(int i = 0; i < area / 100; i++){ int x = pr.range(lc.getX(), uc.getX()); int z = pr.range(lc.getZ(), uc.getZ()); - /*int y = 50; - for(; y>-50; y--){ - pv::Vector3DInt32 p(x, y, z); - VoxelInstance v = ivoxelworld->get_voxel(p); - if(v.getId() != 1) - break; - } - y++;*/ + /*int y = 50; + for(; y>-50; y--){ + pv::Vector3DInt32 p(x, y, z); + VoxelInstance v = ivoxelworld->get_voxel(p); + if(v.getId() != 1) + break; + } + y++;*/ double a = interface::NoisePerlin2D(&np, x, z, 0); int y = a + 11.0; if(y < lc.getY() - 5 || y > uc.getY() - 5) continue; - for(int y1=y; y1set_voxel(p, VoxelInstance(3), true); } diff --git a/games/entitytest/main/main.cpp b/games/entitytest/main/main.cpp index 37978af..c4103a6 100644 --- a/games/entitytest/main/main.cpp +++ b/games/entitytest/main/main.cpp @@ -73,13 +73,13 @@ struct Module: public interface::Module // NOTE: Modified or created materials will not be replicated to the // client. Make sure to always have a resource file or create // the material on the client. - /*m->SetTexture(TU_DIFFUSE, - cache->GetResource("main/green_texture.png"));*/ - /*Material *m = new Material(context); - m->SetTexture(TU_DIFFUSE, - cache->GetResource("main/green_texture.png")); - m->SetTechnique(0, cache->GetResource( - "Techniques/Diff.xml"));*/ + /*m->SetTexture(TU_DIFFUSE, + cache->GetResource("main/green_texture.png"));*/ + /*Material *m = new Material(context); + m->SetTexture(TU_DIFFUSE, + cache->GetResource("main/green_texture.png")); + m->SetTechnique(0, cache->GetResource( + "Techniques/Diff.xml"));*/ { Node *node = scene->CreateChild("DirectionalLight"); diff --git a/games/geometry/main/main.cpp b/games/geometry/main/main.cpp index 4f72b0f..b6ba78d 100644 --- a/games/geometry/main/main.cpp +++ b/games/geometry/main/main.cpp @@ -77,8 +77,8 @@ struct Module: public interface::Module n->SetPosition(Vector3(0.0f, 6.0f, 0.0f)); n->SetScale(Vector3(1.0f, 1.0f, 1.0f)); - /*int w = 1, h = 1, d = 1; - ss_ data = "1";*/ + /*int w = 1, h = 1, d = 1; + ss_ data = "1";*/ int w = 2, h = 2, d = 1; ss_ data = "0111"; diff --git a/games/geometry2/main/main.cpp b/games/geometry2/main/main.cpp index c935bbf..bb96b2d 100644 --- a/games/geometry2/main/main.cpp +++ b/games/geometry2/main/main.cpp @@ -71,7 +71,7 @@ struct Module: public interface::Module seg.select_segment = magic::IntVector2(0, 0); } vdef.edge_material_id = interface::EDGEMATERIALID_EMPTY; - m_voxel_reg->add_voxel(vdef); // id 1 + m_voxel_reg->add_voxel(vdef); // id 1 } { interface::VoxelDefinition vdef; @@ -90,7 +90,7 @@ struct Module: public interface::Module } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 2 + m_voxel_reg->add_voxel(vdef); // id 2 } { interface::VoxelDefinition vdef; @@ -109,7 +109,7 @@ struct Module: public interface::Module } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 3 + m_voxel_reg->add_voxel(vdef); // id 3 } }); } @@ -145,8 +145,8 @@ struct Module: public interface::Module n->SetPosition(Vector3(0.0f, 6.0f, 0.0f)); n->SetScale(Vector3(1.0f, 1.0f, 1.0f)); - /*int w = 1, h = 1, d = 1; - ss_ data = "1";*/ + /*int w = 1, h = 1, d = 1; + ss_ data = "1";*/ int w = 2, h = 2, d = 1; ss_ data = "1333"; diff --git a/games/test/test1/test1.cpp b/games/test/test1/test1.cpp index 4a26259..405aa5e 100644 --- a/games/test/test1/test1.cpp +++ b/games/test/test1/test1.cpp @@ -16,7 +16,7 @@ struct Module: public interface::Module { interface::Server *m_server; - Event::Type m_EventType_test1_thing;// You can cache these for more speed + Event::Type m_EventType_test1_thing; // You can cache these for more speed Module(interface::Server *server): interface::Module("test1"), diff --git a/games/test/test2/test2.cpp b/games/test/test2/test2.cpp index 7cad4c3..5362348 100644 --- a/games/test/test2/test2.cpp +++ b/games/test/test2/test2.cpp @@ -43,22 +43,22 @@ struct Module: public interface::Module { log_i(MODULE, "test2 start(): Calling test1"); - { // Raw + { // Raw Event::Type type = Event::t("test1:thing"); Event event(type, up_(new test1::Thing("Nakki"))); m_server->emit_event(std::move(event)); } - { // Simplified raw + { // Simplified raw Event event("test1:thing", new test1::Thing("Kebab")); m_server->emit_event(std::move(event)); } - { // Even simpler + { // Even simpler m_server->emit_event("test1:thing", new test1::Thing("Pitsa")); } - { // Inline wrapper + { // Inline wrapper test1::do_thing(m_server, "Rulla"); } } diff --git a/src/client/app.cpp b/src/client/app.cpp index c222ce0..2b658b6 100644 --- a/src/client/app.cpp +++ b/src/client/app.cpp @@ -19,8 +19,8 @@ #include #include #include -#include // E_SCREENMODE -#include // E_LOGMESSAGE +#include // E_SCREENMODE +#include // E_LOGMESSAGE #include #include #include @@ -121,7 +121,7 @@ struct CApp: public App, public magic::Application sv_ resource_paths = { g_client_config.cache_path+"/tmp", - g_client_config.share_path+"/extensions", // Could be unsafe + g_client_config.share_path+"/extensions", // Could be unsafe g_client_config.urho3d_path+"/Bin/CoreData", g_client_config.urho3d_path+"/Bin/Data", }; @@ -150,7 +150,7 @@ struct CApp: public App, public magic::Application engineParameters_["ResourcePaths"] = resource_paths_s.c_str(); engineParameters_["AutoloadPaths"] = ""; engineParameters_["LogName"] = ""; - engineParameters_["LogQuiet"] = true; // Don't log to stdout + engineParameters_["LogQuiet"] = true; // Don't log to stdout // Graphics options engineParameters_["FullScreen"] = m_options.graphics.fullscreen; @@ -210,7 +210,7 @@ struct CApp: public App, public magic::Application seg.select_segment = magic::IntVector2(0, 0); } vdef.edge_material_id = interface::EDGEMATERIALID_EMPTY; - m_voxel_reg->add_voxel(vdef); // id 1 + m_voxel_reg->add_voxel(vdef); // id 1 } { interface::VoxelDefinition vdef; @@ -229,7 +229,7 @@ struct CApp: public App, public magic::Application } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 2 + m_voxel_reg->add_voxel(vdef); // id 2 } { interface::VoxelDefinition vdef; @@ -248,7 +248,7 @@ struct CApp: public App, public magic::Application } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 3 + m_voxel_reg->add_voxel(vdef); // id 3 } { interface::VoxelDefinition vdef; @@ -267,7 +267,7 @@ struct CApp: public App, public magic::Application } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 4 + m_voxel_reg->add_voxel(vdef); // id 4 } { interface::VoxelDefinition vdef; @@ -286,7 +286,7 @@ struct CApp: public App, public magic::Application } vdef.edge_material_id = interface::EDGEMATERIALID_GROUND; vdef.physically_solid = true; - m_voxel_reg->add_voxel(vdef); // id 5 + m_voxel_reg->add_voxel(vdef); // id 5 } } @@ -515,7 +515,7 @@ struct CApp: public App, public magic::Application void on_update(magic::StringHash event_type, magic::VariantMap &event_data) { /*magic::AutoProfileBlock profiler_block( - GetSubsystem(), "App::on_update");*/ + GetSubsystem(), "App::on_update");*/ m_atlas_reg->update(); diff --git a/src/client/app.h b/src/client/app.h index 4d465ef..b6d7a0a 100644 --- a/src/client/app.h +++ b/src/client/app.h @@ -36,7 +36,7 @@ namespace app bool resizable = true; bool vsync = true; bool triple_buffer = false; - int multisampling = 1; // 2 looks much better but is much heavier(?) + int multisampling = 1; // 2 looks much better but is much heavier(?) int window_x = UNDEFINED_INT; int window_y = UNDEFINED_INT; diff --git a/src/client/main.cpp b/src/client/main.cpp index a2a1c83..a4a4038 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -20,7 +20,7 @@ bool g_sigint_received = false; void sigint_handler(int sig) { if(!g_sigint_received){ - fprintf(stdout, "\n"); // Newline after "^C" + fprintf(stdout, "\n"); // Newline after "^C" log_i("process", "SIGINT"); g_sigint_received = true; } else { diff --git a/src/client/state.cpp b/src/client/state.cpp index a070751..d22a6e2 100644 --- a/src/client/state.cpp +++ b/src/client/state.cpp @@ -60,8 +60,8 @@ struct CState: public State sp_ m_app; ss_ m_remote_cache_path; ss_ m_tmp_path; - sm_ m_file_hashes;// name -> hash - set_ m_waiting_files; // name + sm_ m_file_hashes; // name -> hash + set_ m_waiting_files; // name bool m_tell_after_all_files_transferred_requested = false; // Connecting is possible only once. After that has happened, the whole // state has to be recreated for making a new connection. diff --git a/src/core/json.cpp b/src/core/json.cpp index 08e9b3c..a018ec1 100644 --- a/src/core/json.cpp +++ b/src/core/json.cpp @@ -8,9 +8,9 @@ #include #include #include -#include // PRId64 -#include // isnan/isinf -#include // DBL_MAX/DBL_MIN +#include // PRId64 +#include // isnan/isinf +#include // DBL_MAX/DBL_MIN #include "sajson.h" using namespace json; diff --git a/src/core/json.h b/src/core/json.h index 6851ca8..4ae59d6 100644 --- a/src/core/json.h +++ b/src/core/json.h @@ -203,6 +203,6 @@ namespace json }; } -#define JSON_INDENT(x) // Dummy for now +#define JSON_INDENT(x) // Dummy for now // vim: set noet ts=4 sw=4: diff --git a/src/core/log.cpp b/src/core/log.cpp index 717522d..8892c96 100644 --- a/src/core/log.cpp +++ b/src/core/log.cpp @@ -103,21 +103,21 @@ static void print(int level, const char *sys, const char *fmt, va_list va_args) if(use_colors && !file && (level != current_level || line_begin) && level <= max_level){ if(level == LOG_FATAL) - fprintf(stderr, "\033[0m\033[0;1;41m"); // reset, bright red bg + fprintf(stderr, "\033[0m\033[0;1;41m"); // reset, bright red bg else if(level == LOG_ERROR) - fprintf(stderr, "\033[0m\033[1;31m"); // bright red fg, black bg + fprintf(stderr, "\033[0m\033[1;31m"); // bright red fg, black bg else if(level == LOG_WARNING) - fprintf(stderr, "\033[0m\033[1;33m"); // bright yellow fg, black bg + fprintf(stderr, "\033[0m\033[1;33m"); // bright yellow fg, black bg else if(level == LOG_INFO) - fprintf(stderr, "\033[0m"); // reset + fprintf(stderr, "\033[0m"); // reset else if(level == LOG_VERBOSE) - fprintf(stderr, "\033[0m\033[0;36m"); // cyan fg, black bg + fprintf(stderr, "\033[0m\033[0;36m"); // cyan fg, black bg else if(level == LOG_DEBUG) - fprintf(stderr, "\033[0m\033[1;30m"); // bright black fg, black bg + fprintf(stderr, "\033[0m\033[1;30m"); // bright black fg, black bg else if(level == LOG_TRACE) - fprintf(stderr, "\033[0m\033[0;35m"); // + fprintf(stderr, "\033[0m\033[0;35m"); // else - fprintf(stderr, "\033[0m"); // reset + fprintf(stderr, "\033[0m"); // reset } current_level = level; if(level > max_level) diff --git a/src/core/sajson.h b/src/core/sajson.h index 945756c..c7fdb44 100644 --- a/src/core/sajson.h +++ b/src/core/sajson.h @@ -34,7 +34,7 @@ #include #include -#include // for error messages. kill someday? +#include // for error messages. kill someday? #if defined(__GNUC__) || defined(__clang__) #define SAJSON_LIKELY(x) __builtin_expect(!!(x), 1) @@ -123,7 +123,7 @@ namespace sajson { const char*const text; const size_t _length; - string(); /*=delete*/ + string(); /*=delete*/ }; class literal: public string { @@ -893,7 +893,7 @@ done: int i = 0; double d = - 0.0;// gcc complains that d might be used uninitialized which isn't true. appease the warning anyway. + 0.0; // gcc complains that d might be used uninitialized which isn't true. appease the warning anyway. for(;;){ char c = *p; if(c < '0' || c > '9'){ @@ -1067,7 +1067,7 @@ done: tag = out; } - ++p;// " + ++p; // " size_t start = p - input.get_data(); for(;;){ if(SAJSON_UNLIKELY(p >= input_end)){ @@ -1113,7 +1113,7 @@ done: } u = v; - return TYPE_NULL; // ??? + return TYPE_NULL; // ??? } void write_utf8(unsigned codepoint, char* &end){ @@ -1196,7 +1196,7 @@ replace: return error("unexpected end of input h"); } unsigned u = - 0; // gcc's complaining that this could be used uninitialized. wrong. + 0; // gcc's complaining that this could be used uninitialized. wrong. parse_result result = read_hex(u); if(!result){ return result; @@ -1213,7 +1213,7 @@ replace: } p += 2; unsigned v = - 0; // gcc's complaining that this could be used uninitialized. wrong. + 0; // gcc's complaining that this could be used uninitialized. wrong. result = read_hex(v); if(!result){ return result; diff --git a/src/core/types.h b/src/core/types.h index 5ab6b92..9732c46 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -7,10 +7,10 @@ #include #include #include -#include // PRId64 +#include // PRId64 #include #include -#include // snprintf +#include // snprintf typedef unsigned int uint; typedef unsigned char uchar; diff --git a/src/impl/atlas.cpp b/src/impl/atlas.cpp index 87f476b..a1d6cc3 100644 --- a/src/impl/atlas.cpp +++ b/src/impl/atlas.cpp @@ -30,7 +30,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry CTextureAtlasRegistry(magic::Context *context): m_context(context) { - m_defs.resize(1); // id=0 is ATLAS_UNDEFINED + m_defs.resize(1); // id=0 is ATLAS_UNDEFINED } const AtlasSegmentReference add_segment( @@ -55,7 +55,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry if(def0.segment_resolution == seg_img_size){ size_t max = def0.total_segments.x_ * def0.total_segments.y_; if(def0.segments.size() >= max) - continue; // Full + continue; // Full atlas_def = &def0; break; } diff --git a/src/impl/block.cpp b/src/impl/block.cpp index 8affcea..380ff42 100644 --- a/src/impl/block.cpp +++ b/src/impl/block.cpp @@ -86,7 +86,7 @@ struct CBlockRegistry: public BlockRegistry CBlockRegistry(VoxelRegistry *voxel_reg): m_voxel_reg(voxel_reg) { - m_defs.resize(1); // Id 0 is BLOCKTYPEID_UNDEFINEDD + m_defs.resize(1); // Id 0 is BLOCKTYPEID_UNDEFINEDD } BlockTypeId add_block_with_predefined_segments(const BlockDefinition &def) diff --git a/src/impl/compress.cpp b/src/impl/compress.cpp index 6d881e6..ab00db8 100644 --- a/src/impl/compress.cpp +++ b/src/impl/compress.cpp @@ -13,11 +13,11 @@ namespace interface { ss_ zerr(int ret) { - switch (ret) { + switch(ret){ case Z_ERRNO: - if (ferror(stdin)) + if(ferror(stdin)) return "error reading stdin"; - if (ferror(stdout)) + if(ferror(stdout)) return "error writing stdout"; return "errno"; case Z_STREAM_ERROR: @@ -48,7 +48,7 @@ void compress_zlib(const ss_ &data_in, std::ostream &os, int level) ret = deflateInit(&z, level); if(ret != Z_OK) throw Exception("compress_zlib: deflateInit failed"); - + // Point zlib to our input buffer z.next_in = (Bytef*)data_in.c_str(); z.avail_in = data_in.size(); @@ -57,7 +57,7 @@ void compress_zlib(const ss_ &data_in, std::ostream &os, int level) { z.next_out = (Bytef*)output_buffer; z.avail_out = bufsize; - + status = deflate(&z, Z_FINISH); if(status == Z_NEED_DICT || status == Z_DATA_ERROR || status == Z_MEM_ERROR) @@ -94,9 +94,9 @@ void decompress_zlib(std::istream &is, std::ostream &os) ret = inflateInit(&z); if(ret != Z_OK) throw Exception("dcompress_zlib: inflateInit failed"); - + z.avail_in = 0; - + //dstream<<"initial fail="< #include #include -#include // Resource parameter of StaticModel +#include // Resource parameter of StaticModel #include #include #include -#include // A Drawable similarly as StaticModel +#include // A Drawable similarly as StaticModel #include #include #include #include -#include // Allows cast to Texture +#include // Allows cast to Texture #include #include #pragma GCC diagnostic pop @@ -70,7 +70,7 @@ Model* create_simple_voxel_model(Context *context, const size_t num_indices = pv_indices.size(); sv_ vertex_data; - vertex_data.resize(num_vertices * 6); // vertex + normal + vertex_data.resize(num_vertices * 6); // vertex + normal for(size_t i = 0; i < num_vertices; i++){ vertex_data[i*6 + 0] = pv_vertices[i].position.getX() - w/2.0f - 0.5f; vertex_data[i*6 + 1] = pv_vertices[i].position.getY() - h/2.0f - 0.5f; @@ -183,7 +183,7 @@ public: IsQuadNeededByRegistryPhysics(interface::VoxelRegistry *voxel_reg): m_voxel_reg(voxel_reg) {} - IsQuadNeededByRegistryPhysics():// PolyVox wants this + IsQuadNeededByRegistryPhysics(): // PolyVox wants this m_voxel_reg(nullptr) {} bool operator()(VoxelType back, VoxelType front, uint32_t &materialToUse) @@ -197,7 +197,7 @@ public: if(!back_def || !back_def->physically_solid) return false; if(!front_def || !front_def->physically_solid){ - materialToUse = 1; // Doesn't matter + materialToUse = 1; // Doesn't matter return true; } return false; @@ -215,7 +215,7 @@ Model* create_voxel_physics_model(Context *context, IsQuadNeededByRegistryPhysics iqn(voxel_reg); pv::SurfaceMesh pv_mesh; pv::CubicSurfaceExtractorWithNormals, - IsQuadNeededByRegistryPhysics> + IsQuadNeededByRegistryPhysics> surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn); surfaceExtractor.execute(); @@ -232,7 +232,7 @@ Model* create_voxel_physics_model(Context *context, int h = volume.getHeight() - 2; int d = volume.getDepth() - 2; sv_ vertex_data; - vertex_data.resize(num_vertices * 6); // vertex + normal + vertex_data.resize(num_vertices * 6); // vertex + normal for(size_t i = 0; i < num_vertices; i++){ vertex_data[i*6 + 0] = pv_vertices[i].position.getX() - w/2.0f - 1.0f; vertex_data[i*6 + 1] = pv_vertices[i].position.getY() - h/2.0f - 1.0f; @@ -290,7 +290,7 @@ public: interface::TextureAtlasRegistry *atlas_reg): m_voxel_reg(voxel_reg), m_atlas_reg(atlas_reg) {} - IsQuadNeededByRegistry(): // PolyVox wants this + IsQuadNeededByRegistry(): // PolyVox wants this m_voxel_reg(nullptr), m_atlas_reg(nullptr) {} @@ -331,8 +331,8 @@ public: struct TemporaryGeometry { uint atlas_id = 0; - sv_ vertex_data; // vertex(3) + normal(3) + texcoord(2) - sv_ index_data; // Urho3D eats unsigned as large indices + sv_ vertex_data; // vertex(3) + normal(3) + texcoord(2) + sv_ index_data; // Urho3D eats unsigned as large indices }; #else struct TemporaryGeometry @@ -430,7 +430,7 @@ void set_voxel_geometry(CustomGeometry *cg, Context *context, IsQuadNeededByRegistry iqn(voxel_reg, atlas_reg); pv::SurfaceMesh pv_mesh; pv::CubicSurfaceExtractorWithNormals, - IsQuadNeededByRegistry> + IsQuadNeededByRegistry> surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn); surfaceExtractor.execute(); @@ -601,8 +601,8 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context, auto &lc_orig = region_orig.getLowerCorner(); auto &uc_orig = region_orig.getUpperCorner(); - pv::Region region(lc_orig / lod - pv::Vector3DInt32(1,1,1), - uc_orig / lod + pv::Vector3DInt32(1,1,1)); + pv::Region region(lc_orig / lod - pv::Vector3DInt32(1, 1, 1), + uc_orig / lod + pv::Vector3DInt32(1, 1, 1)); auto &lc = region.getLowerCorner(); auto &uc = region.getUpperCorner(); @@ -632,7 +632,7 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context, } } /*const interface::CachedVoxelDefinition *def = - voxel_reg->get_cached(v_orig);*/ + voxel_reg->get_cached(v_orig);*/ volume.setVoxelAt(x, y, z, v_orig); } } @@ -641,7 +641,7 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context, IsQuadNeededByRegistry iqn(voxel_reg, atlas_reg); pv::SurfaceMesh pv_mesh; pv::CubicSurfaceExtractorWithNormals, - IsQuadNeededByRegistry> + IsQuadNeededByRegistry> surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn); surfaceExtractor.execute(); @@ -901,15 +901,15 @@ z_plane_does_not_fit: else shape = node->CreateComponent(LOCAL); shape->SetBox(Vector3( - x1 - x0 + 1, - y1 - y0 + 1, - z1 - z0 + 1 - )); + x1 - x0 + 1, + y1 - y0 + 1, + z1 - z0 + 1 + )); shape->SetPosition(Vector3( - (x0 + x1)/2.0f - w/2 - 1.0f, - (y0 + y1)/2.0f - h/2 - 1.0f, - (z0 + z1)/2.0f - d/2 - 1.0f - )); + (x0 + x1)/2.0f - w/2 - 1.0f, + (y0 + y1)/2.0f - h/2 - 1.0f, + (z0 + z1)/2.0f - d/2 - 1.0f + )); } } @@ -925,5 +925,5 @@ z_plane_does_not_fit: } } -} // namespace interface +} // namespace interface // vim: set noet ts=4 sw=4: diff --git a/src/impl/tcpsocket.cpp b/src/impl/tcpsocket.cpp index fa5490a..87785ee 100644 --- a/src/impl/tcpsocket.cpp +++ b/src/impl/tcpsocket.cpp @@ -15,7 +15,7 @@ #define closesocket close //typedef int socket_t; #endif -#include // strerror() +#include // strerror() #include #include @@ -120,7 +120,7 @@ struct CTCPSocket: public TCPSocket hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if(address == "any") - hints.ai_flags = AI_PASSIVE;// Wildcard address + hints.ai_flags = AI_PASSIVE; // Wildcard address const char *address_c = (address == "any" ? NULL : address.c_str()); const char *port_c = (port == "any" ? NULL : port.c_str()); int err = getaddrinfo(address_c, port_c, &hints, &res0); @@ -194,7 +194,7 @@ struct CTCPSocket: public TCPSocket hints.ai_family = AF_INET6; } if(address1 == "any"){ - hints.ai_flags = AI_PASSIVE;// Wildcard address + hints.ai_flags = AI_PASSIVE; // Wildcard address } const char *address_c = (address1 == "any" ? NULL : address1.c_str()); const char *port_c = (port == "any" ? NULL : port.c_str()); diff --git a/src/impl/voxel.cpp b/src/impl/voxel.cpp index 8584fe0..89cf4f6 100644 --- a/src/impl/voxel.cpp +++ b/src/impl/voxel.cpp @@ -51,7 +51,7 @@ struct CVoxelRegistry: public VoxelRegistry CVoxelRegistry() { - m_defs.resize(1); // Id 0 is VOXELTYPEID_UNDEFINEDD + m_defs.resize(1); // Id 0 is VOXELTYPEID_UNDEFINEDD } VoxelTypeId add_voxel(const VoxelDefinition &def) @@ -136,7 +136,7 @@ struct CVoxelRegistry: public VoxelRegistry for(size_t i = 0; i<6; i++){ const AtlasSegmentDefinition &seg_def = def.textures[i]; if(seg_def.resource_name == ""){ - AtlasSegmentReference seg_ref; // Use default values + AtlasSegmentReference seg_ref; // Use default values cache.textures[i] = seg_ref; for(size_t j = 0; j < VOXELDEF_NUM_LOD; j++){ cache.lod_textures[j][i] = seg_ref; @@ -155,11 +155,11 @@ struct CVoxelRegistry: public VoxelRegistry lod_seg_def.lod_simulation |= interface::ATLAS_LOD_TOP_FACE; } - if(i == 5/*Z-*/){ + if(i == 5 /*Z-*/){ lod_seg_def.lod_simulation |= interface::ATLAS_LOD_SEMIBRIGHT1_FACE; } - if(i == 2/*X+*/){ + if(i == 2 /*X+*/){ lod_seg_def.lod_simulation |= interface::ATLAS_LOD_SEMIBRIGHT2_FACE; } diff --git a/src/impl/voxel_volume.cpp b/src/impl/voxel_volume.cpp index 4317d9f..a9ab796 100644 --- a/src/impl/voxel_volume.cpp +++ b/src/impl/voxel_volume.cpp @@ -21,13 +21,13 @@ ss_ serialize_volume_simple(const pv::RawVolume &volume) auto region = volume.getEnclosingRegion(); auto lc = region.getLowerCorner(); auto uc = region.getUpperCorner(); - for(size_t i=0; i &volume) { @@ -44,7 +44,7 @@ ss_ serialize_volume_compressed(const pv::RawVolume &volume) auto region = volume.getEnclosingRegion(); auto lc = region.getLowerCorner(); auto uc = region.getUpperCorner(); - for(size_t i=0; i &volume) ar(compressed_os.str()); } return os.str(); -}; +} up_> deserialize_volume(const ss_ &data) { @@ -71,7 +71,7 @@ up_> deserialize_volume(const ss_ &data) pv::Region region(0, 0, 0, w-1, h-1, d-1); up_> volume( new pv::RawVolume(region)); - for(size_t i=0; im_dataSize; i++){ + for(size_t i = 0; im_dataSize; i++){ uint32_t v; ar(v); volume->m_pData[i].data = v; @@ -94,7 +94,7 @@ up_> deserialize_volume(const ss_ &data) { std::istringstream raw_is(raw_os.str(), std::ios::binary); cereal::PortableBinaryInputArchive ar(raw_is); - for(size_t i=0; im_dataSize; i++){ + for(size_t i = 0; im_dataSize; i++){ uint32_t v; ar(v); volume->m_pData[i].data = v; @@ -102,7 +102,7 @@ up_> deserialize_volume(const ss_ &data) } return volume; } - return up_>();; + return up_>(); } } diff --git a/src/interface/atlas.h b/src/interface/atlas.h index b8af7c0..090639e 100644 --- a/src/interface/atlas.h +++ b/src/interface/atlas.h @@ -20,7 +20,7 @@ namespace interface struct AtlasSegmentReference { - uint atlas_id = ATLAS_UNDEFINED;// 0 = undefined atlas + uint atlas_id = ATLAS_UNDEFINED; // 0 = undefined atlas uint segment_id = 0; }; @@ -34,7 +34,7 @@ namespace interface struct AtlasSegmentDefinition { - ss_ resource_name; // If "", segment won't be added + ss_ resource_name; // If "", segment won't be added magic::IntVector2 total_segments; magic::IntVector2 select_segment; // Mask 0x0f: LOD level, mask 0xf0: flags diff --git a/src/interface/block.h b/src/interface/block.h index b1653d9..3574b66 100644 --- a/src/interface/block.h +++ b/src/interface/block.h @@ -17,19 +17,19 @@ namespace interface { BlockName name; BlockTypeId id = BLOCKTYPEID_UNDEFINED; - uint8_t num_rotations = 0; // Supported: 0, 4, 24 - pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0);// Size in voxels - sv_ segments; // Rotations*voxels + uint8_t num_rotations = 0; // Supported: 0, 4, 24 + pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0); // Size in voxels + sv_ segments; // Rotations*voxels }; // Voxels and a BlockDefinition can be generated based on this struct BlockSourceDefinition { BlockName name; - uint8_t num_rotations = 0; // Supported: 0, 4, 24 - pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0);// Size in voxels + uint8_t num_rotations = 0; // Supported: 0, 4, 24 + pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0); // Size in voxels // Definitions for creating voxels - sv_ side_textures; // 6 resource names + sv_ side_textures; // 6 resource names ss_ handler_module; }; diff --git a/src/interface/compress.h b/src/interface/compress.h index 8635556..cac0bae 100644 --- a/src/interface/compress.h +++ b/src/interface/compress.h @@ -5,7 +5,7 @@ namespace interface { - void compress_zlib(const ss_ &data_in, std::ostream &os, int level=6); + void compress_zlib(const ss_ &data_in, std::ostream &os, int level = 6); void decompress_zlib(std::istream &is, std::ostream &os); } // vim: set noet ts=4 sw=4: diff --git a/src/interface/event.h b/src/interface/event.h index e2113c6..f8e9baf 100644 --- a/src/interface/event.h +++ b/src/interface/event.h @@ -50,7 +50,7 @@ namespace interface type(t(name)), p(up_(p)) {} - static Type t(const ss_ &name); // Shorthand function + static Type t(const ss_ &name); // Shorthand function }; struct EventRegistry diff --git a/src/interface/voxel.h b/src/interface/voxel.h index f706983..09c8160 100644 --- a/src/interface/voxel.h +++ b/src/interface/voxel.h @@ -15,12 +15,12 @@ namespace interface struct VoxelName { - ss_ block_name; // Name of the block this was instanced from - uint segment_x = 0; // Which segment of the block this was instanced from + ss_ block_name; // Name of the block this was instanced from + uint segment_x = 0; // Which segment of the block this was instanced from uint segment_y = 0; uint segment_z = 0; - uint rotation_primary = 0; // 4 possible rotations when looking at a face - uint rotation_secondary = 0;// 6 possible directions for a face to point to + uint rotation_primary = 0; // 4 possible rotations when looking at a face + uint rotation_secondary = 0; // 6 possible directions for a face to point to ss_ dump() const; bool operator==(const VoxelName &other) const; @@ -104,8 +104,8 @@ namespace interface // Create voxel from raw data (MSBs are preserved) VoxelInstance(uint32_t id): data(id){} - VoxelTypeId getId() const { return data & 0x001fffff; } - uint8_t getMSB() const { return (data>>24) & 0xff; } + VoxelTypeId getId() const {return data & 0x001fffff; } + uint8_t getMSB() const {return (data>>24) & 0xff; } }; } // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/cereal.cpp b/src/lua_bindings/cereal.cpp index 36b7cd8..fbfd2e2 100644 --- a/src/lua_bindings/cereal.cpp +++ b/src/lua_bindings/cereal.cpp @@ -90,7 +90,7 @@ static void binary_input_read_value(lua_State *L, int type_L, binary_input_read_value(L, array_type_L, ar); lua_rawseti(L, value_result_table_L, i + 1); } - lua_pop(L, 1); // array_type_L + lua_pop(L, 1); // array_type_L // value_result_table_L is left on stack } else if(outfield_type == "unordered_map"){ if(!has_table) @@ -110,8 +110,8 @@ static void binary_input_read_value(lua_State *L, int type_L, binary_input_read_value(L, map_value_type_L, ar); lua_rawset(L, value_result_table_L); } - lua_pop(L, 1); // map_value_type_L - lua_pop(L, 1); // map_key_type_L + lua_pop(L, 1); // map_value_type_L + lua_pop(L, 1); // map_key_type_L // value_result_table_L is left on stack } else if(outfield_type == "object"){ if(!has_table) @@ -125,14 +125,14 @@ static void binary_input_read_value(lua_State *L, int type_L, if(field_i != 0){ log_t(MODULE, "object field %zu", field_i); int field_def_L = lua_gettop(L); - lua_rawgeti(L, field_def_L, 1); // name - lua_rawgeti(L, field_def_L, 2); // type + lua_rawgeti(L, field_def_L, 1); // name + lua_rawgeti(L, field_def_L, 2); // type log_t(MODULE, " = object[\"%s\"]", lua_tostring(L, -2)); - binary_input_read_value(L, -1, ar); // Uses type, pushes value - lua_remove(L, -2); // Remove type - lua_rawset(L, value_result_table_L);// Set t[#-2] = #-1 + binary_input_read_value(L, -1, ar); // Uses type, pushes value + lua_remove(L, -2); // Remove type + lua_rawset(L, value_result_table_L); // Set t[#-2] = #-1 } - lua_pop(L, 1); // Continue iterating by popping table value + lua_pop(L, 1); // Continue iterating by popping table value field_i++; } // value_result_table_L is left on stack @@ -189,7 +189,7 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L, uint64_t num_entries = 0; lua_pushnil(L); while(lua_next(L, value_L) != 0){ - lua_pop(L, 1); // Continue iterating by popping table value + lua_pop(L, 1); // Continue iterating by popping table value num_entries++; } ar(num_entries); @@ -198,10 +198,10 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L, while(lua_next(L, value_L) != 0){ log_t(MODULE, "array[%i]", i); binary_output_write_value(L, -1, array_type_L, ar); - lua_pop(L, 1); // Continue iterating by popping table value + lua_pop(L, 1); // Continue iterating by popping table value i++; } - lua_pop(L, 1); // array_type_L + lua_pop(L, 1); // array_type_L // value_result_table_L is left on stack } else if(outfield_type == "unordered_map"){ if(!has_table) @@ -214,7 +214,7 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L, uint64_t num_entries = 0; lua_pushnil(L); while(lua_next(L, value_L) != 0){ - lua_pop(L, 1); // Continue iterating by popping table value + lua_pop(L, 1); // Continue iterating by popping table value num_entries++; } ar(num_entries); @@ -225,10 +225,10 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L, log_t(MODULE, "unordered_map[%s]", lua_tostring(L, key_L)); binary_output_write_value(L, key_L, map_key_type_L, ar); binary_output_write_value(L, value_L, map_value_type_L, ar); - lua_pop(L, 1); // Continue iterating by popping table value + lua_pop(L, 1); // Continue iterating by popping table value } - lua_pop(L, 1); // map_value_type_L - lua_pop(L, 1); // map_key_type_L + lua_pop(L, 1); // map_value_type_L + lua_pop(L, 1); // map_key_type_L // value_result_table_L is left on stack } else if(outfield_type == "object"){ if(!has_table) @@ -240,17 +240,17 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L, if(field_i != 0){ log_t(MODULE, "object field %zu", field_i); int field_def_L = lua_gettop(L); - lua_rawgeti(L, field_def_L, 2); // type - lua_rawgeti(L, field_def_L, 1); // name + lua_rawgeti(L, field_def_L, 2); // type + lua_rawgeti(L, field_def_L, 1); // name log_t(MODULE, " = object[\"%s\"]", lua_tostring(L, -1)); // Get value_L[name]; name is replaced by value lua_rawget(L, value_L); // Recurse into this value binary_output_write_value(L, -1, -2, ar); - lua_pop(L, 1); // Pop value - lua_pop(L, 1); // Pop type + lua_pop(L, 1); // Pop value + lua_pop(L, 1); // Pop type } - lua_pop(L, 1); // Continue iterating by popping table value + lua_pop(L, 1); // Continue iterating by popping table value field_i++; } } else { @@ -304,6 +304,6 @@ void init_cereal(lua_State *L) DEF_BUILDAT_FUNC(cereal_binary_output) } -} // namespace lua_bindingss +} // namespace lua_bindingss // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/init.cpp b/src/lua_bindings/init.cpp index b3c1726..829796a 100644 --- a/src/lua_bindings/init.cpp +++ b/src/lua_bindings/init.cpp @@ -22,5 +22,5 @@ void init(lua_State *L) init_misc_urho3d(L); } -} // namespace lua_bindingss +} // namespace lua_bindingss // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/misc.cpp b/src/lua_bindings/misc.cpp index 43d43c1..41b548c 100644 --- a/src/lua_bindings/misc.cpp +++ b/src/lua_bindings/misc.cpp @@ -98,5 +98,5 @@ void init_misc(lua_State *L) DEF_BUILDAT_FUNC(get_time_us) } -} // namespace lua_bindingss +} // namespace lua_bindingss // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/misc_urho3d.cpp b/src/lua_bindings/misc_urho3d.cpp index afa1573..cf1c4e3 100644 --- a/src/lua_bindings/misc_urho3d.cpp +++ b/src/lua_bindings/misc_urho3d.cpp @@ -19,16 +19,16 @@ using namespace Urho3D; namespace lua_bindings { -#define GET_TOLUA_STUFF(result_name, index, type)\ - if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){\ - tolua_error(L, __PRETTY_FUNCTION__, &tolua_err);\ - return 0;\ - }\ +#define GET_TOLUA_STUFF(result_name, index, type) \ + if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){ \ + tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \ + return 0; \ + } \ type *result_name = (type*)tolua_tousertype(L, index, 0); -#define TRY_GET_TOLUA_STUFF(result_name, index, type)\ - type *result_name = nullptr;\ - if(tolua_isusertype(L, index, #type, 0, &tolua_err)){\ - result_name = (type*)tolua_tousertype(L, index, 0);\ +#define TRY_GET_TOLUA_STUFF(result_name, index, type) \ + type *result_name = nullptr; \ + if(tolua_isusertype(L, index, #type, 0, &tolua_err)){ \ + result_name = (type*)tolua_tousertype(L, index, 0); \ } static int l_profiler_block_begin(lua_State *L) @@ -71,6 +71,6 @@ void init_misc_urho3d(lua_State *L) DEF_BUILDAT_FUNC(profiler_block_end); } -} // namespace lua_bindingss +} // namespace lua_bindingss // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/spatial_update_queue.cpp b/src/lua_bindings/spatial_update_queue.cpp index c909440..d87373c 100644 --- a/src/lua_bindings/spatial_update_queue.cpp +++ b/src/lua_bindings/spatial_update_queue.cpp @@ -8,21 +8,21 @@ #include #define MODULE "lua_bindings" -#define DEF_METHOD(name){\ - lua_pushcfunction(L, l_##name);\ - lua_setfield(L, -2, #name);\ +#define DEF_METHOD(name){ \ + lua_pushcfunction(L, l_##name); \ + lua_setfield(L, -2, #name); \ } -#define GET_TOLUA_STUFF(result_name, index, type)\ - if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){\ - tolua_error(L, __PRETTY_FUNCTION__, &tolua_err);\ - return 0;\ - }\ +#define GET_TOLUA_STUFF(result_name, index, type) \ + if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){ \ + tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \ + return 0; \ + } \ type *result_name = (type*)tolua_tousertype(L, index, 0); -#define TRY_GET_TOLUA_STUFF(result_name, index, type)\ - type *result_name = nullptr;\ - if(tolua_isusertype(L, index, #type, 0, &tolua_err)){\ - result_name = (type*)tolua_tousertype(L, index, 0);\ +#define TRY_GET_TOLUA_STUFF(result_name, index, type) \ + type *result_name = nullptr; \ + if(tolua_isusertype(L, index, #type, 0, &tolua_err)){ \ + result_name = (type*)tolua_tousertype(L, index, 0); \ } // Just do this; Urho3D's stuff doesn't really clash with anything in buildat @@ -81,7 +81,7 @@ struct SpatialUpdateQueue void insert(const Value &value, std::list::iterator queue_it){ Entry entry(value, queue_it); auto it = std::lower_bound(m_set.begin(), m_set.end(), entry, - std::greater()); + std::greater()); if(it == m_set.end()) m_set.insert(it, entry); else if(it->value.node_id != value.node_id || @@ -93,15 +93,15 @@ struct SpatialUpdateQueue void remove(const Value &value){ Entry entry(value); auto it = std::lower_bound(m_set.begin(), m_set.end(), entry, - std::greater()); + std::greater()); if(it == m_set.end()) return; m_set.erase(it); } - std::list::iterator* find(const Value &value){ + std::list::iterator*find(const Value &value){ Entry entry(value); auto it = std::lower_bound(m_set.begin(), m_set.end(), entry, - std::greater()); + std::greater()); if(it == m_set.end()) return nullptr; if(it->value.node_id != value.node_id || @@ -125,7 +125,7 @@ struct SpatialUpdateQueue return; log_d(MODULE, "SpatialUpdateQueue(): Items in old queue: %zu", m_old_queue.size()); - for(int i=0; i()); // position in descending order + item, std::greater()); // position in descending order auto inserted_it = m_queue.insert(it, item); m_queue_length++; m_value_set.insert(item.value, inserted_it); @@ -264,7 +264,7 @@ struct LuaSUQ { static constexpr const char *class_name = "SpatialUpdateQueue"; SpatialUpdateQueue internal; - + static int gc_object(lua_State *L){ delete *(LuaSUQ**)(lua_touserdata(L, 1)); return 0; @@ -303,7 +303,7 @@ struct LuaSUQ value.node_id = luaL_checkinteger(L, -1); lua_pop(L, 1); o->internal.put(*p, near_weight, near_trigger_d, - far_weight, far_trigger_d, value); + far_weight, far_trigger_d, value); return 0; } static int l_get(lua_State *L){ @@ -406,6 +406,6 @@ void init_spatial_update_queue(lua_State *L) DEF_BUILDAT_FUNC(SpatialUpdateQueue); } -} // namespace lua_bindingss -// vim: set noet ts=4 sw=4: +} // namespace lua_bindingss +// vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/util.cpp b/src/lua_bindings/util.cpp index 2f2c70d..7c421f0 100644 --- a/src/lua_bindings/util.cpp +++ b/src/lua_bindings/util.cpp @@ -61,6 +61,6 @@ int handle_error(lua_State *L) return 1; } -} // namespace lua_bindingss +} // namespace lua_bindingss // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/voxel.cpp b/src/lua_bindings/voxel.cpp index ea9d551..671956e 100644 --- a/src/lua_bindings/voxel.cpp +++ b/src/lua_bindings/voxel.cpp @@ -27,16 +27,16 @@ using namespace Urho3D; namespace lua_bindings { -#define GET_TOLUA_STUFF(result_name, index, type)\ - if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){\ - tolua_error(L, __PRETTY_FUNCTION__, &tolua_err);\ - return 0;\ - }\ +#define GET_TOLUA_STUFF(result_name, index, type) \ + if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){ \ + tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \ + return 0; \ + } \ type *result_name = (type*)tolua_tousertype(L, index, 0); -#define TRY_GET_TOLUA_STUFF(result_name, index, type)\ - type *result_name = nullptr;\ - if(tolua_isusertype(L, index, #type, 0, &tolua_err)){\ - result_name = (type*)tolua_tousertype(L, index, 0);\ +#define TRY_GET_TOLUA_STUFF(result_name, index, type) \ + type *result_name = nullptr; \ + if(tolua_isusertype(L, index, #type, 0, &tolua_err)){ \ + result_name = (type*)tolua_tousertype(L, index, 0); \ } // NOTE: This API is designed this way because otherwise ownership management of @@ -296,6 +296,6 @@ void init_voxel(lua_State *L) DEF_BUILDAT_FUNC(clear_voxel_physics_boxes); } -} // namespace lua_bindingss +} // namespace lua_bindingss // vim: set noet ts=4 sw=4: diff --git a/src/server/main.cpp b/src/server/main.cpp index a19ccdf..3ec9c7e 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -23,8 +23,8 @@ #include #include #include -#include // strerror() -#include // struct timeval +#include // strerror() +#include // struct timeval #define MODULE "main" namespace magic = Urho3D; @@ -35,7 +35,7 @@ bool g_sigint_received = false; void sigint_handler(int sig) { if(!g_sigint_received){ - fprintf(stdout, "\n"); // Newline after "^C" + fprintf(stdout, "\n"); // Newline after "^C" log_i("process", "SIGINT"); g_sigint_received = true; } else { diff --git a/src/server/rccpp.cpp b/src/server/rccpp.cpp index 13c8552..e3882b5 100644 --- a/src/server/rccpp.cpp +++ b/src/server/rccpp.cpp @@ -190,5 +190,5 @@ Compiler* createCompiler(const ss_ &compiler_command) return new CCompiler(compiler_command); } -} // rccpp +} // rccpp // vim: set noet ts=4 sw=4: diff --git a/src/server/state.cpp b/src/server/state.cpp index 968f1d5..4dec485 100644 --- a/src/server/state.cpp +++ b/src/server/state.cpp @@ -216,16 +216,16 @@ struct CState: public State, public interface::Server // modules. In every other case modules must use access_scene(). // NOTE: If not locked, creating or destructing Urho3D Objects can cause a // crash. - interface::Mutex m_magic_mutex; // Lock for all of Urho3D + interface::Mutex m_magic_mutex; // Lock for all of Urho3D - sm_ m_module_info; // Info of every seen module - sm_ m_modules;// Currently loaded modules + sm_ m_module_info; // Info of every seen module + sm_ m_modules; // Currently loaded modules set_ m_unloads_requested; sm_> m_module_file_watches; // Module modifications are accumulated here and core:module_modified events // are fired every event loop based on this to lump multiple modifications // into one (generally a modification causes many notifications) - set_ m_modified_modules; // Module names + set_ m_modified_modules; // Module names // TODO: Handle properly in reloads (unload by popping from top, then reload // everything until top) sv_ m_module_load_order; @@ -275,7 +275,7 @@ struct CState: public State, public interface::Server g_server_config.urho3d_path+"/Source/Engine/"+subdir); } m_compiler->include_directories.push_back( - g_server_config.urho3d_path+"/Build/Engine"); // Urho3D.h + g_server_config.urho3d_path+"/Build/Engine"); // Urho3D.h m_compiler->library_directories.push_back( g_server_config.urho3d_path+"/Lib"); m_compiler->libraries.push_back("-lUrho3D"); @@ -302,7 +302,7 @@ struct CState: public State, public interface::Server magic::VariantMap params; params["ResourcePaths"] = resource_paths_s.c_str(); params["Headless"] = true; - params["LogName"] = ""; // Don't log to file + params["LogName"] = ""; // Don't log to file //params["LogQuiet"] = true; // Don't log to stdout if(!m_magic_engine->Initialize(params)) throw Exception("Urho3D engine initialization failed"); @@ -761,7 +761,7 @@ struct CState: public State, public interface::Server void handle_events() { magic::AutoProfileBlock profiler_block(m_magic_context-> - GetSubsystem(), "Buildat|handle_events"); + GetSubsystem(), "Buildat|handle_events"); // Get modified modules and push events to queue { @@ -821,8 +821,8 @@ struct CState: public State, public interface::Server interface::MutexScope ms(m_modules_mutex); for(auto it = m_unloads_requested.begin(); it != m_unloads_requested.end();){ - ss_ module_name = *it; // Copy - it++; // Increment before unload_module_u; it erases this + ss_ module_name = *it; // Copy + it++; // Increment before unload_module_u; it erases this log_i("state", "Unloading %s as requested", cs(module_name)); unload_module_u(module_name); }