mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-02 19:42:05 -04:00
Added a way to reset a zone and reload the NPC list.
This commit is contained in:
parent
f1025f89d3
commit
e043be5ca4
@ -293,10 +293,15 @@ namespace FFXIVClassic_Lobby_Server
|
||||
{
|
||||
uint id;
|
||||
|
||||
if (entranceId.ToLower().StartsWith("0x"))
|
||||
id = Convert.ToUInt32(entranceId, 16);
|
||||
else
|
||||
id = Convert.ToUInt32(entranceId);
|
||||
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);
|
||||
|
||||
@ -314,27 +319,34 @@ namespace FFXIVClassic_Lobby_Server
|
||||
}
|
||||
}
|
||||
|
||||
public void doWarp(ConnectedPlayer client, string map, string sx, string sy, string sz)
|
||||
public void doWarp(ConnectedPlayer client, string zone, string sx, string sy, string sz)
|
||||
{
|
||||
uint mapId;
|
||||
uint zoneId;
|
||||
float x,y,z;
|
||||
|
||||
if (map.ToLower().StartsWith("0x"))
|
||||
mapId = Convert.ToUInt32(map, 16);
|
||||
if (zone.ToLower().StartsWith("0x"))
|
||||
zoneId = Convert.ToUInt32(zone, 16);
|
||||
else
|
||||
mapId = Convert.ToUInt32(map);
|
||||
zoneId = Convert.ToUInt32(zone);
|
||||
|
||||
if (mWorldManager.GetZone(zoneId) == null)
|
||||
{
|
||||
if (client != null)
|
||||
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false));
|
||||
Log.error("Zone does not exist or setting isn't valid.");
|
||||
}
|
||||
|
||||
x = Single.Parse(sx);
|
||||
y = Single.Parse(sy);
|
||||
z = Single.Parse(sz);
|
||||
|
||||
if (client != null)
|
||||
mWorldManager.DoZoneChange(client.getActor(), mapId, 0x2, x, y, z, 0.0f);
|
||||
mWorldManager.DoZoneChange(client.getActor(), zoneId, 0x2, x, y, z, 0.0f);
|
||||
else
|
||||
{
|
||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
||||
{
|
||||
mWorldManager.DoZoneChange(entry.Value.getActor(), mapId, 0x2, x, y, z, 0.0f);
|
||||
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, 0x2, x, y, z, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,6 +376,8 @@ namespace FFXIVClassic_Lobby_Server
|
||||
|
||||
internal void doCommand(string input, ConnectedPlayer client)
|
||||
{
|
||||
input.Trim();
|
||||
|
||||
String[] split = input.Split(' ');
|
||||
|
||||
if (split.Length >= 1)
|
||||
@ -379,6 +393,12 @@ namespace FFXIVClassic_Lobby_Server
|
||||
Log.error("Could not load packet: " + e);
|
||||
}
|
||||
}
|
||||
else if (split[0].Equals("resetzone"))
|
||||
{
|
||||
Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId));
|
||||
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Resting zone {0}...", client.getActor().zoneId)), true, false));
|
||||
mWorldManager.reloadZone(client.getActor().zoneId);
|
||||
}
|
||||
}
|
||||
if (split.Length >= 2)
|
||||
{
|
||||
|
@ -186,6 +186,72 @@ namespace FFXIVClassic_Map_Server
|
||||
Log.info(String.Format("Loaded {0} npc(s).", count));
|
||||
}
|
||||
|
||||
public void LoadNPCs(uint zoneId)
|
||||
{
|
||||
int count = 0;
|
||||
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
||||
{
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
string query = @"
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
zoneId,
|
||||
actorTemplateId,
|
||||
positionX,
|
||||
positionY,
|
||||
positionZ,
|
||||
rotation,
|
||||
actorState,
|
||||
animationId,
|
||||
actorClassName,
|
||||
eventConditions
|
||||
FROM server_npclist
|
||||
WHERE zoneId = @zoneId
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@zoneId", zoneId);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
Npc npc = new Npc(reader.GetUInt32(0), reader.GetString(1), reader.GetUInt32(2), reader.GetUInt32(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetFloat(6), reader.GetFloat(7), reader.GetUInt16(8), reader.GetUInt32(9), reader.GetString(10));
|
||||
|
||||
if (!reader.IsDBNull(11))
|
||||
{
|
||||
string eventConditions = reader.GetString(11);
|
||||
npc.loadEventConditions(eventConditions);
|
||||
}
|
||||
|
||||
if (!zoneList.ContainsKey(npc.zoneId))
|
||||
continue;
|
||||
Zone zone = zoneList[npc.zoneId];
|
||||
if (zone == null)
|
||||
continue;
|
||||
npc.zone = zone;
|
||||
zone.addActorToZone(npc);
|
||||
count++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Log.info(String.Format("Loaded {0} npc(s).", count));
|
||||
}
|
||||
|
||||
//Moves the actor to the new zone if exists. No packets are sent nor position changed.
|
||||
public void DoSeamlessZoneChange(Player player, uint destinationZoneId)
|
||||
{
|
||||
@ -273,6 +339,17 @@ namespace FFXIVClassic_Map_Server
|
||||
player.sendZoneInPackets(this, 0x1);
|
||||
}
|
||||
|
||||
public void reloadZone(uint zoneId)
|
||||
{
|
||||
if (!zoneList.ContainsKey(zoneId))
|
||||
return;
|
||||
|
||||
Zone zone = zoneList[zoneId];
|
||||
zone.clear();
|
||||
LoadNPCs(zone.actorId);
|
||||
|
||||
}
|
||||
|
||||
public Player GetPCInWorld(string name)
|
||||
{
|
||||
foreach (Zone zone in zoneList.Values)
|
||||
|
@ -268,5 +268,18 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
return (Player)mActorList[id];
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
//Clear All
|
||||
mActorList.Clear();
|
||||
for (int y = 0; y < numYBlocks; y++)
|
||||
{
|
||||
for (int x = 0; x < numXBlocks; x++)
|
||||
{
|
||||
mActorBlock[x, y].Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user