Moved script stuff to their matching directory

This commit is contained in:
L 2023-01-30 18:20:50 +01:00
parent 16d9a6f8b0
commit cf18c3a96f
21 changed files with 475 additions and 540 deletions

View file

@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "navigate.h"
#include "lodthing.h"
#include "player.h"
#include <compiler.h>
#include <scriptcompiler.h>
#include "playerbot.h"
#include "consoleevent.h"

View file

@ -24,9 +24,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "glb_local.h"
#include "gamescript.h"
#include "compiler.h"
#include "scriptcompiler.h"
#include "scriptmaster.h"
#include "scriptthread.h"
#include "scriptclass.h"
#include "level.h"
static unsigned char *current_progBuffer = NULL;

View file

@ -25,12 +25,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "glb_local.h"
#include "scriptmaster.h"
#include "scriptthread.h"
#include "scriptclass.h"
#include "gamescript.h"
#include "game.h"
#include "g_spawn.h"
#include "object.h"
#include <world.h>
#include <compiler.h>
#include "world.h"
#include "scriptcompiler.h"
#ifdef WIN32
#include <direct.h>

View file

@ -1,5 +1,6 @@
#include "scriptthread.h"
#include "scriptmaster.h"
#include "scriptclass.h"
#include "scriptvariable.h"
#include "level.h"

View file

@ -24,7 +24,7 @@
* yyParser.*: BISON Parser for MoHScript.
*/
#include "compiler.h"
#include "scriptcompiler.h"
#include "yyParser.h"
#include "yyLexer.h"

View file

@ -24,7 +24,7 @@
* yyLexer.*: FLEX Lexical grammar for MoHScript.
*/
#include "compiler.h"
#include "scriptcompiler.h"
#include "yyParser.h"
#include <stdio.h>

View file

@ -875,7 +875,7 @@ char *yytext;
* yyLexer.*: FLEX Lexical grammar for MoHScript.
*/
#include "compiler.h"
#include "scriptcompiler.h"
#include "yyParser.h"
#include <stdio.h>

View file

@ -90,7 +90,7 @@
* yyParser.*: BISON Parser for MoHScript.
*/
#include "compiler.h"
#include "scriptcompiler.h"
#include "yyParser.h"
#include "yyLexer.h"

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "archive.h"
#include "scriptmaster.h"
#include "scriptthread.h"
#include "scriptclass.h"
#endif
#if defined( GAME_DLL )

375
code/script/scriptclass.cpp Normal file
View file

