-fixes to ring buffer (fixes network error)

-fixes to invalid disabling of commands on scene tree dock
This commit is contained in:
Juan Linietsky 2015-10-21 16:52:43 -03:00
parent b59c86f6f9
commit 35959f9c5a
4 changed files with 11 additions and 8 deletions

View file

@ -36,7 +36,10 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
const uint8_t * buf=p_buffer;
int len=p_len;
ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
if (len<4) {
ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
}
uint32_t type=decode_uint32(buf);

View file

@ -156,7 +156,6 @@ Error PacketPeerStream::_poll_buffer() const {
Error err = peer->get_partial_data(&temp_buffer[0], ring_buffer.space_left(), read);
if (err)
return err;
if (read==0)
return OK;
@ -202,7 +201,7 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer,int &r_buffer_size)
uint8_t lbuf[4];
ring_buffer.copy(lbuf,0,4);
remaining-=4;
uint32_t len = decode_uint32(lbuf);
uint32_t len = decode_uint32(lbuf);
ERR_FAIL_COND_V(remaining<(int)len,ERR_UNAVAILABLE);
ring_buffer.read(lbuf,4); //get rid of first 4 bytes

View file

@ -141,15 +141,15 @@ public:
inline int space_left() {
int left = read_pos - write_pos;
if (left < 0) {
return size() + left;
return size() + left - 1;
};
if (left == 0) {
return size();
return size()-1;
};
return left;
return left -1;
};
inline int data_left() {
return size() - space_left();
return size() - space_left() - 1;
};
inline int size() {

View file

@ -1088,7 +1088,8 @@ void SceneTreeDock::_delete_confirm() {
void SceneTreeDock::_update_tool_buttons() {
Node *sel = scene_tree->get_selected();
bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene) || (edited_scene->get_scene_instance_state().is_valid() && edited_scene->get_scene_instance_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0);
bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene);
disable = disable || (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0);
bool disable_root = disable || sel->get_parent()==scene_root;
bool disable_edit = !sel;