Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bunch of small fixes from my android branch #1168

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
143 changes: 74 additions & 69 deletions src/client.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/client.h
Expand Up @@ -409,7 +409,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);

void updateCameraOffset(v3s16 camera_offset){ m_mesh_update_thread.m_camera_offset = camera_offset; }
void updateCameraOffset(v3s16 camera_offset)
{ m_mesh_update_thread.m_camera_offset = camera_offset; }

// Get event from queue. CE_NONE is returned if queue is empty.
ClientEvent getClientEvent();
Expand Down
22 changes: 13 additions & 9 deletions src/connection.cpp
Expand Up @@ -111,10 +111,10 @@ SharedBuffer<u8> makeOriginalPacket(
u32 packet_size = data.getSize() + header_size;
SharedBuffer<u8> b(packet_size);

writeU8(&b[0], TYPE_ORIGINAL);

memcpy(&b[header_size], *data, data.getSize());

writeU8(&(b[0]), TYPE_ORIGINAL);
if (data.getSize() > 0) {
memcpy(&(b[header_size]), *data, data.getSize());
}
return b;
}

Expand Down Expand Up @@ -1227,6 +1227,8 @@ void * ConnectionSendThread::Thread()
PROFILE(std::stringstream ThreadIdentifier);
PROFILE(ThreadIdentifier << "ConnectionSend: [" << m_connection->getDesc() << "]");

porting::setThreadName("ConnectionSend");

/* if stop is requested don't stop immediately but try to send all */
/* packets first */
while(!StopRequested() || packetsQueued()) {
Expand Down Expand Up @@ -1955,6 +1957,8 @@ void * ConnectionReceiveThread::Thread()
PROFILE(std::stringstream ThreadIdentifier);
PROFILE(ThreadIdentifier << "ConnectionReceive: [" << m_connection->getDesc() << "]");

porting::setThreadName("ConnectionReceive");

#ifdef DEBUG_CONNECTION_KBPS
u32 curtime = porting::getTimeMs();
u32 lasttime = curtime;
Expand Down Expand Up @@ -2263,14 +2267,14 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
if(packetdata.getSize() < 1)
throw InvalidIncomingDataException("packetdata.getSize() < 1");

u8 type = readU8(&packetdata[0]);
u8 type = readU8(&(packetdata[0]));

if(type == TYPE_CONTROL)
{
if(packetdata.getSize() < 2)
throw InvalidIncomingDataException("packetdata.getSize() < 2");

u8 controltype = readU8(&packetdata[1]);
u8 controltype = readU8(&(packetdata[1]));

if( (controltype == CONTROLTYPE_ACK)
&& (peer_id <= MAX_UDP_PEERS))
Expand Down Expand Up @@ -2395,15 +2399,15 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
}
else if(type == TYPE_ORIGINAL)
{
if(packetdata.getSize() < ORIGINAL_HEADER_SIZE)
if(packetdata.getSize() <= ORIGINAL_HEADER_SIZE)
throw InvalidIncomingDataException
("packetdata.getSize() < ORIGINAL_HEADER_SIZE");
("packetdata.getSize() <= ORIGINAL_HEADER_SIZE");
LOG(dout_con<<m_connection->getDesc()
<<"RETURNING TYPE_ORIGINAL to user"
<<std::endl);
// Get the inside packet out and return it
SharedBuffer<u8> payload(packetdata.getSize() - ORIGINAL_HEADER_SIZE);
memcpy(*payload, &packetdata[ORIGINAL_HEADER_SIZE], payload.getSize());
memcpy(*payload, &(packetdata[ORIGINAL_HEADER_SIZE]), payload.getSize());
return payload;
}
else if(type == TYPE_SPLIT)
Expand Down
2 changes: 1 addition & 1 deletion src/content_cao.cpp
Expand Up @@ -1075,7 +1075,7 @@ class GenericCAO : public ClientActiveObject
m_spritenode->setPosition(pos_translator.vect_show-intToFloat(camera_offset, BS));
}
}

void step(float dtime, ClientEnvironment *env)
{
if(m_visuals_expired && m_smgr && m_irr){
Expand Down
3 changes: 2 additions & 1 deletion src/emerge.cpp
Expand Up @@ -456,7 +456,6 @@ bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
return false;
}


void *EmergeThread::Thread() {
ThreadStarted();
log_register_thread("EmergeThread" + itos(id));
Expand All @@ -472,6 +471,8 @@ void *EmergeThread::Thread() {
mapgen = emerge->mapgen[id];
enable_mapgen_debug_info = emerge->mapgen_debug_info;

porting::setThreadName("EmergeThread");

while (!StopRequested())
try {
if (!popBlockEmerge(&p, &flags)) {
Expand Down