Fix coding style

This commit is contained in:
Perttu Ahola 2014-10-17 13:49:55 +03:00
parent ad528c2443
commit f64adf35d6
46 changed files with 292 additions and 287 deletions

View File

@ -462,7 +462,7 @@ struct Module: public interface::Module, public replicate::Interface
sv_<PeerId> find_peers_that_know_node(uint node_id)
{
sv_<PeerId> 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_;

View File

@ -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_<pv::RawVolume<uint32_t>> node_ids;
size_t num_chunks = 0;
@ -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;
@ -234,7 +235,8 @@ ChunkBuffer& Section::get_buffer(const pv::Vector3DInt32 &chunk_p,
interface::deserialize_volume(data);
buf.volume = sp_<pv::RawVolume<VoxelInstance>>(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));
@ -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 &sector_pair : m_sections){
for(auto &section_pair : sector_pair.second){
for(auto &sector_pair: m_sections){
for(auto &section_pair: sector_pair.second){
Section &section = 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_<pv::RawVolume<VoxelInstance>> 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());
}

View File

@ -118,7 +118,8 @@ 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));
@ -152,7 +153,8 @@ struct Module: public interface::Module
RigidBody *body = n->CreateComponent<RigidBody>(LOCAL);
body->SetFriction(0.75f);
body->SetMass(1.0);
CollisionShape *shape = n->CreateComponent<CollisionShape>(LOCAL);
CollisionShape *shape =
n->CreateComponent<CollisionShape>(LOCAL);
shape->SetConvexHull(model, 0, Vector3::ONE);
//shape->SetTriangleMesh(model, 0, Vector3::ONE);
//shape->SetBox(Vector3::ONE);
@ -201,7 +203,8 @@ struct Module: public interface::Module
voxelworld::access(m_server, [&](voxelworld::Interface *ivoxelworld)
{
const pv::Vector3DInt16 &section_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,7 +256,7 @@ 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++){
@ -273,7 +276,7 @@ struct Module: public interface::Module
if(y < lc.getY() - 5 || y > uc.getY() - 5)
continue;
for(int y1=y; y1<y+4; y1++){
for(int y1 = y; y1<y+4; y1++){
pv::Vector3DInt32 p(x, y1, z);
ivoxelworld->set_voxel(p, VoxelInstance(3), true);
}

View File

@ -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"),

View File

@ -60,7 +60,7 @@ struct CState: public State
sp_<app::App> m_app;
ss_ m_remote_cache_path;
ss_ m_tmp_path;
sm_<ss_, ss_> m_file_hashes;// name -> hash
sm_<ss_, ss_> m_file_hashes; // name -> hash
set_<ss_> m_waiting_files; // name
bool m_tell_after_all_files_transferred_requested = false;
// Connecting is possible only once. After that has happened, the whole

View File

@ -8,8 +8,8 @@
#include <iomanip>
#include <fstream>
#include <streambuf>
#include <cinttypes>// PRId64
#include <cmath>// isnan/isinf
#include <cinttypes> // PRId64
#include <cmath> // isnan/isinf
#include <cfloat> // DBL_MAX/DBL_MIN
#include "sajson.h"

View File

@ -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)){

View File

@ -7,7 +7,7 @@
#include <set>
#include <exception>
#include <cstdint>
#include <cinttypes>// PRId64
#include <cinttypes> // PRId64
#include <sstream>
#include <memory>
#include <stdio.h> // snprintf

View File

@ -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:
@ -140,7 +140,7 @@ void decompress_zlib(std::istream &is, std::ostream &os)
//dstream<<"z.avail_in="<<z.avail_in<<std::endl;
//dstream<<"fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
// Unget all the data that inflate didn't take
for(size_t i=0; i < z.avail_in; i++)
for(size_t i = 0; i < z.avail_in; i++)
{
is.unget();
if(is.fail() || is.bad())

View File

@ -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)
@ -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();

View File

@ -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());

View File

@ -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;
}

View File

