forked from NWNX/nwnx2-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NWNXBase.h
122 lines (102 loc) · 4.44 KB
/
NWNXBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/***************************************************************************
NWNXBase.h: interface for the CNWNXBase class.
Copyright (C) 2003 Ingmar Stieger (Papillon, [email protected]) and
Jeroen Broekhuizen ([email protected])
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
#ifndef NWNXBase_h_
#define NWNXBase_h_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "gline.h"
#include "newpluginapi.h"
#include "core/core.h"
#define OBJECT_INVALID 0x7F000000
class CNWNXBase
{
public:
CNWNXBase();
virtual ~CNWNXBase();
///////////////////////////////////////////////////////////////////////////
// Function: OnCreate
// Description
// This function is called just when an instance is created.
// Overloading is allowed, but the base class function must be called first.
// Parameters
// nwnxConfig : parsed nwnx2.ini, a gline instance
// LogFile : optionally a path and filename of the log file
virtual bool OnCreate(gline *nwnxConfig, const char* LogFile = NULL);
///////////////////////////////////////////////////////////////////////////
// Function: OnRequest (char* Request, char* Parameters)
// Description
// Called when a request is pending from a NWScript.
// This function must be overloaded by the module.
// Parameters
// Request : the job that must be performed
// Parameters : optional parameters
virtual char* OnRequest(char *gameObject, char* Request, char* Parameters) = 0;
///////////////////////////////////////////////////////////////////////////
// Function: OnRequestObject (char* Request)
// Description
// Called when a request is pending from a NWScript.
// This function must be overloaded by the module.
// Request : the job that must be performed
virtual unsigned long OnRequestObject(char *gameObject, char* Request);
///////////////////////////////////////////////////////////////////////////
// Function: OnRelease
// Description
// Called just before deletion of an instance of this class.
// Overloading is allowed, but the base class function must be called.
// Parameters
// None
virtual bool OnRelease();
///////////////////////////////////////////////////////////////////////////
// Function: Log (int debugPri, const char* pcMsg[, argument]...);
// Description:
// This function formats and writes a message to the log file. It works
// the same way as the standard C printf function.
// Example: Log ("Set array item %d with value %s.", iIndex, pcValue);
// Parameters:
// debugPri : message will only be sent to the log if this argument
// is >= the instance's debuglevel
// Msg : the format string
// [argument] : optional arguments
void Log(int debugPri, const char* Msg, ...);
// convenience, checks Msg and Param lengths
// returns 0 if Param not set 1 if set
int ParamLog(int debugPri, const char* Msg, char* Parameters);
///////////////////////////////////////////////////////////////////////////
// Function: SetDebugLevel (int level);
// Description:
// Helper function to alter the instance's debuglevel independent of
// the global level. Returns the old debuglevel.
// Parameters:
// level : the desired level
int SetDebugLevel(int level);
int GetDebugLevel();
///////////////////////////////////////////////////////////////////////////
// Function: BaseConf ();
// Description:
// This function parses the generic config options: "debuglevel", etc.
// Parameters:
// None
void BaseConf();
protected:
FILE* m_fFile;
gline* nwnxConfig;
const char * confKey;
int debuglevel;
private:
};
#endif