-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destiny Patch support #3131
Destiny Patch support #3131
Conversation
Nice! Some Documentation, to help contextualize this patch: Destiny Patch 2.0 (also from Bananen-Joe) + Maniacs Update, by Kotatsu Akira: |
Hello. As adding the rest of destiny will be a huge task I have to ask: Your code looks good but do you feel confident enough in C++ to implement the rest of it?
|
Hm actually the grammar doesn't look too hard to parse because the language lacks flow control like if and for. Very straightforward. I can offer my help here if you encounter problems. |
Thanks for the feedback! Maybe the interpreter I could use OOP. |
If you think you can implement such a parser then go for it :). When it is flexible enough it can also be used for other parts as you proposed (Maniac has nothing to parse on the player side but there is an expression parser needed for the editor.) |
Jenkins: test this please |
src/game_destiny.cpp
Outdated
length = code.length() + 1; | ||
destinyScript = new char[length]; | ||
strcpy_s(destinyScript, length, code.c_str()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcpy_s
is a Microsoft extension.
In general you do not need new
or malloc
in modern C++ code. You could just change the type of _destinyScript
to std::string
and do destinyScript = code
.
You can still do the _scriptPtr
stuff via _scriptPtr = &destintyScript.data()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this?
private:
// Member data
std::string _destinyScript;
const char* Interpreter::MakeString(SaveEventExecFrame& frame)
{
std::string code;
int32_t& current = frame.current_command;
const std::vector<EventCommand>& cmdList = frame.commands;
std::vector<EventCommand>::const_iterator it = cmdList.begin() + current++;
code = ToString((*it++).string);
while (it != cmdList.cend() && it->code == static_cast<int32_t>(EventCommand::Code::Comment_2))
{
code += '\n';
code += ToString((*it++).string);
++current;
}
_destinyScript = code;
return _scriptPtr = _destinyScript.data();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this _scriptPtr
assignment is legal here because _destinyScript
is a member variable. (in case of a local variable this would return a dangling pointer because the memory is freed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I'll push again to see whether the code passes.
Honestly when these two issues are resolved I would be fine with merging it for now. Just to avoid regular rebasing because of conflicts in the other files. Of course its currently not useful as is a stub and the coding style is different but most of the upcoming patch commits will be pretty isolated (only in (Also we had a DynRpg interpreter but 0 implemented plugins for years xD) |
I forgot to note: later I want to do unit tests in |
Thats fine. Just create the file and add the file at the correct location in |
Jenkins: test this please |
I'm going to start implementing Destiny Patch support on EasyRPG.
I hope can help.
Awaiting for a feedback. Thanks! =D