@ -0,0 +1,375 @@
#include "scriptclass.h"
#include "scriptmaster.h"
#include "scriptthread.h"
//====================
// ScriptClass
//====================
MEM_BlockAlloc<ScriptClass> ScriptClass_allocator;
CLASS_DECLARATION(Listener, ScriptClass, NULL)
{
{ NULL, NULL }
};
/*
====================
new ScriptClass
====================
*/
void* ScriptClass::operator new(size_t size)
{
return ScriptClass_allocator.Alloc();
}
/*
====================
delete ptr
====================
*/
void ScriptClass::operator delete(void* ptr)
{
ScriptClass_allocator.Free(ptr);
}
/*
====================
ScriptClass
====================
*/
ScriptClass::ScriptClass(GameScript* gameScript, Listener* self)
{
m_Self = self;
m_Script = gameScript;
m_Threads = NULL;
}
/*
====================
ScriptClass
====================
*/
ScriptClass::ScriptClass()
{
m_Self = NULL;
m_Script = NULL;
m_Threads = NULL;
}
/*
====================
~ScriptClass
====================
*/
ScriptClass::~ScriptClass()
{
if (m_Script == NULL) {
throw ScriptException("Attempting to delete dead class.");
}
KillThreads();
if (!m_Script->m_Filename)
{
// This is a temporary gamescript
delete m_Script;
}
}
/*
====================
Archive
====================
*/
void ScriptClass::Archive(Archiver& arc)
{
}
/*
====================
ArchiveInternal
====================
*/
void ScriptClass::ArchiveInternal(Archiver& arc)
{
Listener::Archive(arc);
arc.ArchiveObjectPosition(this);
arc.ArchiveSafePointer(&m_Self);
GameScript::Archive(arc, m_Script);
}
/*
====================
ArchiveScript
====================
*/
void ScriptClass::ArchiveScript(Archiver& arc, ScriptClass** obj)
{
ScriptClass* scr;
ScriptVM* m_current;
ScriptThread* m_thread;
int num;
int i;
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++;
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);
arc.ArchiveInteger(&num);
for (i = 0; i < num; i++)
{
m_thread = new ScriptThread(scr, NULL);
m_thread->ArchiveInternal(arc);
}
*obj = scr;
}
}
/*
====================
ArchiveCodePos
====================
*/
void ScriptClass::ArchiveCodePos(Archiver& arc, unsigned char** codePos)
{
m_Script->ArchiveCodePos(arc, codePos);
}
/*
====================
CreateThreadInternal
====================
*/
ScriptThread* ScriptClass::CreateThreadInternal(const ScriptVariable& label)
{
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_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 (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;
}
/*
====================
CreateScriptInternal
====================
*/
ScriptThread* ScriptClass::CreateScriptInternal(const ScriptVariable& label)
{
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 (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());
}
return thread;
}
/*
====================
AddThread
====================
*/
void ScriptClass::AddThread(ScriptVM* m_ScriptVM)
{
m_ScriptVM->next = m_Threads;
m_Threads = m_ScriptVM;
}
/*
====================
KillThreads
====================
*/
void ScriptClass::KillThreads()
{
if (!m_Threads) {
return;
}
ScriptVM* m_current;
ScriptVM* m_next;
m_current = m_Threads;
do
{
m_current->m_ScriptClass = NULL;
m_next = m_current->next;
delete m_current->m_Thread;
} while (m_current = m_next);
m_Threads = NULL;
}
/*
====================
RemoveThread
====================
*/
void ScriptClass::RemoveThread(ScriptVM* m_ScriptVM)
{
if (m_Threads == m_ScriptVM)
{
m_Threads = m_ScriptVM->next;
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;
}
m_current->next = i->next;
}
}
/*
====================
Filename
====================
*/
str ScriptClass::Filename()
{
return m_Script->Filename();
}
/*
====================
FindLabel
====================
*/
unsigned char* ScriptClass::FindLabel(str label)
{
return m_Script->m_State.FindLabel(label);
}
/*
====================
FindLabel
====================
*/
unsigned char* ScriptClass::FindLabel(const_str label)
{
return m_Script->m_State.FindLabel(label);
}
/*
====================
NearestLabel
====================
*/
const_str ScriptClass::NearestLabel(unsigned char* pos)
{
return m_Script->m_State.NearestLabel(pos);
}
/*
====================
GetCatchStateScript
====================
*/
StateScript* ScriptClass::GetCatchStateScript(unsigned char* in, unsigned char*& out)
{
return m_Script->GetCatchStateScript(in, out);
}
/*
====================
GetScript
====================
*/
GameScript* ScriptClass::GetScript()
{
return m_Script;
}
/*
====================
GetSelf
====================
*/
Listener* ScriptClass::GetSelf()
{
return static_cast<Listener*>(m_Self.Pointer());
}

80
code/script/scriptclass.h Normal file
View file

