Skip to content

Commit eda9214

Browse files
sapiersapier
sapier
authored and
sapier
committedApr 19, 2014
Bunch of small fixes (coding style, very unlikely errors, warning messages)
1 parent a230e1e commit eda9214

9 files changed

+51
-34
lines changed
 

‎src/client.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
409409
void addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server=false, bool urgent=false);
410410
void addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server=false, bool urgent=false);
411411

412-
void updateCameraOffset(v3s16 camera_offset){ m_mesh_update_thread.m_camera_offset = camera_offset; }
412+
void updateCameraOffset(v3s16 camera_offset)
413+
{ m_mesh_update_thread.m_camera_offset = camera_offset; }
413414

414415
// Get event from queue. CE_NONE is returned if queue is empty.
415416
ClientEvent getClientEvent();

‎src/connection.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ SharedBuffer<u8> makeOriginalPacket(
111111
u32 packet_size = data.getSize() + header_size;
112112
SharedBuffer<u8> b(packet_size);
113113

114-
writeU8(&b[0], TYPE_ORIGINAL);
115-
116-
memcpy(&b[header_size], *data, data.getSize());
117-
114+
writeU8(&(b[0]), TYPE_ORIGINAL);
115+
if (data.getSize() > 0) {
116+
memcpy(&(b[header_size]), *data, data.getSize());
117+
}
118118
return b;
119119
}
120120

@@ -2266,14 +2266,14 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
22662266
if(packetdata.getSize() < 1)
22672267
throw InvalidIncomingDataException("packetdata.getSize() < 1");
22682268

2269-
u8 type = readU8(&packetdata[0]);
2269+
u8 type = readU8(&(packetdata[0]));
22702270

22712271
if(type == TYPE_CONTROL)
22722272
{
22732273
if(packetdata.getSize() < 2)
22742274
throw InvalidIncomingDataException("packetdata.getSize() < 2");
22752275

2276-
u8 controltype = readU8(&packetdata[1]);
2276+
u8 controltype = readU8(&(packetdata[1]));
22772277

22782278
if( (controltype == CONTROLTYPE_ACK)
22792279
&& (peer_id <= MAX_UDP_PEERS))
@@ -2398,15 +2398,15 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
23982398
}
23992399
else if(type == TYPE_ORIGINAL)
24002400
{
2401-
if(packetdata.getSize() < ORIGINAL_HEADER_SIZE)
2401+
if(packetdata.getSize() <= ORIGINAL_HEADER_SIZE)
24022402
throw InvalidIncomingDataException
2403-
("packetdata.getSize() < ORIGINAL_HEADER_SIZE");
2403+
("packetdata.getSize() <= ORIGINAL_HEADER_SIZE");
24042404
LOG(dout_con<<m_connection->getDesc()
24052405
<<"RETURNING TYPE_ORIGINAL to user"
24062406
<<std::endl);
24072407
// Get the inside packet out and return it
24082408
SharedBuffer<u8> payload(packetdata.getSize() - ORIGINAL_HEADER_SIZE);
2409-
memcpy(*payload, &packetdata[ORIGINAL_HEADER_SIZE], payload.getSize());
2409+
memcpy(*payload, &(packetdata[ORIGINAL_HEADER_SIZE]), payload.getSize());
24102410
return payload;
24112411
}
24122412
else if(type == TYPE_SPLIT)

‎src/guiEngine.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ bool GUIEngine::loadMainMenuScript()
226226
}
227227
else {
228228
infostream
229-
<< "GUIEngine: execution of custom menu failed!"
229+
<< "GUIEngine: execution of custom menu: \""
230+
<< menuscript << "\" failed!"
230231
<< std::endl
231232
<< "\tfalling back to builtin menu"
232233
<< std::endl;

‎src/localplayer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
268268
if(nodemgr->get(map->getNode(p)).walkable == false)
269269
continue;
270270
// And the node above it has to be nonwalkable
271-
if(nodemgr->get(map->getNode(p+v3s16(0,1,0))).walkable == true)
271+
if(nodemgr->get(map->getNode(p+v3s16(0,1,0))).walkable == true) {
272272
continue;
273+
}
273274
if (!physics_override_sneak_glitch) {
274275
if (nodemgr->get(map->getNode(p+v3s16(0,2,0))).walkable)
275276
continue;

‎src/main.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class MyEventReceiver : public IEventReceiver
266266
} else {
267267
keyIsDown.unset(event.KeyInput);
268268
}
269+
return true;
269270
}
270271

