aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/DLC/DLCGameRulesHeader.cpp
blob: 39b8521907617c3edf345164acd9caf8c13304f1 (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
#include "stdafx.h"

#include <string>

#include "..\..\..\Minecraft.World\File.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\InputOutputStream.h"

#include "DLCManager.h"
#include "DLCGameRulesHeader.h"

DLCGameRulesHeader::DLCGameRulesHeader(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader,path)
{	
	m_pbData = NULL;
	m_dwBytes = 0;

	m_hasData = false;

	m_grfPath = path.substr(0, path.length() - 4) + L".grf";

	lgo = NULL;
}

void DLCGameRulesHeader::addData(PBYTE pbData, DWORD dwBytes)
{
	m_pbData = pbData;
	m_dwBytes = dwBytes;


#if 0
	byteArray data(m_pbData, m_dwBytes);
	ByteArrayInputStream bais(data);
	DataInputStream dis(&bais);

	// Init values.
	int version_number;
	byte compression_type;
	wstring texturepackid;

	// Read Datastream.
	version_number = dis.readInt();
	compression_type = dis.readByte();
	m_defaultSaveName = dis.readUTF();
	m_displayName = dis.readUTF();
	texturepackid = dis.readUTF();
	m_grfPath = dis.readUTF();

	// Debug printout.
	app.DebugPrintf	(
						"DLCGameRulesHeader::readHeader:\n"
						"\tversion_number = '%d',\n"
						"\tcompression_type = '%d',\n"
						"\tdefault_savename = '%s',\n"
						"\tdisplayname = '%s',\n"
						"\ttexturepackid = '%s',\n"
						"\tgrf_path = '%s',\n",

						version_number, compression_type,

						wstringtofilename(m_defaultSaveName),
						wstringtofilename(m_displayName),
						wstringtofilename(texturepackid),
						wstringtofilename(m_grfPath)
					);

	// Texture Pack.
	m_requiredTexturePackId = _fromString<long>(texturepackid);
	m_bRequiresTexturePack = m_requiredTexturePackId > 0;

	dis.close();
	bais.close();
	bais.reset();
#endif
}

PBYTE DLCGameRulesHeader::getData(DWORD &dwBytes)
{
	dwBytes = m_dwBytes;
	return m_pbData;
}

void DLCGameRulesHeader::setGrfData(PBYTE fData, DWORD fSize, StringTable *st)
{
	if (!m_hasData)
	{
		m_hasData = true;
	
		//app.m_gameRules.loadGameRules(lgo, fData, fSize);

		app.m_gameRules.readRuleFile(lgo, fData, fSize, st);
	}
}