@ -21,13 +21,13 @@ ss_ serialize_volume_simple(const pv::RawVolume<VoxelInstance> &volume)
auto region = volume.getEnclosingRegion();
auto lc = region.getLowerCorner();
auto uc = region.getUpperCorner();
for(size_t i=0; i<volume.m_dataSize; i++){
for(size_t i = 0; i<volume.m_dataSize; i++){
const VoxelInstance &v = volume.m_pData[i];
ar((uint32_t)v.data);
}
}
return os.str();
};
}
ss_ serialize_volume_compressed(const pv::RawVolume<VoxelInstance> &volume)
{
@ -44,7 +44,7 @@ ss_ serialize_volume_compressed(const pv::RawVolume<VoxelInstance> &volume)
auto region = volume.getEnclosingRegion();
auto lc = region.getLowerCorner();
auto uc = region.getUpperCorner();
for(size_t i=0; i<volume.m_dataSize; i++){
for(size_t i = 0; i<volume.m_dataSize; i++){
const VoxelInstance &v = volume.m_pData[i];
ar((uint32_t)v.data);
}
@ -55,7 +55,7 @@ ss_ serialize_volume_compressed(const pv::RawVolume<VoxelInstance> &volume)
ar(compressed_os.str());
}
return os.str();
};
}
up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
{
@ -71,7 +71,7 @@ up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
pv::Region region(0, 0, 0, w-1, h-1, d-1);
up_<pv::RawVolume<VoxelInstance>> volume(
new pv::RawVolume<VoxelInstance>(region));
for(size_t i=0; i<volume->m_dataSize; i++){
for(size_t i = 0; i<volume->m_dataSize; i++){
uint32_t v;
ar(v);
volume->m_pData[i].data = v;
@ -94,7 +94,7 @@ up_<pv::RawVolume<VoxelInstance>> 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; i<volume->m_dataSize; i++){
for(size_t i = 0; i<volume->m_dataSize; i++){
uint32_t v;
ar(v);
volume->m_pData[i].data = v;
@ -102,7 +102,7 @@ up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
}
return volume;
}
return up_<pv::RawVolume<VoxelInstance>>();;
return up_<pv::RawVolume<VoxelInstance>>();
}
}

View File

@ -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;
};

View File

@ -18,7 +18,7 @@ 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
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0); // Size in voxels
sv_<VoxelTypeId> segments; // Rotations*voxels
};
@ -27,7 +27,7 @@ namespace interface
{
BlockName name;
uint8_t num_rotations = 0; // Supported: 0, 4, 24
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0);// Size in voxels
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0); // Size in voxels
// Definitions for creating voxels
sv_<ss_> side_textures; // 6 resource names
ss_ handler_module;

View File

@ -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:

View File

@ -20,7 +20,7 @@ namespace interface
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_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:

View File

@ -130,7 +130,7 @@ static void binary_input_read_value(lua_State *L, int type_L,
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
lua_rawset(L, value_result_table_L); // Set t[#-2] = #-1
}
lua_pop(L, 1); // Continue iterating by popping table value
field_i++;

View File

@ -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)

View File

@ -8,21 +8,21 @@
#include <algorithm>
#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
@ -98,7 +98,7 @@ struct SpatialUpdateQueue
return;
m_set.erase(it);
}
std::list<Item>::iterator* find(const Value &value){
std::list<Item>::iterator*find(const Value &value){
Entry entry(value);
auto it = std::lower_bound(m_set.begin(), m_set.end(), entry,
std::greater<Entry>());
@ -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<max_operations; i++){
for(int i = 0; i<max_operations; i++){
if(m_old_queue.empty())
break;
Item &item = m_old_queue.back();
@ -407,5 +407,5 @@ void init_spatial_update_queue(lua_State *L)
}
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:
// vim: set noet ts=4 sw=4:

View File

@ -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

View File

@ -219,7 +219,7 @@ struct CState: public State, public interface::Server
interface::Mutex m_magic_mutex; // Lock for all of Urho3D
sm_<ss_, interface::ModuleInfo> m_module_info; // Info of every seen module
sm_<ss_, ModuleContainer> m_modules;// Currently loaded modules
sm_<ss_, ModuleContainer> m_modules; // Currently loaded modules
set_<ss_> m_unloads_requested;
sm_<ss_, sp_<interface::FileWatch>> m_module_file_watches;
// Module modifications are accumulated here and core:module_modified events