mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Used clang-format on some common files
This commit is contained in:
parent
37d8938e91
commit
68d48d9889
27 changed files with 7275 additions and 8076 deletions
|
@ -9,9 +9,8 @@
|
|||
|
||||
MEM_BlockAlloc<ScriptClass> ScriptClass_allocator;
|
||||
|
||||
CLASS_DECLARATION(Listener, ScriptClass, NULL)
|
||||
{
|
||||
{ NULL, NULL }
|
||||
CLASS_DECLARATION(Listener, ScriptClass, NULL) {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -19,9 +18,9 @@ CLASS_DECLARATION(Listener, ScriptClass, NULL)
|
|||
new ScriptClass
|
||||
====================
|
||||
*/
|
||||
void* ScriptClass::operator new(size_t size)
|
||||
void *ScriptClass::operator new(size_t size)
|
||||
{
|
||||
return ScriptClass_allocator.Alloc();
|
||||
return ScriptClass_allocator.Alloc();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -29,9 +28,9 @@ void* ScriptClass::operator new(size_t size)
|
|||
delete ptr
|
||||
====================
|
||||
*/
|
||||
void ScriptClass::operator delete(void* ptr)
|
||||
void ScriptClass::operator delete(void *ptr)
|
||||
{
|
||||
ScriptClass_allocator.Free(ptr);
|
||||
ScriptClass_allocator.Free(ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -39,11 +38,11 @@ void ScriptClass::operator delete(void* ptr)
|
|||
ScriptClass
|
||||
====================
|
||||
*/
|
||||
ScriptClass::ScriptClass(GameScript* gameScript, Listener* self)
|
||||
ScriptClass::ScriptClass(GameScript *gameScript, Listener *self)
|
||||
{
|
||||
m_Self = self;
|
||||
m_Script = gameScript;
|
||||
m_Threads = NULL;
|
||||
m_Self = self;
|
||||
m_Script = gameScript;
|
||||
m_Threads = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -53,9 +52,9 @@ ScriptClass
|
|||
*/
|
||||
ScriptClass::ScriptClass()
|
||||
{
|
||||
m_Self = NULL;
|
||||
m_Script = NULL;
|
||||
m_Threads = NULL;
|
||||
m_Self = NULL;
|
||||
m_Script = NULL;
|
||||
m_Threads = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -65,17 +64,16 @@ ScriptClass::ScriptClass()
|
|||
*/
|
||||
ScriptClass::~ScriptClass()
|
||||
{
|
||||
if (m_Script == NULL) {
|
||||
throw ScriptException("Attempting to delete dead class.");
|
||||
}
|
||||
if (m_Script == NULL) {
|
||||
throw ScriptException("Attempting to delete dead class.");
|
||||
}
|
||||
|
||||
KillThreads();
|
||||
KillThreads();
|
||||
|
||||
if (!m_Script->m_Filename)
|
||||
{
|
||||
// This is a temporary gamescript
|
||||
delete m_Script;
|
||||
}
|
||||
if (!m_Script->m_Filename) {
|
||||
// This is a temporary gamescript
|
||||
delete m_Script;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -83,9 +81,7 @@ ScriptClass::~ScriptClass()
|
|||
Archive
|
||||
====================
|
||||
*/
|
||||
void ScriptClass::Archive(Archiver& arc)
|
||||
{
|
||||
}
|
||||
void ScriptClass::Archive(Archiver& arc) {}
|
||||
|
||||
/*
|
||||
====================
|
||||
|
@ -94,11 +90,11 @@ ArchiveInternal
|
|||
*/
|
||||
void ScriptClass::ArchiveInternal(Archiver& arc)
|
||||
{
|
||||
Listener::Archive(arc);
|
||||
Listener::Archive(arc);
|
||||
|
||||
arc.ArchiveObjectPosition(this);
|
||||
arc.ArchiveSafePointer(&m_Self);
|
||||
GameScript::Archive(arc, m_Script);
|
||||
arc.ArchiveObjectPosition(this);
|
||||
arc.ArchiveSafePointer(&m_Self);
|
||||
GameScript::Archive(arc, m_Script);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -106,43 +102,41 @@ void ScriptClass::ArchiveInternal(Archiver& arc)
|
|||
ArchiveScript
|
||||
====================
|
||||
*/
|
||||
void ScriptClass::ArchiveScript(Archiver& arc, ScriptClass** obj)
|
||||
void ScriptClass::ArchiveScript(Archiver& arc, ScriptClass **obj)
|
||||
{
|
||||
ScriptClass* scr;
|
||||
ScriptVM* m_current;
|
||||
ScriptThread* m_thread;
|
||||
int num;
|
||||
int i;
|
||||
ScriptClass *scr;
|
||||
ScriptVM *m_current;
|
||||
ScriptThread *m_thread;
|
||||
int num;
|
||||
int i;
|
||||
|
||||
if (arc.Saving())
|
||||
{
|
||||
scr = *obj;
|
||||
scr->ArchiveInternal(arc);
|
||||
if (arc.Saving()) {
|
||||
scr = *obj;
|
||||
scr->ArchiveInternal(arc);
|
||||
|
||||
num = 0;
|
||||
for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next)
|
||||
num++;
|
||||
num = 0;
|
||||
for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next) {
|
||||
num++;
|
||||
}
|
||||
|
||||
arc.ArchiveInteger(&num);
|
||||
arc.ArchiveInteger(&num);
|
||||
|
||||
for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next)
|
||||
m_current->m_Thread->ArchiveInternal(arc);
|
||||
}
|
||||
else
|
||||
{
|
||||
scr = new ScriptClass();
|
||||
scr->ArchiveInternal(arc);
|
||||
for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next) {
|
||||
m_current->m_Thread->ArchiveInternal(arc);
|
||||
}
|
||||
} else {
|
||||
scr = new ScriptClass();
|
||||
scr->ArchiveInternal(arc);
|
||||
|
||||
arc.ArchiveInteger(&num);
|
||||
arc.ArchiveInteger(&num);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
m_thread = new ScriptThread(scr, NULL);
|
||||
m_thread->ArchiveInternal(arc);
|
||||
}
|
||||
for (i = 0; i < num; i++) {
|
||||
m_thread = new ScriptThread(scr, NULL);
|
||||
m_thread->ArchiveInternal(arc);
|
||||
}
|
||||
|
||||
*obj = scr;
|
||||
}
|
||||
*obj = scr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -150,9 +144,9 @@ void ScriptClass::ArchiveScript(Archiver& arc, ScriptClass** obj)
|
|||
ArchiveCodePos
|
||||
====================
|
||||
*/
|
||||
void ScriptClass::ArchiveCodePos(Archiver& arc, unsigned char** codePos)
|
||||
void ScriptClass::ArchiveCodePos(Archiver& arc, unsigned char **codePos)
|
||||
{
|
||||
m_Script->ArchiveCodePos(arc, codePos);
|
||||
m_Script->ArchiveCodePos(arc, codePos);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -160,42 +154,40 @@ void ScriptClass::ArchiveCodePos(Archiver& arc, unsigned char** codePos)
|
|||
CreateThreadInternal
|
||||
====================
|
||||
*/
|
||||
ScriptThread* ScriptClass::CreateThreadInternal(const ScriptVariable& label)
|
||||
ScriptThread *ScriptClass::CreateThreadInternal(const ScriptVariable& label)
|
||||
{
|
||||
GameScript* scr;
|
||||
ScriptThread* thread = NULL;
|
||||
GameScript *scr;
|
||||
ScriptThread *thread = NULL;
|
||||
|
||||
if (label.GetType() == VARIABLE_STRING || label.GetType() == VARIABLE_CONSTSTRING)
|
||||
{
|
||||
ScriptClass* scriptClass = Director.CurrentScriptClass();
|
||||
scr = scriptClass->GetScript();
|
||||
if (label.GetType() == VARIABLE_STRING || label.GetType() == VARIABLE_CONSTSTRING) {
|
||||
ScriptClass *scriptClass = Director.CurrentScriptClass();
|
||||
scr = scriptClass->GetScript();
|
||||
|
||||
if (label.GetType() == VARIABLE_CONSTSTRING)
|
||||
thread = Director.CreateScriptThread(scr, m_Self, label.constStringValue());
|
||||
else
|
||||
thread = Director.CreateScriptThread(scr, m_Self, label.stringValue());
|
||||
}
|
||||
else if (label.GetType() == VARIABLE_CONSTARRAY && label.arraysize() > 1)
|
||||
{
|
||||
ScriptVariable* script = label[1];
|
||||
ScriptVariable* labelname = label[2];
|
||||
if (label.GetType() == VARIABLE_CONSTSTRING) {
|
||||
thread = Director.CreateScriptThread(scr, m_Self, label.constStringValue());
|
||||
} else {
|
||||
thread = Director.CreateScriptThread(scr, m_Self, label.stringValue());
|
||||
}
|
||||
} else if (label.GetType() == VARIABLE_CONSTARRAY && label.arraysize() > 1) {
|
||||
ScriptVariable *script = label[1];
|
||||
ScriptVariable *labelname = label[2];
|
||||
|
||||
if (script->GetType() == VARIABLE_CONSTSTRING)
|
||||
scr = Director.GetGameScript(script->constStringValue());
|
||||
else
|
||||
scr = Director.GetGameScript(script->stringValue());
|
||||
if (script->GetType() == VARIABLE_CONSTSTRING) {
|
||||
scr = Director.GetGameScript(script->constStringValue());
|
||||
} else {
|
||||
scr = Director.GetGameScript(script->stringValue());
|
||||
}
|
||||
|
||||
if (labelname->GetType() == VARIABLE_CONSTSTRING)
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->constStringValue());
|
||||
else
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->stringValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptError("ScriptClass::CreateThreadInternal: bad argument format");
|
||||
}
|
||||
if (labelname->GetType() == VARIABLE_CONSTSTRING) {
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->constStringValue());
|
||||
} else {
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->stringValue());
|
||||
}
|
||||
} else {
|
||||
ScriptError("ScriptClass::CreateThreadInternal: bad argument format");
|
||||
}
|
||||
|
||||
return thread;
|
||||
return thread;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -203,39 +195,37 @@ ScriptThread* ScriptClass::CreateThreadInternal(const ScriptVariable& label)
|
|||
CreateScriptInternal
|
||||
====================
|
||||
*/
|
||||
ScriptThread* ScriptClass::CreateScriptInternal(const ScriptVariable& label)
|
||||
ScriptThread *ScriptClass::CreateScriptInternal(const ScriptVariable& label)
|
||||
{
|
||||
GameScript* scr;
|
||||
ScriptThread* thread = NULL;
|
||||
GameScript *scr;
|
||||
ScriptThread *thread = NULL;
|
||||
|
||||
if (label.GetType() == VARIABLE_STRING || label.GetType() == VARIABLE_CONSTSTRING)
|
||||
{
|
||||
if (label.GetType() == VARIABLE_CONSTSTRING)
|
||||
thread = Director.CreateScriptThread(Director.GetGameScript(label.stringValue()), m_Self, "");
|
||||
else
|
||||
thread = Director.CreateScriptThread(Director.GetGameScript(label.constStringValue()), m_Self, "");
|
||||
}
|
||||
else if (label.GetType() == VARIABLE_CONSTARRAY && label.arraysize() > 1)
|
||||
{
|
||||
ScriptVariable* script = label[1];
|
||||
ScriptVariable* labelname = label[2];
|
||||
if (label.GetType() == VARIABLE_STRING || label.GetType() == VARIABLE_CONSTSTRING) {
|
||||
if (label.GetType() == VARIABLE_CONSTSTRING) {
|
||||
thread = Director.CreateScriptThread(Director.GetGameScript(label.stringValue()), m_Self, "");
|
||||
} else {
|
||||
thread = Director.CreateScriptThread(Director.GetGameScript(label.constStringValue()), m_Self, "");
|
||||
}
|
||||
} else if (label.GetType() == VARIABLE_CONSTARRAY && label.arraysize() > 1) {
|
||||
ScriptVariable *script = label[1];
|
||||
ScriptVariable *labelname = label[2];
|
||||
|
||||
if (script->GetType() == VARIABLE_CONSTSTRING)
|
||||
scr = Director.GetGameScript(script->constStringValue());
|
||||
else
|
||||
scr = Director.GetGameScript(script->stringValue());
|
||||
if (script->GetType() == VARIABLE_CONSTSTRING) {
|
||||
scr = Director.GetGameScript(script->constStringValue());
|
||||
} else {
|
||||
scr = Director.GetGameScript(script->stringValue());
|
||||
}
|
||||
|
||||
if (labelname->GetType() == VARIABLE_CONSTSTRING)
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->constStringValue());
|
||||
else
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->stringValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptError("ScriptClass::CreateScriptInternal: bad label type '%s'", label.GetTypeName());
|
||||
}
|
||||
if (labelname->GetType() == VARIABLE_CONSTSTRING) {
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->constStringValue());
|
||||
} else {
|
||||
thread = Director.CreateScriptThread(scr, m_Self, labelname->stringValue());
|
||||
}
|
||||
} else {
|
||||
ScriptError("ScriptClass::CreateScriptInternal: bad label type '%s'", label.GetTypeName());
|
||||
}
|
||||
|
||||
return thread;
|
||||
return thread;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -243,10 +233,10 @@ ScriptThread* ScriptClass::CreateScriptInternal(const ScriptVariable& label)
|
|||
AddThread
|
||||
====================
|
||||
*/
|
||||
void ScriptClass::AddThread(ScriptVM* m_ScriptVM)
|
||||
void ScriptClass::AddThread(ScriptVM *m_ScriptVM)
|
||||
{
|
||||
m_ScriptVM->next = m_Threads;
|
||||
m_Threads = m_ScriptVM;
|
||||
m_ScriptVM->next = m_Threads;
|
||||
m_Threads = m_ScriptVM;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -256,25 +246,24 @@ KillThreads
|
|||
*/
|
||||
void ScriptClass::KillThreads()
|
||||
{
|
||||
if (!m_Threads) {
|
||||
return;
|
||||
}
|
||||
if (!m_Threads) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScriptVM* m_current;
|
||||
ScriptVM* m_next;
|
||||
ScriptVM *m_current;
|
||||
ScriptVM *m_next;
|
||||
|
||||
m_current = m_Threads;
|
||||
m_current = m_Threads;
|
||||
|
||||
do
|
||||
{
|
||||
m_current->m_ScriptClass = NULL;
|
||||
do {
|
||||
m_current->m_ScriptClass = NULL;
|
||||
|
||||
m_next = m_current->next;
|
||||
delete m_current->m_Thread;
|
||||
m_next = m_current->next;
|
||||
delete m_current->m_Thread;
|
||||
|
||||
} while ((m_current = m_next) != nullptr);
|
||||
} while ((m_current = m_next) != nullptr);
|
||||
|
||||
m_Threads = NULL;
|
||||
m_Threads = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -282,27 +271,24 @@ void ScriptClass::KillThreads()
|
|||
RemoveThread
|
||||
====================
|
||||
*/
|
||||
void ScriptClass::RemoveThread(ScriptVM* m_ScriptVM)
|
||||
void ScriptClass::RemoveThread(ScriptVM *m_ScriptVM)
|
||||
{
|
||||
if (m_Threads == m_ScriptVM)
|
||||
{
|
||||
m_Threads = m_ScriptVM->next;
|
||||
if (m_Threads == m_ScriptVM) {
|
||||
m_Threads = m_ScriptVM->next;
|
||||
|
||||
if (m_Threads == NULL) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptVM* m_current = m_Threads;
|
||||
ScriptVM* i;
|
||||
if (m_Threads == NULL) {
|
||||
delete this;
|
||||
}
|
||||
} else {
|
||||
ScriptVM *m_current = m_Threads;
|
||||
ScriptVM *i;
|
||||
|
||||
for (i = m_Threads->next; i != m_ScriptVM; i = i->next) {
|
||||
m_current = i;
|
||||
}
|
||||
for (i = m_Threads->next; i != m_ScriptVM; i = i->next) {
|
||||
m_current = i;
|
||||
}
|
||||
|
||||
m_current->next = i->next;
|
||||
}
|
||||
m_current->next = i->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -312,7 +298,7 @@ Filename
|
|||
*/
|
||||
str ScriptClass::Filename()
|
||||
{
|
||||
return m_Script->Filename();
|
||||
return m_Script->Filename();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -320,9 +306,9 @@ str ScriptClass::Filename()
|
|||
FindLabel
|
||||
====================
|
||||
*/
|
||||
unsigned char* ScriptClass::FindLabel(str label)
|
||||
unsigned char *ScriptClass::FindLabel(str label)
|
||||
{
|
||||
return m_Script->m_State.FindLabel(label);
|
||||
return m_Script->m_State.FindLabel(label);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -330,9 +316,9 @@ unsigned char* ScriptClass::FindLabel(str label)
|
|||
FindLabel
|
||||
====================
|
||||
*/
|
||||
unsigned char* ScriptClass::FindLabel(const_str label)
|
||||
unsigned char *ScriptClass::FindLabel(const_str label)
|
||||
{
|
||||
return m_Script->m_State.FindLabel(label);
|
||||
return m_Script->m_State.FindLabel(label);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -340,9 +326,9 @@ unsigned char* ScriptClass::FindLabel(const_str label)
|
|||
NearestLabel
|
||||
====================
|
||||
*/
|
||||
const_str ScriptClass::NearestLabel(unsigned char* pos)
|
||||
const_str ScriptClass::NearestLabel(unsigned char *pos)
|
||||
{
|
||||
return m_Script->m_State.NearestLabel(pos);
|
||||
return m_Script->m_State.NearestLabel(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -350,9 +336,9 @@ const_str ScriptClass::NearestLabel(unsigned char* pos)
|
|||
GetCatchStateScript
|
||||
====================
|
||||
*/
|
||||
StateScript* ScriptClass::GetCatchStateScript(unsigned char* in, unsigned char*& out)
|
||||
StateScript *ScriptClass::GetCatchStateScript(unsigned char *in, unsigned char *& out)
|
||||
{
|
||||
return m_Script->GetCatchStateScript(in, out);
|
||||
return m_Script->GetCatchStateScript(in, out);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -360,9 +346,9 @@ StateScript* ScriptClass::GetCatchStateScript(unsigned char* in, unsigned char*&
|
|||
GetScript
|
||||
====================
|
||||
*/
|
||||
GameScript* ScriptClass::GetScript()
|
||||
GameScript *ScriptClass::GetScript()
|
||||
{
|
||||
return m_Script;
|
||||
return m_Script;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -370,7 +356,7 @@ GameScript* ScriptClass::GetScript()
|
|||
GetSelf
|
||||
====================
|
||||
*/
|
||||
Listener* ScriptClass::GetSelf()
|
||||
Listener *ScriptClass::GetSelf()
|
||||
{
|
||||
return static_cast<Listener*>(m_Self.Pointer());
|
||||
return static_cast<Listener *>(m_Self.Pointer());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue