Fix coding style

master
Perttu Ahola 2014-11-01 22:08:03 +02:00
parent 7cbd9d3ac4
commit 52b9031100
59 changed files with 619 additions and 613 deletions

View File

@ -43,8 +43,7 @@ void interval_loop(int interval_us, std::function<bool(float load_avg)> f)
int64_t t_tick_end = get_timeofday_us();
int64_t t_tick_length = t_tick_end > t_tick_start ? t_tick_end -
t_tick_start :
0;
t_tick_start : 0;
float load_ratio = (float)t_tick_length / interval_us;
//log_i("loop", "load_ratio=%f", load_ratio);
load_log[load_log_i] = load_ratio;

View File

@ -10,7 +10,7 @@ namespace main_context
{
struct OpaqueSceneReference;
typedef OpaqueSceneReference* SceneReference;
};
}
namespace ground_plane_lighting
{

View File

@ -236,7 +236,7 @@ struct CInstance: public ground_plane_lighting::Instance
ar(s);
}
network::access(m_server, [&](network::Interface *inetwork){
for(auto &peer : m_clients_initialized){
for(auto &peer: m_clients_initialized){
inetwork->send(peer, "ground_plane_lighting:update",
os.str());
}
@ -440,7 +440,7 @@ struct Module: public interface::Module, public ground_plane_lighting::Interface
{
// Drop instance of the deleted scene (there should be only one, but
// loop through all of them just for robustness)
for(auto it = m_instances.begin(); it != m_instances.end(); ){
for(auto it = m_instances.begin(); it != m_instances.end();){
auto current_it = it++;
up_<CInstance> &instance = current_it->second;
if(instance->m_scene_ref == event.scene){

View File

@ -224,10 +224,10 @@ struct ResolveState
{
log_d(MODULE, "step_through()");
while(step(true)) ;
while(step(true));
if(m_failed) return false;
while(step(false)) ;
while(step(false));
if(m_failed) return false;
for(const ss_ &name : m_required_modules){

View File

@ -25,7 +25,7 @@ namespace main_context
{
SceneReference scene;
SceneDeleted(SceneReference scene): scene(scene) {}
SceneDeleted(SceneReference scene): scene(scene){}
};
struct Interface

View File

@ -61,7 +61,7 @@ struct OpaqueSceneReference
{
SharedPtr<Scene> scene;
OpaqueSceneReference(const SharedPtr<Scene> &scene): scene(scene) {}
OpaqueSceneReference(const SharedPtr<Scene> &scene): scene(scene){}
};
struct Module: public interface::Module, public main_context::Interface

View File

@ -16,7 +16,7 @@ namespace main_context
{
struct OpaqueSceneReference;
typedef OpaqueSceneReference* SceneReference;
};
}
namespace replicate
{

View File

@ -85,10 +85,12 @@ struct Module: public interface::Module, public replicate::Interface
if(ps.scene_ref != nullptr){
scene = imc->find_scene(ps.scene_ref);
if(!scene)
log_w(MODULE, "~Module(): Scene %p not found", ps.scene_ref);
log_w(MODULE, "~Module(): Scene %p not found",
ps.scene_ref);
}
if(scene){
scene->CleanupConnection((magic::Connection*)&ps.scene_state);
scene->CleanupConnection(
(magic::Connection*)&ps.scene_state);
}
// Make sure to fully clear the SceneReplicationState in
// the context of main_context. Otherwise race conditions can
@ -530,7 +532,7 @@ struct Module: public interface::Module, public replicate::Interface
main_context::SceneReference scene_ref)
{
sv_<PeerId> result;
for(auto &pair: m_peers){
for(auto &pair : m_peers){
PeerState &ps = pair.second;
if(ps.scene_ref == nullptr || ps.scene_ref != scene_ref)
continue;
@ -543,7 +545,7 @@ struct Module: public interface::Module, public replicate::Interface
main_context::SceneReference scene_ref, uint node_id)
{
sv_<PeerId> result;
for(auto &pair: m_peers){
for(auto &pair : m_peers){
PeerState &ps = pair.second;
if(ps.scene_ref == nullptr || ps.scene_ref != scene_ref)
continue;

View File

@ -21,7 +21,7 @@ namespace main_context
{
struct OpaqueSceneReference;
typedef OpaqueSceneReference* SceneReference;
};
}
namespace voxelworld
{
@ -126,10 +126,11 @@ namespace voxelworld
}
inline bool access(interface::Server *server, SceneReference scene_ref,
std::function<void(voxelworld::Instance *instance)> cb)
std::function<void(voxelworld::Instance*instance)> cb)
{
return access(server, [&](voxelworld::Interface *i){
voxelworld::Instance *instance = check(i->get_instance(scene_ref));
voxelworld::Instance *instance =
check(i->get_instance(scene_ref));
cb(instance);
});
}

View File

@ -432,7 +432,7 @@ struct CInstance: public voxelworld::Instance
ss_ voxel_reg_data = m_voxel_reg->serialize();
network::access(m_server, [&](network::Interface *inetwork){
for(auto &peer : m_clients_initialized){
for(auto &peer: m_clients_initialized){
inetwork->send(peer, "voxelworld:voxel_registry",
voxel_reg_data);
}
@ -1185,7 +1185,7 @@ struct Module: public interface::Module, public voxelworld::Interface
{
// Drop instance of the deleted scene (there should be only one, but
// loop through all of them just for robustness)
for(auto it = m_instances.begin(); it != m_instances.end(); ){
for(auto it = m_instances.begin(); it != m_instances.end();){
auto current_it = it++;
up_<CInstance> &instance = current_it->second;
if(instance->m_scene_ref == event.scene){

View File

@ -11,7 +11,7 @@ namespace main_context
{
struct OpaqueSceneReference;
typedef OpaqueSceneReference* SceneReference;
};
}
namespace worldgen
{
@ -59,14 +59,15 @@ namespace worldgen
}
inline bool access(interface::Server *server, SceneReference scene_ref,
std::function<void(worldgen::Instance *instance)> cb)
std::function<void(worldgen::Instance*instance)> cb)
{
return access(server, [&](worldgen::Interface *i){
worldgen::Instance *instance = check(i->get_instance(scene_ref));
worldgen::Instance *instance =
check(i->get_instance(scene_ref));
cb(instance);
});
}
}
// vim: set noet ts=4 sw=4:
// vim: set noet ts=4 sw=4:

View File

@ -249,7 +249,7 @@ void GenerateThread::run(interface::Thread *thread)
[&](worldgen::Interface *iworldgen)
{
// Generate one section for each instance
for(auto &pair : m_module->m_instances){
for(auto &pair: m_module->m_instances){
up_<CInstance> &instance = pair.second;
if(!instance->m_enabled && !instance->m_queued_sections.empty()){
// Has to be checked later

View File

@ -228,18 +228,15 @@ PathDefinition server_paths[] = {
{PD_READ, "share_path",
"",
"/builtin/network/network.cpp",
"Static files"
},
"Static files"},
{PD_READ, "interface_path",
"/src/interface",
"/event.h",
"Interface files"
},
"Interface files"},
{PD_WRITE, "rccpp_build_path",
"/cache/rccpp_build",
"/write.test",
"RCC++ build directory"
},
"RCC++ build directory"},
{PD_END, "", "", "", ""},
};
@ -257,8 +254,7 @@ PathDefinition compiler_bin_paths[] = {
{PD_RUN, "compiler_command",
"c++",
" --version",
"Compiler command"
},
"Compiler command"},
{PD_END, "", "", "", ""},
};
@ -266,7 +262,8 @@ static bool detect_compiler_bin_paths(core::Config &config)
{
sv_<ss_> roots;
generate_compiler_binary_dir_alternatives(roots);
return detect_paths(config, roots, compiler_bin_paths, "Compiler binary directory");
return detect_paths(config, roots, compiler_bin_paths,
"Compiler binary directory");
}
// Client-only paths
@ -275,13 +272,11 @@ PathDefinition client_paths[] = {
{PD_READ, "share_path",
"",
"/client/init.lua",
"Static files"
},
"Static files"},
{PD_WRITE, "cache_path",
"/cache",
"/write.test",
"Cache directory"
},
"Cache directory"},
{PD_END, "", "", "", ""},
};
@ -298,8 +293,7 @@ PathDefinition server_urho3d_paths[] = {
{PD_READ, "urho3d_path",
"",
"/Bin/CoreData/Shaders/GLSL/Basic.glsl",
"Urho3D path"
},
"Urho3D path"},
{PD_END, "", "", "", ""},
};
@ -316,8 +310,7 @@ PathDefinition client_urho3d_paths[] = {
{PD_READ, "urho3d_path",
"",
"/Bin/CoreData/Shaders/GLSL/Basic.glsl",
"Urho3D path"
},
"Urho3D path"},
{PD_END, "", "", "", ""},
};
@ -378,5 +371,6 @@ bool detect_client_paths(core::Config &config)
return ok;
}
}}
}
}
// vim: set noet ts=4 sw=4:

View File

@ -25,7 +25,8 @@ namespace boot
// Force '.' as decimal point
try {
std::locale::global(std::locale(std::locale(""), "C", std::locale::numeric));
std::locale::global(std::locale(std::locale(""), "C",
std::locale::numeric));
} catch(std::runtime_error &e){
// Can happen on Wine
fprintf(stderr, "Failed to set numeric C++ locale\n");

View File

@ -35,8 +35,8 @@
#include <DebugRenderer.h>
#include <Profiler.h>
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lua.h>
#include <lauxlib.h>
}
#include <signal.h>
#define MODULE "__app"
@ -353,7 +353,8 @@ struct CApp: public App, public magic::Application
lua_bindings::replicate::set_scene(L, m_scene);
// Run initial client Lua scripts
ss_ init_lua_path = g_client_config.get<ss_>("share_path")+"/client/init.lua";
ss_ init_lua_path = g_client_config.get<ss_>("share_path")+
"/client/init.lua";
int error = luaL_dofile(L, init_lua_path.c_str());
if(error){
log_w(MODULE, "luaL_dofile: An error occurred: %s\n",

View File

@ -329,7 +329,8 @@ void CState::setup_packet_handlers()
return;
}
ss_ file_hash_hex = interface::sha1::hex(file_hash);
ss_ path = g_client_config.get<ss_>("cache_path")+"/remote/"+file_hash_hex;
ss_ path = g_client_config.get<ss_>("cache_path")+"/remote/"+
file_hash_hex;
log_i(MODULE, "Saving %s to %s", cs(file_name), cs(path));
std::ofstream of(path, std::ios::binary);
of<<file_content;

View File

@ -702,7 +702,7 @@ namespace sajson {
*temp++ = make_element(result.value_type, out - current_base - 1);
}
done:
done:
if(0 == peek_structure()){
return true;
} else {
@ -1186,7 +1186,7 @@ done:
case 't':
replacement = '\t';
goto replace;
replace:
replace:
*end++ = replacement;
++p;
break;

View File

@ -87,7 +87,7 @@ static inline ss_ ftos(float f){
#define SLEN(x) (sizeof(x)/sizeof((x)[0]))
template<typename T>
static inline ss_ dump(const T &v);
static inline ss_ dump(const T &v);
template<>
inline ss_ dump(const double &v){
@ -165,10 +165,10 @@ static inline const T* check(const T *v){
}
#if 0 // Don't use this; this isn't needed on MinGW 4.9.1 and newer
#ifdef __MINGW32__
#ifdef __MINGW32__
// MinGW doesn't have std::to_string (as of mingw-w64 4.8.1); define something to replace it
// This include is going to fuck things up for Linux users that use modules developed on Windows
#include <sstream>
#include <sstream>
namespace std {
template<typename T>
ss_ to_string(const T &v){
@ -179,7 +179,7 @@ namespace std {
}
// Also this doesn't exist on MinGW (as of mingw-w64 4.8.1)
typedef int ssize_t;
#endif
#endif
#endif
// vim: set noet ts=4 sw=4:

View File

@ -116,5 +116,6 @@ bool path_exists(const ss_ &path)
return c55fs::PathExists(path);
}
}}
}
}
// vim: set noet ts=4 sw=4:

View File

@ -173,7 +173,7 @@ void set_8bit_voxel_geometry(CustomGeometry *cg, Context *context,
}
template<typename VoxelType>
class IsQuadNeededByRegistryPhysics
class IsQuadNeededByRegistryPhysics
{
interface::VoxelRegistry *m_voxel_reg;
// NOTE: The voxel type id is used directly as PolyVox material value
@ -282,7 +282,7 @@ Model* create_voxel_physics_model(Context *context,
}
template<typename VoxelType>
class IsQuadNeededByRegistry
class IsQuadNeededByRegistry
{
interface::VoxelRegistry *m_voxel_reg;
// NOTE: The voxel type id is used directly as PolyVox material value
@ -848,6 +848,7 @@ void generate_voxel_physics_boxes(
uint8_t v = (def && def->physically_solid);
volume.setVoxelAt(x, y, z, v);
}
@ -875,7 +876,7 @@ void generate_voxel_physics_boxes(
}
}
break; // Done
found_non_covered_voxel:
found_non_covered_voxel:
// Stretch this box first in x, then y and then z to be as large as
// possible without covering any non-solid voxels
int x1 = x0;
@ -891,7 +892,7 @@ found_non_covered_voxel:
}
}
continue; // Fits
x_plane_does_not_fit:
x_plane_does_not_fit:
x1--;
break;
}
@ -905,7 +906,7 @@ x_plane_does_not_fit:
}
}
continue; // Fits
y_plane_does_not_fit:
y_plane_does_not_fit:
y1--;
break;
}
@ -919,7 +920,7 @@ y_plane_does_not_fit:
}
}
continue; // Fits
z_plane_does_not_fit:
z_plane_does_not_fit:
z1--;
break;
}

