mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-08 21:44:35 +02:00
Merge branch 'master' of https://bitbucket.org/Ioncannon/ffxiv-classic-server into method_casing
# Conflicts: # FFXIVClassic Map Server/CommandProcessor.cs # FFXIVClassic Map Server/WorldManager.cs # FFXIVClassic Map Server/actors/area/Area.cs # FFXIVClassic Map Server/actors/area/PrivateArea.cs # FFXIVClassic Map Server/actors/area/Zone.cs # FFXIVClassic Map Server/actors/chara/npc/Npc.cs # FFXIVClassic Map Server/common/Utils.cs # FFXIVClassic Map Server/dataobjects/ConnectedPlayer.cs
This commit is contained in:
commit
335a59204c
521 changed files with 12848 additions and 10394 deletions
|
@ -1,12 +1,21 @@
|
|||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.actors.area;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
using FFXIVClassic_Map_Server.dataobjects.chara;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
using FFXIVClassic_Map_Server.packets.send;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using FFXIVClassic_Map_Server.packets.send.login;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server
|
||||
{
|
||||
|
@ -16,6 +25,7 @@ namespace FFXIVClassic_Map_Server
|
|||
private WorldMaster worldMaster = new WorldMaster();
|
||||
private Dictionary<uint, Zone> zoneList;
|
||||
private Dictionary<uint, ZoneEntrance> zoneEntranceList;
|
||||
private Dictionary<uint, ActorClass> actorClasses = new Dictionary<uint,ActorClass>();
|
||||
|
||||
private Server mServer;
|
||||
|
||||
|
@ -66,10 +76,7 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
|
||||
}
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
|
@ -105,7 +112,7 @@ namespace FFXIVClassic_Map_Server
|
|||
if (zoneList.ContainsKey(parentZoneId))
|
||||
{
|
||||
Zone parent = zoneList[parentZoneId];
|
||||
PrivateArea privArea = new PrivateArea(parent, reader.GetUInt32("id"), reader.GetString("className"), reader.GetString("privateAreaName"), reader.GetUInt16("dayMusic"), reader.GetUInt16("nightMusic"), reader.GetUInt16("battleMusic"));
|
||||
PrivateArea privArea = new PrivateArea(parent, reader.GetUInt32("id"), reader.GetString("className"), reader.GetString("privateAreaName"), 1, reader.GetUInt16("dayMusic"), reader.GetUInt16("nightMusic"), reader.GetUInt16("battleMusic"));
|
||||
parent.AddPrivateArea(privArea);
|
||||
}
|
||||
else
|
||||
|
@ -116,16 +123,14 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Program.Log.Info("Loaded {0} zones and {1} private areas.", count1, count2);
|
||||
Program.Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2));
|
||||
}
|
||||
|
||||
public void LoadZoneEntranceList()
|
||||
|
@ -169,19 +174,17 @@ namespace FFXIVClassic_Map_Server
|
|||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Program.Log.Info("Loaded {0} zone spawn locations.", count);
|
||||
Program.Log.Info(String.Format("Loaded {0} zone spawn locations.", count));
|
||||
}
|
||||
|
||||
public void LoadNPCs()
|
||||
public void LoadActorClasses()
|
||||
{
|
||||
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)))
|
||||
|
@ -193,20 +196,11 @@ namespace FFXIVClassic_Map_Server
|
|||
string query = @"
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
zoneId,
|
||||
positionX,
|
||||
positionY,
|
||||
positionZ,
|
||||
rotation,
|
||||
actorState,
|
||||
animationId,
|
||||
classPath,
|
||||
displayNameId,
|
||||
customDisplayName,
|
||||
actorClassName,
|
||||
eventConditions
|
||||
FROM gamedata_actor_class
|
||||
WHERE name is not NULL AND zoneId > 0
|
||||
WHERE classPath <> ''
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
|
@ -215,45 +209,35 @@ namespace FFXIVClassic_Map_Server
|
|||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
string customName = null;
|
||||
if (!reader.IsDBNull(10))
|
||||
customName = reader.GetString(10);
|
||||
uint id = reader.GetUInt32("id");
|
||||
string classPath = reader.GetString("classPath");
|
||||
uint nameId = reader.GetUInt32("displayNameId");
|
||||
string eventConditions = null;
|
||||
|
||||
if (!reader.IsDBNull(3))
|
||||
eventConditions = reader.GetString("eventConditions");
|
||||
else
|
||||
eventConditions = "{}";
|
||||
|
||||
Npc npc = new Npc(reader.GetUInt32(0), reader.GetString(1), reader.GetUInt32(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetFloat(6), reader.GetUInt16(7), reader.GetUInt32(8), reader.GetUInt32(9), customName, reader.GetString(11));
|
||||
|
||||
if (!reader.IsDBNull(12))
|
||||
{
|
||||
string eventConditions = reader.GetString(12);
|
||||
npc.LoadEventConditions(eventConditions);
|
||||
}
|
||||
|
||||
if (!zoneList.ContainsKey(npc.zoneId))
|
||||
continue;
|
||||
Zone zone = zoneList[npc.zoneId];
|
||||
if (zone == null)
|
||||
continue;
|
||||
npc.zone = zone;
|
||||
zone.AddActorToZone(npc);
|
||||
ActorClass actorClass = new ActorClass(id, classPath, nameId, eventConditions);
|
||||
actorClasses.Add(id, actorClass);
|
||||
count++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Program.Log.Info("Loaded {0} npc(s).", count);
|
||||
Program.Log.Info(String.Format("Loaded {0} actor classes.", count));
|
||||
}
|
||||
|
||||
public void LoadNPCs(uint zoneId)
|
||||
public void LoadSpawnLocations()
|
||||
{
|
||||
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)))
|
||||
|
@ -264,69 +248,80 @@ namespace FFXIVClassic_Map_Server
|
|||
|
||||
string query = @"
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
zoneId,
|
||||
actorClassId,
|
||||
uniqueId,
|
||||
zoneId,
|
||||
privateAreaName,
|
||||
privateAreaLevel,
|
||||
positionX,
|
||||
positionY,
|
||||
positionZ,
|
||||
rotation,
|
||||
actorState,
|
||||
animationId,
|
||||
displayNameId,
|
||||
customDisplayName,
|
||||
actorClassName,
|
||||
eventConditions
|
||||
FROM gamedata_actor_class
|
||||
WHERE name is not NULL AND zoneId = @zoneId
|
||||
customDisplayName
|
||||
FROM server_spawn_locations
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@zoneId", zoneId);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
string customName = null;
|
||||
if (!reader.IsDBNull(10))
|
||||
customName = reader.GetString(10);
|
||||
if (!reader.IsDBNull(11))
|
||||
customName = reader.GetString("customDisplayName");
|
||||
|
||||
Npc npc = new Npc(reader.GetUInt32(0), reader.GetString(1), reader.GetUInt32(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetFloat(6), reader.GetUInt16(7), reader.GetUInt32(8), reader.GetUInt32(9), customName, reader.GetString(11));
|
||||
uint classId = reader.GetUInt32("actorClassId");
|
||||
string uniqueId = reader.GetString("uniqueId");
|
||||
uint zoneId = reader.GetUInt32("zoneId");
|
||||
string privAreaName = reader.GetString("privateAreaName");
|
||||
uint privAreaLevel = reader.GetUInt32("privateAreaLevel");
|
||||
float x = reader.GetFloat("positionX");
|
||||
float y = reader.GetFloat("positionY");
|
||||
float z = reader.GetFloat("positionZ");
|
||||
float rot = reader.GetFloat("rotation");
|
||||
ushort state = reader.GetUInt16("actorState");
|
||||
uint animId = reader.GetUInt32("animationId");
|
||||
|
||||
if (!reader.IsDBNull(12))
|
||||
{
|
||||
string eventConditions = reader.GetString(12);
|
||||
npc.LoadEventConditions(eventConditions);
|
||||
}
|
||||
|
||||
if (!zoneList.ContainsKey(npc.zoneId))
|
||||
if (!actorClasses.ContainsKey(classId))
|
||||
continue;
|
||||
Zone zone = zoneList[npc.zoneId];
|
||||
if (!zoneList.ContainsKey(zoneId))
|
||||
continue;
|
||||
|
||||
Zone zone = zoneList[zoneId];
|
||||
if (zone == null)
|
||||
continue;
|
||||
npc.zone = zone;
|
||||
zone.AddActorToZone(npc);
|
||||
count++;
|
||||
|
||||
SpawnLocation spawn = new SpawnLocation(classId, uniqueId, zoneId, privAreaName, privAreaLevel, x, y, z, rot, state, animId);
|
||||
|
||||
zone.AddSpawnLocation(spawn);
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
{ Console.WriteLine(e); }
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Program.Log.Info("Loaded {0} npc(s).", count);
|
||||
Program.Log.Info(String.Format("Loaded {0} spawn(s).", count));
|
||||
}
|
||||
|
||||
//Moves the actor to the new zone if exists. No packets are sent nor position Changed.
|
||||
public void SpawnAllActors()
|
||||
{
|
||||
Program.Log.Info("Spawning actors...");
|
||||
foreach (Zone z in zoneList.Values)
|
||||
z.SpawnAllActors(true);
|
||||
}
|
||||
|
||||
//Moves the actor to the new zone if exists. No packets are sent nor position changed.
|
||||
public void DoSeamlessZoneChange(Player player, uint destinationZoneId)
|
||||
{
|
||||
Area oldZone;
|
||||
|
@ -340,7 +335,7 @@ namespace FFXIVClassic_Map_Server
|
|||
//Add player to new zone and update
|
||||
Zone newZone = GetZone(destinationZoneId);
|
||||
|
||||
//This server Does not contain that zoneId
|
||||
//This server does not contain that zoneId
|
||||
if (newZone == null)
|
||||
return;
|
||||
|
||||
|
@ -381,7 +376,7 @@ namespace FFXIVClassic_Map_Server
|
|||
newArea = GetZone(destinationZoneId);
|
||||
else
|
||||
newArea = GetZone(destinationZoneId).GetPrivateArea(destinationPrivateArea, 0);
|
||||
//This server Does not contain that zoneId
|
||||
//This server does not contain that zoneId
|
||||
if (newArea == null)
|
||||
return;
|
||||
|
||||
|
@ -451,11 +446,11 @@ namespace FFXIVClassic_Map_Server
|
|||
//Add player to new zone and update
|
||||
Zone zone = GetZone(player.zoneId);
|
||||
|
||||
//This server Does not contain that zoneId
|
||||
//This server does not contain that zoneId
|
||||
if (zone == null)
|
||||
return;
|
||||
|
||||
//Set the current zone and Add player
|
||||
//Set the current zone and add player
|
||||
player.zone = zone;
|
||||
|
||||
LuaEngine.OnBeginLogin(player);
|
||||
|
@ -469,14 +464,14 @@ namespace FFXIVClassic_Map_Server
|
|||
LuaEngine.OnZoneIn(player);
|
||||
}
|
||||
|
||||
public void ReloadZone(uint zoneId)
|
||||
public void reloadZone(uint zoneId)
|
||||
{
|
||||
if (!zoneList.ContainsKey(zoneId))
|
||||
return;
|
||||
|
||||
Zone zone = zoneList[zoneId];
|
||||
//zone.Clear();
|
||||
LoadNPCs(zone.actorId);
|
||||
//zone.clear();
|
||||
//LoadNPCs(zone.actorId);
|
||||
|
||||
}
|
||||
|
||||
|
@ -559,6 +554,15 @@ namespace FFXIVClassic_Map_Server
|
|||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public ActorClass GetActorClass(uint id)
|
||||
{
|
||||
if (actorClasses.ContainsKey(id))
|
||||
return actorClasses[id];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue