Merge in Relative warps

This commit is contained in:
TheManii 2016-04-09 12:42:24 -07:00
commit 10d4d7c148
9 changed files with 290 additions and 201 deletions

View File

@ -24,8 +24,8 @@ namespace FFXIVClassic_Lobby_Server
class CommandProcessor
{
private Dictionary<uint, ConnectedPlayer> mConnectedPlayerList;
private static WorldManager mWorldManager = Server.getWorldManager();
private static Dictionary<uint, Item> gamedataItems = Server.getItemGamedataList();
private static WorldManager mWorldManager = Server.GetWorldManager();
private static Dictionary<uint, Item> gamedataItems = Server.GetGamedataItems();
// For the moment, this is the only predefined item
// TODO: make a list/enum in the future so that items can be given by name, instead of by id
@ -99,58 +99,27 @@ namespace FFXIVClassic_Lobby_Server
/// Teleports player to a location on a predefined list
/// </summary>
/// <param name="client">The current player</param>
/// <param name="entranceId">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param>
public void doWarp(ConnectedPlayer client, string entranceId)
/// <param name="id">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param>
public void doWarp(ConnectedPlayer client, uint id)
{
uint id;
try
{
if (entranceId.ToLower().StartsWith("0x"))
id = Convert.ToUInt32(entranceId, 16);
else
id = Convert.ToUInt32(entranceId);
}
catch(FormatException e)
{return;}
FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id);
if (ze == null)
return;
if (client != null)
mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f);
mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
else
{
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f);
mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
}
}
}
public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz)
public void doWarp(ConnectedPlayer client, uint zoneId, string privateArea, float x, float y, float z, float r)
{
uint zoneId;
float x,y,z;
x = Single.Parse(sx);
y = Single.Parse(sy);
z = Single.Parse(sz);
if (zone == null)
{
if (client != null)
mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f);
}
else
{
if (zone.ToLower().StartsWith("0x"))
zoneId = Convert.ToUInt32(zone, 16);
else
zoneId = Convert.ToUInt32(zone);
if (mWorldManager.GetZone(zoneId) == null)
{
if (client != null)
@ -159,13 +128,12 @@ namespace FFXIVClassic_Lobby_Server
}
if (client != null)
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f);
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
else
{
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f);
}
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
}
}
}
@ -351,6 +319,141 @@ namespace FFXIVClassic_Lobby_Server
}
}
private void parseWarp(ConnectedPlayer client, string[] split)
{
float x = 0, y = 0, z = 0, r = 0.0f;
uint zoneId = 0;
string privatearea = null;
if (split.Length == 2) // Predefined list
{
// TODO: Handle !warp Playername
#region !warp (predefined list)
try
{
if (split[1].ToLower().StartsWith("0x"))
zoneId = Convert.ToUInt32(split[1], 16);
else
zoneId = Convert.ToUInt32(split[1]);
}
catch{return;}
#endregion
doWarp(client, zoneId);
}
else if (split.Length == 4)
{
#region !warp X Y Z
if (split[1].StartsWith("@"))
{
split[1] = split[1].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[1]))
split[1] = "0";
try { x = Single.Parse(split[1]) + client.getActor().positionX; }
catch{return;}
split[1] = x.ToString();
}
if (split[2].StartsWith("@"))
{
split[2] = split[2].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[2]))
split[2] = "0";
try { y = Single.Parse(split[2]) + client.getActor().positionY; }
catch{return;}
split[2] = y.ToString();
}
if (split[3].StartsWith("@"))
{
split[3] = split[3].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[3]))
split[3] = "0";
try { z = Single.Parse(split[3]) + client.getActor().positionZ; }
catch{return;}
split[3] = z.ToString();
}
try
{
x = Single.Parse(split[1]);
y = Single.Parse(split[2]);
z = Single.Parse(split[3]);
}
catch{return;}
zoneId = client.getActor().zoneId;
r = client.getActor().rotation;
#endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y));
doWarp(client, zoneId, privatearea, x, y, z, r);
}
else if (split.Length == 5)
{
#region !warp Zone X Y Z
try
{
x = Single.Parse(split[2]);
y = Single.Parse(split[3]);
z = Single.Parse(split[4]);
}
catch{return;}
if (split[1].ToLower().StartsWith("0x"))
{
try { zoneId = Convert.ToUInt32(split[1], 16); }
catch{return;}
}
else
{
try { zoneId = Convert.ToUInt32(split[1]); }
catch{return;}
}
#endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y));
doWarp(client, zoneId, privatearea, x, y, z, r);
}
else if (split.Length == 6)
{
#region !warp Zone Instance X Y Z
try
{
x = Single.Parse(split[3]);
y = Single.Parse(split[4]);
z = Single.Parse(split[5]);
}
catch{return;}
if (split[1].ToLower().StartsWith("0x"))
{
try { zoneId = Convert.ToUInt32(split[1], 16); }
catch{return;}
}
else
{
try { zoneId = Convert.ToUInt32(split[1]); }
catch{return;}
}
privatearea = split[2];
#endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y));
doWarp(client, zoneId, privatearea, x, y, z, r);
}
else
return; // catch any invalid warps here
}
/// <summary>
/// We only use the default options for SendMessagePacket.
/// May as well make it less unwieldly to view
@ -639,14 +742,7 @@ namespace FFXIVClassic_Lobby_Server
#region !warp
else if (split[0].Equals("warp"))
{
if (split.Length == 2) // Predefined list
doWarp(client, split[1]);
else if (split.Length == 4) // X/Y/Z
doWarp(client, null, null, split[1], split[2], split[3]);
else if (split.Length == 5) // Zone + X/Y/Z
doWarp(client, split[1], null, split[2], split[3], split[4]);
else if (split.Length == 6) // Zone + instance + X/Y/Z
doWarp(client, split[1], split[2], split[3], split[4], split[5]);
parseWarp(client, split);
return true;
}
#endregion

