1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-21 20:27:47 +00:00

Implementing zone settings from DB.

This commit is contained in:
Filip Maj 2016-01-17 01:51:02 -05:00
parent 9d67718060
commit 0e85e2bddf
3 changed files with 58 additions and 3 deletions

View file

@ -13,12 +13,14 @@ using FFXIVClassic_Map_Server.utils;
using FFXIVClassic_Lobby_Server.packets; using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Map_Server.packets.send.player; using FFXIVClassic_Map_Server.packets.send.player;
using FFXIVClassic_Lobby_Server.dataobjects; using FFXIVClassic_Lobby_Server.dataobjects;
using FFXIVClassic_Map_Server;
namespace FFXIVClassic_Lobby_Server namespace FFXIVClassic_Lobby_Server
{ {
class Database class Database
{ {
public static uint getUserIdFromSession(String sessionId) public static uint getUserIdFromSession(String sessionId)
{ {
uint id = 0; uint id = 0;
@ -540,5 +542,51 @@ namespace FFXIVClassic_Lobby_Server
return cheevosPacket.buildPacket(player.actorId); return cheevosPacket.buildPacket(player.actorId);
} }
public static List<Zone> loadZones()
{
List<Zone> zones = new List<Zone>();
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();
//Load Last 5 Completed
string query = @"
SELECT
id,
regionId,
zoneName,
dayMusic,
nightMusic,
battleMusic,
isInn,
canRideChocobo,
canStealth,
isInstanceRaid,
FROM server_zones
WHERE zoneName IS NOT NULL";
MySqlCommand cmd = new MySqlCommand(query, conn);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read()) {
Zone zone = new Zone(reader.GetUInt32(0), reader.GetString(2), reader.GetUInt16(1), reader.GetUInt16(3), reader.GetUInt16(4), reader.GetUInt16(5), reader.GetBoolean(6), reader.GetBoolean(7), reader.GetBoolean(8), reader.GetBoolean(9));
zones.Add(zone);
}
}
}
catch (MySqlException e)
{ Console.WriteLine(e); }
finally
{
conn.Dispose();
}
}
return zones;
}
} }
} }

View file

@ -49,13 +49,15 @@ namespace FFXIVClassic_Lobby_Server
DebugProg debug = new DebugProg(); DebugProg debug = new DebugProg();
WorldMaster worldMaster = new WorldMaster(); WorldMaster worldMaster = new WorldMaster();
Zone inn = new Zone(0xF4, "prv0Inn01", 0xD1, false, false, false, false);
List<Zone> zoneList;
public PacketProcessor(Dictionary<uint, ConnectedPlayer> playerList, List<ClientConnection> connectionList) public PacketProcessor(Dictionary<uint, ConnectedPlayer> playerList, List<ClientConnection> connectionList)
{ {
mPlayers = playerList; mPlayers = playerList;
mConnections = connectionList; mConnections = connectionList;
// initNpcs();
zoneList = Database.loadZones();
} }
public void processPacket(ClientConnection client, BasePacket packet) public void processPacket(ClientConnection client, BasePacket packet)

View file

@ -25,7 +25,8 @@ namespace FFXIVClassic_Map_Server
private int halfWidth, halfHeight; private int halfWidth, halfHeight;
private List<Actor>[,] actorBlock; private List<Actor>[,] actorBlock;
public Zone(uint id, string zoneName, ushort regionId, bool canStealth, bool isInn, bool canRideChocobo, bool isInstanceRaid) : base(id) public Zone(uint id, string zoneName, ushort regionId, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool canStealth, bool isInn, bool canRideChocobo, bool isInstanceRaid)
: base(id)
{ {
this.zoneName = zoneName; this.zoneName = zoneName;
@ -35,6 +36,10 @@ namespace FFXIVClassic_Map_Server
this.canRideChocobo = canRideChocobo; this.canRideChocobo = canRideChocobo;
this.isInstanceRaid = isInstanceRaid; this.isInstanceRaid = isInstanceRaid;
this.bgmDay = bgmDay;
this.bgmNight = bgmNight;
this.bgmBattle = bgmBattle;
this.displayNameId = 0; this.displayNameId = 0;
this.customDisplayName = "_areaMaster"; this.customDisplayName = "_areaMaster";
this.actorName = String.Format("_areaMaster@{0:X5}",id<<8); this.actorName = String.Format("_areaMaster@{0:X5}",id<<8);