Merged branch develop into develop

develop
Jon Pamala Illo 2016-10-29 13:32:38 +05:30
commit 82f42addcb
1 changed files with 26 additions and 6 deletions

@ -244,11 +244,20 @@ static command_result savestock ( color_ostream &out, vector <string> & paramete
cereal.enable_debug ( out );
if ( !is_dfstockfile ( file ) ) file += ".dfstock";
if ( !cereal.serialize_to_file ( file ) )
try
{
out.printerr ( "could not save to %s\n", file.c_str() );
if ( !cereal.serialize_to_file ( file ) )
{
out.printerr ( "could not save to %s\n", file.c_str() );
return CR_FAILURE;
}
}
catch ( std::exception &e )
{
out.printerr ( "serialization failed: protobuf exception: %s\n", e.what() );
return CR_FAILURE;
}
return CR_OK;
}
@ -296,9 +305,17 @@ static command_result loadstock ( color_ostream &out, vector <string> & paramete
StockpileSerializer cereal ( sp );
if ( debug )
cereal.enable_debug ( out );
if ( !cereal.unserialize_from_file ( file ) )
try
{
out.printerr ( "unserialization failed\n" );
if ( !cereal.unserialize_from_file ( file ) )
{
out.printerr ( "unserialization failed: %s\n", file.c_str() );
return CR_FAILURE;
}
}
catch ( std::exception &e )
{
out.printerr ( "unserialization failed: protobuf exception: %s\n", e.what() );
return CR_FAILURE;
}
return CR_OK;
@ -508,13 +525,16 @@ static int stockpiles_list_settings ( lua_State *L )
return 1;
}
const std::string err_title = "Stockpile Settings Error";
const std::string err_help = "Does the folder exist?\nCheck the console for more information.";
static void stockpiles_load ( color_ostream &out, std::string filename )
{
std::vector<std::string> params;
params.push_back ( filename );
command_result r = loadstock ( out, params );
if ( r != CR_OK )
show_message_box ( "Stockpile Settings Error", "Couldn't load. Does the folder exist?", true );
show_message_box ( err_title, "Couldn't load. " + err_help, true );
}
@ -524,7 +544,7 @@ static void stockpiles_save ( color_ostream &out, std::string filename )
params.push_back ( filename );
command_result r = savestock ( out, params );
if ( r != CR_OK )
show_message_box ( "Stockpile Settings Error", "Couldn't save. Does the folder exist?", true );
show_message_box ( err_title, "Couldn't save. " + err_help, true );
}
DFHACK_PLUGIN_LUA_FUNCTIONS