Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:

committed by
Michael Lutz

parent
3b4f224c0b
commit
7c8e7c6b6e
@@ -34,8 +34,8 @@
|
||||
ScriptStorage::~ScriptStorage()
|
||||
{
|
||||
/* Free our pointers */
|
||||
if (event_data != NULL) ScriptEventController::FreeEventPointer();
|
||||
if (log_data != NULL) ScriptLog::FreeLogPointer();
|
||||
if (event_data != nullptr) ScriptEventController::FreeEventPointer();
|
||||
if (log_data != nullptr) ScriptLog::FreeLogPointer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,17 +50,17 @@ static void PrintFunc(bool error_msg, const SQChar *message)
|
||||
}
|
||||
|
||||
ScriptInstance::ScriptInstance(const char *APIName) :
|
||||
engine(NULL),
|
||||
versionAPI(NULL),
|
||||
controller(NULL),
|
||||
storage(NULL),
|
||||
instance(NULL),
|
||||
engine(nullptr),
|
||||
versionAPI(nullptr),
|
||||
controller(nullptr),
|
||||
storage(nullptr),
|
||||
instance(nullptr),
|
||||
is_started(false),
|
||||
is_dead(false),
|
||||
is_save_data_on_stack(false),
|
||||
suspend(0),
|
||||
is_paused(false),
|
||||
callback(NULL)
|
||||
callback(nullptr)
|
||||
{
|
||||
this->storage = new ScriptStorage();
|
||||
this->engine = new Squirrel(APIName);
|
||||
@@ -135,8 +135,8 @@ ScriptInstance::~ScriptInstance()
|
||||
{
|
||||
ScriptObject::ActiveInstance active(this);
|
||||
|
||||
if (instance != NULL) this->engine->ReleaseObject(this->instance);
|
||||
if (engine != NULL) delete this->engine;
|
||||
if (instance != nullptr) this->engine->ReleaseObject(this->instance);
|
||||
if (engine != nullptr) delete this->engine;
|
||||
delete this->storage;
|
||||
delete this->controller;
|
||||
free(this->instance);
|
||||
@@ -153,10 +153,10 @@ void ScriptInstance::Died()
|
||||
DEBUG(script, 0, "The script died unexpectedly.");
|
||||
this->is_dead = true;
|
||||
|
||||
if (this->instance != NULL) this->engine->ReleaseObject(this->instance);
|
||||
if (this->instance != nullptr) this->engine->ReleaseObject(this->instance);
|
||||
delete this->engine;
|
||||
this->instance = NULL;
|
||||
this->engine = NULL;
|
||||
this->instance = nullptr;
|
||||
this->engine = nullptr;
|
||||
}
|
||||
|
||||
void ScriptInstance::GameLoop()
|
||||
@@ -179,7 +179,7 @@ void ScriptInstance::GameLoop()
|
||||
_current_company = ScriptObject::GetCompany();
|
||||
|
||||
/* If there is a callback to call, call that first */
|
||||
if (this->callback != NULL) {
|
||||
if (this->callback != nullptr) {
|
||||
if (this->is_save_data_on_stack) {
|
||||
sq_poptop(this->engine->GetVM());
|
||||
this->is_save_data_on_stack = false;
|
||||
@@ -195,7 +195,7 @@ void ScriptInstance::GameLoop()
|
||||
}
|
||||
|
||||
this->suspend = 0;
|
||||
this->callback = NULL;
|
||||
this->callback = nullptr;
|
||||
|
||||
if (!this->is_started) {
|
||||
try {
|
||||
@@ -351,7 +351,7 @@ static const SaveLoad _script_byte[] = {
|
||||
case OT_INTEGER: {
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_INT;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
SQInteger res;
|
||||
sq_getinteger(vm, index, &res);
|
||||
@@ -365,7 +365,7 @@ static const SaveLoad _script_byte[] = {
|
||||
case OT_STRING: {
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_STRING;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
const SQChar *buf;
|
||||
sq_getstring(vm, index, &buf);
|
||||
@@ -376,7 +376,7 @@ static const SaveLoad _script_byte[] = {
|
||||
}
|
||||
if (!test) {
|
||||
_script_sl_byte = (byte)len;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
SlArray(const_cast<char *>(buf), len, SLE_CHAR);
|
||||
}
|
||||
return true;
|
||||
@@ -385,7 +385,7 @@ static const SaveLoad _script_byte[] = {
|
||||
case OT_ARRAY: {
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_ARRAY;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
sq_pushnull(vm);
|
||||
while (SQ_SUCCEEDED(sq_next(vm, index - 1))) {
|
||||
@@ -400,7 +400,7 @@ static const SaveLoad _script_byte[] = {
|
||||
sq_pop(vm, 1);
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_ARRAY_TABLE_END;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -408,7 +408,7 @@ static const SaveLoad _script_byte[] = {
|
||||
case OT_TABLE: {
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_TABLE;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
sq_pushnull(vm);
|
||||
while (SQ_SUCCEEDED(sq_next(vm, index - 1))) {
|
||||
@@ -423,7 +423,7 @@ static const SaveLoad _script_byte[] = {
|
||||
sq_pop(vm, 1);
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_ARRAY_TABLE_END;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -431,13 +431,13 @@ static const SaveLoad _script_byte[] = {
|
||||
case OT_BOOL: {
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_BOOL;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
SQBool res;
|
||||
sq_getbool(vm, index, &res);
|
||||
if (!test) {
|
||||
_script_sl_byte = res ? 1 : 0;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ static const SaveLoad _script_byte[] = {
|
||||
case OT_NULL: {
|
||||
if (!test) {
|
||||
_script_sl_byte = SQSL_NULL;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -459,7 +459,7 @@ static const SaveLoad _script_byte[] = {
|
||||
/* static */ void ScriptInstance::SaveEmpty()
|
||||
{
|
||||
_script_sl_byte = 0;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
|
||||
void ScriptInstance::Save()
|
||||
@@ -467,7 +467,7 @@ void ScriptInstance::Save()
|
||||
ScriptObject::ActiveInstance active(this);
|
||||
|
||||
/* Don't save data if the script didn't start yet or if it crashed. */
|
||||
if (this->engine == NULL || this->engine->HasScriptCrashed()) {
|
||||
if (this->engine == nullptr || this->engine->HasScriptCrashed()) {
|
||||
SaveEmpty();
|
||||
return;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ void ScriptInstance::Save()
|
||||
HSQUIRRELVM vm = this->engine->GetVM();
|
||||
if (this->is_save_data_on_stack) {
|
||||
_script_sl_byte = 1;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
/* Save the data that was just loaded. */
|
||||
SaveObject(vm, -1, SQUIRREL_MAX_DEPTH, false);
|
||||
} else if (!this->is_started) {
|
||||
@@ -518,7 +518,7 @@ void ScriptInstance::Save()
|
||||
sq_pushobject(vm, savedata);
|
||||
if (SaveObject(vm, -1, SQUIRREL_MAX_DEPTH, true)) {
|
||||
_script_sl_byte = 1;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
SaveObject(vm, -1, SQUIRREL_MAX_DEPTH, false);
|
||||
this->is_save_data_on_stack = true;
|
||||
} else {
|
||||
@@ -528,7 +528,7 @@ void ScriptInstance::Save()
|
||||
} else {
|
||||
ScriptLog::Warning("Save function is not implemented");
|
||||
_script_sl_byte = 0;
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,50 +553,50 @@ bool ScriptInstance::IsPaused()
|
||||
|
||||
/* static */ bool ScriptInstance::LoadObjects(HSQUIRRELVM vm)
|
||||
{
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
switch (_script_sl_byte) {
|
||||
case SQSL_INT: {
|
||||
int value;
|
||||
SlArray(&value, 1, SLE_INT32);
|
||||
if (vm != NULL) sq_pushinteger(vm, (SQInteger)value);
|
||||
if (vm != nullptr) sq_pushinteger(vm, (SQInteger)value);
|
||||
return true;
|
||||
}
|
||||
|
||||
case SQSL_STRING: {
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
static char buf[256];
|
||||
SlArray(buf, _script_sl_byte, SLE_CHAR);
|
||||
if (vm != NULL) sq_pushstring(vm, buf, -1);
|
||||
if (vm != nullptr) sq_pushstring(vm, buf, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
case SQSL_ARRAY: {
|
||||
if (vm != NULL) sq_newarray(vm, 0);
|
||||
if (vm != nullptr) sq_newarray(vm, 0);
|
||||
while (LoadObjects(vm)) {
|
||||
if (vm != NULL) sq_arrayappend(vm, -2);
|
||||
if (vm != nullptr) sq_arrayappend(vm, -2);
|
||||
/* The value is popped from the stack by squirrel. */
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case SQSL_TABLE: {
|
||||
if (vm != NULL) sq_newtable(vm);
|
||||
if (vm != nullptr) sq_newtable(vm);
|
||||
while (LoadObjects(vm)) {
|
||||
LoadObjects(vm);
|
||||
if (vm != NULL) sq_rawset(vm, -3);
|
||||
if (vm != nullptr) sq_rawset(vm, -3);
|
||||
/* The key (-2) and value (-1) are popped from the stack by squirrel. */
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case SQSL_BOOL: {
|
||||
SlObject(NULL, _script_byte);
|
||||
if (vm != NULL) sq_pushbool(vm, (SQBool)(_script_sl_byte != 0));
|
||||
SlObject(nullptr, _script_byte);
|
||||
if (vm != nullptr) sq_pushbool(vm, (SQBool)(_script_sl_byte != 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
case SQSL_NULL: {
|
||||
if (vm != NULL) sq_pushnull(vm);
|
||||
if (vm != nullptr) sq_pushnull(vm);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -610,24 +610,24 @@ bool ScriptInstance::IsPaused()
|
||||
|
||||
/* static */ void ScriptInstance::LoadEmpty()
|
||||
{
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
/* Check if there was anything saved at all. */
|
||||
if (_script_sl_byte == 0) return;
|
||||
|
||||
LoadObjects(NULL);
|
||||
LoadObjects(nullptr);
|
||||
}
|
||||
|
||||
void ScriptInstance::Load(int version)
|
||||
{
|
||||
ScriptObject::ActiveInstance active(this);
|
||||
|
||||
if (this->engine == NULL || version == -1) {
|
||||
if (this->engine == nullptr || version == -1) {
|
||||
LoadEmpty();
|
||||
return;
|
||||
}
|
||||
HSQUIRRELVM vm = this->engine->GetVM();
|
||||
|
||||
SlObject(NULL, _script_byte);
|
||||
SlObject(nullptr, _script_byte);
|
||||
/* Check if there was anything saved at all. */
|
||||
if (_script_sl_byte == 0) return;
|
||||
|
||||
|
Reference in New Issue
Block a user