diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index a78aefd8a4304..515eb0daaabf4 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "clientmap.h" #include "client.h" +#include "irr_v2d.h" #include "irr_v3d.h" #include "mapblock_mesh.h" #include @@ -169,7 +170,7 @@ void ClientMap::OnRegisterSceneNode() } void ClientMap::getBlocksInViewRange(v3pos_t cam_pos_nodes, - v3pos_t *p_blocks_min, v3pos_t *p_blocks_max, float range) + v3bpos_t *p_blocks_min, v3bpos_t *p_blocks_max, float range) { if (range <= 0.0f) range = m_control.wanted_range; @@ -188,11 +189,11 @@ void ClientMap::getBlocksInViewRange(v3pos_t cam_pos_nodes, cam_pos_nodes.Z + box_nodes_d.Z); // Take a fair amount as we will be dropping more out later // Umm... these additions are a bit strange but they are needed. - *p_blocks_min = v3pos_t( + *p_blocks_min = v3bpos_t( p_nodes_min.X / MAP_BLOCKSIZE - 3, p_nodes_min.Y / MAP_BLOCKSIZE - 3, p_nodes_min.Z / MAP_BLOCKSIZE - 3); - *p_blocks_max = v3pos_t( + *p_blocks_max = v3bpos_t( p_nodes_max.X / MAP_BLOCKSIZE + 1, p_nodes_max.Y / MAP_BLOCKSIZE + 1, p_nodes_max.Z / MAP_BLOCKSIZE + 1); @@ -205,7 +206,7 @@ class MapBlockFlags static constexpr u16 CHUNK_MASK = CHUNK_EDGE - 1; static constexpr std::size_t CHUNK_VOLUME = CHUNK_EDGE * CHUNK_EDGE * CHUNK_EDGE; // volume of a chunk - MapBlockFlags(v3s16 min_pos, v3s16 max_pos) + MapBlockFlags(v3bpos_t min_pos, v3bpos_t max_pos) : min_pos(min_pos), volume((max_pos - min_pos) / CHUNK_EDGE + 1) { chunks.resize(volume.X * volume.Y * volume.Z); @@ -214,14 +215,14 @@ class MapBlockFlags class Chunk { public: - inline u8 &getBits(v3s16 pos) + inline u8 &getBits(v3bpos_t pos) { std::size_t address = getAddress(pos); return bits[address]; } private: - inline std::size_t getAddress(v3s16 pos) { + inline std::size_t getAddress(v3bpos_t pos) { std::size_t address = (pos.X & CHUNK_MASK) + (pos.Y & CHUNK_MASK) * CHUNK_EDGE + (pos.Z & CHUNK_MASK) * (CHUNK_EDGE * CHUNK_EDGE); return address; } @@ -229,9 +230,9 @@ class MapBlockFlags std::array bits; }; - Chunk &getChunk(v3s16 pos) + Chunk &getChunk(v3bpos_t pos) { - v3s16 delta = (pos - min_pos) / CHUNK_EDGE; + v3bpos_t delta = (pos - min_pos) / CHUNK_EDGE; std::size_t address = delta.X + delta.Y * volume.X + delta.Z * volume.X * volume.Y; Chunk *chunk = chunks[address].get(); if (!chunk) { @@ -242,8 +243,8 @@ class MapBlockFlags } private: std::vector> chunks; - v3s16 min_pos; - v3s16 volume; + v3bpos_t min_pos; + v3bpos_t volume; }; void ClientMap::updateDrawList() @@ -289,7 +290,7 @@ void ClientMap::updateDrawList() // if (occlusion_culling_enabled && m_control.show_wireframe) // occlusion_culling_enabled = porting::getTimeS() & 1; - std::queue blocks_to_consider; + std::queue blocks_to_consider; // Bits per block: // [ visited | 0 | 0 | 0 | 0 | Z visible | Y visible | X visible ] @@ -302,7 +303,7 @@ void ClientMap::updateDrawList() // Recursively walk the space and pick mapblocks for drawing while (blocks_to_consider.size() > 0) { - v3s16 block_coord = blocks_to_consider.front(); + v3bpos_t block_coord = blocks_to_consider.front(); blocks_to_consider.pop(); auto &flags = blocks_seen.getChunk(block_coord).getBits(block_coord); @@ -315,7 +316,7 @@ void ClientMap::updateDrawList() blocks_visited++; // Get the sector, block and mesh - MapSector *sector = this->getSectorNoGenerate(v2s16(block_coord.X, block_coord.Z)); + MapSector *sector = this->getSectorNoGenerate(v2bpos_t(block_coord.X, block_coord.Z)); if (!sector) continue; @@ -329,7 +330,7 @@ void ClientMap::updateDrawList() v3f mesh_sphere_center; f32 mesh_sphere_radius; - v3s16 block_pos_nodes = block_coord * MAP_BLOCKSIZE; + v3pos_t block_pos_nodes = block_coord * MAP_BLOCKSIZE; if (mesh) { mesh_sphere_center = intToFloat(block_pos_nodes, BS) @@ -357,7 +358,7 @@ void ClientMap::updateDrawList() // Calculate the vector from the camera block to the current block // We use it to determine through which sides of the current block we can continue the search - v3s16 look = block_coord - camera_block; + v3bpos_t look = block_coord - camera_block; // Occluded near sides will further occlude the far sides u8 visible_outer_sides = flags & 0x07; @@ -422,7 +423,7 @@ void ClientMap::updateDrawList() // Calculate vector from camera to mapblock center. Because we only need relation between // coordinates we scale by 2 to avoid precision loss. - v3s16 precise_look = 2 * (block_pos_nodes - cam_pos_nodes) + MAP_BLOCKSIZE - 1; + v3bpos_t precise_look = 2 * (block_pos_nodes - cam_pos_nodes) + MAP_BLOCKSIZE - 1; // dominant axis flag u8 dominant_axis = (abs(precise_look.X) > abs(precise_look.Y) && abs(precise_look.X) > abs(precise_look.Z)) | @@ -448,7 +449,7 @@ void ClientMap::updateDrawList() bool side_visible = ((near_transparency & adjacent_sides) | (near_transparency & my_side & dominant_axis)) != 0; side_visible = side_visible && ((far_side_mask & transparent_sides) != 0); - v3s16 next_pos = block_coord; + v3bpos_t next_pos = block_coord; next_pos[axis] += next_pos_offset; // If a side is a see-through, mark the next block's side as visible, and queue @@ -483,10 +484,10 @@ void ClientMap::updateDrawList() void ClientMap::touchMapBlocks() { - v3s16 cam_pos_nodes = floatToInt(m_camera_position, BS); + v3pos_t cam_pos_nodes = floatToInt(m_camera_position, BS); - v3s16 p_blocks_min; - v3s16 p_blocks_max; + v3bpos_t p_blocks_min; + v3bpos_t p_blocks_max; getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max); // Number of blocks currently loaded by the client diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 43e35c8fd2434..88e054f18ed3c 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -1586,20 +1586,20 @@ video::SColor encode_light(u16 light, u8 emissive_light) u8 get_solid_sides(MeshMakeData *data) { - v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; + v3pos_t blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; const NodeDefManager *ndef = data->m_client->ndef(); u8 result = 0x3F; // all sides solid; for (s16 i = 0; i < MAP_BLOCKSIZE && result != 0; i++) for (s16 j = 0; j < MAP_BLOCKSIZE && result != 0; j++) { - v3s16 positions[6] = { - v3s16(0, i, j), - v3s16(MAP_BLOCKSIZE - 1, i, j), - v3s16(i, 0, j), - v3s16(i, MAP_BLOCKSIZE - 1, j), - v3s16(i, j, 0), - v3s16(i, j, MAP_BLOCKSIZE - 1) + v3pos_t positions[6] = { + v3pos_t(0, i, j), + v3pos_t(MAP_BLOCKSIZE - 1, i, j), + v3pos_t(i, 0, j), + v3pos_t(i, MAP_BLOCKSIZE - 1, j), + v3pos_t(i, j, 0), + v3pos_t(i, j, MAP_BLOCKSIZE - 1) }; for (u8 k = 0; k < 6; k++) { diff --git a/src/client/mesh_generator_thread.cpp b/src/client/mesh_generator_thread.cpp index 5e3f01011c601..eb6ae1c221e47 100644 --- a/src/client/mesh_generator_thread.cpp +++ b/src/client/mesh_generator_thread.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "mesh_generator_thread.h" +#include "irr_v3d.h" #include "settings.h" #include "profiler.h" #include "client.h" @@ -106,7 +107,7 @@ bool MeshUpdateQueue::addBlock(Map *map, v3bpos_t p, bool ack_block_to_server, b cached_blocks.reserve(3*3*3); cached_blocks.push_back(main_block); main_block->refGrab(); - for (v3s16 dp : g_26dirs) { + for (v3pos_t dp : g_26dirs) { MapBlock *block = map->getBlockNoCreateNoEx(p + dp); cached_blocks.push_back(block); if (block) @@ -185,7 +186,7 @@ void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q) MeshUpdateWorkerThread */ -MeshUpdateWorkerThread::MeshUpdateWorkerThread(MeshUpdateQueue *queue_in, MeshUpdateManager *manager, v3s16 *camera_offset) : +MeshUpdateWorkerThread::MeshUpdateWorkerThread(MeshUpdateQueue *queue_in, MeshUpdateManager *manager, v3pos_t *camera_offset) : UpdateThread("Mesh"), m_queue_in(queue_in), m_manager(manager), m_camera_offset(camera_offset) { m_generation_interval = g_settings->getU16("mesh_generation_interval"); diff --git a/src/client/mesh_generator_thread.h b/src/client/mesh_generator_thread.h index e2c3301ff002f..316994a79e692 100644 --- a/src/client/mesh_generator_thread.h +++ b/src/client/mesh_generator_thread.h @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include "irr_v3d.h" #include "mapblock_mesh.h" #include "threading/mutex_auto_lock.h" #include "util/thread.h" @@ -68,7 +69,7 @@ class MeshUpdateQueue QueuedMeshUpdate *pop(); // Marks a position as finished, unblocking the next update - void done(v3s16 pos); + void done(v3pos_t pos); u32 size() { @@ -109,7 +110,7 @@ class MeshUpdateManager; class MeshUpdateWorkerThread : public UpdateThread { public: - MeshUpdateWorkerThread(MeshUpdateQueue *queue_in, MeshUpdateManager *manager, v3s16 *camera_offset); + MeshUpdateWorkerThread(MeshUpdateQueue *queue_in, MeshUpdateManager *manager, v3pos_t *camera_offset); protected: virtual void doUpdate(); @@ -117,7 +118,7 @@ class MeshUpdateWorkerThread : public UpdateThread private: MeshUpdateQueue *m_queue_in; MeshUpdateManager *m_manager; - v3s16 *m_camera_offset; + v3pos_t *m_camera_offset; // TODO: Add callback to update these when g_settings changes int m_generation_interval; diff --git a/src/dummymap.h b/src/dummymap.h index 5f2881371803c..34d178cc386c6 100644 --- a/src/dummymap.h +++ b/src/dummymap.h @@ -19,17 +19,20 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once +#include "irr_v2d.h" +#include "irr_v3d.h" +#include "irrlichttypes.h" #include "map.h" #include "mapsector.h" class DummyMap : public Map { public: - DummyMap(IGameDef *gamedef, v3s16 bpmin, v3s16 bpmax): Map(gamedef) + DummyMap(IGameDef *gamedef, v3bpos_t bpmin, v3bpos_t bpmax): Map(gamedef) { - for (s16 z = bpmin.Z; z <= bpmax.Z; z++) - for (s16 x = bpmin.X; x <= bpmax.X; x++) { - v2s16 p2d(x, z); + for (bpos_t z = bpmin.Z; z <= bpmax.Z; z++) + for (bpos_t x = bpmin.X; x <= bpmax.X; x++) { + v2bpos_t p2d(x, z); MapSector *sector = new MapSector(this, p2d, gamedef); m_sectors[p2d] = sector; for (s16 y = bpmin.Y; y <= bpmax.Y; y++) diff --git a/src/map.cpp b/src/map.cpp index 6e34dc1225bb7..a421c8157f0ed 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -529,7 +529,7 @@ void ServerMap::transformLiquids(std::map &modified_blocks, std::vector > changed_nodes; - std::vector check_for_falling; + std::vector check_for_falling; u32 liquid_loop_max = g_settings->getS32("liquid_loop_max"); u32 loop_max = liquid_loop_max; @@ -843,7 +843,7 @@ void ServerMap::transformLiquids(std::map &modified_blocks, voxalgo::update_lighting_nodes(this, changed_nodes, modified_blocks); - for (const v3s16 &p : check_for_falling) { + for (const v3pos_t &p : check_for_falling) { env->getScriptIface()->check_for_falling(p); } diff --git a/src/map.h b/src/map.h index fe2b570a5a967..0ad71840ac660 100644 --- a/src/map.h +++ b/src/map.h @@ -83,14 +83,14 @@ struct MapEditEvent MapEditEvent() = default; // Sets the event's position and marks the block as modified. - void setPositionModified(v3s16 pos) + void setPositionModified(v3pos_t pos) { assert(modified_blocks.empty()); // only meant for initialization (once) p = pos; modified_blocks.push_back(getNodeBlockPos(pos)); } - void setModifiedBlocks(const std::map blocks) + void setModifiedBlocks(const std::map blocks) { assert(modified_blocks.empty()); // only meant for initialization (once) modified_blocks.reserve(blocks.size()); @@ -309,7 +309,7 @@ class Map /*: public NodeContainer*/ } } - bool isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes); + bool isBlockOccluded(MapBlock *block, v3pos_t cam_pos_nodes); protected: IGameDef *m_gamedef; diff --git a/src/mapblock.cpp b/src/mapblock.cpp index d24908acd6d3c..50606d246b079 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapblock.h" #include +#include "irr_v3d.h" #include "map.h" #include "light.h" #include "nodedef.h" @@ -125,13 +126,13 @@ bool MapBlock::saveStaticObject(u16 id, const StaticObject &obj, u32 reason) } // This method is only for Server, don't call it on client -void MapBlock::step(float dtime, const std::function &on_timer_cb) +void MapBlock::step(float dtime, const std::function &on_timer_cb) { // Run script callbacks for elapsed node_timers std::vector elapsed_timers = m_node_timers.step(dtime); if (!elapsed_timers.empty()) { MapNode n; - v3s16 p; + v3pos_t p; for (const NodeTimer &elapsed_timer : elapsed_timers) { n = getNodeNoEx(elapsed_timer.position); p = elapsed_timer.position + getPosRelative(); @@ -910,7 +911,7 @@ std::string analyze_block(MapBlock *block) for(s16 y0=0; y0getNodeNoEx(p); content_t c = n.getContent(); if(c == CONTENT_IGNORE) diff --git a/src/mapblock.h b/src/mapblock.h index ba788bdb46fee..2937d3cf4a8df 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -329,7 +329,7 @@ class MapBlock bool onObjectsActivation(); bool saveStaticObject(u16 id, const StaticObject &obj, u32 reason); - void step(float dtime, const std::function &on_timer_cb); + void step(float dtime, const std::function &on_timer_cb); //// //// Timestamp (see m_timestamp) diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp index 6cb09d5849259..b4240fb0e7d11 100644 --- a/src/mapgen/mapgen.cpp +++ b/src/mapgen/mapgen.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include +#include "irrlichttypes.h" #include "mapgen.h" #include "voxel.h" #include "noise.h" @@ -1066,7 +1067,7 @@ void MapgenParams::writeParams(Settings *settings) const s32 MapgenParams::getSpawnRangeMax() { if (!m_mapgen_edges_calculated) { - std::pair edges = get_mapgen_edges(mapgen_limit, chunksize); + std::pair edges = get_mapgen_edges(mapgen_limit, chunksize); mapgen_edge_min = edges.first; mapgen_edge_max = edges.second; m_mapgen_edges_calculated = true; @@ -1076,7 +1077,7 @@ s32 MapgenParams::getSpawnRangeMax() } -std::pair get_mapgen_edges(s16 mapgen_limit, s16 chunksize) +std::pair get_mapgen_edges(pos_t mapgen_limit, s16 chunksize) { // Central chunk offset, in blocks s16 ccoff_b = -chunksize / 2; @@ -1100,5 +1101,5 @@ std::pair get_mapgen_edges(s16 mapgen_limit, s16 chunksize) pos_t numcmin = MYMAX((ccfmin - mapgen_limit_min) / csize_n, 0); pos_t numcmax = MYMAX((mapgen_limit_max - ccfmax) / csize_n, 0); // Mapgen edges, in nodes - return std::pair(ccmin - numcmin * csize_n, ccmax + numcmax * csize_n); + return std::pair(ccmin - numcmin * csize_n, ccmax + numcmax * csize_n); } diff --git a/src/mapgen/mapgen.h b/src/mapgen/mapgen.h index af321907fdcc1..3d40f9ee3a3fa 100644 --- a/src/mapgen/mapgen.h +++ b/src/mapgen/mapgen.h @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "irr_v3d.h" +#include "irrlichttypes.h" #include "noise.h" #include "nodedef.h" #include "util/string.h" @@ -333,4 +334,4 @@ class MapgenBasic : public Mapgen { // Calculate exact edges of the outermost mapchunks that are within the set // mapgen_limit. Returns the minimum and maximum edges in nodes in that order. -std::pair get_mapgen_edges(s16 mapgen_limit, s16 chunksize); +std::pair get_mapgen_edges(pos_t mapgen_limit, s16 chunksize); diff --git a/src/rollback.h b/src/rollback.h index c965cb6b51bad..05c9ebae95175 100644 --- a/src/rollback.h +++ b/src/rollback.h @@ -73,7 +73,7 @@ class RollbackManager: public IRollbackManager int range, int limit); const std::list getActionsSince(time_t firstTime, const std::string & actor = ""); - static float getSuspectNearness(bool is_guess, v3s16 suspect_p, + static float getSuspectNearness(bool is_guess, v3pos_t suspect_p, time_t suspect_t, v3pos_t action_p, time_t action_t); diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index 9900954902f13..d48f9ba03f15a 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include +#include "irr_v3d.h" #include "irrlichttypes_bloated.h" #include "common/c_types.h" @@ -154,7 +155,7 @@ size_t write_array_slice_float(lua_State *L, int table_index, float *data, // This must match the implementation in builtin/game/misc_s.lua // Note that this returns a floating point result as Lua integers are 32-bit -inline lua_Number hash_node_position(v3s16 pos) +inline lua_Number hash_node_position(v3pos_t pos) { return (((s64)pos.Z + 0x8000L) << 32) | (((s64)pos.Y + 0x8000L) << 16) diff --git a/src/script/cpp_api/s_env.cpp b/src/script/cpp_api/s_env.cpp index 099e48c1abcd8..c5bdd9af60a69 100644 --- a/src/script/cpp_api/s_env.cpp +++ b/src/script/cpp_api/s_env.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/s_env.h" #include "cpp_api/s_internal.h" #include "common/c_converter.h" +#include "irr_v3d.h" #include "log.h" #include "environment.h" #include "mapgen/mapgen.h" @@ -257,7 +258,7 @@ void ScriptApiEnv::on_emerge_area_completion( } } -void ScriptApiEnv::check_for_falling(v3s16 p) +void ScriptApiEnv::check_for_falling(v3pos_t p) { SCRIPTAPI_PRECHECKHEADER @@ -265,7 +266,7 @@ void ScriptApiEnv::check_for_falling(v3s16 p) lua_getglobal(L, "core"); lua_getfield(L, -1, "check_for_falling"); luaL_checktype(L, -1, LUA_TFUNCTION); - push_v3s16(L, p); + push_v3pos(L, p); PCALL_RES(lua_pcall(L, 1, 0, error_handler)); } @@ -300,7 +301,7 @@ void ScriptApiEnv::on_liquid_transformed( runCallbacks(2, RUN_CALLBACKS_MODE_FIRST); } -void ScriptApiEnv::on_mapblocks_changed(const std::unordered_set &set) +void ScriptApiEnv::on_mapblocks_changed(const std::unordered_set &set) { SCRIPTAPI_PRECHECKHEADER @@ -312,7 +313,7 @@ void ScriptApiEnv::on_mapblocks_changed(const std::unordered_set &set) // Convert the set to a set of position hashes lua_createtable(L, 0, set.size()); - for(const v3s16 &p : set) { + for(const v3bpos_t &p : set) { lua_pushnumber(L, hash_node_position(p)); lua_pushboolean(L, true); lua_rawset(L, -3); diff --git a/src/script/cpp_api/s_env.h b/src/script/cpp_api/s_env.h index de05c756ae9e5..416ce0ca65e23 100644 --- a/src/script/cpp_api/s_env.h +++ b/src/script/cpp_api/s_env.h @@ -44,13 +44,13 @@ class ScriptApiEnv : virtual public ScriptApiBase void on_emerge_area_completion(v3bpos_t blockpos, int action, ScriptCallbackState *state); - void check_for_falling(v3s16 p); + void check_for_falling(v3pos_t p); // Called after liquid transform changes void on_liquid_transformed(const std::vector> &list); // Called after mapblock changes - void on_mapblocks_changed(const std::unordered_set &set); + void on_mapblocks_changed(const std::unordered_set &set); // Determines whether there are any on_mapblocks_changed callbacks bool has_on_mapblocks_changed(); diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 051cb2ab37e2c..1adbe722f5747 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -18,11 +18,14 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "lua_api/l_mapgen.h" +#include "irr_v3d.h" +#include "irrlichttypes.h" #include "lua_api/l_internal.h" #include "lua_api/l_vmanip.h" #include "common/c_converter.h" #include "common/c_content.h" #include "cpp_api/s_security.h" +#include "server/player_sao.h" #include "util/serialize.h" #include "server.h" #include "environment.h" @@ -821,7 +824,7 @@ int ModApiMapgen::l_get_mapgen_edges(lua_State *L) // make mapgen settings immutable from then on. Mapgen settings should stay // mutable until after mod loading ends. - s16 mapgen_limit; + pos_t mapgen_limit; if (lua_isnumber(L, 1)) { mapgen_limit = lua_tointeger(L, 1); } else { @@ -839,9 +842,9 @@ int ModApiMapgen::l_get_mapgen_edges(lua_State *L) chunksize = stoi(chunksize_str, -32768, 32767); } - std::pair edges = get_mapgen_edges(mapgen_limit, chunksize); - push_v3s16(L, v3s16(1, 1, 1) * edges.first); - push_v3s16(L, v3s16(1, 1, 1) * edges.second); + std::pair edges = get_mapgen_edges(mapgen_limit, chunksize); + push_v3pos(L, v3pos_t(1, 1, 1) * edges.first); + push_v3pos(L, v3pos_t(1, 1, 1) * edges.second); return 2; } diff --git a/src/server.cpp b/src/server.cpp index 222a326654efc..ca579af2beaff 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2276,7 +2276,7 @@ void Server::sendAddNode(v3pos_t p, MapNode n, std::unordered_set *far_play sendNodeChangePkt(pkt, block_pos, p_f, far_d_nodes, far_players); } -void Server::sendNodeChangePkt(NetworkPacket &pkt, v3s16 block_pos, +void Server::sendNodeChangePkt(NetworkPacket &pkt, v3bpos_t block_pos, v3f p, float far_d_nodes, std::unordered_set *far_players) { float maxd = far_d_nodes * BS; diff --git a/src/server.h b/src/server.h index de2fe43205434..4a977f74f2808 100644 --- a/src/server.h +++ b/src/server.h @@ -477,7 +477,7 @@ class Server : public con::PeerHandler, public MapEventReceiver, void sendAddNode(v3pos_t p, MapNode n, std::unordered_set *far_players = nullptr, float far_d_nodes = 100, bool remove_metadata = true); - void sendNodeChangePkt(NetworkPacket &pkt, v3s16 block_pos, + void sendNodeChangePkt(NetworkPacket &pkt, v3bpos_t block_pos, v3f p, float far_d_nodes, std::unordered_set *far_players); void sendMetadataChanged(const std::unordered_set &positions, diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 26825c9cafec4..cd15207bbc048 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include +#include "irr_v3d.h" #include "serverenvironment.h" #include "settings.h" #include "log.h" @@ -388,7 +389,7 @@ void ActiveBlockList::update(std::vector &active_players, void OnMapblocksChangedReceiver::onMapEditEvent(const MapEditEvent &event) { assert(receiving); - for (const v3s16 &p : event.modified_blocks) { + for (const v3pos_t &p : event.modified_blocks) { modified_blocks.insert(p); } } @@ -1590,7 +1591,7 @@ void ServerEnvironment::step(float dtime) // Notify mods of modified mapblocks if (m_on_mapblocks_changed_receiver.receiving && !m_on_mapblocks_changed_receiver.modified_blocks.empty()) { - std::unordered_set modified_blocks; + std::unordered_set modified_blocks; std::swap(modified_blocks, m_on_mapblocks_changed_receiver.modified_blocks); m_script->on_mapblocks_changed(modified_blocks); } diff --git a/src/serverenvironment.h b/src/serverenvironment.h index 6d07d1e9b463a..f3e918541547b 100644 --- a/src/serverenvironment.h +++ b/src/serverenvironment.h @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "activeobject.h" #include "environment.h" +#include "irr_v3d.h" #include "map.h" #include "settings.h" #include "server/activeobjectmgr.h" @@ -195,7 +196,7 @@ class ActiveBlockList ServerEnvironment::m_on_mapblocks_changed_receiver */ struct OnMapblocksChangedReceiver : public MapEventReceiver { - std::unordered_set modified_blocks; + std::unordered_set modified_blocks; bool receiving = false; void onMapEditEvent(const MapEditEvent &event) override; diff --git a/src/unittest/test_map.cpp b/src/unittest/test_map.cpp index 7a8275141bc69..3e3633854c1ae 100644 --- a/src/unittest/test_map.cpp +++ b/src/unittest/test_map.cpp @@ -16,6 +16,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "irr_v3d.h" #include "test.h" #include @@ -78,28 +79,28 @@ void TestMap::testMaxMapgenLimit() void TestMap::testForEachNodeInArea(IGameDef *gamedef) { - v3s16 minp_visit(-10, -10, -10); - v3s16 maxp_visit(20, 20, 10); - v3s16 dims_visit = maxp_visit - minp_visit + v3s16(1, 1, 1); + v3pos_t minp_visit(-10, -10, -10); + v3pos_t maxp_visit(20, 20, 10); + v3pos_t dims_visit = maxp_visit - minp_visit + v3pos_t(1, 1, 1); s32 volume_visit = (s32)dims_visit.X * (s32)dims_visit.Y * (s32)dims_visit.Z; - v3s16 minp = minp_visit - v3s16(1, 1, 1); - v3s16 maxp = maxp_visit + v3s16(1, 1, 1); + v3pos_t minp = minp_visit - v3pos_t(1, 1, 1); + v3pos_t maxp = maxp_visit + v3pos_t(1, 1, 1); DummyMap map(gamedef, getNodeBlockPos(minp), getNodeBlockPos(maxp)); - v3s16 p1(0, 10, 5); + v3pos_t p1(0, 10, 5); MapNode n1(t_CONTENT_STONE); map.setNode(p1, n1); - v3s16 p2(-1, 15, 5); + v3pos_t p2(-1, 15, 5); MapNode n2(t_CONTENT_TORCH); map.setNode(p2, n2); - v3s16 p3 = minp_visit; + v3pos_t p3 = minp_visit; MapNode n3(CONTENT_AIR); map.setNode(p3, n3); - v3s16 p4 = maxp_visit; + v3pos_t p4 = maxp_visit; MapNode n4(t_CONTENT_LAVA); map.setNode(p4, n4); @@ -108,11 +109,11 @@ void TestMap::testForEachNodeInArea(IGameDef *gamedef) map.setNode(maxp, MapNode(t_CONTENT_WATER)); s32 n_visited = 0; - std::unordered_set visited; - v3s16 minp_visited(0, 0, 0); - v3s16 maxp_visited(0, 0, 0); - std::unordered_map found; - map.forEachNodeInArea(minp_visit, maxp_visit, [&](v3s16 p, MapNode n) -> bool { + std::unordered_set visited; + v3pos_t minp_visited(0, 0, 0); + v3pos_t maxp_visited(0, 0, 0); + std::unordered_map found; + map.forEachNodeInArea(minp_visit, maxp_visit, [&](v3pos_t p, MapNode n) -> bool { n_visited++; visited.insert(p); minp_visited.X = std::min(minp_visited.X, p.X); @@ -146,11 +147,11 @@ void TestMap::testForEachNodeInArea(IGameDef *gamedef) void TestMap::testForEachNodeInAreaBlank(IGameDef *gamedef) { - DummyMap map(gamedef, v3s16(0, 0, 0), v3s16(-1, -1, -1)); + DummyMap map(gamedef, v3pos_t(0, 0, 0), v3pos_t(-1, -1, -1)); - v3s16 invalid_p(0, 0, 0); + v3pos_t invalid_p(0, 0, 0); bool visited = false; - map.forEachNodeInArea(invalid_p, invalid_p, [&](v3s16 p, MapNode n) -> bool { + map.forEachNodeInArea(invalid_p, invalid_p, [&](v3pos_t p, MapNode n) -> bool { bool is_valid_position = true; UASSERT(n == map.getNode(p, &is_valid_position)); UASSERT(!is_valid_position); @@ -163,8 +164,8 @@ void TestMap::testForEachNodeInAreaBlank(IGameDef *gamedef) void TestMap::testForEachNodeInAreaEmpty(IGameDef *gamedef) { - DummyMap map(gamedef, v3s16(), v3s16()); - map.forEachNodeInArea(v3s16(0, 0, 0), v3s16(-1, -1, -1), [&](v3s16 p, MapNode n) -> bool { + DummyMap map(gamedef, v3pos_t(), v3pos_t()); + map.forEachNodeInArea(v3pos_t(0, 0, 0), v3pos_t(-1, -1, -1), [&](v3pos_t p, MapNode n) -> bool { UASSERT(false); // Should be unreachable return true; }); diff --git a/src/unittest/test_voxelalgorithms.cpp b/src/unittest/test_voxelalgorithms.cpp index 69260beb6fe19..fd12689cd7747 100644 --- a/src/unittest/test_voxelalgorithms.cpp +++ b/src/unittest/test_voxelalgorithms.cpp @@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "irr_v3d.h" #include "test.h" #include "gamedef.h" @@ -103,14 +104,14 @@ void TestVoxelAlgorithms::testVoxelLineIterator() void TestVoxelAlgorithms::testLighting(IGameDef *gamedef) { - v3s16 pmin(-32, -32, -32); - v3s16 pmax(31, 31, 31); - v3s16 bpmin = getNodeBlockPos(pmin), bpmax = getNodeBlockPos(pmax); + v3pos_t pmin(-32, -32, -32); + v3pos_t pmax(31, 31, 31); + v3pos_t bpmin = getNodeBlockPos(pmin), bpmax = getNodeBlockPos(pmax); DummyMap map(gamedef, bpmin, bpmax); // Make a 21x21x21 hollow box centered at the origin. { - std::map modified_blocks; + std::map modified_blocks; MMVManip vm(&map); vm.initialEmerge(bpmin, bpmax, false); s32 volume = vm.m_area.getVolume(); @@ -119,52 +120,52 @@ void TestVoxelAlgorithms::testLighting(IGameDef *gamedef) for (s16 z = -10; z <= 10; z++) for (s16 y = -10; y <= 10; y++) for (s16 x = -10; x <= 10; x++) - vm.setNodeNoEmerge(v3s16(x, y, z), MapNode(t_CONTENT_STONE)); + vm.setNodeNoEmerge(v3pos_t(x, y, z), MapNode(t_CONTENT_STONE)); for (s16 z = -9; z <= 9; z++) for (s16 y = -9; y <= 9; y++) for (s16 x = -9; x <= 9; x++) - vm.setNodeNoEmerge(v3s16(x, y, z), MapNode(CONTENT_AIR)); + vm.setNodeNoEmerge(v3pos_t(x, y, z), MapNode(CONTENT_AIR)); voxalgo::blit_back_with_light(&map, &vm, &modified_blocks); } // Place two holes on the edges a torch in the center. { - std::map modified_blocks; - map.addNodeAndUpdate(v3s16(-10, 0, 0), MapNode(CONTENT_AIR), modified_blocks); - map.addNodeAndUpdate(v3s16(9, 10, -9), MapNode(t_CONTENT_WATER), modified_blocks); - map.addNodeAndUpdate(v3s16(0, 0, 0), MapNode(t_CONTENT_TORCH), modified_blocks); - map.addNodeAndUpdate(v3s16(-10, 1, 0), MapNode(t_CONTENT_STONE, 153), modified_blocks); + std::map modified_blocks; + map.addNodeAndUpdate(v3pos_t(-10, 0, 0), MapNode(CONTENT_AIR), modified_blocks); + map.addNodeAndUpdate(v3pos_t(9, 10, -9), MapNode(t_CONTENT_WATER), modified_blocks); + map.addNodeAndUpdate(v3pos_t(0, 0, 0), MapNode(t_CONTENT_TORCH), modified_blocks); + map.addNodeAndUpdate(v3pos_t(-10, 1, 0), MapNode(t_CONTENT_STONE, 153), modified_blocks); } const NodeDefManager *ndef = gamedef->ndef(); { - MapNode n = map.getNode(v3s16(9, 9, -9)); + MapNode n = map.getNode(v3pos_t(9, 9, -9)); UASSERTEQ(int, n.getLight(LIGHTBANK_NIGHT, ndef->getLightingFlags(n)), 0); UASSERTEQ(int, n.getLight(LIGHTBANK_DAY, ndef->getLightingFlags(n)), 13); } { - MapNode n = map.getNode(v3s16(0, 1, 0)); + MapNode n = map.getNode(v3pos_t(0, 1, 0)); UASSERTEQ(int, n.getLight(LIGHTBANK_NIGHT, ndef->getLightingFlags(n)), 12); UASSERTEQ(int, n.getLight(LIGHTBANK_DAY, ndef->getLightingFlags(n)), 12); } { - MapNode n = map.getNode(v3s16(-9, -1, 0)); + MapNode n = map.getNode(v3pos_t(-9, -1, 0)); UASSERTEQ(int, n.getLight(LIGHTBANK_NIGHT, ndef->getLightingFlags(n)), 3); UASSERTEQ(int, n.getLight(LIGHTBANK_DAY, ndef->getLightingFlags(n)), 12); } { - MapNode n = map.getNode(v3s16(-10, 0, 0)); + MapNode n = map.getNode(v3pos_t(-10, 0, 0)); UASSERTEQ(int, n.getLight(LIGHTBANK_NIGHT, ndef->getLightingFlags(n)), 3); UASSERTEQ(int, n.getLight(LIGHTBANK_DAY, ndef->getLightingFlags(n)), 14); } { - MapNode n = map.getNode(v3s16(-11, 0, 0)); + MapNode n = map.getNode(v3pos_t(-11, 0, 0)); UASSERTEQ(int, n.getLight(LIGHTBANK_NIGHT, ndef->getLightingFlags(n)), 2); UASSERTEQ(int, n.getLight(LIGHTBANK_DAY, ndef->getLightingFlags(n)), 15); } { // Test that irrelevant param1 values are not clobbered. - MapNode n = map.getNode(v3s16(-10, 1, 0)); + MapNode n = map.getNode(v3pos_t(-10, 1, 0)); UASSERTEQ(int, n.getParam1(), 153); } } diff --git a/src/util/directiontables.cpp b/src/util/directiontables.cpp index 392ab312fd2be..ab90c63dcd8c9 100644 --- a/src/util/directiontables.cpp +++ b/src/util/directiontables.cpp @@ -128,37 +128,37 @@ const v3s16 wallmounted_dirs[8] = { v3s16(0, 0, -1), }; -const v3s16 facedir_dirs[32] = { +const v3pos_t facedir_dirs[32] = { //0 - v3s16(0, 0, 1), - v3s16(1, 0, 0), - v3s16(0, 0, -1), - v3s16(-1, 0, 0), + v3pos_t(0, 0, 1), + v3pos_t(1, 0, 0), + v3pos_t(0, 0, -1), + v3pos_t(-1, 0, 0), //4 - v3s16(0, -1, 0), - v3s16(1, 0, 0), - v3s16(0, 1, 0), - v3s16(-1, 0, 0), + v3pos_t(0, -1, 0), + v3pos_t(1, 0, 0), + v3pos_t(0, 1, 0), + v3pos_t(-1, 0, 0), //8 - v3s16(0, 1, 0), - v3s16(1, 0, 0), - v3s16(0, -1, 0), - v3s16(-1, 0, 0), + v3pos_t(0, 1, 0), + v3pos_t(1, 0, 0), + v3pos_t(0, -1, 0), + v3pos_t(-1, 0, 0), //12 - v3s16(0, 0, 1), - v3s16(0, -1, 0), - v3s16(0, 0, -1), - v3s16(0, 1, 0), + v3pos_t(0, 0, 1), + v3pos_t(0, -1, 0), + v3pos_t(0, 0, -1), + v3pos_t(0, 1, 0), //16 - v3s16(0, 0, 1), - v3s16(0, 1, 0), - v3s16(0, 0, -1), - v3s16(0, -1, 0), + v3pos_t(0, 0, 1), + v3pos_t(0, 1, 0), + v3pos_t(0, 0, -1), + v3pos_t(0, -1, 0), //20 - v3s16(0, 0, 1), - v3s16(-1, 0, 0), - v3s16(0, 0, -1), - v3s16(1, 0, 0), + v3pos_t(0, 0, 1), + v3pos_t(-1, 0, 0), + v3pos_t(0, 0, -1), + v3pos_t(1, 0, 0), }; const v3s16 fourdir_dirs[4] = { diff --git a/src/util/directiontables.h b/src/util/directiontables.h index 9ecee454feb1d..8abd71189f372 100644 --- a/src/util/directiontables.h +++ b/src/util/directiontables.h @@ -35,7 +35,7 @@ extern const u8 wallmounted_to_facedir[6]; extern const v3s16 wallmounted_dirs[8]; -extern const v3s16 facedir_dirs[32]; +extern const v3pos_t facedir_dirs[32]; extern const v3s16 fourdir_dirs[4]; diff --git a/src/util/pointedthing.cpp b/src/util/pointedthing.cpp index df7ebd6301416..90258b8ade7cc 100644 --- a/src/util/pointedthing.cpp +++ b/src/util/pointedthing.cpp @@ -19,11 +19,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "pointedthing.h" +#include "irr_v3d.h" #include "serialize.h" #include "exceptions.h" #include -PointedThing::PointedThing(const v3s16 &under, const v3pos_t &above, +PointedThing::PointedThing(const v3pos_t &under, const v3pos_t &above, const v3pos_t &real_under, const v3f &point, const v3f &normal, u16 box_id, f32 distSq): type(POINTEDTHING_NODE),