26 static void ReadLcf(std::vector<RPG::EventCommand>& ref,
LcfReader& stream, uint32_t length);
27 static void WriteLcf(
const std::vector<RPG::EventCommand>& ref,
LcfWriter& stream);
28 static int LcfSize(
const std::vector<RPG::EventCommand>& ref,
LcfWriter& stream);
29 static void WriteXml(
const std::vector<RPG::EventCommand>& ref,
XmlWriter& stream);
38 if (event_command.
code != 0) {
45 for (
int i = stream.
ReadInt(); i > 0; i--) {
46 param_buf.push_back(stream.
ReadInt());
48 if (!param_buf.empty()) {
49 event_command.
parameters.reserve(param_buf.size());
50 event_command.
parameters.assign(param_buf.begin(), param_buf.end());
60 int32_t count = (int32_t)event_command.
parameters.size();
62 for (
int i = 0; i < count; i++)
74 for (
int i = 0; i < count; i++)
101 if (strcmp(name,
"code") == 0)
103 else if (strcmp(name,
"indent") == 0)
105 else if (strcmp(name,
"string") == 0)
107 else if (strcmp(name,
"parameters") == 0)
110 stream.
Error(
"Unrecognized field '%s'", name);
145 std::vector<RPG::EventCommand>& event_commands,
LcfReader& stream, uint32_t length) {
148 unsigned long startpos = stream.
Tell();
149 unsigned long endpos = startpos + length;
155 uint8_t ch = (uint8_t)stream.
Peek();
161 if (stream.
Tell() >= endpos) {
163 fprintf(stderr,
"Event command corrupted at %" PRIu32
"\n", stream.
Tell());
175 if (i == 4 || stream.
Eof()) {
185 event_commands.push_back(command);
190 int count = event_commands.size();
191 for (
int i = 0; i < count; i++)
193 for (
int i = 0; i < 4; i++)
199 int count = event_commands.size();
200 for (
int i = 0; i < count; i++)
207 std::vector<RPG::EventCommand>::const_iterator it;
208 for (it = event_commands.begin(); it != event_commands.end(); it++)
217 if (strcmp(name,
"EventCommand") != 0)
218 stream.
Error(
"Expecting %s but got %s",
"EventCommand", name);
219 ref.resize(
ref.size() + 1);
224 std::vector<RPG::EventCommand>&
ref;
void StartElement(XmlReader &stream, const char *name, const char **)
std::vector< RPG::EventCommand > & ref
EventCommandVectorXmlHandler(std::vector< RPG::EventCommand > &ref)
enum EventCommandXmlHandler::@0 field
void EndElement(XmlReader &, const char *)
void StartElement(XmlReader &stream, const char *name, const char **)
void CharacterData(XmlReader &, const std::string &data)
EventCommandXmlHandler(RPG::EventCommand &ref)
std::vector< int32_t > & IntBuffer()
static int IntSize(unsigned int x)
void Seek(size_t pos, SeekMode mode=FromStart)
void ReadString(std::string &ref, size_t size)
void Read(void *ptr, size_t size, size_t nmemb)
void Write(const void *ptr, size_t size, size_t nmemb)
std::string Decode(const std::string &str_to_encode)
std::vector< int32_t > parameters
void SetHandler(XmlHandler *handler)
void Error(const char *fmt,...)
void BeginElement(const std::string &name)
void EndElement(const std::string &name)
void WriteNode(const std::string &name, const T &val)
static int LcfSize(const T &ref, LcfWriter &stream)
static void WriteXml(const T &ref, XmlWriter &stream)
static void ReadLcf(T &ref, LcfReader &stream, uint32_t length)
static void WriteLcf(const T &ref, LcfWriter &stream)
static void BeginXml(T &ref, XmlReader &stream)