-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handling of systemmessages, load systemmessage data from dat
- Loading branch information
Showing
25 changed files
with
5,978 additions
and
78 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
l2-unity/Assets/Scripts/Database/Model/SystemMessageDat.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class SystemMessageDat | ||
{ | ||
private int _id; | ||
private string _message; | ||
private int _group; | ||
private string _color; | ||
|
||
public int Id { get { return _id; } set { _id = value; } } | ||
public string Message { get { return _message; } set { _message = value; } } | ||
public int Group { get { return _group; } set { _group = value; } } | ||
public string Color { get { return _color; } set { _color = value; } } | ||
} |
2 changes: 1 addition & 1 deletion
2
...hat/MessageTypes/MessageLoggedOut.cs.meta → ...s/Database/Model/SystemMessageDat.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
|
||
public class SystemMessageTable { | ||
private static SystemMessageTable _instance; | ||
public static SystemMessageTable Instance { | ||
get { | ||
if (_instance == null) { | ||
_instance = new SystemMessageTable(); | ||
} | ||
|
||
return _instance; | ||
} | ||
} | ||
|
||
private Dictionary<int, SystemMessageDat> _systemMessages; | ||
public Dictionary<int, SystemMessageDat> SystemMessages { get { return _systemMessages; } } | ||
|
||
public void Initialize() { | ||
ReadDatFile(); | ||
} | ||
|
||
private void ReadDatFile() { | ||
_systemMessages = new Dictionary<int, SystemMessageDat>(); | ||
string dataPath = Path.Combine(Application.streamingAssetsPath, "Data/Meta/SystemMsg_Classic-eu.txt"); | ||
if (!File.Exists(dataPath)) { | ||
Debug.LogWarning("File not found: " + dataPath); | ||
return; | ||
} | ||
|
||
using (StreamReader reader = new StreamReader(dataPath)) { | ||
string line; | ||
while ((line = reader.ReadLine()) != null) { | ||
SystemMessageDat systemMessage = new SystemMessageDat(); | ||
|
||
string[] keyvals = line.Split('\t'); | ||
|
||
for (int i = 0; i < keyvals.Length; i++) { | ||
if (!keyvals[i].Contains("=")) { | ||
continue; | ||
} | ||
|
||
string[] keyval = keyvals[i].Split("="); | ||
string key = keyval[0]; | ||
string value = keyval[1]; | ||
|
||
switch (key) { | ||
case "id": | ||
systemMessage.Id = int.Parse(value); | ||
break; | ||
case "message": | ||
systemMessage.Message = value.Replace("[", "").Replace("]", ""); | ||
break; | ||
case "color": | ||
systemMessage.Color = value; | ||
string r = systemMessage.Color.Substring(0, 2); | ||
string g = systemMessage.Color.Substring(2, 2); | ||
string b = systemMessage.Color.Substring(4, 2); | ||
string a = systemMessage.Color.Substring(6, 2); | ||
systemMessage.Color = b + g + r + "B0"; | ||
break; | ||
case "group": | ||
systemMessage.Group = int.Parse(value); | ||
break; | ||
} | ||
} | ||
|
||
_systemMessages.TryAdd(systemMessage.Id, systemMessage); | ||
} | ||
|
||
Debug.Log($"Successfully imported {_systemMessages.Count} system message(s)"); | ||
} | ||
} | ||
|
||
public SystemMessageDat GetSystemMessage(int id) { | ||
SystemMessageDat message; | ||
_systemMessages.TryGetValue(id, out message); | ||
return message; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...UI/Game/Chat/MessageTypes/Message.cs.meta → ...ripts/Database/SystemMessageTable.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
l2-unity/Assets/Scripts/Networking/ClientLibrary/Model/SMParam.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class SMParam { | ||
public enum SMParamType { | ||
TYPE_SYSTEM_STRING = 13, | ||
TYPE_PLAYER_NAME = 12, | ||
TYPE_DOOR_NAME = 11, | ||
TYPE_INSTANCE_NAME = 10, | ||
TYPE_ELEMENT_NAME = 9, | ||
// id 8 - same as 3 | ||
TYPE_ZONE_NAME = 7, | ||
TYPE_LONG_NUMBER = 6, | ||
TYPE_CASTLE_NAME = 5, | ||
TYPE_SKILL_NAME = 4, | ||
TYPE_ITEM_NAME = 3, | ||
TYPE_NPC_NAME = 2, | ||
TYPE_INT_NUMBER = 1, | ||
TYPE_TEXT = 0 | ||
} | ||
|
||
private SMParamType _type; | ||
private object _value; | ||
|
||
public SMParamType Type { get { return _type; } set { _type = value;} } | ||
|
||
public SMParam(SMParamType type, object value) { | ||
_type = type; | ||
_value = value; | ||
} | ||
|
||
public SMParam(SMParamType type) { | ||
_type = type; | ||
} | ||
|
||
public void SetValue(object value) { | ||
this._value = value; | ||
} | ||
|
||
public string GetStringValue() { | ||
return (string)_value; | ||
} | ||
|
||
public int GetIntValue() { | ||
return (int)_value; | ||
} | ||
|
||
public long GetLongValue() { | ||
return (long)_value; | ||
} | ||
|
||
public int[] GetIntArrayValue() { | ||
return (int[])_value; | ||
} | ||
|
||
public float[] GetFloatArrayValue() { | ||
return (float[])_value; | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...ame/Chat/MessageTypes/MessageType.cs.meta → ...rking/ClientLibrary/Model/SMParam.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
l2-unity/Assets/Scripts/Networking/ClientLibrary/Model/SystemMessageId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class SystemMessageId : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
|
||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...Chat/MessageTypes/MessageLoggedIn.cs.meta → ...ientLibrary/Model/SystemMessageId.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
70 changes: 53 additions & 17 deletions
70
...s/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/SystemMessagePacket.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.