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

@ -251,7 +251,7 @@ bool PathExists(std::string path)
bool RecursiveDelete(std::string path)
{
/*
Execute the 'rm' command directly, by fork() and execve()
Execute the 'rm' command directly, by fork() and execve()
*/
std::cerr<<"Removing \""<<path<<"\""<<std::endl;
@ -274,7 +274,7 @@ bool RecursiveDelete(std::string path)
argv[3] = NULL;
std::cerr<<"Executing '"<<argv[0]<<"' '"<<argv[1]<<"' '"
<<argv[2]<<"'"<<std::endl;
<<argv[2]<<"'"<<std::endl;
execv(argv[0], argv);

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

@ -114,10 +114,10 @@ struct Module: public interface::Module, public client_file::Interface
const FileInfo &info = *pair.second.get();
if(info.path != ""){
file_restore_info.push_back(std::tuple<ss_, ss_, ss_>(
info.name, "", info.path));
info.name, "", info.path));
} else {
file_restore_info.push_back(std::tuple<ss_, ss_, ss_>(
info.name, info.content, ""));
info.name, info.content, ""));
}
}
@ -280,9 +280,9 @@ struct Module: public interface::Module, public client_file::Interface
std::ifstream f(path, std::ios::binary);
if(!f.good())
throw Exception("client_file::add_file_path(): Couldn't open \""+
name+"\" from \""+path+"\"");
name+"\" from \""+path+"\"");
std::string content((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
ss_ hash = interface::sha1::calculate(content);
log_v(MODULE, "File added: %s: %s (%s)", cs(name),
cs(interface::sha1::hex(hash)), cs(path));

View File

@ -10,7 +10,7 @@ namespace main_context
{
struct OpaqueSceneReference;
typedef OpaqueSceneReference* SceneReference;
};
}
namespace ground_plane_lighting
{
@ -36,7 +36,7 @@ namespace ground_plane_lighting
return server->access_module("ground_plane_lighting",
[&](interface::Module *module){
auto *iface = (ground_plane_lighting::Interface*)
module->check_interface();
module->check_interface();
cb(iface);
});
}

View File

@ -41,7 +41,7 @@ namespace std {
template<> struct hash<pv::Vector<2u, int16_t>>{
std::size_t operator()(const pv::Vector<2u, int16_t> &v) const {
return ((std::hash<int16_t>() (v.getX()) << 0) ^
(std::hash<int16_t>() (v.getY()) << 1));
(std::hash<int16_t>() (v.getY()) << 1));
}
};
@ -74,14 +74,14 @@ struct YSTSector
sector_p.getX() * sector_size.getX() + sector_size.getX() - 1,
0,
sector_p.getY() * sector_size.getY() + sector_size.getY() - 1
)))
)))
{
pv::Region region = volume->getEnclosingRegion();
auto lc = region.getLowerCorner();
auto uc = region.getUpperCorner();
/*log_v(MODULE, "YSTSector volume lc=" PV3I_FORMAT ", uc=" PV3I_FORMAT
", size=%zu", PV3I_PARAMS(lc), PV3I_PARAMS(uc),
volume->m_dataSize);*/
", size=%zu", PV3I_PARAMS(lc), PV3I_PARAMS(uc),
volume->m_dataSize);*/
for(int z = lc.getZ(); z <= uc.getZ(); z++){
for(int x = lc.getX(); x <= uc.getX(); x++){
volume->setVoxelAt(x, 0, z, INT_MIN);
@ -145,8 +145,8 @@ struct GlobalYSTMap
// Set sector dirty flag
auto it = std::lower_bound(m_dirty_sectors.begin(),
m_dirty_sectors.end(), sector,
std::greater<YSTSector*>()); // position in descending order
m_dirty_sectors.end(), sector,
std::greater<YSTSector*>()); // position in descending order
if(it == m_dirty_sectors.end() || *it != sector)
m_dirty_sectors.insert(it, sector);
}
@ -180,7 +180,7 @@ struct CInstance: public ground_plane_lighting::Instance
ivoxelworld->get_instance(m_scene_ref);
pv::Vector3DInt16 section_size = world->get_section_size_voxels();
pv::Vector<2, int16_t> sector_size(
section_size.getX(), section_size.getZ());
section_size.getX(), section_size.getZ());
m_global_yst.reset(new GlobalYSTMap(sector_size));
});
}
@ -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());
}
@ -287,7 +287,7 @@ struct CInstance: public ground_plane_lighting::Instance
interface::VoxelRegistry *voxel_reg = world->get_voxel_reg();
//const auto &chunk_size_voxels = world->get_chunk_size_voxels();
pv::Region chunk_region =
world->get_chunk_region_voxels(chunk_p);
world->get_chunk_region_voxels(chunk_p);
auto lc = chunk_region.getLowerCorner();
auto uc = chunk_region.getUpperCorner();
@ -302,7 +302,7 @@ struct CInstance: public ground_plane_lighting::Instance
int y = uc.getY();
for(;; y--){
VoxelInstance v = world->get_voxel(
pv::Vector3DInt32(x, y, z), true);
pv::Vector3DInt32(x, y, z), true);
if(v.get_id() == interface::VOXELTYPEID_UNDEFINED){
// NOTE: This leaves the chunks below unhandled;
// there would have to be some kind of a dirty
@ -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

@ -104,7 +104,7 @@ struct ResolveState
return true;
}
return set_error(ss_()+"Couldn't get module info for \""+name+"\""+
(log_extra_info == "" ? "" : ss_()+" ("+log_extra_info+")"));
(log_extra_info == "" ? "" : ss_()+" ("+log_extra_info+")"));
}
m_required_modules.insert(name);
@ -150,7 +150,7 @@ struct ResolveState
{
if(m_promised_modules.count(name)){
throw Exception(ss_()+"Logic error in ResolveState: "
"load_module(\""+name+"\"): already promised");
"load_module(\""+name+"\"): already promised");
}
log_d(MODULE, "Marking \"%s\" to be loaded", cs(name));
m_module_load_order.push_back(name);
@ -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){
@ -329,7 +329,7 @@ struct Module: public interface::Module, public loader::Interface
log_t(MODULE, "%s: Opened", cs(meta_path));
}
std::string meta_content((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
log_t(MODULE, "%s: File length: %zu", cs(meta_path),
meta_content.size());
json::json_error_t json_error;

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
@ -77,7 +77,7 @@ struct Module: public interface::Module, public main_context::Interface
sm_<SceneReference, up_<OpaqueSceneReference>> m_scenes;
sm_<Event::Type, SharedPtr<
interface::MagicEventHandler>> m_magic_event_handlers;
interface::MagicEventHandler>> m_magic_event_handlers;
Module(interface::Server *server):
interface::Module(MODULE),
@ -113,7 +113,7 @@ struct Module: public interface::Module, public main_context::Interface
sv_<ss_> resource_paths = {
server_config.get<ss_>("urho3d_path")+"/Bin/CoreData",
server_config.get<ss_>("urho3d_path")+"/Bin/Data",
server_config.get<ss_>("urho3d_path")+"/Bin/Data",
};
ss_ resource_paths_s;
for(const ss_ &path : resource_paths){

View File

@ -144,7 +144,7 @@ struct Module: public interface::Module, public network::Interface
for(auto &pair : m_peers){
Peer &peer = pair.second;
peer_restore_info.push_back(std::tuple<Peer::Id, int>(
peer.id, peer.socket->fd()));
peer.id, peer.socket->fd()));
}
std::ostringstream os(std::ios::binary);

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
@ -387,7 +389,7 @@ struct Module: public interface::Module, public replicate::Interface
// Handle changed or removed components
magic::HashMap<unsigned, magic::ComponentReplicationState>
&component_states = node_state.componentStates_;
&component_states = node_state.componentStates_;
for(auto it = component_states.Begin(); it != component_states.End();){
auto current_it = it++;
uint component_id = current_it->first_;
@ -448,7 +450,7 @@ struct Module: public interface::Module, public replicate::Interface
// Handle new components
if(component_states.Size() != node->GetNumNetworkComponents()){
const magic::Vector<magic::SharedPtr<Component>>
&components = node->GetComponents();
&components = node->GetComponents();
for(uint i = 0; i<components.Size(); i++){
Component *component = components[i];
if(component->GetID() >= magic::FIRST_LOCAL_ID)
@ -488,14 +490,14 @@ struct Module: public interface::Module, public replicate::Interface
/*void send_to_all(const ss_ &name, const magic::VectorBuffer &buf)
{
log_i(MODULE, "%s: Update size: %zu, data=%s",
cs(name), buf.GetBuffer().Size(), cs(dump(buf)));
ss_ data = buf_to_string(buf);
network::access(m_server, [&](network::Interface * inetwork){
auto peers = inetwork->list_peers();
for(auto &peer : peers)
inetwork->send(peer, name, data);
});
log_i(MODULE, "%s: Update size: %zu, data=%s",
cs(name), buf.GetBuffer().Size(), cs(dump(buf)));
ss_ data = buf_to_string(buf);
network::access(m_server, [&](network::Interface * inetwork){
auto peers = inetwork->list_peers();
for(auto &peer : peers)
inetwork->send(peer, name, data);
});
}*/
// Interface
@ -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

@ -103,8 +103,8 @@ struct Section
contained_chunks(contained_chunks),
node_ids(new pv::RawVolume<uint32_t>(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
@ -132,7 +132,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;
}
@ -336,7 +336,7 @@ struct CInstance: public voxelworld::Instance
const PODVector<unsigned char> &rawbuf = var.GetBuffer();
ss_ data((const char*)&rawbuf[0], rawbuf.Size());
up_<pv::RawVolume<VoxelInstance>> volume =
interface::deserialize_volume(data);
interface::deserialize_volume(data);
// Update collision shape
interface::mesh::set_voxel_physics_boxes(n, context, *volume,
m_voxel_reg.get());
@ -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);
}
@ -529,7 +529,7 @@ struct CInstance: public voxelworld::Instance
Zone *node_zone = n->CreateComponent<Zone>();
node_zone->SetPriority(-1000);
node_zone->SetBoundingBox(BoundingBox(
Vector3(-w/2, -h/2, -d/2), Vector3(w/2, h/2, d/2)));
Vector3(-w/2, -h/2, -d/2), Vector3(w/2, h/2, d/2)));
n->SetScale(Vector3(1.0f, 1.0f, 1.0f));
n->SetPosition(node_p);
@ -555,7 +555,7 @@ struct CInstance: public voxelworld::Instance
ss_ data = interface::serialize_volume_compressed(*volume);
n->SetVar(StringHash("buildat_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(), data.size())));
PODVector<uint8_t>((const uint8_t*)data.c_str(), data.size())));
run_commit_hooks_in_scene(chunk_p, n);
@ -616,8 +616,8 @@ struct CInstance: public voxelworld::Instance
{
QueuedNodePhysicsUpdate update(node_id);
auto it = std::lower_bound(m_nodes_needing_physics_update.begin(),
m_nodes_needing_physics_update.end(), update,
std::greater<QueuedNodePhysicsUpdate>());
m_nodes_needing_physics_update.end(), update,
std::greater<QueuedNodePhysicsUpdate>());
if(it == m_nodes_needing_physics_update.end()){
m_nodes_needing_physics_update.insert(it, update);
} else if(it->node_id != node_id){
@ -786,13 +786,13 @@ struct CInstance: public voxelworld::Instance
const PODVector<unsigned char> &buf = var.GetBuffer();
ss_ data((const char*)&buf[0], buf.Size());
up_<pv::RawVolume<VoxelInstance>> volume =
interface::deserialize_volume(data);
interface::deserialize_volume(data);
pv::Vector3DInt32 voxel_p(
p.getX() - chunk_p.getX() * m_chunk_size_voxels.getX(),
p.getY() - chunk_p.getY() * m_chunk_size_voxels.getY(),
p.getZ() - chunk_p.getZ() * m_chunk_size_voxels.getZ()
);
p.getX() - chunk_p.getX() * m_chunk_size_voxels.getX(),
p.getY() - chunk_p.getY() * m_chunk_size_voxels.getY(),
p.getZ() - chunk_p.getZ() * m_chunk_size_voxels.getZ()
);
log_t(MODULE, "set_voxel_direct() p=" PV3I_FORMAT ", v=%i: "
"Chunk " PV3I_FORMAT " in section " PV3I_FORMAT
"; internal position " PV3I_FORMAT,
@ -805,8 +805,8 @@ struct CInstance: public voxelworld::Instance
ss_ new_data = interface::serialize_volume_compressed(*volume);
n->SetVar(StringHash("buildat_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
run_commit_hooks_in_scene(chunk_p, n);
});
@ -823,7 +823,7 @@ struct CInstance: public voxelworld::Instance
{
// 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);
@ -842,7 +842,7 @@ struct CInstance: public voxelworld::Instance
// Set in buffer
ChunkBuffer &buf = section->get_buffer(chunk_p, m_server,
&m_total_buffers_loaded);
&m_total_buffers_loaded);
if(!buf.volume){
log_(disable_warnings ? CORE_DEBUG : CORE_WARNING,
MODULE, "set_voxel() p=" PV3I_FORMAT ", v=%i: Couldn't get "
@ -866,8 +866,8 @@ struct CInstance: public voxelworld::Instance
// 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<Section*>()); // position in descending order
m_sections_with_loaded_buffers.end(), section,
std::greater<Section*>()); // position in descending order
if(it == m_sections_with_loaded_buffers.end() || *it != section)
m_sections_with_loaded_buffers.insert(it, section);
}
@ -920,8 +920,8 @@ struct CInstance: public voxelworld::Instance
}
n->SetVar(StringHash("buildat_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
run_commit_hooks_in_scene(chunk_p, n);
});
@ -1000,7 +1000,7 @@ struct CInstance: public voxelworld::Instance
// Get from buffer
ChunkBuffer &buf = section->get_buffer(chunk_p, m_server,
&m_total_buffers_loaded);
&m_total_buffers_loaded);
if(!buf.volume){
log_(disable_warnings ? CORE_DEBUG : CORE_WARNING,
MODULE, "get_voxel() p=" PV3I_FORMAT ": Couldn't get "
@ -1018,8 +1018,8 @@ struct CInstance: public voxelworld::Instance
// 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<Section*>()); // position in descending order
m_sections_with_loaded_buffers.end(), section,
std::greater<Section*>()); // position in descending order
if(it == m_sections_with_loaded_buffers.end() || *it != section)
m_sections_with_loaded_buffers.insert(it, section);
@ -1152,7 +1152,7 @@ struct Module: public interface::Module, public voxelworld::Interface
// TODO
/*// Restore voxel registry and stuff
ss_ data = m_server->tmp_restore_data("voxelworld:restore_info");
ss_ data = m_server->tmp_restore_data("voxelworld:restore_info");
ss_ voxel_reg_data;
{
std::istringstream is(data, std::ios::binary);
@ -1162,7 +1162,7 @@ struct Module: public interface::Module, public voxelworld::Interface
m_voxel_reg->deserialize(voxel_reg_data);*/
// Start up normally
on_start();
on_start();
}
void on_tick(const interface::TickEvent &event)
@ -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){
@ -1197,7 +1197,7 @@ struct Module: public interface::Module, public voxelworld::Interface
/*// TODO: How should nodes be filtered for replication?
// TODO: Generally the client wants roughly one section, but isn't
// positioned at the middle of a section
void on_get_section(const network::Packet &packet)
void on_get_section(const network::Packet &packet)
{
pv::Vector3DInt16 section_p;
{
@ -1207,11 +1207,11 @@ struct Module: public interface::Module, public voxelworld::Interface
}
log_v(MODULE, "C%i: on_get_section(): " PV3I_FORMAT,
packet.sender, PV3I_PARAMS(section_p));
}*/
}*/
// Interface
// Interface
void create_instance(SceneReference scene_ref, const pv::Region &region)
void create_instance(SceneReference scene_ref, const pv::Region &region)
{
auto it = m_instances.find(scene_ref);
// TODO: Is an exception the best way to handle this?

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

@ -71,7 +71,7 @@ struct Worldgen: public worldgen::GeneratorInterface
ivoxelworld->get_instance(scene_ref);
pv::Region region = world->get_section_region_voxels(
section_p);
section_p);
auto lc = region.getLowerCorner();
auto uc = region.getUpperCorner();
@ -142,14 +142,14 @@ struct Worldgen: public worldgen::GeneratorInterface
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 = world->get_voxel(p);
if(v.get_id() != 1)
break;
}
y++;*/
/*int y = 50;
for(; y>-50; y--){
pv::Vector3DInt32 p(x, y, z);
VoxelInstance v = world->get_voxel(p);
if(v.get_id() != 1)
break;
}
y++;*/
size_t noise_i = (z-lc.getZ())*d + (x-lc.getX());
double a = noise.result[noise_i];
int y = a + 11.0;
@ -197,9 +197,9 @@ struct Module: public interface::Module
m_server->sub_event(this, Event::t("core:tick"));
m_server->sub_event(this, Event::t("client_file:files_transmitted"));
m_server->sub_event(this, Event::t(
"network:packet_received/main:place_voxel"));
"network:packet_received/main:place_voxel"));
m_server->sub_event(this, Event::t(
"network:packet_received/main:dig_voxel"));
"network:packet_received/main:dig_voxel"));
m_server->sub_event(this, Event::t("worldgen:queue_modified"));
}
@ -394,14 +394,14 @@ struct Module: public interface::Module
ResourceCache *cache = context->GetSubsystem<ResourceCache>();
interface::VoxelRegistry *voxel_reg =
instance->get_voxel_reg();
instance->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";
@ -412,8 +412,8 @@ struct Module: public interface::Module
}
n->SetVar(StringHash("simple_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(),
data.size())));
PODVector<uint8_t>((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));
@ -429,7 +429,7 @@ struct Module: public interface::Module
body->SetFriction(0.75f);
body->SetMass(1.0);
CollisionShape *shape =
n->CreateComponent<CollisionShape>(LOCAL);
n->CreateComponent<CollisionShape>(LOCAL);
shape->SetConvexHull(model, 0, Vector3::ONE);
//shape->SetTriangleMesh(model, 0, Vector3::ONE);
//shape->SetBox(Vector3::ONE);
@ -457,10 +457,10 @@ struct Module: public interface::Module
{
/*main_context::access(m_server, [&](main_context::Interface *imc)
{
Scene *scene = imc->check_scene(m_main_scene);
Node *n = scene->GetChild("Testbox");
auto p = n->GetPosition();
log_v(MODULE, "Testbox: (%f, %f, %f)", p.x_, p.y_, p.z_);
Scene *scene = imc->check_scene(m_main_scene);
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++) % 150) == 0){

View File

@ -81,13 +81,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<Texture2D>("main/green_texture.png"));*/
/*Material *m = new Material(context);
m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));
m->SetTechnique(0, cache->GetResource<Technique>(
"Techniques/Diff.xml"));*/
/*m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));*/
/*Material *m = new Material(context);
m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));
m->SetTechnique(0, cache->GetResource<Technique>(
"Techniques/Diff.xml"));*/
{
Node *node = scene->CreateChild("DirectionalLight");

View File

@ -85,14 +85,14 @@ 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";
// Crude way of dynamically defining a voxel model
n->SetVar(StringHash("simple_voxel_data"), Variant(
data.c_str()));
data.c_str()));
n->SetVar(StringHash("simple_voxel_w"), Variant(w));
n->SetVar(StringHash("simple_voxel_h"), Variant(h));
n->SetVar(StringHash("simple_voxel_d"), Variant(d));
@ -106,7 +106,7 @@ struct Module: public interface::Module
body->SetFriction(0.75f);
body->SetMass(1.0);
CollisionShape *shape = n->CreateComponent<CollisionShape>(
LOCAL);
LOCAL);
shape->SetConvexHull(model, 0, Vector3::ONE);
//shape->SetTriangleMesh(model, 0, Vector3::ONE);
//shape->SetBox(Vector3::ONE);
@ -137,21 +137,21 @@ struct Module: public interface::Module
int w = 10, h = 3, d = 10;
ss_ data =
"111111111100100000100000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100011000000001000000"
"111111111100011000000001000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
;
"111111111100100000100000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100011000000001000000"
"111111111100011000000001000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
"111111111100000000000000000000"
;
// Crude way of dynamically defining a voxel model
n->SetVar(StringHash("simple_voxel_data"), Variant(
data.c_str()));
data.c_str()));
n->SetVar(StringHash("simple_voxel_w"), Variant(w));
n->SetVar(StringHash("simple_voxel_h"), Variant(h));
n->SetVar(StringHash("simple_voxel_d"), Variant(d));
@ -164,7 +164,7 @@ struct Module: public interface::Module
RigidBody *body = n->CreateComponent<RigidBody>(LOCAL);
body->SetFriction(0.75f);
CollisionShape *shape = n->CreateComponent<CollisionShape>(
LOCAL);
LOCAL);
shape->SetTriangleMesh(model, 0, Vector3::ONE);
}
});

