aboutsummaryrefslogtreecommitdiff
path: root/src/network
Commit message (Expand)AuthorAge
* Fix "error: ‘playerSAO’ was not declared"Auke Kok2017-04-06
* Fix spacingEkdohibs2017-04-06
* Fix problems when overriding the hand:Ekdohibs2017-04-06
* Fix multiple death messages (#5305)presstabstart2017-04-06
* Client handlers: Remove useless stringstream usage in two handlers (#5510)Loïc Blot2017-04-04
* Update server min protocol version to v24 (#5411)Loïc Blot2017-03-19
* [CSM] Add minimap API modifiers (#5399)Loïc Blot2017-03-16
* [CSM] Add enable_client_modding param (default: false)nerzhul2017-03-13
* [CSM] Add on_death, on_hp_modification & oh_damage_taken callbacks (#5093)Loïc Blot2017-03-13
* [CSM] Add method that display chat to client-sided lua. (#5089) (#5091)red-0012017-03-13
* [CSM] Client side moddingLoic Blot2017-03-13
* Plantlike: Fix visual_scale being applied squaredparamat2017-02-10
* Revert "Plantlike visual scale: Send sqrt(visual_scale) to old clients"Craig Robbins2017-02-10
* Plantlike visual scale: Send sqrt(visual_scale) to old clientsparamat2017-01-30
* Wrap to positive degree values (#5106)raymoo2017-01-24
* Add hardware node coloring. Includes:Dániel Juhász2017-01-23
* Add particle animation, glowsfan52017-01-18
* Remove client-side chat prediction. (#5055)red-0012017-01-17
* Cleanup some header inclusions to improve compilation timesLoic Blot2017-01-11
* Move TileAnimation code to seperate filesfan52017-01-02
* Fix non reverted change on TOSERVER_BREATH compatLoic Blot2017-01-01
* Breath cheat fix: server sideLoic Blot2017-01-01
* Fix interact range check (thanks to @lhofhansl)sfan52016-12-29
* Use the outgoing split sequence number for every outgoing packet (#4864)Rogier-52016-12-29
* Various anticheat improvementssfan52016-12-26
* Fix computation of viewing range (in blocks) sent to server (#4882)Rogier-52016-12-11
* Optimize block sent: Fix rendering issueLars Hofhansl2016-12-03
* Optimize/adjust blocks/ActiveObjects sent at the server based on client setti...lhofhansl2016-11-30
* Wieldhand: Allow overriding the handTeTpaAka2016-11-26
* Revert "Adding particle blend, glow and animation (#4705)"sfan52016-11-14
* Adding particle blend, glow and animation (#4705)Foghrye42016-11-15
* Add control information to player interacts (#4685)raymoo2016-11-12
* Fix overloading problems mentioned by clangLoic Blot2016-10-30
* PlayerSAO/LocalPlayer refactor: (#4612)Ner'zhul2016-10-30
* Attached particle spawnersraymoo2016-10-13
* More code cleanup (UNORDERED + RemotePlayer/LocalPlayer)Loic Blot2016-10-08
* Player/LocalPlayer/RemotePlayer inheritance cleanup (part 2 on X)Loic Blot2016-10-08
* Player/LocalPlayer/RemotePlayer inheritance cleanup (part 1 on X)Loic Blot2016-10-08
* use unordered containers where possible (patch 4 on X)Loic Blot2016-10-06
* Use more unordered_maps to improve performance in c++11 buildsLoic Blot2016-10-06
* Chat: new settings to prevent spamLoic Blot2016-10-05
* Make plantlike drawtype more funAuke Kok2016-08-26
* Sapier's fix for the RESEND RELIABLE problem (#4170)Robert Kiraly2016-06-03
* Particles: Add option to remove particles on collisionAuke Kok2016-05-28
* Tolerate packet reordering in the early init processest312016-05-22
* Fix small formatting issue in SRP debug outputsfan52016-03-29
* Clean up StrfndShadowNinja2016-03-19
* Add option to not send pre v25 init packetest312016-03-15
* Much better API for auth.{cpp, h}est312016-03-15
* Fix player teleportation bug whilst sneakingHybridDog2016-03-14
s="hl opt">(v3s16( 1, 0, 1)); // back right list.push_back(v3s16(-1, 0,-1)); // front left list.push_back(v3s16( 1, 0,-1)); // front right list.push_back(v3s16(-1,-1, 0)); // bottom left list.push_back(v3s16( 1,-1, 0)); // bottom right list.push_back(v3s16( 0,-1, 1)); // bottom back list.push_back(v3s16( 0,-1,-1)); // bottom front list.push_back(v3s16(-1, 1, 0)); // top left list.push_back(v3s16( 1, 1, 0)); // top right list.push_back(v3s16( 0, 1, 1)); // top back list.push_back(v3s16( 0, 1,-1)); // top front // 18 list.push_back(v3s16(-1, 1, 1)); // top back-left list.push_back(v3s16( 1, 1, 1)); // top back-right list.push_back(v3s16(-1, 1,-1)); // top front-left list.push_back(v3s16( 1, 1,-1)); // top front-right list.push_back(v3s16(-1,-1, 1)); // bottom back-left list.push_back(v3s16( 1,-1, 1)); // bottom back-right list.push_back(v3s16(-1,-1,-1)); // bottom front-left list.push_back(v3s16( 1,-1,-1)); // bottom front-right // 26 return; } // Take blocks in all sides, starting from y=0 and going +-y for(s16 y=0; y<=d-1; y++) { // Left and right side, including borders for(s16 z=-d; z<=d; z++) { list.push_back(v3s16(d,y,z)); list.push_back(v3s16(-d,y,z)); if(y != 0) { list.push_back(v3s16(d,-y,z)); list.push_back(v3s16(-d,-y,z)); } } // Back and front side, excluding borders for(s16 x=-d+1; x<=d-1; x++) { list.push_back(v3s16(x,y,d)); list.push_back(v3s16(x,y,-d)); if(y != 0) { list.push_back(v3s16(x,-y,d)); list.push_back(v3s16(x,-y,-d)); } } } // Take the bottom and top face with borders // -d<x<d, y=+-d, -d<z<d for(s16 x=-d; x<=d; x++) for(s16 z=-d; z<=d; z++) { list.push_back(v3s16(x,-d,z)); list.push_back(v3s16(x,d,z)); } } /* myrand */ static unsigned long next = 1; /* RAND_MAX assumed to be 32767 */ int myrand(void) { next = next * 1103515245 + 12345; return((unsigned)(next/65536) % 32768); } void mysrand(unsigned seed) { next = seed; } int myrand_range(int min, int max) { if(max-min > MYRAND_MAX) { errorstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<std::endl; max = min + MYRAND_MAX; } if(min > max) { errorstream<<"WARNING: myrand_range: min > max"<<std::endl; return max; } return (myrand()%(max-min+1))+min; } // 64-bit unaligned version of MurmurHash u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed) { const u64 m = 0xc6a4a7935bd1e995ULL; const int r = 47; u64 h = seed ^ (len * m); const u64 *data = (const u64 *)key; const u64 *end = data + (len / 8); while (data != end) { u64 k; memcpy(&k, data, sizeof(u64)); data++; k *= m; k ^= k >> r; k *= m; h ^= k; h *= m; } const unsigned char *data2 = (const unsigned char *)data; switch (len & 7) { case 7: h ^= (u64)data2[6] << 48; case 6: h ^= (u64)data2[5] << 40; case 5: h ^= (u64)data2[4] << 32; case 4: h ^= (u64)data2[3] << 24; case 3: h ^= (u64)data2[2] << 16; case 2: h ^= (u64)data2[1] << 8; case 1: h ^= (u64)data2[0]; h *= m; } h ^= h >> r; h *= m; h ^= h >> r; return h; } /* blockpos: position of block in block coordinates camera_pos: position of camera in nodes camera_dir: an unit vector pointing to camera direction range: viewing range */ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 camera_fov, f32 range, f32 *distance_ptr) { v3s16 blockpos_nodes = blockpos_b * MAP_BLOCKSIZE; // Block center position v3f blockpos( ((float)blockpos_nodes.X + MAP_BLOCKSIZE/2) * BS, ((float)blockpos_nodes.Y + MAP_BLOCKSIZE/2) * BS, ((float)blockpos_nodes.Z + MAP_BLOCKSIZE/2) * BS ); // Block position relative to camera v3f blockpos_relative = blockpos - camera_pos; // Total distance f32 d = blockpos_relative.getLength(); if(distance_ptr) *distance_ptr = d; // If block is far away, it's not in sight if(d > range) return false; // Maximum radius of a block. The magic number is // sqrt(3.0) / 2.0 in literal form. f32 block_max_radius = 0.866025403784 * MAP_BLOCKSIZE * BS; // If block is (nearly) touching the camera, don't // bother validating further (that is, render it anyway) if(d < block_max_radius) return true; // Adjust camera position, for purposes of computing the angle, // such that a block that has any portion visible with the // current camera position will have the center visible at the // adjusted postion f32 adjdist = block_max_radius / cos((M_PI - camera_fov) / 2); // Block position relative to adjusted camera v3f blockpos_adj = blockpos - (camera_pos - camera_dir * adjdist); // Distance in camera direction (+=front, -=back) f32 dforward = blockpos_adj.dotProduct(camera_dir); // Cosine of the angle between the camera direction // and the block direction (camera_dir is an unit vector) f32 cosangle = dforward / blockpos_adj.getLength(); // If block is not in the field of view, skip it if(cosangle < cos(camera_fov / 2)) return false; return true; }