Skip to content
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

Feature: orderlist Importing / Exporting. #679

Open
wants to merge 19 commits into
base: jgrpp
Choose a base branch
from

Conversation

lucaFiorini
Copy link

No description provided.

@lucaFiorini
Copy link
Author

the system is now fully operational, imporing and exporting should work.

src/fios_gui.cpp Outdated Show resolved Hide resolved
src/order_cmd.cpp Outdated Show resolved Hide resolved
auto& headJson = json["head"];
for (unsigned int i = 0; auto &SD : SD_data) {

headJson["scheduled-dispatch"][i++] = nlohmann::json::parse(SD.ToJSONString());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serialising a JSON string and then immediately parsing it suggests that a string is not really the right return type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to avoid having to include the json library in the headers, but I guess you are right.
Should it be changed to just use a json object then?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would likely be better, I agree that including the JSON library everywhere is not ideal, but I can resolve that later on

src/order_gui.cpp Outdated Show resolved Hide resolved
if (extraJson.contains("dispatch-index"))
extraJson["dispatch-index"].get_to(new_order.extra->dispatch_index);

if (extraJson.contains("xdata"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These bypass all the order flag and value validation, so likely some changes are needed here. Something for me to look into later probably.

src/order_cmd.cpp Outdated Show resolved Hide resolved
src/fios_gui.cpp Outdated
@@ -367,9 +474,9 @@ struct SaveLoadWindow : public Window {
this->querystrings[WID_SL_FILTER] = &this->filter_editbox;
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;

/* pause is only used in single-player, non-editor mode, non-menu mode. It
/* pause is only used in single-player, non-editor mode, non-menu mode, when not operationg on orderlists. It
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are quite a lot of spelling errors like this

ds.UpdateScheduledDispatch(nullptr);
SetTimetableWindowsDirty(v, STWDF_SCHEDULED_DISPATCH);
if (scheduleJson == nullptr) {
if (p2 == 0) return CMD_ERROR;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check shouldn't be within DC_EXEC because text and exec runs should return the same command result (except where flagged otherwise).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what solution do you suggest? Should I move it outside of DC_EXEC by checking that condition twice?
I.E. something like
if(scheduleJson == nullptr && p2 == 0) return CMD_ERROR;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants