summaryrefslogtreecommitdiff
path: root/src/T2DLL/CPluginInfo.cpp
blob: e836e42b5659f021f48160be6dca4d5b109c568c (plain)
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
#include "CPluginInfo.h"
#include "T2Archive.h"

/*static*/ CPluginInfo* CPluginInfo::ReadPluginInfo(T2Archive& archive) {
	CPluginInfo *info = new CPluginInfo;
	info->Read(archive);
	return info;
}

CPluginInfo::CPluginInfo() {
	mType = 0;
	mID = 0;
	mItemType = 0;
	mMustItem = 0;
	mName = "";
	mFileName = "";
	mUsed = false;
}

CPluginInfo::CPluginInfo(DWORD type, DWORD id, int itemType, int mustItem, const char* name, const char* fileName) {
	mType = type;
	mID = id;
	mItemType = itemType;
	mMustItem = mustItem;
	mName = name;
	mFileName = fileName;
	mUsed = false;
}

/*virtual*/ CPluginInfo::~CPluginInfo() {
}

void CPluginInfo::GetName(CString& outStr) {
	outStr = mName;
}

void CPluginInfo::GetFileName(CString& outStr) {
	outStr = mFileName;
}

void CPluginInfo::Read(T2Archive& archive) {
	short s;
	unsigned char i, c;

	archive >> mType;
	archive >> mID;

	archive >> s;
	mItemType = s;
	archive >> s;
	mMustItem = s;

	archive >> c;
	for (i = 0; i < c; i++) {
		char ch;
		archive >> ch;
		mName += ch;
	}

	archive >> c;
	for (i = 0; i < c; i++) {
		char ch;
		archive >> ch;
		mFileName += ch;
	}

	char buf[1024];
	sprintf(buf, "PluginInfo %s, %s\n", mName, mFileName);
	TRACE(buf);

	archive >> c;
	mUsed = c != 0;
}

void CPluginInfo::Write(T2Archive& archive) {
	short s;
	unsigned char i, c;

	archive << mType;
	archive << mID;

	s = mItemType;
	archive << s;
	s = mMustItem;
	archive << s;

	c = mName.GetLength();
	archive << c;
	for (i = 0; i < c; i++)
		archive << mName.GetAt(i);

	c = mFileName.GetLength();
	archive << c;
	for (i = 0; i < c; i++)
		archive << mFileName.GetAt(i);

	c = mUsed != false;
	archive << c;
}