using System.Collections;
using System.Collections.Generic;
using System.IO;
using Server.Commands;
using Server.Gumps;
using Server.Items;
namespace Server
{
public class Statics
{
private const string BaseFreezeWarning = "{0} " +
"Those items will be removed from the world and placed into the server data files. " +
"Other players will not see the changes unless you distribute your data files to them.
" +
"This operation may not complete unless the server and client are using different data files. " +
"If you receive a message stating 'output data files could not be opened,' then you are probably sharing data files. " +
"Create a new directory for the world data files (statics*.mul and staidx*.mul) and add that to Scritps/Misc/DataPath.cs.
" +
"The change will be in effect immediately on the server, however, you must restart your client and update it's data files for the changes to become visible. " +
"It is strongly recommended that you make backup of the data files mentioned above. " +
"Do you wish to proceed?";
private const string BaseUnfreezeWarning = "{0} " +
"Those items will be removed from the static files and exchanged with unmovable dynamic items. " +
"Other players will not see the changes unless you distribute your data files to them.
" +
"This operation may not complete unless the server and client are using different data files. " +
"If you receive a message stating 'output data files could not be opened,' then you are probably sharing data files. " +
"Create a new directory for the world data files (statics*.mul and staidx*.mul) and add that to Scritps/Misc/DataPath.cs.
" +
"The change will be in effect immediately on the server, however, you must restart your client and update it's data files for the changes to become visible. " +
"It is strongly recommended that you make backup of the data files mentioned above. " +
"Do you wish to proceed?";
private static Point3D NullP3D = new Point3D(int.MinValue, int.MinValue, int.MinValue);
private static byte[] m_Buffer;
private static StaticTile[] m_TileBuffer = new StaticTile[128];
public static void Initialize()
{
CommandSystem.Register("Freeze", AccessLevel.Administrator, Freeze_OnCommand);
CommandSystem.Register("FreezeMap", AccessLevel.Administrator, FreezeMap_OnCommand);
CommandSystem.Register("FreezeWorld", AccessLevel.Administrator, FreezeWorld_OnCommand);
CommandSystem.Register("Unfreeze", AccessLevel.Administrator, Unfreeze_OnCommand);
CommandSystem.Register("UnfreezeMap", AccessLevel.Administrator, UnfreezeMap_OnCommand);
CommandSystem.Register("UnfreezeWorld", AccessLevel.Administrator, UnfreezeWorld_OnCommand);
}
public delegate void FreezeCallback( Mobile from, bool okay, StateInfo si );
[Usage("Freeze")]
[Description("Makes a targeted area of dynamic items static.")]
public static void Freeze_OnCommand(CommandEventArgs e)
{
Mobile from = e.Mobile;
BoundingBoxPicker.Begin(from, (map, start, end) => FreezeBox_Callback(from, map, start, end));
}
[Usage("FreezeMap")]
[Description("Makes every dynamic item in your map static.")]
public static void FreezeMap_OnCommand(CommandEventArgs e)
{
Mobile from = e.Mobile;
Map map = from.Map;
if (map != null && map != Map.Internal)
SendWarning(from, "You are about to freeze all items in {0}.", BaseFreezeWarning, map, NullP3D,
NullP3D, FreezeWarning_Callback);
}
[Usage("FreezeWorld")]
[Description("Makes every dynamic item on all maps static.")]
public static void FreezeWorld_OnCommand(CommandEventArgs e)
{
SendWarning(e.Mobile, "You are about to freeze every item on every map.", BaseFreezeWarning, null,
NullP3D, NullP3D, FreezeWarning_Callback);
}
public static void SendWarning(Mobile m, string header, string baseWarning, Map map, Point3D start, Point3D end,
FreezeCallback callback)
{
m.SendGump(new WarningGump(1060635, 30720, string.Format(baseWarning, string.Format(header, map)), 0xFFC000, 420,
400, okay => callback(m, okay, new StateInfo(map, start, end))));
}
private static void FreezeBox_Callback(Mobile from, Map map, Point3D start, Point3D end)
{
SendWarning(from, "You are about to freeze a section of items.", BaseFreezeWarning, map, start, end,
FreezeWarning_Callback);
}
private static void FreezeWarning_Callback(Mobile from, bool okay, StateInfo si)
{
if (!okay)
return;
Freeze(from, si.m_Map, si.m_Start, si.m_End);
}
public static void Freeze(Mobile from, Map targetMap, Point3D start3d, Point3D end3d)
{
Dictionary