Merge remote-tracking branch 'minetest/master'
commit
d97b4d420d
|
@ -31,7 +31,8 @@ NoiseParams nparams_caveliquids(0, 1, v3f(150.0, 150.0, 150.0), 776, 3, 0.6, 2.0
|
|||
///////////////////////////////////////// Caves V5
|
||||
|
||||
|
||||
CaveV5::CaveV5(MapgenV5 *mg, PseudoRandom *ps) {
|
||||
CaveV5::CaveV5(MapgenV5 *mg, PseudoRandom *ps)
|
||||
{
|
||||
this->mg = mg;
|
||||
this->vm = mg->vm;
|
||||
this->ndef = mg->ndef;
|
||||
|
@ -54,7 +55,8 @@ CaveV5::CaveV5(MapgenV5 *mg, PseudoRandom *ps) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV5::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
||||
void CaveV5::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
|
||||
{
|
||||
node_min = nmin;
|
||||
node_max = nmax;
|
||||
main_direction = v3f(0, 0, 0);
|
||||
|
@ -115,8 +117,8 @@ void CaveV5::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV5::makeTunnel(bool dirswitch) {
|
||||
|
||||
void CaveV5::makeTunnel(bool dirswitch)
|
||||
{
|
||||
// Randomize size
|
||||
s16 min_d = min_tunnel_diameter;
|
||||
s16 max_d = max_tunnel_diameter;
|
||||
|
@ -201,7 +203,8 @@ void CaveV5::makeTunnel(bool dirswitch) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz) {
|
||||
void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz)
|
||||
{
|
||||
MapNode airnode(CONTENT_AIR);
|
||||
MapNode waternode(c_water_source);
|
||||
MapNode lavanode(c_lava_source);
|
||||
|
@ -271,7 +274,8 @@ void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz) {
|
|||
///////////////////////////////////////// Caves V6
|
||||
|
||||
|
||||
CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_cave) {
|
||||
CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_cave)
|
||||
{
|
||||
this->mg = mg;
|
||||
this->vm = mg->vm;
|
||||
this->ndef = mg->ndef;
|
||||
|
@ -301,7 +305,8 @@ CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_
|
|||
}
|
||||
|
||||
|
||||
void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
||||
void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
|
||||
{
|
||||
node_min = nmin;
|
||||
node_max = nmax;
|
||||
max_stone_y = max_stone_height;
|
||||
|
@ -368,7 +373,8 @@ void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV6::makeTunnel(bool dirswitch) {
|
||||
void CaveV6::makeTunnel(bool dirswitch)
|
||||
{
|
||||
if (dirswitch && !large_cave) {
|
||||
main_direction = v3f(
|
||||
((float)(ps->next() % 20) - (float)10) / 10,
|
||||
|
@ -414,7 +420,8 @@ void CaveV6::makeTunnel(bool dirswitch) {
|
|||
);
|
||||
}
|
||||
|
||||
// Do not make caves that are entirely above ground.
|
||||
// Do not make caves that are entirely above ground, to fix
|
||||
// shadow bugs caused by overgenerated large caves.
|
||||
// It is only necessary to check the startpoint and endpoint.
|
||||
v3s16 orpi(orp.X, orp.Y, orp.Z);
|
||||
v3s16 veci(vec.X, vec.Y, vec.Z);
|
||||
|
@ -441,8 +448,11 @@ void CaveV6::makeTunnel(bool dirswitch) {
|
|||
h2 = water_level;
|
||||
}
|
||||
|
||||
if (p1.Y > h1 && p2.Y > h2) // If startpoint and endpoint are above ground
|
||||
return;
|
||||
// If startpoint and endpoint are above ground,
|
||||
// disable placing of nodes in carveRoute while
|
||||
// still running all pseudorandom calls to ensure
|
||||
// caves consistent with existing worlds.
|
||||
bool tunnel_above_ground = p1.Y > h1 && p2.Y > h2;
|
||||
|
||||
vec += main_direction;
|
||||
|
||||
|
@ -474,13 +484,14 @@ void CaveV6::makeTunnel(bool dirswitch) {
|
|||
|
||||
// Carve routes
|
||||
for (float f = 0; f < 1.0; f += 1.0 / veclen)
|
||||
carveRoute(vec, f, randomize_xz);
|
||||
carveRoute(vec, f, randomize_xz, tunnel_above_ground);
|
||||
|
||||
orp = rp;
|
||||
}
|
||||
|
||||
|
||||
void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
|
||||
void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground)
|
||||
{
|
||||
MapNode airnode(CONTENT_AIR);
|
||||
MapNode waternode(c_water_source);
|
||||
MapNode lavanode(c_lava_source);
|
||||
|
@ -503,6 +514,9 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
|
|||
for (s16 z0 = d0; z0 <= d1; z0++) {
|
||||
s16 si = rs / 2 - MYMAX(0, abs(z0) - rs / 7 - 1);
|
||||
for (s16 x0 = -si - ps->range(0,1); x0 <= si - 1 + ps->range(0,1); x0++) {
|
||||
if (tunnel_above_ground)
|
||||
continue;
|
||||
|
||||
s16 maxabsxz = MYMAX(abs(x0), abs(z0));
|
||||
s16 si2 = rs / 2 - MYMAX(0, maxabsxz - rs / 7 - 1);
|
||||
for (s16 y0 = -si2; y0 <= si2; y0++) {
|
||||
|
@ -553,7 +567,8 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
|
|||
///////////////////////////////////////// Caves V7
|
||||
|
||||
|
||||
CaveV7::CaveV7(MapgenV7 *mg, PseudoRandom *ps) {
|
||||
CaveV7::CaveV7(MapgenV7 *mg, PseudoRandom *ps)
|
||||
{
|
||||
this->mg = mg;
|
||||
this->vm = mg->vm;
|
||||
this->ndef = mg->ndef;
|
||||
|
@ -576,7 +591,8 @@ CaveV7::CaveV7(MapgenV7 *mg, PseudoRandom *ps) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
||||
void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
|
||||
{
|
||||
node_min = nmin;
|
||||
node_max = nmax;
|
||||
max_stone_y = max_stone_height;
|
||||
|
@ -638,8 +654,8 @@ void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV7::makeTunnel(bool dirswitch) {
|
||||
|
||||
void CaveV7::makeTunnel(bool dirswitch)
|
||||
{
|
||||
// Randomize size
|
||||
s16 min_d = min_tunnel_diameter;
|
||||
s16 max_d = max_tunnel_diameter;
|
||||
|
@ -724,7 +740,8 @@ void CaveV7::makeTunnel(bool dirswitch) {
|
|||
}
|
||||
|
||||
|
||||
void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz) {
|
||||
void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz)
|
||||
{
|
||||
MapNode airnode(CONTENT_AIR);
|
||||
MapNode waternode(c_water_source);
|
||||
MapNode lavanode(c_lava_source);
|
||||
|
@ -790,4 +807,3 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool large_cave);
|
||||
void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
|
||||
void makeTunnel(bool dirswitch);
|
||||
void carveRoute(v3f vec, float f, bool randomize_xz);
|
||||
void carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground);
|
||||
};
|
||||
|
||||
class CaveV7 {
|
||||
|
|
|
@ -168,6 +168,8 @@ enum MaterialType{
|
|||
// defined by extra parameters
|
||||
#define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
|
||||
#define MATERIAL_FLAG_HIGHLIGHTED 0x10
|
||||
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
|
||||
#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
|
||||
|
||||
/*
|
||||
This fully defines the looks of a tile.
|
||||
|
@ -216,7 +218,9 @@ struct TileSpec
|
|||
alpha == other.alpha &&
|
||||
material_type == other.material_type &&
|
||||
material_flags == other.material_flags &&
|
||||
rotation == other.rotation
|
||||
rotation == other.rotation &&
|
||||
(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) &&
|
||||
(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -250,12 +254,26 @@ struct TileSpec
|
|||
}
|
||||
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
|
||||
? true : false;
|
||||
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
|
||||
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
|
||||
}
|
||||
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
|
||||
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
||||
}
|
||||
}
|
||||
|
||||
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
|
||||
{
|
||||
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
|
||||
? true : false;
|
||||
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
|
||||
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
|
||||
material.TextureLayer[1].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
|
||||
}
|
||||
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
|
||||
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
||||
material.TextureLayer[1].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
||||
}
|
||||
}
|
||||
|
||||
u32 texture_id;
|
||||
|
|
|
@ -58,7 +58,7 @@ void set_default_settings(Settings *settings)
|
|||
#if DEBUG
|
||||
"KEY_F4");
|
||||
#else
|
||||
"none");
|
||||
"");
|
||||
#endif
|
||||
settings->setDefault("keymap_toggle_debug", "KEY_F5");
|
||||
settings->setDefault("keymap_toggle_profiler", "KEY_F6");
|
||||
|
|
|
@ -258,7 +258,11 @@ KeyPress::KeyPress() :
|
|||
|
||||
KeyPress::KeyPress(const char *name)
|
||||
{
|
||||
if (strlen(name) > 4) {
|
||||
if (name[0] == 0) {
|
||||
Key = irr::KEY_KEY_CODES_COUNT;
|
||||
Char = L'\0';
|
||||
return;
|
||||
} else if (strlen(name) > 4) {
|
||||
try {
|
||||
Key = keyname_to_keycode(name);
|
||||
m_name = name;
|
||||
|
|
|
@ -230,7 +230,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
|||
player is sneaking from, if any. If the node from under
|
||||
the player has been removed, the player falls.
|
||||
*/
|
||||
v3s16 current_node = floatToInt(position - v3f(0,BS/2,0), BS);
|
||||
v3s16 current_node = floatToInt(position - v3f(0, 0.05 * BS, 0), BS);
|
||||
if(m_sneak_node_exists &&
|
||||
nodemgr->get(map->getNodeNoEx(m_old_node_below)).name == "air" &&
|
||||
m_old_node_below_type != "air")
|
||||
|
@ -248,7 +248,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
|||
}
|
||||
if(m_need_to_get_new_sneak_node && physics_override_sneak)
|
||||
{
|
||||
v3s16 pos_i_bottom = floatToInt(position - v3f(0,BS/2,0), BS);
|
||||
v3s16 pos_i_bottom = floatToInt(position - v3f(0, 0.05 * BS ,0), BS);
|
||||
v2f player_p2df(position.X, position.Z);
|
||||
f32 min_distance_f = 100000.0*BS;
|
||||
// If already seeking from some node, compare to it.
|
||||
|
|
|
@ -312,13 +312,29 @@ BufferedPacket ReliablePacketBuffer::popSeqnum(u16 seqnum)
|
|||
void ReliablePacketBuffer::insert(BufferedPacket &p,u16 next_expected)
|
||||
{
|
||||
JMutexAutoLock listlock(m_list_mutex);
|
||||
FATAL_ERROR_IF(p.data.getSize() < BASE_HEADER_SIZE+3, "Invalid data size");
|
||||
u8 type = readU8(&p.data[BASE_HEADER_SIZE+0]);
|
||||
sanity_check(type == TYPE_RELIABLE);
|
||||
u16 seqnum = readU16(&p.data[BASE_HEADER_SIZE+1]);
|
||||
if (p.data.getSize() < BASE_HEADER_SIZE + 3) {
|
||||
errorstream << "ReliablePacketBuffer::insert(): Invalid data size for "
|
||||
"reliable packet" << std::endl;
|
||||
return;
|
||||
}
|
||||
u8 type = readU8(&p.data[BASE_HEADER_SIZE + 0]);
|
||||
if (type != TYPE_RELIABLE) {
|
||||
errorstream << "ReliablePacketBuffer::insert(): type is not reliable"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
u16 seqnum = readU16(&p.data[BASE_HEADER_SIZE + 1]);
|
||||
|
||||
sanity_check(seqnum_in_window(seqnum, next_expected, MAX_RELIABLE_WINDOW_SIZE));
|
||||
sanity_check(seqnum != next_expected);
|
||||
if (!seqnum_in_window(seqnum, next_expected, MAX_RELIABLE_WINDOW_SIZE)) {
|
||||
errorstream << "ReliablePacketBuffer::insert(): seqnum is outside of "
|
||||
"expected window " << std::endl;
|
||||
return;
|
||||
}
|
||||
if (seqnum == next_expected) {
|
||||
errorstream << "ReliablePacketBuffer::insert(): seqnum is next expected"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
++m_list_size;
|
||||
sanity_check(m_list_size <= SEQNUM_MAX+1); // FIXME: Handle the error?
|
||||
|
@ -377,10 +393,6 @@ void ReliablePacketBuffer::insert(BufferedPacket &p,u16 next_expected)
|
|||
throw IncomingDataCorruption("duplicated packet isn't same as original one");
|
||||
}
|
||||
|
||||
sanity_check(readU16(&(i->data[BASE_HEADER_SIZE+1])) == seqnum);
|
||||
sanity_check(i->data.getSize() == p.data.getSize());
|
||||
sanity_check(i->address == p.address);
|
||||
|
||||
/* nothing to do this seems to be a resent packet */
|
||||
/* for paranoia reason data should be compared */
|
||||
--m_list_size;
|
||||
|
@ -449,13 +461,21 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
|
|||
{
|
||||
JMutexAutoLock listlock(m_map_mutex);
|
||||
u32 headersize = BASE_HEADER_SIZE + 7;
|
||||
FATAL_ERROR_IF(p.data.getSize() < headersize, "Invalid data size");
|
||||
if (p.data.getSize() < headersize) {
|
||||
errorstream << "Invalid data size for split packet" << std::endl;
|
||||
return SharedBuffer<u8>();
|
||||
}
|
||||
u8 type = readU8(&p.data[BASE_HEADER_SIZE+0]);
|
||||
sanity_check(type == TYPE_SPLIT);
|
||||
u16 seqnum = readU16(&p.data[BASE_HEADER_SIZE+1]);
|
||||
u16 chunk_count = readU16(&p.data[BASE_HEADER_SIZE+3]);
|
||||
u16 chunk_num = readU16(&p.data[BASE_HEADER_SIZE+5]);
|
||||
|
||||
if (type != TYPE_SPLIT) {
|
||||
errorstream << "IncomingSplitBuffer::insert(): type is not split"
|
||||
<< std::endl;
|
||||
return SharedBuffer<u8>();
|
||||
}
|
||||
|
||||
// Add if doesn't exist
|
||||
if (m_buf.find(seqnum) == m_buf.end())
|
||||
{
|
||||
|
@ -2327,8 +2347,9 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||
u8 type = readU8(&(packetdata[0]));
|
||||
|
||||
if (MAX_UDP_PEERS <= 65535 && peer_id >= MAX_UDP_PEERS) {
|
||||
errorstream << "Something is wrong with peer_id" << std::endl;
|
||||
FATAL_ERROR("");
|
||||
std::string errmsg = "Invalid peer_id=" + itos(peer_id);
|
||||
errorstream << errmsg << std::endl;
|
||||
throw InvalidIncomingDataException(errmsg.c_str());
|
||||
}
|
||||
|
||||
if (type == TYPE_CONTROL)
|
||||
|
@ -2340,10 +2361,12 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||
|
||||
if (controltype == CONTROLTYPE_ACK)
|
||||
{
|
||||
FATAL_ERROR_IF(channel == 0, "Invalid channel (0)");
|
||||
if (packetdata.getSize() < 4)
|
||||
throw InvalidIncomingDataException
|
||||
("packetdata.getSize() < 4 (ACK header size)");
|
||||
assert(channel != NULL);
|
||||
|
||||
if (packetdata.getSize() < 4) {
|
||||
throw InvalidIncomingDataException(
|
||||
"packetdata.getSize() < 4 (ACK header size)");
|
||||
}
|
||||
|
||||
u16 seqnum = readU16(&packetdata[2]);
|
||||
LOG(dout_con<<m_connection->getDesc()
|
||||
|
@ -2508,7 +2531,8 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||
}
|
||||
else if (type == TYPE_RELIABLE)
|
||||
{
|
||||
FATAL_ERROR_IF(channel == 0, "Invalid channel (0)");
|
||||
assert(channel != NULL);
|
||||
|
||||
// Recursive reliable packets not allowed
|
||||
if (reliable)
|
||||
throw InvalidIncomingDataException("Found nested reliable packets");
|
||||
|
|
|
@ -172,7 +172,7 @@ struct BufferedPacket
|
|||
data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
|
||||
resend_count(0)
|
||||
{}
|
||||
SharedBuffer<u8> data; // Data of the packet, including headers
|
||||
Buffer<u8> data; // Data of the packet, including headers
|
||||
float time; // Seconds from buffering the packet or re-sending
|
||||
float totaltime; // Seconds from buffering the packet
|
||||
unsigned int absolute_send_time;
|
||||
|
|
|
@ -39,9 +39,9 @@ NetworkPacket::~NetworkPacket()
|
|||
m_data.clear();
|
||||
}
|
||||
|
||||
void NetworkPacket::checkReadOffset(u32 from_offset)
|
||||
void NetworkPacket::checkReadOffset(u32 from_offset, u32 field_size)
|
||||
{
|
||||
if (from_offset >= m_datasize) {
|
||||
if (from_offset + field_size > m_datasize) {
|
||||
std::stringstream ss;
|
||||
ss << "Reading outside packet (offset: " <<
|
||||
from_offset << ", packet size: " << getSize() << ")";
|
||||
|
@ -65,7 +65,7 @@ void NetworkPacket::putRawPacket(u8 *data, u32 datasize, u16 peer_id)
|
|||
|
||||
char* NetworkPacket::getString(u32 from_offset)
|
||||
{
|
||||
checkReadOffset(from_offset);
|
||||
checkReadOffset(from_offset, 0);
|
||||
|
||||
return (char*)&m_data[from_offset];
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ void NetworkPacket::putRawString(const char* src, u32 len)
|
|||
|
||||
NetworkPacket& NetworkPacket::operator>>(std::string& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 2);
|
||||
u16 strLen = readU16(&m_data[m_read_offset]);
|
||||
m_read_offset += sizeof(u16);
|
||||
|
||||
|
@ -92,6 +93,8 @@ NetworkPacket& NetworkPacket::operator>>(std::string& dst)
|
|||
return *this;
|
||||
}
|
||||
|
||||
checkReadOffset(m_read_offset, strLen);
|
||||
|
||||
dst.reserve(strLen);
|
||||
dst.append((char*)&m_data[m_read_offset], strLen);
|
||||
|
||||
|
@ -127,8 +130,9 @@ void NetworkPacket::putLongString(std::string src)
|
|||
|
||||
NetworkPacket& NetworkPacket::operator>>(std::wstring& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 2);
|
||||
u16 strLen = readU16(&m_data[m_read_offset]);
|
||||
m_read_offset += sizeof(u16);
|
||||
m_read_offset += 2;
|
||||
|
||||
dst.clear();
|
||||
|
||||
|
@ -136,6 +140,8 @@ NetworkPacket& NetworkPacket::operator>>(std::wstring& dst)
|
|||
return *this;
|
||||
}
|
||||
|
||||
checkReadOffset(m_read_offset, strLen * 2);
|
||||
|
||||
dst.reserve(strLen);
|
||||
for(u16 i=0; i<strLen; i++) {
|
||||
wchar_t c16 = readU16(&m_data[m_read_offset]);
|
||||
|
@ -165,13 +171,16 @@ NetworkPacket& NetworkPacket::operator<<(std::wstring src)
|
|||
|
||||
std::string NetworkPacket::readLongString()
|
||||
{
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
u32 strLen = readU32(&m_data[m_read_offset]);
|
||||
m_read_offset += sizeof(u32);
|
||||
m_read_offset += 4;
|
||||
|
||||
if (strLen == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
checkReadOffset(m_read_offset, strLen);
|
||||
|
||||
std::string dst;
|
||||
|
||||
dst.reserve(strLen);
|
||||
|
@ -184,114 +193,114 @@ std::string NetworkPacket::readLongString()
|
|||
|
||||
NetworkPacket& NetworkPacket::operator>>(char& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 1);
|
||||
|
||||
dst = readU8(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<char>();
|
||||
m_read_offset += 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
char NetworkPacket::getChar(u32 offset)
|
||||
{
|
||||
checkReadOffset(offset);
|
||||
checkReadOffset(offset, 1);
|
||||
|
||||
return readU8(&m_data[offset]);
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(char src)
|
||||
{
|
||||
checkDataSize<u8>();
|
||||
checkDataSize(1);
|
||||
|
||||
writeU8(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<char>();
|
||||
m_read_offset += 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(u8 src)
|
||||
{
|
||||
checkDataSize<u8>();
|
||||
checkDataSize(1);
|
||||
|
||||
writeU8(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<u8>();
|
||||
m_read_offset += 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(bool src)
|
||||
{
|
||||
checkDataSize<u8>();
|
||||
checkDataSize(1);
|
||||
|
||||
writeU8(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<u8>();
|
||||
m_read_offset += 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(u16 src)
|
||||
{
|
||||
checkDataSize<u16>();
|
||||
checkDataSize(2);
|
||||
|
||||
writeU16(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<u16>();
|
||||
m_read_offset += 2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(u32 src)
|
||||
{
|
||||
checkDataSize<u32>();
|
||||
checkDataSize(4);
|
||||
|
||||
writeU32(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<u32>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(u64 src)
|
||||
{
|
||||
checkDataSize<u64>();
|
||||
checkDataSize(8);
|
||||
|
||||
writeU64(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<u64>();
|
||||
m_read_offset += 8;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(float src)
|
||||
{
|
||||
checkDataSize<float>();
|
||||
checkDataSize(4);
|
||||
|
||||
writeF1000(&m_data[m_read_offset], src);
|
||||
|
||||
incrOffset<float>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(bool& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 1);
|
||||
|
||||
dst = readU8(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<u8>();
|
||||
m_read_offset += 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(u8& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 1);
|
||||
|
||||
dst = readU8(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<u8>();
|
||||
m_read_offset += 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
u8 NetworkPacket::getU8(u32 offset)
|
||||
{
|
||||
checkReadOffset(offset);
|
||||
checkReadOffset(offset, 1);
|
||||
|
||||
return readU8(&m_data[offset]);
|
||||
}
|
||||
|
@ -302,85 +311,85 @@ u8* NetworkPacket::getU8Ptr(u32 from_offset)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
checkReadOffset(from_offset);
|
||||
checkReadOffset(from_offset, 1);
|
||||
|
||||
return (u8*)&m_data[from_offset];
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(u16& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 2);
|
||||
|
||||
dst = readU16(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<u16>();
|
||||
m_read_offset += 2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
u16 NetworkPacket::getU16(u32 from_offset)
|
||||
{
|
||||
checkReadOffset(from_offset);
|
||||
checkReadOffset(from_offset, 2);
|
||||
|
||||
return readU16(&m_data[from_offset]);
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(u32& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
|
||||
dst = readU32(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<u32>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(u64& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 8);
|
||||
|
||||
dst = readU64(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<u64>();
|
||||
m_read_offset += 8;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(float& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
|
||||
dst = readF1000(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<float>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(v2f& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 8);
|
||||
|
||||
dst = readV2F1000(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<v2f>();
|
||||
m_read_offset += 8;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(v3f& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 12);
|
||||
|
||||
dst = readV3F1000(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<v3f>();
|
||||
m_read_offset += 12;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(s16& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 2);
|
||||
|
||||
dst = readS16(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<s16>();
|
||||
m_read_offset += 2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -392,11 +401,11 @@ NetworkPacket& NetworkPacket::operator<<(s16 src)
|
|||
|
||||
NetworkPacket& NetworkPacket::operator>>(s32& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
|
||||
dst = readS32(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<s32>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -408,29 +417,31 @@ NetworkPacket& NetworkPacket::operator<<(s32 src)
|
|||
|
||||
NetworkPacket& NetworkPacket::operator>>(v3s16& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 6);
|
||||
|
||||
dst = readV3S16(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<v3s16>();
|
||||
m_read_offset += 6;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(v2s32& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 8);
|
||||
|
||||
dst = readV2S32(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<v2s32>();
|
||||
m_read_offset += 8;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(v3s32& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 12);
|
||||
|
||||
dst = readV3S32(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<v3s32>();
|
||||
m_read_offset += 12;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -474,21 +485,21 @@ NetworkPacket& NetworkPacket::operator<<(v3s32 src)
|
|||
|
||||
NetworkPacket& NetworkPacket::operator>>(video::SColor& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset);
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
|
||||
dst = readARGB8(&m_data[m_read_offset]);
|
||||
|
||||
incrOffset<u32>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator<<(video::SColor src)
|
||||
{
|
||||
checkDataSize<u32>();
|
||||
checkDataSize(4);
|
||||
|
||||
writeU32(&m_data[m_read_offset], src.color);
|
||||
|
||||
incrOffset<u32>();
|
||||
m_read_offset += 4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,21 +111,16 @@ public:
|
|||
// Temp, we remove SharedBuffer when migration finished
|
||||
Buffer<u8> oldForgePacket();
|
||||
private:
|
||||
void checkReadOffset(u32 from_offset);
|
||||
void checkReadOffset(u32 from_offset, u32 field_size);
|
||||
|
||||
template<typename T> void checkDataSize()
|
||||
inline void checkDataSize(u32 field_size)
|
||||
{
|
||||
if (m_read_offset + sizeof(T) > m_datasize) {
|
||||
m_datasize = m_read_offset + sizeof(T);
|
||||
if (m_read_offset + field_size > m_datasize) {
|
||||
m_datasize = m_read_offset + field_size;
|
||||
m_data.resize(m_datasize);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> void incrOffset()
|
||||
{
|
||||
m_read_offset += sizeof(T);
|
||||
}
|
||||
|
||||
std::vector<u8> m_data;
|
||||
u32 m_datasize;
|
||||
u32 m_read_offset;
|
||||
|
|
|
@ -1014,7 +1014,7 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
|
|||
}
|
||||
tile->flags_texture = tsrc->getShaderFlagsTexture(
|
||||
tile->normal_texture ? true : false,
|
||||
tiledef->tileable_horizontal, tiledef->tileable_vertical);
|
||||
tiledef->tileable_vertical, tiledef->tileable_horizontal);
|
||||
|
||||
// Material flags
|
||||
tile->material_flags = 0;
|
||||
|
@ -1022,6 +1022,10 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
|
|||
tile->material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
|
||||
if (tiledef->animation.type == TAT_VERTICAL_FRAMES)
|
||||
tile->material_flags |= MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
|
||||
if (tiledef->tileable_horizontal)
|
||||
tile->material_flags |= MATERIAL_FLAG_TILEABLE_HORIZONTAL;
|
||||
if (tiledef->tileable_vertical)
|
||||
tile->material_flags |= MATERIAL_FLAG_TILEABLE_VERTICAL;
|
||||
|
||||
// Animation parameters
|
||||
int frame_count = 1;
|
||||
|
|
|
@ -258,17 +258,20 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
|
|||
}
|
||||
|
||||
/******************************************************************************/
|
||||
TileDef read_tiledef(lua_State *L, int index)
|
||||
TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
|
||||
{
|
||||
if(index < 0)
|
||||
index = lua_gettop(L) + 1 + index;
|
||||
|
||||
TileDef tiledef;
|
||||
|
||||
bool default_tiling = (drawtype == NDT_PLANTLIKE || drawtype == NDT_FIRELIKE)
|
||||
? false : true;
|
||||
// key at index -2 and value at index
|
||||
if(lua_isstring(L, index)){
|
||||
// "default_lava.png"
|
||||
tiledef.name = lua_tostring(L, index);
|
||||
tiledef.tileable_vertical = default_tiling;
|
||||
tiledef.tileable_horizontal = default_tiling;
|
||||
}
|
||||
else if(lua_istable(L, index))
|
||||
{
|
||||
|
@ -279,9 +282,9 @@ TileDef read_tiledef(lua_State *L, int index)
|
|||
tiledef.backface_culling = getboolfield_default(
|
||||
L, index, "backface_culling", true);
|
||||
tiledef.tileable_horizontal = getboolfield_default(
|
||||
L, index, "tileable_horizontal", true);
|
||||
L, index, "tileable_horizontal", default_tiling);
|
||||
tiledef.tileable_vertical = getboolfield_default(
|
||||
L, index, "tileable_vertical", true);
|
||||
L, index, "tileable_vertical", default_tiling);
|
||||
// animation = {}
|
||||
lua_getfield(L, index, "animation");
|
||||
if(lua_istable(L, -1)){
|
||||
|
@ -357,7 +360,7 @@ ContentFeatures read_content_features(lua_State *L, int index)
|
|||
int i = 0;
|
||||
while(lua_next(L, table) != 0){
|
||||
// Read tiledef from value
|
||||
f.tiledef[i] = read_tiledef(L, -1);
|
||||
f.tiledef[i] = read_tiledef(L, -1, f.drawtype);
|
||||
// removes value, keeps key for next iteration
|
||||
lua_pop(L, 1);
|
||||
i++;
|
||||
|
@ -392,7 +395,7 @@ ContentFeatures read_content_features(lua_State *L, int index)
|
|||
int i = 0;
|
||||
while(lua_next(L, table) != 0){
|
||||
// Read tiledef from value
|
||||
f.tiledef_special[i] = read_tiledef(L, -1);
|
||||
f.tiledef_special[i] = read_tiledef(L, -1, f.drawtype);
|
||||
// removes value, keeps key for next iteration
|
||||
lua_pop(L, 1);
|
||||
i++;
|
||||
|
|
|
@ -63,7 +63,8 @@ class Schematic;
|
|||
|
||||
|
||||
ContentFeatures read_content_features (lua_State *L, int index);
|
||||
TileDef read_tiledef (lua_State *L, int index);
|
||||
TileDef read_tiledef (lua_State *L, int index,
|
||||
u8 drawtype);
|
||||
void read_soundspec (lua_State *L, int index,
|
||||
SimpleSoundSpec &spec);
|
||||
NodeBox read_nodebox (lua_State *L, int index);
|
||||
|
|
|
@ -69,11 +69,51 @@ int script_exception_wrapper(lua_State *L, lua_CFunction f)
|
|||
return lua_error(L); // Rethrow as a Lua error.
|
||||
}
|
||||
|
||||
void script_error(lua_State *L)
|
||||
/*
|
||||
* Note that we can't get tracebacks for LUA_ERRMEM or LUA_ERRERR (without
|
||||
* hacking Lua internals). For LUA_ERRMEM, this is because memory errors will
|
||||
* not execute the the error handler, and by the time lua_pcall returns the
|
||||
* execution stack will have already been unwound. For LUA_ERRERR, there was
|
||||
* another error while trying to generate a backtrace from a LUA_ERRRUN. It is
|
||||
* presumed there is an error with the internal Lua state and thus not possible
|
||||
* to gather a coherent backtrace. Realistically, the best we can do here is
|
||||
* print which C function performed the failing pcall.
|
||||
*/
|
||||
void script_error(lua_State *L, int pcall_result, const char *fxn)
|
||||
{
|
||||
const char *s = lua_tostring(L, -1);
|
||||
std::string str(s ? s : "");
|
||||
throw LuaError(str);
|
||||
if (pcall_result == 0)
|
||||
return;
|
||||
|
||||
const char *err_type;
|
||||
switch (pcall_result) {
|
||||
case LUA_ERRRUN:
|
||||
err_type = "Runtime";
|
||||
break;
|
||||
case LUA_ERRMEM:
|
||||
err_type = "OOM";
|
||||
break;
|
||||
case LUA_ERRERR:
|
||||
err_type = "Double fault";
|
||||
break;
|
||||
default:
|
||||
err_type = "Unknown";
|
||||
}
|
||||
|
||||
const char *err_descr = lua_tostring(L, -1);
|
||||
if (!err_descr)
|
||||
err_descr = "<no description>";
|
||||
|
||||
std::string err_msg(err_type);
|
||||
if (fxn) {
|
||||
err_msg += " error in ";
|
||||
err_msg += fxn;
|
||||
err_msg += "(): ";
|
||||
} else {
|
||||
err_msg += " error: ";
|
||||
}
|
||||
err_msg += err_descr;
|
||||
|
||||
throw LuaError(err_msg);
|
||||
}
|
||||
|
||||
// Push the list of callbacks (a lua table).
|
||||
|
@ -82,7 +122,8 @@ void script_error(lua_State *L)
|
|||
// - runs the callbacks
|
||||
// - replaces the table and arguments with the return value,
|
||||
// computed depending on mode
|
||||
void script_run_callbacks(lua_State *L, int nargs, RunCallbacksMode mode)
|
||||
void script_run_callbacks_f(lua_State *L, int nargs,
|
||||
RunCallbacksMode mode, const char *fxn)
|
||||
{
|
||||
FATAL_ERROR_IF(lua_gettop(L) < nargs + 1, "Not enough arguments");
|
||||
|
||||
|
@ -104,14 +145,12 @@ void script_run_callbacks(lua_State *L, int nargs, RunCallbacksMode mode)
|
|||
// Stack now looks like this:
|
||||
// ... <error handler> <run_callbacks> <table> <mode> <arg#1> <arg#2> ... <arg#n>
|
||||
|
||||
if (lua_pcall(L, nargs + 2, 1, errorhandler)) {
|
||||
script_error(L);
|
||||
}
|
||||
script_error(L, lua_pcall(L, nargs + 2, 1, errorhandler), fxn);
|
||||
|
||||
lua_remove(L, -2); // Remove error handler
|
||||
}
|
||||
|
||||
void log_deprecated(lua_State *L, std::string message)
|
||||
void log_deprecated(lua_State *L, const std::string &message)
|
||||
{
|
||||
static bool configured = false;
|
||||
static bool dolog = false;
|
||||
|
@ -131,9 +170,10 @@ void log_deprecated(lua_State *L, std::string message)
|
|||
|
||||
if (doerror) {
|
||||
if (L != NULL) {
|
||||
script_error(L);
|
||||
script_error(L, LUA_ERRRUN, NULL);
|
||||
} else {
|
||||
FATAL_ERROR("Can't do a scripterror for this deprecated message, so exit completely!");
|
||||
FATAL_ERROR("Can't do a scripterror for this deprecated message, "
|
||||
"so exit completely!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,16 @@ extern "C" {
|
|||
|
||||
#include "common/c_types.h"
|
||||
|
||||
#define PCALL_RESL(L, RES) do { \
|
||||
int result_ = (RES); \
|
||||
if (result_ != 0) { \
|
||||
script_error((L), result_, __FUNCTION__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define script_run_callbacks(L, nargs, mode) \
|
||||
script_run_callbacks_f((L), (nargs), (mode), __FUNCTION__)
|
||||
|
||||
// What script_run_callbacks does with the return values of callbacks.
|
||||
// Regardless of the mode, if only one callback is defined,
|
||||
// its return value is the total return value.
|
||||
|
@ -67,8 +77,9 @@ enum RunCallbacksMode
|
|||
std::string script_get_backtrace(lua_State *L);
|
||||
int script_error_handler(lua_State *L);
|
||||
int script_exception_wrapper(lua_State *L, lua_CFunction f);
|
||||
void script_error(lua_State *L);
|
||||
void script_run_callbacks(lua_State *L, int nargs, RunCallbacksMode mode);
|
||||
void log_deprecated(lua_State *L, std::string message);
|
||||
void script_error(lua_State *L, int pcall_result, const char *fxn);
|
||||
void script_run_callbacks_f(lua_State *L, int nargs,
|
||||
RunCallbacksMode mode, const char *fxn);
|
||||
void log_deprecated(lua_State *L, const std::string &message);
|
||||
|
||||
#endif /* C_INTERNAL_H_ */
|
||||
|
|
|
@ -164,9 +164,7 @@ void AsyncEngine::step(lua_State *L, int errorhandler)
|
|||
lua_pushlstring(L, jobDone.serializedResult.data(),
|
||||
jobDone.serializedResult.size());
|
||||
|
||||
if (lua_pcall(L, 2, 0, errorhandler)) {
|
||||
script_error(L);
|
||||
}
|
||||
PCALL_RESL(L, lua_pcall(L, 2, 0, errorhandler));
|
||||
}
|
||||
resultQueueMutex.Unlock();
|
||||
lua_pop(L, 1); // Pop core
|
||||
|
@ -293,8 +291,9 @@ void* AsyncWorkerThread::Thread()
|
|||
toProcess.serializedParams.data(),
|
||||
toProcess.serializedParams.size());
|
||||
|
||||
if (lua_pcall(L, 2, 1, m_errorhandler)) {
|
||||
scriptError();
|
||||
int result = lua_pcall(L, 2, 1, m_errorhandler);
|
||||
if (result) {
|
||||
PCALL_RES(result);
|
||||
toProcess.serializedResult = "";
|
||||
} else {
|
||||
// Fetch result
|
||||
|
|
|
@ -165,9 +165,9 @@ void ScriptApiBase::realityCheck()
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptApiBase::scriptError()
|
||||
void ScriptApiBase::scriptError(int result, const char *fxn)
|
||||
{
|
||||
throw LuaError(lua_tostring(m_luastack, -1));
|
||||
script_error(getStack(), result, fxn);
|
||||
}
|
||||
|
||||
void ScriptApiBase::stackDump(std::ostream &o)
|
||||
|
|
|
@ -40,6 +40,12 @@ extern "C" {
|
|||
// use that name to bypass security!
|
||||
#define BUILTIN_MOD_NAME "*builtin*"
|
||||
|
||||
#define PCALL_RES(RES) do { \
|
||||
int result_ = (RES); \
|
||||
if (result_ != 0) { \
|
||||
scriptError(result_, __FUNCTION__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class Server;
|
||||
class Environment;
|
||||
|
@ -74,7 +80,7 @@ protected:
|
|||
{ return m_luastack; }
|
||||
|
||||
void realityCheck();
|
||||
void scriptError();
|
||||
void scriptError(int result, const char *fxn);
|
||||
void stackDump(std::ostream &o);
|
||||
|
||||
void setServer(Server* server) { m_server = server; }
|
||||
|
|
|
@ -92,8 +92,7 @@ void ScriptApiEntity::luaentity_Activate(u16 id,
|
|||
lua_pushlstring(L, staticdata.c_str(), staticdata.size());
|
||||
lua_pushinteger(L, dtime_s);
|
||||
// Call with 3 arguments, 0 results
|
||||
if (lua_pcall(L, 3, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 3, 0, m_errorhandler));
|
||||
} else {
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -140,8 +139,7 @@ std::string ScriptApiEntity::luaentity_GetStaticdata(u16 id)
|
|||
luaL_checktype(L, -1, LUA_TFUNCTION);
|
||||
lua_pushvalue(L, object); // self
|
||||
// Call with 1 arguments, 1 results
|
||||
if (lua_pcall(L, 1, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 1, m_errorhandler));
|
||||
lua_remove(L, object); // Remove object
|
||||
|
||||
size_t len = 0;
|
||||
|
@ -210,8 +208,7 @@ void ScriptApiEntity::luaentity_Step(u16 id, float dtime)
|
|||
lua_pushvalue(L, object); // self
|
||||
lua_pushnumber(L, dtime); // dtime
|
||||
// Call with 2 arguments, 0 results
|
||||
if (lua_pcall(L, 2, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler));
|
||||
lua_pop(L, 1); // Pop object
|
||||
}
|
||||
|
||||
|
@ -242,8 +239,7 @@ void ScriptApiEntity::luaentity_Punch(u16 id,
|
|||
push_tool_capabilities(L, *toolcap);
|
||||
push_v3f(L, dir);
|
||||
// Call with 5 arguments, 0 results
|
||||
if (lua_pcall(L, 5, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
|
||||
lua_pop(L, 1); // Pop object
|
||||
}
|
||||
|
||||
|
@ -269,8 +265,7 @@ void ScriptApiEntity::luaentity_Rightclick(u16 id,
|
|||
lua_pushvalue(L, object); // self
|
||||
objectrefGetOrCreate(L, clicker); // Clicker reference
|
||||
// Call with 2 arguments, 0 results
|
||||
if (lua_pcall(L, 2, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler));
|
||||
lua_pop(L, 1); // Pop object
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ int ScriptApiDetached::detached_inventory_AllowMove(
|
|||
lua_pushinteger(L, to_index + 1); // to_index
|
||||
lua_pushinteger(L, count); // count
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 7, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 7, 1, m_errorhandler));
|
||||
if(!lua_isnumber(L, -1))
|
||||
throw LuaError("allow_move should return a number. name=" + name);
|
||||
int ret = luaL_checkinteger(L, -1);
|
||||
|
@ -77,8 +76,7 @@ int ScriptApiDetached::detached_inventory_AllowPut(
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 1, m_errorhandler));
|
||||
if (!lua_isnumber(L, -1))
|
||||
throw LuaError("allow_put should return a number. name=" + name);
|
||||
int ret = luaL_checkinteger(L, -1);
|
||||
|
@ -106,8 +104,7 @@ int ScriptApiDetached::detached_inventory_AllowTake(
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 1, m_errorhandler));
|
||||
if (!lua_isnumber(L, -1))
|
||||
throw LuaError("allow_take should return a number. name=" + name);
|
||||
int ret = luaL_checkinteger(L, -1);
|
||||
|
@ -139,8 +136,7 @@ void ScriptApiDetached::detached_inventory_OnMove(
|
|||
lua_pushinteger(L, to_index + 1); // to_index
|
||||
lua_pushinteger(L, count); // count
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 7, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 7, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
// Report put items
|
||||
|
@ -164,8 +160,7 @@ void ScriptApiDetached::detached_inventory_OnPut(
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
// Report taken items
|
||||
|
@ -189,8 +184,7 @@ void ScriptApiDetached::detached_inventory_OnTake(
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
// Retrieves core.detached_inventories[name][callbackname]
|
||||
|
|
|
@ -42,8 +42,7 @@ bool ScriptApiItem::item_OnDrop(ItemStack &item,
|
|||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(L, dropper);
|
||||
pushFloatPos(L, pos);
|
||||
if (lua_pcall(L, 3, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 3, 1, m_errorhandler));
|
||||
if (!lua_isnil(L, -1)) {
|
||||
try {
|
||||
item = read_item(L,-1, getServer());
|
||||
|
@ -68,8 +67,7 @@ bool ScriptApiItem::item_OnPlace(ItemStack &item,
|
|||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(L, placer);
|
||||
pushPointedThing(pointed);
|
||||
if (lua_pcall(L, 3, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 3, 1, m_errorhandler));
|
||||
if (!lua_isnil(L, -1)) {
|
||||
try {
|
||||
item = read_item(L,-1, getServer());
|
||||
|
@ -94,8 +92,7 @@ bool ScriptApiItem::item_OnUse(ItemStack &item,
|
|||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(L, user);
|
||||
pushPointedThing(pointed);
|
||||
if (lua_pcall(L, 3, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 3, 1, m_errorhandler));
|
||||
if(!lua_isnil(L, -1)) {
|
||||
try {
|
||||
item = read_item(L,-1, getServer());
|
||||
|
@ -116,7 +113,7 @@ bool ScriptApiItem::item_OnCraft(ItemStack &item, ServerActiveObject *user,
|
|||
lua_getfield(L, -1, "on_craft");
|
||||
LuaItemStack::create(L, item);
|
||||
objectrefGetOrCreate(L, user);
|
||||
|
||||
|
||||
// Push inventory list
|
||||
std::vector<ItemStack> items;
|
||||
for (u32 i = 0; i < old_craft_grid->getSize(); i++) {
|
||||
|
@ -125,8 +122,7 @@ bool ScriptApiItem::item_OnCraft(ItemStack &item, ServerActiveObject *user,
|
|||
push_items(L, items);
|
||||
|
||||
InvRef::create(L, craft_inv);
|
||||
if (lua_pcall(L, 4, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 4, 1, m_errorhandler));
|
||||
if (!lua_isnil(L, -1)) {
|
||||
try {
|
||||
item = read_item(L,-1, getServer());
|
||||
|
@ -156,8 +152,7 @@ bool ScriptApiItem::item_CraftPredict(ItemStack &item, ServerActiveObject *user,
|
|||
push_items(L, items);
|
||||
|
||||
InvRef::create(L, craft_inv);
|
||||
if (lua_pcall(L, 4, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 4, 1, m_errorhandler));
|
||||
if (!lua_isnil(L, -1)) {
|
||||
try {
|
||||
item = read_item(L,-1, getServer());
|
||||
|
|
|
@ -55,8 +55,7 @@ void ScriptApiMainMenu::handleMainMenuEvent(std::string text)
|
|||
|
||||
// Call it
|
||||
lua_pushstring(L, text.c_str());
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields)
|
||||
|
@ -85,7 +84,6 @@ void ScriptApiMainMenu::handleMainMenuButtons(const StringMap &fields)
|
|||
}
|
||||
|
||||
// Call it
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
|
|
|
@ -106,8 +106,7 @@ bool ScriptApiNode::node_on_punch(v3s16 p, MapNode node,
|
|||
pushnode(L, node, ndef);
|
||||
objectrefGetOrCreate(L, puncher);
|
||||
pushPointedThing(pointed);
|
||||
if (lua_pcall(L, 4, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 4, 0, m_errorhandler));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -126,8 +125,7 @@ bool ScriptApiNode::node_on_dig(v3s16 p, MapNode node,
|
|||
push_v3s16(L, p);
|
||||
pushnode(L, node, ndef);
|
||||
objectrefGetOrCreate(L, digger);
|
||||
if (lua_pcall(L, 3, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 3, 0, m_errorhandler));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -143,8 +141,7 @@ void ScriptApiNode::node_on_construct(v3s16 p, MapNode node)
|
|||
|
||||
// Call function
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_on_destruct(v3s16 p, MapNode node)
|
||||
|
@ -159,8 +156,7 @@ void ScriptApiNode::node_on_destruct(v3s16 p, MapNode node)
|
|||
|
||||
// Call function
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_after_destruct(v3s16 p, MapNode node)
|
||||
|
@ -176,8 +172,7 @@ void ScriptApiNode::node_after_destruct(v3s16 p, MapNode node)
|
|||
// Call function
|
||||
push_v3s16(L, p);
|
||||
pushnode(L, node, ndef);
|
||||
if (lua_pcall(L, 2, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 dtime)
|
||||
|
@ -193,8 +188,7 @@ bool ScriptApiNode::node_on_timer(v3s16 p, MapNode node, f32 dtime)
|
|||
// Call function
|
||||
push_v3s16(L, p);
|
||||
lua_pushnumber(L,dtime);
|
||||
if (lua_pcall(L, 2, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 1, m_errorhandler));
|
||||
return (bool) lua_isboolean(L, -1) && (bool) lua_toboolean(L, -1) == true;
|
||||
}
|
||||
|
||||
|
@ -229,8 +223,7 @@ void ScriptApiNode::node_on_receive_fields(v3s16 p,
|
|||
lua_settable(L, -3);
|
||||
}
|
||||
objectrefGetOrCreate(L, sender); // player
|
||||
if (lua_pcall(L, 4, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 4, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_falling_update(v3s16 p)
|
||||
|
@ -239,8 +232,7 @@ void ScriptApiNode::node_falling_update(v3s16 p)
|
|||
|
||||
lua_getglobal(L, "nodeupdate");
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
void ScriptApiNode::node_falling_update_single(v3s16 p)
|
||||
|
@ -249,7 +241,5 @@ void ScriptApiNode::node_falling_update_single(v3s16 p)
|
|||
|
||||
lua_getglobal(L, "nodeupdate_single");
|
||||
push_v3s16(L, p);
|
||||
if (lua_pcall(L, 1, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowMove(v3s16 p,
|
|||
lua_pushinteger(L, to_index + 1); // to_index
|
||||
lua_pushinteger(L, count); // count
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 7, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 7, 1, m_errorhandler));
|
||||
if (!lua_isnumber(L, -1))
|
||||
throw LuaError("allow_metadata_inventory_move should"
|
||||
" return a number, guilty node: " + nodename);
|
||||
|
@ -89,8 +88,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowPut(v3s16 p,
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 1, m_errorhandler));
|
||||
if(!lua_isnumber(L, -1))
|
||||
throw LuaError("allow_metadata_inventory_put should"
|
||||
" return a number, guilty node: " + nodename);
|
||||
|
@ -124,8 +122,7 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowTake(v3s16 p,
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 1, m_errorhandler));
|
||||
if (!lua_isnumber(L, -1))
|
||||
throw LuaError("allow_metadata_inventory_take should"
|
||||
" return a number, guilty node: " + nodename);
|
||||
|
@ -162,8 +159,7 @@ void ScriptApiNodemeta::nodemeta_inventory_OnMove(v3s16 p,
|
|||
lua_pushinteger(L, to_index + 1); // to_index
|
||||
lua_pushinteger(L, count); // count
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 7, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 7, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
// Report put items
|
||||
|
@ -191,8 +187,7 @@ void ScriptApiNodemeta::nodemeta_inventory_OnPut(v3s16 p,
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
// Report taken items
|
||||
|
@ -220,13 +215,14 @@ void ScriptApiNodemeta::nodemeta_inventory_OnTake(v3s16 p,
|
|||
lua_pushinteger(L, index + 1); // index
|
||||
LuaItemStack::create(L, stack); // stack
|
||||
objectrefGetOrCreate(L, player); // player
|
||||
if (lua_pcall(L, 5, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
ScriptApiNodemeta::ScriptApiNodemeta() {
|
||||
ScriptApiNodemeta::ScriptApiNodemeta()
|
||||
{
|
||||
}
|
||||
|
||||
ScriptApiNodemeta::~ScriptApiNodemeta() {
|
||||
ScriptApiNodemeta::~ScriptApiNodemeta()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,7 @@ s16 ScriptApiPlayer::on_player_hpchange(ServerActiveObject *player,
|
|||
|
||||
objectrefGetOrCreate(L, player);
|
||||
lua_pushnumber(L, hp_change);
|
||||
if (lua_pcall(L, 2, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 1, m_errorhandler));
|
||||
hp_change = lua_tointeger(L, -1);
|
||||
lua_pop(L, -1);
|
||||
return hp_change;
|
||||
|
|
|
@ -32,8 +32,7 @@ bool ScriptApiServer::getAuth(const std::string &playername,
|
|||
if (lua_type(L, -1) != LUA_TFUNCTION)
|
||||
throw LuaError("Authentication handler missing get_auth");
|
||||
lua_pushstring(L, playername.c_str());
|
||||
if (lua_pcall(L, 1, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 1, 1, m_errorhandler));
|
||||
lua_remove(L, -2); // Remove auth handler
|
||||
|
||||
// nil = login not allowed
|
||||
|
@ -104,8 +103,7 @@ void ScriptApiServer::createAuth(const std::string &playername,
|
|||
throw LuaError("Authentication handler missing create_auth");
|
||||
lua_pushstring(L, playername.c_str());
|
||||
lua_pushstring(L, password.c_str());
|
||||
if (lua_pcall(L, 2, 0, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler));
|
||||
}
|
||||
|
||||
bool ScriptApiServer::setPassword(const std::string &playername,
|
||||
|
@ -120,8 +118,7 @@ bool ScriptApiServer::setPassword(const std::string &playername,
|
|||
throw LuaError("Authentication handler missing set_password");
|
||||
lua_pushstring(L, playername.c_str());
|
||||
lua_pushstring(L, password.c_str());
|
||||
if (lua_pcall(L, 2, 1, m_errorhandler))
|
||||
scriptError();
|
||||
PCALL_RES(lua_pcall(L, 2, 1, m_errorhandler));
|
||||
return lua_toboolean(L, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,9 @@ void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
|
|||
pushnode(L, n, env->getGameDef()->ndef());
|
||||
lua_pushnumber(L, active_object_count);
|
||||
lua_pushnumber(L, active_object_count_wider);
|
||||
if(lua_pcall(L, 4, 0, errorhandler))
|
||||
script_error(L);
|
||||
|
||||
PCALL_RESL(L, lua_pcall(L, 4, 0, errorhandler));
|
||||
|
||||
lua_pop(L, 1); // Pop error handler
|
||||
}
|
||||
|
||||
|
@ -418,8 +419,9 @@ int ModApiEnvMod::l_add_item(lua_State *L)
|
|||
return 0;
|
||||
lua_pushvalue(L, 1);
|
||||
lua_pushstring(L, item.getItemString().c_str());
|
||||
if(lua_pcall(L, 2, 1, errorhandler))
|
||||
script_error(L);
|
||||
|
||||
PCALL_RESL(L, lua_pcall(L, 2, 1, errorhandler));
|
||||
|
||||
lua_remove(L, errorhandler); // Remove error handler
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ void GameScripting::InitializeModApi(lua_State *L, int top)
|
|||
LuaSettings::Register(L);
|
||||
}
|
||||
|
||||
void log_deprecated(std::string message)
|
||||
void log_deprecated(const std::string &message)
|
||||
{
|
||||
log_deprecated(NULL,message);
|
||||
log_deprecated(NULL, message);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ private:
|
|||
void InitializeModApi(lua_State *L, int top);
|
||||
};
|
||||
|
||||
void log_deprecated(std::string message);
|
||||
void log_deprecated(const std::string &message);
|
||||
|
||||
#endif /* SCRIPTING_GAME_H_ */
|
||||
|
|
|
@ -178,6 +178,14 @@ private:
|
|||
unsigned int m_size;
|
||||
};
|
||||
|
||||
/************************************************
|
||||
* !!! W A R N I N G !!! *
|
||||
* !!! A C H T U N G !!! *
|
||||
* *
|
||||
* This smart pointer class is NOT thread safe. *
|
||||
* ONLY use in a single-threaded context! *
|
||||
* *
|
||||
************************************************/
|
||||
template <typename T>
|
||||
class SharedBuffer
|
||||
{
|
||||
|
|
|
@ -593,6 +593,8 @@ void srp_create_salted_verification_key( SRP_HashAlgorithm alg,
|
|||
if(!ng)
|
||||
goto cleanup_and_exit;
|
||||
|
||||
init_random(); /* Only happens once */
|
||||
|
||||
if (*bytes_s == NULL) {
|
||||
*len_s = 16;
|
||||
if (RAND_BUFF_MAX - g_rand_idx < 16)
|
||||
|
|
Loading…
Reference in New Issue