271272
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
@@ -1484,10 +1485,11 @@ int main(int argc, char *argv[])
14841485
bool random_input = g_settings->getBool("random_input")
14851486
|| cmd_args.getFlag("random-input");
14861487
InputHandler *input = NULL;
1487-
if(random_input)
1488+
if(random_input) {
14881489
input = new RandomInputHandler();
1489-
else
1490+
} else {
14901491
input = new RealInputHandler(device, &receiver);
1492+
}
14911493

14921494
scene::ISceneManager* smgr = device->getSceneManager();
14931495

‎src/porting.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ bool threadBindToProcessor(threadid_t tid, int pnumber) {
191191

192192
#elif defined(__sun) || defined(sun)
193193

194-
return processor_bind(P_LWPID, MAKE_LWPID_PTHREAD(tid),
194+
return processor_bind(P_LWPID, MAKE_LWPID_PTHREAD(tid),
195195
pnumber, NULL) == 0;
196196

197197
#elif defined(_AIX)
@@ -477,7 +477,7 @@ void initializePaths()
477477
i != trylist.end(); i++)
478478
{
479479
const std::string &trypath = *i;
480-
if(!fs::PathExists(trypath) || !fs::PathExists(trypath + "/builtin")){
480+
if(!fs::PathExists(trypath) || !fs::PathExists(trypath + DIR_DELIM + "builtin")){
481481
dstream<<"WARNING: system-wide share not found at \""
482482
<<trypath<<"\""<<std::endl;
483483
continue;
@@ -491,37 +491,37 @@ void initializePaths()
491491
break;
492492
}
493493

494-
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
494+
path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME;
495495

496496
/*
497497
OS X
498498
*/
499499
#elif defined(__APPLE__)
500500

501-
// Code based on
502-
// http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
503-
CFBundleRef main_bundle = CFBundleGetMainBundle();
504-
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
505-
char path[PATH_MAX];
506-
if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
501+
// Code based on
502+
// http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
503+
CFBundleRef main_bundle = CFBundleGetMainBundle();
504+
CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
505+
char path[PATH_MAX];
506+
if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
507507
{
508508
dstream<<"Bundle resource path: "<<path<<std::endl;
509509
//chdir(path);
510-
path_share = std::string(path) + "/share";
510+
path_share = std::string(path) + DIR_DELIM + "share";
511511
}
512512
else
513-
{
514-
// error!
513+
{
514+
// error!
515515
dstream<<"WARNING: Could not determine bundle resource path"<<std::endl;
516-
}
517-
CFRelease(resources_url);
516+
}
517+
CFRelease(resources_url);
518518

519519
path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME;
520520

521521
#else // FreeBSD, and probably many other POSIX-like systems.
522522

523523
path_share = STATIC_SHAREDIR;
524-
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
524+
path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME;
525525

526526
#endif
527527

‎src/settings.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3737
#include <map>
3838
#include <set>
3939
#include "filesys.h"
40+
#include <cctype>
4041

4142
enum ValueType
4243
{
@@ -575,7 +576,7 @@ class Settings
575576
u32 getFlagStr(std::string name, FlagDesc *flagdesc, u32 *flagmask)
576577
{
577578
std::string val = get(name);
578-
return (isdigit(val[0])) ? stoi(val) :
579+
return (std::isdigit(val[0])) ? stoi(val) :
579580
readFlagString(val, flagdesc, flagmask);
580581
}
581582

‎src/tile.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,6 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
730730
m_textureinfo_cache.push_back(ti);
731731
m_name_to_id[name] = id;
732732

733-
/*infostream<<"getTextureIdDirect(): "
734-
<<"Returning id="<<id<<" for name \""<<name<<"\""<<std::endl;*/
735-
736733
return id;
737734
}
738735

@@ -962,6 +959,20 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
962959
{
963960
video::IImage *image = m_sourcecache.getOrLoad(part_of_name, m_device);
964961

962+
if (image != NULL) {
963+
if (!driver->queryFeature(irr::video::EVDF_TEXTURE_NPOT)) {
964+
core::dimension2d<u32> dim = image->getDimension();
965+
966+
967+
if ((dim.Height %2 != 0) ||
968+
(dim.Width %2 != 0)) {
969+
errorstream << "TextureSource::generateImage "
970+
<< part_of_name << " size npot2 x=" << dim.Width
971+
<< " y=" << dim.Height << std::endl;
972+
}
973+
}
974+
}
975+
965976
if(image == NULL)
966977
{
967978
if(part_of_name != ""){

‎src/util/pointer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class SharedBuffer
258258
}
259259
T & operator[](unsigned int i) const
260260
{
261-
//assert(i < m_size)
261+
assert(i < m_size);
262262
return data[i];
263263
}
264264
T * operator*() const

0 commit comments

Comments
 (0)
Please sign in to comment.