@ -0,0 +1,80 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// scriptclass.h: Script class.
#pragma once
#include "listener.h"
class Archiver;
class ScriptVM;
class ScriptClass : public Listener
{
friend class GameScript;
friend class StateScript;
public:
// script variable
GameScript* m_Script; // current game script
// listener variable
SafePtr<Listener> m_Self; // self
// thread variable
ScriptVM* m_Threads; // threads list
public:
CLASS_PROTOTYPE(ScriptClass);
#ifndef _DEBUG_MEM
void* operator new(size_t size);
void operator delete(void* ptr);
#endif
ScriptClass(GameScript* gameScript, Listener* self);
ScriptClass();
virtual ~ScriptClass();
virtual void Archive(Archiver& arc);
void ArchiveInternal(Archiver& arc);
static void ArchiveScript(Archiver& arc, ScriptClass** obj);
void ArchiveCodePos(Archiver& arc, unsigned char** codePos);
virtual ScriptThread* CreateThreadInternal(const ScriptVariable& label);
virtual ScriptThread* CreateScriptInternal(const ScriptVariable& label);
void AddThread(ScriptVM* m_ScriptVM);
void KillThreads(void);
void RemoveThread(ScriptVM* m_ScriptVM);
str Filename();
unsigned char* FindLabel(str label);
unsigned char* FindLabel(const_str label);
const_str NearestLabel(unsigned char* pos);
StateScript* GetCatchStateScript(unsigned char* in, unsigned char*& out);
GameScript* GetScript();
Listener* GetSelf();
};

View file

@ -23,15 +23,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// compiler.cpp : Parse, then compile to op-codes.
#include "glb_local.h"
#include "compiler.h"
#include "scriptcompiler.h"
#include "scriptvm.h"
#include "level.h"
#include "parm.h"
#include "scriptmaster.h"
#include "scriptthread.h"
#include "parser/parsetree.h"
#include "parser/yyParser.h"
#include "parser/yyLexer.h"
#include "scriptclass.h"
#include "parsetree.h"
#include "yyParser.h"
#include "yyLexer.h"
ScriptCompiler Compiler;
int ScriptCompiler::current_label;

View file