View File

@ -153,8 +153,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";
@ -166,8 +166,8 @@ struct Module: public interface::Module
// Crude way of dynamically defining a voxel model
n->SetVar(StringHash("simple_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(),
data.size())));
PODVector<uint8_t>((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));
@ -182,7 +182,7 @@ struct Module: public interface::Module
body->SetFriction(0.75f);
body->SetMass(1.0);
CollisionShape *shape = n->CreateComponent<CollisionShape>(
LOCAL);
LOCAL);
shape->SetConvexHull(model, 0, Vector3::ONE);
//shape->SetTriangleMesh(model, 0, Vector3::ONE);
//shape->SetBox(Vector3::ONE);
@ -214,17 +214,17 @@ struct Module: public interface::Module
int w = 10, h = 3, d = 10;
ss_ data =
"222222222211211111211111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211122111111112111111"
"222233222211123111111112111111"
"222233222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
;
"222222222211211111211111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211122111111112111111"
"222233222211123111111112111111"
"222233222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
;
// Convert data to the actually usable voxel type id namespace
// starting from VOXELTYPEID_UNDEFINED=0
@ -234,8 +234,8 @@ struct Module: public interface::Module
// Crude way of dynamically defining a voxel model
n->SetVar(StringHash("simple_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(),
data.size())));
PODVector<uint8_t>((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));
@ -249,7 +249,7 @@ struct Module: public interface::Module
RigidBody *body = n->CreateComponent<RigidBody>(LOCAL);
body->SetFriction(0.75f);
CollisionShape *shape = n->CreateComponent<CollisionShape>(
LOCAL);
LOCAL);
shape->SetTriangleMesh(model, 0, Vector3::ONE);
}
});