View File

@ -78,7 +78,7 @@ struct CThreadPool: public ThreadPool
}
// Run the task's threaded part
try {
while(!current->thread()) ;
while(!current->thread());
} catch(std::exception &e){
log_w(MODULE, "Worker task failed: %s", e.what());
interface::debug::log_exception_backtrace();
@ -100,7 +100,7 @@ struct CThreadPool: public ThreadPool
void add_task(up_<Task> task)
{
// TODO: Limit task->pre() execution time per frame
while(!task->pre()) ;
while(!task->pre());
interface::MutexScope ms(m_mutex);
m_input_queue.push_back(std::move(task));
m_tasks_sem.post();

View File

@ -14,7 +14,7 @@ namespace interface {
// pv::RawVolume<T>
template<typename T>
ss_ generic_serialize_volume_simple(const pv::RawVolume<T> &volume)
ss_ generic_serialize_volume_simple(const pv::RawVolume<T> &volume)
{
std::ostringstream os(std::ios::binary);
{
@ -32,7 +32,7 @@ ss_ generic_serialize_volume_simple(const pv::RawVolume<T> &volume)
}
template<typename T>
ss_ generic_serialize_volume_compressed(const pv::RawVolume<T> &volume)
ss_ generic_serialize_volume_compressed(const pv::RawVolume<T> &volume)
{
std::ostringstream os(std::ios::binary);
{
@ -58,7 +58,7 @@ ss_ generic_serialize_volume_compressed(const pv::RawVolume<T> &volume)
}
template<typename T>
up_<pv::RawVolume<T>> generic_deserialize_volume(const ss_ &data)
up_<pv::RawVolume<T>> generic_deserialize_volume(const ss_ &data)
{
std::istringstream is(data, std::ios::binary);
cereal::PortableBinaryInputArchive ar(is);

View File

@ -8,8 +8,8 @@ namespace interface
{
namespace debug
{
void log_current_backtrace(const ss_ &title="Current backtrace:");
void log_exception_backtrace(const ss_ &title="Exception backtrace:");
void log_current_backtrace(const ss_ &title = "Current backtrace:");
void log_exception_backtrace(const ss_ &title = "Exception backtrace:");
static const size_t BACKTRACE_SIZE = 48;
@ -23,7 +23,7 @@ namespace interface
void get_exception_backtrace(StoredBacktrace &result);
void log_backtrace(const StoredBacktrace &result,
const ss_ &title="Stored backtrace:");
const ss_ &title = "Stored backtrace:");
struct ThreadBacktrace {
ss_ thread_name;

View File

@ -26,6 +26,6 @@ namespace interface
bool check_file_extension(const char *path, const char *ext);
ss_ strip_file_extension(const ss_ &path);
ss_ strip_file_name(const ss_ &path);
};
}
}
// vim: set noet ts=4 sw=4:

View File

@ -3,8 +3,8 @@
#pragma once
#include "core/types.h"
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lua.h>
#include <lauxlib.h>
}
namespace lua_bindings

View File

@ -67,7 +67,7 @@ static const char* library_error(){
}
#endif
typedef void*(*RCCPP_Constructor)(interface::Server *server);
typedef void*(*RCCPP_Constructor)(interface::Server * server);
struct RCCPP_Info {
void *module;

View File

@ -284,7 +284,7 @@ void ModuleThread::run(interface::Thread *thread)
if(direct_cb){
// Handle the direct callback
handle_direct_cb(direct_cb);
} else if(got_event) {
} else if(got_event){
// Handle the event
handle_event(event);
} else {
@ -459,7 +459,8 @@ struct CState: public State, public interface::Server
up_<interface::Thread> m_file_watch_thread;
CState():
m_compiler(rccpp::createCompiler(g_server_config.get<ss_>("compiler_command"))),
m_compiler(rccpp::createCompiler(
g_server_config.get<ss_>("compiler_command"))),
m_thread_pool(interface::thread_pool::createThreadPool())
{
m_thread_pool->start(4); // TODO: Configurable
@ -476,7 +477,8 @@ struct CState: public State, public interface::Server
m_compiler->include_directories.push_back(
g_server_config.get<ss_>("interface_path")+"/..");
m_compiler->include_directories.push_back(
g_server_config.get<ss_>("interface_path")+"/../../3rdparty/cereal/include");
g_server_config.get<ss_>(
"interface_path")+"/../../3rdparty/cereal/include");
m_compiler->include_directories.push_back(
g_server_config.get<ss_>("interface_path")+
"/../../3rdparty/polyvox/library/PolyVoxCore/include");
@ -874,7 +876,8 @@ struct CState: public State, public interface::Server
mc.get())
new_sublist.push_back(mc1);
else
log_v(MODULE, "Removing %s subscription to event %zu",
log_v(MODULE,
"Removing %s subscription to event %zu",
cs(module_name), type);
}
sublist = new_sublist;
@ -899,7 +902,8 @@ struct CState: public State, public interface::Server
" reference; unloading shared executable is probably unsafe",
cs(module_name));
// Drop reference to container
log_t(MODULE, "unload_module_u[%s]: Dropping container", cs(module_name));
log_t(MODULE, "unload_module_u[%s]: Dropping container",
cs(module_name));
mc.reset();
// Unload shared executable
log_t(MODULE, "unload_module_u[%s]: Unloading shared executable",
@ -1346,7 +1350,7 @@ void FileWatchThread::run(interface::Thread *thread)
{
interface::MutexScope ms(m_server->m_modules_mutex);
for(auto &pair : m_server->m_module_file_watches){
for(int fd: active_sockets){
for(int fd : active_sockets){
pair.second->report_fd(fd);
}
}