@@ -97,7 +97,7 @@ void MeshUpdateQueue::addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_se
97
97
{
98
98
DSTACK (__FUNCTION_NAME);
99
99
100
- assert (data);
100
+ assert (data); // pre-condition
101
101
102
102
JMutexAutoLock lock (m_mutex);
103
103
@@ -388,8 +388,9 @@ void Client::step(float dtime)
388
388
if (counter <= 0.0 ) {
389
389
counter = 2.0 ;
390
390
391
- Player *myplayer = m_env.getLocalPlayer ();
392
- assert (myplayer != NULL );
391
+ Player *myplayer = m_env.getLocalPlayer ();
392
+ FATAL_ERROR_IF (myplayer == NULL , " Local player not found in environment." );
393
+
393
394
// Send TOSERVER_INIT
394
395
// [0] u16 TOSERVER_INIT
395
396
// [2] u8 SER_FMT_VER_HIGHEST_READ
@@ -707,7 +708,9 @@ bool Client::loadMedia(const std::string &data, const std::string &filename)
707
708
// Create an irrlicht memory file
708
709
io::IReadFile *rfile = irrfs->createMemoryReadFile (
709
710
*data_rw, data_rw.getSize (), " _tempreadfile" );
710
- assert (rfile);
711
+
712
+ FATAL_ERROR_IF (!rfile, " Could not create irrlicht memory file." );
713
+
711
714
// Read image
712
715
video::IImage *img = vdrv->createImageFromFile (rfile);
713
716
if (!img){
@@ -785,7 +788,8 @@ void Client::request_media(const std::vector<std::string> &file_requests)
785
788
std::ostringstream os (std::ios_base::binary);
786
789
writeU16 (os, TOSERVER_REQUEST_MEDIA);
787
790
size_t file_requests_size = file_requests.size ();
788
- assert (file_requests_size <= 0xFFFF );
791
+
792
+ FATAL_ERROR_IF (file_requests_size > 0xFFFF , " Unsupported number of file requests" );
789
793
790
794
// Packet dynamicly resized
791
795
NetworkPacket* pkt = new NetworkPacket (TOSERVER_REQUEST_MEDIA, 2 + 0 );
@@ -986,7 +990,8 @@ void Client::sendNodemetaFields(v3s16 p, const std::string &formname,
986
990
const std::map<std::string, std::string> &fields)
987
991
{
988
992
size_t fields_size = fields.size ();
989
- assert (fields_size <= 0xFFFF );
993
+
994
+ FATAL_ERROR_IF (fields_size > 0xFFFF , " Unsupported number of nodemeta fields" );
990
995
991
996
NetworkPacket* pkt = new NetworkPacket (TOSERVER_NODEMETA_FIELDS, 0 );
992
997
@@ -1007,7 +1012,7 @@ void Client::sendInventoryFields(const std::string &formname,
1007
1012
const std::map<std::string, std::string> &fields)
1008
1013
{
1009
1014
size_t fields_size = fields.size ();
1010
- assert (fields_size <= 0xFFFF );
1015
+ FATAL_ERROR_IF (fields_size > 0xFFFF , " Unsupported number of inventory fields " );
1011
1016
1012
1017
NetworkPacket* pkt = new NetworkPacket (TOSERVER_INVENTORY_FIELDS, 0 );
1013
1018
*pkt << formname << (u16) (fields_size & 0xFFFF );
@@ -1141,7 +1146,7 @@ void Client::sendPlayerPos()
1141
1146
// Set peer id if not set already
1142
1147
if (myplayer->peer_id == PEER_ID_INEXISTENT)
1143
1148
myplayer->peer_id = our_peer_id;
1144
- // Check that an existing peer_id is the same as the connection's
1149
+
1145
1150
assert (myplayer->peer_id == our_peer_id);
1146
1151
1147
1152
v3f pf = myplayer->getPosition ();
@@ -1179,8 +1184,6 @@ void Client::sendPlayerItem(u16 item)
1179
1184
// Set peer id if not set already
1180
1185
if (myplayer->peer_id == PEER_ID_INEXISTENT)
1181
1186
myplayer->peer_id = our_peer_id;
1182
-
1183
- // Check that an existing peer_id is the same as the connection's
1184
1187
assert (myplayer->peer_id == our_peer_id);
1185
1188
1186
1189
NetworkPacket* pkt = new NetworkPacket (TOSERVER_PLAYERITEM, 2 );
@@ -1295,7 +1298,7 @@ Inventory* Client::getInventory(const InventoryLocation &loc)
1295
1298
}
1296
1299
break ;
1297
1300
default :
1298
- assert ( 0 );
1301
+ FATAL_ERROR ( " Invalid inventory location type. " );
1299
1302
}
1300
1303
return NULL ;
1301
1304
}
@@ -1555,9 +1558,9 @@ float Client::mediaReceiveProgress()
1555
1558
void Client::afterContentReceived (IrrlichtDevice *device, gui::IGUIFont* font)
1556
1559
{
1557
1560
infostream<<" Client::afterContentReceived() started" <<std::endl;
1558
- assert (m_itemdef_received);
1559
- assert (m_nodedef_received);
1560
- assert (mediaReceived ());
1561
+ assert (m_itemdef_received); // pre-condition
1562
+ assert (m_nodedef_received); // pre-condition
1563
+ assert (mediaReceived ()); // pre-condition
1561
1564
1562
1565
const wchar_t * text = wgettext (" Loading textures..." );
1563
1566
@@ -1697,9 +1700,10 @@ scene::ISceneManager* Client::getSceneManager()
1697
1700
}
1698
1701
u16 Client::allocateUnknownNodeId (const std::string &name)
1699
1702
{
1700
- errorstream<<" Client::allocateUnknownNodeId(): "
1701
- <<" Client cannot allocate node IDs" <<std::endl;
1702
- assert (0 );
1703
+ errorstream << " Client::allocateUnknownNodeId(): "
1704
+ << " Client cannot allocate node IDs" << std::endl;
1705
+ FATAL_ERROR (" Client allocated unknown node" );
1706
+
1703
1707
return CONTENT_IGNORE;
1704
1708
}
1705
1709
ISoundManager* Client::getSoundManager ()
@@ -1734,7 +1738,7 @@ scene::IAnimatedMesh* Client::getMesh(const std::string &filename)
1734
1738
io::IFileSystem *irrfs = m_device->getFileSystem ();
1735
1739
io::IReadFile *rfile = irrfs->createMemoryReadFile (
1736
1740
*data_rw, data_rw.getSize (), filename.c_str ());
1737
- assert ( rfile);
1741
+ FATAL_ERROR_IF (! rfile, " Could not create/open RAM file " );
1738
1742
1739
1743
scene::IAnimatedMesh *mesh = smgr->getMesh (rfile);
1740
1744
rfile->drop ();
0 commit comments