From 4944491228bc3ba1bcfaf581fbeef825c1c39a72 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Thu, 20 Dec 2018 19:26:02 +0100 Subject: [PATCH] Added support for viewpointvalue command (#3754) Additionally added a script command to update the player's camera. Added a new atcommand camerainfo for this, which is limited to admins. Credits to @4144 for finding /setcamera --- conf/atcommand_athena.conf | 1 + conf/help.txt | 1 + conf/msg_conf/map_msg.conf | 4 +++- doc/packet_struct_notation.txt | 1 + doc/script_commands.txt | 22 ++++++++++++++++++++++ src/common/socket.hpp | 2 ++ src/map/atcommand.cpp | 27 +++++++++++++++++++++++++++ src/map/clif.cpp | 33 +++++++++++++++++++++++++++++++++ src/map/clif.hpp | 2 ++ src/map/clif_packetdb.hpp | 6 ++++++ src/map/script.cpp | 18 ++++++++++++++++++ 11 files changed, 116 insertions(+), 1 deletion(-) diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf index 53eff8088b..8747ed0622 100644 --- a/conf/atcommand_athena.conf +++ b/conf/atcommand_athena.conf @@ -64,6 +64,7 @@ aliases: { clonestat: ["stclone"] reloadnpcfile: ["reloadnpc"] changedress: ["nocosplay"] + camerainfo: ["viewpointvalue", "setcamera"] } /* Commands help file */ diff --git a/conf/help.txt b/conf/help.txt index 2e23110a7e..1e3464054e 100644 --- a/conf/help.txt +++ b/conf/help.txt @@ -325,3 +325,4 @@ reload: "Params: \n" "Reload a database or configuration file.\n" langtype: "Params: \n" "Changes your language setting." limitedsale: "Opens the limited sale window." changedress: "Removes all character costumes." +camerainfo: "Shows or updates the client's camera settings." diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index 1c7bb4f3e1..fdf8cab283 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -855,7 +855,9 @@ // Private Airship 792: The private airship system is disabled. -//793-899 free +793: Usage @camerainfo range rotation latitude + +//794-899 free //------------------------------------ // More atcommands message diff --git a/doc/packet_struct_notation.txt b/doc/packet_struct_notation.txt index aeddee1568..4657baa40c 100644 --- a/doc/packet_struct_notation.txt +++ b/doc/packet_struct_notation.txt @@ -59,6 +59,7 @@ values. B = 1 byte (byte) W = 2 bytes (word) L = 4 bytes (long, dword) + F = 4 bytes (float) Q = 8 bytes (quad) nB = n bytes diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 7a568711e1..ee08cde531 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -7659,6 +7659,28 @@ and attempt to execute a source-defined command. The three .@atcmd_***** variables will NOT be set when invoking script-bound atcommands in this way. +--------------------------------------- + +*camerainfo ,,{,}; + +This command will update the client's camera information with the given values where +the client can be the attached character or the player given by the char id parameter. +Note: This requires 2016-05-25aRagexeRE or newer. + +The values given will be divided by 100 and transmitted as floating-point number. + + range The zoomfactor of the camera. + Default: 230000 (230.0) when fully zoomed in + Maximum: 400000 (400.0) when fully zoomed out + + rotation The rotation of the camera. + Default: 0 (0.0) when no rotation is applied + Maximum: 360000 (360.0°) when fully rotated + + latitude The angle of the camera. + Default: -50000 (-50.0) + Maximum: -75000 (-75.0) + --------------------------------------- \\ 6,1.- Unit-related commands diff --git a/src/common/socket.hpp b/src/common/socket.hpp index 4b0df74bae..88d967f43f 100644 --- a/src/common/socket.hpp +++ b/src/common/socket.hpp @@ -32,6 +32,8 @@ #define WFIFOW(fd,pos) (*(uint16*)WFIFOP(fd,pos)) #define RFIFOL(fd,pos) (*(uint32*)RFIFOP(fd,pos)) #define WFIFOL(fd,pos) (*(uint32*)WFIFOP(fd,pos)) +#define RFIFOF(fd,pos) (*(float*)RFIFOP(fd,pos)) +#define WFIFOF(fd,pos) (*(float*)WFIFOP(fd,pos)) #define RFIFOQ(fd,pos) (*(uint64*)RFIFOP(fd,pos)) #define WFIFOQ(fd,pos) (*(uint64*)WFIFOP(fd,pos)) #define RFIFOSPACE(fd) (session[fd]->max_rdata - session[fd]->rdata_size) diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 6548584f9b..4bdb46c213 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -10002,6 +10002,32 @@ ACMD_FUNC(limitedsale){ return 0; } +/** + * Displays camera information from the client. + * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients + */ +ACMD_FUNC(camerainfo){ + nullpo_retr(-1, sd); + + if( message == nullptr || message[0] == '\0' ){ + clif_camerainfo( sd, true ); + return 0; + } + + float range = 0; + float rotation = 0; + float latitude = 0; + + if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){ + clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude + return -1; + } + + clif_camerainfo( sd, false, range, rotation, latitude ); + + return 0; +} + #include "../custom/atcommand.inc" /** @@ -10301,6 +10327,7 @@ void atcommand_basecommands(void) { ACMD_DEF(agitend3), ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE), ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE), + ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE), }; AtCommandInfo* atcommand; int i; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index ec6ec3c9c1..ca47f472c1 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -20565,6 +20565,39 @@ void clif_guild_storage_log( struct map_session_data* sd, std::vector.B .F .F .F +void clif_camerainfo( struct map_session_data* sd, bool show, float range, float rotation, float latitude ){ +#if PACKETVER >= 20160525 + int fd = sd->fd; + + WFIFOHEAD(fd, packet_len(0xa78)); + WFIFOW(fd, 0) = 0xa78; + WFIFOB(fd, 2) = show; + WFIFOF(fd, 3) = range; + WFIFOF(fd, 7) = rotation; + WFIFOF(fd, 11) = latitude; + WFIFOSET(fd, packet_len(0xa78)); +#endif +} + +/// Activates or deactives the client camera info or updates the camera settings. +/// This packet is triggered by /viewpointvalue or /setcamera +/// 0A77 .B .F .F .F +void clif_parse_camerainfo( int fd, struct map_session_data* sd ){ + char command[CHAT_SIZE_MAX]; + + // /viewpointvalue + if( RFIFOB( fd, 2 ) == 1 ){ + safesnprintf( command, sizeof( command ), "%ccamerainfo", atcommand_symbol ); + // /setcamera + }else{ + safesnprintf( command, sizeof( command ), "%ccamerainfo %03.03f %03.03f %03.03f", atcommand_symbol, RFIFOF( fd, 3 ), RFIFOF( fd, 7 ), RFIFOF( fd, 11 ) ); + } + + is_atcommand( fd, sd, command, 1 ); +} + /*========================================== * Main client packet processing function *------------------------------------------*/ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index a171564a27..183cca24bf 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -1101,4 +1101,6 @@ void clif_weight_limit( struct map_session_data* sd ); void clif_guild_storage_log( struct map_session_data* sd, std::vector& log, enum e_guild_storage_log result ); +void clif_camerainfo( struct map_session_data* sd, bool show, float range = 0.0f, float rotation = 0.0f, float latitude = 0.0f ); + #endif /* CLIF_HPP */ diff --git a/src/map/clif_packetdb.hpp b/src/map/clif_packetdb.hpp index 54eaf97b81..d92a9b2bad 100644 --- a/src/map/clif_packetdb.hpp +++ b/src/map/clif_packetdb.hpp @@ -2317,6 +2317,12 @@ parseable_packet(0x0A6E,-1,clif_parse_Mail_send,2,4,28,52,60,62,64,68); // CZ_REQ_WRITE_MAIL2 #endif +// 2016-05-25aRagexeRE +#if PACKETVER >= 20160525 + parseable_packet(0x0A77,15,clif_parse_camerainfo,0); + packet(0x0A78, 15); +#endif + // 2016-06-01aRagexe #if PACKETVER >= 20160601 packet(0x0A7D,-1); diff --git a/src/map/script.cpp b/src/map/script.cpp index 01a1a05afd..0e8212efc4 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -24043,6 +24043,23 @@ BUILDIN_FUNC(is_party_leader) return SCRIPT_CMD_SUCCESS; } +BUILDIN_FUNC( camerainfo ){ +#if PACKETVER < 20160525 + ShowError("buildin_camerainfo: This command requires PACKETVER 2016-05-25 or newer.\n"); + return SCRIPT_CMD_FAILURE; +#else + struct map_session_data* sd; + + if( !script_charid2sd( 5, sd ) ){ + return SCRIPT_CMD_FAILURE; + } + + clif_camerainfo( sd, false, script_getnum( st, 2 ) / 100.0f, script_getnum( st, 3 ) / 100.0f, script_getnum( st, 4 ) / 100.0f ); + + return SCRIPT_CMD_SUCCESS; +#endif +} + #include "../custom/script.inc" // declarations that were supposed to be exported from npc_chat.c @@ -24705,6 +24722,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(identifyall,"??"), BUILDIN_DEF(is_guild_leader,"?"), BUILDIN_DEF(is_party_leader,"?"), + BUILDIN_DEF(camerainfo,"iii?"), #include "../custom/script_def.inc" {NULL,NULL,NULL},