2019-06-18 22:55:32 -04:00
|
|
|
|
/*
|
|
|
|
|
===========================================================================
|
|
|
|
|
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/>.
|
|
|
|
|
===========================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
2019-06-19 01:10:15 -04:00
|
|
|
|
using Meteor.Map.lua;
|
2016-01-02 14:03:28 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2019-06-19 00:05:18 -04:00
|
|
|
|
using Meteor.Common;
|
2016-08-22 10:43:04 -04:00
|
|
|
|
|
2019-06-19 01:10:15 -04:00
|
|
|
|
namespace Meteor.Map.packets.send.actor
|
2016-01-02 14:03:28 -05:00
|
|
|
|
{
|
|
|
|
|
class ActorInstantiatePacket
|
|
|
|
|
{
|
|
|
|
|
public const ushort OPCODE = 0x00CC;
|
|
|
|
|
public const uint PACKET_SIZE = 0x128;
|
|
|
|
|
|
2017-06-27 13:23:05 -04:00
|
|
|
|
public static SubPacket BuildPacket(uint sourceActorId, string objectName, string className, List<LuaParam> initParams)
|
2016-01-02 14:03:28 -05:00
|
|
|
|
{
|
|
|
|
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
|
|
|
|
|
|
|
|
|
using (MemoryStream mem = new MemoryStream(data))
|
|
|
|
|
{
|
|
|
|
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
|
|
|
|
{
|
2016-03-30 20:15:21 -04:00
|
|
|
|
int value1 = 0x00; //Instance ID?
|
|
|
|
|
int value2 = 0x3040;
|
2016-02-07 13:05:54 -05:00
|
|
|
|
binWriter.Write((Int16)value1);
|
|
|
|
|
binWriter.Write((Int16)value2);
|
2016-01-02 14:03:28 -05:00
|
|
|
|
binWriter.Write(Encoding.ASCII.GetBytes(objectName), 0, Encoding.ASCII.GetByteCount(objectName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(objectName));
|
|
|
|
|
binWriter.BaseStream.Seek(0x24, SeekOrigin.Begin);
|
|
|
|
|
binWriter.Write(Encoding.ASCII.GetBytes(className), 0, Encoding.ASCII.GetByteCount(className) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(className));
|
|
|
|
|
binWriter.BaseStream.Seek(0x44, SeekOrigin.Begin);
|
2016-06-14 21:29:10 +01:00
|
|
|
|
LuaUtils.WriteLuaParams(binWriter, initParams);
|
2016-01-02 14:03:28 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-27 13:23:05 -04:00
|
|
|
|
return new SubPacket(OPCODE, sourceActorId, data);
|
2016-01-02 14:03:28 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|