|
From: Crossfire C. r. messages.
<cro...@li...> - 2020-11-24 22:07:51
|
Revision: 21563
http://sourceforge.net/p/crossfire/code/21563
Author: partmedia
Date: 2020-11-24 22:07:50 +0000 (Tue, 24 Nov 2020)
Log Message:
-----------
Report relative coordinates for 'request map pos'
Modified Paths:
--------------
client/trunk/common/mapdata.c
client/trunk/common/mapdata.h
client/trunk/common/script.c
Modified: client/trunk/common/mapdata.c
===================================================================
--- client/trunk/common/mapdata.c 2020-11-23 14:18:12 UTC (rev 21562)
+++ client/trunk/common/mapdata.c 2020-11-24 22:07:50 UTC (rev 21563)
@@ -25,6 +25,12 @@
#include "mapdata.h"
/**
+ * Position of a player on the map, relative to the coordinates received
+ * after a 'newmap' command. These are kept to for reporting to client scripts.
+ */
+PlayerPosition script_pos;
+
+/**
* Size of virtual map.
*/
#define FOG_MAP_SIZE 512
@@ -914,6 +920,8 @@
void mapdata_scroll(int dx, int dy)
{
+ script_pos.x += dx;
+ script_pos.y += dy;
int x, y;
recenter_virtual_map_view(dx, dy);
@@ -987,6 +995,8 @@
void mapdata_newmap(void)
{
+ script_pos.x = 0;
+ script_pos.y = 0;
int x, y;
/* Clear the_map.cells[]. */
Modified: client/trunk/common/mapdata.h
===================================================================
--- client/trunk/common/mapdata.h 2020-11-23 14:18:12 UTC (rev 21562)
+++ client/trunk/common/mapdata.h 2020-11-24 22:07:50 UTC (rev 21563)
@@ -151,4 +151,6 @@
gint16 mapdata_bigface_head(int x, int y, int layer, int *ww, int *hh);
void mapdata_animation(void);
+extern PlayerPosition script_pos;
+
#endif
Modified: client/trunk/common/script.c
===================================================================
--- client/trunk/common/script.c 2020-11-23 14:18:12 UTC (rev 21562)
+++ client/trunk/common/script.c 2020-11-24 22:07:50 UTC (rev 21563)
@@ -1369,7 +1369,8 @@
if (strncmp(c, "pos", 3) == 0) {
char buf[1024];
- snprintf(buf, sizeof(buf), "request map pos %d %d\n", pl_pos.x+use_config[CONFIG_MAPWIDTH]/2, pl_pos.y+use_config[CONFIG_MAPHEIGHT]/2);
+ snprintf(buf, sizeof(buf), "request map pos %d %d\n",
+ script_pos.x, script_pos.y);
write(scripts[i].out_fd, buf, strlen(buf));
} else if (strncmp(c, "near", 4) == 0) {
for (y = 0; y < 3; ++y)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|