summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c624
-rw-r--r--src/map/clif.c43
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/map.c4
4 files changed, 282 insertions, 390 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 213f864d5..dec6131a6 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8,12 +8,13 @@
#include <math.h>
#include <limits.h>
-#include "../common/socket.h"
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/mmo.h"
#include "../common/core.h"
#include "../common/showmsg.h"
+#include "../common/malloc.h"
+#include "../common/socket.h"
#include "atcommand.h"
#include "log.h"
@@ -1069,48 +1070,30 @@ int atcommand_send(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- int i,type=0;
+ int type=0;
int info[20];
-
- if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
+
+ malloc_tsetdword(info,0,sizeof(info));
+
+ if (!message || !*message || sscanf(message,
+ "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
+ &type,
+ &info[0], &info[1], &info[2], &info[3], &info[4],
+ &info[5], &info[6], &info[7], &info[8], &info[9],
+ &info[10], &info[11], &info[12], &info[13], &info[14],
+ &info[15], &info[16], &info[17], &info[18], &info[19]) < 1)
+ {
clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
return -1;
}
- if (type > 0 && type < MAX_PACKET_DB) {
-
- switch (type)
- {
- case 0x209: {
- WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
- WFIFOW(fd,0) = 0x209;
- WFIFOW(fd,2) = 2;
- memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
- WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
- break;
- }
- case 0x1b1:
- case 0x1c2:
- //case xxx:
- // add others here
- // break;
- default: {
- WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
- WFIFOW(fd,0) = type;
- for(i=1;i<=sizeof(info);i++)
- if(info[i])
- WFIFOW(fd,i) = info[i];
- WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
- break;
- }
- }
-
- sprintf (atcmd_output, msg_txt(258), type, type);
- clif_displaymessage(fd, atcmd_output);
- } else {
+ if (!clif_send_debug(sd, type, info, sizeof(info)/sizeof(int)))
+ {
clif_displaymessage(fd, msg_txt(259));
+ return -1;
}
-
+ sprintf (atcmd_output, msg_txt(258), type, type);
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8819,27 +8802,6 @@ int atcommand_misceffect(
return 0;
}
-int charid2sessionid(int charid)
-{
- struct map_session_data *pl_sd = NULL;
-
- pl_sd = map_charid2sd(charid);
- if (pl_sd) return pl_sd->fd;
-
- return 0;
-}
-
-int accountid2sessionid(int accountid)
-{
- struct map_session_data *pl_sd = NULL;
-
- pl_sd = map_id2sd(accountid);
- if (pl_sd) return pl_sd->fd;
-
- return 0;
-}
-
-
/*==========================================
* Jump to a player by PID number
* Original by Dino9021
@@ -8852,44 +8814,36 @@ int atcommand_jumptoid(
const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
- sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
-
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+
+ pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
+ sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8905,44 +8859,36 @@ int atcommand_jumptoid2(
const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
- sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+ pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
+ sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8957,49 +8903,43 @@ int atcommand_recallid(
const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -9014,49 +8954,42 @@ int atcommand_recallid2(
const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
return -1;
}
- aid=atoi(message);
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can recall only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -9072,38 +9005,25 @@ int atcommand_kickid(
{
struct map_session_data *pl_sd;
int cid=0;
- int session_id=0;
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
return -1;
}
+
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
- clif_GM_kick(sd, pl_sd, 1);
- else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kick only lower or same gm level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ clif_GM_kick(sd, pl_sd, 1);
return 0;
}
@@ -9119,38 +9039,23 @@ int atcommand_kickid2(
{
struct map_session_data *pl_sd;
int aid=0;
- int session_id=0;
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
- clif_GM_kick(sd, pl_sd, 1);
- else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
-
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kick only lower or same gm level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ clif_GM_kick(sd, pl_sd, 1);
return 0;
}
@@ -9165,42 +9070,23 @@ int atcommand_reviveid(
const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- pl_sd->status.hp = pl_sd->status.max_hp;
- pc_setstand(pl_sd);
- if (battle_config.pc_invincible_time > 0)
- pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
- clif_updatestatus(pl_sd, SP_HP);
- clif_updatestatus(pl_sd, SP_SP);
- clif_resurrection(&pl_sd->bl, 1);
- clif_displaymessage(fd, msg_txt(51)); // Character revived.
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
-
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if(!status_revive(&pl_sd->bl, 100, 100))
+ return -1;
+ clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(fd, msg_txt(51)); // Character revived.
return 0;
}
@@ -9215,42 +9101,25 @@ int atcommand_reviveid2(
const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- pl_sd->status.hp = pl_sd->status.max_hp;
- pc_setstand(pl_sd);
- if (battle_config.pc_invincible_time > 0)
- pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
- clif_updatestatus(pl_sd, SP_HP);
- clif_updatestatus(pl_sd, SP_SP);
- clif_resurrection(&pl_sd->bl, 1);
- clif_displaymessage(fd, msg_txt(51)); // Character revived.
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
+ pl_sd = map_id2sd(aid);
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ if(!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if(!status_revive(&pl_sd->bl, 100, 100))
+ return -1;
+ clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(fd, msg_txt(51)); // Character revived.
return 0;
}
@@ -9265,40 +9134,28 @@ int atcommand_killid(
const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
- status_kill(&pl_sd->bl);
- clif_displaymessage(fd, msg_txt(14)); // Character killed.
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
+ pl_sd = map_charid2sd(cid);
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kill only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ status_kill(&pl_sd->bl);
+ clif_displaymessage(fd, msg_txt(14)); // Character killed.
return 0;
}
@@ -9313,40 +9170,27 @@ int atcommand_killid2(
const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
- status_kill(&pl_sd->bl);
- clif_displaymessage(fd, msg_txt(14)); // Character killed.
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kill only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+
+ status_kill(&pl_sd->bl);
+ clif_displaymessage(fd, msg_txt(14)); // Character killed.
return 0;
}
@@ -9363,28 +9207,30 @@ atcommand_charkillableid(
{
struct map_session_data *pl_sd = NULL;
int cid=0;
- int session_id=0;
- if (!message || (cid = atoi(message)) == 0 || !*message)
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID.");
return -1;
+ }
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
- return -1;
+ pl_sd = map_charid2sd(cid);
+
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
- pl_sd->state.killable = !pl_sd->state.killable;
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
- if(pl_sd->state.killable)
- clif_displaymessage(fd, msg_txt(289));
- else
- clif_displaymessage(fd, msg_txt(290));
- }
- else
- clif_displaymessage(fd,msg_txt(3));
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ pl_sd->state.killable = !pl_sd->state.killable;
+ if(pl_sd->state.killable)
+ clif_displaymessage(fd, msg_txt(289));
+ else
+ clif_displaymessage(fd, msg_txt(290));
return 0;
}
@@ -9402,28 +9248,32 @@ atcommand_charkillableid2(
{
struct map_session_data *pl_sd = NULL;
int aid=0;
- int session_id=0;
- if (!message || (aid = atoi(message)) == 0 || !*message)
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID.");
return -1;
+ }
- aid=atoi(message);
+ pl_sd = map_id2sd(aid);
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
- return -1;
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
- pl_sd->state.killable = !pl_sd->state.killable;
+ pl_sd->state.killable = !pl_sd->state.killable;
+
+ if(pl_sd->state.killable)
+ clif_displaymessage(fd, msg_txt(289));
+ else
+ clif_displaymessage(fd, msg_txt(290));
- if(pl_sd->state.killable)
- clif_displaymessage(fd, msg_txt(289));
- else
- clif_displaymessage(fd, msg_txt(290));
- }
- else
- clif_displaymessage(fd,msg_txt(3));
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
return 0;
}
@@ -9646,13 +9496,13 @@ int atcommand_mobinfo(
*/
int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
{
- struct map_session_data *sd;
+ struct map_session_data *sd;
- if (!session[id] || (sd = session[id]->session_data) == NULL)
- return 0;
+ if (!session[id] || (sd = session[id]->session_data) == NULL)
+ return 0;
- clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
- return 1;
+ clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
+ return 1;
}
static int atshowmobs_sub(struct block_list *bl,va_list ap)
{
diff --git a/src/map/clif.c b/src/map/clif.c
index 548369d5d..8e468515d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -618,6 +618,47 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
return 0;
}
+//For use in the @send command.
+int clif_send_debug(struct map_session_data *sd, int cmd, int* args, int args_num)
+{
+ int fd = sd->fd;
+ int len;
+ if (cmd < 0 || cmd >= MAX_PACKET_DB)
+ return 0;
+
+ len = packet_db[sd->packet_ver][cmd].len;
+
+ if (!fd || !len || len == -1) //len -1, variable width, not supported!
+ return 0;
+
+ switch (cmd)
+ {
+ case 0x209:
+ {
+ WFIFOHEAD(fd, len);
+ WFIFOW(fd,0) = 0x209;
+ WFIFOW(fd,2) = 2;
+ memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
+ WFIFOSET(fd, len);
+ break;
+ }
+ default:
+ {
+ int i;
+ WFIFOHEAD(fd, len);
+ memset(WFIFOP(fd,0), 0, len);
+ WFIFOW(fd,0) = cmd;
+ //Packet can only have len/2 arguments. Since each arg is a Word
+ if (args_num > len/2 -2)
+ args_num = len/2 -2;
+ for(i=0; i<args_num; i++)
+ WFIFOW(fd,i+1) = args[i];
+ WFIFOSET(fd, len);
+ break;
+ }
+ }
+ return 1;
+}
//
// パケット作って送信
//
@@ -4234,7 +4275,7 @@ int clif_01ac(struct block_list *bl)
sd=va_arg(ap,struct map_session_data*);
- if (sd == NULL || session[sd->fd] == NULL)
+ if (sd == NULL || !sd->fd || session[sd->fd] == NULL)
return 0;
switch(bl->type){
diff --git a/src/map/clif.h b/src/map/clif.h
index 5d1294825..5ba025065 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -320,6 +320,7 @@ int clif_pet_performance(struct block_list *bl,int param);
int clif_pet_equip(struct pet_data *pd);
int clif_pet_food(struct map_session_data *sd,int foodid,int fail);
int clif_send (unsigned char *buf, int len, struct block_list *bl, int type);
+int clif_send_debug(struct map_session_data *sd, int cmd, int* args, int args_num);
//friends list
int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap);
diff --git a/src/map/map.c b/src/map/map.c
index 12039e914..e5f266b9e 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -963,7 +963,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list),int m,int x0,i
for(i=blockcount;i<bl_list_count;i++)
if(bl_list[i]->prev) { // 有?かどうかチェック
if (bl_list[i]->type == BL_PC
- && session[((struct map_session_data *) bl_list[i])->fd] == NULL)
+ && ((TBL_PC*) bl_list[i])->fd == 0)
continue;
returnCount += func(bl_list[i],ap);
}
@@ -1713,7 +1713,7 @@ int map_quit(struct map_session_data *sd) {
if(charsave_method)
{ //Let player be free'd on closing the connection.
idb_remove(pc_db,sd->status.account_id);
- if (!(sd->fd && session[sd->fd]->session_data))
+ if (!(sd->fd && session[sd->fd]->session_data == sd))
aFree(sd); //In case player was not attached to session.
return 0;
}