View File

@ -209,8 +209,8 @@ struct Module: public interface::Module
cs(packet.name), packet.data.size());
for(size_t y = 0; y < m_playfield.h; y++)
for(size_t x = 0; x < m_playfield.w; x++)
m_playfield.set(x, y, 0);
for(size_t x = 0; x < m_playfield.w; x++)
m_playfield.set(x, y, 0);
for(auto &pair : m_players)
send_update(pair.second.peer);

View File

@ -226,21 +226,18 @@ static void generate_compiler_binary_dir_alternatives(sv_<ss_> &roots)
PathDefinition server_paths[] = {
{PD_READ, "share_path",
"",
"/builtin/network/network.cpp",
"Static files"
},
"",
"/builtin/network/network.cpp",
"Static files"},
{PD_READ, "interface_path",
"/src/interface",
"/event.h",
"Interface files"
},
"/src/interface",
"/event.h",
"Interface files"},
{PD_WRITE, "rccpp_build_path",
"/cache/rccpp_build",
"/write.test",
"RCC++ build directory"
},
{PD_END, "", "", "", ""},
"/cache/rccpp_build",
"/write.test",
"RCC++ build directory"},
{PD_END, "", "", "", ""},
};
static bool detect_buildat_server_paths(core::Config &config)
@ -255,34 +252,32 @@ static bool detect_buildat_server_paths(core::Config &config)
// NOTE: For these, the root contains a trailing slash, and can be an empty string.
PathDefinition compiler_bin_paths[] = {
{PD_RUN, "compiler_command",
"c++",
" --version",
"Compiler command"
},
{PD_END, "", "", "", ""},
"c++",
" --version",
"Compiler command"},
{PD_END, "", "", "", ""},
};
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
PathDefinition client_paths[] = {
{PD_READ, "share_path",
"",
"/client/init.lua",
"Static files"
},
"",
"/client/init.lua",
"Static files"},
{PD_WRITE, "cache_path",
"/cache",
"/write.test",
"Cache directory"
},
{PD_END, "", "", "", ""},
"/cache",
"/write.test",
"Cache directory"},
{PD_END, "", "", "", ""},
};
static bool detect_buildat_client_paths(core::Config &config)
@ -296,11 +291,10 @@ static bool detect_buildat_client_paths(core::Config &config)
PathDefinition server_urho3d_paths[] = {
{PD_READ, "urho3d_path",
"",
"/Bin/CoreData/Shaders/GLSL/Basic.glsl",
"Urho3D path"
},
{PD_END, "", "", "", ""},
"",
"/Bin/CoreData/Shaders/GLSL/Basic.glsl",
"Urho3D path"},
{PD_END, "", "", "", ""},
};
static bool detect_server_urho3d_paths(core::Config &config)
@ -314,11 +308,10 @@ static bool detect_server_urho3d_paths(core::Config &config)
PathDefinition client_urho3d_paths[] = {
{PD_READ, "urho3d_path",
"",
"/Bin/CoreData/Shaders/GLSL/Basic.glsl",
"Urho3D path"
},
{PD_END, "", "", "", ""},
"",
"/Bin/CoreData/Shaders/GLSL/Basic.glsl",
"Urho3D path"},
{PD_END, "", "", "", ""},
};
static bool detect_client_urho3d_paths(core::Config &config)
@ -378,5 +371,6 @@ bool detect_client_paths(core::Config &config)
return ok;
}
}}
}
}
// vim: set noet ts=4 sw=4:

View File

@ -1,57 +1,58 @@
// http://www.apache.org/licenses/LICENSE-2.0
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
#pragma once
#include "core/types.h"
#include "boot/cmem.h"
#include "interface/debug.h"
#include "interface/os.h"
#ifdef _WIN32
#include "ports/windows_sockets.h"
#include "ports/windows_compat.h"
#else
#include <unistd.h>
#endif
void signal_handler_init();
namespace boot
{
struct BasicInitScope
{
BasicInitScope(){
boot::buildat_mem_libc_enable();
signal_handler_init();
// Force '.' as decimal point
try {
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");
}
setlocale(LC_NUMERIC, "C");
log_init();
log_set_max_level(CORE_VERBOSE);
interface::debug::SigConfig debug_sig_config;
interface::debug::init_signal_handlers(debug_sig_config);
srand(interface::os::time_us());
#ifdef _WIN32
WORD version_request = MAKEWORD(2, 2);
WSADATA wsa_data;
if(int err = WSAStartup(version_request, &wsa_data))
throw Exception("WSAStartup failed; err="+itos(err));
#endif
}
~BasicInitScope(){
#ifdef _WIN32
WSACleanup();
#endif
}
};
}
// vim: set noet ts=4 sw=4:
// http://www.apache.org/licenses/LICENSE-2.0
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
#pragma once
#include "core/types.h"
#include "boot/cmem.h"
#include "interface/debug.h"
#include "interface/os.h"
#ifdef _WIN32
#include "ports/windows_sockets.h"
#include "ports/windows_compat.h"
#else
#include <unistd.h>
#endif
void signal_handler_init();
namespace boot
{
struct BasicInitScope
{
BasicInitScope(){
boot::buildat_mem_libc_enable();
signal_handler_init();
// Force '.' as decimal point
try {
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");
}
setlocale(LC_NUMERIC, "C");
log_init();
log_set_max_level(CORE_VERBOSE);
interface::debug::SigConfig debug_sig_config;
interface::debug::init_signal_handlers(debug_sig_config);
srand(interface::os::time_us());
#ifdef _WIN32
WORD version_request = MAKEWORD(2, 2);
WSADATA wsa_data;
if(int err = WSAStartup(version_request, &wsa_data))
throw Exception("WSAStartup failed; err="+itos(err));
#endif
}
~BasicInitScope(){
#ifdef _WIN32
WSACleanup();
#endif
}
};
}
// vim: set noet ts=4 sw=4:

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"
@ -121,9 +121,9 @@ struct CApp: public App, public magic::Application
sv_<ss_> resource_paths = {
g_client_config.get<ss_>("cache_path")+"/tmp",
g_client_config.get<ss_>("share_path")+"/extensions", // Could be unsafe
g_client_config.get<ss_>("urho3d_path")+"/Bin/CoreData",
g_client_config.get<ss_>("urho3d_path")+"/Bin/Data",
g_client_config.get<ss_>("share_path")+"/extensions", // Could be unsafe
g_client_config.get<ss_>("urho3d_path")+"/Bin/CoreData",
g_client_config.get<ss_>("urho3d_path")+"/Bin/Data",
};
ss_ resource_paths_s;
for(const ss_ &path : resource_paths){
@ -278,8 +278,8 @@ struct CApp: public App, public magic::Application
/*lua_getfield(L, LUA_GLOBALSINDEX, "__buildat_file_updated_in_cache");
if(lua_isnil(L, -1)){
lua_pop(L, 1);
return;
lua_pop(L, 1);
return;
}
lua_pushlstring(L, file_name.c_str(), file_name.size());
lua_pushlstring(L, file_hash.c_str(), file_hash.size());
@ -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",
@ -366,14 +367,14 @@ struct CApp: public App, public magic::Application
if(g_client_config.get<bool>("boot_to_menu")){
ss_ extname = g_client_config.get<ss_>("menu_extension_name");
ss_ script = ss_() +
"local m = require('buildat/extension/"+extname+"')\n"
"local m = require('buildat/extension/"+extname+"')\n"
"if type(m) ~= 'table' then\n"
" error('Failed to load extension "+extname+"')\n"
"end\n"
"m.boot()\n";
if(!run_script_no_sandbox(script)){
throw AppStartupError(ss_()+
"Failed to load and run extension "+extname);
"Failed to load and run extension "+extname);
}
}
@ -381,13 +382,13 @@ struct CApp: public App, public magic::Application
magic::ResourceCache *magic_cache = GetSubsystem<magic::ResourceCache>();
magic::DebugHud *dhud = GetSubsystem<magic::Engine>()->CreateDebugHud();
dhud->SetDefaultStyle(magic_cache->GetResource<magic::XMLFile>(
"UI/DefaultStyle.xml"));
"UI/DefaultStyle.xml"));
}
void on_update(magic::StringHash event_type, magic::VariantMap &event_data)
{
/*magic::AutoProfileBlock profiler_block(
GetSubsystem<magic::Profiler>(), "App::on_update");*/
GetSubsystem<magic::Profiler>(), "App::on_update");*/
if(g_sigint_received)
shutdown();
@ -439,7 +440,7 @@ struct CApp: public App, public magic::Application
if(key == Urho3D::KEY_F10){
ss_ extname = "sandbox_test";
ss_ script = ss_() +
"local m = require('buildat/extension/"+extname+"')\n"
"local m = require('buildat/extension/"+extname+"')\n"
"if type(m) ~= 'table' then\n"
" error('Failed to load extension "+extname+"')\n"
"end\n"
@ -601,8 +602,8 @@ struct CApp: public App, public magic::Application
lua_pop(L, 1);
const char *msg =
r == LUA_ERRRUN ? "runtime error" :
r == LUA_ERRMEM ? "ran out of memory" :
r == LUA_ERRERR ? "error handler failed" : "unknown error";
r == LUA_ERRMEM ? "ran out of memory" :
r == LUA_ERRERR ? "error handler failed" : "unknown error";
//log_e(MODULE, "Lua %s: %s", msg, cs(traceback));
throw Exception(ss_()+"Lua "+msg+":\n"+traceback);
}

View File

@ -52,7 +52,7 @@ int main(int argc, char *argv[])
" -l [level number] Set maximum log level (0...5)\n"
" -L [log file path] Append log to a specified file\n"
" -m [name] Choose menu extension name\n"
;
;
int c;
while((c = c55_getopt(argc, argv, opts)) != -1)