@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "glb_local.h"
#include <scriptopcodes.h>
#include <gamescript.h>
#include <parser/parsetree.h>
#include "parsetree.h"
enum
{

View file

@ -25,8 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "glb_local.h"
#include "scriptmaster.h"
#include "scriptthread.h"
#include "scriptclass.h"
#include "scriptvm.h"
#include "compiler.h"
#include "scriptcompiler.h"
#include "game.h"
#include "level.h"
#include "parm.h"
@ -49,378 +50,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
//====================
// ScriptClass
//====================
MEM_BlockAlloc<ScriptClass> ScriptClass_allocator;
CLASS_DECLARATION(Listener, ScriptClass, NULL)
{
{ NULL, NULL }
};
/*
====================
new ScriptClass
====================
*/
void* ScriptClass::operator new(size_t size)
{
return ScriptClass_allocator.Alloc();
}
/*
====================
delete ptr
====================
*/
void ScriptClass::operator delete(void* ptr)
{
ScriptClass_allocator.Free(ptr);
}
/*
====================
ScriptClass
====================
*/
ScriptClass::ScriptClass(GameScript* gameScript, Listener* self)
{
m_Self = self;
m_Script = gameScript;
m_Threads = NULL;
}
/*
====================
ScriptClass
====================
*/
ScriptClass::ScriptClass()
{
m_Self = NULL;
m_Script = NULL;
m_Threads = NULL;
}
/*
====================
~ScriptClass
====================
*/
ScriptClass::~ScriptClass()
{
if (m_Script == NULL) {
throw ScriptException("Attempting to delete dead class.");
}
KillThreads();
if (!m_Script->m_Filename)
{
// This is a temporary gamescript
delete m_Script;
}
}
/*
====================
Archive
====================
*/
void ScriptClass::Archive(Archiver& arc)
{
}
/*
====================
ArchiveInternal
====================
*/
void ScriptClass::ArchiveInternal(Archiver& arc)
{
Listener::Archive(arc);
arc.ArchiveObjectPosition(this);
arc.ArchiveSafePointer(&m_Self);
GameScript::Archive(arc, m_Script);
}
/*
====================
ArchiveScript
====================
*/
void ScriptClass::ArchiveScript(Archiver& arc, ScriptClass** obj)
{
ScriptClass* scr;
ScriptVM* m_current;
ScriptThread* m_thread;
int num;
int i;
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++;
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);
arc.ArchiveInteger(&num);
for (i = 0; i < num; i++)
{
m_thread = new ScriptThread(scr, NULL);
m_thread->ArchiveInternal(arc);
}
*obj = scr;
}
}
/*
====================
ArchiveCodePos
====================
*/
void ScriptClass::ArchiveCodePos(Archiver& arc, unsigned char** codePos)
{
m_Script->ArchiveCodePos(arc, codePos);
}
/*
====================
CreateThreadInternal
====================
*/
ScriptThread* ScriptClass::CreateThreadInternal(const ScriptVariable& label)
{
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_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 (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;
}
/*
====================
CreateScriptInternal
====================
*/
ScriptThread* ScriptClass::CreateScriptInternal(const ScriptVariable& label)
{
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 (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());
}
return thread;
}
/*
====================
AddThread
====================
*/
void ScriptClass::AddThread(ScriptVM* m_ScriptVM)
{
m_ScriptVM->next = m_Threads;
m_Threads = m_ScriptVM;
}
/*
====================
KillThreads
====================
*/
void ScriptClass::KillThreads()
{
if (!m_Threads) {
return;
}
ScriptVM* m_current;
ScriptVM* m_next;
m_current = m_Threads;
do
{
m_current->m_ScriptClass = NULL;
m_next = m_current->next;
delete m_current->m_Thread;
} while (m_current = m_next);
m_Threads = NULL;
}
/*
====================
RemoveThread
====================
*/
void ScriptClass::RemoveThread(ScriptVM* m_ScriptVM)
{
if (m_Threads == m_ScriptVM)
{
m_Threads = m_ScriptVM->next;
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;
}
m_current->next = i->next;
}
}
/*
====================
Filename
====================
*/
str ScriptClass::Filename()
{
return m_Script->Filename();
}
/*
====================
FindLabel
====================
*/
unsigned char* ScriptClass::FindLabel(str label)
{
return m_Script->m_State.FindLabel(label);
}
/*
====================
FindLabel
====================
*/
unsigned char* ScriptClass::FindLabel(const_str label)
{
return m_Script->m_State.FindLabel(label);
}
/*
====================
NearestLabel
====================
*/
const_str ScriptClass::NearestLabel(unsigned char* pos)
{
return m_Script->m_State.NearestLabel(pos);
}
/*
====================
GetCatchStateScript
====================
*/
StateScript* ScriptClass::GetCatchStateScript(unsigned char* in, unsigned char*& out)
{
return m_Script->GetCatchStateScript(in, out);
}
/*
====================
GetScript
====================
*/
GameScript* ScriptClass::GetScript()
{
return m_Script;
}
/*
====================
GetSelf
====================
*/
Listener* ScriptClass::GetSelf()
{
return static_cast<Listener*>(m_Self.Pointer());
}
//====================
// ScriptVM
//====================

View file

