OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
scriptclass.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// scriptclass.h: Script class.
24
25#pragma once
26
27#include "listener.h"
28
29class Archiver;
30class ScriptVM;
31class GameScript;
32class StateScript;
33
34class ScriptClass : public Listener
35{
36 friend GameScript;
37 friend StateScript;
38
39public:
40 // script variable
41 GameScript *m_Script; // current game script
42
43 // listener variable
44 SafePtr<Listener> m_Self; // self
45
46 // thread variable
47 ScriptVM *m_Threads; // threads list
48
49public:
50 CLASS_PROTOTYPE(ScriptClass);
51
52 void *operator new(size_t size);
53 void operator delete(void *ptr);
54
55 ScriptClass(GameScript *gameScript, Listener *self);
56 ScriptClass();
57 ~ScriptClass();
58
59 void StoppedNotify() override;
60 void Archive(Archiver &arc) override;
61 void ArchiveInternal(Archiver &arc);
62 static void ArchiveScript(Archiver& arc, ScriptClass **obj);
63 void ArchiveCodePos(Archiver &arc, unsigned char **codePos);
64
65 ScriptThread *CreateThreadInternal(const ScriptVariable& label) override;
66 ScriptThread *CreateScriptInternal(const ScriptVariable& label) override;
67
68 void AddThread(ScriptVM *thread);
69 void KillThreads(void);
70 void RemoveThread(ScriptVM *thread);
71
72 str Filename();
73 unsigned char *FindLabel(str label);
74 unsigned char *FindLabel(const_str label);
75 const_str NearestLabel(unsigned char *pos);
76
77 StateScript *GetCatchStateScript(unsigned char *in, unsigned char *& out);
78
79 GameScript *GetScript();
80 Listener *GetSelf();
81};
Definition archive.h:86
Definition gamescript.h:118
Definition safeptr.h:160
Definition scriptthread.h:28
Definition scriptvm.h:135
Definition scriptvariable.h:75
Definition gamescript.h:83
Definition str.h:77