diff --git a/world/remote_call.cpp b/world/remote_call.cpp index 200720aa5..c403d1c1c 100644 --- a/world/remote_call.cpp +++ b/world/remote_call.cpp @@ -166,7 +166,7 @@ void handle_rc_quest_interface(const std::string &method, const std::string &con std::string error; std::map res; - FILE *f = fopen("quests/global/Waypoint.pl", "r"); + FILE *f = fopen("quests/global/Waypoint.pl", "rb"); if(!f) { error = "File not found"; RemoteCallResponse(connection_id, request_id, res, error); @@ -177,32 +177,19 @@ void handle_rc_quest_interface(const std::string &method, const std::string &con size_t sz = ftell(f); rewind(f); - //todo: actually break the message apart or something so we don't destroy web_interface's poor buffer - //dunno where to do this yet, got some musing to do - //if(sz >= 1024) { - // error = "File too large... for now..."; - // RemoteCallResponse(connection_id, request_id, res, error); - // return; - //} - char *buffer = new char[sz + 1]; size_t r = fread(buffer, 1, sz, f); if(r != sz) { error = "Unable to read file"; RemoteCallResponse(connection_id, request_id, res, error); + fclose(f); delete[] buffer; return; } + fclose(f); buffer[sz] = '\0'; - //std::string str; - //std::ifstream file("quests/global/Waypoint.pl", std::ios::in); - //if (file) { - // while (!file.eof()) - // str.push_back(file.get()); - //} - res["quest_text"] = buffer; RemoteCallResponse(connection_id, request_id, res, error); } \ No newline at end of file