View File

@ -188,7 +188,7 @@ namespace FFXIVClassic_Lobby_Server
subpacket.debugPrintSubPacket();
client.queuePacket(_0x2Packet.buildPacket(player.actorID), true, false);
Server.getWorldManager().DoLogin(player.getActor());
Server.GetWorldManager().DoLogin(player.getActor());
break;
@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server
if (ownerActor == null)
{
//Is it a instance actor?
ownerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
ownerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
if (ownerActor == null)
{
//Is it a Director?
@ -298,7 +298,7 @@ namespace FFXIVClassic_Lobby_Server
Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner);
if (updateOwnerActor == null)
{
updateOwnerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
updateOwnerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
if (player.getActor().currentDirector != null && player.getActor().eventCurrentOwner == player.getActor().currentDirector.actorId)
updateOwnerActor = player.getActor().currentDirector;

View File

@ -239,13 +239,14 @@ namespace FFXIVClassic_Map_Server.Properties {
/// <summary>
/// Looks up a localized string similar to Teleports the player to the specified location
///
///*Note: You can teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name
///
///*Syntax: warp &lt;location list&gt;
/// warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
/// warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
/// warp &lt;zone id&gt; &lt;instance&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
///&lt;location list&gt; is a pre-defined list of locations from the server database
///&lt;zone id&gt; is the zone&apos;s id as defined in the server database
///&lt;instance&gt; is an instanced copy of the desired zone that&apos;s only visible to the current player.
///&lt;zone id&gt; is the [rest of string was truncated]&quot;;.
/// </summary>
public static string CPwarp {
get {

View File

@ -206,6 +206,8 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo
<data name="CPwarp" xml:space="preserve">
<value>Teleports the player to the specified location
*Note: You can teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name
*Syntax: warp &lt;location list&gt;
warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;

View File

@ -330,7 +330,7 @@ namespace FFXIVClassic_Lobby_Server
#endregion
public static WorldManager getWorldManager()
public static WorldManager GetWorldManager()
{
return mWorldManager;
}
@ -340,7 +340,7 @@ namespace FFXIVClassic_Lobby_Server
return mConnectedPlayerList;
}
public static Dictionary<uint, Item> getItemGamedataList()
public static Dictionary<uint, Item> GetGamedataItems()
{
return gamedataItems;
}

View File

@ -374,20 +374,10 @@ namespace FFXIVClassic_Map_Server
//Add player to new zone and update
Area newArea;
if (destinationZoneId != 0)
{
if (destinationPrivateArea == null)
newArea = GetZone(destinationZoneId);
else
newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0);
}
else
{
if (destinationPrivateArea == null)
newArea = GetZone(player.zoneId);
else
newArea = GetZone(player.zoneId).getPrivateArea(destinationPrivateArea, 0);
}
//This server does not contain that zoneId
if (newArea == null)
return;

View File

@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.Actors
{
List<LuaParam> lParams;
Player player = Server.getWorldManager().GetPCInWorld(playerActorId);
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
lParams = LuaEngine.doActorOnInstantiate(player, this);
if (lParams == null)

View File

@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors
{
if (msgParams.Length == 0)
{
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log));
}
else
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
}
public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams)
{
if (msgParams.Length == 0)
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log));
else
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
}
public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams)
{
if (msgParams.Length == 0)
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log));
else
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams)));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams)));
}
public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams)
{
if (msgParams.Length == 0)
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log));
else
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams)));
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams)));
}
public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams)

View File

@ -43,7 +43,7 @@ namespace FFXIVClassic_Map_Server.lua
Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath);
DynValue result = script.Call(script.Globals["onInstantiate"], target);
@ -82,9 +82,9 @@ namespace FFXIVClassic_Map_Server.lua
{
Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath);
@ -125,9 +125,9 @@ namespace FFXIVClassic_Map_Server.lua
{
Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath);
@ -158,9 +158,9 @@ namespace FFXIVClassic_Map_Server.lua
{
Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath);
@ -175,9 +175,9 @@ namespace FFXIVClassic_Map_Server.lua
{
Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(FILEPATH_PLAYER);