Skip to content

Commit f604a13

Browse files
author
mekolat
authored
Merge pull request #226 from mekolat/settiles
Implement SMSG_MAP_SET_TILES_TYPE
2 parents 8c380d5 + 6d5919b commit f604a13

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

src/map/clif.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -3925,6 +3925,24 @@ void clif_remote_command(dumb_ptr<map_session_data> sd, XString cmd)
39253925
clif_send(buf, sd, SendWho::SELF, wrap<ClientVersion>(6));
39263926
}
39273927

3928+
void clif_update_collision(dumb_ptr<map_session_data> sd, short x1, short y1,
3929+
short x2, short y2, MapName map_name, int mask)
3930+
{
3931+
nullpo_retv(sd);
3932+
3933+
Packet_Fixed<0x0231> fixed_231;
3934+
fixed_231.x1 = x1;
3935+
fixed_231.y1 = y1;
3936+
fixed_231.x2 = x2;
3937+
fixed_231.y2 = y2;
3938+
fixed_231.mask = mask;
3939+
fixed_231.unused_layer = 0;
3940+
fixed_231.map = map_name;
3941+
Buffer buf = create_fpacket<0x0231, 34>(fixed_231);
3942+
3943+
clif_send(buf, sd, SendWho::SELF, wrap<ClientVersion>(7));
3944+
}
3945+
39283946
void clif_change_music(dumb_ptr<map_session_data> sd, XString music)
39293947
{
39303948
nullpo_retv(sd);

src/map/clif.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ void clif_setnpcdirection_towards(dumb_ptr<map_session_data> sd, dumb_ptr<npc_da
107107
void clif_npc_send_title(Session *s, BlockId npcid, XString msg);
108108
void clif_server_message(dumb_ptr<map_session_data>, uint8_t, XString msg);
109109
void clif_remote_command(dumb_ptr<map_session_data>, XString);
110+
void clif_update_collision(dumb_ptr<map_session_data>, short, short, short, short, MapName, int);
110111
void clif_change_music(dumb_ptr<map_session_data> sd, XString music);
111112
void clif_npc_action(dumb_ptr<map_session_data>, BlockId, short, int, short, short);
112113
void clif_send_mask(dumb_ptr<map_session_data>, int);

src/map/script-fun.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,38 @@ void builtin_remotecmd(ScriptState *st)
41864186
clif_remote_command(sd, msg);
41874187
}
41884188

4189+
static
4190+
void builtin_sendcollision(ScriptState *st)
4191+
{
4192+
dumb_ptr<map_session_data> sd = script_rid2sd(st);
4193+
MapName map_name = stringish<MapName>(ZString(conv_str(st, &AARG(0))));
4194+
int mask = conv_num(st, &AARG(1));
4195+
short x1, y1, x2, y2;
4196+
x1 = x2 = conv_num(st, &AARG(2));
4197+
y1 = y2 = conv_num(st, &AARG(3));
4198+
4199+
if (HARG(5))
4200+
{
4201+
x2 = conv_num(st, &AARG(4));
4202+
y2 = conv_num(st, &AARG(5));
4203+
if (HARG(6))
4204+
{
4205+
CharName player = stringish<CharName>(ZString(conv_str(st, &AARG(6))));
4206+
sd = map_nick2sd(player);
4207+
}
4208+
}
4209+
4210+
else if (HARG(4))
4211+
{
4212+
CharName player = stringish<CharName>(ZString(conv_str(st, &AARG(4))));
4213+
sd = map_nick2sd(player);
4214+
}
4215+
4216+
if (sd == nullptr)
4217+
return;
4218+
clif_update_collision(sd, x1, y1, x2, y2, map_name, mask);
4219+
}
4220+
41894221
static
41904222
void builtin_music(ScriptState *st)
41914223
{
@@ -4818,6 +4850,7 @@ BuiltinFunction builtin_functions[] =
48184850
BUILTIN(title, "s"_s, '\0'),
48194851
BUILTIN(smsg, "e??"_s, '\0'),
48204852
BUILTIN(remotecmd, "s?"_s, '\0'),
4853+
BUILTIN(sendcollision, "Mixy???"_s, '\0'),
48214854
BUILTIN(music, "s"_s, '\0'),
48224855
BUILTIN(mapmask, "i?"_s, '\0'),
48234856
BUILTIN(getmask, ""_s, 'i'),

tools/protocol.py

+20
Original file line numberDiff line numberDiff line change
@@ -4796,6 +4796,26 @@ def build_context():
47964796
Execute a client command remotely
47974797
''',
47984798
)
4799+
map_user.s(0x0231, 'send area collision',
4800+
define='SMSG_MAP_SET_TILES_TYPE',
4801+
fixed=[
4802+
at(0, u16, 'packet id'),
4803+
at(2, u16, 'x1'),
4804+
at(4, u16, 'y1'),
4805+
at(6, u16, 'x2'),
4806+
at(8, u16, 'y2'),
4807+
at(10, u32, 'mask'),
4808+
at(14, u32, 'unused layer'),
4809+
at(18, map_name, 'map'),
4810+
],
4811+
fixed_size=34,
4812+
pre=[NOTHING],
4813+
post=[PRETTY],
4814+
desc='''
4815+
Set updated collision for a square area
4816+
''',
4817+
)
4818+
47994819

48004820
# TOC_LOGINCHAR
48014821
# login char

0 commit comments

Comments
 (0)