View File

@ -172,7 +172,7 @@ struct CState: public State
if(!f.good())
throw Exception(ss_()+"Could not open file: "+path);
std::string file_content((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
ss_ file_hash2 = interface::sha1::calculate(file_content);
if(file_hash != file_hash2){
log_e(MODULE, "Opened file differs in hash: \"%s\": "
@ -251,7 +251,7 @@ void CState::setup_packet_handlers()
m_file_hashes[file_name] = file_hash;
ss_ file_hash_hex = interface::sha1::hex(file_hash);
log_v(MODULE, "Server announces file: %s %s",
cs(file_hash_hex), cs(file_name));
cs(file_hash_hex), cs(file_name));
// Check if we already have this file
ss_ path = m_remote_cache_path+"/"+file_hash_hex;
std::ifstream ifs(path, std::ios::binary);
@ -263,13 +263,13 @@ void CState::setup_packet_handlers()
if(content_hash == file_hash){
// We have it; no need to ask this file
log_i(MODULE, "%s %s: cached",
cs(file_hash_hex), cs(file_name));
cs(file_hash_hex), cs(file_name));
cached_is_ok = true;
} else {
// Our copy is broken, re-request it
log_i(MODULE, "%s %s: Our copy is broken (has hash %s)",
cs(file_hash_hex), cs(file_name),
cs(interface::sha1::hex(content_hash)));
cs(file_hash_hex), cs(file_name),
cs(interface::sha1::hex(content_hash)));
}
}
if(cached_is_ok){
@ -279,7 +279,7 @@ void CState::setup_packet_handlers()
} else {
// We don't have it; request this file
log_i(MODULE, "%s %s: requesting",
cs(file_hash_hex), cs(file_name));
cs(file_hash_hex), cs(file_name));
std::ostringstream os(std::ios::binary);
{
cereal::PortableBinaryOutputArchive ar(os);
@ -316,20 +316,21 @@ void CState::setup_packet_handlers()
}
if(m_waiting_files.count(file_name) == 0){
log_w(MODULE, "Received file was not requested: %s %s",
cs(interface::sha1::hex(file_hash)), cs(file_name));
cs(interface::sha1::hex(file_hash)), cs(file_name));
return;
}
m_waiting_files.erase(file_name);
ss_ file_hash2 = interface::sha1::calculate(file_content);
if(file_hash != file_hash2){
log_w(MODULE, "Requested file differs in hash: \"%s\": "
"requested %s, actual %s", cs(file_name),
cs(interface::sha1::hex(file_hash)),
cs(interface::sha1::hex(file_hash2)));
"requested %s, actual %s", cs(file_name),
cs(interface::sha1::hex(file_hash)),
cs(interface::sha1::hex(file_hash2)));
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;
@ -358,11 +359,11 @@ void CState::setup_packet_handlers()
// This is the scene
} else if(node){
log_w(MODULE, "replicate:create_node: Node %i (old name=\"%s\")"
" already exists. This could be due to a node having been"
" accidentally created on the client side without mode=LOCAL."
" If a node seems to mysteriously disappear, this is the"
" reason.",
node_id, node->GetName().CString());
" already exists. This could be due to a node having been"
" accidentally created on the client side without mode=LOCAL."
" If a node seems to mysteriously disappear, this is the"
" reason.",
node_id, node->GetName().CString());
} else {
log_v(MODULE, "Creating node %i", node_id);
// Add to the root level; it may be moved as we receive the parent
@ -397,11 +398,11 @@ void CState::setup_packet_handlers()
if(!c || c->GetType() != type || c->GetNode() != node){
if(c){
log_w(MODULE, "replicate:create_node: Component %i already"
" exists. This could be due to a component having"
" been accidentally created on the client side"
" without mode=LOCAL."
" If a component seems to mysteriously disappear,"
" this is the reason.", c_id);
" exists. This could be due to a component having"
" been accidentally created on the client side"
" without mode=LOCAL."
" If a component seems to mysteriously disappear,"
" this is the reason.", c_id);
c->Remove();
}
log_v(MODULE, "Creating component %i", c_id);
@ -503,7 +504,7 @@ void CState::setup_packet_handlers()
m_packet_handlers[""] =
[this](const ss_ &packet_name, const ss_ &data)
{
};
};
}
State* createState(sp_<app::App> app)

View File

@ -17,7 +17,7 @@ namespace core
{}
template<typename T>
void set_default(const ss_ &name, const T &native_v)
void set_default(const ss_ &name, const T &native_v)
{
json::Value new_v(native_v);
@ -33,7 +33,7 @@ namespace core
}
template<typename T>
void set(const ss_ &name, const T &native_v)
void set(const ss_ &name, const T &native_v)
{
json::Value new_v(native_v);
@ -49,7 +49,7 @@ namespace core
}
template<typename T>
const T& get(const ss_ &name) const
const T& get(const ss_ &name) const
{
const json::Value &current_v = values.get(name);
if(current_v.is_undefined()){

View File

@ -136,12 +136,12 @@ static void print(int level, const char *sys, const char *fmt, va_list va_args)
timestr[0] = 0;
} else {
size_t timestr_len = strftime(timestr, sizeof(timestr),
"%b %d %H:%M:%S", localtime(&now));
"%b %d %H:%M:%S", localtime(&now));
if(timestr_len == 0)
timestr[0] = '\0';
int ms = (get_timeofday_us() % 1000000) / 1000;
timestr_len += snprintf(timestr + timestr_len,
sizeof(timestr) - timestr_len, ".%03i", ms);
sizeof(timestr) - timestr_len, ".%03i", ms);
}
char sysstr[9];
snprintf(sysstr, 9, "%s ", sys);

View File

