Mass replace NULL --> nullptr

(Except one instance was instead replaced with nil)
This commit is contained in:
2015-09-13 10:50:21 -04:00
parent f1b097a54c
commit 780b413d0c
24 changed files with 92 additions and 92 deletions

View File

@@ -841,7 +841,7 @@ void handle_talk_event(location p) {
case eTalkNode::TRAINING:
if((get_pc = char_select_pc(0,"Train who?")) < 6) {
can_save_talk = false;
spend_xp(get_pc,1, NULL);
spend_xp(get_pc,1, nullptr);
}
save_talk_str1 = "You conclude your training.";
return;

View File

@@ -427,7 +427,7 @@ static bool display_monst_event_filter(cDialog& me, std::string item_hit, cCreat
return true;
}
//creature_data_type *which_m; // if NULL, show full roster
//creature_data_type *which_m; // if nullptr, show full roster
//short mode; // if 1, full roster, else use monster from store_m
void display_monst(short array_pos,cCreature *which_m,short mode) {
using namespace std::placeholders;
@@ -851,7 +851,7 @@ static void give_help(short help1,short help2,cDialog* parent) {
}
void give_help(short help1, short help2) {
give_help(help1, help2, NULL);
give_help(help1, help2, nullptr);
}
void give_help(short help1, short help2, cDialog& parent) {

View File

@@ -178,7 +178,7 @@ void Initialize(void) {
// and date into the seed. Since it is always incrementing the starting seed
// will always be different. Don't for each call of Random, or the sequence
// will no longer be random. Only needed once, here in the init.
srand(time(NULL));
srand(time(nullptr));
load_prefs();
text_sbar.reset(new cScrollbar(mainPtr));
@@ -453,7 +453,7 @@ void handle_menu_choice(eMenu item_hit) {
case eMenu::OPTIONS_PC_GRAPHIC:
choice = char_select_pc(1,"New graphic for who?");
if(choice < 6)
pick_pc_graphic(choice,1,NULL);
pick_pc_graphic(choice,1,nullptr);
draw_terrain();
break;
@@ -477,7 +477,7 @@ void handle_menu_choice(eMenu item_hit) {
case eMenu::OPTIONS_RENAME_PC:
choice = char_select_pc(1,"Rename who?");
if(choice < 6)
pick_pc_name(choice,NULL);
pick_pc_name(choice,nullptr);
put_pc_screen();
put_item_screen(stat_window);
break;
@@ -499,7 +499,7 @@ void handle_menu_choice(eMenu item_hit) {
}
if(univ.town->has_tavern) {
give_help(56,0);
create_pc(6,NULL);
create_pc(6,nullptr);
} else {
add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2);
}
@@ -605,7 +605,7 @@ void handle_menu_choice(eMenu item_hit) {
// TODO: Let this function take a cMonster* instead of the item_hit
void handle_monster_info_menu(int item_hit) {
display_monst(item_hit - 1, NULL,1);
display_monst(item_hit - 1, nullptr,1);
}
static cursor_type get_mode_cursor(){

View File

@@ -207,14 +207,14 @@ void cLed::attachFocusHandler(focus_callback_t f) throw(){
}
bool cLed::triggerFocusHandler(cDialog& me, std::string id, bool losing){
if(onFocus != NULL) return onFocus(me,id,losing);
if(onFocus != nullptr) return onFocus(me,id,losing);
return true;
}
bool cLed::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
bool result;
eLedState oldState = state;
if(onClick != NULL) result = onClick(me,id,mods);
if(onClick != nullptr) result = onClick(me,id,mods);
else{ // simple state toggle
switch(state){
case led_red:
@@ -394,7 +394,7 @@ bool cLedGroup::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
}
bool cLedGroup::triggerFocusHandler(cDialog& me, std::string id, bool losingFocus){
if(onFocus != NULL) return onFocus(me,id,losingFocus);
if(onFocus != nullptr) return onFocus(me,id,losingFocus);
return true;
}

View File

@@ -50,13 +50,13 @@ const char* xHandlerNotSupported::what(){
xUnsupportedProp::xUnsupportedProp(eFormat prop) throw(){
whichProp = prop;
msg = NULL;
msg = nullptr;
}
xUnsupportedProp::~xUnsupportedProp() throw(){
if(msg != NULL) delete msg;
if(msg != nullptr) delete msg;
}
const char* xUnsupportedProp::what() throw(){
if(msg == NULL){
if(msg == nullptr){
msg = new char[62];
std::string s;
switch(whichProp){
@@ -266,7 +266,7 @@ void cControl::detachKey(){
cControl::cControl(eControlType t, cDialog& p) : parent(&p), inWindow(&p.win), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(NULL), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(nullptr), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {}
bool cControl::triggerClickHandler(cDialog&, std::string, eKeyMod){
return true;

View File

@@ -230,7 +230,7 @@ protected:
/// May be null, if the control was created via cControl(eControlType,sf::RenderWindow&).
cDialog* parent;
/// This control's labelling control.
cControl* labelCtrl = NULL;
cControl* labelCtrl = nullptr;
/// The parent window of the control.
/// This is for use in implementing draw().
sf::RenderWindow* inWindow;

View File

@@ -1360,7 +1360,7 @@ bool cDialog::addLabelFor(std::string key, std::string label, eLabelPos where, s
}
labelCtrl->setText(label);
labelCtrl->setFormat(TXT_FONT, bold ? FONT_BOLD : FONT_PLAIN);
if(bg == BG_DARK && dynamic_cast<cButton*>(&ctrl) != NULL)
if(bg == BG_DARK && dynamic_cast<cButton*>(&ctrl) != nullptr)
labelCtrl->setColour(defTextClr);
else labelCtrl->setColour(ctrl.getColour());
ctrl.setLabelCtrl(labelCtrl);
@@ -1417,13 +1417,13 @@ xBadNode::xBadNode(std::string t, int r, int c, std::string dlg) throw() :
type(t),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xBadNode::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1434,7 +1434,7 @@ const char* xBadNode::what() const throw() {
}
xBadNode::~xBadNode() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xBadAttr::xBadAttr(std::string t, std::string n, int r, int c, std::string dlg) throw() :
@@ -1442,13 +1442,13 @@ xBadAttr::xBadAttr(std::string t, std::string n, int r, int c, std::string dlg)
name(n),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xBadAttr::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1459,7 +1459,7 @@ const char* xBadAttr::what() const throw() {
}
xBadAttr::~xBadAttr() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xMissingAttr::xMissingAttr(std::string t, std::string n, int r, int c, std::string dlg) throw() :
@@ -1467,13 +1467,13 @@ xMissingAttr::xMissingAttr(std::string t, std::string n, int r, int c, std::stri
name(n),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xMissingAttr::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1484,7 +1484,7 @@ const char* xMissingAttr::what() const throw() {
}
xMissingAttr::~xMissingAttr() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xMissingElem::xMissingElem(std::string p, std::string t, int r, int c, std::string dlg) throw() :
@@ -1492,13 +1492,13 @@ xMissingElem::xMissingElem(std::string p, std::string t, int r, int c, std::stri
name(t),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xMissingElem::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1509,7 +1509,7 @@ const char* xMissingElem::what() const throw() {
}
xMissingElem::~xMissingElem() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
xBadVal::xBadVal(std::string t, std::string n, std::string v, int r, int c, std::string dlg) throw() :
@@ -1518,13 +1518,13 @@ xBadVal::xBadVal(std::string t, std::string n, std::string v, int r, int c, std:
val(v),
row(r),
col(c),
msg(NULL),
msg(nullptr),
dlg(dlg) {}
const char* xBadVal::what() const throw() {
if(msg == NULL){
if(msg == nullptr){
char* s = new (nothrow) char[200];
if(s == NULL){
if(s == nullptr){
std::cerr << "Allocation of memory for error message failed, bailing out..." << std::endl;
abort();
}
@@ -1535,7 +1535,7 @@ const char* xBadVal::what() const throw() {
}
xBadVal::~xBadVal() throw(){
if(msg != NULL) delete[] msg;
if(msg != nullptr) delete[] msg;
}
bool cDialog::doAnimations = false;

View File

@@ -58,11 +58,11 @@ public:
static short defaultBackground;
/// Create a new dialog with no items.
/// @param p Optionally, a parent dialog.
explicit cDialog(cDialog* p = NULL);
explicit cDialog(cDialog* p = nullptr);
/// Creates a new dialog, loading its definition from a file.
/// @param path The name of the file to load. It must be in the game's dialogs directory.
/// @param p Optionally, a parent dialog.
explicit cDialog(std::string path, cDialog* p = NULL); // cd_create_dialog
explicit cDialog(std::string path, cDialog* p = nullptr); // cd_create_dialog
~cDialog(); // cd_kill_dialog
/// Add a new control to the dialog.
/// @param what A pointer to the control, which should already be constructed.

View File

@@ -502,7 +502,7 @@ cStrDlog& cStrDlog::setSound(snd_num_t snd){
}
cStrDlog& cStrDlog::setRecordHandler(record_callback_t rec){
if(rec == NULL){
if(rec == nullptr){
hasRecord = false;
dlg["record"].hide();
}else{

View File

@@ -44,7 +44,7 @@ public:
/// @param pic The icon to show at the top left.
/// @param t The type of icon to show.
/// @param parent Optionally, a parent dialog.
cStrDlog(std::string str1,std::string str2,std::string title,pic_num_t pic,ePicType t,cDialog* parent = NULL);
cStrDlog(std::string str1,std::string str2,std::string title,pic_num_t pic,ePicType t,cDialog* parent = nullptr);
/// Set a sound to be played when the dialog is shown.
/// @param num The sound number.
/// @return This object, for method-call chaining.
@@ -78,18 +78,18 @@ protected:
bool onClick(cDialog& me, std::string id);
/// Create a choice dialog, but don't initialize it.
/// @param p Optionally, a parent dialog.
explicit cChoiceDlog(cDialog* p = NULL);
explicit cChoiceDlog(cDialog* p = nullptr);
public:
/// Create a choice dialog with just one button.
/// @param file The file to load the dialog definition from.
/// @param p Optionally, a parent dialog.
/// @note The dialog definition file must include a button whose name attribute is "okay".
explicit cChoiceDlog(std::string file, cDialog* p = NULL);
explicit cChoiceDlog(std::string file, cDialog* p = nullptr);
/// Create a choice dialog with several buttons.
/// @param file The file to load the dialog definition from.
/// @param buttons A list of the buttons to handle. All of them must be defined in the file.
/// @param p Optionally, a parent dialog.
cChoiceDlog(std::string file, std::vector<std::string> buttons, cDialog* p = NULL);
cChoiceDlog(std::string file, std::vector<std::string> buttons, cDialog* p = nullptr);
/// Reference the cDialog powering this choice dialog, perhaps to customize details of it.
/// @return A pointer to the dialog.
cDialog* operator->();
@@ -133,21 +133,21 @@ public:
/// @param pic The icon to show at the top left.
/// @param t The type of the icon.
/// @param parent Optionally, a parent dialog.
cThreeChoice(std::vector<std::string>& strings, cBasicButtonType button, pic_num_t pic, ePicType t, cDialog* parent = NULL);
cThreeChoice(std::vector<std::string>& strings, cBasicButtonType button, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
/// Create a dialog with up to three buttons.
/// @param strings A list of the strings to place in the dialog.
/// @param buttons A list of the button specifications.
/// @param pic The icon to show at the top left.
/// @param t The type of the icon.
/// @param parent Optionally, a parent dialog.
cThreeChoice(std::vector<std::string>& strings, std::array<cBasicButtonType, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = NULL);
cThreeChoice(std::vector<std::string>& strings, std::array<cBasicButtonType, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
/// Create a dialog with up to three buttons.
/// @param strings A list of the strings to place in the dialog.
/// @param buttons A list of the index of the button; this is an index into available_btns which is in turn used to index basic_buttons.
/// @param pic The icon to show at the top left.
/// @param t The type of the icon.
/// @param parent Optionally, a parent dialog.
cThreeChoice(std::vector<std::string>& strings, std::array<short, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = NULL);
cThreeChoice(std::vector<std::string>& strings, std::array<short, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
/// @copydoc cChoiceDlog::show()
/// @note The unique key in this case is the label specified in the button specification.
std::string show();
@@ -174,14 +174,14 @@ public:
/// @param strs A list of all strings in the dialog.
/// @param title The title to show in the dialog.
/// @param parent Optionally, a parent dialog.
explicit cStringChoice(std::vector<std::string>& strs, std::string title, cDialog* parent = NULL);
explicit cStringChoice(std::vector<std::string>& strs, std::string title, cDialog* parent = nullptr);
/// Initializes a dialog from an iterator pair.
/// @param begin An iterator to the first string in the dialog.
/// @param end An iterator to one past the last string in the dialog.
/// @param title The title to show in the dialog.
/// @param parent Optionally, a parent dialog.
/// @note Currently, only vector iterators are supported.
cStringChoice(std::vector<std::string>::iterator begin, std::vector<std::string>::iterator end, std::string title, cDialog* parent = NULL);
cStringChoice(std::vector<std::string>::iterator begin, std::vector<std::string>::iterator end, std::string title, cDialog* parent = nullptr);
/// Attach a handler to be called when the selected item changes.
/// @param f A function that takes a reference to the dialog and the index of the newly selected item.
void attachSelectHandler(std::function<void(cStringChoice&,int)> f);
@@ -216,23 +216,23 @@ public:
/// @param pics A list of all icons in the dialog.
/// @param t The type of icons to show; all icons are assumed to be of the same type.
/// @param parent Optionally, a parent dialog.
cPictChoice(const std::vector<pic_num_t>& pics, ePicType t, cDialog* parent = NULL);
cPictChoice(const std::vector<pic_num_t>& pics, ePicType t, cDialog* parent = nullptr);
/// Initializes a dialog from a list of icons.
/// @param pics A list of all icons in the dialog as {num,type} pairs.
/// @param parent Optionally, a parent dialog.
cPictChoice(const std::vector<std::pair<pic_num_t,ePicType>>& pics, cDialog* parent = NULL);
cPictChoice(const std::vector<std::pair<pic_num_t,ePicType>>& pics, cDialog* parent = nullptr);
/// Initializes a dialog from an iterator pair.
/// @param begin An iterator to the first icon in the dialog.
/// @param end An iterator to one past the last icon in the dialog.
/// @param t The type of icons to show; all icons are assumed to be of the same type.
/// @param parent Optionally, a parent dialog.
cPictChoice(std::vector<pic_num_t>::const_iterator begin, std::vector<pic_num_t>::const_iterator end, ePicType t, cDialog* parent = NULL);
cPictChoice(std::vector<pic_num_t>::const_iterator begin, std::vector<pic_num_t>::const_iterator end, ePicType t, cDialog* parent = nullptr);
/// Initializes a dialog from an index pair.
/// @param first The number of the first icon in the dialog.
/// @param last The number of the last icon in the dialog.
/// @param t The type of icons to show; all icons are assumed to be of the same type.
/// @param parent Optionally, a parent dialog.
cPictChoice(pic_num_t first, pic_num_t last, ePicType t, cDialog* parent = NULL);
cPictChoice(pic_num_t first, pic_num_t last, ePicType t, cDialog* parent = nullptr);
/// Attach a handler to be called when the selected item changes.
/// @param f A function that takes a reference to the dialog and the index of the newly selected item.
void attachSelectHandler(std::function<void(cPictChoice&,int)> f);
@@ -259,28 +259,28 @@ public:
/// @param str1 The first string in the error dialog.
/// @param str2 The second string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showFatalError(std::string str1, std::string str2, cDialog* parent = NULL);
void showFatalError(std::string str1, std::string str2, cDialog* parent = nullptr);
/// Shows a simple error dialog for an unrecoverable condition.
/// @param str1 The string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showFatalError(std::string str1, cDialog* parent = NULL);
void showFatalError(std::string str1, cDialog* parent = nullptr);
/// Shows a simple error dialog for a recoverable condition.
/// @param str1 The first string in the error dialog.
/// @param str2 The second string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showError(std::string str1, std::string str2, cDialog* parent = NULL);
void showError(std::string str1, std::string str2, cDialog* parent = nullptr);
/// Shows a simple error dialog for a recoverable condition.
/// @param str1 The string in the error dialog.
/// @param parent Optionally, a parent dialog.
void showError(std::string str1, cDialog* parent = NULL);
void showError(std::string str1, cDialog* parent = nullptr);
/// Shows a simple warning message dialog.
/// @param str1 The first string in the warning dialog.
/// @param str2 The second string in the warning dialog.
/// @param parent Optionally, a parent dialog.
void showWarning(std::string str1, std::string str2, cDialog* parent = NULL);
void showWarning(std::string str1, std::string str2, cDialog* parent = nullptr);
/// Shows a simple warning message dialog.
/// @param str1 The string in the warning dialog.
/// @param parent Optionally, a parent dialog.
void showWarning(std::string str1, cDialog* parent = NULL);
void showWarning(std::string str1, cDialog* parent = nullptr);

View File

@@ -52,7 +52,7 @@ bool cTextField::triggerFocusHandler(cDialog& me, std::string id, bool losingFoc
}
}
bool passed = true;
if(onFocus != NULL) passed = onFocus(me,id,losingFocus);
if(onFocus != nullptr) passed = onFocus(me,id,losingFocus);
if(passed) haveFocus = !losingFocus;
if(haveFocus && insertionPoint < 0)
insertionPoint = getText().length();

View File

@@ -15,7 +15,7 @@ extern sf::Texture bg_gworld;
void cTextMsg::attachClickHandler(click_callback_t f) throw(){
onClick = f;
clickable = onClick != NULL;
clickable = onClick != nullptr;
}
void cTextMsg::attachFocusHandler(focus_callback_t) throw(xHandlerNotSupported){
@@ -23,7 +23,7 @@ void cTextMsg::attachFocusHandler(focus_callback_t) throw(xHandlerNotSupported){
}
bool cTextMsg::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods){
if(onClick != NULL) return onClick(me,id,mods);
if(onClick != nullptr) return onClick(me,id,mods);
return false;
}

View File

@@ -60,7 +60,7 @@ void cScrollbar::attachFocusHandler(focus_callback_t) throw(xHandlerNotSupported
bool cScrollbar::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods) {
// TODO: Implement detection of scrolling stuff, maybe even dragging the thumb
if(onClick != NULL) return onClick(me,id,mods);
if(onClick != nullptr) return onClick(me,id,mods);
return false;
}

View File

@@ -54,16 +54,16 @@ bool handle_action(sf::Event event) {
do_button_action(0,i + 10);
switch(i) {
case 0:
display_pc(current_active_pc,10,NULL);
display_pc(current_active_pc,10,nullptr);
break;
case 1:
display_pc(current_active_pc,11,NULL);
display_pc(current_active_pc,11,nullptr);
break;
case 2:
pick_race_abil(&univ.party[current_active_pc],0);
break;
case 3:
spend_xp(current_active_pc,2,NULL);
spend_xp(current_active_pc,2,nullptr);
break;
case 4:
edit_xp(&univ.party[current_active_pc]);

View File

@@ -106,7 +106,7 @@ void Initialize(void) {
// and date into the seed. Since it is always incrementing the starting seed
// will always be different. Dont for each call of Random, or the sequence
// will no longer be random. Only needed once, here in the init.
srand(time(NULL));
srand(time(nullptr));
// Make a new window for drawing in, and it must be a color window.
// The window is full screen size, made smaller to make it more visible.
@@ -369,7 +369,7 @@ static void give_help(short help1,short help2,cDialog* parent) {
}
void give_help(short help1, short help2) {
give_help(help1, help2, NULL);
give_help(help1, help2, nullptr);
}
void give_help(short help1, short help2, cDialog& parent) {

View File

@@ -27,7 +27,7 @@
bool All_Done = false;
sf::Event event;
sf::RenderWindow mainPtr;
cTown* town = NULL;
cTown* town = nullptr;
bool diff_depth_ok = false,mouse_button_held = false,editing_town = false;
short cur_viewing_mode = 0;
short cen_x, cen_y;
@@ -124,7 +124,7 @@ void Initialize(void) {
// and date into the seed. Since it is always incrementing the starting seed
// will always be different. Dont for each call of Random, or the sequence
// will no longer be random. Only needed once, here in the init.
srand(time(NULL));
srand(time(nullptr));
// Make a new window for drawing in, and it must be a color window.
// The window is full screen size, made smaller to make it more visible.

View File

@@ -14,12 +14,12 @@
extern cursor_type current_cursor;
static NSImage* imageFromURL(CFURLRef url){
CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, NULL);
CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, nullptr);
CGImageRef theImage = nil;
if(imageSource == nil) return nil;
theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nullptr);
if(theImage == nil) return nil;
CFRelease( imageSource );
@@ -44,8 +44,8 @@ static NSImage* imageFromURL(CFURLRef url){
Cursor::Cursor(fs::path path, float hotSpotX, float hotSpotY){
FSRef ref;
FSPathMakeRef((UInt8*)path.c_str(), &ref, NULL);
CFURLRef imgPath = CFURLCreateFromFSRef(NULL, &ref);
FSPathMakeRef((UInt8*)path.c_str(), &ref, nullptr);
CFURLRef imgPath = CFURLCreateFromFSRef(nullptr, &ref);
NSImage *img = imageFromURL(imgPath);
NSCursor *cursor = [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(hotSpotX, hotSpotY)];

View File

@@ -53,7 +53,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){
// but if the first flag is 0x0B0E, we have a new-format save
// the three flags still follow that.
FILE* file_id = fopen(file_to_load.string().c_str(), "rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError("Loading Blades of Exile save file failed.");
return false;
}

View File

@@ -123,7 +123,7 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario, bool only_head
legacy::scen_item_data_type *item_data = new legacy::scen_item_data_type;
// TODO: Convert this (and all the others in this file) to use C++ streams
FILE* file_id = fopen(file_to_load.string().c_str(),"rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError(err_prefix + "Could not open file.", get_file_error());
return false;
}
@@ -2164,7 +2164,7 @@ bool load_town_v1(fs::path scen_file, short which_town, cTown& the_town, legacy:
legacy::tiny_tr_type tiny_t;
FILE* file_id = fopen(scen_file.string().c_str(), "rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError(err_prefix + "Could not open file for reading town data.", get_file_error());
return false;
}
@@ -2302,7 +2302,7 @@ bool load_outdoors_v1(fs::path scen_file, location which_out,cOutdoors& the_out,
legacy::outdoor_record_type store_out;
FILE* file_id = fopen(scen_file.string().c_str(), "rb");
if(file_id == NULL) {
if(file_id == nullptr) {
showError(err_prefix + "Could not open file for reading outdoor data.", get_file_error());
return false;
}

View File

@@ -404,8 +404,8 @@ graf_pos cCustomGraphics::find_graphic(pic_num_t which_rect, bool party) {
}
size_t cCustomGraphics::count(bool party) {
if(!party && sheets == NULL) return 0;
else if(party && party_sheet == NULL) return 0;
if(!party && sheets == nullptr) return 0;
else if(party && party_sheet == nullptr) return 0;
else if(is_old || party) {
rectangle bounds(party ? *party_sheet : sheets[0]);
if(bounds.width() < 280) return bounds.width() / 28;

View File

@@ -65,12 +65,12 @@ using hilite_t = std::pair<size_t,size_t>;
struct cCustomGraphics {
size_t numSheets;
sf::Texture* sheets = NULL;
sf::Texture* sheets = nullptr;
std::shared_ptr<sf::Texture> party_sheet;
bool is_old = false;
void clear() {
if(sheets != NULL) delete[] sheets;
sheets = NULL;
if(sheets != nullptr) delete[] sheets;
sheets = nullptr;
}
~cCustomGraphics() {
clear();

View File

@@ -459,8 +459,8 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store) {
// TODO: There's no way around it; I'll have to read resource files for this section.
FSRef file;
ResFileRefNum custRef;
OSErr err = FSPathMakeRef((const UInt8*)gpath.c_str(), &file, NULL);
err = FSOpenResourceFile(&file, 0, NULL, fsRdPerm, &custRef);
OSErr err = FSPathMakeRef((const UInt8*)gpath.c_str(), &file, nullptr);
err = FSOpenResourceFile(&file, 0, nullptr, fsRdPerm, &custRef);
if(err != noErr) { // TODO: Is the error that would be returned if the resources were stored in the resource fork?
HFSUniStr255 rsrc;
err = FSGetResourceForkName(&rsrc);
@@ -482,29 +482,29 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store) {
showError("An old-style .meg graphics file was found, but it did not contain a PICT resource of ID 1.",noGraphics);
return false;
}
if(resHandle == NULL) {
if(resHandle == nullptr) {
CloseResFile(custRef);
showError("An old-style .meg graphics file was found, but an error occurred while fetching the PICT resource of ID 1.",noGraphics);
return false;
}
unsigned char* data = NULL;
unsigned char* data = nullptr;
int error = 0;
rectangle picFrame;
try {
picFrame = loadFromPictResource(resHandle, data, error);
} catch(std::runtime_error&) {
CloseResFile(custRef);
if(data != NULL) delete[] data;
if(data != nullptr) delete[] data;
showError("An old-style .meg graphics file was found, but an error occurred while loading the PICT resource of ID 1.",noGraphics);
return false;
}
CloseResFile(custRef);
if(picFrame.width() <= 0 || picFrame.height() <= 0) {
if(data != NULL) delete[] data;
if(data != nullptr) delete[] data;
showError("An old-style .meg graphics file was found, but an error occurred while reading it: " + errStrings[error],noGraphics);
return false;
}
graphics_store.create(picFrame.width(), picFrame.height(), data);
if(data != NULL) delete[] data;
if(data != nullptr) delete[] data;
return true;
}

View File

@@ -31,7 +31,7 @@ tarball::header_posix_ustar tarball::generateTarHeader(const std::string& fileNa
// leave uid filled with NULs
// leave gid filled with NULs
snprintf(header.size,12,"%011llo",fileSize);
snprintf(header.mtime,12,"%011lo",time(NULL));
snprintf(header.mtime,12,"%011lo",time(nullptr));
memset(header.checksum,' ',8);
header.typeflag[0] = directory ? '5' : '0';
// leave linkname filled with NULs

View File

@@ -324,7 +324,7 @@ sf::Image* sfImageFromNSImage(NSImage *image) {
return nil;
NSBitmapImageRep* rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL
initWithBitmapDataPlanes: nil
pixelsWide: width
pixelsHigh: height
bitsPerSample: 8