@ -47,163 +47,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define THREAD_SUSPENDED 2 // Suspended
#define THREAD_CONTEXT_SWITCH 3 // Resume from context switch
// Ley0k: That's the old OpenMOHAA script stuff
// not needed anymore
//
/****************************************************************************************************************************************************************
// IneQuation: MoHAA server-side scripting
// TODO: work on it, it's a stub
// variables
typedef enum {
SVT_INTEGER,
SVT_FLOAT,
SVT_VECTOR,
SVT_STRING,
SVT_ENTITY,
SVT_LISTENER, // for compatibility with the bare Listener MoHAA object which is basically just a data container
SVT_ARRAY
} scriptVariableType_t;
typedef union {
int i;
float f;
char *s;
gentity_t *e;
struct scriptStack_s *l; // for compatibility with the bare Listener MoHAA object which is basically just a data container
struct scriptArray_s *a;
} scriptVariableData_t;
typedef struct scriptArrayElement_s {
scriptVariableData_t data;
struct scriptArrayElement_s *next;
struct scriptArrayElement_s *prev;
} scriptArrayElement_t;
typedef struct scriptArray_s {
int size;
scriptArrayElement_t *first;
} scriptArray_t;
typedef struct scriptVariable_s {
qboolean readonly;
scriptVariableType_t type;
scriptVariableData_t data;
} scriptVariable_t;
// script stack
typedef struct scriptStackVariable_s {
scriptVariable_t var;
struct scriptStackVariable_s *prev;
struct scriptStackVariable_s *next;
} scriptStackVariable_t;
typedef struct scriptStack_s {
int size;
scriptVariable_t *top;
} scriptStack_t;
// compiled script
typedef enum { // what code gets translated into the given instruction
SI_STARTTHREAD, // thread, waitthread, exec, waitexec
SI_TERMINATETHREAD, // end
SI_WAIT, // wait, waitframe
SI_JUMP, // goto, break and continue
SI_CONDITIONALJUMP, // if, for, while, switch
SI_INCR, // ++
SI_DECR, // --
SI_ASSIGN,
SI_EVENT // TODO: this possibly needs expanding into a separate instruction for each event (entity command), need to think the design through
} scriptInstruction_t;
typedef struct scriptStatement_s {
scriptInstruction_t inst;
int numParams;
scriptVariableData_t *params; // malloced at script compilation time
} scriptStatement_t;
typedef struct scriptCompiled_s {
scriptStack_t level;
scriptStack_t parm;
int numStats;
scriptStatement_t *stat;
} scriptCompiled_t;
// script threads
typedef struct scriptThread_s {
scriptVariableData_t object;
scriptStack_t stack;
int pos; // index of the statement we should be executing at this frame
int resumeTime; // execution of thread will stop until level.time >= resumeTime
struct scriptThread_s *next;
struct scriptThread_s *prev;
} scriptThread_t;
typedef struct scriptThreadGroup_s {
scriptStack_t group;
int count;
scriptThread_t *first;
} scriptThreadGroup_t;
****************************************************************************************************************************************************************/
//
//
// End of the old OpenMOHAA script stuff
class ScriptThread;
class ScriptVM;
class ScriptClass : public Listener
{
friend class GameScript;
friend class StateScript;
public:
// script variable
GameScript *m_Script; // current game script
// listener variable
SafePtr<Listener> m_Self; // self
// thread variable
ScriptVM *m_Threads; // threads list
public:
CLASS_PROTOTYPE( ScriptClass );
#ifndef _DEBUG_MEM
void *operator new( size_t size );
void operator delete( void *ptr );
#endif
ScriptClass( GameScript *gameScript, Listener *self );
ScriptClass();
virtual ~ScriptClass();
virtual void Archive( Archiver& arc );
void ArchiveInternal( Archiver& arc );
static void ArchiveScript( Archiver& arc, ScriptClass **obj );
void ArchiveCodePos( Archiver& arc, unsigned char **codePos );
virtual ScriptThread *CreateThreadInternal( const ScriptVariable& label );
virtual ScriptThread *CreateScriptInternal( const ScriptVariable& label );
void AddThread( ScriptVM * m_ScriptVM );
void KillThreads( void );
void RemoveThread( ScriptVM * m_ScriptVM );
str Filename();
unsigned char *FindLabel( str label );
unsigned char *FindLabel( const_str label );
const_str NearestLabel( unsigned char *pos );
StateScript *GetCatchStateScript( unsigned char *in, unsigned char *&out );
GameScript *GetScript();
Listener *GetSelf();
};
class ScriptCallStack {
public:
// opcode variable