private static bool WritePluginsToDisk(BinaryWriter writer, Game game, CompileMessages errors)
{
if (game.Plugins.Count > NativeConstants.MAX_PLUGINS)
{
errors.Add(new CompileError("Too many plugins"));
return false;
}
writer.Write(1); // version
writer.Write(game.Plugins.Count);
foreach (Plugin plugin in game.Plugins)
{
FilePutNullTerminatedString(plugin.FileName, plugin.FileName.Length + 1, writer);
int savesize = plugin.SerializedData.Length;
if (savesize > NativeConstants.SAVEBUFFERSIZE)
{
System.Windows.Forms.MessageBox.Show("Plugin tried to write too much data to game file.");
savesize = 0;
}
writer.Write(savesize);
if (savesize > 0) writer.Write(plugin.SerializedData);
}
return true;
}