From 82c08317f6e0eb0f2f9432a8f78955f9d12bb4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 8 Jun 2010 19:09:54 +0200 Subject: [PATCH] game: Improved mission start handling. --- include/maps.hrl | 13 ++++++------ p/packet1015_mission.bin | Bin 8252 -> 0 bytes src/egs_game.erl | 42 ++++++++++++++++++++++++--------------- 3 files changed, 33 insertions(+), 22 deletions(-) delete mode 100644 p/packet1015_mission.bin diff --git a/include/maps.hrl b/include/maps.hrl index 199db7f..d23b5a3 100644 --- a/include/maps.hrl +++ b/include/maps.hrl @@ -19,16 +19,17 @@ %% EGS maps settings. -define(QUESTS, [ - % Current test mission + % Missions - {1000013, [{type, mission}, {file, "data/missions/test.quest.nbl"}]}, + {1000013, [{type, mission}, {file, "data/missions/test.quest.nbl"}, {start, [0, 1121, 0]}]}, % Planetary lobbies - {1100000, [{type, lobby}, {file, "data/lobby/colony.quest.nbl"}]}, - {1101000, [{type, lobby}, {file, "data/lobby/parum.quest.nbl"}]}, - {1102000, [{type, lobby}, {file, "data/lobby/neudaiz.quest.nbl"}]}, - {1103000, [{type, lobby}, {file, "data/lobby/moatoob.quest.nbl"}]}, + {1100000, [{type, lobby}, {file, "data/lobby/colony.quest.nbl"}]}, + {1101000, [{type, lobby}, {file, "data/lobby/parum.quest.nbl"}]}, + {1102000, [{type, lobby}, {file, "data/lobby/neudaiz.quest.nbl"}]}, + {1103000, [{type, lobby}, {file, "data/lobby/moatoob.quest.nbl"}]}, + {1104000, [{type, spaceport}, {file, "data/lobby/spaceport.quest.nbl"}]} ]). diff --git a/p/packet1015_mission.bin b/p/packet1015_mission.bin deleted file mode 100644 index f1ddc30f0c0d87b3003417a7de26dada16cc2cf8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8252 zcmeI1cTiK?7RH02g(4yJCP-HhLCU2nQiOympcDlH(jig=9z`UfDkvZ&bSX-+0t!T0 zXd+cE5D}0n3P=@!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zhlMMgaFFw7^A3_R87cB$e={`hESTOapnN3p{tHom>^QI5 zt0QOnLs&8f(SzrSb#@OB?R7Gicwso5nuffiolEdo69dvCiDs`Xfy-&{<$;#8LEp=# zB3piyUZm-;>2T;I_0x@5~4ePWi#1#voG<`r{XnGhlXiy9V_L*xf z7x4UHrdEOO-3m!}Z$&fXST>bTL^ekUo0act%1^mCaFy28VU}1vaog9YB_;Ugtof6s z0unE!75mF%>AMA(3O6{~74olP^kxSXi$igDN=6ZKD(oURjz9(8!j0-l&rzxZKifzA z&01Z)>8mr@CCouV+vJf-f_U#H2Zm0V(TlZ+Rf1#x;0b;S7!rCEi+_eMGIhp>%hj81 zn5L|Kk;0oZPF?YSR=VqqD?q{Al0>R#wMk{Z-44;*EO+>Ba|tnO&b8bf<+~r}dNPA% ztVQ0(CTK3P2fbGI$Zlqk>b?y8P{?(<2GNem{HN#JeR$Q112OPLHK%|OYP&ra*)4aT zXcBh?k|>BgJT(vy8Olx1y|ZzT2g070%*99~o!muDF!UUoPK)ek_LCqTD({#_7ubRO zz-Pb<6`D_Q-Pxl44XPCIXjaR>!SJ1L>?X~QEHYY!{1*#(-?F(YzmHhrI_un0EwDqLk*Fo|^b zs($d!rKXQb+8qU_r`s*z&P80%UG+)-EHPDrM{|eE#cdBWElsSlG^o#Ie|qFxqq{1o zfBJ47P0{oa6x4^S>8F1tn6IP!#Ocy-Xa%ruf{+1wv=M#{?6Yz&&fl3`mQ3h#HMOkX z>f`DSZj)N#^jVb~eq!FuL=9E%&z-juA3E)VtJZb z|FiuO^ss{7oDb+yGGkIRL`|V*u{~nt*o(V*n7~ z)q^O&b$}dzdjKSWVSq7!_W;`f^uTj|ZUAY3d3vCaGAIsE9H2Nrae(3g#ex5e1HS{( CE)gaG diff --git a/src/egs_game.erl b/src/egs_game.erl index c23c858..f838243 100644 --- a/src/egs_game.erl +++ b/src/egs_game.erl @@ -253,7 +253,7 @@ lobby_load(CSocket, GID, QuestID, ZoneID, MapID, EntryID) -> User = OldUser#users{instanceid=undefined, questid=QuestID, zoneid=ZoneID, mapid=MapID, entryid=EntryID}, egs_db:users_insert(User), [{status, 1}, {char, Char}, {options, _}] = data_load(User#users.folder, User#users.charnumber), - [{type, AreaType}, {file, QuestFile}] = proplists:get_value(QuestID, ?QUESTS, [{type, lobby}, {file, "data/lobby/colony.quest.nbl"}]), + [{type, AreaType}, {file, QuestFile}|_] = proplists:get_value(QuestID, ?QUESTS, [{type, lobby}, {file, "data/lobby/colony.quest.nbl"}]), [{file, ZoneFile}] = proplists:get_value([QuestID, ZoneID], ?ZONES, [{file, "data/lobby/colony.zone-0.nbl"}]), [{name, AreaName}] = proplists:get_value([QuestID, MapID], ?MAPS, [{name, "dammy"}]), try @@ -300,14 +300,14 @@ lobby_load(CSocket, GID, QuestID, ZoneID, MapID, EntryID) -> %% @todo One of the silenced packets enable a 04xx command sent by the client and related to enemies sync. Probably 1202. %% @todo Maybe the quest doesn't work right because of the lack of this odd checksum-like value. -mission_load(CSocket, GID, QuestID, ZoneID, MapID, EntryID) -> +mission_load(CSocket, GID, QuestID, _, _, _) -> OldUser = egs_db:users_select(GID), - User = OldUser#users{instanceid=GID, questid=QuestID, zoneid=ZoneID, mapid=MapID, entryid=EntryID}, - egs_db:users_insert(User), - [{status, 1}, {char, Char}, {options, _}] = data_load(User#users.folder, User#users.charnumber), - [{type, AreaType}, {file, QuestFile}] = proplists:get_value(QuestID, ?QUESTS, [{type, lobby}, {file, "data/missions/test.quest.nbl"}]), + [{status, 1}, {char, Char}, {options, _}] = data_load(OldUser#users.folder, OldUser#users.charnumber), + [{type, AreaType}, {file, QuestFile}, {start, [ZoneID, MapID, EntryID]}] = proplists:get_value(QuestID, ?QUESTS, [{type, missions}, {file, "data/missions/test.quest.nbl"}, {start, [0, 0, 0]}]), [{file, ZoneFile}] = proplists:get_value([QuestID, ZoneID], ?ZONES, [{file, "data/missions/test.zone.nbl"}]), [{name, AreaName}] = proplists:get_value([QuestID, MapID], ?MAPS, [{name, "dammy"}]), + User = OldUser#users{instanceid=GID, questid=QuestID, zoneid=ZoneID, mapid=MapID, entryid=EntryID}, + egs_db:users_insert(User), try egs_proto:send_init_quest(CSocket, GID, QuestID), egs_proto:send_quest(CSocket, QuestFile), @@ -600,6 +600,7 @@ handle(16#0402, _, _, _, _) -> %% @doc Map change handler. %% Rooms are handled differently than normal lobbies. +%% When entering a mission the values other than quest are all 65535. Find the actual start area and load it. %% @todo Load 'Your room' correctly. %% @todo When changing lobby to the room, 0230 must also be sent. Same when going from room to lobby. %% @todo The mission loading here is a temporary one-mission only choice. @@ -608,13 +609,16 @@ handle(16#0807, CSocket, GID, _, Orig) -> << _:352, QuestID:32/little-unsigned-integer, ZoneID:16/little-unsigned-integer, MapID:16/little-unsigned-integer, EntryID:16/little-unsigned-integer, _/bits >> = Orig, log(GID, "lobby change (~b,~b,~b,~b)", [QuestID, ZoneID, MapID, EntryID]), - case QuestID of - 1000013 -> - mission_load(CSocket, GID, 1000013, 0, 1121, 0); - 1120000 -> - myroom_load(CSocket, GID, QuestID, ZoneID, 423, EntryID); + case ZoneID of + 65535 -> + mission_load(CSocket, GID, QuestID, ZoneID, MapID, EntryID); _ -> - lobby_load(CSocket, GID, QuestID, ZoneID, MapID, EntryID) + case QuestID of + 1120000 -> + myroom_load(CSocket, GID, QuestID, ZoneID, 423, EntryID); + _ -> + lobby_load(CSocket, GID, QuestID, ZoneID, MapID, EntryID) + end end; %% @doc Mission counter handler. @@ -640,7 +644,7 @@ handle(16#0c01, CSocket, GID, _, Orig) -> log(GID, "start mission ~b", [QuestID]), send_packet_170c(CSocket, GID), egs_proto:packet_send(CSocket, << 16#10200300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64 >>), - send_packet_1015(CSocket), + send_packet_1015(CSocket, GID, QuestID), Packet = << 16#0c020300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:96 >>, egs_proto:packet_send(CSocket, Packet); @@ -966,10 +970,16 @@ send_packet_1006(CSocket, GID, N) -> Packet = << 16#10060300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, N:32/little-unsigned-integer >>, egs_proto:packet_send(CSocket, Packet). -%% @todo Handle correctly. +%% @doc Send the mission's quest file when starting a new mission. +%% @todo Handle correctly. 0:32 is actually a missing value. Value before that is unknown too. -send_packet_1015(CSocket) -> - myroom_send_packet(CSocket, "p/packet1015_mission.bin"). +send_packet_1015(CSocket, GID, QuestID) -> + [{type, _}, {file, QuestFile}|_] = proplists:get_value(QuestID, ?QUESTS, [{type, missions}, {file, "data/missions/test.quest.nbl"}, {start, [0, 0, 0]}]), + {ok, File} = file:read_file(QuestFile), + Size = byte_size(File), + Packet = << 16#10150300:32, 0:160, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, + QuestID:32/little-unsigned-integer, 16#01010000:32, 0:32, Size:32/little-unsigned-integer, File/binary >>, + egs_proto:packet_send(CSocket, Packet). %% @todo Figure out what this packet does. Sane values for counter and missions for now.