diff options
author | Henry Wilson <m3henry@googlemail.com> | 2019-04-10 22:07:06 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-10 23:22:20 +0200 |
commit | 7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch) | |
tree | 99f134b7e66367cf11e10bc5061896eab4a3264f /src/script/squirrel.cpp | |
parent | 3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff) | |
download | openttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz |
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/script/squirrel.cpp')
-rw-r--r-- | src/script/squirrel.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 23163f6b3..fd0478bb5 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -31,7 +31,7 @@ void Squirrel::CompileError(HSQUIRRELVM vm, const SQChar *desc, const SQChar *so Squirrel *engine = (Squirrel *)sq_getforeignptr(vm); engine->crashed = true; SQPrintFunc *func = engine->print_func; - if (func == NULL) { + if (func == nullptr) { DEBUG(misc, 0, "[Squirrel] Compile error: %s", buf); } else { (*func)(true, buf); @@ -49,7 +49,7 @@ void Squirrel::ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) /* Check if we have a custom print function */ SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func; - if (func == NULL) { + if (func == nullptr) { fprintf(stderr, "%s", buf); } else { (*func)(true, buf); @@ -67,7 +67,7 @@ void Squirrel::RunError(HSQUIRRELVM vm, const SQChar *error) seprintf(buf, lastof(buf), "Your script made an error: %s\n", error); Squirrel *engine = (Squirrel *)sq_getforeignptr(vm); SQPrintFunc *func = engine->print_func; - if (func == NULL) { + if (func == nullptr) { fprintf(stderr, "%s", buf); } else { (*func)(true, buf); @@ -106,7 +106,7 @@ void Squirrel::PrintFunc(HSQUIRRELVM vm, const SQChar *s, ...) /* Check if we have a custom print function */ SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func; - if (func == NULL) { + if (func == nullptr) { printf("%s", buf); } else { (*func)(false, buf); @@ -234,8 +234,8 @@ bool Squirrel::CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT } /* Call the method */ sq_pushobject(this->vm, instance); - if (SQ_FAILED(sq_call(this->vm, 1, ret == NULL ? SQFalse : SQTrue, SQTrue, suspend))) return false; - if (ret != NULL) sq_getstackobj(vm, -1, ret); + if (SQ_FAILED(sq_call(this->vm, 1, ret == nullptr ? SQFalse : SQTrue, SQTrue, suspend))) return false; + if (ret != nullptr) sq_getstackobj(vm, -1, ret); /* Reset the top, but don't do so for the script main function, as we need * a correct stack when resuming. */ if (suspend == -1 || !this->IsSuspended()) sq_settop(this->vm, top); @@ -305,7 +305,7 @@ bool Squirrel::CallBoolMethod(HSQOBJECT instance, const char *method_name, bool return false; } - if (instance != NULL) { + if (instance != nullptr) { /* Find our instance */ sq_getstackobj(vm, -1, instance); /* Add a reference to it, so it survives for ever */ @@ -316,16 +316,16 @@ bool Squirrel::CallBoolMethod(HSQOBJECT instance, const char *method_name, bool /* Store it in the class */ sq_setinstanceup(vm, -1, real_instance); - if (release_hook != NULL) sq_setreleasehook(vm, -1, release_hook); + if (release_hook != nullptr) sq_setreleasehook(vm, -1, release_hook); - if (instance != NULL) sq_settop(vm, oldtop); + if (instance != nullptr) sq_settop(vm, oldtop); return true; } bool Squirrel::CreateClassInstance(const char *class_name, void *real_instance, HSQOBJECT *instance) { - return Squirrel::CreateClassInstanceVM(this->vm, class_name, real_instance, instance, NULL); + return Squirrel::CreateClassInstanceVM(this->vm, class_name, real_instance, instance, nullptr); } Squirrel::Squirrel(const char *APIName) : @@ -336,8 +336,8 @@ Squirrel::Squirrel(const char *APIName) : void Squirrel::Initialize() { - this->global_pointer = NULL; - this->print_func = NULL; + this->global_pointer = nullptr; + this->print_func = nullptr; this->crashed = false; this->overdrawn_ops = 0; this->vm = sq_open(1024); @@ -436,15 +436,15 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer size_t size; if (strncmp(this->GetAPIName(), "AI", 2) == 0) { file = FioFOpenFile(filename, "rb", AI_DIR, &size); - if (file == NULL) file = FioFOpenFile(filename, "rb", AI_LIBRARY_DIR, &size); + if (file == nullptr) file = FioFOpenFile(filename, "rb", AI_LIBRARY_DIR, &size); } else if (strncmp(this->GetAPIName(), "GS", 2) == 0) { file = FioFOpenFile(filename, "rb", GAME_DIR, &size); - if (file == NULL) file = FioFOpenFile(filename, "rb", GAME_LIBRARY_DIR, &size); + if (file == nullptr) file = FioFOpenFile(filename, "rb", GAME_LIBRARY_DIR, &size); } else { NOT_REACHED(); } - if (file == NULL) { + if (file == nullptr) { return sq_throwerror(vm, "cannot open the file"); } unsigned short bom = 0; |