mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-06-10 14:34:32 +02:00
Updated Map Server namespace. Moved all other data folders (www and sql) to data folder. Renamed boot name to Project Meteor.
This commit is contained in:
parent
18ef69f3d1
commit
91549bff7a
1823 changed files with 102704 additions and 901 deletions
72
Map Server/Utils/ActorPropertyPacketUtil.cs
Normal file
72
Map Server/Utils/ActorPropertyPacketUtil.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Meteor.Map.packets.send.actor;
|
||||
using Meteor.Map.Actors;
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Map.utils
|
||||
{
|
||||
class ActorPropertyPacketUtil
|
||||
{
|
||||
private Actor forActor;
|
||||
private List<SubPacket> subPackets = new List<SubPacket>();
|
||||
private SetActorPropetyPacket currentActorPropertyPacket;
|
||||
private string currentTarget;
|
||||
|
||||
public ActorPropertyPacketUtil(string firstTarget, Actor forActor)
|
||||
{
|
||||
currentActorPropertyPacket = new SetActorPropetyPacket(firstTarget);
|
||||
this.forActor = forActor;
|
||||
this.currentTarget = firstTarget;
|
||||
}
|
||||
|
||||
public void AddProperty(string property)
|
||||
{
|
||||
if (!currentActorPropertyPacket.AddProperty(forActor, property))
|
||||
{
|
||||
currentActorPropertyPacket.SetIsMore(true);
|
||||
currentActorPropertyPacket.AddTarget();
|
||||
subPackets.Add(currentActorPropertyPacket.BuildPacket(forActor.actorId));
|
||||
currentActorPropertyPacket = new SetActorPropetyPacket(currentTarget);
|
||||
currentActorPropertyPacket.AddProperty(forActor, property);
|
||||
}
|
||||
}
|
||||
|
||||
public void NewTarget(string target)
|
||||
{
|
||||
currentActorPropertyPacket.AddTarget();
|
||||
currentTarget = target;
|
||||
currentActorPropertyPacket.SetTarget(target);
|
||||
}
|
||||
|
||||
public List<SubPacket> Done()
|
||||
{
|
||||
currentActorPropertyPacket.AddTarget();
|
||||
currentActorPropertyPacket.SetIsMore(false);
|
||||
subPackets.Add(currentActorPropertyPacket.BuildPacket(forActor.actorId));
|
||||
return subPackets;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
147
Map Server/Utils/CharacterUtils.cs
Normal file
147
Map Server/Utils/CharacterUtils.cs
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using System;
|
||||
|
||||
namespace Meteor.Map.utils
|
||||
{
|
||||
class CharacterUtils
|
||||
{
|
||||
public struct FaceInfo
|
||||
{
|
||||
[BitfieldLength(5)]
|
||||
public uint characteristics;
|
||||
[BitfieldLength(3)]
|
||||
public uint characteristicsColor;
|
||||
[BitfieldLength(6)]
|
||||
public uint type;
|
||||
[BitfieldLength(2)]
|
||||
public uint ears;
|
||||
[BitfieldLength(2)]
|
||||
public uint mouth;
|
||||
[BitfieldLength(2)]
|
||||
public uint features;
|
||||
[BitfieldLength(3)]
|
||||
public uint nose;
|
||||
[BitfieldLength(3)]
|
||||
public uint eyeShape;
|
||||
[BitfieldLength(1)]
|
||||
public uint irisSize;
|
||||
[BitfieldLength(3)]
|
||||
public uint eyebrows;
|
||||
[BitfieldLength(2)]
|
||||
public uint unknown;
|
||||
}
|
||||
|
||||
public static FaceInfo GetFaceInfo(byte characteristics, byte characteristicsColor, byte faceType, byte ears, byte faceMouth, byte faceFeatures, byte faceNose, byte faceEyeShape, byte faceIrisSize, byte faceEyebrows)
|
||||
{
|
||||
FaceInfo faceInfo = new FaceInfo();
|
||||
faceInfo.characteristics = characteristics;
|
||||
faceInfo.characteristicsColor = characteristicsColor;
|
||||
faceInfo.type = faceType;
|
||||
faceInfo.ears = ears;
|
||||
faceInfo.features = faceFeatures;
|
||||
faceInfo.eyebrows = faceEyebrows;
|
||||
faceInfo.eyeShape = faceEyeShape;
|
||||
faceInfo.irisSize = faceIrisSize;
|
||||
faceInfo.mouth = faceMouth;
|
||||
faceInfo.nose = faceNose;
|
||||
return faceInfo;
|
||||
}
|
||||
|
||||
public static UInt32 GetTribeModel(byte tribe)
|
||||
{
|
||||
switch (tribe)
|
||||
{
|
||||
//Hyur Midlander Male
|
||||
case 1:
|
||||
default:
|
||||
return 1;
|
||||
|
||||
//Hyur Midlander Female
|
||||
case 2:
|
||||
return 2;
|
||||
|
||||
//Elezen Male
|
||||
case 4:
|
||||
case 6:
|
||||
return 3;
|
||||
|
||||
//Elezen Female
|
||||
case 5:
|
||||
case 7:
|
||||
return 4;
|
||||
|
||||
//Lalafell Male
|
||||
case 8:
|
||||
case 10:
|
||||
return 5;
|
||||
|
||||
//Lalafell Female
|
||||
case 9:
|
||||
case 11:
|
||||
return 6;
|
||||
|
||||
//Miqo'te Female
|
||||
case 12:
|
||||
case 13:
|
||||
return 8;
|
||||
|
||||
//Roegadyn Male
|
||||
case 14:
|
||||
case 15:
|
||||
return 7;
|
||||
|
||||
//Hyur Highlander Male
|
||||
case 3:
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetClassNameForId(short id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 2: return "pug";
|
||||
case 3: return "gla";
|
||||
case 4: return "mrd";
|
||||
case 7: return "arc";
|
||||
case 8: return "lnc";
|
||||
case 22: return "thm";
|
||||
case 23: return "cnj";
|
||||
case 29: return "crp";
|
||||
case 30: return "bsm";
|
||||
case 31: return "arm";
|
||||
case 32: return "gsm";
|
||||
case 33: return "ltw";
|
||||
case 34: return "wvr";
|
||||
case 35: return "alc";
|
||||
case 36: return "cul";
|
||||
case 39: return "min";
|
||||
case 40: return "btn";
|
||||
case 41: return "fsh";
|
||||
default: return "undefined";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
281
Map Server/Utils/NavmeshUtils.cs
Normal file
281
Map Server/Utils/NavmeshUtils.cs
Normal file
|
@ -0,0 +1,281 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SharpNav;
|
||||
using SharpNav.Pathfinding;
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Map.utils
|
||||
{
|
||||
class NavmeshUtils
|
||||
{
|
||||
|
||||
// navmesh
|
||||
public static bool CanSee(actors.area.Zone zone, float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
// todo: prolly shouldnt raycast
|
||||
var navMesh = zone.tiledNavMesh;
|
||||
if (navMesh != null)
|
||||
{
|
||||
var navMeshQuery = zone.navMeshQuery;
|
||||
|
||||
NavPoint startPt, endPt;
|
||||
SharpNav.Pathfinding.Path path = new SharpNav.Pathfinding.Path();
|
||||
|
||||
RaycastHit hit = new RaycastHit();
|
||||
|
||||
SharpNav.Geometry.Vector3 c = new SharpNav.Geometry.Vector3(x1, y1, z1);
|
||||
SharpNav.Geometry.Vector3 ep = new SharpNav.Geometry.Vector3(x2, y2, z2);
|
||||
|
||||
SharpNav.Geometry.Vector3 e = new SharpNav.Geometry.Vector3(5, 5, 5);
|
||||
navMeshQuery.FindNearestPoly(ref c, ref e, out startPt);
|
||||
navMeshQuery.FindNearestPoly(ref ep, ref e, out endPt);
|
||||
|
||||
|
||||
if (navMeshQuery.Raycast(ref startPt, ref ep, RaycastOptions.None, out hit, path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static SharpNav.TiledNavMesh LoadNavmesh(TiledNavMesh navmesh, string filePath)
|
||||
{
|
||||
SharpNav.IO.NavMeshSerializer serializer;
|
||||
if (System.IO.Path.GetExtension(filePath) == ".snb")
|
||||
serializer = new SharpNav.IO.Binary.NavMeshBinarySerializer();
|
||||
else
|
||||
serializer = new SharpNav.IO.Json.NavMeshJsonSerializer();
|
||||
|
||||
return serializer.Deserialize(System.IO.Path.Combine("../../navmesh/", filePath));
|
||||
//return navmesh = new SharpNav.IO.Json.NavMeshJsonSerializer().Deserialize(filePath);
|
||||
}
|
||||
|
||||
public static List<Vector3> GetPath(actors.area.Zone zone, float x, float y, float z, float targetX, float targetY, float targetZ, float stepSize = 0.70f, int pathSize = 45, float polyRadius = 0.0f, bool skipToTarget = false)
|
||||
{
|
||||
return GetPath(zone, new Vector3(x, y, z), new Vector3(targetX, targetY, targetZ), stepSize, pathSize, polyRadius, skipToTarget);
|
||||
}
|
||||
|
||||
#region sharpnav stuff
|
||||
// Copyright (c) 2013-2016 Robert Rouhani <robert.rouhani@gmail.com> and other contributors (see CONTRIBUTORS file).
|
||||
// Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
|
||||
|
||||
public static List<Vector3> GetPath(actors.area.Zone zone, Vector3 startVec, Vector3 endVec, float stepSize = 0.70f, int pathSize = 45, float polyRadius = 0.0f, bool skipToTarget = false)
|
||||
{
|
||||
var navMesh = zone.tiledNavMesh;
|
||||
var navMeshQuery = zone.navMeshQuery;
|
||||
|
||||
// no navmesh loaded, run straight to player
|
||||
if (navMesh == null)
|
||||
{
|
||||
return new List<Vector3>() { endVec };
|
||||
}
|
||||
|
||||
// no need to waste cycles finding path to same point
|
||||
if (startVec.X == endVec.X && startVec.Y == endVec.Y && startVec.Z == endVec.Z && polyRadius == 0.0f)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var smoothPath = new List<Vector3>(pathSize) { };
|
||||
|
||||
NavQueryFilter filter = new NavQueryFilter();
|
||||
|
||||
NavPoint startPt, endPt;
|
||||
|
||||
try
|
||||
{
|
||||
SharpNav.Geometry.Vector3 c = new SharpNav.Geometry.Vector3(startVec.X, startVec.Y, startVec.Z);
|
||||
SharpNav.Geometry.Vector3 ep = new SharpNav.Geometry.Vector3(endVec.X, endVec.Y, endVec.Z);
|
||||
|
||||
SharpNav.Geometry.Vector3 e = new SharpNav.Geometry.Vector3(5, 5, 5);
|
||||
navMeshQuery.FindNearestPoly(ref c, ref e, out startPt);
|
||||
navMeshQuery.FindNearestPoly(ref ep, ref e, out endPt);
|
||||
|
||||
//calculate the overall path, which contains an array of polygon references
|
||||
int MAX_POLYS = 256;
|
||||
var path = new SharpNav.Pathfinding.Path();
|
||||
|
||||
navMeshQuery.FindPath(ref startPt, ref endPt, filter, path);
|
||||
|
||||
//find a smooth path over the mesh surface
|
||||
int npolys = path.Count;
|
||||
SharpNav.Geometry.Vector3 iterPos = new SharpNav.Geometry.Vector3();
|
||||
SharpNav.Geometry.Vector3 targetPos = new SharpNav.Geometry.Vector3();
|
||||
navMeshQuery.ClosestPointOnPoly(startPt.Polygon, startPt.Position, ref iterPos);
|
||||
navMeshQuery.ClosestPointOnPoly(path[npolys - 1], endPt.Position, ref targetPos);
|
||||
|
||||
// set target to random point at end of path
|
||||
if (polyRadius != 0.0f)
|
||||
{
|
||||
var randPoly = navMeshQuery.FindRandomPointAroundCircle(endPt, polyRadius);
|
||||
targetPos = randPoly.Position;
|
||||
}
|
||||
|
||||
if (skipToTarget)
|
||||
{
|
||||
return new List<Vector3>() { new Vector3(targetPos.X, targetPos.Y, targetPos.Z) };
|
||||
}
|
||||
smoothPath.Add(new Vector3(iterPos.X, iterPos.Y, iterPos.Z));
|
||||
|
||||
//float STEP_SIZE = 0.70f;
|
||||
float SLOP = 0.15f;
|
||||
while (npolys > 0 && smoothPath.Count < smoothPath.Capacity)
|
||||
{
|
||||
//find location to steer towards
|
||||
SharpNav.Geometry.Vector3 steerPos = new SharpNav.Geometry.Vector3();
|
||||
StraightPathFlags steerPosFlag = 0;
|
||||
NavPolyId steerPosRef = NavPolyId.Null;
|
||||
|
||||
if (!GetSteerTarget(navMeshQuery, iterPos, targetPos, SLOP, path, ref steerPos, ref steerPosFlag, ref steerPosRef))
|
||||
break;
|
||||
|
||||
bool endOfPath = (steerPosFlag & StraightPathFlags.End) != 0 ? true : false;
|
||||
bool offMeshConnection = (steerPosFlag & StraightPathFlags.OffMeshConnection) != 0 ? true : false;
|
||||
|
||||
//find movement delta
|
||||
SharpNav.Geometry.Vector3 delta = steerPos - iterPos;
|
||||
float len = (float)Math.Sqrt(SharpNav.Geometry.Vector3.Dot(delta, delta));
|
||||
|
||||
//if steer target is at end of path or off-mesh link
|
||||
//don't move past location
|
||||
if ((endOfPath || offMeshConnection) && len < stepSize)
|
||||
len = 1;
|
||||
else
|
||||
len = stepSize / len;
|
||||
|
||||
SharpNav.Geometry.Vector3 moveTgt = new SharpNav.Geometry.Vector3();
|
||||
VMad(ref moveTgt, iterPos, delta, len);
|
||||
|
||||
//move
|
||||
SharpNav.Geometry.Vector3 result = new SharpNav.Geometry.Vector3();
|
||||
List<NavPolyId> visited = new List<NavPolyId>(pathSize);
|
||||
NavPoint startPoint = new NavPoint(path[0], iterPos);
|
||||
navMeshQuery.MoveAlongSurface(ref startPoint, ref moveTgt, out result, visited);
|
||||
path.FixupCorridor(visited);
|
||||
npolys = path.Count;
|
||||
float h = 0;
|
||||
navMeshQuery.GetPolyHeight(path[0], result, ref h);
|
||||
result.Y = h;
|
||||
iterPos = result;
|
||||
|
||||
//handle end of path when close enough
|
||||
if (endOfPath && InRange(iterPos, steerPos, SLOP, 1000.0f))
|
||||
{
|
||||
//reached end of path
|
||||
iterPos = targetPos;
|
||||
if (smoothPath.Count < smoothPath.Capacity)
|
||||
{
|
||||
smoothPath.Add(new Vector3(iterPos.X, iterPos.Y, iterPos.Z));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//store results
|
||||
if (smoothPath.Count < smoothPath.Capacity)
|
||||
{
|
||||
smoothPath.Add(new Vector3(iterPos.X, iterPos.Y, iterPos.Z));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Program.Log.Error(e.Message);
|
||||
Program.Log.Error("Start pos {0} {1} {2} end pos {3} {4} {5}", startVec.X, startVec.Y, startVec.Z, endVec.X, endVec.Y, endVec.Z);
|
||||
// todo: probably log this
|
||||
return new List<Vector3>() { endVec };
|
||||
}
|
||||
return smoothPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scaled vector addition
|
||||
/// </summary>
|
||||
/// <param name="dest">Result</param>
|
||||
/// <param name="v1">Vector 1</param>
|
||||
/// <param name="v2">Vector 2</param>
|
||||
/// <param name="s">Scalar</param>
|
||||
private static void VMad(ref SharpNav.Geometry.Vector3 dest, SharpNav.Geometry.Vector3 v1, SharpNav.Geometry.Vector3 v2, float s)
|
||||
{
|
||||
dest.X = v1.X + v2.X * s;
|
||||
dest.Y = v1.Y + v2.Y * s;
|
||||
dest.Z = v1.Z + v2.Z * s;
|
||||
}
|
||||
|
||||
private static bool GetSteerTarget(NavMeshQuery navMeshQuery, SharpNav.Geometry.Vector3 startPos, SharpNav.Geometry.Vector3 endPos, float minTargetDist, SharpNav.Pathfinding.Path path,
|
||||
ref SharpNav.Geometry.Vector3 steerPos, ref StraightPathFlags steerPosFlag, ref NavPolyId steerPosRef)
|
||||
{
|
||||
StraightPath steerPath = new StraightPath();
|
||||
navMeshQuery.FindStraightPath(startPos, endPos, path, steerPath, 0);
|
||||
int nsteerPath = steerPath.Count;
|
||||
if (nsteerPath == 0)
|
||||
return false;
|
||||
|
||||
//find vertex far enough to steer to
|
||||
int ns = 0;
|
||||
while (ns < nsteerPath)
|
||||
{
|
||||
if ((steerPath[ns].Flags & StraightPathFlags.OffMeshConnection) != 0 ||
|
||||
!InRange(steerPath[ns].Point.Position, startPos, minTargetDist, 1000.0f))
|
||||
break;
|
||||
|
||||
ns++;
|
||||
}
|
||||
|
||||
//failed to find good point to steer to
|
||||
if (ns >= nsteerPath)
|
||||
return false;
|
||||
|
||||
steerPos = steerPath[ns].Point.Position;
|
||||
steerPos.Y = startPos.Y;
|
||||
steerPosFlag = steerPath[ns].Flags;
|
||||
if (steerPosFlag == StraightPathFlags.None && ns == (nsteerPath - 1))
|
||||
steerPosFlag = StraightPathFlags.End; // otherwise seeks path infinitely!!!
|
||||
steerPosRef = steerPath[ns].Point.Polygon;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool InRange(SharpNav.Geometry.Vector3 v1, SharpNav.Geometry.Vector3 v2, float r, float h)
|
||||
{
|
||||
float dx = v2.X - v1.X;
|
||||
float dy = v2.Y - v1.Y;
|
||||
float dz = v2.Z - v1.Z;
|
||||
return (dx * dx + dz * dz) < (r * r) && Math.Abs(dy) < h;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Vector3 GamePosToNavmeshPos(float x, float y, float z)
|
||||
{
|
||||
return new Vector3(x, -z, y);
|
||||
}
|
||||
|
||||
public static Vector3 NavmeshPosToGamePos(float x, float y, float z)
|
||||
{
|
||||
return new Vector3(x, z, -y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
421
Map Server/Utils/SQLGeneration.cs
Normal file
421
Map Server/Utils/SQLGeneration.cs
Normal file
|
@ -0,0 +1,421 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using Meteor.Common;
|
||||
using Meteor.Map.packets.send.player;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Meteor.Map.utils
|
||||
{
|
||||
class SQLGeneration
|
||||
{
|
||||
|
||||
public static void GenerateZones()
|
||||
{
|
||||
|
||||
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 = @"
|
||||
INSERT INTO server_zones VALUES (@id, NULL, @placename, false, false, false, false)";
|
||||
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@id", 100);
|
||||
cmd.Parameters.AddWithValue("@placename", "");
|
||||
|
||||
cmd.Prepare();
|
||||
|
||||
Dictionary<uint, string> placenames = new Dictionary<uint, string>();
|
||||
|
||||
string line2;
|
||||
Regex csvSplit2 = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);
|
||||
System.IO.StreamReader file2 = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\xtx_placeName.csv");
|
||||
while ((line2 = file2.ReadLine()) != null)
|
||||
{
|
||||
MatchCollection matches = csvSplit2.Matches(line2);
|
||||
|
||||
uint id;
|
||||
string name;
|
||||
|
||||
try
|
||||
{
|
||||
id = UInt32.Parse(matches[0].Value.Trim(','));
|
||||
name = matches[2].Value.Trim(',');
|
||||
|
||||
}
|
||||
catch (FormatException)
|
||||
{ continue; }
|
||||
|
||||
placenames.Add(id, name);
|
||||
|
||||
}
|
||||
|
||||
string line;
|
||||
Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);
|
||||
System.IO.StreamReader file = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\_zoneParam.csv");
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
MatchCollection matches = csvSplit.Matches(line);
|
||||
|
||||
uint id;
|
||||
uint pId;
|
||||
|
||||
try
|
||||
{
|
||||
id = UInt32.Parse(matches[0].Value.Trim(','));
|
||||
pId = UInt32.Parse(matches[1].Value.Trim(','));
|
||||
}
|
||||
catch (FormatException)
|
||||
{ continue; }
|
||||
|
||||
cmd.Parameters["@id"].Value = id;
|
||||
|
||||
cmd.Parameters["@placename"].Value = placenames[pId];
|
||||
|
||||
Program.Log.Debug("Wrote: {0}", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateActors()
|
||||
{
|
||||
|
||||
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 = @"
|
||||
INSERT INTO gamedata_actor_templates VALUES (@id, @displayNameId, NULL)";
|
||||
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@id", 100);
|
||||
cmd.Parameters.AddWithValue("@displayNameId", 100);
|
||||
|
||||
cmd.Prepare();
|
||||
|
||||
string line, line2;
|
||||
Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);
|
||||
System.IO.StreamReader file = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\actorclass.csv");
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
MatchCollection matches = csvSplit.Matches(line);
|
||||
|
||||
uint id;
|
||||
uint nameId;
|
||||
|
||||
try
|
||||
{
|
||||
id = UInt32.Parse(matches[0].Value.Trim(','));
|
||||
nameId = UInt32.Parse(matches[6].Value.Trim(','));
|
||||
|
||||
}
|
||||
catch (FormatException)
|
||||
{ continue; }
|
||||
|
||||
cmd.Parameters["@id"].Value = id;
|
||||
cmd.Parameters["@displayNameId"].Value = nameId;
|
||||
|
||||
Program.Log.Debug("Wrote: {0} : {1}", id, nameId);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateActorAppearance()
|
||||
{
|
||||
uint NUMFIELDS = 39;
|
||||
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 = @"
|
||||
INSERT INTO gamedata_actor_appearance VALUES (@id, ";
|
||||
|
||||
for (int i = 0; i < NUMFIELDS-1; i++)
|
||||
query += "@v"+i+", ";
|
||||
|
||||
query += "@v" + (NUMFIELDS-1) + ")";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@id", 0);
|
||||
|
||||
for (int i = 0; i < NUMFIELDS; i++)
|
||||
cmd.Parameters.AddWithValue("@v" + i, 100);
|
||||
|
||||
cmd.Prepare();
|
||||
|
||||
string line;
|
||||
Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);
|
||||
//System.IO.StreamReader file = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\actorclass.csv");
|
||||
System.IO.StreamReader file = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\actorclass_graphic.csv");
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
MatchCollection matches = csvSplit.Matches(line);
|
||||
|
||||
uint id;
|
||||
|
||||
try
|
||||
{
|
||||
id = UInt32.Parse(matches[0].Value.Trim(','));
|
||||
|
||||
for (int i = 0; i < NUMFIELDS; i++)
|
||||
cmd.Parameters["@v" + i].Value = matches[i + 7].Value.Trim(',');
|
||||
|
||||
|
||||
}
|
||||
catch (FormatException)
|
||||
{ continue; }
|
||||
|
||||
cmd.Parameters["@id"].Value = id;
|
||||
|
||||
Program.Log.Debug("Wrote: {0}", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void GenerateAchievementIds()
|
||||
{
|
||||
|
||||
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 = @"
|
||||
INSERT INTO gamedata_achievements VALUES (@id, @name, @otherId, @rewardPoints)";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
cmd.Parameters.AddWithValue("@id", 100);
|
||||
cmd.Parameters.AddWithValue("@name", "Battle");
|
||||
cmd.Parameters.AddWithValue("@otherId", 0);
|
||||
cmd.Parameters.AddWithValue("@rewardPoints", 0);
|
||||
cmd.Prepare();
|
||||
|
||||
int otherId = 1;
|
||||
string line, line2;
|
||||
Regex csvSplit = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)", RegexOptions.Compiled);
|
||||
System.IO.StreamReader file = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\achievement.csv");
|
||||
System.IO.StreamReader file2 = new System.IO.StreamReader("D:\\Coding\\FFXIV Related\\FFXIV Tool\\2012.09.19.0001.decode.csv\\xtx_achievement.csv");
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
line2 = file2.ReadLine();
|
||||
MatchCollection matches = csvSplit.Matches(line);
|
||||
MatchCollection matches2 = csvSplit.Matches(line2);
|
||||
uint id;
|
||||
string name;
|
||||
uint points;
|
||||
try
|
||||
{
|
||||
id = UInt32.Parse(matches2[0].Value.Trim(','));
|
||||
name = matches2[9].Value.Trim(',');
|
||||
points = UInt32.Parse(matches[3].Value.Trim(','));
|
||||
}
|
||||
catch (FormatException)
|
||||
{ continue; }
|
||||
|
||||
if (id == 100)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_BATTLE;
|
||||
else if (id == 200)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_CHARACTER;
|
||||
else if (id == 400)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_CURRENCY;
|
||||
else if (id == 500)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_ITEMS;
|
||||
else if (id == 600)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_SYNTHESIS;
|
||||
else if (id == 700)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_GATHERING;
|
||||
else if (id == 900)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_MATERIA;
|
||||
else if (id == 1000)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_QUESTS;
|
||||
else if (id == 1200)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_SEASONAL_EVENTS;
|
||||
else if (id == 1300)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_DUNGEONS;
|
||||
else if (id == 1400)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_EXPLORATION;
|
||||
else if (id == 1500)
|
||||
otherId = SetCompletedAchievementsPacket.CATEGORY_GRAND_COMPANY;
|
||||
|
||||
Program.Log.Debug("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points);
|
||||
cmd.Parameters["@id"].Value = id;
|
||||
cmd.Parameters["@name"].Value = name;
|
||||
cmd.Parameters["@otherId"].Value = otherId;
|
||||
cmd.Parameters["@rewardPoints"].Value = points;
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
otherId++;
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void GetStaticActors()
|
||||
{
|
||||
using (MemoryStream s = new MemoryStream(File.ReadAllBytes("D:\\luadec\\script\\staticactorr9w.luab")))
|
||||
{
|
||||
using (BinaryReader binReader = new BinaryReader(s))
|
||||
{
|
||||
|
||||
using (StreamWriter w = File.AppendText("D:\\myfile.txt"))
|
||||
{
|
||||
|
||||
|
||||
while (binReader.BaseStream.Position != binReader.BaseStream.Length)
|
||||
{
|
||||
uint id = Utils.SwapEndian(binReader.ReadUInt32()) | 0xA0F00000;
|
||||
|
||||
List<byte> list = new List<byte>();
|
||||
byte readByte;
|
||||
|
||||
while ((readByte = binReader.ReadByte()) != 0)
|
||||
{ //or whatever your condition is
|
||||
list.Add(readByte);
|
||||
}
|
||||
|
||||
string output = Encoding.UTF8.GetString(list.ToArray());
|
||||
|
||||
string output2 = String.Format("mStaticActors.Add(0x{0:x}, new {2}(0x{0:x}, \"{1}\"));", id, output.Substring(1 + output.LastIndexOf("/")), output.Split('/')[1]);
|
||||
|
||||
Program.Log.Debug(output2);
|
||||
w.WriteLine(output2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static void GenerateScriptsForNPCs()
|
||||
{
|
||||
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 uniqueId FROM server_spawn_locations WHERE zoneId = 206";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
string name = reader.GetString("uniqueId");
|
||||
|
||||
if (name == null || name.Equals(""))
|
||||
continue;
|
||||
|
||||
string nameCapital = name.Substring(0, 1).ToUpper() + name.Substring(1);
|
||||
|
||||
string template = File.ReadAllText("D:\\Coding\\FFXIV Related\\ffxiv-classic-map-server\\FFXIVClassic Map Server\\bin\\Debug\\scripts\\unique\\wil0Town01\\PopulaceStandard\\bertram.lua");
|
||||
|
||||
template = template.Replace("defaultWil", "defaultFst");
|
||||
template = template.Replace("DftWil", "DftFst");
|
||||
template = template.Replace("Bertram", nameCapital);
|
||||
|
||||
File.WriteAllText(String.Format("D:\\Coding\\FFXIV Related\\ffxiv-classic-map-server\\FFXIVClassic Map Server\\bin\\Debug\\scripts\\unique\\fst0Town01a\\PopulaceStandard\\{0}.lua", name), template);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Program.Log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue