17
17
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
18
19
19
#include " items/powerup_manager.hpp"
20
-
21
- #include < cinttypes>
22
- #include < stdexcept>
23
-
24
20
#include " config/stk_config.hpp"
25
21
#include " graphics/irr_driver.hpp"
26
22
#include " graphics/sp/sp_base.hpp"
41
37
42
38
#include < IMesh.h>
43
39
44
- PowerupManager* powerup_manager= 0 ;
40
+ PowerupManager* powerup_manager = nullptr ;
45
41
46
42
// -----------------------------------------------------------------------------
47
43
/* * The constructor initialises everything to zero. */
@@ -50,8 +46,8 @@ PowerupManager::PowerupManager()
50
46
m_random_seed.store (0 );
51
47
for (int i=0 ; i<POWERUP_MAX; i++)
52
48
{
53
- m_all_meshes[i] = NULL ;
54
- m_all_icons[i] = (Material*)NULL ;
49
+ m_all_meshes[i] = nullptr ;
50
+ m_all_icons[i] = (Material*)nullptr ;
55
51
}
56
52
} // PowerupManager
57
53
@@ -94,7 +90,7 @@ void PowerupManager::unloadPowerups()
94
90
95
91
// FIXME: I'm not sure if this is OK or if I need to ->drop(),
96
92
// or delete them, or...
97
- m_all_icons[i] = (Material*)NULL ;
93
+ m_all_icons[i] = (Material*)nullptr ;
98
94
}
99
95
} // removeTextures
100
96
@@ -107,7 +103,7 @@ PowerupManager::PowerupType
107
103
PowerupManager::getPowerupType (const std::string &name) const
108
104
{
109
105
// Must match the order of PowerupType in powerup_manager.hpp!!
110
- static std::string powerup_names[] = {
106
+ static const std::string powerup_names[] = {
111
107
" " , /* Nothing */
112
108
" bubblegum" , " cake" , " bowling" , " zipper" , " plunger" , " switch" ,
113
109
" swatter" , " rubber-ball" , " parachute" , " anchor"
@@ -185,6 +181,7 @@ void PowerupManager::loadWeights(const XMLNode *powerup_node,
185
181
Log::fatal (" PowerupManager" ,
186
182
" Cannot find node '%s' in powerup.xml file." ,
187
183
class_name.c_str ());
184
+ return ;
188
185
}
189
186
190
187
for (unsigned int i = 0 ; i < node->getNumNodes (); i++)
@@ -232,12 +229,19 @@ void PowerupManager::WeightsData::readData(int num_karts, const XMLNode *node)
232
229
233
230
// Keep a reference for shorter access to the list
234
231
std::vector<int > &l = m_weights_for_section.back ();
235
- for (unsigned int i =0 ; i< l_string.size (); i ++)
232
+ for (unsigned int j =0 ; j < l_string.size (); j ++)
236
233
{
237
- if (l_string[i]== " " ) continue ;
234
+ if (l_string[j]. empty () ) continue ;
238
235
int n;
239
- StringUtils::fromString (l_string[i], n);
240
- l.push_back (n);
236
+ if (StringUtils::fromString (l_string[j], n))
237
+ {
238
+ l.push_back (n);
239
+ } else
240
+ {
241
+ Log::warn (" PowerupManager" ,
242
+ " Invalid integer value '%s' in powerup.xml for '%s'" ,
243
+ l_string[j].c_str (), node->getName ().c_str ());
244
+ }
241
245
}
242
246
// Make sure we have the right number of entries
243
247
if (l.size () < 2 * (int )POWERUP_LAST)
@@ -472,8 +476,8 @@ void PowerupManager::loadPowerup(PowerupType type, const XMLNode &node)
472
476
/* strip_path*/ false );
473
477
474
478
475
- assert (m_all_icons[type] != NULL );
476
- assert (m_all_icons[type]->getTexture () != NULL );
479
+ assert (m_all_icons[type] != nullptr );
480
+ assert (m_all_icons[type]->getTexture () != nullptr );
477
481
478
482
std::string model (" " );
479
483
node.get (" model" , &model);
0 commit comments