@ -103,8 +103,8 @@ namespace sajson {
class string {
public:
string(const char *text, size_t length)
: text(text)
, _length(length)
: text(text)
, _length(length)
{}
const char* data() const {
@ -129,7 +129,7 @@ namespace sajson {
class literal: public string {
public:
explicit literal(const char *text)
: string(text, strlen(text))
: string(text, strlen(text))
{}
};
@ -143,7 +143,7 @@ namespace sajson {
struct object_key_comparator
{
object_key_comparator(const char *object_data)
: data(object_data)
: data(object_data)
{
}
@ -173,7 +173,7 @@ namespace sajson {
return false;
}
return memcmp(data + lhs.key_start, data + rhs.key_start,
lhs_length) < 0;
lhs_length) < 0;
}
const char *data;
@ -182,11 +182,11 @@ namespace sajson {
class refcount {
public:
refcount()
: pn(new size_t(1))
: pn(new size_t(1))
{}
refcount(const refcount &rc)
: pn(rc.pn)
: pn(rc.pn)
{
++*pn;
}
@ -210,19 +210,19 @@ namespace sajson {
class mutable_string_view {
public:
mutable_string_view()
: length(0)
, data(0)
: length(0)
, data(0)
{}
mutable_string_view(const literal &s)
: length(s.length())
: length(s.length())
{
data = new char[length];
memcpy(data, s.data(), length);
}
mutable_string_view(const string &s)
: length(s.length())
: length(s.length())
{
data = new char[length];
memcpy(data, s.data(), length);
@ -295,9 +295,9 @@ namespace sajson {
class value {
public:
explicit value(type value_type, const size_t *payload, const char *text)
: value_type(value_type)
, payload(payload)
, text(text)
: value_type(value_type)
, payload(payload)
, text(text)
{}
type get_type() const {
@ -313,8 +313,8 @@ namespace sajson {
value get_array_element(size_t index) const {
size_t element = payload[1 + index];
return value(get_element_type(element), payload +
get_element_value(element),
text);
get_element_value(element),
text);
}
// valid iff get_type() is TYPE_OBJECT
@ -327,8 +327,8 @@ namespace sajson {
value get_object_value(size_t index) const {
size_t element = payload[3 + index * 3];
return value(get_element_type(element), payload +
get_element_value(element),
text);
get_element_value(element),
text);
}
@ -340,11 +340,11 @@ namespace sajson {
(payload + 1);
const object_key_record *end = start + get_length();
const object_key_record *i = std::lower_bound(start, end, key,
object_key_comparator(text));
object_key_comparator(text));
return (i != end
&& (i->key_end - i->key_start) == key.length()
&& memcmp(key.data(), text + i->key_start,
key.length()) == 0) ? i - start : get_length();
&& (i->key_end - i->key_start) == key.length()
&& memcmp(key.data(), text + i->key_start,
key.length()) == 0) ? i - start : get_length();
}
// valid iff get_type() is TYPE_INTEGER
@ -391,13 +391,13 @@ namespace sajson {
type root_type, const size_t *root, size_t error_line,
size_t error_column,
const std::string &error_message)
: input(input)
, structure(structure)
, root_type(root_type)
, root(root)
, error_line(error_line)
, error_column(error_column)
, error_message(error_message)
: input(input)
, structure(structure)
, root_type(root_type)
, root(root)
, error_line(error_line)
, error_column(error_column)
, error_message(error_message)
{}
~document(){
@ -437,25 +437,25 @@ namespace sajson {
class parser {
public:
parser(const mutable_string_view &msv, size_t *structure)
: input(msv)
, input_end(input.get_data() + input.get_length())
, structure(structure)
, p(input.get_data())
, temp(structure)
, root_type(TYPE_NULL)
, out(structure + input.get_length())
, error_line(0)
, error_column(0)
: input(msv)
, input_end(input.get_data() + input.get_length())
, structure(structure)
, p(input.get_data())
, temp(structure)
, root_type(TYPE_NULL)
, out(structure + input.get_length())
, error_line(0)
, error_column(0)
{}
document get_document(){
if(parse()){
return document(input, structure, root_type, out, 0, 0,
std::string());
std::string());
} else {
delete[] structure;
return document(input, 0, TYPE_NULL, 0, error_line, error_column,
error_message);
error_message);
}
}
@ -468,12 +468,12 @@ namespace sajson {
struct parse_result {
parse_result(error_result)
: success(false)
: success(false)
{}
parse_result(type t)
: success(true)
, value_type(t)
: success(true)
, value_type(t)
{}
bool operator!() const {
@ -534,8 +534,8 @@ namespace sajson {
} else if(c == 't'){
current_structure_type = TYPE_TRUE;
/*} else if(c == 'u' && input.get_length() == 9 &&
strncmp(input.get_data(), "undefined", 9) == 0){
return true;*/
strncmp(input.get_data(), "undefined", 9) == 0){
return true;*/
} else {
return error("document root must be a json value");
}
@ -603,13 +603,13 @@ namespace sajson {
}
if(current_structure_type == TYPE_OBJECT && c != '}'){
if(c != '"'){
return error("object key must be quoted");
}
if(c != '"'){
return error("object key must be quoted");
}
result = parse_string(temp);
if(peek_structure() != ':'){
return error("expected :");
}
if(peek_structure() != ':'){
return error("expected :");
}
++p;
temp += 2;
}
@ -652,12 +652,12 @@ namespace sajson {
case '{':
next_type = TYPE_OBJECT;
goto push;
push: {
push: {
++p;
size_t *previous_base = current_base;
current_base = temp;
*temp++ = make_element(current_structure_type,
previous_base - structure);
previous_base - structure);
current_structure_type = next_type;
continue;
}
@ -676,7 +676,7 @@ namespace sajson {
} else {
return error("expected ]");
}
pop: {
pop: {
++p;
size_t element = *current_base;
result = (this->*structure_installer)(current_base + 1);
@ -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 {
@ -765,115 +765,115 @@ done:
}
static const double constants[] = {
1e-323, 1e-322, 1e-321, 1e-320, 1e-319, 1e-318, 1e-317, 1e-316,
1e-315, 1e-314,
1e-313, 1e-312, 1e-311, 1e-310, 1e-309, 1e-308, 1e-307, 1e-306,
1e-305, 1e-304,
1e-303, 1e-302, 1e-301, 1e-300, 1e-299, 1e-298, 1e-297, 1e-296,
1e-295, 1e-294,
1e-293, 1e-292, 1e-291, 1e-290, 1e-289, 1e-288, 1e-287, 1e-286,
1e-285, 1e-284,
1e-283, 1e-282, 1e-281, 1e-280, 1e-279, 1e-278, 1e-277, 1e-276,
1e-275, 1e-274,
1e-273, 1e-272, 1e-271, 1e-270, 1e-269, 1e-268, 1e-267, 1e-266,
1e-265, 1e-264,
1e-263, 1e-262, 1e-261, 1e-260, 1e-259, 1e-258, 1e-257, 1e-256,
1e-255, 1e-254,
1e-253, 1e-252, 1e-251, 1e-250, 1e-249, 1e-248, 1e-247, 1e-246,
1e-245, 1e-244,
1e-243, 1e-242, 1e-241, 1e-240, 1e-239, 1e-238, 1e-237, 1e-236,
1e-235, 1e-234,
1e-233, 1e-232, 1e-231, 1e-230, 1e-229, 1e-228, 1e-227, 1e-226,
1e-225, 1e-224,
1e-223, 1e-222, 1e-221, 1e-220, 1e-219, 1e-218, 1e-217, 1e-216,
1e-215, 1e-214,
1e-213, 1e-212, 1e-211, 1e-210, 1e-209, 1e-208, 1e-207, 1e-206,
1e-205, 1e-204,
1e-203, 1e-202, 1e-201, 1e-200, 1e-199, 1e-198, 1e-197, 1e-196,
1e-195, 1e-194,
1e-193, 1e-192, 1e-191, 1e-190, 1e-189, 1e-188, 1e-187, 1e-186,
1e-185, 1e-184,
1e-183, 1e-182, 1e-181, 1e-180, 1e-179, 1e-178, 1e-177, 1e-176,
1e-175, 1e-174,
1e-173, 1e-172, 1e-171, 1e-170, 1e-169, 1e-168, 1e-167, 1e-166,
1e-165, 1e-164,
1e-163, 1e-162, 1e-161, 1e-160, 1e-159, 1e-158, 1e-157, 1e-156,
1e-155, 1e-154,
1e-153, 1e-152, 1e-151, 1e-150, 1e-149, 1e-148, 1e-147, 1e-146,
1e-145, 1e-144,
1e-143, 1e-142, 1e-141, 1e-140, 1e-139, 1e-138, 1e-137, 1e-136,
1e-135, 1e-134,
1e-133, 1e-132, 1e-131, 1e-130, 1e-129, 1e-128, 1e-127, 1e-126,
1e-125, 1e-124,
1e-123, 1e-122, 1e-121, 1e-120, 1e-119, 1e-118, 1e-117, 1e-116,
1e-115, 1e-114,
1e-113, 1e-112, 1e-111, 1e-110, 1e-109, 1e-108, 1e-107, 1e-106,
1e-105, 1e-104,
1e-103, 1e-102, 1e-101, 1e-100, 1e-99, 1e-98, 1e-97, 1e-96, 1e-95,
1e-94, 1e-93,
1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83,
1e-82, 1e-81,
1e-80, 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71,
1e-70, 1e-69,
1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59,
1e-58, 1e-57,
1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47,
1e-46, 1e-45,
1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35,
1e-34, 1e-33,
1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23,
1e-22, 1e-21,
1e-20, 1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11,
1e-10, 1e-9,
1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3,
1e4, 1e5, 1e6, 1e7,
1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1e20, 1e21,
1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, 1e30, 1e31, 1e32,
1e33, 1e34, 1e35,
1e36, 1e37, 1e38, 1e39, 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46,
1e47, 1e48, 1e49,
1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, 1e60,
1e61, 1e62, 1e63,
1e64, 1e65, 1e66, 1e67, 1e68, 1e69, 1e70, 1e71, 1e72, 1e73, 1e74,
1e75, 1e76, 1e77,
1e78, 1e79, 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88,
1e89, 1e90, 1e91,
1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99, 1e100, 1e101, 1e102,
1e103, 1e104,
1e105, 1e106, 1e107, 1e108, 1e109, 1e110, 1e111, 1e112, 1e113, 1e114,
1e115, 1e116,
1e117, 1e118, 1e119, 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126,
1e127, 1e128,
1e129, 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138,
1e139, 1e140,
1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, 1e150,
1e151, 1e152,
1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, 1e160, 1e161, 1e162,
1e163, 1e164,
1e165, 1e166, 1e167, 1e168, 1e169, 1e170, 1e171, 1e172, 1e173, 1e174,
1e175, 1e176,
1e177, 1e178, 1e179, 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186,
1e187, 1e188,
1e189, 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198,
1e199, 1e200,
1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209, 1e210,
1e211, 1e212,
1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219, 1e220, 1e221, 1e222,
1e223, 1e224,
1e225, 1e226, 1e227, 1e228, 1e229, 1e230, 1e231, 1e232, 1e233, 1e234,
1e235, 1e236,
1e237, 1e238, 1e239, 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246,
1e247, 1e248,
1e249, 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258,
1e259, 1e260,
1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269, 1e270,
1e271, 1e272,
1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279, 1e280, 1e281, 1e282,
1e283, 1e284,
1e285, 1e286, 1e287, 1e288, 1e289, 1e290, 1e291, 1e292, 1e293, 1e294,
1e295, 1e296,
1e297, 1e298, 1e299, 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306,
1e307, 1e308
1e-315, 1e-314,
1e-313, 1e-312, 1e-311, 1e-310, 1e-309, 1e-308, 1e-307, 1e-306,
1e-305, 1e-304,
1e-303, 1e-302, 1e-301, 1e-300, 1e-299, 1e-298, 1e-297, 1e-296,
1e-295, 1e-294,
1e-293, 1e-292, 1e-291, 1e-290, 1e-289, 1e-288, 1e-287, 1e-286,
1e-285, 1e-284,
1e-283, 1e-282, 1e-281, 1e-280, 1e-279, 1e-278, 1e-277, 1e-276,
1e-275, 1e-274,
1e-273, 1e-272, 1e-271, 1e-270, 1e-269, 1e-268, 1e-267, 1e-266,
1e-265, 1e-264,
1e-263, 1e-262, 1e-261, 1e-260, 1e-259, 1e-258, 1e-257, 1e-256,
1e-255, 1e-254,
1e-253, 1e-252, 1e-251, 1e-250, 1e-249, 1e-248, 1e-247, 1e-246,
1e-245, 1e-244,
1e-243, 1e-242, 1e-241, 1e-240, 1e-239, 1e-238, 1e-237, 1e-236,
1e-235, 1e-234,
1e-233, 1e-232, 1e-231, 1e-230, 1e-229, 1e-228, 1e-227, 1e-226,
1e-225, 1e-224,
1e-223, 1e-222, 1e-221, 1e-220, 1e-219, 1e-218, 1e-217, 1e-216,
1e-215, 1e-214,
1e-213, 1e-212, 1e-211, 1e-210, 1e-209, 1e-208, 1e-207, 1e-206,
1e-205, 1e-204,
1e-203, 1e-202, 1e-201, 1e-200, 1e-199, 1e-198, 1e-197, 1e-196,
1e-195, 1e-194,
1e-193, 1e-192, 1e-191, 1e-190, 1e-189, 1e-188, 1e-187, 1e-186,
1e-185, 1e-184,
1e-183, 1e-182, 1e-181, 1e-180, 1e-179, 1e-178, 1e-177, 1e-176,
1e-175, 1e-174,
1e-173, 1e-172, 1e-171, 1e-170, 1e-169, 1e-168, 1e-167, 1e-166,
1e-165, 1e-164,
1e-163, 1e-162, 1e-161, 1e-160, 1e-159, 1e-158, 1e-157, 1e-156,
1e-155, 1e-154,
1e-153, 1e-152, 1e-151, 1e-150, 1e-149, 1e-148, 1e-147, 1e-146,
1e-145, 1e-144,
1e-143, 1e-142, 1e-141, 1e-140, 1e-139, 1e-138, 1e-137, 1e-136,
1e-135, 1e-134,
1e-133, 1e-132, 1e-131, 1e-130, 1e-129, 1e-128, 1e-127, 1e-126,
1e-125, 1e-124,
1e-123, 1e-122, 1e-121, 1e-120, 1e-119, 1e-118, 1e-117, 1e-116,
1e-115, 1e-114,
1e-113, 1e-112, 1e-111, 1e-110, 1e-109, 1e-108, 1e-107, 1e-106,
1e-105, 1e-104,
1e-103, 1e-102, 1e-101, 1e-100, 1e-99, 1e-98, 1e-97, 1e-96, 1e-95,
1e-94, 1e-93,
1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83,
1e-82, 1e-81,
1e-80, 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71,
1e-70, 1e-69,
1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 1e-59,
1e-58, 1e-57,
1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47,
1e-46, 1e-45,
1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 1e-39, 1e-38, 1e-37, 1e-36, 1e-35,
1e-34, 1e-33,
1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23,
1e-22, 1e-21,
1e-20, 1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11,
1e-10, 1e-9,
1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3,
1e4, 1e5, 1e6, 1e7,
1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1e20, 1e21,
1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, 1e30, 1e31, 1e32,
1e33, 1e34, 1e35,
1e36, 1e37, 1e38, 1e39, 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46,
1e47, 1e48, 1e49,
1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, 1e60,
1e61, 1e62, 1e63,
1e64, 1e65, 1e66, 1e67, 1e68, 1e69, 1e70, 1e71, 1e72, 1e73, 1e74,
1e75, 1e76, 1e77,
1e78, 1e79, 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88,
1e89, 1e90, 1e91,
1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99, 1e100, 1e101, 1e102,
1e103, 1e104,
1e105, 1e106, 1e107, 1e108, 1e109, 1e110, 1e111, 1e112, 1e113, 1e114,
1e115, 1e116,
1e117, 1e118, 1e119, 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126,
1e127, 1e128,
1e129, 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138,
1e139, 1e140,
1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, 1e150,
1e151, 1e152,
1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, 1e160, 1e161, 1e162,
1e163, 1e164,
1e165, 1e166, 1e167, 1e168, 1e169, 1e170, 1e171, 1e172, 1e173, 1e174,
1e175, 1e176,
1e177, 1e178, 1e179, 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186,
1e187, 1e188,
1e189, 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198,
1e199, 1e200,
1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209, 1e210,
1e211, 1e212,
1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219, 1e220, 1e221, 1e222,
1e223, 1e224,
1e225, 1e226, 1e227, 1e228, 1e229, 1e230, 1e231, 1e232, 1e233, 1e234,
1e235, 1e236,
1e237, 1e238, 1e239, 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246,
1e247, 1e248,
1e249, 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258,
1e259, 1e260,
1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269, 1e270,
1e271, 1e272,
1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279, 1e280, 1e281, 1e282,
1e283, 1e284,
1e285, 1e286, 1e287, 1e288, 1e289, 1e290, 1e291, 1e292, 1e293, 1e294,
1e295, 1e296,
1e297, 1e298, 1e299, 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306,
1e307, 1e308
};
return constants[exponent + 323];
}
@ -1186,11 +1186,11 @@ done:
case 't':
replacement = '\t';
goto replace;
replace:
replace:
*end++ = replacement;
++p;
break;
case 'u': {
case 'u': {
++p;
if(SAJSON_UNLIKELY(!has_remaining_characters(4))){
return error("unexpected end of input h");
@ -1204,7 +1204,7 @@ replace:
if(u >= 0xD800 && u <= 0xDBFF){
if(SAJSON_UNLIKELY(!has_remaining_characters(6))){
return error(
"unexpected end of input during UTF-16 surrogate pair");
"unexpected end of input during UTF-16 surrogate pair");
}
char p0 = p[0];
char p1 = p[1];

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

@ -43,8 +43,8 @@ struct CAtlasRegistry: public AtlasRegistry
segment_def.resource_name.c_str());
if(seg_img == nullptr)
throw Exception("CAtlasRegistry::add_segment(): Couldn't "
"find image \""+segment_def.resource_name+"\" when adding "
"segment");
"find image \""+segment_def.resource_name+"\" when adding "
"segment");
// Get resolution of texture
magic::IntVector2 seg_img_size(seg_img->GetWidth(), seg_img->GetHeight());
// Try to find a texture atlas for this texture size
@ -176,9 +176,9 @@ struct CAtlasRegistry: public AtlasRegistry
size_t max_segments = atlas.total_segments.x_ * atlas.total_segments.y_;
if(atlas.segments.size() > max_segments){
throw Exception("Atlas has too many segments (segments.size()="+
itos(atlas.segments.size())+", total_segments=("+
itos(atlas.total_segments.x_)+", "+
itos(atlas.total_segments.y_)+"))");
itos(atlas.segments.size())+", total_segments=("+
itos(atlas.total_segments.x_)+", "+
itos(atlas.total_segments.y_)+"))");
}
// Set segment texture
cache.texture = atlas.texture;
@ -325,7 +325,7 @@ struct CAtlasRegistry: public AtlasRegistry
// Debug: save atlas image to file
/*ss_ atlas_img_name = "/tmp/atlas_"+itos(seg_size.x_)+"x"+
itos(seg_size.y_)+".png";
itos(seg_size.y_)+".png";
magic::File f(m_context, atlas_img_name.c_str(), magic::FILE_WRITE);
atlas.image->Save(f);*/
}
@ -358,7 +358,7 @@ struct CAtlasRegistry: public AtlasRegistry
{
// Re-create textures if a device reset has destroyed them
for(uint atlas_id = ATLAS_UNDEFINED + 1;
atlas_id < m_cache.size(); atlas_id++){
atlas_id < m_cache.size(); atlas_id++){
AtlasCache &cache = m_cache[atlas_id];
if(cache.texture->IsDataLost()){
log_v(MODULE, "Atlas %i texture data lost - re-creating",

View File

@ -8,11 +8,11 @@ namespace interface {
static const pv::Vector3DUint8 FACE_DIRS[6] = {
pv::Vector3DUint8(0, 1, 0),
pv::Vector3DUint8(0, -1, 0),
pv::Vector3DUint8(1, 0, 0),
pv::Vector3DUint8(-1, 0, 0),
pv::Vector3DUint8(0, 0, 1),
pv::Vector3DUint8(0, 0, -1),
pv::Vector3DUint8(0, -1, 0),
pv::Vector3DUint8(1, 0, 0),
pv::Vector3DUint8(-1, 0, 0),
pv::Vector3DUint8(0, 0, 1),
pv::Vector3DUint8(0, 0, -1),
};
// Map part block segment's face to atlas segment definition
@ -104,7 +104,7 @@ struct CBlockRegistry: public BlockRegistry
// Check this because VoxelDefinition has a static number of textures
if(def.side_textures.size() != 6)
throw Exception("BlockSourceDefinition::side_textures must contain "
"6 resource names");
"6 resource names");
// Create block definition without segments
BlockDefinition plain_def;
plain_def.name = def.name;

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

@ -58,7 +58,7 @@ Model* create_simple_voxel_model(Context *context,
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::SimpleVolume<uint8_t>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh);
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh);
surfaceExtractor.execute();
const sv_<uint32_t> &pv_indices = pv_mesh.getIndices();
@ -107,7 +107,7 @@ Model* create_simple_voxel_model(Context *context,
fromScratchModel->SetNumGeometries(1);
fromScratchModel->SetGeometry(0, 0, geom);
fromScratchModel->SetBoundingBox(BoundingBox(
Vector3(-0.5f*w, -0.5f*h, -0.5f*d), Vector3(0.5f*w, 0.5f*h, 0.5f*d)));
Vector3(-0.5f*w, -0.5f*h, -0.5f*d), Vector3(0.5f*w, 0.5f*h, 0.5f*d)));
return fromScratchModel;
}
@ -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
@ -217,8 +217,8 @@ Model* create_voxel_physics_model(Context *context,
IsQuadNeededByRegistryPhysics<VoxelInstance> iqn(voxel_reg);
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::RawVolume<VoxelInstance>,
IsQuadNeededByRegistryPhysics<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
IsQuadNeededByRegistryPhysics<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
surfaceExtractor.execute();
const sv_<uint32_t> &pv_indices = pv_mesh.getIndices();
@ -249,7 +249,7 @@ Model* create_voxel_physics_model(Context *context,
index_data.resize(num_indices);
for(size_t i = 0; i < num_indices; i++){
/*if(pv_indices[i] >= 0x10000)
throw Exception("Index too large");*/
throw Exception("Index too large");*/
index_data[i] = pv_indices[i];
}
@ -276,13 +276,13 @@ Model* create_voxel_physics_model(Context *context,
fromScratchModel->SetNumGeometries(1);
fromScratchModel->SetGeometry(0, 0, geom);
fromScratchModel->SetBoundingBox(BoundingBox(
Vector3(-0.5f*w, -0.5f*h, -0.5f*d), Vector3(0.5f*w, 0.5f*h, 0.5f*d)));
Vector3(-0.5f*w, -0.5f*h, -0.5f*d), Vector3(0.5f*w, 0.5f*h, 0.5f*d)));
return fromScratchModel;
}
template<typename VoxelType>
class IsQuadNeededByRegistry
class IsQuadNeededByRegistry
{
interface::VoxelRegistry *m_voxel_reg;
// NOTE: The voxel type id is used directly as PolyVox material value
@ -306,7 +306,7 @@ public:
if(!front_def)
throw Exception(ss_()+"Undefined voxel: front="+itos(front.get_id()));
/*if(!back_def){
return false;
return false;
}*/
else if(back_def->face_draw_type == interface::FaceDrawType::NEVER){
return false;
@ -433,8 +433,8 @@ void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
IsQuadNeededByRegistry<VoxelInstance> iqn(voxel_reg);
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::RawVolume<VoxelInstance>,
IsQuadNeededByRegistry<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
IsQuadNeededByRegistry<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
surfaceExtractor.execute();
const sv_<uint32_t> &pv_indices = pv_mesh.getIndices();
@ -453,7 +453,7 @@ void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
voxel_reg->get_cached(voxel_id0);
if(voxel_def0 == nullptr)
throw Exception("Unknown voxel in generated geometry: "+
itos(voxel_id0));
itos(voxel_id0));
// Figure out which face this is
uint face_id = 0;
const pv::Vector3DFloat &n = pv_vertices[pv_vertex_i0].normal;
@ -479,7 +479,7 @@ void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
const AtlasSegmentCache *aseg = atlas_reg->get_texture(seg_ref);
if(aseg == nullptr)
throw Exception("No atlas segment cache for voxel "+itos(voxel_id0)+
" face "+itos(face_id));
" face "+itos(face_id));
#if 0
// TODO: Create a custom Drawable that can use an index buffer
// Get or create the appropriate temporary geometry for this atlas
@ -542,7 +542,7 @@ void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
size_t pv_vertex_i = pv_indices[pv_index_i];
if(pv_index_i1 == 0 && pv_vertex_i0 != pv_vertex_i)
throw Exception("First index of face does not point to first "
"vertex of face");
"vertex of face");
const auto &pv_vert = pv_vertices[pv_vertex_i];
tg.vertex_data.Resize(tg.vertex_data.Size() + 1);
CustomGeometryVertex &tg_vert = tg.vertex_data.Back();
@ -617,7 +617,7 @@ up_<pv::RawVolume<VoxelInstance>> generate_voxel_lod_volume(
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));
uc_orig / lod + pv::Vector3DInt32(1, 1, 1));
auto &lc = region.getLowerCorner();
auto &uc = region.getUpperCorner();
@ -663,8 +663,8 @@ void generate_voxel_lod_geometry(int lod,
IsQuadNeededByRegistry<VoxelInstance> iqn(voxel_reg);
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::RawVolume<VoxelInstance>,
IsQuadNeededByRegistry<VoxelInstance>>
surfaceExtractor(&lod_volume, lod_volume.getEnclosingRegion(), &pv_mesh, iqn);
IsQuadNeededByRegistry<VoxelInstance>>
surfaceExtractor(&lod_volume, lod_volume.getEnclosingRegion(), &pv_mesh, iqn);
surfaceExtractor.execute();
const sv_<uint32_t> &pv_indices = pv_mesh.getIndices();
@ -683,7 +683,7 @@ void generate_voxel_lod_geometry(int lod,
voxel_reg->get_cached(voxel_id0);
if(voxel_def0 == nullptr)
throw Exception("Unknown voxel in generated geometry: "+
itos(voxel_id0));
itos(voxel_id0));
// Figure out which face this is
uint face_id = 0;
const pv::Vector3DFloat &n = pv_vertices[pv_vertex_i0].normal;
@ -712,7 +712,7 @@ void generate_voxel_lod_geometry(int lod,
const AtlasSegmentCache *aseg = atlas_reg->get_texture(seg_ref);
if(aseg == nullptr)
throw Exception("No atlas segment cache for voxel "+itos(voxel_id0)+
" face "+itos(face_id));
" face "+itos(face_id));
// Get or create the appropriate temporary geometry for this atlas
TemporaryGeometry &tg = result[seg_ref.atlas_id];
if(tg.vertex_data.Empty()){
@ -729,7 +729,7 @@ void generate_voxel_lod_geometry(int lod,
size_t pv_vertex_i = pv_indices[pv_index_i];
if(pv_index_i1 == 0 && pv_vertex_i0 != pv_vertex_i)
throw Exception("First index of face does not point to first "
"vertex of face");
"vertex of face");
const auto &pv_vert = pv_vertices[pv_vertex_i];
tg.vertex_data.Resize(tg.vertex_data.Size() + 1);
CustomGeometryVertex &tg_vert = tg.vertex_data.Back();
@ -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

@ -68,7 +68,7 @@ void PacketStream::output(const ss_ &name, const ss_ &data,
PacketType highest_known_type_was = m_highest_known_type;
m_highest_known_type = m_outgoing_types.m_next_type - 1;
for(PacketType t1 = highest_known_type_was + 1;
t1 < m_outgoing_types.m_next_type; t1++){
t1 < m_outgoing_types.m_next_type; t1++){
ss_ name = m_outgoing_types.get_name(t1);
log_d(MODULE, "Sending type %zu = %s", t1, cs(name));
std::ostringstream os(std::ios::binary);

View File

@ -22,7 +22,7 @@
namespace interface {
const unsigned char prefix[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFF};
0x00, 0x00, 0x00, 0xFF, 0xFF};
bool sockaddr_to_bytes(const sockaddr_storage *ptr, sv_<uchar> &to)
{
@ -52,16 +52,16 @@ std::string address_bytes_to_string(const sv_<uchar> &ip)
for(size_t i = 0; i < ip.size(); i++){
if(ip.size() == 4){
os<<std::dec<<std::setfill('0')<<std::setw(0)
<<((uint32_t)ip[i] & 0xff);
<<((uint32_t)ip[i] & 0xff);
if(i < ip.size() - 1)
os<<".";
} else {
os<<std::hex<<std::setfill('0')<<std::setw(2)
<<((uint32_t)ip[i] & 0xff);
<<((uint32_t)ip[i] & 0xff);
i++;
if(i < ip.size())
os<<std::hex<<std::setfill('0')<<std::setw(2)
<<((uint32_t)ip[i] & 0xff);
<<((uint32_t)ip[i] & 0xff);
if(i < ip.size() - 1)
os<<":";
}

View File

@ -75,7 +75,7 @@ struct CThread: public Thread
// Set thread name
if(!thread_name.empty()){
ss_ limited_name = thread_name.size() <= 15 ?
thread_name : thread_name.substr(0, 15);
thread_name : thread_name.substr(0, 15);
if(pthread_setname_np(thread->m_thread, limited_name.c_str())){
log_w(MODULE, "Failed to set thread name (thread %p, name \"%s\")",
thread, limited_name.c_str());
@ -102,7 +102,7 @@ struct CThread: public Thread
interface::debug::get_exception_backtrace(bt);
interface::debug::log_backtrace(bt,
"Backtrace in ThreadThing("+thread_name+") for "+
bt.exception_name+"(\""+e.what()+"\")");
bt.exception_name+"(\""+e.what()+"\")");
}
// Call crash handler
try {
@ -119,7 +119,7 @@ struct CThread: public Thread
interface::debug::get_exception_backtrace(bt);
interface::debug::log_backtrace(bt,
"Backtrace in ThreadThing("+thread_name+") for "+
bt.exception_name+"(\""+e.what()+"\")");
bt.exception_name+"(\""+e.what()+"\")");
}
}
}

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

@ -11,11 +11,11 @@ namespace std {
template<> struct hash<interface::VoxelName>{
std::size_t operator()(const interface::VoxelName &v) const {
return ((std::hash<ss_>() (v.block_name) << 0) ^
(std::hash<uint>() (v.segment_x) << 1) ^
(std::hash<uint>() (v.segment_y) << 2) ^
(std::hash<uint>() (v.segment_z) << 3) ^
(std::hash<uint>() (v.rotation_primary) << 4) ^
(std::hash<uint>() (v.rotation_secondary) << 5));
(std::hash<uint>() (v.segment_x) << 1) ^
(std::hash<uint>() (v.segment_y) << 2) ^
(std::hash<uint>() (v.segment_z) << 3) ^
(std::hash<uint>() (v.rotation_primary) << 4) ^
(std::hash<uint>() (v.rotation_secondary) << 5));
}
};
}
@ -28,7 +28,7 @@ ss_ VoxelName::dump() const
os<<"VoxelName(";
os<<"block_name="<<block_name;
os<<", segment=("<<(int)segment_x<<","<<(int)segment_y<<","
<<(int)segment_z<<")";
<<(int)segment_z<<")";
os<<", rotation_primary="<<(int)rotation_primary;
os<<", rotation_secondary="<<(int)rotation_secondary;
os<<")";
@ -80,10 +80,10 @@ struct CVoxelRegistry: public VoxelRegistry
VoxelTypeId id = m_defs.size();
if(def.id != VOXELTYPEID_UNDEFINED && id != def.id)
throw Exception(ss_()+"add_voxel(): def.id="+itos(def.id)+
"; should be "+itos(id));
"; should be "+itos(id));
if(m_name_to_id.count(def.name) != 0)
throw Exception(ss_()+"add_voxel(): Already exists: "+
cs(def.name.dump()));
cs(def.name.dump()));
// NOTE: This invalidates all previous pointers to cache entries that
// were given out
m_defs.resize(id + 1);
@ -194,12 +194,12 @@ struct CVoxelRegistry: public VoxelRegistry
interface::ATLAS_LOD_TOP_FACE;
}
if(i == 5 /*Z-*/){
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_SEMIBRIGHT1_FACE;
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_SEMIBRIGHT1_FACE;
}
if(i == 2 /*X+*/){
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_SEMIBRIGHT2_FACE;
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_SEMIBRIGHT2_FACE;
}
if(lod > MAX_LOD_WITH_SHADOWS){
lod_seg_def.lod_simulation |=

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

@ -9,7 +9,7 @@
namespace interface
{
template<class Archive>
void serialize(Archive &archive, AtlasSegmentDefinition &v)
void serialize(Archive &archive, AtlasSegmentDefinition &v)
{
uint8_t version = 1;
archive(

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

@ -48,7 +48,7 @@ namespace interface
Event(const ss_ &name, up_<Private> p):
type(t(name)), p(std::move(p)){}
template<typename PrivateT>
Event(const ss_ &name, PrivateT *p):
Event(const ss_ &name, PrivateT *p):
type(t(name)), p(up_<Private>(p))
{}

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

@ -66,7 +66,7 @@ namespace interface
event_data.Erase("Component");
}
m_server->emit_event(m_buildat_event_type, new interface::MagicEvent(
event_type, event_data));
event_type, event_data));
}
};
}

View File

@ -143,44 +143,44 @@ namespace interface
inline float NoisePerlin2D(const NoiseParams *np, float x, float y, float s)
{
return (np->offset + np->scale * noise2d_perlin(
(float)x / np->spread.X,
(float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
(float)x / np->spread.X,
(float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
}
inline float NoisePerlin2DNoTxfm(
const NoiseParams *np, float x, float y, float s)
{
return (noise2d_perlin(
(float)x / np->spread.X,
(float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
(float)x / np->spread.X,
(float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
}
inline float NoisePerlin2DPosOffset(const NoiseParams *np, float x, float xoff,
float y, float yoff, float s)
{
return (np->offset + np->scale * noise2d_perlin(
(float)xoff + (float)x / np->spread.X,
(float)yoff + (float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
(float)xoff + (float)x / np->spread.X,
(float)yoff + (float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
}
inline float NoisePerlin2DNoTxfmPosOffset(const NoiseParams *np, float x,
float xoff, float y, float yoff, float s)
{
return (noise2d_perlin(
(float)xoff + (float)x / np->spread.X,
(float)yoff + (float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
(float)xoff + (float)x / np->spread.X,
(float)yoff + (float)y / np->spread.Y,
s + np->seed, np->octaves, np->persist));
}
inline float NoisePerlin3D(
const NoiseParams *np, float x, float y, float z, float s)
{
return (np->offset + np->scale *
noise3d_perlin((float)x / np->spread.X, (float)y / np->spread.Y,
(float)z / np->spread.Z, s + np->seed, np->octaves, np->persist));
noise3d_perlin((float)x / np->spread.X, (float)y / np->spread.Y,
(float)z / np->spread.Z, s + np->seed, np->octaves, np->persist));
}
}
// vim: set noet ts=4 sw=4:

View File

@ -9,15 +9,15 @@ namespace std {
template<> struct hash<PolyVox::Vector<2u, int16_t>>{
std::size_t operator()(const PolyVox::Vector<2u, int16_t> &v) const {
return ((std::hash<int16_t>() (v.getX()) << 0) ^
(std::hash<int16_t>() (v.getY()) << 1));
(std::hash<int16_t>() (v.getY()) << 1));
}
};
template<> struct hash<PolyVox::Vector<3u, int16_t>>{
std::size_t operator()(const PolyVox::Vector<3u, int16_t> &v) const {
return ((std::hash<int16_t>() (v.getX()) << 0) ^
(std::hash<int16_t>() (v.getY()) << 1) ^
(std::hash<int16_t>() (v.getZ()) << 2));
(std::hash<int16_t>() (v.getY()) << 1) ^
(std::hash<int16_t>() (v.getZ()) << 2));
}
};

View File

@ -98,7 +98,7 @@ namespace interface
virtual const ServerConfig& get_config() = 0;
virtual void access_thread_pool(std::function<void(
interface::thread_pool::ThreadPool*pool)> cb) = 0;
interface::thread_pool::ThreadPool*pool)> cb) = 0;
};
}
// vim: set noet ts=4 sw=4:

View File

@ -9,13 +9,13 @@
namespace cereal
{
template<class Archive>
void save(Archive &archive, const Urho3D::IntVector2 &v)
void save(Archive &archive, const Urho3D::IntVector2 &v)
{
archive((int32_t)v.x_);
archive((int32_t)v.y_);
}
template<class Archive>
void load(Archive &archive, Urho3D::IntVector2 &v)
void load(Archive &archive, Urho3D::IntVector2 &v)
{
int32_t x, y;
archive(x, y);

View File

@ -9,7 +9,7 @@
namespace interface
{
template<class Archive>
void serialize(Archive &archive, VoxelName &v)
void serialize(Archive &archive, VoxelName &v)
{
uint8_t version = 1;
archive(
@ -24,7 +24,7 @@ namespace interface
}
template<class Archive>
void serialize(Archive &archive, VoxelDefinition &v)
void serialize(Archive &archive, VoxelDefinition &v)
{
uint8_t version = 1;
archive(
@ -40,7 +40,7 @@ namespace interface
}
template<class Archive>
void serialize(Archive &archive, VoxelInstance &v)
void serialize(Archive &archive, VoxelInstance &v)
{
archive(v.data);
}

View File

@ -10,20 +10,20 @@ namespace lua_bindings {
/* Type format:
{"object",
{"peer", "int32_t"},
{"players", {"unordered_map",
"int32_t",
{"object",
{"peer", "int32_t"},
{"x", "int32_t"},
{"y", "int32_t"},
},
}},
{"playfield", {"object",
{"w", "int32_t"},
{"h", "int32_t"},
{"tiles", {"array", "int32_t"}},
}},
{"peer", "int32_t"},
{"players", {"unordered_map",
"int32_t",
{"object",
{"peer", "int32_t"},
{"x", "int32_t"},
{"y", "int32_t"},
},
}},
{"playfield", {"object",
{"w", "int32_t"},
{"h", "int32_t"},
{"tiles", {"array", "int32_t"}},
}},
}) */
static constexpr auto known_types =
@ -144,7 +144,7 @@ static void binary_input_read_value(lua_State *L, int type_L,
// value_result_table_L is left on stack
} else {
throw Exception(ss_()+"Unknown type \""+outfield_type+"\""
"; known types are "+known_types);
"; known types are "+known_types);
}
}
@ -265,7 +265,7 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L,
}
} else {
throw Exception(ss_()+"Unknown type \""+outfield_type+"\""
"; known types are "+known_types);
"; known types are "+known_types);
}
}

View File

@ -64,7 +64,7 @@ void set_simple_voxel_model(const luabind::object &node_o,
if((int)data.size() != w * h * d){
throw Exception(ss_()+"set_simple_voxel_model(): Data size does not match"
" with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")");
" with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")");
}
lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app");
@ -99,7 +99,7 @@ void set_8bit_voxel_geometry(const luabind::object &node_o,
if((int)data.size() != w * h * d){
throw Exception(ss_()+"set_8bit_voxel_geometry(): Data size does not match"
" with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")");
" with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")");
}
lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app");
@ -281,9 +281,9 @@ struct SetPhysicsBoxesTask: public interface::thread_pool::Task
{
ScopeTimer timer(
post_step == 1 ? "post physics 1" :
post_step == 2 ? "post_physics 2" :
post_step == 3 ? "post physics 3" :
"post physics");
post_step == 2 ? "post_physics 2" :
post_step == 3 ? "post physics 3" :
"post physics");
Context *context = node->GetContext();
switch(post_step){
case 1:
@ -343,7 +343,7 @@ void set_voxel_geometry(const luabind::object &node_o,
up_<SetVoxelGeometryTask> task(new SetVoxelGeometryTask(
node, data, voxel_reg, atlas_reg
));
));
auto *thread_pool = buildat_app->get_thread_pool();
@ -375,7 +375,7 @@ void set_voxel_lod_geometry(int lod, const luabind::object &node_o,
up_<SetVoxelLodGeometryTask> task(new SetVoxelLodGeometryTask(
lod, node, data, voxel_reg, atlas_reg
));
));
auto *thread_pool = buildat_app->get_thread_pool();
@ -418,7 +418,7 @@ void set_voxel_physics_boxes(const luabind::object &node_o,
up_<SetPhysicsBoxesTask> task(new SetPhysicsBoxesTask(
node, data, voxel_reg
));
));
auto *thread_pool = buildat_app->get_thread_pool();
@ -449,13 +449,13 @@ void init_mesh(lua_State *L)
{
using namespace luabind;
module(L)[
LUABIND_FUNC(set_simple_voxel_model),
LUABIND_FUNC(set_8bit_voxel_geometry),
LUABIND_FUNC(set_voxel_geometry),
LUABIND_FUNC(set_voxel_lod_geometry),
LUABIND_FUNC(clear_voxel_geometry),
LUABIND_FUNC(set_voxel_physics_boxes),
LUABIND_FUNC(clear_voxel_physics_boxes)
LUABIND_FUNC(set_simple_voxel_model),
LUABIND_FUNC(set_8bit_voxel_geometry),
LUABIND_FUNC(set_voxel_geometry),
LUABIND_FUNC(set_voxel_lod_geometry),
LUABIND_FUNC(clear_voxel_geometry),
LUABIND_FUNC(set_voxel_physics_boxes),
LUABIND_FUNC(clear_voxel_physics_boxes)
];
}

View File

@ -81,7 +81,7 @@ struct SpatialUpdateQueue
void insert(const Value &value, std::list<Item>::iterator queue_it){
Entry entry(value, queue_it);
auto it = std::lower_bound(m_set.begin(), m_set.end(), entry,
std::greater<Entry>());
std::greater<Entry>());
if(it == m_set.end())
m_set.insert(it, entry);
else if(it->value.node_id != value.node_id ||
@ -93,7 +93,7 @@ struct SpatialUpdateQueue
void remove(const Value &value){
Entry entry(value);
auto it = std::lower_bound(m_set.begin(), m_set.end(), entry,
std::greater<Entry>());
std::greater<Entry>());
if(it == m_set.end())
return;
m_set.erase(it);
@ -101,7 +101,7 @@ struct SpatialUpdateQueue
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>());
std::greater<Entry>());
if(it == m_set.end())
return nullptr;
if(it->value.node_id != value.node_id ||
@ -190,7 +190,7 @@ struct SpatialUpdateQueue
}
auto it = std::lower_bound(m_queue.begin(), m_queue.end(),
item, std::greater<Item>()); // position in descending order
item, std::greater<Item>()); // position in descending order
auto inserted_it = m_queue.insert(it, item);
m_queue_length++;
m_value_set.insert(item.value, inserted_it);

View File

@ -30,7 +30,7 @@ ss_ lua_tocppstring(lua_State *L, int index)
{
if(!lua_isstring(L, index))
throw Exception(ss_()+"lua_tocppstring: Expected string, got "+
lua_typename(L, index));
lua_typename(L, index));
size_t length;
const char *s = lua_tolstring(L, index, &length);
return ss_(s, length);

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 @@ int main(int argc, char *argv[])
" -l [integer] Set maximum log level (0...5)\n"
" -L [log file path] Append log to a specified file\n"
" -C [module_name] Skip compiling specified module\n"
;
;
int c;
while((c = c55_getopt(argc, argv, opts)) != -1)
@ -171,7 +171,7 @@ int main(int argc, char *argv[])
next_tick_us = current_us;
}
interface::Event event("core:tick",
new interface::TickEvent(t_per_tick / 1e6));
new interface::TickEvent(t_per_tick / 1e6));
state->emit_event(std::move(event));
}

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

@ -58,7 +58,7 @@ ss_ hash_files(const sv_<ss_> &paths)
std::ifstream f(path);
try {
std::string content((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
os<<content;
} catch(std::ios_base::failure &e){
// Just ignore errors

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 {
@ -394,7 +394,7 @@ void ModuleThread::handle_event(Event &event)
interface::debug::get_exception_backtrace(bt);
interface::debug::log_backtrace(bt,
"Backtrace in M["+mc->info.name+"] for "+
bt.exception_name+"(\""+e.what()+"\")");
bt.exception_name+"(\""+e.what()+"\")");
}
}
}
@ -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");
@ -487,8 +489,8 @@ struct CState: public State, public interface::Server
sv_<ss_> urho3d_subdirs = {
"Audio", "Container", "Core", "Engine", "Graphics", "Input", "IO",
"LuaScript", "Math", "Navigation", "Network", "Physics", "Resource",
"Scene", "Script", "UI", "Urho2D",
"LuaScript", "Math", "Navigation", "Network", "Physics", "Resource",
"Scene", "Script", "UI", "Urho2D",
};
for(const ss_ &subdir : urho3d_subdirs){
m_compiler->include_directories.push_back(
@ -516,7 +518,7 @@ struct CState: public State, public interface::Server
// deadlocks
interface::MutexScope ms(m_modules_mutex);
for(auto name_it = m_module_load_order.rbegin();
name_it != m_module_load_order.rend(); ++name_it){
name_it != m_module_load_order.rend(); ++name_it){
auto it2 = m_modules.find(*name_it);
if(it2 == m_modules.end())
continue;
@ -670,7 +672,7 @@ struct CState: public State, public interface::Server
std::ifstream f(hashfile_path);
if(f.good()){
previous_hash = ss_((std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
}
}
if(previous_hash == content_hash){
@ -682,7 +684,7 @@ struct CState: public State, public interface::Server
m_compiler->include_directories.push_back(m_modules_path);
bool build_ok = m_compiler->build(info.name, init_cpp_path, build_dst,
extra_cxxflags, extra_ldflags, skip_compile);
extra_cxxflags, extra_ldflags, skip_compile);
m_compiler->include_directories.pop_back();
if(!build_ok){
@ -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",
@ -997,7 +1001,7 @@ struct CState: public State, public interface::Server
void check_valid_access_u(
ModuleContainer *target_mc,
ModuleContainer *caller_mc
){
){
const ss_ &target_name = target_mc->info.name;
const ss_ &caller_name = caller_mc->info.name;
@ -1226,7 +1230,7 @@ struct CState: public State, public interface::Server
interface::ModuleInfo &info = it->second;
emit_event(Event("core:module_modified",
new interface::ModuleModifiedEvent(
info.name, info.path)));
info.name, info.path)));
}
}
@ -1315,7 +1319,7 @@ struct CState: public State, public interface::Server
}
void access_thread_pool(std::function<void(
interface::thread_pool::ThreadPool*pool)> cb)
interface::thread_pool::ThreadPool*pool)> cb)
{
interface::MutexScope ms(m_thread_pool_mutex);
cb(m_thread_pool.get());
@ -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);
}
}

View File

@ -49,7 +49,7 @@ namespace server
virtual ss_ get_file_path(const ss_ &name) = 0;
virtual void access_thread_pool(std::function<void(
interface::thread_pool::ThreadPool*pool)> cb) = 0;
interface::thread_pool::ThreadPool*pool)> cb) = 0;
};
State* createState();