-
Notifications
You must be signed in to change notification settings - Fork 1
/
d_scripts.cpp
99 lines (82 loc) · 2.81 KB
/
d_scripts.cpp
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
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 2014 James Haley
//
// 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
//
//-----------------------------------------------------------------------------
//
// DESCRIPTION:
// Writing of script lumps.
//
//-----------------------------------------------------------------------------
#include "z_zone.h"
#include "i_system.h"
#include "m_misc.h"
#include "m_qstr.h"
#include "main.h"
#include "zip_write.h"
//
// D_addResourceScriptToZip
//
// Add a file from the resource directory as a script lump.
//
static void D_addResourceScriptToZip(ziparchive_t *zip, const char *filename)
{
qstring srcpath;
srcpath = filename;
D_MakeResourceFilePath(srcpath);
char *text;
if(!(text = M_LoadStringFromFile(srcpath.constPtr())))
I_Error("D_addResourceScript: unable to load resource %s\n", srcpath.constPtr());
Zip_AddFile(zip, filename, reinterpret_cast<byte *>(text),
static_cast<uint32_t>(strlen(text)), ZIP_FILE_TEXT, true);
}
//
// D_addBinaryFileToZip
//
// Add a binary file from the /res folder into the zip.
//
static void D_addBinaryFileToZip(ziparchive_t *zip, const char *filename,
const char *lumpname)
{
qstring srcpath;
srcpath = filename;
D_MakeResourceFilePath(srcpath);
Zip_AddFile(zip, lumpname, srcpath.constPtr(), false);
}
//
// D_ProcessScriptsForZip
//
// Add script lumps to the zip archive.
//
void D_ProcessScriptsForZip(ziparchive_t *zip)
{
printf("D_ProcessScripts: adding script files.\n");
// EDFROOT
D_addResourceScriptToZip(zip, "EDFROOT.edf");
// EMAPINFO, for Eternity LevelInfo
D_addResourceScriptToZip(zip, "EMAPINFO.txt");
// Level end texts
D_addResourceScriptToZip(zip, "UDOOMEND.txt");
D_addResourceScriptToZip(zip, "DOOM2END.txt");
// gameversion.txt, for Eternity gamemode determination
D_addResourceScriptToZip(zip, "gameversion.txt");
// add ANIMATED and SWITCHES lumps
D_addBinaryFileToZip(zip, "ANIMATED.LMP", "ANIMATED.lmp");
D_addBinaryFileToZip(zip, "SWITCHES.LMP", "SWITCHES.lmp");
}
// EOF