summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-02 04:21:35 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-02 04:21:35 +0000
commit0698f0b34299624e6ac535442b4e7b8894dd8167 (patch)
treee99840f5ad111c4fb7828f1f0d054e157a315e03 /src
parent5a6cc045a38a775943b29ca5903520c96935f2d1 (diff)
downloadhercules-0698f0b34299624e6ac535442b4e7b8894dd8167.tar.gz
hercules-0698f0b34299624e6ac535442b4e7b8894dd8167.tar.bz2
hercules-0698f0b34299624e6ac535442b4e7b8894dd8167.tar.xz
hercules-0698f0b34299624e6ac535442b4e7b8894dd8167.zip
- Replaced @send with the version I use for testing packets.
Can display the packet length. Supports dynamic packets, quoted strings with escaped characters and fixed/variable length, and normal/hex byte/word/long data types. The number of fields is not limited, but it automatically stops parsing when the packet is full. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9387 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/common/socket.h4
-rw-r--r--src/map/atcommand.c21411
-rw-r--r--src/map/clif.c24643
3 files changed, 23112 insertions, 22946 deletions
diff --git a/src/common/socket.h b/src/common/socket.h
index eb3a78f7e..9552575f3 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -72,6 +72,10 @@ extern time_t stall_time;
#define WBUFW(p,pos) (*(unsigned short*)((p) + (pos)))
#define WBUFL(p,pos) (*(unsigned long*)((p) + (pos)))
+#define TOB(n) ((unsigned char)(n))
+#define TOW(n) ((unsigned short)(n))
+#define TOL(n) ((unsigned long)(n))
+
//FD_SETSIZE must be modified on the project files/Makefile, since a change here won't affect
// dependant windows libraries.
/*
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index ee243669b..a4badbaef 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1,10604 +1,10807 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-#include <limits.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"
-#include "clif.h"
-#include "chrif.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "map.h"
-#include "pc.h"
-#include "status.h"
-#include "skill.h"
-#include "mob.h"
-#include "pet.h"
-#include "mercenary.h" //[orn]
-#include "battle.h"
-#include "party.h"
-#include "guild.h"
-#include "script.h"
-#include "npc.h"
-#include "trade.h"
-#include "unit.h"
-
-#ifndef TXT_ONLY
-#include "mail.h"
-#endif
-
-static char command_symbol = '@'; // first char of the commands (by [Yor])
-
-char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
-
-#define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
-ACMD_FUNC(broadcast);
-ACMD_FUNC(localbroadcast);
-ACMD_FUNC(rura);
-ACMD_FUNC(where);
-ACMD_FUNC(jumpto);
-ACMD_FUNC(jump);
-ACMD_FUNC(who);
-ACMD_FUNC(who2);
-ACMD_FUNC(who3);
-ACMD_FUNC(whomap);
-ACMD_FUNC(whomap2);
-ACMD_FUNC(whomap3);
-ACMD_FUNC(whogm); // by Yor
-ACMD_FUNC(whozeny); // [Valaris]
-ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
-ACMD_FUNC(save);
-ACMD_FUNC(load);
-ACMD_FUNC(speed);
-ACMD_FUNC(charspeed);
-ACMD_FUNC(storage);
-ACMD_FUNC(guildstorage);
-ACMD_FUNC(option);
-ACMD_FUNC(hide);
-ACMD_FUNC(jobchange);
-ACMD_FUNC(die);
-ACMD_FUNC(kill);
-ACMD_FUNC(alive);
-ACMD_FUNC(kami);
-ACMD_FUNC(heal);
-ACMD_FUNC(item);
-ACMD_FUNC(item2);
-ACMD_FUNC(itemreset);
-ACMD_FUNC(baselevelup);
-ACMD_FUNC(joblevelup);
-ACMD_FUNC(help);
-ACMD_FUNC(help2);
-ACMD_FUNC(gm);
-ACMD_FUNC(pvpoff);
-ACMD_FUNC(pvpon);
-ACMD_FUNC(gvgoff);
-ACMD_FUNC(gvgon);
-ACMD_FUNC(model);
-ACMD_FUNC(go);
-ACMD_FUNC(monster);
-ACMD_FUNC(monstersmall);
-ACMD_FUNC(monsterbig);
-ACMD_FUNC(spawn);
-ACMD_FUNC(killmonster);
-ACMD_FUNC(killmonster2);
-ACMD_FUNC(refine);
-ACMD_FUNC(produce);
-ACMD_FUNC(memo);
-ACMD_FUNC(gat);
-ACMD_FUNC(packet);
-ACMD_FUNC(waterlevel);
-ACMD_FUNC(statuspoint);
-ACMD_FUNC(skillpoint);
-ACMD_FUNC(zeny);
-ACMD_FUNC(param);
-ACMD_FUNC(guildlevelup);
-ACMD_FUNC(makeegg);
-ACMD_FUNC(hatch);
-ACMD_FUNC(petfriendly);
-ACMD_FUNC(pethungry);
-ACMD_FUNC(petrename);
-ACMD_FUNC(recall);
-ACMD_FUNC(recallall);
-ACMD_FUNC(revive);
-ACMD_FUNC(night);
-ACMD_FUNC(day);
-ACMD_FUNC(doom);
-ACMD_FUNC(doommap);
-ACMD_FUNC(raise);
-ACMD_FUNC(raisemap);
-ACMD_FUNC(kick);
-ACMD_FUNC(kickall);
-ACMD_FUNC(allskill);
-ACMD_FUNC(questskill);
-ACMD_FUNC(lostskill);
-ACMD_FUNC(spiritball);
-ACMD_FUNC(party);
-ACMD_FUNC(guild);
-ACMD_FUNC(agitstart);
-ACMD_FUNC(agitend);
-ACMD_FUNC(reloaditemdb);
-ACMD_FUNC(reloadmobdb);
-ACMD_FUNC(reloadskilldb);
-ACMD_FUNC(reloadscript);
-ACMD_FUNC(reloadgmdb); // by Yor
-ACMD_FUNC(reloadatcommand);
-ACMD_FUNC(reloadbattleconf);
-ACMD_FUNC(reloadstatusdb);
-ACMD_FUNC(reloadpcdb);
-ACMD_FUNC(reloadmotd); // [Valaris]
-ACMD_FUNC(mapexit);
-ACMD_FUNC(idsearch);
-ACMD_FUNC(mapinfo);
-ACMD_FUNC(dye); //** by fritz
-ACMD_FUNC(hair_style); //** by fritz
-ACMD_FUNC(hair_color); //** by fritz
-ACMD_FUNC(stat_all); //** by fritz
-ACMD_FUNC(char_block); // by Yor
-ACMD_FUNC(char_ban); // by Yor
-ACMD_FUNC(char_unblock); // by Yor
-ACMD_FUNC(char_unban); // by Yor
-ACMD_FUNC(mount_peco); // by Valaris
-ACMD_FUNC(char_mount_peco); // by Yor
-ACMD_FUNC(guildspy); // [Syrus22]
-ACMD_FUNC(partyspy); // [Syrus22]
-ACMD_FUNC(repairall); // [Valaris]
-ACMD_FUNC(guildrecall); // by Yor
-ACMD_FUNC(partyrecall); // by Yor
-ACMD_FUNC(nuke); // [Valaris]
-ACMD_FUNC(shownpc);
-ACMD_FUNC(hidenpc);
-ACMD_FUNC(loadnpc);
-ACMD_FUNC(unloadnpc);
-ACMD_FUNC(servertime); // by Yor
-ACMD_FUNC(chardelitem); // by Yor
-ACMD_FUNC(jail); // by Yor
-ACMD_FUNC(unjail); // by Yor
-ACMD_FUNC(jailfor); // Alias Meruru
-ACMD_FUNC(jailtime); // Coltaro
-ACMD_FUNC(charjailtime); // Coltaro
-ACMD_FUNC(disguise); // [Valaris]
-ACMD_FUNC(undisguise); // by Yor
-ACMD_FUNC(chardisguise); // Kalaspuff
-ACMD_FUNC(charundisguise); // Kalaspuff
-ACMD_FUNC(email); // by Yor
-ACMD_FUNC(effect);//by Apple
-ACMD_FUNC(character_cart_list); // by Yor
-ACMD_FUNC(addwarp); // by MouseJstr
-ACMD_FUNC(follow); // by MouseJstr
-ACMD_FUNC(skillon); // by MouseJstr
-ACMD_FUNC(skilloff); // by MouseJstr
-ACMD_FUNC(killer); // by MouseJstr
-ACMD_FUNC(npcmove); // by MouseJstr
-ACMD_FUNC(killable); // by MouseJstr
-ACMD_FUNC(charkillable); // by MouseJstr
-ACMD_FUNC(dropall); // by MouseJstr
-ACMD_FUNC(chardropall); // by MouseJstr
-ACMD_FUNC(storeall); // by MouseJstr
-ACMD_FUNC(charstoreall); // by MouseJstr
-ACMD_FUNC(skillid); // by MouseJstr
-ACMD_FUNC(useskill); // by MouseJstr
-ACMD_FUNC(summon);
-ACMD_FUNC(rain);
-ACMD_FUNC(snow);
-ACMD_FUNC(sakura);
-ACMD_FUNC(clouds);
-ACMD_FUNC(clouds2); // [Valaris]
-ACMD_FUNC(fog);
-ACMD_FUNC(fireworks);
-ACMD_FUNC(leaves);
-ACMD_FUNC(adjgmlvl); // by MouseJstr
-ACMD_FUNC(adjcmdlvl); // by MouseJstr
-ACMD_FUNC(trade); // by MouseJstr
-ACMD_FUNC(send); // by davidsiaw
-ACMD_FUNC(setbattleflag); // by MouseJstr
-ACMD_FUNC(unmute); // [Valaris]
-ACMD_FUNC(clearweather); // Dexity
-ACMD_FUNC(uptime); // by MC Cameri
-ACMD_FUNC(changesex); // by MC Cameri
-ACMD_FUNC(mute); // celest
-ACMD_FUNC(refresh); // by MC Cameri
-ACMD_FUNC(petid); // by MC Cameri
-ACMD_FUNC(identify); // by MC Cameri
-ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
-ACMD_FUNC(misceffect); // by MC Cameri
-ACMD_FUNC(mobsearch);
-ACMD_FUNC(cleanmap);
-ACMD_FUNC(npctalk);
-ACMD_FUNC(pettalk);
-ACMD_FUNC(users);
-ACMD_FUNC(reset);
-ACMD_FUNC(autoloot); // Improved version imported from Freya.
-
-#ifndef TXT_ONLY
-ACMD_FUNC(checkmail); // [Valaris]
-ACMD_FUNC(listmail); // [Valaris]
-ACMD_FUNC(listnewmail); // [Valaris]
-ACMD_FUNC(readmail); // [Valaris]
-ACMD_FUNC(sendmail); // [Valaris]
-ACMD_FUNC(sendprioritymail); // [Valaris]
-ACMD_FUNC(deletemail); // [Valaris]
-ACMD_FUNC(refreshonline); // [Valaris]
-#endif /* TXT_ONLY */
-
-ACMD_FUNC(skilltree); // by MouseJstr
-
-ACMD_FUNC(marry); // by MouseJstr
-ACMD_FUNC(divorce); // by MouseJstr
-
-ACMD_FUNC(grind); // by MouseJstr
-ACMD_FUNC(grind2); // by MouseJstr
-
-#ifdef DMALLOC
-ACMD_FUNC(dmstart); // by MouseJstr
-ACMD_FUNC(dmtick); // by MouseJstr
-#endif
-
-ACMD_FUNC(jumptoid); // by Dino9021
-ACMD_FUNC(jumptoid2); // by Dino9021
-ACMD_FUNC(recallid); // by Dino9021
-ACMD_FUNC(recallid2); // by Dino9021
-ACMD_FUNC(kickid); // by Dino9021
-ACMD_FUNC(kickid2); // by Dino9021
-ACMD_FUNC(reviveid); // by Dino9021
-ACMD_FUNC(reviveid2); // by Dino9021
-ACMD_FUNC(killid); // by Dino9021
-ACMD_FUNC(killid2); // by Dino9021
-ACMD_FUNC(charkillableid); // by Dino9021
-ACMD_FUNC(charkillableid2); // by Dino9021
-ACMD_FUNC(sound);
-ACMD_FUNC(undisguiseall);
-ACMD_FUNC(disguiseall);
-ACMD_FUNC(changelook);
-ACMD_FUNC(mobinfo); //by Lupus
-ACMD_FUNC(exp); // by Skotlex
-ACMD_FUNC(adopt); // by Veider
-
-ACMD_FUNC(version); // by Ancyker
-
-ACMD_FUNC(mutearea); // by MouseJstr
-ACMD_FUNC(shuffle); // by MouseJstr
-ACMD_FUNC(rates); // by MouseJstr
-
-ACMD_FUNC(iteminfo); // Lupus
-ACMD_FUNC(whodrops); //Skotlex
-ACMD_FUNC(mapflag); // Lupus
-ACMD_FUNC(me); //added by massdriller, code by lordalfa
-ACMD_FUNC(monsterignore); // [Valaris]
-ACMD_FUNC(fakename); //[Valaris]
-ACMD_FUNC(size); //[Valaris]
-ACMD_FUNC(showexp); //moved from charcommand [Kevin]
-ACMD_FUNC(showzeny);
-ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
-ACMD_FUNC(autotrade);// durf
-ACMD_FUNC(changeleader);// [Skotlex]
-ACMD_FUNC(partyoption);// [Skotlex]
-ACMD_FUNC(changegm);// durf
-
-// Duel [LuzZza]
-ACMD_FUNC(invite);
-ACMD_FUNC(duel);
-ACMD_FUNC(leave);
-ACMD_FUNC(accept);
-ACMD_FUNC(reject);
-
-ACMD_FUNC(away); // LuzZza
-ACMD_FUNC(main); // LuzZza
-
-ACMD_FUNC(clone); // [Valaris]
-ACMD_FUNC(tonpc); // LuzZza
-ACMD_FUNC(commands); // [Skotlex]
-ACMD_FUNC(noask); //LuzZza
-ACMD_FUNC(request); //[Skotlex]
-
-ACMD_FUNC(homlevel); //[orn]
-ACMD_FUNC(homevolution); //[orn]
-ACMD_FUNC(makehomun); //[orn]
-ACMD_FUNC(homfriendly); //[orn]
-ACMD_FUNC(homhungry); //[orn]
-ACMD_FUNC(homtalk); //[orn]
-ACMD_FUNC(hominfo); //[Toms]
-ACMD_FUNC(showmobs); //KarLaeda
-
-/*==========================================
- *AtCommandInfo atcommand_info[]構造体の定義
- *------------------------------------------
- */
-
-// First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
-// to set default level, read atcommand_athena.conf first please.
-static AtCommandInfo atcommand_info[] = {
- { AtCommand_Rura, "@rura", 40, atcommand_rura },
- { AtCommand_Warp, "@warp", 40, atcommand_rura },
- { AtCommand_Where, "@where", 1, atcommand_where },
- { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
- { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
- { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
- { AtCommand_Jump, "@jump", 40, atcommand_jump },
- { AtCommand_Who, "@who", 20, atcommand_who },
- { AtCommand_Who, "@whois", 20, atcommand_who },
- { AtCommand_Who, "@w", 20, atcommand_who },
- { AtCommand_Who2, "@who2", 20, atcommand_who2 },
- { AtCommand_Who3, "@who3", 20, atcommand_who3 },
- { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
- { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
- { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
- { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
- { AtCommand_Save, "@save", 40, atcommand_save },
- { AtCommand_Load, "@return", 40, atcommand_load },
- { AtCommand_Load, "@load", 40, atcommand_load },
- { AtCommand_Speed, "@speed", 40, atcommand_speed },
- { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
- { AtCommand_Storage, "@storage", 1, atcommand_storage },
- { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
- { AtCommand_Option, "@option", 40, atcommand_option },
- { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
- { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
- { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
- { AtCommand_Die, "@die", 1, atcommand_die },
- { AtCommand_Kill, "@kill", 60, atcommand_kill },
- { AtCommand_Alive, "@alive", 60, atcommand_alive },
- { AtCommand_Kami, "@kami", 40, atcommand_kami },
- { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
- { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
- { AtCommand_Heal, "@heal", 40, atcommand_heal },
- { AtCommand_Item, "@item", 60, atcommand_item },
- { AtCommand_Item2, "@item2", 60, atcommand_item2 },
- { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
- { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
- { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
- { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
- { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
- { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
- { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
- { AtCommand_H, "@h", 20, atcommand_help },
- { AtCommand_Help, "@help", 20, atcommand_help },
- { AtCommand_H2, "@h2", 20, atcommand_help2 },
- { AtCommand_Help2, "@help2", 20, atcommand_help2 },
- { AtCommand_GM, "@gm", 100,atcommand_gm },
- { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
- { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
- { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
- { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
- { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
- { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
- { AtCommand_Model, "@model", 20, atcommand_model },
- { AtCommand_Go, "@go", 10, atcommand_go },
- { AtCommand_Spawn, "@monster", 50, atcommand_monster },
- { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
- { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
- { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
- { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
- { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
- { AtCommand_Refine, "@refine", 60, atcommand_refine },
- { AtCommand_Produce, "@produce", 60, atcommand_produce },
- { AtCommand_Memo, "@memo", 40, atcommand_memo },
- { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
- { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
- { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
- { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
- { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
- { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
- { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
- { AtCommand_Strength, "@str", 60, atcommand_param },
- { AtCommand_Agility, "@agi", 60, atcommand_param },
- { AtCommand_Vitality, "@vit", 60, atcommand_param },
- { AtCommand_Intelligence, "@int", 60, atcommand_param },
- { AtCommand_Dexterity, "@dex", 60, atcommand_param },
- { AtCommand_Luck, "@luk", 60, atcommand_param },
- { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
- { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
- { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
- { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
- { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
- { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
- { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
- { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
- { AtCommand_Revive, "@revive", 60, atcommand_revive },
- { AtCommand_Night, "@night", 80, atcommand_night },
- { AtCommand_Day, "@day", 80, atcommand_day },
- { AtCommand_Doom, "@doom", 80, atcommand_doom },
- { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
- { AtCommand_Raise, "@raise", 80, atcommand_raise },
- { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
- { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
- { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
- { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
- { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
- { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
- { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
- { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
- { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
- { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
- { AtCommand_Party, "@party", 1, atcommand_party },
- { AtCommand_Guild, "@guild", 50, atcommand_guild },
- { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
- { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
- { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
- { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
- { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
- { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
- { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
- { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
- { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
- { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
- { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
- { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
- { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
- { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
- { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
- { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
- { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
- { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
- { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
- { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
- { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
- { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
- { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
- { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
- { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
- { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
- { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
- { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
- { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
- { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
- { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
- { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
- { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
- { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
- { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
- { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
- { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
- { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
- { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
- { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
- { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
- { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
- { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
- { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
- { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
- { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
- { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
- { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
- { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
- { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
- { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
- { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
- { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
- { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
- { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
- { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
- { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
- { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
- { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
- { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
- { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
- { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
- { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
- { AtCommand_JailFor, "@jailfor", 20, atcommand_jailfor }, //Meruru
- { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime }, //Change this to 0 in atcommand_conf.txt if you want it accessible to players (you most likely will ;))
- { AtCommand_CharJailTime, "@charjailtime", 20, atcommand_charjailtime },
- { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
- { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
- { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
- { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
- { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
- { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
- { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
- { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
- { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
- { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
- { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
- { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
- { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
- { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
- { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
- { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
- { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
- { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
- { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
- { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
- { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
-// { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
- { AtCommand_Snow, "@snow", 99, atcommand_snow },
- { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
- { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
- { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
- { AtCommand_Fog, "@fog", 99, atcommand_fog },
- { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
- { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
- { AtCommand_Summon, "@summon", 60, atcommand_summon },
- { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
- { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
- { AtCommand_Trade, "@trade", 60, atcommand_trade },
- { AtCommand_Send, "@send", 60, atcommand_send },
- { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
- { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
- { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
- { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
- { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
- { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
- { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
- { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
- { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
- { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
- { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
- { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
- { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
- { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
- { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
- { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
- { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
- { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
- { AtCommand_Users, "@users", 40, atcommand_users },
- { AtCommand_ResetState, "@reset", 40, atcommand_reset },
-
-#ifndef TXT_ONLY // sql-only commands
- { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
- { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
- { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
- { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
- { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
- { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
- { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
- { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
-
-#endif /* TXT_ONLY */
- { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
- { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
- { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
- { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
- { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
-
-#ifdef DMALLOC
- { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
- { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
-#endif
-
- { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
- { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
- { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
- { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
- { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
- { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
- { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
- { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
- { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
- { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
- { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
- { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
- { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
- { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
- { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
- { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
- { AtCommand_Sound, "@sound", 40, atcommand_sound },
- { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
- { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
- { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
- { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
- { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
- { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
- { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
- { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
- { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
- { AtCommand_Version, "@version", 1, atcommand_version },
-
- { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
- { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
- { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
- { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
-
- { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
- { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
- { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
- { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
-
- { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
- { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
- { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
- { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
- { AtCommand_Size, "@size", 20, atcommand_size },
- { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
- { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
- { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
- { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
- { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
- { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
- { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
- { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
- { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
- { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
- { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
- { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
- { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
- { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
- { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
- { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
- { AtCommand_Clone, "@clone", 50, atcommand_clone },
- { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
- { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
- { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
- { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
- { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
- { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
-
- { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
- { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
- { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
- { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
- { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
- { AtCommand_HomTalk, "@homtalk", 0, atcommand_homtalk },
- { AtCommand_HomInfo, "@hominfo", 0, atcommand_hominfo },
- { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
-// add new commands before this line
- { AtCommand_Unknown, NULL, 1, NULL }
-};
-
-/*=========================================
- * Generic variables
- *-----------------------------------------
- */
-char atcmd_output[200];
-char atcmd_player_name[100];
-char atcmd_temp[100];
-
-/*==========================================
- * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
- *------------------------------------------
- */
-char *estr_lower(char *str)
-{
- int i;
-
- for (i=0; str[i]; i++)
- if ((str[i] >= 65) && (str[i] <= 90))
- str[i] += 32;
- return str;
-}
-
-// compare function for sorting high to lowest
-int hightolow_compare (const void * a, const void * b)
-{
- return ( *(int*)b - *(int*)a );
-}
-
-// compare function for sorting lowest to highest
-int lowtohigh_compare (const void * a, const void * b)
-{
- return ( *(int*)a - *(int*)b );
-}
-
-//-----------------------------------------------------------
-// Return the message string of the specified number by [Yor]
-//-----------------------------------------------------------
-char * msg_txt(int msg_number) {
- if (msg_number >= 0 && msg_number < MAX_MSG &&
- msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
- return msg_table[msg_number];
-
- return "??";
-}
-
-//-----------------------------------------------------------
-// Returns Players title (from msg_athena.conf) [Lupus]
-//-----------------------------------------------------------
-char * player_title_txt(int level) {
- if (level < battle_config.title_lvl1)
- return ""; //w/o any titles
-
- if (level >= battle_config.title_lvl8)
- sprintf(atcmd_temp, msg_txt(332), level);
- else
- if (level >= battle_config.title_lvl7)
- sprintf(atcmd_temp, msg_txt(331), level);
- else
- if (level >= battle_config.title_lvl6)
- sprintf(atcmd_temp, msg_txt(330), level);
- else
- if (level >= battle_config.title_lvl5)
- sprintf(atcmd_temp, msg_txt(329), level);
- else
- if (level >= battle_config.title_lvl4)
- sprintf(atcmd_temp, msg_txt(328), level);
- else
- if (level >= battle_config.title_lvl3)
- sprintf(atcmd_temp, msg_txt(327), level);
- else
- if (level >= battle_config.title_lvl2)
- sprintf(atcmd_temp, msg_txt(326), level);
- else
- sprintf(atcmd_temp, msg_txt(325), level); //lvl1
- return atcmd_temp;
-}
-
-//------------------------------------------------------------
-// E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
-//------------------------------------------------------------
-int e_mail_check(char *email) {
- char ch;
- char* last_arobas;
-
- // athena limits
- if (strlen(email) < 3 || strlen(email) > 39)
- return 0;
-
- // part of RFC limits (official reference of e-mail description)
- if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
- return 0;
-
- if (email[strlen(email)-1] == '.')
- return 0;
-
- last_arobas = strrchr(email, '@');
-
- if (strstr(last_arobas, "@.") != NULL ||
- strstr(last_arobas, "..") != NULL)
- return 0;
-
- for(ch = 1; ch < 32; ch++) {
- if (strchr(last_arobas, ch) != NULL) {
- return 0;
- break;
- }
- }
-
- if (strchr(last_arobas, ' ') != NULL ||
- strchr(last_arobas, ';') != NULL)
- return 0;
-
- // all correct
- return 1;
-}
-
-/*==========================================
- * get_atcommand_level @コマンドの必要レベルを取得
- *------------------------------------------
- */
-int get_atcommand_level(const AtCommandType type) {
- int i;
-
- for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
- if (atcommand_info[i].type == type)
- return atcommand_info[i].level;
-
- return 100; // 100: command can not be used
-}
-
-AtCommandType
-atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
- AtCommandInfo info;
- AtCommandType type;
-
- malloc_set(&info, 0, sizeof(info));
-
- type = atcommand(sd, gmlvl, str, &info);
- if (type != AtCommand_None) {
- char command[100];
- const char* p = str;
-
- if (map[sd->bl.m].nocommand &&
- gmlvl < map[sd->bl.m].nocommand)
- { //Command not allowed on this map.
- sprintf(atcmd_output, msg_txt(143));
- clif_displaymessage(fd, atcmd_output);
- return AtCommand_None;
- }
-
- malloc_tsetdword(command, '\0', sizeof(command));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- while (*p && !isspace(*p))
- p++;
- if (p - str >= sizeof(command)) // too long
- return AtCommand_Unknown;
- strncpy(command, str, p - str);
- while (isspace(*p))
- p++;
-
- if (type == AtCommand_Unknown || info.proc == NULL) {
- sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
- clif_displaymessage(fd, atcmd_output);
- } else {
- if (info.proc(fd, sd, command, p) != 0) {
- // Command can not be executed
- sprintf(atcmd_output, msg_txt(154), command); // %s failed.
- clif_displaymessage(fd, atcmd_output);
- }
- }
-
- return info.type;
- }
-
- return AtCommand_None;
-}
-
-/*==========================================
- *is_atcommand @コマンドに存在するかどうか確認する
- *------------------------------------------
- */
-AtCommandType
-is_atcommand(const int fd, struct map_session_data* sd, const char* message) {
- const char* str = message;
- int s_flag = 0;
-
- nullpo_retr(AtCommand_None, sd);
-
- if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
- return AtCommand_Unknown;
- }
-
- if (!message || !*message)
- return AtCommand_None;
-
- str += strlen(sd->status.name);
- while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
- if (*str == ':')
- s_flag = 1;
- str++;
- }
- if (!*str)
- return AtCommand_None;
-
- return atcommand_sub(fd,sd,str,pc_isGM(sd));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
- char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
-
- if (!info)
- return AtCommand_None;
- if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
- return AtCommand_None;
- if (!p || !*p) {
- ShowError("at command message is empty\n");
- return AtCommand_None;
- }
-
- if (*p == command_symbol) { // check first char.
- char command[101];
- int i = 0;
- malloc_set(info, 0, sizeof(AtCommandInfo));
- sscanf(p, "%100s", command);
- command[sizeof(command)-1] = '\0';
-
- while (atcommand_info[i].type != AtCommand_Unknown) {
- if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
- p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
- break;
- }
- i++;
- }
-
- if (atcommand_info[i].type == AtCommand_Unknown) {
- // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
- if (level == 0)
- return AtCommand_None;
- else
- return AtCommand_Unknown;
- } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
- log_atcommand(sd, message);
- }
- memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
- } else {
- return AtCommand_None;
- }
-
- return info->type;
-}
-
-/*==========================================
- * Read Message Data
- *------------------------------------------
- */
-int msg_config_read(const char *cfgName) {
- int msg_number;
- char line[1024], w1[1024], w2[1024];
- FILE *fp;
- static int called = 1;
-
- if ((fp = fopen(cfgName, "r")) == NULL) {
- ShowError("Messages file not found: %s\n", cfgName);
- return 1;
- }
-
- if ((--called) == 0)
- malloc_tsetdword(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
- while(fgets(line, sizeof(line)-1, fp)) {
- if (line[0] == '/' && line[1] == '/')
- continue;
- if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
- if (strcmpi(w1, "import") == 0) {
- msg_config_read(w2);
- } else {
- msg_number = atoi(w1);
- if (msg_number >= 0 && msg_number < MAX_MSG) {
- if (msg_table[msg_number] != NULL)
- aFree(msg_table[msg_number]);
- msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
- strcpy(msg_table[msg_number],w2);
- // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
- }
- }
- }
- }
- fclose(fp);
-
- return 0;
-}
-
-/*==========================================
- * Cleanup Message Data
- *------------------------------------------
- */
-void do_final_msg (void) {
- int i;
- for (i = 0; i < MAX_MSG; i++)
- aFree(msg_table[i]);
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
- int i;
-
- for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
- if (strcmpi(atcommand_info[i].command + 1, name) == 0)
- return &atcommand_info[i];
-
- return NULL;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_config_read(const char *cfgName) {
- char line[1024], w1[1024], w2[1024];
- AtCommandInfo* p;
- FILE* fp;
-
- if ((fp = fopen(cfgName, "r")) == NULL) {
- ShowError("At commands configuration file not found: %s\n", cfgName);
- return 1;
- }
-
- while (fgets(line, sizeof(line)-1, fp)) {
- if (line[0] == '/' && line[1] == '/')
- continue;
-
- if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
- continue;
- p = get_atcommandinfo_byname(w1);
- if (p != NULL) {
- p->level = atoi(w2);
- if (p->level > 100)
- p->level = 100;
- else if (p->level < 0)
- p->level = 0;
- }
-
- if (strcmpi(w1, "import") == 0)
- atcommand_config_read(w2);
- else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
- w2[0] != '/' && // symbol of standard ragnarok GM commands
- w2[0] != '%' && // symbol of party chat speaking
- w2[0] != '$' && // symbol of guild chat
- w2[0] != '#') // symbol of charcommand
- command_symbol = w2[0];
- }
- fclose(fp);
-
- return 0;
-}
-
-/*==========================================
-// @ command processing functions
- *------------------------------------------
- */
-
-/*==========================================
- * @commands Lists available @ commands to you (code 98% from Meruru)
- *------------------------------------------
- */
-int atcommand_commands(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char cz_line_buff[MESSAGE_SIZE+1];
-
- register char *lpcz_cur = cz_line_buff;
- register unsigned int ui_slen;
-
- int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
-
- malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
- cz_line_buff[MESSAGE_SIZE] = 0;
-
- clif_displaymessage(fd, msg_txt(273));
-
- for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
- {
- if(gm_lvl < atcommand_info[i_cur_cmd].level)
- continue;
-
- count++;
- ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
-
- //rember not <= bc we need null terminator
- if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
- {
- clif_displaymessage(fd,(char*)cz_line_buff);
- lpcz_cur = cz_line_buff;
- malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
- cz_line_buff[MESSAGE_SIZE] = 0;
- }
-
- memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
- lpcz_cur += ui_slen+(10-ui_slen%10);
- }
-
- clif_displaymessage(fd,(char*)cz_line_buff);
- sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
- clif_displaymessage(fd, atcmd_output);
- return 0;
-}
-
-/*==========================================
- * @send (used for testing packet sends from the client)
- *------------------------------------------
- */
-int atcommand_send(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int type=0;
- int info[20];
-
- 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 (!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;
-}
-
-// @rura
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_rura(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char map_name[MAP_NAME_LENGTH];
- unsigned short mapindex;
- int x = 0, y = 0;
- int m = -1;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(map_name, '\0', sizeof(map_name));
-
- if (!message || !*message ||
- (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
- sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
-
- clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
- return -1;
- }
-
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
-
- mapindex = mapindex_name2id(map_name);
- if (mapindex)
- m = map_mapindex2mapid(mapindex);
-
- if (!mapindex || m < 0) {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
-
- if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
- clif_displaymessage(fd, msg_txt(2));
- x = y = 0; //Invalid cell, use random spot.
- }
- if (map[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;
- }
- if (pc_setpos(sd, mapindex, x, y, 3) == 0)
- clif_displaymessage(fd, msg_txt(0)); // Warped.
- else {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * Displays where a character is. Corrected version by Silent. [Skotlex]
- *------------------------------------------
- */
-int atcommand_where(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int GM_level, pl_GM_level;
-
- nullpo_retr(-1, sd);
- malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
- return -1;
- }
- pl_sd = map_nick2sd(atcmd_player_name);
-
- if (pl_sd == NULL)
- return -1;
-
- if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
- return -1;
-
- GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
- pl_GM_level = pc_isGM(pl_sd);
-
- if (battle_config.hide_GM_session) {
- if(GM_level < pl_GM_level) {
- if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
- return -1;
- }
- }
- }
-
- snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
- pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_jumpto(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
- return -1;
- }
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
- if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
- return -1;
- if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
- return -1;
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != 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), atcmd_player_name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_jump(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int x = 0, y = 0;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- sscanf(message, "%d %d", &x, &y);
-
- if (x <= 0) //If coordinates are 'wrong', random jump.
- x = -1;
- if (y <= 0)
- y = -1;
- if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(sd, sd->mapindex, x, y, 3);
- sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
- clif_displaymessage(fd, atcmd_output);
- return 0;
-}
-
-/*==========================================
- * @who3 = Player name, his location
- *------------------------------------------
- */
-int atcommand_who3(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char temp0[100];
- struct map_session_data *pl_sd, **pl_allsd;
- int i, j, count, users;
- int pl_GM_level, GM_level;
- char match_text[100];
- char player_name[NAME_LENGTH];
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(match_text, '\0', sizeof(match_text));
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if (sscanf(message, "%99[^\n]", match_text) < 1)
- strcpy(match_text, "");
- for (j = 0; match_text[j]; j++)
- match_text[j] = tolower(match_text[j]);
-
- count = 0;
- GM_level = pc_isGM(sd);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
- for (j = 0; player_name[j]; j++)
- player_name[j] = tolower(player_name[j]);
- if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
-
- if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
- sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
- } else {
- atcmd_output[0]=0;
- }
- //Player name
- sprintf(temp0, msg_txt(333), pl_sd->status.name);
- strcat(atcmd_output,temp0);
- //Player title, if exists
- if (pl_GM_level > 0) {
- //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
- sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
- strcat(atcmd_output,temp0);
- }
- //Players Location: map x y
- sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
- strcat(atcmd_output,temp0);
-
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
-
- if (count == 0)
- clif_displaymessage(fd, msg_txt(28)); // No player found.
- else if (count == 1)
- clif_displaymessage(fd, msg_txt(29)); // 1 player found.
- else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-/*==========================================
- * Player name, BLevel, Job,
- *------------------------------------------
- */
-int atcommand_who2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char temp0[100];
- struct map_session_data *pl_sd, **pl_allsd;
- int i, j, count, users;
- int pl_GM_level, GM_level;
- char match_text[100];
- char player_name[NAME_LENGTH];
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(match_text, '\0', sizeof(match_text));
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if (sscanf(message, "%99[^\n]", match_text) < 1)
- strcpy(match_text, "");
- for (j = 0; match_text[j]; j++)
- match_text[j] = tolower(match_text[j]);
-
- count = 0;
- GM_level = pc_isGM(sd);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
- for (j = 0; player_name[j]; j++)
- player_name[j] = tolower(player_name[j]);
- if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
- //Players Name
- //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
- sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
- //Player title, if exists
- if (pl_GM_level > 0) {
- //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
- sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
- strcat(atcmd_output,temp0);
- }
- //Players Base Level / Job name
- //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
- sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
- strcat(atcmd_output,temp0);
-
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
-
- if (count == 0)
- clif_displaymessage(fd, msg_txt(28)); // No player found.
- else if (count == 1)
- clif_displaymessage(fd, msg_txt(29)); // 1 player found.
- else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-/*==========================================
- * Player name, Playrs Party / Guild name
- *------------------------------------------
- */
-int atcommand_who(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char temp0[100];
- struct map_session_data *pl_sd, **pl_allsd;
- int i, j, count, users;
- int pl_GM_level, GM_level;
- char match_text[100];
- char player_name[NAME_LENGTH];
- struct guild *g;
- struct party_data *p;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(temp0, '\0', sizeof(temp0));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(match_text, '\0', sizeof(match_text));
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if (sscanf(message, "%99[^\n]", match_text) < 1)
- strcpy(match_text, "");
- for (j = 0; match_text[j]; j++)
- match_text[j] = tolower(match_text[j]);
-
- count = 0;
- GM_level = pc_isGM(sd);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
- for (j = 0; player_name[j]; j++)
- player_name[j] = tolower(player_name[j]);
- if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
- g = guild_search(pl_sd->status.guild_id);
- p = party_search(pl_sd->status.party_id);
- //Players Name
- //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
- sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
- //Player title, if exists
- if (pl_GM_level > 0) {
- //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
- sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
- strcat(atcmd_output,temp0);
- }
- //Players Party if exists
- if (p != NULL) {
- //sprintf(temp0," | Party: '%s'", p->name);
- sprintf(temp0, msg_txt(335), p->party.name);
- strcat(atcmd_output,temp0);
- }
- //Players Guild if exists
- if (g != NULL) {
- //sprintf(temp0," | Guild: '%s'", g->name);
- sprintf(temp0, msg_txt(336), g->name);
- strcat(atcmd_output,temp0);
- }
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
-
- if (count == 0)
- clif_displaymessage(fd, msg_txt(28)); // No player found.
- else if (count == 1)
- clif_displaymessage(fd, msg_txt(29)); // 1 player found.
- else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_whomap3(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, count, users;
- int pl_GM_level, GM_level;
- int map_id;
- char map_name[MAP_NAME_LENGTH];
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(map_name, '\0', sizeof(map_name));
-
- if (!message || !*message)
- map_id = sd->bl.m;
- else {
- sscanf(message, "%15s", map_name);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
- if ((map_id = map_mapname2mapid(map_name)) < 0)
- map_id = sd->bl.m;
- }
-
- count = 0;
- GM_level = pc_isGM(sd);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- if (pl_sd->bl.m == map_id) {
- if (pl_GM_level > 0)
- sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
- else
- sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
-
- if (count == 0)
- sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
- else if (count == 1)
- sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
- else {
- sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
- }
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_whomap2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, count, users;
- int pl_GM_level, GM_level;
- int map_id = 0;
- char map_name[MAP_NAME_LENGTH];
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(map_name, '\0', sizeof(map_name));
-
- if (!message || !*message)
- map_id = sd->bl.m;
- else {
- sscanf(message, "%15s", map_name);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
- if ((map_id = map_mapname2mapid(map_name)) < 0)
- map_id = sd->bl.m;
- }
-
- count = 0;
- GM_level = pc_isGM(sd);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- if (pl_sd->bl.m == map_id) {
- if (pl_GM_level > 0)
- sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
- else
- sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
-
- if (count == 0)
- sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
- else if (count == 1)
- sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
- else {
- sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
- }
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_whomap(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char temp0[100];
- char temp1[100];
- struct map_session_data *pl_sd, **pl_allsd;
- int i, count, users;
- int pl_GM_level, GM_level;
- int map_id = 0;
- char map_name[MAP_NAME_LENGTH];
- struct guild *g;
- struct party_data *p;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(temp0, '\0', sizeof(temp0));
- malloc_tsetdword(temp1, '\0', sizeof(temp1));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(map_name, '\0', sizeof(map_name));
-
- if (!message || !*message)
- map_id = sd->bl.m;
- else {
- sscanf(message, "%15s", map_name);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
- if ((map_id = map_mapname2mapid(map_name)) < 0)
- map_id = sd->bl.m;
- }
-
- count = 0;
- GM_level = pc_isGM(sd);
-
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- if (pl_sd->bl.m == map_id) {
- g = guild_search(pl_sd->status.guild_id);
- if (g == NULL)
- sprintf(temp1, "None");
- else
- sprintf(temp1, "%s", g->name);
- p = party_search(pl_sd->status.party_id);
- if (p == NULL)
- sprintf(temp0, "None");
- else
- sprintf(temp0, "%s", p->party.name);
- if (pl_GM_level > 0)
- sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
- else
- sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
-
- if (count == 0)
- sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
- else if (count == 1)
- sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
- else {
- sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
- }
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_whogm(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char temp0[100];
- char temp1[100];
- struct map_session_data *pl_sd, **pl_allsd;
- int i, j, count, users;
- int pl_GM_level, GM_level;
- char match_text[100];
- char player_name[NAME_LENGTH];
- struct guild *g;
- struct party_data *p;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(temp0, '\0', sizeof(temp0));
- malloc_tsetdword(temp1, '\0', sizeof(temp1));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(match_text, '\0', sizeof(match_text));
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if (sscanf(message, "%99[^\n]", match_text) < 1)
- strcpy(match_text, "");
- for (j = 0; match_text[j]; j++)
- match_text[j] = tolower(match_text[j]);
-
- count = 0;
- GM_level = pc_isGM(sd);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- pl_GM_level = pc_isGM(pl_sd);
- if (pl_GM_level > 0) {
- if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
- memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
- for (j = 0; player_name[j]; j++)
- player_name[j] = tolower(player_name[j]);
- if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
- sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
- clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
- clif_displaymessage(fd, atcmd_output);
- g = guild_search(pl_sd->status.guild_id);
- if (g == NULL)
- sprintf(temp1, "None");
- else
- sprintf(temp1, "%s", g->name);
- p = party_search(pl_sd->status.party_id);
- if (p == NULL)
- sprintf(temp0, "None");
- else
- sprintf(temp0, "%s", p->party.name);
- sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
- clif_displaymessage(fd, atcmd_output);
- count++;
- }
- }
- }
- }
- }
-
- if (count == 0)
- clif_displaymessage(fd, msg_txt(150)); // No GM found.
- else if (count == 1)
- clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
- else {
- sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-int atcommand_whozeny(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, j, count,c, users;
- char match_text[100];
- char player_name[NAME_LENGTH];
- int *zeny;
- int *counted;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(match_text, '\0', sizeof(match_text));
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if (sscanf(message, "%99[^\n]", match_text) < 1)
- strcpy(match_text, "");
- for (j = 0; match_text[j]; j++)
- match_text[j] = tolower(match_text[j]);
-
- count = 0;
- pl_allsd = map_getallusers(&users);
- if (users < 1)
- {
- clif_displaymessage(fd, msg_txt(28)); // No player found.
- return 0;
- }
- zeny = (int *)aMallocA(users*sizeof(int));
- counted = (int *)aMallocA(users*sizeof(int));
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
- for (j = 0; player_name[j]; j++)
- player_name[j] = tolower(player_name[j]);
- if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
- zeny[count]=pl_sd->status.zeny;
- counted[i]=0;
- count++;
- }
- }
- }
-
- qsort(zeny, count, sizeof(int), hightolow_compare);
- for (c = 0; c < count && c < 50; c++) {
- if(!zeny[c])
- continue;
- for (i = 0; i < users; i++) {
- if(!zeny[c])
- continue;
- if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
- if(pl_sd->status.zeny==zeny[c]) {
- sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
- clif_displaymessage(fd, atcmd_output);
- zeny[c]=0;
- counted[i]=1;
- }
- }
- }
- }
-
- if (count == 0)
- clif_displaymessage(fd, msg_txt(28)); // No player found.
- else if (count == 1)
- clif_displaymessage(fd, msg_txt(29)); // 1 player found.
- else {
- sprintf(atcmd_output, msg_txt(30), count); // %d players found.
- clif_displaymessage(fd, atcmd_output);
- }
-
- aFree(zeny);
- aFree(counted);
-
- return 0;
-}
-
-
-// cause random emote on all online players [Valaris]
-int atcommand_happyhappyjoyjoy(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i,e, users;
-
- nullpo_retr(-1, sd);
-
- pl_allsd = map_getallusers(&users);
-
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i])) {
- e=rand()%40;
- if(e==34)
- e = 0;
- clif_emotion(&pl_sd->bl,e);
- }
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_save(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
- if (sd->status.pet_id > 0 && sd->pd)
- intif_save_petdata(sd->status.account_id, &sd->pd->pet);
-
- chrif_save(sd,0);
-
- clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_load(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int m;
-
- nullpo_retr(-1, sd);
-
- m = map_mapindex2mapid(sd->status.save_point.map);
- if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(249));
- 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, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
- clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_speed(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int speed;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message) {
- sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- speed = atoi(message);
- if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
- sd->base_status.speed = speed;
- status_calc_bl(&sd->bl, SCB_SPEED);
- clif_displaymessage(fd, msg_txt(8)); // Speed changed.
- } else {
- sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_charspeed(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- int speed;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
- sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- if (pc_isGM(sd) < pc_isGM(pl_sd))
- { //GM level check
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
-
- if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
- pl_sd->base_status.speed = speed;
- status_calc_bl(&pl_sd->bl, SCB_SPEED);
- clif_displaymessage(fd, msg_txt(8)); // Speed changed.
- if(pl_sd->fd)
- clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
- } else {
- sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_storage(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- if (storage_storageopen(sd) == 1)
- { //Already open.
- clif_displaymessage(fd, msg_txt(250));
- return -1;
- }
- return 0;
-}
-
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_guildstorage(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct storage *stor; //changes from Freya/Yor
- nullpo_retr(-1, sd);
-
- if (sd->status.guild_id > 0) {
- if (sd->state.storage_flag) {
- clif_displaymessage(fd, msg_txt(251));
- return -1;
- }
- if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
- clif_displaymessage(fd, msg_txt(251));
- return -1;
- }
- storage_guild_storageopen(sd);
- } else {
- clif_displaymessage(fd, msg_txt(252));
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_option(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int param1 = 0, param2 = 0, param3 = 0;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
- clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
- return -1;
- }
-
- sd->sc.opt1 = param1;
- sd->sc.opt2 = param2;
- if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
- clif_cartlist(sd);
- clif_updatestatus(sd, SP_CARTINFO);
- }
- pc_setoption(sd, param3);
-
- clif_displaymessage(fd, msg_txt(9)); // Options changed.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_hide(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (sd->sc.option & OPTION_INVISIBLE) {
- sd->sc.option &= ~OPTION_INVISIBLE;
- if (sd->disguise)
- status_set_viewdata(&sd->bl, sd->disguise);
- else
- status_set_viewdata(&sd->bl, sd->status.class_);
- clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
- } else {
- sd->sc.option |= OPTION_INVISIBLE;
- sd->vd.class_ = INVISIBLE_CLASS;
- clif_displaymessage(fd, msg_txt(11)); // Invisible: On
- }
- clif_changeoption(&sd->bl);
-
- return 0;
-}
-
-/*==========================================
- * 転職する upperを指定すると転生や養子にもなれる
- *------------------------------------------
- */
-int atcommand_jobchange(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int job = 0, upper = 0;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
-
- int i, found = 0;
- const struct { char name[16]; int id; } jobs[] = {
- { "novice", 0 },
- { "swordsman", 1 },
- { "mage", 2 },
- { "archer", 3 },
- { "acolyte", 4 },
- { "merchant", 5 },
- { "thief", 6 },
- { "knight", 7 },
- { "priest", 8 },
- { "priestess", 8 },
- { "wizard", 9 },
- { "blacksmith", 10 },
- { "hunter", 11 },
- { "assassin", 12 },
- { "crusader", 14 },
- { "monk", 15 },
- { "sage", 16 },
- { "rogue", 17 },
- { "alchemist", 18 },
- { "bard", 19 },
- { "dancer", 20 },
- { "super novice", 23 },
- { "supernovice", 23 },
- { "gunslinger", 24 },
- { "gunner", 24 },
- { "ninja", 25 },
- { "high novice", 4001 },
- { "swordsman high", 4002 },
- { "mage high", 4003 },
- { "archer high", 4004 },
- { "acolyte high", 4005 },
- { "merchant high", 4006 },
- { "thief high", 4007 },
- { "lord knight", 4008 },
- { "high priest", 4009 },
- { "high priestess", 4009 },
- { "high wizard", 4010 },
- { "whitesmith", 4011 },
- { "sniper", 4012 },
- { "assassin cross", 4013 },
- { "paladin", 4015 },
- { "champion", 4016 },
- { "professor", 4017 },
- { "stalker", 4018 },
- { "creator", 4019 },
- { "clown", 4020 },
- { "gypsy", 4021 },
- { "baby novice", 4023 },
- { "baby swordsman", 4024 },
- { "baby mage", 4025 },
- { "baby archer", 4026 },
- { "baby acolyte", 4027 },
- { "baby merchant", 4028 },
- { "baby thief", 4029 },
- { "baby knight", 4030 },
- { "baby priest", 4031 },
- { "baby priestess", 4031 },
- { "baby wizard", 4032 },
- { "baby blacksmith",4033 },
- { "baby hunter", 4034 },
- { "baby assassin", 4035 },
- { "baby crusader", 4037 },
- { "baby monk", 4038 },
- { "baby sage", 4039 },
- { "baby rogue", 4040 },
- { "baby alchemist", 4041 },
- { "baby bard", 4042 },
- { "baby dancer", 4043 },
- { "super baby", 4045 },
- { "taekwon", 4046 },
- { "taekwon boy", 4046 },
- { "taekwon girl", 4046 },
- { "star gladiator", 4047 },
- { "soul linker", 4049 },
- };
-
- for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
- if (strncmpi(message, jobs[i].name, 16) == 0) {
- job = jobs[i].id;
- upper = 0;
- found = 1;
- break;
- }
- }
-
- if (!found) {
- clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
- return -1;
- }
- }
-
- if (job == 37 ||job == 45)
- return 0;
-
- if ((job >= 0 && job < MAX_PC_CLASS))
- {
- int j;
-
- for (j=0; j < MAX_INVENTORY; j++) {
- if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
- pc_unequipitem(sd, j, 3);
- }
- if (pc_jobchange(sd, job, upper) == 0)
- clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
- else {
- clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
- return -1;
- }
- } else {
- clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_die(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- clif_specialeffect(&sd->bl,450,SELF);
- status_kill(&sd->bl);
- clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_kill(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != 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;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_alive(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (!status_revive(&sd->bl, 100, 100))
- return -1;
- clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
- clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
- return 0;
-}
-
-/*==========================================
- * +kamic [LuzZza]
- *------------------------------------------
- */
-int atcommand_kami(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
-
- unsigned long color=0;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if(*(command + 5) != 'c' && *(command + 5) != 'C') {
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
- return -1;
- }
-
- sscanf(message, "%199[^\n]", atcmd_output);
- intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
-
- } else {
-
- if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
- clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
- return -1;
- }
-
- if(color > 0xFFFFFF) {
- clif_displaymessage(fd, "Invalid color.");
- return -1;
- }
-
- intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_heal(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int hp = 0, sp = 0; // [Valaris] thanks to fov
- nullpo_retr(-1, sd);
-
- sscanf(message, "%d %d", &hp, &sp);
-
- if (hp == 0 && sp == 0) {
- if (!status_percent_heal(&sd->bl, 100, 100))
- clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
- else
- clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
- return 0;
- }
-
- if(hp > 0 && sp >= 0) {
- if(!status_heal(&sd->bl, hp, sp, 0))
- clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
- else
- clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
- return 0;
- }
-
- if(hp < 0 && sp <= 0) {
- status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
- clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
- clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
- return 0;
- }
-
- //Opposing signs.
- if (hp) {
- if (hp > 0)
- status_heal(&sd->bl, hp, 0, 0);
- else {
- status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
- clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
- }
- }
-
- if (sp) {
- if (sp > 0)
- status_heal(&sd->bl, 0, sp, 0);
- else
- status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
- }
-
- clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
- return 0;
-}
-
-/*==========================================
- * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
- *------------------------------------------
- */
-int atcommand_item(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char item_name[100];
- int number = 0, item_id, flag;
- struct item item_tmp;
- struct item_data *item_data;
- int get_count, i;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(item_name, '\0', sizeof(item_name));
-
- if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
- clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
- return -1;
- }
-
- if (number <= 0)
- number = 1;
-
- if ((item_data = itemdb_searchname(item_name)) == NULL &&
- (item_data = itemdb_exists(atoi(item_name))) == NULL)
- {
- clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
- }
-
- item_id = item_data->nameid;
- get_count = number;
- //Check if it's stackable.
- if (!itemdb_isstackable2(item_data))
- get_count = 1;
-
- for (i = 0; i < number; i += get_count) {
- // if not pet egg
- if (!pet_create_egg(sd, item_id)) {
- malloc_set(&item_tmp, 0, sizeof(item_tmp));
- item_tmp.nameid = item_id;
- item_tmp.identify = 1;
-
- if ((flag = pc_additem(sd, &item_tmp, get_count)))
- clif_additem(sd, 0, 0, flag);
- }
- }
-
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", item_id, number, NULL);
-
- clif_displaymessage(fd, msg_txt(18)); // Item created.
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_item2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct item item_tmp;
- struct item_data *item_data;
- char item_name[100];
- int item_id, number = 0;
- int identify = 0, refine = 0, attr = 0;
- int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
- int flag;
- int loop, get_count, i;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(item_name, '\0', sizeof(item_name));
-
- if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
- clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
- clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
- return -1;
- }
-
- if (number <= 0)
- number = 1;
-
- item_id = 0;
- if ((item_data = itemdb_searchname(item_name)) != NULL ||
- (item_data = itemdb_exists(atoi(item_name))) != NULL)
- item_id = item_data->nameid;
-
- if (item_id > 500) {
- loop = 1;
- get_count = number;
- if (item_data->type == 4 || item_data->type == 5 ||
- item_data->type == 7 || item_data->type == 8) {
- loop = number;
- get_count = 1;
- if (item_data->type == 7) {
- identify = 1;
- refine = 0;
- }
- if (item_data->type == 8)
- refine = 0;
- if (refine > 10)
- refine = 10;
- } else {
- identify = 1;
- refine = attr = 0;
- }
- for (i = 0; i < loop; i++) {
- malloc_set(&item_tmp, 0, sizeof(item_tmp));
- item_tmp.nameid = item_id;
- item_tmp.identify = identify;
- item_tmp.refine = refine;
- item_tmp.attribute = attr;
- item_tmp.card[0] = c1;
- item_tmp.card[1] = c2;
- item_tmp.card[2] = c3;
- item_tmp.card[3] = c4;
- if ((flag = pc_additem(sd, &item_tmp, get_count)))
- clif_additem(sd, 0, 0, flag);
- }
-
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
-
- clif_displaymessage(fd, msg_txt(18)); // Item created.
- } else {
- clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_itemreset(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- nullpo_retr(-1, sd);
-
- for (i = 0; i < MAX_INVENTORY; i++) {
- if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
-
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
-
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
- }
- }
- clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
-
- return 0;
-}
-
-/*==========================================
- * Atcommand @lvlup
- *------------------------------------------
- */
-int atcommand_baselevelup(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int level=0, i=0, status_point=0;
- nullpo_retr(-1, sd);
- level = atoi(message);
-
- if (!message || !*message || !level) {
- clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
- return -1;
- }
-
- if (level > 0) {
- if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
- clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
- return -1;
- } /* End Addition */
- if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
- level = pc_maxbaselv(sd) - sd->status.base_level;
- for (i = 1; i <= level; i++)
- status_point += (sd->status.base_level + i + 14) / 5;
-
- if (sd->status.status_point > USHRT_MAX - status_point)
- sd->status.status_point = USHRT_MAX;
- else
- sd->status.status_point += status_point;
- sd->status.base_level += (unsigned int)level;
- clif_updatestatus(sd, SP_BASELEVEL);
- clif_updatestatus(sd, SP_NEXTBASEEXP);
- clif_updatestatus(sd, SP_STATUSPOINT);
- status_calc_pc(sd, 0);
- status_percent_heal(&sd->bl, 100, 100);
- clif_misceffect(&sd->bl, 0);
- clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
- } else {
- if (sd->status.base_level == 1) {
- clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
- return -1;
- }
- level*=-1;
- if ((unsigned int)level >= sd->status.base_level)
- level = sd->status.base_level-1;
- if (sd->status.status_point > 0) {
- for (i = 0; i > -level; i--)
- status_point += (sd->status.base_level + i + 14) / 5;
- if (sd->status.status_point < status_point)
- pc_resetstate(sd);
- if (sd->status.status_point < status_point)
- sd->status.status_point = 0;
- else
- sd->status.status_point -= status_point;
- clif_updatestatus(sd, SP_STATUSPOINT);
- } /* to add: remove status points from stats */
- sd->status.base_level -= (unsigned int)level;
- clif_updatestatus(sd, SP_BASELEVEL);
- clif_updatestatus(sd, SP_NEXTBASEEXP);
- status_calc_pc(sd, 0);
- clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_joblevelup(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int level=0;
- nullpo_retr(-1, sd);
-
- level = atoi(message);
-
- if (!message || !*message || !level) {
- clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
- return -1;
- }
- if (level > 0) {
- if (sd->status.job_level == pc_maxjoblv(sd)) {
- clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
- return -1;
- }
- if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
- level = pc_maxjoblv(sd) - sd->status.job_level;
- sd->status.job_level += (unsigned int)level;
- clif_updatestatus(sd, SP_JOBLEVEL);
- clif_updatestatus(sd, SP_NEXTJOBEXP);
- if (sd->status.skill_point > USHRT_MAX - level)
- sd->status.skill_point = USHRT_MAX;
- else
- sd->status.skill_point += level;
- clif_updatestatus(sd, SP_SKILLPOINT);
- status_calc_pc(sd, 0);
- clif_misceffect(&sd->bl, 1);
- clif_displaymessage(fd, msg_txt(24)); // Job level raised.
- } else {
- if (sd->status.job_level == 1) {
- clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
- return -1;
- }
- level *=-1;
- if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
- level = sd->status.job_level-1;
- sd->status.job_level -= (unsigned int)level;
- clif_updatestatus(sd, SP_JOBLEVEL);
- clif_updatestatus(sd, SP_NEXTJOBEXP);
- if (sd->status.skill_point < level)
- pc_resetskill(sd,0); //Reset skills since we need to substract more points.
- if (sd->status.skill_point < level)
- sd->status.skill_point = 0;
- else
- sd->status.skill_point -= level;
- clif_updatestatus(sd, SP_SKILLPOINT);
- status_calc_pc(sd, 0);
- clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
- }
-
- return 0;
-}
-
-/*==========================================
- * @help
- *------------------------------------------
- */
-int atcommand_help(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char buf[2048], w1[2048], w2[2048];
- int i, gm_level;
- FILE* fp;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(buf, '\0', sizeof(buf));
-
- if ((fp = fopen(help_txt, "r")) != NULL) {
- clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
- gm_level = pc_isGM(sd);
- while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
- if (buf[0] == '/' && buf[1] == '/')
- continue;
- for (i = 0; buf[i] != '\0'; i++) {
- if (buf[i] == '\r' || buf[i] == '\n') {
- buf[i] = '\0';
- break;
- }
- }
- if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
- clif_displaymessage(fd, buf);
- else if (gm_level >= atoi(w1))
- clif_displaymessage(fd, w2);
- }
- fclose(fp);
- } else {
- clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @help2 - Char commands [Kayla]
- *------------------------------------------
- */
-int atcommand_help2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char buf[2048], w1[2048], w2[2048];
- int i, gm_level;
- FILE* fp;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(buf, '\0', sizeof(buf));
-
- if ((fp = fopen(help2_txt, "r")) != NULL) {
- clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
- gm_level = pc_isGM(sd);
- while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
- if (buf[0] == '/' && buf[1] == '/')
- continue;
- for (i = 0; buf[i] != '\0'; i++) {
- if (buf[i] == '\r' || buf[i] == '\n') {
- buf[i] = '\0';
- break;
- }
- }
- if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
- clif_displaymessage(fd, buf);
- else if (gm_level >= atoi(w1))
- clif_displaymessage(fd, w2);
- }
- fclose(fp);
- } else {
- clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
- return -1;
- }
-
- return 0;
-}
-
-
-/*==========================================
- * @gm
- *------------------------------------------
- */
-int atcommand_gm(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char password[100];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(password, '\0', sizeof(password));
-
- if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
- clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
- return -1;
- }
-
- if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
- clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
- return -1;
- } else
- chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_pvpoff(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
-
- if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
- clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
- return -1;
- }
-
- if (map[sd->bl.m].flag.pvp) {
- map[sd->bl.m].flag.pvp = 0;
- clif_send0199(sd->bl.m, 0);
-
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) { //人数分ループ
- if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
- clif_pvpset(pl_sd, 0, 0, 2);
- if (pl_sd->pvp_timer != -1) {
- delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
- pl_sd->pvp_timer = -1;
- }
- }
- }
- clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
- } else {
- clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_pvpon(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
-
- if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
- clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
- return -1;
- }
-
- if (!map[sd->bl.m].flag.pvp) {
- map[sd->bl.m].flag.pvp = 1;
- clif_send0199(sd->bl.m, 1);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
- pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
- pl_sd->pvp_rank = 0;
- pl_sd->pvp_lastusers = 0;
- pl_sd->pvp_point = 5;
- pl_sd->pvp_won = 0;
- pl_sd->pvp_lost = 0;
- }
- }
- clif_displaymessage(fd, msg_txt(32)); // PvP: On.
- } else {
- clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_gvgoff(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.gvg) {
- map[sd->bl.m].flag.gvg = 0;
- clif_send0199(sd->bl.m, 0);
- clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
- } else {
- clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_gvgon(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (!map[sd->bl.m].flag.gvg) {
- map[sd->bl.m].flag.gvg = 1;
- clif_send0199(sd->bl.m, 3);
- clif_displaymessage(fd, msg_txt(34)); // GvG: On.
- } else {
- clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_model(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int hair_style = 0, hair_color = 0, cloth_color = 0;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
- sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
- MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
- hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
- cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
- /* Removed because this check is TOO strange. [Skotlex]
- //秒フ色変更
- if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
- //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
- //秒フ色未実装職の判定
- clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
- return -1;
- } else {
- */
- pc_changelook(sd, LOOK_HAIR, hair_style);
- pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
- pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
- clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
-// }
- } else {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @dye && @ccolor
- *------------------------------------------
- */
-int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
-{
- int cloth_color = 0;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
- sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
- pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
- clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
- } else {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @hairstyle && @hstyle
- *------------------------------------------
- */
-int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
-{
- int hair_style = 0;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
- sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
- /* Removed because this check is TOO strange. [Skotlex]
- if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
- clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
- return -1;
- } else {
- */
- pc_changelook(sd, LOOK_HAIR, hair_style);
- clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
-// }
- } else {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @charhairstyle by [MouseJstr]
- *------------------------------------------
- */
-int
-atcommand_charhairstyle(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- return 0;
-}
-
-/*==========================================
- * @haircolor && @hcolor
- *------------------------------------------
- */
-int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
-{
- int hair_color = 0;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
- sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
- /* Removed for being such a strange check. [Skotlex]
- if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
- clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
- return -1;
- } else {
- */
- pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
- clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
-// }
- } else {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @go [city_number or city_name] - Updated by Harbin
- *------------------------------------------
- */
-int atcommand_go(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- int town;
- char map_name[MAP_NAME_LENGTH];
- int m;
-
- const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
- { MAP_PRONTERA, 156, 191 }, // 0=Prontera
- { MAP_MORROC, 156, 93 }, // 1=Morroc
- { MAP_GEFFEN, 119, 59 }, // 2=Geffen
- { MAP_PAYON, 162, 233 }, // 3=Payon
- { MAP_ALBERTA, 192, 147 }, // 4=Alberta
- { MAP_IZLUDE, 128, 114 }, // 5=Izlude
- { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
- { MAP_LUTIE, 147, 134 }, // 7=Lutie
- { MAP_COMODO, 209, 143 }, // 8=Comodo
- { MAP_YUNO, 157, 51 }, // 9=Yuno
- { MAP_AMATSU, 198, 84 }, // 10=Amatsu
- { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
- { MAP_UMBALA, 89, 157 }, // 12=Umbala
- { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
- { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
- { "new_zone01.gat", 53, 111 }, // 15=Training Grounds
- { MAP_JAIL, 23, 61 }, // 16=Prison
- { MAP_JAWAII, 249, 127 }, // 17=Jawaii
- { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
- { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
- { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
- { MAP_EINBECH, 70, 95 }, // 21=Einbech
- { MAP_HUGEL, 96, 145 }, // 22=Hugel
- };
-
- nullpo_retr(-1, sd);
-
- if(map[sd->bl.m].flag.nogo) {
- clif_displaymessage(sd->fd,"You can not use @go on this map.");
- return 0;
- }
-
- malloc_tsetdword(map_name, '\0', sizeof(map_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- // get the number
- town = atoi(message);
-
- // if no value, display all value
- if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
- clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
- clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
- clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
- clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
- clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
- clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
- clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
- clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
- clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
- clif_displaymessage(fd, " 21=Einbech 22=Hugel");
- return -1;
- } else {
- // get possible name of the city and add .gat if not in the name
- map_name[MAP_NAME_LENGTH-1] = '\0';
- for (i = 0; map_name[i]; i++)
- map_name[i] = tolower(map_name[i]);
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
- // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
- if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
- town = 0;
- } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
- town = 1;
- } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
- town = 2;
- } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
- town = 3;
- } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
- town = 4;
- } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
- town = 5;
- } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
- strcmp(map_name, "al.gat") == 0) { // al (de baran)
- town = 6;
- } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
- strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
- strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
- town = 7;
- } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
- town = 8;
- } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
- town = 9;
- } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
- town = 10;
- } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
- town = 11;
- } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
- town = 12;
- } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
- town = 13;
- } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
- town = 14;
- } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
- strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
- strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
- town = 15;
- } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
- strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
- town = 16;
- } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
- town = 17;
- } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
- strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
- town = 18;
- } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
- town = 19;
- } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
- strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
- town = 20;
- } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
- town = 21;
- } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
- town = 22;
- }
-
- if (town >= -3 && town <= -1) {
- if (sd->status.memo_point[-town-1].map) {
- m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
- if (m >= 0 && map[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;
- }
- if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
- clif_displaymessage(fd, msg_txt(0)); // Warped.
- } else {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
- } else {
- sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
- } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
- m = map_mapname2mapid((char *)data[town].map);
- if (m >= 0 && map[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;
- }
- if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
- clif_displaymessage(fd, msg_txt(0)); // Warped.
- } else {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
- } else { // if you arrive here, you have an error in town variable when reading of names
- clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
- return -1;
- }
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_monster(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char name[NAME_LENGTH];
- char monster[NAME_LENGTH];
- int mob_id;
- int number = 0;
- int count;
- int i, k, range;
- short mx, my;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(name, '\0', sizeof(name));
- malloc_tsetdword(monster, '\0', sizeof(monster));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message) {
- clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
- return -1;
- }
- if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
- sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
- //All data can be left as it is.
- } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
- //Here, it is possible name was not given and we are using monster for it.
- if (count < 3) //Blank mob's name.
- name[0] = '\0';
- } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
- //All data can be left as it is.
- } else if (sscanf(message, "%23s", monster) > 0) {
- //As before, name may be already filled.
- name[0] = '\0';
- } else {
- clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
- return -1;
- }
-
- if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
- mob_id = mobdb_checkid(atoi(monster));
-
- if (mob_id == 0) {
- clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
- }
-
- if (mob_id == MOBID_EMPERIUM) {
- clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
- return -1;
- }
-
- if (number <= 0)
- number = 1;
-
- if (strlen(name) < 1)
- strcpy(name, "--ja--");
-
- // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
- if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
- number = battle_config.atc_spawn_quantity_limit;
-
- if (battle_config.etc_log)
- ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
-
- count = 0;
- range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
- for (i = 0; i < number; i++) {
- map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
- k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
- count += (k != 0) ? 1 : 0;
- }
-
- if (count != 0)
- if (number == count)
- clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
- else {
- sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
- clif_displaymessage(fd, atcmd_output);
- }
- else {
- clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
- }
-
- return 0;
-}
-
-// small monster spawning [Valaris]
-int atcommand_monstersmall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message) {
- char name[NAME_LENGTH] = "";
- char monster[NAME_LENGTH] = "";
- int mob_id = 0;
- int number = 0;
- int x = 0;
- int y = 0;
- int count;
- int i;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Give a monster name/id please.");
- return -1;
- }
-
- if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
- sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
- sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
- clif_displaymessage(fd, "Give a monster name/id please.");
- return -1;
- }
-
- // If monster identifier/name argument is a name
- if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
- mob_id = atoi(monster);
-
- if (mob_id == 0) {
- clif_displaymessage(fd, msg_txt(40));
- return -1;
- }
-
- if (mob_id == MOBID_EMPERIUM) {
- clif_displaymessage(fd, msg_txt(83));
- return -1;
- }
-
- if (mobdb_checkid(mob_id) == 0) {
- clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
- return -1;
- }
-
- if (number <= 0)
- number = 1;
-
- if (strlen(name) < 1)
- strcpy(name, "--ja--");
-
- // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
- if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
- number = battle_config.atc_spawn_quantity_limit;
-
- count = 0;
- for (i = 0; i < number; i++) {
- int mx, my;
- if (x <= 0)
- mx = sd->bl.x + (rand() % 11 - 5);
- else
- mx = x;
- if (y <= 0)
- my = sd->bl.y + (rand() % 11 - 5);
- else
- my = y;
- count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
- }
-
- if (count != 0)
- clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
- else
- clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
-
- return 0;
-}
-// big monster spawning [Valaris]
-int atcommand_monsterbig(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message) {
- char name[NAME_LENGTH] = "";
- char monster[NAME_LENGTH] = "";
- int mob_id = 0;
- int number = 0;
- int x = 0;
- int y = 0;
- int count;
- int i;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Give a monster name/id please.");
- return -1;
- }
-
- if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
- sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
- sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
- clif_displaymessage(fd, "Give a monster name/id please.");
- return -1;
- }
-
- // If monster identifier/name argument is a name
- if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
- mob_id = atoi(monster);
-
- if (mob_id == 0) {
- clif_displaymessage(fd, msg_txt(40));
- return -1;
- }
-
- if (mob_id == MOBID_EMPERIUM) {
- clif_displaymessage(fd, msg_txt(83));
- return -1;
- }
-
- if (mobdb_checkid(mob_id) == 0) {
- clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
- return -1;
- }
-
- if (number <= 0)
- number = 1;
-
- if (strlen(name) < 1)
- strcpy(name, "--ja--");
-
- // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
- if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
- number = battle_config.atc_spawn_quantity_limit;
-
- count = 0;
- for (i = 0; i < number; i++) {
- int mx, my;
- if (x <= 0)
- mx = sd->bl.x + (rand() % 11 - 5);
- else
- mx = x;
- if (y <= 0)
- my = sd->bl.y + (rand() % 11 - 5);
- else
- my = y;
- count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
- }
-
- if (count != 0)
- clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
- else
- clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int atkillmonster_sub(struct block_list *bl, va_list ap) {
- struct mob_data *md;
- int flag;
-
- nullpo_retr(0, ap);
- nullpo_retr(0, md=(struct mob_data *)bl);
- flag = va_arg(ap, int);
-
- if (md->guardian_data)
- return 0; //Do not touch WoE mobs!
-
- if (flag)
- status_zap(bl,md->status.hp, 0);
- else
- status_kill(bl);
- return 1;
-}
-void atcommand_killmonster_sub(
- const int fd, struct map_session_data* sd, const char* message,
- const int drop)
-{
- int map_id;
- char map_name[MAP_NAME_LENGTH];
-
- if (!sd) return;
-
- malloc_tsetdword(map_name, '\0', sizeof(map_name));
-
- if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
- map_id = sd->bl.m;
- else {
- if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(map_name, ".gat");
- if ((map_id = map_mapname2mapid(map_name)) < 0)
- map_id = sd->bl.m;
- }
-
- map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
-
- clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
-
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_killmonster(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if (!sd) return 0;
- atcommand_killmonster_sub(fd, sd, message, 1);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_killmonster2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if (!sd) return 0;
- atcommand_killmonster_sub(fd, sd, message, 0);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_refine(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i,j, position = 0, refine = 0, current_position, final_refine;
- int count;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
- clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
- return -1;
- }
-
- if (refine < -MAX_REFINE)
- refine = -MAX_REFINE;
- else if (refine > MAX_REFINE)
- refine = MAX_REFINE;
- else if (refine == 0)
- refine = 1;
-
- count = 0;
- for (j = 0; j < EQI_MAX-1; j++) {
- if ((i = sd->equip_index[j]) < 0)
- continue;
- if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
- continue;
- if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
- continue;
- if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
- continue;
-
- if(position && !(sd->status.inventory[i].equip & position))
- continue;
-
- final_refine = sd->status.inventory[i].refine + refine;
- if (final_refine > MAX_REFINE)
- final_refine = MAX_REFINE;
- else if (final_refine < 0)
- final_refine = 0;
- if (sd->status.inventory[i].refine != final_refine) {
- sd->status.inventory[i].refine = final_refine;
- current_position = sd->status.inventory[i].equip;
- pc_unequipitem(sd, i, 3);
- clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
- clif_delitem(sd, i, 1);
- clif_additem(sd, i, 1, 0);
- pc_equipitem(sd, i, current_position);
- clif_misceffect(&sd->bl, 3);
- count++;
- }
- }
-
- if (count == 0)
- clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
- else if (count == 1)
- clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
- else {
- sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_produce(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char item_name[100];
- int item_id, attribute = 0, star = 0;
- int flag = 0;
- struct item_data *item_data;
- struct item tmp_item;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(item_name, '\0', sizeof(item_name));
-
- if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
- clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
- return -1;
- }
-
- item_id = 0;
- if ((item_data = itemdb_searchname(item_name)) == NULL &&
- (item_data = itemdb_exists(atoi(item_name))) == NULL)
- {
- sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
- item_id = item_data->nameid;
- if (itemdb_isequip2(item_data)) {
- if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
- attribute = ATTRIBUTE_NORMAL;
- if (star < MIN_STAR || star > MAX_STAR)
- star = 0;
- malloc_set(&tmp_item, 0, sizeof tmp_item);
- tmp_item.nameid = item_id;
- tmp_item.amount = 1;
- tmp_item.identify = 1;
- tmp_item.card[0] = CARD0_FORGE;
- tmp_item.card[1] = item_data->type==IT_WEAPON?
- ((star*5) << 8) + attribute:0;
- tmp_item.card[2] = GetWord(sd->status.char_id, 0);
- tmp_item.card[3] = GetWord(sd->status.char_id, 1);
- clif_produceeffect(sd, 0, item_id);
- clif_misceffect(&sd->bl, 3);
-
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
-
- if ((flag = pc_additem(sd, &tmp_item, 1)))
- clif_additem(sd, 0, 0, flag);
- } else {
- sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * Sub-function to display actual memo points
- *------------------------------------------
- */
-void atcommand_memo_sub(struct map_session_data* sd) {
- int i;
-
- if (!sd) return;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
- for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
- if (sd->status.memo_point[i].map)
- sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
- else
- sprintf(atcmd_output, msg_txt(171), i); // %d - void
- clif_displaymessage(sd->fd, atcmd_output);
- }
-
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_memo(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int position = 0;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d", &position) < 1)
- atcommand_memo_sub(sd);
- else {
- if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
- if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(253));
- return -1;
- }
- if (sd->status.memo_point[position].map) {
- sprintf(atcmd_output, msg_txt(172), position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
- clif_displaymessage(fd, atcmd_output);
- }
- sd->status.memo_point[position].map = map[sd->bl.m].index;
- sd->status.memo_point[position].x = sd->bl.x;
- sd->status.memo_point[position].y = sd->bl.y;
- clif_skill_memo(sd, 0);
- if (pc_checkskill(sd, AL_WARP) <= (position + 1))
- clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
- atcommand_memo_sub(sd);
- } else {
- sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
- clif_displaymessage(fd, atcmd_output);
- atcommand_memo_sub(sd);
- return -1;
- }
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_gat(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int y;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- for (y = 2; y >= -2; y--) {
- sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
- map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
- map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
-
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_packet(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- static int packet_mode = 0;
- int i, x = 0, y = 0;
- nullpo_retr(-1, sd);
-
- if (strstr(command, "packetmode")) {
- packet_mode = atoi(message);
- clif_displaymessage(fd, "Packet mode changed.");
- return 0;
- }
-
- if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
- clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
- return -1;
- }
- if (i == 1) y = 1;
-
- switch (packet_mode)
- {
- case 0:
- clif_status_change(&sd->bl, x, y);
- break;
- case 1:
- sd->status.skill[sd->cloneskill_id].id=0;
- sd->status.skill[sd->cloneskill_id].lv=0;
- sd->status.skill[sd->cloneskill_id].flag=0;
- sd->cloneskill_id = x;
- sd->status.skill[x].id = x;
- sd->status.skill[x].lv = skill_get_max(x);
- sd->status.skill[x].flag = 13;//cloneskill flag
- clif_skillinfoblock(sd);
- break;
- case 2:
- clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
- case 3:
- clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
- default:
- break;
- //added later
- }
-
- return 0;
-}
-
-/*==========================================
- * @waterlevel [Skotlex]
- *------------------------------------------
- */
-
-int atcommand_waterlevel(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int newlevel;
- if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
- sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
-
- if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
- if (newlevel > 0)
- sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
- else
- sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
- clif_displaymessage(fd, atcmd_output);
- } else {
- sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
- clif_displaymessage(fd, atcmd_output);
- }
- return 0;
-}
-
-/*==========================================
- * @stpoint (Rewritten by [Yor])
- *------------------------------------------
- */
-int atcommand_statuspoint(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int point, new_status_point;
-
- if (!message || !*message || (point = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
- return -1;
- }
-
- if (point > 0 && sd->status.status_point > USHRT_MAX - point)
- new_status_point = USHRT_MAX;
- else
- if (point < 0 && sd->status.status_point < -point)
- new_status_point = 0;
- else
- new_status_point = sd->status.status_point + point;
- if (new_status_point != (int)sd->status.status_point) {
- sd->status.status_point = (unsigned short)new_status_point;
- clif_updatestatus(sd, SP_STATUSPOINT);
- clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
- } else {
- if (point < 0)
- clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
- else
- clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @skpoint (Rewritten by [Yor])
- *------------------------------------------
- */
-int atcommand_skillpoint(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int point, new_skill_point;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (point = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
- return -1;
- }
-
- if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
- new_skill_point = USHRT_MAX;
- else if (point < 0 && sd->status.skill_point < -point)
- new_skill_point = 0;
- else
- new_skill_point = sd->status.skill_point + point;
-
- if (new_skill_point != (int)sd->status.skill_point) {
- sd->status.skill_point = (unsigned short)new_skill_point;
- clif_updatestatus(sd, SP_SKILLPOINT);
- clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
- } else {
- if (point < 0)
- clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
- else
- clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @zeny (Rewritten by [Yor])
- *------------------------------------------
- */
-int atcommand_zeny(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int zeny, new_zeny;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (zeny = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
- return -1;
- }
-
- new_zeny = sd->status.zeny + zeny;
- if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
- new_zeny = MAX_ZENY;
- else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
- new_zeny = 0;
-
- if (new_zeny != sd->status.zeny) {
- sd->status.zeny = new_zeny;
- clif_updatestatus(sd, SP_ZENY);
- clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
- } else {
- if (zeny < 0)
- clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
- else
- clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_param(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int index, value = 0, new_value, max;
- const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
- short* status[6];
- //we don't use direct initialization because it isn't part of the c standard.
- nullpo_retr(-1, sd);
-
- status[0] = &sd->status.str;
- status[1] = &sd->status.agi;
- status[2] = &sd->status.vit;
- status[3] = &sd->status.int_;
- status[4] = &sd->status.dex;
- status[5] = &sd->status.luk;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
- sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- index = -1;
- for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
- if (strcmpi(command, param[index]) == 0)
- break;
- }
- if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
- // normaly impossible...
- sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
-
- max = pc_maxparameter(sd);
- if (value > 0 && *status[index] > max - value)
- new_value = max;
- else if (value < 0 && *status[index] <= -value)
- new_value = 1;
- else
- new_value = *status[index] + value;
-
- if (new_value != (int)*status[index]) {
- *status[index] = new_value;
- clif_updatestatus(sd, SP_STR + index);
- clif_updatestatus(sd, SP_USTR + index);
- status_calc_pc(sd, 0);
- clif_displaymessage(fd, msg_txt(42)); // Stat changed.
- } else {
- if (value < 0)
- clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
- else
- clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-//** Stat all by fritz (rewritten by [Yor])
-int atcommand_stat_all(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int index, count, value = 0, max, new_value;
- short* status[6];
- //we don't use direct initialization because it isn't part of the c standard.
- nullpo_retr(-1, sd);
-
- status[0] = &sd->status.str;
- status[1] = &sd->status.agi;
- status[2] = &sd->status.vit;
- status[3] = &sd->status.int_;
- status[4] = &sd->status.dex;
- status[5] = &sd->status.luk;
-
- if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
- value = pc_maxparameter(sd);
-
- count = 0;
- max = pc_maxparameter(sd);
- for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
-
- if (value > 0 && *status[index] > max - value)
- new_value = max;
- else if (value < 0 && *status[index] <= -value)
- new_value = 1;
- else
- new_value = *status[index] +value;
-
- if (new_value != (int)*status[index]) {
- *status[index] = new_value;
- clif_updatestatus(sd, SP_STR + index);
- clif_updatestatus(sd, SP_USTR + index);
- status_calc_pc(sd, 0);
- count++;
- }
- }
-
- if (count > 0) // if at least 1 stat modified
- clif_displaymessage(fd, msg_txt(84)); // All stats changed!
- else {
- if (value < 0)
- clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
- else
- clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_guildlevelup(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int level = 0;
- short added_level;
- struct guild *guild_info;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
- clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
- return -1;
- }
-
- if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
- clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
- return -1;
- }
- if (strcmp(sd->status.name, guild_info->master) != 0) {
- clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
- return -1;
- }
-
- added_level = (short)level;
- if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
- added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
- else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
- added_level = 1 - guild_info->guild_lv;
-
- if (added_level != 0) {
- intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
- clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
- } else {
- clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_makeegg(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct item_data *item_data;
- int id, pet_id;
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
- return -1;
- }
-
- if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
- id = item_data->nameid;
- else if ((id = mobdb_searchname(message)) == 0) // for monster name
- id = atoi(message);
-
- pet_id = search_petDB_index(id, PET_CLASS);
- if (pet_id < 0)
- pet_id = search_petDB_index(id, PET_EGG);
- if (pet_id >= 0) {
- sd->catch_target_class = pet_db[pet_id].class_;
- intif_create_pet(
- sd->status.account_id, sd->status.char_id,
- (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
- (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
- 100, 0, 1, pet_db[pet_id].jname);
- } else {
- clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_hatch(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (sd->status.pet_id <= 0)
- clif_sendegg(sd);
- else {
- clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_petfriendly(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int friendly;
- struct pet_data *pd;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (friendly = atoi(message)) < 0) {
- clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
- return -1;
- }
-
- pd = sd->pd;
- if (!pd) {
- clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
- return -1;
- }
-
- if (friendly < 0 || friendly > 1000)
- {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
-
- if (friendly == pd->pet.intimate) {
- clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
- return -1;
- }
- pd->pet.intimate = friendly;
- clif_send_petstatus(sd);
- clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_pethungry(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int hungry;
- struct pet_data *pd;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (hungry = atoi(message)) < 0) {
- clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
- return -1;
- }
-
- pd = sd->pd;
- if (!sd->status.pet_id || !pd) {
- clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
- return -1;
- }
- if (hungry < 0 || hungry > 100) {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
- if (hungry == pd->pet.hungry) {
- clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
- return -1;
- }
-
- pd->pet.hungry = hungry;
- clif_send_petstatus(sd);
- clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_petrename(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct pet_data *pd;
- nullpo_retr(-1, sd);
- if (!sd->status.pet_id || !sd->pd) {
- clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
- return -1;
- }
- pd = sd->pd;
- if (!pd->pet.rename_flag) {
- clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
- return -1;
- }
-
- pd->pet.rename_flag = 0;
- intif_save_petdata(sd->status.account_id, &pd->pet);
- clif_send_petstatus(sd);
- clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int
-atcommand_recall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
- return -1;
- }
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
- if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
- return -1;
- if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
- return -1;
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
- return -1;
- }
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
- return -1;
- }
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
- 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(3)); // Character not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_revive(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
- return -1;
- }
-
- pl_sd = map_nick2sd(atcmd_player_name);
-
- if (!pl_sd) {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- if (!status_revive(&sd->bl, 100, 0))
- return -1;
-
- clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
- clif_displaymessage(fd, msg_txt(51)); // Character revived.
- return 0;
-}
-
-/*==========================================
- * charblock command (usage: charblock <player_name>)
- * This command do a definitiv ban on a player
- *------------------------------------------
- */
-int atcommand_char_block(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
- return -1;
- }
-
- // check player name
- if (strlen(atcmd_player_name) < 4) {
- clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
- return -1;
- } else if (strlen(atcmd_player_name) > 23) {
- clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
- return -1;
- } else {
- chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
- clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
- }
-
- return 0;
-}
-
-/*==========================================
- * charban command (usage: charban <time> <player_name>)
- * This command do a limited ban on a player
- * Time is done as follows:
- * Adjustment value (-1, 1, +1, etc...)
- * Modified element:
- * a or y: year
- * m: month
- * j or d: day
- * h: hour
- * mn: minute
- * s: second
- * <example> @ban +1m-2mn1s-6y test_player
- * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
- *------------------------------------------
- */
-int atcommand_char_ban(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char * modif_p;
- int year, month, day, hour, minute, second, value;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
- clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
- return -1;
- }
-
- atcmd_output[sizeof(atcmd_output)-1] = '\0';
-
- modif_p = atcmd_output;
- year = month = day = hour = minute = second = 0;
- while (modif_p[0] != '\0') {
- value = atoi(modif_p);
- if (value == 0)
- modif_p++;
- else {
- if (modif_p[0] == '-' || modif_p[0] == '+')
- modif_p++;
- while (modif_p[0] >= '0' && modif_p[0] <= '9')
- modif_p++;
- if (modif_p[0] == 's') {
- second = value;
- modif_p++;
- } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
- minute = value;
- modif_p = modif_p + 2;
- } else if (modif_p[0] == 'h') {
- hour = value;
- modif_p++;
- } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
- day = value;
- modif_p++;
- } else if (modif_p[0] == 'm') {
- month = value;
- modif_p++;
- } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
- year = value;
- modif_p++;
- } else if (modif_p[0] != '\0') {
- modif_p++;
- }
- }
- }
- if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
- clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
- return -1;
- }
-
- // check player name
- if (strlen(atcmd_player_name) < 4) {
- clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
- return -1;
- } else if (strlen(atcmd_player_name) > 23) {
- clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
- return -1;
- } else {
- chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
- clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
- }
-
- return 0;
-}
-
-/*==========================================
- * charunblock command (usage: charunblock <player_name>)
- *------------------------------------------
- */
-int atcommand_char_unblock(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
- return -1;
- }
-
- // check player name
- if (strlen(atcmd_player_name) < 4) {
- clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
- return -1;
- } else if (strlen(atcmd_player_name) > 23) {
- clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
- return -1;
- } else {
- // send answer to login server via char-server
- chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
- clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
- }
-
- return 0;
-}
-
-/*==========================================
- * charunban command (usage: charunban <player_name>)
- *------------------------------------------
- */
-int atcommand_char_unban(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
- return -1;
- }
-
- // check player name
- if (strlen(atcmd_player_name) < 4) {
- clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
- return -1;
- } else if (strlen(atcmd_player_name) > 23) {
- clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
- return -1;
- } else {
- // send answer to login server via char-server
- chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
- clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_night(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- if (night_flag != 1) {
- map_night_timer(night_timer_tid, 0, 0, 1);
- } else {
- clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_day(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- if (night_flag != 0) {
- map_day_timer(day_timer_tid, 0, 0, 1);
- } else {
- clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_doom(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
- clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
- pl_allsd = map_getallusers(&users);
- for(i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
- status_kill(&pl_sd->bl);
- clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
- }
- }
- clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_doommap(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
- clif_specialeffect(&sd->bl,450,ALL_CLIENT);
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
- pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
- {
- status_kill(&pl_sd->bl);
-// clif_specialeffect(&pl_sd->bl,450,1);
- clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
- }
- }
- clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static void atcommand_raise_sub(struct map_session_data* sd)
-{
- if (!sd->state.auth || !status_isdead(&sd->bl))
- return;
-
- if(!status_revive(&sd->bl, 100, 100))
- return;
- clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
- clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_raise(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i, users;
- struct map_session_data **all_sd;
-
- nullpo_retr(-1, sd);
-
- all_sd = map_getallusers(&users);
-
- for (i = 0; i < users; i++) {
- atcommand_raise_sub(all_sd[i]);
- }
- clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_raisemap(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data **pl_allsd;
- int i, users;
-
- nullpo_retr(-1, sd);
-
- pl_allsd = map_getallusers(&users);
-
- for (i = 0; i < users; i++) {
- if (sd->bl.m == pl_allsd[i]->bl.m)
- atcommand_raise_sub(pl_allsd[i]);
- }
- clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_kick(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != 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;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_kickall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
-
- pl_allsd = map_getallusers(&users);
-
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
- if (sd->status.account_id != pl_sd->status.account_id)
- clif_GM_kick(sd, pl_sd, 0);
- }
- }
-
- clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_allskill(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- pc_allskillup(sd); // all skills
- sd->status.skill_point = 0; // 0 skill points
- clif_updatestatus(sd, SP_SKILLPOINT); // update
- clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_questskill(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int skill_id;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (skill_id = atoi(message)) < 0) {
- clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
- return -1;
- }
-
- if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
- if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
- if (pc_checkskill(sd, skill_id) == 0) {
- pc_skill(sd, skill_id, 1, 0);
- clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
- } else {
- clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_lostskill(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int skill_id;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (skill_id = atoi(message)) < 0) {
- clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
- return -1;
- }
-
- if (skill_id >= 0 && skill_id < MAX_SKILL) {
- if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
- if (pc_checkskill(sd, skill_id) > 0) {
- sd->status.skill[skill_id].lv = 0;
- sd->status.skill[skill_id].flag = 0;
- clif_skillinfoblock(sd);
- clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
- } else {
- clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_spiritball(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int number;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || (number = atoi(message)) < 0) {
- clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
- return -1;
- }
-
- // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
- if (number > 500)
- number = 500;
-
- if (number >= 0 && number <= 0x7FFF) {
- if (sd->spiritball != number || number > 499) {
- if (sd->spiritball > 0)
- pc_delspiritball(sd, sd->spiritball, 1);
- sd->spiritball = number;
- clif_spiritball(sd);
- // no message, player can look the difference
- if (number > 1000)
- clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
- } else {
- clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_party(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char party[NAME_LENGTH];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(party, '\0', sizeof(party));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
- clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
- return -1;
- }
-
- party_create(sd, party, 0, 0);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_guild(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char guild[NAME_LENGTH];
- int prev;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(guild, '\0', sizeof(guild));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
- clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
- return -1;
- }
-
- prev = battle_config.guild_emperium_check;
- battle_config.guild_emperium_check = 0;
- guild_create(sd, guild);
- battle_config.guild_emperium_check = prev;
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_agitstart(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (agit_flag == 1) {
- clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
- return -1;
- }
-
- agit_flag = 1;
- guild_agit_start();
- clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_agitend(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (agit_flag == 0) {
- clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
- return -1;
- }
-
- agit_flag = 0;
- guild_agit_end();
- clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
-
- return 0;
-}
-
-/*==========================================
- * @mapexitでマップサーバーを終了させる
- *------------------------------------------
- */
-int atcommand_mapexit(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
-
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
- clif_GM_kick(sd, pl_sd, 0);
- }
- clif_GM_kick(sd, sd, 0);
-
- flush_fifos();
-
- runflag = 0;
-
- return 0;
-}
-
-/*==========================================
- * idsearch <part_of_name>: revrited by [Yor]
- *------------------------------------------
- */
-int atcommand_idsearch(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char item_name[100];
- unsigned int i, match;
- struct item_data *item_array[MAX_SEARCH];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(item_name, '\0', sizeof(item_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
- clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
- return -1;
- }
-
- sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
- clif_displaymessage(fd, atcmd_output);
- match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
- if (match > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
- clif_displaymessage(fd, atcmd_output);
- match = MAX_SEARCH;
- }
- for(i = 0; i < match; i++) {
- sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
- clif_displaymessage(fd, atcmd_output);
- }
- sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- * Recall All Characters Online To Your Location
- *------------------------------------------
- */
-int atcommand_recallall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i;
- int count, users;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
- return -1;
- }
-
- count = 0;
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
- 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.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
- count++;
- else {
- if (pc_isdead(pl_sd)) { //Wake them up
- pc_setstand(pl_sd);
- pc_setrestartvalue(pl_sd,1);
- }
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- }
- }
- }
-
- clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
- if (count) {
- sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-/*==========================================
- * Recall online characters of a guild to your location
- *------------------------------------------
- */
-int atcommand_guildrecall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users, count;
- char guild_name[NAME_LENGTH];
- struct guild *g;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
- clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
- return -1;
- }
-
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
- return -1;
- }
-
- if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
- (g = guild_search(atoi(message))) != NULL) {
- count = 0;
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
- pl_sd->status.guild_id == g->guild_id) {
- if (pc_isGM(pl_sd) > pc_isGM(sd))
- continue; //Skip GMs greater than you.
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
- count++;
- else
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- }
- }
- sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
- clif_displaymessage(fd, atcmd_output);
- if (count) {
- sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
- clif_displaymessage(fd, atcmd_output);
- }
- } else {
- clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * Recall online characters of a party to your location
- *------------------------------------------
- */
-int atcommand_partyrecall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- struct map_session_data *pl_sd, **pl_allsd;
- char party_name[NAME_LENGTH];
- struct party_data *p;
- int count, users;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(party_name, '\0', sizeof(party_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
- clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
- return -1;
- }
-
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
- return -1;
- }
-
- if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
- (p = party_search(atoi(message))) != NULL) {
- count = 0;
-
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
- pl_sd->status.party_id == p->party.party_id) {
- if (pc_isGM(pl_sd) > pc_isGM(sd))
- continue; //Skip GMs greater than you.
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
- count++;
- else
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- }
- }
- sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
- clif_displaymessage(fd, atcmd_output);
- if (count) {
- sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
- clif_displaymessage(fd, atcmd_output);
- }
- } else {
- clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_reloaditemdb(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- itemdb_reload();
- clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_reloadmobdb(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- mob_reload();
- read_petdb();
- merc_reload();
- clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_reloadskilldb(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- skill_reload();
- merc_skill_reload();
- clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
-
- return 0;
-}
-
-/*==========================================
- * @reloadatcommand
- * atcommand_athena.conf のリロード
- *------------------------------------------
- */
-int
-atcommand_reloadatcommand(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- atcommand_config_read(ATCOMMAND_CONF_FILENAME);
- clif_displaymessage(fd, msg_txt(254));
- return 0;
-}
-/*==========================================
- * @reloadbattleconf
- * battle_athena.conf のリロード
- *------------------------------------------
- */
-int
-atcommand_reloadbattleconf(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct Battle_Config prev_config;
- memcpy(&prev_config, &battle_config, sizeof(prev_config));
-
- battle_config_read(BATTLE_CONF_FILENAME);
-
- if (memcmp(&prev_config.item_rate_mvp,
- &battle_config.item_rate_mvp,
- sizeof(battle_config.item_rate_mvp)+
- sizeof(battle_config.item_rate_common)+
- sizeof(battle_config.item_rate_common_boss)+
- sizeof(battle_config.item_rate_card)+
- sizeof(battle_config.item_rate_card_boss)+
- sizeof(battle_config.item_rate_equip)+
- sizeof(battle_config.item_rate_equip_boss)+
- sizeof(battle_config.item_rate_heal)+
- sizeof(battle_config.item_rate_heal_boss)+
- sizeof(battle_config.item_rate_use)+
- sizeof(battle_config.item_rate_use_boss)+
- sizeof(battle_config.item_rate_treasure)+
- sizeof(battle_config.item_rate_adddrop)+
- sizeof(battle_config.logarithmic_drops)+
- sizeof(battle_config.item_drop_common_min)+
- sizeof(battle_config.item_drop_common_max)+
- sizeof(battle_config.item_drop_card_min)+
- sizeof(battle_config.item_drop_card_max)+
- sizeof(battle_config.item_drop_equip_min)+
- sizeof(battle_config.item_drop_equip_max)+
- sizeof(battle_config.item_drop_mvp_min)+
- sizeof(battle_config.item_drop_mvp_max)+
- sizeof(battle_config.item_drop_heal_min)+
- sizeof(battle_config.item_drop_heal_max)+
- sizeof(battle_config.item_drop_use_min)+
- sizeof(battle_config.item_drop_use_max)+
- sizeof(battle_config.item_drop_treasure_min)+
- sizeof(battle_config.item_drop_treasure_max)
- ) != 0)
- { //Drop rates changed.
- mob_reload(); //Needed as well so rate changes take effect.
-#ifndef TXT_ONLY
- chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
-#endif
- }
- clif_displaymessage(fd, msg_txt(255));
- return 0;
-}
-/*==========================================
- * @reloadstatusdb
- * job_db1.txt job_db2.txt job_db2-2.txt
- * refine_db.txt size_fix.txt
- * のリロード
- *------------------------------------------
- */
-int
-atcommand_reloadstatusdb(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- status_readdb();
- clif_displaymessage(fd, msg_txt(256));
- return 0;
-}
-/*==========================================
- * @reloadpcdb
- * exp.txt skill_tree.txt attr_fix.txt
- * のリロード
- *------------------------------------------
- */
-int
-atcommand_reloadpcdb(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- pc_readdb();
- clif_displaymessage(fd, msg_txt(257));
- return 0;
-}
-
-/*==========================================
- * @reloadmotd [Valaris]
- * Reloads motd.txt
- *------------------------------------------
- */
-int
-atcommand_reloadmotd(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- pc_read_motd();
- clif_displaymessage(fd, msg_txt(268));
- return 0;
-}
-
-
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_reloadscript(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
- atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
- atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
- flush_fifos();
-
- //do_init_npc();
- script_reload();
- npc_reload();
-
- clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_reloadgmdb( // by [Yor]
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- chrif_reloadGMdb();
-
- clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
-
- return 0;
-}
-
-/*==========================================
- * @mapinfo <map name> [0-3] by MC_Cameri
- * => Shows information about the map [map name]
- * 0 = no additional information
- * 1 = Show users in that map and their location
- * 2 = Shows NPCs in that map
- * 3 = Shows the shops/chats in that map (not implemented)
- *------------------------------------------
- */
-int atcommand_mapinfo(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- struct npc_data *nd = NULL;
- struct chat_data *cd = NULL;
- char direction[12];
- int m_id, i, chat_num, users, list = 0;
- unsigned short m_index;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(direction, '\0', sizeof(direction));
-
- sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
-
- if (list < 0 || list > 3) {
- clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
- return -1;
- }
-
- if (atcmd_player_name[0] == '\0') {
- memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
- atcmd_player_name[MAP_NAME_LENGTH] = '\0';
- m_id = map_mapindex2mapid(sd->mapindex);
- } else {
- if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
- strcat(atcmd_player_name, ".gat");
- m_id = map_mapname2mapid(atcmd_player_name);
- }
- if (m_id < 0) {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
- m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
-
- clif_displaymessage(fd, "------ Map Info ------");
- chat_num = 0;
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
- chat_num++;
- }
- }
- sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
- clif_displaymessage(fd, atcmd_output);
- if (map[m_id].flag.alias)
- strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
- clif_displaymessage(fd, "------ Map Flags ------");
- strcpy(atcmd_output,"PvP Flags: ");
- if (map[m_id].flag.pvp)
- strcat(atcmd_output, "Pvp ON | ");
- if (map[m_id].flag.pvp_noguild)
- strcat(atcmd_output, "NoGuild | ");
- if (map[m_id].flag.pvp_noparty)
- strcat(atcmd_output, "NoParty | ");
- if (map[m_id].flag.pvp_nightmaredrop)
- strcat(atcmd_output, "NightmareDrop | ");
- if (map[m_id].flag.pvp_nocalcrank)
- strcat(atcmd_output, "NoCalcRank | ");
- clif_displaymessage(fd, atcmd_output);
-
- strcpy(atcmd_output,"GvG Flags: ");
- if (map[m_id].flag.gvg)
- strcat(atcmd_output, "GvG ON | ");
- if (map[m_id].flag.gvg_dungeon)
- strcat(atcmd_output, "GvG Dungeon | ");
- if (map[m_id].flag.gvg_castle)
- strcat(atcmd_output, "GvG Castle | ");
- if (map[m_id].flag.gvg_noparty)
- strcat(atcmd_output, "NoParty | ");
- clif_displaymessage(fd, atcmd_output);
-
- strcpy(atcmd_output,"Teleport Flags: ");
- if (map[m_id].flag.noteleport)
- strcat(atcmd_output, "NoTeleport | ");
- if (map[m_id].flag.monster_noteleport)
- strcat(atcmd_output, "Monster NoTeleport | ");
- if (map[m_id].flag.nowarp)
- strcat(atcmd_output, "NoWarp | ");
- if (map[m_id].flag.nowarpto)
- strcat(atcmd_output, "NoWarpTo | ");
- if (map[m_id].flag.noreturn)
- strcat(atcmd_output, "NoReturn | ");
- if (map[m_id].flag.nogo)
- strcat(atcmd_output, "NoGo | ");
- if (map[m_id].flag.nomemo)
- strcat(atcmd_output, "NoMemo | ");
- clif_displaymessage(fd, atcmd_output);
-
- sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
- clif_displaymessage(fd, atcmd_output);
-
- if (map[m_id].flag.nosave) {
- if (!map[m_id].save.map)
- sprintf(atcmd_output, "No Save (Return to last Save Point)");
- else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
- sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
- else
- sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
- mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
- clif_displaymessage(fd, atcmd_output);
- }
-
- strcpy(atcmd_output,"Weather Flags: ");
- if (map[m_id].flag.snow)
- strcat(atcmd_output, "Snow | ");
- if (map[m_id].flag.fog)
- strcat(atcmd_output, "Fog | ");
- if (map[m_id].flag.sakura)
- strcat(atcmd_output, "Sakura | ");
- if (map[m_id].flag.clouds)
- strcat(atcmd_output, "Clouds | ");
- if (map[m_id].flag.clouds2)
- strcat(atcmd_output, "Clouds2 | ");
- if (map[m_id].flag.fireworks)
- strcat(atcmd_output, "Fireworks | ");
- if (map[m_id].flag.leaves)
- strcat(atcmd_output, "Leaves | ");
- if (map[m_id].flag.rain)
- strcat(atcmd_output, "Rain | ");
- if (map[m_id].flag.indoors)
- strcat(atcmd_output, "Indoors | ");
- if (map[m_id].flag.nightenabled)
- strcat(atcmd_output, "Displays Night | ");
- clif_displaymessage(fd, atcmd_output);
-
- strcpy(atcmd_output,"Other Flags: ");
- if (map[m_id].flag.nobranch)
- strcat(atcmd_output, "NoBranch | ");
- if (map[m_id].flag.notrade)
- strcat(atcmd_output, "NoTrade | ");
- if (map[m_id].flag.novending)
- strcat(atcmd_output, "NoVending | ");
- if (map[m_id].flag.nodrop)
- strcat(atcmd_output, "NoDrop | ");
- if (map[m_id].flag.noskill)
- strcat(atcmd_output, "NoSkill | ");
- if (map[m_id].flag.noicewall)
- strcat(atcmd_output, "NoIcewall | ");
-
- clif_displaymessage(fd, atcmd_output);
-
- strcpy(atcmd_output,"Other Flags: ");
- if (map[m_id].nocommand)
- strcat(atcmd_output, "NoCommand | ");
- if (map[m_id].flag.nobaseexp)
- strcat(atcmd_output, "NoBaseEXP | ");
- if (map[m_id].flag.nojobexp)
- strcat(atcmd_output, "NoJobEXP | ");
- if (map[m_id].flag.nomobloot)
- strcat(atcmd_output, "NoMobLoot | ");
- if (map[m_id].flag.nomvploot)
- strcat(atcmd_output, "NoMVPLoot | ");
- if (map[m_id].flag.partylock)
- strcat(atcmd_output, "PartyLock | ");
- if (map[m_id].flag.guildlock)
- strcat(atcmd_output, "GuildLock | ");
- clif_displaymessage(fd, atcmd_output);
-
-
- switch (list) {
- case 0:
- // Do nothing. It's list 0, no additional display.
- break;
- case 1:
- clif_displaymessage(fd, "----- Players in Map -----");
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
- sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
- pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
- clif_displaymessage(fd, atcmd_output);
- }
- }
- break;
- case 2:
- clif_displaymessage(fd, "----- NPCs in Map -----");
- for (i = 0; i < map[m_id].npc_num;) {
- nd = map[m_id].npc[i];
- switch(nd->ud.dir) {
- case 0: strcpy(direction, "North"); break;
- case 1: strcpy(direction, "North West"); break;
- case 2: strcpy(direction, "West"); break;
- case 3: strcpy(direction, "South West"); break;
- case 4: strcpy(direction, "South"); break;
- case 5: strcpy(direction, "South East"); break;
- case 6: strcpy(direction, "East"); break;
- case 7: strcpy(direction, "North East"); break;
- case 9: strcpy(direction, "North"); break;
- default: strcpy(direction, "Unknown"); break;
- }
- sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
- ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
- clif_displaymessage(fd, atcmd_output);
- }
- break;
- case 3:
- clif_displaymessage(fd, "----- Chats in Map -----");
- for (i = 0; i < users; i++) {
- if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
- pl_sd->mapindex == m_index &&
- cd->usersd[0] == pl_sd) {
- sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
- i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
- clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
- cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
- clif_displaymessage(fd, atcmd_output);
- }
- }
- break;
- default: // normally impossible to arrive here
- clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
- return -1;
- break;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_mount_peco(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- if (!pc_isriding(sd)) { // if actually no peco
- if (pc_checkskill(sd, KN_RIDING)) {
- pc_setoption(sd, sd->sc.option | 0x0020);
- clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
- } else {
- clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
- return -1;
- }
- } else { //Dismount
- pc_setoption(sd, sd->sc.option & ~0x0020);
- clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_char_mount_peco(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
-
- if (!pc_isriding(pl_sd)) { // if actually no peco
- if (pc_checkskill(pl_sd, KN_RIDING)) {
- pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
- clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
- } else {
- clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
- return -1;
- }
- } else { //Dismount
- pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
- clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *Spy Commands by Syrus22
- *------------------------------------------
- */
-int atcommand_guildspy(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char guild_name[NAME_LENGTH];
- struct guild *g;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!enable_spy)
- {
- clif_displaymessage(fd, "The mapserver has spy command support disabled.");
- return -1;
- }
- if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
- clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
- return -1;
- }
-
- if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
- (g = guild_search(atoi(message))) != NULL) {
- if (sd->guildspy == g->guild_id) {
- sd->guildspy = 0;
- sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
- clif_displaymessage(fd, atcmd_output);
- } else {
- sd->guildspy = g->guild_id;
- sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
- clif_displaymessage(fd, atcmd_output);
- }
- } else {
- clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_partyspy(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char party_name[NAME_LENGTH];
- struct party_data *p;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(party_name, '\0', sizeof(party_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!enable_spy)
- {
- clif_displaymessage(fd, "The mapserver has spy command support disabled.");
- return -1;
- }
-
- if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
- clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
- return -1;
- }
-
- if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
- (p = party_search(atoi(message))) != NULL) {
- if (sd->partyspy == p->party.party_id) {
- sd->partyspy = 0;
- sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
- clif_displaymessage(fd, atcmd_output);
- } else {
- sd->partyspy = p->party.party_id;
- sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
- clif_displaymessage(fd, atcmd_output);
- }
- } else {
- clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @repairall [Valaris]
- *------------------------------------------
- */
-int atcommand_repairall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int count, i;
- nullpo_retr(-1, sd);
-
- count = 0;
- for (i = 0; i < MAX_INVENTORY; i++) {
- if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
- sd->status.inventory[i].attribute = 0;
- clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
- count++;
- }
- }
-
- if (count > 0) {
- clif_misceffect(&sd->bl, 3);
- clif_equiplist(sd);
- clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
- } else {
- clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
- return -1;
- }
-
- return 0;
-}
-
-// Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
-int atcommand_nuke(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
- skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
- clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
- } 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;
- }
-
- return 0;
-}
-
-/*==========================================
- * @tonpc
- *------------------------------------------
- */
-int atcommand_tonpc(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
-
- char npcname[NAME_LENGTH];
- struct npc_data *nd;
-
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(npcname, 0, sizeof(npcname));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
- clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
- return -1;
- }
-
- if ((nd = npc_name2id(npcname)) != NULL) {
- if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
- clif_displaymessage(fd, msg_txt(0)); // Warped.
- else
- return -1;
- } else {
- clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_shownpc(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char NPCname[NAME_LENGTH];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
- clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
- return -1;
- }
-
- if (npc_name2id(NPCname) != NULL) {
- npc_enable(NPCname, 1);
- clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
- } else {
- clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int atcommand_hidenpc(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char NPCname[NAME_LENGTH];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
- clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
- return -1;
- }
-
- if (npc_name2id(NPCname) != NULL) {
- npc_enable(NPCname, 0);
- clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
- } else {
- clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-int atcommand_loadnpc(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- FILE *fp;
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
- return -1;
- }
-
- // check if script file exists
- if ((fp = fopen(message, "r")) == NULL) {
- clif_displaymessage(fd, msg_txt(261));
- return -1;
- }
- fclose(fp);
-
- // add to list of script sources and run it
- npc_addsrcfile((char *)message);
- npc_parsesrcfile((char *)message);
-
- clif_displaymessage(fd, msg_txt(262));
-
- return 0;
-}
-
-int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct npc_data *nd;
- char NPCname[NAME_LENGTH];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
- clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
- return -1;
- }
-
- if ((nd = npc_name2id(NPCname)) != NULL) {
- npc_unload_duplicates(nd);
- npc_unload(nd);
- clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
- } else {
- clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * time in txt for time command (by [Yor])
- *------------------------------------------
- */
-char * txt_time(unsigned int duration) {
- int days, hours, minutes, seconds;
- char temp[256];
- static char temp1[256];
-
- malloc_tsetdword(temp, '\0', sizeof(temp));
- malloc_tsetdword(temp1, '\0', sizeof(temp1));
-
- days = duration / (60 * 60 * 24);
- duration = duration - (60 * 60 * 24 * days);
- hours = duration / (60 * 60);
- duration = duration - (60 * 60 * hours);
- minutes = duration / 60;
- seconds = duration - (60 * minutes);
-
- if (days < 2)
- sprintf(temp, msg_txt(219), days); // %d day
- else
- sprintf(temp, msg_txt(220), days); // %d days
- if (hours < 2)
- sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
- else
- sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
- if (minutes < 2)
- sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
- else
- sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
- if (seconds < 2)
- sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
- else
- sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
-
- return temp1;
-}
-
-/*==========================================
- * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
- * Calculation management of GM modification (@day/@night GM commands) is done
- *------------------------------------------
- */
-int atcommand_servertime(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct TimerData * timer_data;
- struct TimerData * timer_data2;
- time_t time_server; // variable for number of seconds (used with time() function)
- struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
- char temp[256];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(temp, '\0', sizeof(temp));
-
- time(&time_server); // get time in seconds since 1/1/1970
- datetime = localtime(&time_server); // convert seconds in structure
- // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
- strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
- clif_displaymessage(fd, temp);
-
- if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
- if (night_flag == 0)
- clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
- else
- clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
- } else if (battle_config.night_duration == 0)
- if (night_flag == 1) { // we start with night
- timer_data = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
- clif_displaymessage(fd, temp);
- clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
- } else
- clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
- else if (battle_config.day_duration == 0)
- if (night_flag == 0) { // we start with day
- timer_data = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
- clif_displaymessage(fd, temp);
- clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
- } else
- clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
- else {
- if (night_flag == 0) {
- timer_data = get_timer(night_timer_tid);
- timer_data2 = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
- clif_displaymessage(fd, temp);
- if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
- sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
- else
- sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
- clif_displaymessage(fd, temp);
- sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
- clif_displaymessage(fd, temp);
- } else {
- timer_data = get_timer(day_timer_tid);
- timer_data2 = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
- clif_displaymessage(fd, temp);
- if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
- sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
- else
- sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
- clif_displaymessage(fd, temp);
- sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
- clif_displaymessage(fd, temp);
- }
- }
-
- return 0;
-}
-
-/*==========================================
- * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
- * removes <quantity> item from a character
- * item can be equiped or not.
- * Inspired from a old command created by RoVeRT
- *------------------------------------------
- */
-int atcommand_chardelitem(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- char item_name[100];
- int i, number = 0, item_id, item_position, count;
- struct item_data *item_data;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(item_name, '\0', sizeof(item_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
- clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
- return -1;
- }
-
- item_id = 0;
- if ((item_data = itemdb_searchname(item_name)) != NULL ||
- (item_data = itemdb_exists(atoi(item_name))) != NULL)
- item_id = item_data->nameid;
-
- if (item_id > 500) {
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
- item_position = pc_search_inventory(pl_sd, item_id);
- if (item_position >= 0) {
- count = 0;
- for(i = 0; i < number && item_position >= 0; i++) {
-
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
-
- pc_delitem(pl_sd, item_position, 1, 0);
- count++;
- item_position = pc_search_inventory(pl_sd, item_id); // for next loop
- }
- sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
- clif_displaymessage(pl_sd->fd, atcmd_output);
- if (number == count)
- sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
- else
- sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
- return -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(19)); // Invalid item ID or name.
- return -1;
- }
-
- return 0;
-}
-
-//Added by Coltaro
-//We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
-//Well, using time_t could still work but for some reason that looks like more coding x_x
-static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
- const int factor_year = 518400; //12*30*24*60 = 518400
- const int factor_month = 43200; //30*24*60 = 43200
- const int factor_day = 1440; //24*60 = 1440
- const int factor_hour = 60;
-
- *year = jailtime/factor_year;
- jailtime -= *year*factor_year;
- *month = jailtime/factor_month;
- jailtime -= *month*factor_month;
- *day = jailtime/factor_day;
- jailtime -= *day*factor_day;
- *hour = jailtime/factor_hour;
- jailtime -= *hour*factor_hour;
- *minute = jailtime;
-
- *year = *year > 0? *year : 0;
- *month = *month > 0? *month : 0;
- *day = *day > 0? *day : 0;
- *hour = *hour > 0? *hour : 0;
- *minute = *minute > 0? *minute : 0;
- return;
-}
-
-/*==========================================
- * @jail <char_name> by [Yor]
- * Special warp! No check with nowarp and nowarpto flag
- *------------------------------------------
- */
-int atcommand_jail(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- int x, y;
- unsigned short m_index;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- if (pc_isGM(sd) < pc_isGM(pl_sd))
- { // you can jail only lower or same GM
- 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->mapindex == mapindex_name2id(MAP_JAIL))
- { //Already jailed
- clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
- return -1;
- }
-
- switch(rand() % 2) { //Jail Locations
- case 0:
- m_index = mapindex_name2id(MAP_JAIL);
- x = 24;
- y = 75;
- break;
- default:
- m_index = mapindex_name2id(MAP_JAIL);
- x = 49;
- y = 75;
- break;
- }
- if (pc_setpos(pl_sd, m_index, x, y, 3)) {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
-
- pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
- clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
- clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
- return 0;
-}
-
-/*==========================================
- * @unjail/@discharge <char_name> by [Yor]
- * Special warp! No check with nowarp and nowarpto flag
- *------------------------------------------
- */
-int atcommand_unjail(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- unsigned short m_index;
- int x=0, y=0;
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
-
- 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->mapindex != mapindex_name2id(MAP_JAIL)) {
- clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
- return -1;
- }
-
- if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
- { //Retrieve return map.
- m_index = pl_sd->sc.data[SC_JAILED].val3;
- x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
- y = pl_sd->sc.data[SC_JAILED].val4>>16;
- status_change_end(&pl_sd->bl,SC_JAILED,-1);
- } else
- m_index = mapindex_name2id(MAP_PRONTERA);
-
- if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
- pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
- ) { //Send to Prontera is saved SC map fails.
- pc_setsavepoint(pl_sd, m_index, x, y);
- clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
- clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
- } else {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
- return 0;
-}
-
-int atcommand_jailfor(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int year, month, day, hour, minute, value;
- char * modif_p;
- int jailtime = 0,x,y;
- short m_index = 0;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
- clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
- return -1;
- }
-
- atcmd_output[sizeof(atcmd_output)-1] = '\0';
-
- modif_p = atcmd_output;
- year = month = day = hour = minute = 0;
- while (modif_p[0] != '\0') {
- value = atoi(modif_p);
- if (value == 0)
- modif_p++;
- else {
- if (modif_p[0] == '-' || modif_p[0] == '+')
- modif_p++;
- while (modif_p[0] >= '0' && modif_p[0] <= '9')
- modif_p++;
- if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
- minute = value;
- modif_p = modif_p + 2;
- } else if (modif_p[0] == 'h') {
- hour = value;
- modif_p++;
- } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
- day = value;
- modif_p++;
- } else if (modif_p[0] == 'm') {
- month = value;
- modif_p++;
- } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
- year = value;
- modif_p++;
- } else if (modif_p[0] != '\0') {
- modif_p++;
- }
- }
- }
-
- if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
- clif_displaymessage(fd, "Invalid time for jail command.");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- if (pc_isGM(pl_sd) > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
-
- jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
-
- if(jailtime==0) {
- clif_displaymessage(fd, "Invalid time for jail command.");
- return -1;
- }
-
- //Added by Coltaro
- if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
- { //Update the player's jail time
- jailtime += pl_sd->sc.data[SC_JAILED].val1;
- if (jailtime <= 0) {
- jailtime = 0;
- clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
- clif_displaymessage(fd, msg_txt(121)); // Player unjailed
- } else {
- get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
- clif_displaymessage(pl_sd->fd, atcmd_output);
- sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
- clif_displaymessage(fd, atcmd_output);
- }
- } else if (jailtime < 0) {
- clif_displaymessage(fd, "Invalid time for jail command.");
- return -1;
- }
-
- //Jail locations, add more as you wish.
- switch(rand()%2)
- {
- case 1: //Jail #1
- m_index = mapindex_name2id(MAP_JAIL);
- x = 49; y = 75;
- break;
- default: //Default Jail
- m_index = mapindex_name2id(MAP_JAIL);
- x = 24; y = 75;
- break;
- }
-
- sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
- return 0;
-}
-
-
-//By Coltaro
-int atcommand_jailtime(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
- {
- int year, month, day, hour, minute;
-
- nullpo_retr(-1, sd);
-
- if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
- clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
- return -1;
- }
-
- if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1 || sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
- clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
- return -1;
- }
-
- //Get remaining jail time
- get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
-
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-//By Coltaro
-int atcommand_charjailtime(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
- {
- struct map_session_data* pl_sd;
- int year, month, day, hour, minute;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
- if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
- clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
- return -1;
- }
- if (!pl_sd->sc.count || pl_sd->sc.data[SC_JAILED].timer == -1 || pl_sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail?)
- clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
- return -1;
- }
- //Get remaining jail time
- get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
- sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @disguise <mob_id> by [Valaris] (simplified by [Yor])
- *------------------------------------------
- */
-int atcommand_disguise(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int id = 0;
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
- return -1;
- }
-
- if ((id = atoi(message)) > 0)
- { //Acquired an ID
- if (!mobdb_checkid(id) && !npcdb_checkid(id))
- id = 0; //Invalid id for either mobs or npcs.
- } else { //Acquired a Name
- if ((id = mobdb_searchname(message)) == 0)
- {
- struct npc_data* nd = npc_name2id(message);
- if (nd != NULL)
- id = nd->n;
- }
- }
-
- if (id == 0)
- { // Monster/NPC name/id hasn't been found.
- clif_displaymessage(fd, msg_txt(123));
- return -1;
- }
-
- pc_disguise(sd, id);
- clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
-
- return 0;
-}
-
-/*==========================================
- * DisguiseAll
- *------------------------------------------
- */
-
-int atcommand_disguiseall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int mob_id=0, i=0, users;
- struct map_session_data *pl_sd, **pl_allsd;
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
- return -1;
- }
-
- if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
- mob_id = atoi(message);
-
- if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
- pl_allsd = map_getallusers(&users);
- for(i=0; i < users; i++) {
- if((pl_sd = pl_allsd[i]))
- pc_disguise(pl_sd, mob_id);
- }
- clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
- } else {
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @undisguise by [Yor]
- *------------------------------------------
- */
-int atcommand_undisguise(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (sd->disguise) {
- pc_disguise(sd, 0);
- clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
- } else {
- clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * UndisguiseAll
- *------------------------------------------
- */
-int atcommand_undisguiseall(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd, **pl_allsd;
- int i, users;
- nullpo_retr(-1, sd);
-
- pl_allsd = map_getallusers(&users);
-
- for(i=0; i < users; i++) {
- if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
- pc_disguise(pl_sd, 0);
- }
- clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
-
- return 0;
-}
-/*==========================================
- * @exp by [Skotlex]
- *------------------------------------------
- */
-int atcommand_exp(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char output[200];
- double nextb, nextj;
- nullpo_retr(-1, sd);
- malloc_tsetdword(output, '\0', sizeof(output));
-
- nextb = pc_nextbaseexp(sd);
- if (nextb)
- nextb = sd->status.base_exp*100.0/nextb;
-
- nextj = pc_nextjobexp(sd);
- if (nextj)
- nextj = sd->status.job_exp*100.0/nextj;
-
- sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
- clif_displaymessage(fd, output);
- return 0;
-}
-
-
-/*==========================================
- * @broadcast by [Valaris]
- *------------------------------------------
- */
-int atcommand_broadcast(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
- return -1;
- }
-
- sprintf(atcmd_output, "%s : %s", sd->status.name, message);
- intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
-
- return 0;
-}
-
-/*==========================================
- * @localbroadcast by [Valaris]
- *------------------------------------------
- */
-int atcommand_localbroadcast(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
- return -1;
- }
-
- sprintf(atcmd_output, "%s : %s", sd->status.name, message);
-
- clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
-
- return 0;
-}
-
-/*==========================================
- * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
- *------------------------------------------
- */
-int atcommand_chardisguise(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int mob_id;
- char mob_name[NAME_LENGTH];
- struct map_session_data* pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(mob_name, '\0', sizeof(mob_name));
-
- if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
- clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
- return -1;
- }
-
- if ((mob_id = atoi(mob_name)) > 0)
- { //Acquired an ID
- if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
- mob_id = 0; //Invalid id for either mobs or npcs.
- } else { //Acquired a Name
- if ((mob_id = mobdb_searchname(mob_name)) == 0)
- {
- struct npc_data* nd = npc_name2id(mob_name);
- if (nd != NULL)
- mob_id = nd->n;
- }
- }
-
- if (mob_id == 0)
- {
- clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
- pc_disguise(pl_sd, mob_id);
- clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
- } 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;
- }
-
- return 0;
-}
-
-/*==========================================
- * @charundisguise <character> by Kalaspuff (based off Yor's work)
- *------------------------------------------
- */
-int atcommand_charundisguise(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data* pl_sd;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
- if (pl_sd->disguise)
- pc_disguise(pl_sd, 0);
- else {
- clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
- return -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;
- }
-
- return 0;
-}
-
-/*==========================================
- * @email <actual@email> <new@email> by [Yor]
- *------------------------------------------
- */
-int atcommand_email(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char actual_email[100];
- char new_email[100];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(actual_email, '\0', sizeof(actual_email));
- malloc_tsetdword(new_email, '\0', sizeof(new_email));
-
- if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
- clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
- return -1;
- }
-
- if (e_mail_check(actual_email) == 0) {
- clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
- return -1;
- } else if (e_mail_check(new_email) == 0) {
- clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
- return -1;
- } else if (strcmpi(new_email, "a@a.com") == 0) {
- clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
- return -1;
- } else if (strcmpi(actual_email, new_email) == 0) {
- clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
- return -1;
- } else {
- chrif_changeemail(sd->status.account_id, actual_email, new_email);
- clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
- }
-
- return 0;
-}
-
-/*==========================================
- *@effect
- *------------------------------------------
- */
-int atcommand_effect(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int type = 0, flag = 0;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
- clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
- return -1;
- }
-
- clif_specialeffect(&sd->bl, type, flag);
- clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
-
- return 0;
-}
-
-/*==========================================
- * @charcartlist <character>: Displays the items list of a player's cart.
- *------------------------------------------
- */
-int
-atcommand_character_cart_list(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char outputtmp[200];
- struct map_session_data *pl_sd;
- struct item_data *item_data, *item_temp;
- int i, j, count, counter, counter2;
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
-
- if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
- counter = 0;
- count = 0;
- for (i = 0; i < MAX_CART; i++) {
- if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
- counter = counter + pl_sd->status.cart[i].amount;
- count++;
- if (count == 1) {
- sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
- clif_displaymessage(fd, atcmd_output);
- }
- if (pl_sd->status.cart[i].refine)
- sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
- else
- sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
- clif_displaymessage(fd, atcmd_output);
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- counter2 = 0;
- for (j = 0; j < item_data->slot; j++) {
- if (pl_sd->status.cart[i].card[j]) {
- if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
- if (atcmd_output[0] == '\0')
- sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
- else
- sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
- strcat(atcmd_output, outputtmp);
- }
- }
- }
- if (atcmd_output[0] != '\0') {
- atcmd_output[strlen(atcmd_output) - 2] = ')';
- atcmd_output[strlen(atcmd_output) - 1] = '\0';
- clif_displaymessage(fd, atcmd_output);
- }
- }
- }
- if (count == 0)
- clif_displaymessage(fd, "No item found in the cart of this player.");
- else {
- sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
- 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(3)); // Character not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @killer by MouseJstr
- * enable killing players even when not in pvp
- *------------------------------------------
- */
-int
-atcommand_killer(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- sd->state.killer = !sd->state.killer;
-
- if(sd->state.killer)
- clif_displaymessage(fd, msg_txt(241));
- else
- clif_displaymessage(fd, msg_txt(287));
-
- return 0;
-}
-
-/*==========================================
- * @killable by MouseJstr
- * enable other people killing you
- *------------------------------------------
- */
-int
-atcommand_killable(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- sd->state.killable = !sd->state.killable;
-
- if(sd->state.killable)
- clif_displaymessage(fd, msg_txt(242));
- else
- clif_displaymessage(fd, msg_txt(288));
-
- return 0;
-}
-
-/*==========================================
- * @charkillable by MouseJstr
- * enable another player to be killed
- *------------------------------------------
- */
-int
-atcommand_charkillable(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if((pl_sd=map_nick2sd((char *) message)) == NULL)
- return -1;
-
- 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;
-}
-
-
-/*==========================================
- * @skillon by MouseJstr
- * turn skills on for the map
- *------------------------------------------
- */
-int
-atcommand_skillon(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- map[sd->bl.m].flag.noskill = 0;
- clif_displaymessage(fd, msg_txt(244));
- return 0;
-}
-
-/*==========================================
- * @skilloff by MouseJstr
- * Turn skills off on the map
- *------------------------------------------
- */
-int
-atcommand_skilloff(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- map[sd->bl.m].flag.noskill = 1;
- clif_displaymessage(fd, msg_txt(243));
- return 0;
-}
-
-/*==========================================
- * @npcmove by MouseJstr
- *
- * move a npc
- *------------------------------------------
- */
-int
-atcommand_npcmove(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int x = 0, y = 0, m;
- struct npc_data *nd = 0;
- nullpo_retr(-1, sd);
-
-
- if (!message || !*message)
- return -1;
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
-
- if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
- clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
- return -1;
- }
-
- //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
-// nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
-
- if ((nd = npc_name2id(atcmd_player_name)) == NULL)
- return -1;
-
- if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
- return -1; //Not on a map.
-
- if (x < 0) x = 0;
- else if (x >= map[m].xs) x = map[m].xs-1;
- if (y < 0) y = 0;
- else if (y >= map[m].ys) y = map[m].ys-1;
- map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
- map_moveblock(&nd->bl, x, y, gettick());
- map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
-
- return 0;
-}
-
-/*==========================================
- * @addwarp by MouseJstr
- *
- * Create a new static warp point.
- *------------------------------------------
- */
-int
-atcommand_addwarp(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char w1[64], w3[64], w4[64];
- int x,y,ret;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
- return -1;
-
- sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
- sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
- sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
-
- ret = npc_parse_warp(w1, "warp", w3, w4);
-
- sprintf(atcmd_output, "New warp NPC => %s",w3);
-
- clif_displaymessage(fd, atcmd_output);
-
- return ret;
-}
-
-/*==========================================
- * @follow by [MouseJstr]
- *
- * Follow a player .. staying no more then 5 spaces away
- *------------------------------------------
- */
-int
-atcommand_follow(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- if (sd->followtarget == -1)
- return -1;
-
- pc_stop_following (sd);
- clif_displaymessage(fd, "Follow mode OFF.");
- return 0;
- }
- if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
- if (sd->followtarget == pl_sd->bl.id) {
- pc_stop_following (sd);
- clif_displaymessage(fd, "Follow mode OFF.");
- } else {
- pc_follow(sd, pl_sd->bl.id);
- clif_displaymessage(fd, "Follow mode ON.");
- }
- return 0;
- } else {
- clif_displaymessage(fd, "Character not found.");
- return -1;
- }
-
- return 1;
-}
-
-
-/*==========================================
- * @dropall by [MouseJstr]
- *
- * Drop all your possession on the ground
- *------------------------------------------
- */
-int
-atcommand_dropall(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- nullpo_retr(-1, sd);
- for (i = 0; i < MAX_INVENTORY; i++) {
- if (sd->status.inventory[i].amount) {
- if(sd->status.inventory[i].equip != 0)
- pc_unequipitem(sd, i, 3);
- pc_dropitem(sd, i, sd->status.inventory[i].amount);
- }
- }
- return 0;
-}
-/*==========================================
- * @chardropall by [MouseJstr]
- *
- * Throw all the characters possessions on the ground. Normally
- * done in response to them being disrespectful of a GM
- *------------------------------------------
- */
-int
-atcommand_chardropall(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- struct map_session_data *pl_sd = NULL;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if((pl_sd=map_nick2sd((char *) message)) == NULL)
- return -1;
- for (i = 0; i < MAX_INVENTORY; i++) {
- if (pl_sd->status.inventory[i].amount) {
- if(pl_sd->status.inventory[i].equip != 0)
- pc_unequipitem(pl_sd, i, 3);
- pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
- }
- }
-
- clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
- clif_displaymessage(fd, "It is done");
- //clif_displaymessage(fd, "It is offical.. your a jerk");
-
- return 0;
-}
-/*==========================================
- * @storeall by [MouseJstr]
- *
- * Put everything into storage to simplify your inventory to make
- * debugging easie
- *------------------------------------------
- */
-int
-atcommand_storeall(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- nullpo_retr(-1, sd);
-
- if (sd->state.storage_flag != 1)
- { //Open storage.
- switch (storage_storageopen(sd)) {
- case 2: //Try again
- clif_displaymessage(fd, "run this command again..");
- return 0;
- case 1: //Failure
- clif_displaymessage(fd, "You can't open the storage currently.");
- return -1;
- }
- }
- for (i = 0; i < MAX_INVENTORY; i++) {
- if (sd->status.inventory[i].amount) {
- if(sd->status.inventory[i].equip != 0)
- pc_unequipitem(sd, i, 3);
- storage_storageadd(sd, i, sd->status.inventory[i].amount);
- }
- }
- storage_storageclose(sd);
-
- clif_displaymessage(fd, "It is done");
- return 0;
-}
-/*==========================================
- * @charstoreall by [MouseJstr]
- *
- * A way to screw with players who piss you off
- *------------------------------------------
- */
-int
-atcommand_charstoreall(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- struct map_session_data *pl_sd = NULL;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if((pl_sd=map_nick2sd((char *) message)) == NULL)
- return -1;
-
- if (pl_sd->state.storage_flag != 1)
- { //Open storage.
- switch (storage_storageopen(pl_sd)) {
- case 2: //Try again
- clif_displaymessage(fd, "Had to open the characters storage window...");
- clif_displaymessage(fd, "run this command again..");
- return 0;
- case 1: //Failure
- clif_displaymessage(fd, "The character currently can't use the storage.");
- return 1;
- }
- }
-
- for (i = 0; i < MAX_INVENTORY; i++) {
- if (pl_sd->status.inventory[i].amount) {
- if(pl_sd->status.inventory[i].equip != 0)
- pc_unequipitem(pl_sd, i, 3);
- storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
- }
- }
- storage_storageclose(pl_sd);
-
- clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
- clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
- clif_displaymessage(pl_sd->fd, " -- the management");
-
- clif_displaymessage(fd, "It is done");
-
- return 0;
-}
-/*==========================================
- * @skillid by [MouseJstr]
- *
- * lookup a skill by name
- *------------------------------------------
- */
-int
-atcommand_skillid(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int skillen, idx;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- skillen = strlen(message);
-
- for (idx = 0; idx < MAX_SKILL_DB; idx++) {
- if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
- (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
- {
- sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
- clif_displaymessage(fd, atcmd_output);
- }
- }
-
- return 0;
-}
-
-/*==========================================
- * @useskill by [MouseJstr]
- *
- * A way of using skills without having to find them in the skills menu
- *------------------------------------------
- */
-int
-atcommand_useskill(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- struct block_list *bl;
- int skillnum;
- int skilllv;
- char target[255];
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
- clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
- return -1;
- }
- if((pl_sd=map_nick2sd(target)) == NULL) {
- return -1;
- }
-
- if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
- && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
- bl = &sd->hd->bl;
- else
- bl = &sd->bl;
-
- if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
- unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
- else
- unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
-
- return 0;
-}
-
-/*==========================================
- * @skilltree by [MouseJstr]
- *
- * prints the skill tree for a player required to get to a skill
- *------------------------------------------
- */
-int
-atcommand_skilltree(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int skillnum, skillidx = -1;
- int meets = 1, j, c=0;
- char target[NAME_LENGTH], *tbl;
- struct skill_tree_entry *ent;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
- clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
- return -1;
- }
- if((pl_sd=map_nick2sd(target)) == NULL)
- return -1;
-
- c = pc_calc_skilltree_normalize_job(pl_sd);
- c = pc_mapid2jobid(c, pl_sd->status.sex);
-
- tbl = job_name(c);
-
- sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
- tbl, pc_checkskill(pl_sd, 1));
- clif_displaymessage(fd, atcmd_output);
-
- for (j = 0; skill_tree[c][j].id != 0; j++) {
- if (skill_tree[c][j].id == skillnum) {
- skillidx = j;
- break;
- }
- }
-
- if (skillidx == -1) {
- sprintf(atcmd_output, "I do not believe the player can use that skill");
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
-
- ent = &skill_tree[c][skillidx];
-
- for(j=0;j<5;j++)
- if( ent->need[j].id &&
- pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
- {
- char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
- sprintf(atcmd_output, "player requires level %d of skill %s",
- ent->need[j].lv, desc);
- clif_displaymessage(fd, atcmd_output);
- meets = 0;
- }
-
- if (meets == 1) {
- sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
- clif_displaymessage(fd, atcmd_output);
- }
-
- return 0;
-}
-
-// Hand a ring with partners name on it to this char
-void getring (struct map_session_data *sd)
-{
- int flag,item_id = 0;
- struct item item_tmp;
- if(sd->status.sex==0)
- item_id = 2635;
- else
- item_id = 2634;
-
- malloc_set(&item_tmp,0,sizeof(item_tmp));
- item_tmp.nameid=item_id;
- item_tmp.identify=1;
- item_tmp.card[0]=255;
- item_tmp.card[2]=sd->status.partner_id;
- item_tmp.card[3]=sd->status.partner_id >> 16;
-
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", item_id, 1, &item_tmp);
-
- if((flag = pc_additem(sd,&item_tmp,1))) {
- clif_additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
- }
-
-}
-
-
-/*==========================================
- * @marry by [MouseJstr], fixed by Lupus
- *
- * Marry two players
- *------------------------------------------
- */
-int
-atcommand_marry(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd1 = NULL;
- struct map_session_data *pl_sd2 = NULL;
- char player1[128], player2[128]; //Length used for return error msgs
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
- clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
- return -1;
- }
-
- if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
- sprintf(player2, "Cannot find player '%s' online", player1);
- clif_displaymessage(fd, player2);
- return -1;
- }
-
- if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
- sprintf(player1, "Cannot find player '%s' online", player2);
- clif_displaymessage(fd, player1);
- return -1;
- }
-
- if (pc_marriage(pl_sd1, pl_sd2) == 0) {
- clif_displaymessage(fd, "They are married.. wish them well");
- clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
- // Auto-give named rings (Aru)
- getring (pl_sd1);
- getring (pl_sd2);
- return 0;
- }
- return -1;
-}
-
-/*==========================================
- * @divorce by [MouseJstr], fixed by [Lupus]
- *
- * divorce two players
- *------------------------------------------
- */
-int
-atcommand_divorce(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
- clif_displaymessage(fd, "Usage: @divorce <player>.");
- return -1;
- }
-
- if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
- if (pc_divorce(pl_sd) != 0) {
- sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
- clif_displaymessage(fd, atcmd_output);
- return -1;
- } else {
- sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
- }
- sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
- clif_displaymessage(fd, atcmd_output);
- return -1;
-}
-
-
-#ifdef DMALLOC
-unsigned long dmark_;
-int
-atcommand_dmstart(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- dmark_ = dmalloc_mark();
-
- clif_displaymessage(fd, "debug mark set");
-
- return 0;
-}
-
-int
-atcommand_dmtick(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
- dmark_ = dmalloc_mark();
- clif_displaymessage(fd, "malloc changes logged");
-
- return 0;
-}
-#endif
-
-/*==========================================
- * @grind by [MouseJstr]
- *------------------------------------------
- */
-int
-atcommand_grind(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int skillnum;
- int inf;
- char target[NAME_LENGTH];
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if(sscanf(message, "%23s", target) != 1) {
- clif_displaymessage(fd, "Usage: @grind <target>");
- return -1;
- }
- if((pl_sd=map_nick2sd(target)) == NULL)
- return -1;
-
- for (skillnum = 1; skillnum < 500; skillnum++) {
- sd->status.sp = sd->status.max_sp;
- atcommand_alive(fd, sd, command, message);
-
- inf = skill_get_inf(skillnum);
-
- if (inf & INF_GROUND_SKILL)
- unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
- else if (!(inf & INF_SUPPORT_SKILL))
- unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
- }
-
- return 0;
-}
-
-/*==========================================
- * @grind2 by [MouseJstr]
- *------------------------------------------
- */
-int
-atcommand_grind2(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i;
- short x, y;
-
- for (i = 1000; i < MAX_MOB_DB; i++) {
- if (!mobdb_checkid(i))
- continue;
- map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
- mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
- }
-
- return 0;
-}
-
-/*==========================================
- * @changelook by [Celest]
- *------------------------------------------
- */
-int
-atcommand_changelook(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i, j = 0, k = 0;
- int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
-
- if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
- clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
- clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
- return -1;
- } else if (i == 2) {
- if (j < 1) j = 1;
- else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
- j = pos[j - 1];
- } else if (i == 1) { // position not defined, use HEAD_TOP as default
- k = j; // swap
- j = LOOK_HEAD_TOP;
- }
-
- clif_changelook(&sd->bl,j,k);
-
- return 0;
-}
-
-/*==========================================
- *Turns on/off Autotrade for a specific player
- *------------------------------------------
- *by durf (changed by Lupus)
- */
-int
-atcommand_autotrade(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (sd->vender_id) //check if player's vending
- {
- sd->state.autotrade = 1;
- clif_authfail_fd(fd, 15);
- }
- else
- {
- //"You should be vending to use @Autotrade."
- clif_displaymessage(fd, msg_txt(549));
- }
- return 0;
-}
-
-
-/*==========================================
- * Changes Master of your Guild to a specified guild member
- *------------------------------------------
- *by durf (changed by Lupus)
- */
-int
-atcommand_changegm(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct guild *g;
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
- {
- clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
- return -1;
- }
- if (strlen(message)==0)
- {
- clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
- return -1;
- }
-
- if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
- clif_displaymessage(fd, "Target character must be online and be a guildmate.");
- return -1;
- }
-
- guild_gm_change(sd->status.guild_id, pl_sd);
- return 0;
-}
-
-/*==========================================
- *Changes the leader of a party.
- *------------------------------------------
- *by Skotlex
- */
-int
-atcommand_changeleader(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct party_data *p;
- struct map_session_data *pl_sd;
- int mi, pl_mi;
- nullpo_retr(-1, sd);
-
- if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
- { //Need to be a party leader.
- clif_displaymessage(fd, msg_txt(282));
- return -1;
- }
-
- for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
-
- if (mi == MAX_PARTY)
- return -1; //Shouldn't happen
-
- if (!p->party.member[mi].leader)
- { //Need to be a party leader.
- clif_displaymessage(fd, msg_txt(282));
- return -1;
- }
-
- if (strlen(message)==0)
- {
- clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
- return -1;
- }
-
- if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
- clif_displaymessage(fd, msg_txt(283));
- return -1;
- }
-
- for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
-
- if (pl_mi == MAX_PARTY)
- return -1; //Shouldn't happen
-
- //Change leadership.
- p->party.member[mi].leader = 0;
- if (p->data[mi].sd->fd)
- clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
- p->party.member[pl_mi].leader = 1;
- if (p->data[pl_mi].sd->fd)
- clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
-
- intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
- //Update info.
- clif_party_main_info(p,-1);
- clif_party_info(p,-1);
-
- return 0;
-}
-
-/*==========================================
- * Used to change the item share setting of a party.
- *------------------------------------------
- *by Skotlex
- */
-int
-atcommand_partyoption(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct party_data *p;
- int mi, option;
- char w1[15], w2[15];
- nullpo_retr(-1, sd);
-
- if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
- {
- clif_displaymessage(fd, msg_txt(282));
- return -1;
- }
-
- for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
-
- if (mi == MAX_PARTY)
- return -1; //Shouldn't happen
-
- if (!p->party.member[mi].leader)
- {
- clif_displaymessage(fd, msg_txt(282));
- return -1;
- }
-
- if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
- {
- clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
- return -1;
- }
- w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
- option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
-
- //Change item share type.
- if (option != p->party.item)
- party_changeoption(sd, p->party.exp, option);
- else
- clif_displaymessage(fd, msg_txt(286));
-
- return 0;
-}
-
-/*==========================================
- *Turns on/off AutoLoot for a specific player
- *------------------------------------------
- *by Upa-Kun
- */
-int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
-{
- // autoloot command with value
- int rate;
-
- nullpo_retr(-1, sd);
-
- // autoloot command without value
- if(!message || !*message)
- {
- // autoloot on -> off
- if(sd->state.autoloot)
- {
- clif_displaymessage(fd, "Autoloot is now off.");
- sd->state.autoloot = 0;
- return 0;
- // autoloot off -> on
- } else {
- clif_displaymessage(fd, "Autoloot is now on.");
- sd->state.autoloot = 10000;
- return 0;
- }
- }
-
- // get maximum droprate limit
- rate = (int)(atof(message) * 100.);
-
- // check for invalid value
- if(rate > 10000)
- {
- clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
- return 0;
- }
-
- // autoloot value is 0, turn autoloot off
- if(rate == 0)
- {
- if(sd->state.autoloot == 0)
- clif_displaymessage(fd, "Autoloot is already off.");
- else {
- clif_displaymessage(fd, "Autoloot is now off.");
- sd->state.autoloot = 0;
- }
- return 0;
- }
-
- // autoloot value is 100, turn autoloot on
- if(rate == 10000)
- {
- if(sd->state.autoloot == 10000)
- clif_displaymessage(fd, "Autoloot is already on.");
- else {
- clif_displaymessage(fd, "Autoloot is now on.");
- sd->state.autoloot = 10000;
- }
- return 0;
- }
-
- // autoloot value is between 0 and 100
- snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.", rate/100.);
- clif_displaymessage(fd, atcmd_output);
- sd->state.autoloot = rate;
-
- return 0;
-}
-
-
-/*==========================================
- * It is made to rain.
- *------------------------------------------
- */
-int
-atcommand_rain(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.rain) {
- map[sd->bl.m].flag.rain=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "The rain has stopped.");
- } else {
- map[sd->bl.m].flag.rain=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "It is made to rain.");
- }
- return 0;
-}
-/*==========================================
- * It is made to snow.
- *------------------------------------------
- */
-int
-atcommand_snow(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.snow) {
- map[sd->bl.m].flag.snow=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Snow has stopped falling.");
- } else {
- map[sd->bl.m].flag.snow=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "It is made to snow.");
- }
-
- return 0;
-}
-
-/*==========================================
- * Cherry tree snowstorm is made to fall. (Sakura)
- *------------------------------------------
- */
-int
-atcommand_sakura(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.sakura) {
- map[sd->bl.m].flag.sakura=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
- } else {
- map[sd->bl.m].flag.sakura=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
- }
- return 0;
-}
-
-/*==========================================
- * Clouds appear.
- *------------------------------------------
- */
-int
-atcommand_clouds(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.clouds) {
- map[sd->bl.m].flag.clouds=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "The clouds has disappear.");
- } else {
- map[sd->bl.m].flag.clouds=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Clouds appear.");
- }
-
- return 0;
-}
-
-/*==========================================
- * Different type of clouds using effect 516
- *------------------------------------------
- */
-int
-atcommand_clouds2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.clouds2) {
- map[sd->bl.m].flag.clouds2=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "The alternative clouds disappear.");
- } else {
- map[sd->bl.m].flag.clouds2=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Alternative clouds appear.");
- }
-
- return 0;
-}
-
-/*==========================================
- * Fog hangs over.
- *------------------------------------------
- */
-int
-atcommand_fog(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.fog) {
- map[sd->bl.m].flag.fog=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "The fog has gone.");
- } else {
- map[sd->bl.m].flag.fog=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Fog hangs over.");
- }
- return 0;
-}
-
-/*==========================================
- * Fallen leaves fall.
- *------------------------------------------
- */
-int
-atcommand_leaves(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.leaves) {
- map[sd->bl.m].flag.leaves=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Leaves no longer fall.");
- } else {
- map[sd->bl.m].flag.leaves=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Fallen leaves fall.");
- }
-
- return 0;
-}
-
-/*==========================================
- * Fireworks appear.
- *------------------------------------------
- */
-int
-atcommand_fireworks(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- if (map[sd->bl.m].flag.fireworks) {
- map[sd->bl.m].flag.fireworks=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Fireworks are ended.");
- } else {
- map[sd->bl.m].flag.fireworks=1;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, "Fireworks are launched.");
- }
-
- return 0;
-}
-
-/*==========================================
- * Clearing Weather Effects by Dexity
- *------------------------------------------
- */
-int
-atcommand_clearweather(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- map[sd->bl.m].flag.rain=0;
- map[sd->bl.m].flag.snow=0;
- map[sd->bl.m].flag.sakura=0;
- map[sd->bl.m].flag.clouds=0;
- map[sd->bl.m].flag.clouds2=0;
- map[sd->bl.m].flag.fog=0;
- map[sd->bl.m].flag.fireworks=0;
- map[sd->bl.m].flag.leaves=0;
- clif_weather(sd->bl.m);
- clif_displaymessage(fd, msg_txt(291));
-
- return 0;
-}
-
-/*===============================================================
- * Sound Command - plays a sound for everyone! [Codemaster]
- *---------------------------------------------------------------
- */
-int
-atcommand_sound(
- const int fd, struct map_session_data *sd,
- const char *command, const char *message)
-{
- char sound_file[100];
-
- if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
- clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
- return -1;
- }
-
- malloc_tsetdword(sound_file, '\0', sizeof(sound_file));
- if(sscanf(message, "%99[^\n]", sound_file) < 1)
- return -1;
-
- if(strstr(sound_file, ".wav") == NULL)
- strcat(sound_file, ".wav");
-
- clif_soundeffectall(&sd->bl, sound_file,0,2);
-
- return 0;
-}
-
-/*==========================================
- * MOB Search
- *------------------------------------------
- */
-static int atmobsearch_sub(struct block_list *bl,va_list ap)
-{
- int mob_id,fd;
- static int number=0;
- struct mob_data *md;
-
- nullpo_retr(0, bl);
-
- if(!ap){
- number=0;
- return 0;
- }
- mob_id = va_arg(ap,int);
- fd = va_arg(ap,int);
-
- md = (struct mob_data *)bl;
-
- if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
- snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
- ++number,bl->x, bl->y,md->name);
- clif_displaymessage(fd, atcmd_output);
- }
- return 0;
-}
-int atcommand_mobsearch(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char mob_name[100];
- int mob_id,map_id = 0;
-
- nullpo_retr(-1, sd);
-
- if (sscanf(message, "%99[^\n]", mob_name) < 0)
- return -1;
-
- if ((mob_id = atoi(mob_name)) == 0)
- mob_id = mobdb_searchname(mob_name);
- if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
- snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
- if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
- strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
-// strcpy(mob_name,mob_db(mob_id)->name); // --en--
-
- map_id = sd->bl.m;
-
- snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
- mob_name, mapindex_id2name(sd->mapindex));
- clif_displaymessage(fd, atcmd_output);
-
- map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
-
- atmobsearch_sub(&sd->bl,0); // 番号リセット
-
- return 0;
-}
-/*==========================================
- * ドロップアイテムの掃除
- *------------------------------------------
- */
-/*==========================================
- * cleanmap
- *------------------------------------------
- */
-static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
-{
- nullpo_retr(0, bl);
- map_clearflooritem(bl->id);
-
- return 0;
-}
-
-int
-atcommand_cleanmap(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
- sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
- sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
- BL_ITEM);
- clif_displaymessage(fd, "All dropped items have been cleaned up.");
- return 0;
-}
-
-/*==========================================
- * NPC/PETに話させる
- *------------------------------------------
- */
-int
-atcommand_npctalk(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char name[NAME_LENGTH],mes[100],temp[100];
- struct npc_data *nd;
-
- if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
- return -1;
-
- if (!(nd = npc_name2id(name)))
- return -1;
-
- snprintf(temp, sizeof temp ,"%s : %s",name,mes);
- clif_message(&nd->bl, temp);
-
- return 0;
-}
-int
-atcommand_pettalk(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char mes[100],temp[100];
- struct pet_data *pd;
-
- nullpo_retr(-1, sd);
-
- if(!sd->status.pet_id || !(pd=sd->pd))
- return -1;
-
- if (sd->sc.count && //no "chatting" while muted.
- (sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
- return -1;
-
- if (sscanf(message, "%99[^\n]", mes) < 1)
- return -1;
-
- snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
- clif_message(&pd->bl, temp);
-
- return 0;
-}
-
-/*==========================================
- * @users
- * サーバー内の人数マップを表示させる
- * 手抜きのため汚くなっているのは仕様です。
- *------------------------------------------
- */
-
-static struct dbt *users_db = NULL;
-static int users_all;
-
-static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
- int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
- users_all++;
- uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
- return 0;
-}
-
-static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
- char buf[256];
- struct map_session_data* sd = va_arg(va,struct map_session_data*);
- sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
- clif_displaymessage(sd->fd,buf);
- return 0;
-}
-
-int
-atcommand_users(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char buf[256];
- users_all = 0;
-
- users_db->clear(users_db, NULL);
- clif_foreachclient(atcommand_users_sub1);
- users_db->foreach(users_db,atcommand_users_sub2,sd);
- sprintf(buf,"all : %d",users_all);
- clif_displaymessage(fd,buf);
- return 0;
-}
-
-int
-atcommand_reset(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- pc_resetstate(sd);
- pc_resetskill(sd,1);
- sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
- clif_displaymessage(fd, atcmd_output);
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int
-atcommand_summon(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char name[NAME_LENGTH];
- int mob_id = 0;
- int duration = 0;
- struct mob_data *md;
- unsigned int tick=gettick();
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if (sscanf(message, "%23s %d", name, &duration) < 1)
- return -1;
-
- if (duration < 1)
- duration =1;
- else if (duration > 60)
- duration =60;
-
- if ((mob_id = atoi(name)) == 0)
- mob_id = mobdb_searchname(name);
- if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
- return -1;
-
- md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
-
- if(md){
- md->master_id=sd->bl.id;
- md->special_state.ai=1;
- md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
- clif_misceffect2(&md->bl,344);
- mob_spawn(md);
- sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
- clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
- }
-
- return 0;
-}
-
-
-/*==========================================
- * @adjcmdlvl by [MouseJstr]
- *
- * Temp adjust the GM level required to use a GM command
- *
- * Used during beta testing to allow players to use GM commands
- * for short periods of time
- *------------------------------------------
- */
-int
-atcommand_adjcmdlvl(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i, newlev;
- char cmd[100];
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
- clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
- return -1;
- }
-
- for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
- if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
- atcommand_info[i].level = newlev;
- clif_displaymessage(fd, "@command level changed.");
- return 0;
- }
-
- clif_displaymessage(fd, "@command not found.");
- return -1;
-}
-
-/*==========================================
- * @adjgmlvl by [MouseJstr]
- *
- * Create a temp GM
- *
- * Used during beta testing to allow players to use GM commands
- * for short periods of time
- *------------------------------------------
- */
-int
-atcommand_adjgmlvl(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int newlev;
- char user[NAME_LENGTH];
- struct map_session_data *pl_sd;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
- clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
- return -1;
- }
-
- if((pl_sd=map_nick2sd((char *) user)) == NULL)
- return -1;
-
- pc_set_gm_level(pl_sd->status.account_id, newlev);
-
- return 0;
-}
-
-
-/*==========================================
- * @trade by [MouseJstr]
- *
- * Open a trade window with a remote player
- *
- * If I have to jump to a remote player one more time, I am
- * gonna scream!
- *------------------------------------------
- */
-int
-atcommand_trade(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if((pl_sd=map_nick2sd((char *) message)) != NULL) {
- trade_traderequest(sd, pl_sd);
- return 0;
- }
- return -1;
-}
-
-/*==========================================
- * @setbattleflag by [MouseJstr]
- *
- * set a battle_config flag without having to reboot
- */
-int
-atcommand_setbattleflag(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char flag[128], value[128];
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
- clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
- return -1;
- }
-
- if (battle_set_value(flag, value) == 0)
- clif_displaymessage(fd, "unknown battle_config flag");
- else
- clif_displaymessage(fd, "battle_config set as requested");
-
- return 0;
-}
-
-
-/*===========================
- * @unmute [Valaris]
- *===========================
-*/
-int atcommand_unmute(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if((pl_sd=map_nick2sd((char *) message)) != NULL) {
- if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
- pl_sd->status.manner = 0;
- status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
- clif_displaymessage(sd->fd,"Player unmuted");
- }
- else
- clif_displaymessage(sd->fd,"Player is not muted");
- }
-
- return 0;
-}
-
-/*==========================================
- * @uptime by MC Cameri
- *------------------------------------------
- */
-int
-atcommand_uptime(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
- minute = 60, days = 0, hours = 0, minutes = 0;
- nullpo_retr(-1, sd);
-
- seconds = get_uptime();
- days = seconds/day;
- seconds -= (seconds/day>0)?(seconds/day)*day:0;
- hours = seconds/hour;
- seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
- minutes = seconds/minute;
- seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
-
- snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- * @changesex <sex>
- * => Changes one's sex. Argument sex can be
- * 0 or 1, m or f, male or female.
- *------------------------------------------
- */
-int
-atcommand_changesex(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
- return 0;
-}
-
-/*================================================
- * @mute - Mutes a player for a set amount of time
- *------------------------------------------------
- */
-int atcommand_mute(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int manner;
- nullpo_retr(-1, sd);
-
- if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
- clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
- return -1;
- }
-
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_isGM(pl_sd) > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- clif_GM_silence(sd, pl_sd, 0);
- pl_sd->status.manner -= manner;
- if(pl_sd->status.manner < 0)
- sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
- }
- else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- return 0;
-}
-
-/*==========================================
- * @refresh (like @jumpto <<yourself>>)
- *------------------------------------------
- */
-int atcommand_refresh(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
- clif_refresh(sd);
- return 0;
-}
-
-/*==========================================
- * @petid <part of pet name>
- * => Displays a list of matching pets.
- *------------------------------------------
- */
-int
-atcommand_petid(const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char searchtext[100];
- char temp0[100];
- char temp1[100];
- int cnt = 0, i = 0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
- if (sscanf(message, "%99s", searchtext) < 1)
- return -1;
- estr_lower(searchtext);
- snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
- clif_displaymessage(fd,temp0);
- while (i < MAX_PET_DB) {
- strcpy(temp1,pet_db[i].name);
- strcpy(temp1, estr_lower(temp1));
- strcpy(temp0,pet_db[i].jname);
- strcpy(temp0, estr_lower(temp1));
- if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
- snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
- pet_db[i].jname);
- if (cnt >= 100) { // Only if there are custom pets
- clif_displaymessage(fd, "Be more specific, can't send more than"
- " 100 results.");
- } else {
- clif_displaymessage(fd, temp0);
- }
- cnt++;
- }
- i++;
- }
- snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
- clif_displaymessage(fd, temp0);
- return 0;
-}
-
-/*==========================================
- * @identify
- * => GM's magnifier.
- *------------------------------------------
- */
-int
-atcommand_identify(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int i,num;
-
- nullpo_retr(-1, sd);
-
- for(i=num=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
- num++;
- }
- }
- if (num > 0) {
- clif_item_identify_list(sd);
- } else {
- clif_displaymessage(fd,"There are no items to appraise.");
- }
- return 0;
-}
-
-/*==========================================
- * @gmotd (Global MOTD)
- * by davidsiaw :P
- *------------------------------------------
- */
-int
-atcommand_gmotd(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char buf[256];
- FILE *fp;
- nullpo_retr(-1, sd);
- if( (fp = fopen(motd_txt, "r"))!=NULL){
- while (fgets(buf, 250, fp) != NULL){
- int i;
- for( i=0; buf[i]; i++){
- if( buf[i]=='\r' || buf[i]=='\n'){
- buf[i]=0;
- break;
- }
- }
- intif_GMmessage(buf,strlen(buf)+1,8);
- }
- fclose(fp);
- }
- return 0;
-}
-
-int atcommand_misceffect(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int effect = 0;
- nullpo_retr(-1, sd);
- if (!message || !*message)
- return -1;
- if (sscanf(message, "%d", &effect) < 1)
- return -1;
- clif_misceffect(&sd->bl,effect);
-
- return 0;
-}
-
-/*==========================================
- * Jump to a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-
-int atcommand_jumptoid(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int cid=0;
- struct map_session_data *pl_sd;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || (cid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
- return -1;
- }
-
- 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;
-}
-
-/*==========================================
- * Jump to a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-
-int atcommand_jumptoid2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int aid=0;
- struct map_session_data *pl_sd;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || (aid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
- return -1;
- }
-
- 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;
-}
-
-/*==========================================
- * Recall a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_recallid(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int cid=0;
- struct map_session_data *pl_sd;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || (cid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
- return -1;
- }
-
- 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;
-}
-
-/*==========================================
- * Recall a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_recallid2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int aid=0;
- struct map_session_data *pl_sd;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (!message || (aid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
- return -1;
- }
-
- 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 (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;
-}
-
-/*==========================================
- * Kick a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_kickid(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- int cid=0;
-
- 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;
- }
-
- 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;
-}
-
-/*==========================================
- * Kick a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_kickid2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd;
- int aid=0;
-
- if (!message || (aid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
- return -1;
- }
-
- 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;
-}
-
-/*==========================================
- * Revive a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_reviveid(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int cid=0;
- struct map_session_data *pl_sd;
-
- if (!message || (cid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
- return -1;
- }
-
- 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;
-}
-
-/*==========================================
- * Revive a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_reviveid2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int aid=0;
- struct map_session_data *pl_sd;
-
- if (!message || (aid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
- return -1;
- }
-
- pl_sd = map_id2sd(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;
-}
-
-/*==========================================
- * Kill a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_killid(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int cid=0;
- struct map_session_data *pl_sd;
-
- if (!message || (cid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
- return -1;
- }
-
- pl_sd = map_charid2sd(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;
-}
-
-/*==========================================
- * Kill a player by PID number
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int atcommand_killid2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int aid=0;
- struct map_session_data *pl_sd;
-
- if (!message || (aid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
- return -1;
- }
-
- 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;
-}
-
-/*==========================================
- * Make a player killable, by PID
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int
-atcommand_charkillableid(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int cid=0;
-
- if (!message || (cid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player CID.");
- return -1;
- }
-
- pl_sd = map_charid2sd(cid);
-
- 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;
- if(pl_sd->state.killable)
- clif_displaymessage(fd, msg_txt(289));
- else
- clif_displaymessage(fd, msg_txt(290));
- return 0;
-}
-
-
-/*==========================================
- * Make a player killable, by PID
- * Original by Dino9021
- * Added in by nsstrunks
- *------------------------------------------
- */
-int
-atcommand_charkillableid2(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct map_session_data *pl_sd = NULL;
- int aid=0;
-
- if (!message || (aid = atoi(message)) == 0) {
- clif_displaymessage(fd, "Please, enter a player AID.");
- return -1;
- }
-
- 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))
- {
- 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;
-
- if(pl_sd->state.killable)
- clif_displaymessage(fd, msg_txt(289));
- else
- clif_displaymessage(fd, msg_txt(290));
-
- return 0;
-}
-
-#ifndef TXT_ONLY /* Begin SQL-Only commands */
-
-/*==========================================
- * Mail System commands by [Valaris]
- *------------------------------------------
- */
-int atcommand_listmail(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if(!mail_server_enable)
- return 0;
-
- nullpo_retr(-1, sd);
-
- if(strlen(command)==12)
- mail_check(sd,3);
- else if(strlen(command)==9)
- mail_check(sd,2);
- else
- mail_check(sd,1);
- return 0;
-}
-
-int atcommand_readmail(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int index;
- if(!mail_server_enable)
- return 0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(sd->fd,"You must specify a message number.");
- return 0;
- }
-
- index = atoi(message);
- if (index < 1) {
- clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
- return 0;
- }
-
- if(strlen(command)==11)
- mail_delete(sd,index);
- else
- mail_read(sd,index);
-
- return 0;
-}
-
-int atcommand_sendmail(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char name[NAME_LENGTH],text[80];
-
- if(!mail_server_enable)
- return 0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message) {
- clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
- return 0;
- }
-
- if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
- (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
- clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
- return 0;
- }
-
- if(strlen(command)==17)
- mail_send(sd,name,text,1);
- else
- mail_send(sd,name,text,0);
-
- return 0;
-}
-
-/*==========================================
- * Refresh online command for SQL [Valaris]
- * Will refresh and check online column of
- * players and set correctly.
- *------------------------------------------
- */
-int atcommand_refreshonline(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- send_users_tochar(-1, gettick(), 0, 0);
- return 0;
-}
-
-#endif /* end sql only */
-
-/*==========================================
- * Show Monster DB Info v 1.0
- * originally by [Lupus] eAthena
- *------------------------------------------
- */
-int atcommand_mobinfo(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- unsigned char msize[3][7] = {"Small", "Medium", "Large"};
- unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
- unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
- char atcmd_output2[200];
- struct item_data *item_data;
- struct mob_db *mob, *mob_array[MAX_SEARCH];
- int count;
- int i, j, k;
-
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- malloc_tsetdword(atcmd_output2, '\0', sizeof(atcmd_output2));
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
- return -1;
- }
-
- // If monster identifier/name argument is a name
- if ((i = mobdb_checkid(atoi(message))))
- {
- mob_array[0] = mob_db(i);
- count = 1;
- } else
- count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
-
- if (!count) {
- clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
- return -1;
- }
-
- if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
- clif_displaymessage(fd, atcmd_output);
- count = MAX_SEARCH;
- }
- for (k = 0; k < count; k++) {
- mob = mob_array[k];
-
- // stats
- if (mob->mexp)
- sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
- else
- sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
- clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
- clif_displaymessage(fd, atcmd_output);
- sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
- mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
- mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
- clif_displaymessage(fd, atcmd_output);
-
- sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
- mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
- mob->range2 , mob->range3, msize[mob->status.size],
- mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
- clif_displaymessage(fd, atcmd_output);
- // drops
- clif_displaymessage(fd, " Drops:");
- strcpy(atcmd_output, " ");
- j = 0;
- for (i = 0; i < MAX_MOB_DROP; i++) {
- if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
- continue;
- if (item_data->slot)
- sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
- else
- sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
- strcat(atcmd_output, atcmd_output2);
- if (++j % 3 == 0) {
- clif_displaymessage(fd, atcmd_output);
- strcpy(atcmd_output, " ");
- }
- }
- if (j == 0)
- clif_displaymessage(fd, "This monster has no drops.");
- else if (j % 3 != 0)
- clif_displaymessage(fd, atcmd_output);
- // mvp
- if (mob->mexp) {
- sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
- clif_displaymessage(fd, atcmd_output);
- strcpy(atcmd_output, " MVP Items:");
- j = 0;
- for (i = 0; i < 3; i++) {
- if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
- continue;
- if (mob->mvpitem[i].p > 0) {
- j++;
- if (j == 1)
- sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
- else
- sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
- strcat(atcmd_output, atcmd_output2);
- }
- }
- if (j == 0)
- clif_displaymessage(fd, "This monster has no MVP prizes.");
- else
- clif_displaymessage(fd, atcmd_output);
- }
- }
- return 0;
-}
-
-/*=========================================
-* @showmobs by KarLaeda
-* => For 5 sec displays the mobs on minimap
-*------------------------------------------
-*/
-int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
-{
- struct map_session_data *sd;
-
- if (!session[id] || (sd = session[id]->session_data) == NULL)
- return 0;
-
- clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
- return 1;
-}
-static int atshowmobs_sub(struct block_list *bl,va_list ap)
-{
- int mob_id,fd;
- struct map_session_data* sd;
- static int number=0;
- struct mob_data *md;
-
- if(!ap){
- number=0;
- return 0;
- }
- mob_id = va_arg(ap,int);
- fd = va_arg(ap,int);
- sd = va_arg(ap,struct map_session_data*);
-
- md = (struct mob_data *)bl;
-
- if(md->special_state.ai || md->master_id)
- return 0; //Hide slaves and player summoned mobs. [Skotlex]
-
- if(fd && (mob_id==-1 || (md->class_==mob_id))){
- clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
- add_timer(gettick()+5000, atshowmobs_timer, fd, number);
- }
- return 0;
-}
-int atcommand_showmobs(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char mob_name[100];
- int mob_id,map_id = 0;
-
- nullpo_retr(-1, sd);
-
- if (sscanf(message, "%99[^\n]", mob_name) < 0)
- return -1;
-
- if ((mob_id = atoi(mob_name)) == 0)
- mob_id = mobdb_searchname(mob_name);
- if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
- snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
-// Uncomment the following line to show mini-bosses & MVP.
-//#define SHOW_MVP
-#ifndef SHOW_MVP
- if(mob_db(mob_id)->status.mode&MD_BOSS){
- snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
-#endif
- if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
- strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
-// strcpy(mob_name,mob_db(mob_id)->name); // --en--
-
- map_id = sd->bl.m;
-
- snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
- mob_name, mapindex_id2name(sd->mapindex));
- clif_displaymessage(fd, atcmd_output);
-
- map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
-
- atshowmobs_sub(&sd->bl,0);
-
- return 0;
-}
-
-/*==========================================
- * homunculus level up [orn]
- *------------------------------------------
- */
-int atcommand_homlevel(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- TBL_HOM * hd;
- int level = 0, i = 0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if ( !merc_is_hom_active(sd->hd) )
- return 1 ;
-
- level = atoi(message);
- hd = sd->hd;
-
- for (i = 1; i <= level && hd->exp_next; i++){
- hd->homunculus.exp += hd->exp_next;
- merc_hom_levelup(hd);
- }
- status_calc_homunculus(hd,0);
- status_percent_heal(&hd->bl, 100, 100);
- clif_misceffect2(&hd->bl,568);
- return 0;
-}
-
-/*==========================================
- * homunculus evolution H [orn]
- *------------------------------------------
- */
-int atcommand_homevolution(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- if (sd->hd && sd->hd->homunculusDB->evo_class)
- {
- merc_hom_evolution(sd->hd) ;
- }
- return 0;
-}
-
-/*==========================================
- * call choosen homunculus [orn]
- *------------------------------------------
- */
-int
-atcommand_makehomun(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int homunid;
- nullpo_retr(-1, sd);
- if(sscanf(message, "%d", &homunid)<1)
- return -1;
- if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
- return -1;
- if(sd->status.hom_id == 0)
- {
- merc_create_homunculus_request(sd,homunid);
- }
- else
- {
- clif_displaymessage(fd,msg_txt(450));
- }
- return 0;
-}
-
-/*==========================================
- * modify homunculus intimacy [orn]
- *------------------------------------------
- */
-int atcommand_homfriendly(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int friendly = 0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- friendly = atoi(message);
- if (merc_is_hom_active(sd->hd)) {
- if (friendly > 0 && friendly <= 1000) {
- sd->hd->homunculus.intimacy = friendly * 100 ;
- clif_send_homdata(sd,SP_INTIMATE,friendly);
- } else {
- return -1;
- }
- }
-
- return 0;
-}
-
-/*==========================================
- * modify homunculus hunger [orn]
- *------------------------------------------
- */
-int atcommand_homhungry(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int hungry = 0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- hungry = atoi(message);
- if (sd->status.hom_id > 0 && sd->hd) {
- struct homun_data *hd = sd->hd;
- if (hungry >= 0 && hungry <= 100) {
- hd->homunculus.hunger = hungry;
- clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
- } else {
- return -1;
- }
- }
-
- return 0;
-}
-
-/*==========================================
- * modify homunculus hunger [orn]
- *------------------------------------------
- */
-int atcommand_homtalk(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char mes[100],temp[100];
-
- nullpo_retr(-1, sd);
-
- if(!merc_is_hom_active(sd->hd))
- return -1;
-
- if (sscanf(message, "%99[^\n]", mes) < 1)
- return -1;
-
- snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
- clif_message(&sd->hd->bl, temp);
-
- return 0;
-}
-
-/*==========================================
- * Show homunculus stats
- *------------------------------------------
- */
-int atcommand_hominfo(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct homun_data *hd;
- struct status_data *status;
- nullpo_retr(-1, sd);
-
- if(!merc_is_hom_active(sd->hd))
- return -1;
- hd = sd->hd;
- status = status_get_status_data(&hd->bl);
- clif_displaymessage(fd, "Homunculus stats :");
-
- snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
- status->hp, status->max_hp, status->sp, status->max_sp);
- clif_displaymessage(fd, atcmd_output);
-
- snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
- status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
- clif_displaymessage(fd, atcmd_output);
-
- snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
- hd->homunculus.hunger, hd->homunculus.intimacy/100);
- clif_displaymessage(fd, atcmd_output);
-
- return 0;
-}
-
-/*==========================================
- * Show Items DB Info v 1.0
- * originally by [Lupus] eAthena
- *------------------------------------------
- */
-int atcommand_iteminfo(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
- //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
-
- struct item_data *item_data, *item_array[MAX_SEARCH];
- int i, count = 1;
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
- return -1;
- }
- if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
- count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
-
- if (!count) {
- clif_displaymessage(fd, "Item not found.");
- return -1;
- }
-
- if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
- clif_displaymessage(fd, atcmd_output);
- count = MAX_SEARCH;
- }
- for (i = 0; i < count; i++) {
- item_data = item_array[i];
- sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
- item_data->name,item_data->jname,item_data->slot,item_data->nameid,
- item_data->type < 12 ? itype[item_data->type] : "BUG!",
- (item_data->script==NULL)? "None" : "With script"
- );
- clif_displaymessage(fd, atcmd_output);
-
- sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
- clif_displaymessage(fd, atcmd_output);
-
- if (item_data->maxchance == 10000)
- strcpy(atcmd_output, " - Available in the shops only");
- else if (item_data->maxchance)
- sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
- else
- strcpy(atcmd_output, " - Monsters don't drop this item");
- clif_displaymessage(fd, atcmd_output);
-
- }
- return 0;
-}
-
-/*==========================================
- * Show who drops the item.
- *------------------------------------------
- */
-int atcommand_whodrops(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- struct item_data *item_data, *item_array[MAX_SEARCH];
- int i,j, count = 1;
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
- return -1;
- }
- if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
- count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
-
- if (!count) {
- clif_displaymessage(fd, "Item not found.");
- return -1;
- }
-
- if (count > MAX_SEARCH) {
- sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
- clif_displaymessage(fd, atcmd_output);
- count = MAX_SEARCH;
- }
- for (i = 0; i < count; i++) {
- item_data = item_array[i];
- sprintf(atcmd_output, "Item: '%s'[%d]",
- item_data->jname,item_data->slot);
- clif_displaymessage(fd, atcmd_output);
-
- if (item_data->mob[0].chance == 0) {
- strcpy(atcmd_output, " - Item is not dropped by mobs.");
- clif_displaymessage(fd, atcmd_output);
- } else {
- sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
- clif_displaymessage(fd, atcmd_output);
-
- for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
- {
- sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
- clif_displaymessage(fd, atcmd_output);
- }
- }
- }
- return 0;
-}
-
-/*==========================================
- * @adopt by [Veider]
- *
- * adopt a novice
- *------------------------------------------
- */
-int
-atcommand_adopt(const int fd, struct map_session_data* sd,
-const char* command, const char* message)
-{
- struct map_session_data *pl_sd1 = NULL;
- struct map_session_data *pl_sd2 = NULL;
- struct map_session_data *pl_sd3 = NULL;
- char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
- clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
- return -1;
- }
-
- if (battle_config.etc_log)
- printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
-
- if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
- sprintf(player2, "Cannot find player %s online", player1);
- clif_displaymessage(fd, player2);
- return -1;
- }
-
- if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
- sprintf(player1, "Cannot find player %s online", player2);
- clif_displaymessage(fd, player1);
- return -1;
- }
-
- if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
- sprintf(player1, "Cannot find player %s online", player3);
- clif_displaymessage(fd, player1);
- return -1;
- }
-
- if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
- clif_displaymessage(fd, "They are too young to be parents!");
- return -1;
- }
-
- if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
- clif_displaymessage(fd, "They are family.. wish them luck");
- return 0;
- }
- else
- return -1;
-}
-
-int atcommand_version(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- const char * revision;
-
- if ((revision = get_svn_revision()) != 0) {
- sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
- clif_displaymessage(fd,atcmd_output);
- } else
- clif_displaymessage(fd,"Cannot determine SVN revision");
-
- return 0;
-}
-
-
-static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
-{
-
- int time, id;
- struct map_session_data *pl_sd = (struct map_session_data *)bl;
- if (pl_sd == NULL)
- return 0;
-
- id = va_arg(ap, int);
- time = va_arg(ap, int);
-
- if (id != bl->id && !pc_isGM(pl_sd)) {
- pl_sd->status.manner -= time;
- if (pl_sd->status.manner < 0)
- sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
- else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
- status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
- }
- return 0;
-}
-
-/*==========================================
- * @mutearea by MouseJstr
- *------------------------------------------
- */
-int atcommand_mutearea(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int time;
- nullpo_retr(0, sd);
-
- time = atoi(message);
- if (!time)
- time = 15; // 15 minutes default
- map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
- sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
- sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
-
- return 0;
-}
-
-static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
-{
- struct map_session_data *pl_sd = (struct map_session_data *) bl;
- if (bl == NULL)
- return 0;
-
- if (!pc_isGM(pl_sd))
- pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
-
- return 0;
-}
-
-/*==========================================
- * @shuffle by MouseJstr
- *------------------------------------------
- */
-int atcommand_shuffle(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(0, sd);
-
- if (strcmp(message, "area")== 0) {
- map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
- sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
- sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
- } else if (strcmp(message, "map")== 0) {
- map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
- } else if (strcmp(message, "world") == 0) {
- struct map_session_data **pl_allsd;
- int i, users;
- pl_allsd = map_getallusers(&users);
- for (i = 0; i < users; i++)
- atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
- } else
- clif_displaymessage(fd, "options are area, map, or world");
-
- return 0;
-}
-
-int atcommand_rates(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char buf[255];
-
- nullpo_retr(0, sd);
-
- sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
- battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
-
- clif_displaymessage(fd, buf);
-
- return 0;
-}
-
-/*==========================================
- * @me by lordalfa
- * => Displays the OUTPUT string on top of
- * the Visible players Heads.
- *------------------------------------------
- */
-
-int atcommand_me(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char tempmes[200];
- nullpo_retr(-1, sd);
-
- malloc_tsetdword(tempmes, '\0', sizeof(tempmes));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
-
- if (sd->sc.count && //no "chatting" while muted.
- (sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
- return -1;
-
- if (!message || !*message) {
- clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
- return -1;
- }
-
- sscanf(message, "%199[^\n]", tempmes);
- sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
- clif_disp_overhead(sd, atcmd_output);
-
- return 0;
-
-}
-
-/*==========================================
- * @size
- * => Resize your character sprite. [Valaris]
- *------------------------------------------
- */
-int atcommand_size(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int size=0;
-
- nullpo_retr(-1, sd);
-
- if (!message || !*message)
- return -1;
-
- if (sscanf(message,"%d", &size) < 1)
- return -1;
-
- if(sd->state.size) {
- sd->state.size=0;
- pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
- }
-
- if(size==1) {
- sd->state.size=1;
- clif_specialeffect(&sd->bl,420,AREA);
- } else if(size==2) {
- sd->state.size=2;
- clif_specialeffect(&sd->bl,422,AREA);
- }
-
- return 0;
-}
-
-/*==========================================
- * @monsterignore
- * => Makes monsters ignore you. [Valaris]
- *------------------------------------------
- */
-
-int atcommand_monsterignore(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- nullpo_retr(-1, sd);
-
- if (!sd->state.monster_ignore) {
- sd->state.monster_ignore = 1;
- clif_displaymessage(sd->fd, "You are now inmune to attacks.");
- } else {
- sd->state.monster_ignore = 0;
- clif_displaymessage(sd->fd, "Returned to normal state.");
- }
-
- return 0;
-}
-/*==========================================
- * @fakename
- * => Gives your character a fake name. [Valaris]
- *------------------------------------------
- */
-int atcommand_fakename(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
-
- char name[NAME_LENGTH];
- nullpo_retr(-1, sd);
-
- if((!message || !*message) && strlen(sd->fakename) > 1) {
- sd->fakename[0]='\0';
- clif_charnameack(0, &sd->bl);
- clif_displaymessage(sd->fd,"Returned to real name.");
- return 0;
- }
-
- if (!message || !*message) {
- clif_displaymessage(sd->fd,"You must enter a name.");
- return 0;
- }
-
-
- if (sscanf(message, "%23[^\n]", name) < 1) {
- return 0;
- }
-
- if(strlen(name) < 2) {
- clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
- return 0;
- }
-
- memcpy(sd->fakename,name,NAME_LENGTH-1);
- clif_charnameack(0, &sd->bl);
- clif_displaymessage(sd->fd,"Fake name enabled.");
-
- return 0;
-}
-/*==========================================
- * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
- * => Shows information about the map flags [map name]
- * Also set flags
- *------------------------------------------
- */
-int atcommand_mapflag(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
-// WIP
- return 0;
-}
-
-/*===================================
- * Remove some messages
- *-----------------------------------
- */
-int atcommand_showexp(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if (sd->state.showexp) {
- sd->state.showexp = 0;
- clif_displaymessage(fd, "Gained exp will not be shown.");
- return 0;
- }
-
- sd->state.showexp = 1;
- clif_displaymessage(fd, "Gained exp is now shown");
- return 0;
-}
-
-int atcommand_showzeny(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if (sd->state.showzeny) {
- sd->state.showzeny = 0;
- clif_displaymessage(fd, "Gained zeny will not be shown.");
- return 0;
- }
-
- sd->state.showzeny = 1;
- clif_displaymessage(fd, "Gained zeny is now shown");
- return 0;
-}
-
-int atcommand_showdelay(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if (sd->state.showdelay) {
- sd->state.showdelay = 0;
- clif_displaymessage(fd, "Skill delay failures won't be shown.");
- return 0;
- }
-
- sd->state.showdelay = 1;
- clif_displaymessage(fd, "Skill delay failures are shown now.");
- return 0;
-}
-
-/*==========================================
- * Duel organizing functions [LuzZza]
- *
- * @duel [limit|nick] - create a duel
- * @invite <nick> - invite player
- * @accept - accept invitation
- * @reject - reject invitation
- * @leave - leave duel
- *------------------------------------------
- */
-int atcommand_invite(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- unsigned int did = sd->duel_group;
- struct map_session_data *target_sd = map_nick2sd((char *)message);
-
- if(did <= 0) {
- // "Duel: @invite without @duel."
- clif_displaymessage(fd, msg_txt(350));
- return 0;
- }
-
- if(duel_list[did].max_players_limit > 0 &&
- duel_list[did].members_count >= duel_list[did].max_players_limit) {
-
- // "Duel: Limit of players is reached."
- clif_displaymessage(fd, msg_txt(351));
- return 0;
- }
-
- if(target_sd == NULL) {
- // "Duel: Player not found."
- clif_displaymessage(fd, msg_txt(352));
- return 0;
- }
-
- if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
- // "Duel: Player already in duel."
- clif_displaymessage(fd, msg_txt(353));
- return 0;
- }
-
- if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
- {
- sprintf(atcmd_output, msg_txt(364), message);
- clif_displaymessage(fd, atcmd_output);
- return 0;
- }
-
- duel_invite(did, sd, target_sd);
- // "Duel: Invitation has been sent."
- clif_displaymessage(fd, msg_txt(354));
- return 0;
-}
-
-int atcommand_duel(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char output[256];
- unsigned int maxpl=0, newduel;
- struct map_session_data *target_sd;
-
- /* // Commnted because it can be disabled in at-comms conf.
- if(!battle_config.duel_enable) {
- clif_displaymessage(fd, "Duel: duel is disable.");
- return 0;
- }
- */
-
- if(sd->duel_group > 0) {
- duel_showinfo(sd->duel_group, sd);
- return 0;
- }
-
- if(sd->duel_invite > 0) {
- // "Duel: @duel without @reject."
- clif_displaymessage(fd, msg_txt(355));
- return 0;
- }
-
- if(!duel_checktime(sd)) {
- // "Duel: You can take part in duel only one time per %d minutes."
- sprintf(output, msg_txt(356), battle_config.duel_time_interval);
- clif_displaymessage(fd, output);
- return 0;
- }
-
- if(strlen(message) > 0) {
- if(sscanf(message, "%d", &maxpl) >= 1) {
- if(maxpl < 2 || maxpl > 65535) {
- clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
- return 0;
- }
- duel_create(sd, maxpl);
- } else {
- target_sd = map_nick2sd((char *)message);
- if(target_sd != NULL) {
- if((newduel = duel_create(sd, 2)) != -1) {
- if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
- clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
- return 0;
- }
- duel_invite(newduel, sd, target_sd);
- clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
- }
- } else {
- // "Duel: Player not found."
- clif_displaymessage(fd, msg_txt(352));
- return 0;
- }
- }
- } else
- duel_create(sd, 0);
-
- return 0;
-}
-
-
-int atcommand_leave(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if(sd->duel_group <= 0) {
- // "Duel: @leave without @duel."
- clif_displaymessage(fd, msg_txt(358));
- return 0;
- }
-
- duel_leave(sd->duel_group, sd);
- clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
- return 0;
-}
-
-int atcommand_accept(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- char output[256];
-
- if(!duel_checktime(sd)) {
- // "Duel: You can take part in duel only one time per %d minutes."
- sprintf(output, msg_txt(356), battle_config.duel_time_interval);
- clif_displaymessage(fd, output);
- return 0;
- }
-
- if(sd->duel_invite <= 0) {
- // "Duel: @accept without invititation."
- clif_displaymessage(fd, msg_txt(360));
- return 0;
- }
-
- duel_accept(sd->duel_invite, sd);
- // "Duel: Invitation has been accepted."
- clif_displaymessage(fd, msg_txt(361));
- return 0;
-}
-
-int atcommand_reject(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if(sd->duel_invite <= 0) {
- // "Duel: @reject without invititation."
- clif_displaymessage(fd, msg_txt(362));
- return 0;
- }
-
- duel_reject(sd->duel_invite, sd);
- // "Duel: Invitation has been rejected."
- clif_displaymessage(fd, msg_txt(363));
- return 0;
-}
-
-/*===================================
- * Away message (@away, @aw) [LuzZza]
- *-----------------------------------
- */
-int atcommand_away(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if(strlen(message) > 0) {
- if(strlen(message) > 128)
- return -1;
- strcpy(sd->away_message, message);
- //"Away automessage has been activated."
- clif_displaymessage(fd, msg_txt(546));
- } else {
- if(strlen(sd->away_message) > 0) {
- sd->away_message[0] = 0;
- //"Away automessage has been disabled."
- clif_displaymessage(fd, msg_txt(547));
- return 0;
- }
- //"Usage: @away,@aw <message>. Enter empty message for disable it."
- clif_displaymessage(fd, msg_txt(548));
- }
- return 0;
-}
-
-// @clone/@slaveclone/@evilclone <playername> [Valaris]
-int atcommand_clone(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- int x=0,y=0,flag=0,master=0,i=0;
- struct map_session_data *pl_sd=NULL;
-
- if (!message || !*message) {
- clif_displaymessage(sd->fd,"You must enter a name or character ID.");
- return 0;
- }
-
- if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
- clif_displaymessage(fd, msg_txt(3));
- return 0;
- }
-
- if(pc_isGM(pl_sd) > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(126));
- return 0;
- }
-
- if (strcmpi(command, "@clone") == 0)
- flag = 1;
- else if (strcmpi(command, "@slaveclone") == 0) {
- flag = 2;
- master = sd->bl.id;
- if (battle_config.atc_slave_clone_limit
- && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
- clif_displaymessage(fd, msg_txt(127));
- return 0;
- }
- }
-
- do {
- x = sd->bl.x + (rand() % 10 - 5);
- y = sd->bl.y + (rand() % 10 - 5);
- } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
-
- if (i >= 10) {
- x = sd->bl.x;
- y = sd->bl.y;
- }
-
- if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
- clif_displaymessage(fd, msg_txt(128+flag*2));
- return 0;
- }
- clif_displaymessage(fd, msg_txt(129+flag*2));
- return 0;
-}
-
-/*===================================
- * Main chat [LuzZza]
- * Usage: @main <on|off|message>
- *-----------------------------------
- */
-int atcommand_main(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if(strlen(message) > 0) {
-
- if(strcmpi(message, "on") == 0) {
- if(!sd->state.mainchat) {
- sd->state.mainchat = 1;
- clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
- } else {
- clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
- }
- } else if(strcmpi(message, "off") == 0) {
- if(sd->state.mainchat) {
- sd->state.mainchat = 0;
- clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
- } else {
- clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
- }
- } else {
- if(!sd->state.mainchat) {
- sd->state.mainchat = 1;
- clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
- }
- if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
- clif_displaymessage(fd, msg_txt(387));
- return -1;
- }
- sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
- // I use 0xFE000000 color for signalizing that this message is
- // main chat message. 0xFE000000 is invalid color, same using
- // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
- intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
- }
-
- } else {
-
- if(sd->state.mainchat)
- // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
- clif_displaymessage(fd, msg_txt(384));
- else
- // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
- clif_displaymessage(fd, msg_txt(385));
- }
- return 0;
-}
-
-/*=====================================
- * Autorejecting Invites/Deals [LuzZza]
- * Usage: @noask
- *-------------------------------------
- */
-int atcommand_noask(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
-
- if(sd->state.noask) {
- clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
- sd->state.noask = 0;
- } else {
- clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
- sd->state.noask = 1;
- }
-
- return 0;
-}
-
-/*=====================================
- * Send a @request message to all GMs of lowest_gm_level.
- * Usage: @request <petition>
- *-------------------------------------
- */
-int atcommand_request(
- const int fd, struct map_session_data* sd,
- const char* command, const char* message)
-{
- if (!message || !*message) {
- clif_displaymessage(sd->fd,msg_txt(277));
- return -1;
- }
-
- sprintf(atcmd_output, msg_txt(278), message);
- intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
- clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
- clif_displaymessage(sd->fd,msg_txt(279));
- return 0;
-}
-
-void do_init_atcommand() {
- users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
- duel_count = 0;
- malloc_tsetdword(&duel_list[0], 0, sizeof(duel_list));
- add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
- return;
-}
-
-void do_final_atcommand() {
- users_db->destroy(users_db,NULL);
-}
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include <limits.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"
+#include "clif.h"
+#include "chrif.h"
+#include "intif.h"
+#include "itemdb.h"
+#include "map.h"
+#include "pc.h"
+#include "status.h"
+#include "skill.h"
+#include "mob.h"
+#include "pet.h"
+#include "mercenary.h" //[orn]
+#include "battle.h"
+#include "party.h"
+#include "guild.h"
+#include "script.h"
+#include "npc.h"
+#include "trade.h"
+#include "unit.h"
+
+#ifndef TXT_ONLY
+#include "mail.h"
+#endif
+
+static char command_symbol = '@'; // first char of the commands (by [Yor])
+
+char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
+
+#define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
+ACMD_FUNC(broadcast);
+ACMD_FUNC(localbroadcast);
+ACMD_FUNC(rura);
+ACMD_FUNC(where);
+ACMD_FUNC(jumpto);
+ACMD_FUNC(jump);
+ACMD_FUNC(who);
+ACMD_FUNC(who2);
+ACMD_FUNC(who3);
+ACMD_FUNC(whomap);
+ACMD_FUNC(whomap2);
+ACMD_FUNC(whomap3);
+ACMD_FUNC(whogm); // by Yor
+ACMD_FUNC(whozeny); // [Valaris]
+ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
+ACMD_FUNC(save);
+ACMD_FUNC(load);
+ACMD_FUNC(speed);
+ACMD_FUNC(charspeed);
+ACMD_FUNC(storage);
+ACMD_FUNC(guildstorage);
+ACMD_FUNC(option);
+ACMD_FUNC(hide);
+ACMD_FUNC(jobchange);
+ACMD_FUNC(die);
+ACMD_FUNC(kill);
+ACMD_FUNC(alive);
+ACMD_FUNC(kami);
+ACMD_FUNC(heal);
+ACMD_FUNC(item);
+ACMD_FUNC(item2);
+ACMD_FUNC(itemreset);
+ACMD_FUNC(baselevelup);
+ACMD_FUNC(joblevelup);
+ACMD_FUNC(help);
+ACMD_FUNC(help2);
+ACMD_FUNC(gm);
+ACMD_FUNC(pvpoff);
+ACMD_FUNC(pvpon);
+ACMD_FUNC(gvgoff);
+ACMD_FUNC(gvgon);
+ACMD_FUNC(model);
+ACMD_FUNC(go);
+ACMD_FUNC(monster);
+ACMD_FUNC(monstersmall);
+ACMD_FUNC(monsterbig);
+ACMD_FUNC(spawn);
+ACMD_FUNC(killmonster);
+ACMD_FUNC(killmonster2);
+ACMD_FUNC(refine);
+ACMD_FUNC(produce);
+ACMD_FUNC(memo);
+ACMD_FUNC(gat);
+ACMD_FUNC(packet);
+ACMD_FUNC(waterlevel);
+ACMD_FUNC(statuspoint);
+ACMD_FUNC(skillpoint);
+ACMD_FUNC(zeny);
+ACMD_FUNC(param);
+ACMD_FUNC(guildlevelup);
+ACMD_FUNC(makeegg);
+ACMD_FUNC(hatch);
+ACMD_FUNC(petfriendly);
+ACMD_FUNC(pethungry);
+ACMD_FUNC(petrename);
+ACMD_FUNC(recall);
+ACMD_FUNC(recallall);
+ACMD_FUNC(revive);
+ACMD_FUNC(night);
+ACMD_FUNC(day);
+ACMD_FUNC(doom);
+ACMD_FUNC(doommap);
+ACMD_FUNC(raise);
+ACMD_FUNC(raisemap);
+ACMD_FUNC(kick);
+ACMD_FUNC(kickall);
+ACMD_FUNC(allskill);
+ACMD_FUNC(questskill);
+ACMD_FUNC(lostskill);
+ACMD_FUNC(spiritball);
+ACMD_FUNC(party);
+ACMD_FUNC(guild);
+ACMD_FUNC(agitstart);
+ACMD_FUNC(agitend);
+ACMD_FUNC(reloaditemdb);
+ACMD_FUNC(reloadmobdb);
+ACMD_FUNC(reloadskilldb);
+ACMD_FUNC(reloadscript);
+ACMD_FUNC(reloadgmdb); // by Yor
+ACMD_FUNC(reloadatcommand);
+ACMD_FUNC(reloadbattleconf);
+ACMD_FUNC(reloadstatusdb);
+ACMD_FUNC(reloadpcdb);
+ACMD_FUNC(reloadmotd); // [Valaris]
+ACMD_FUNC(mapexit);
+ACMD_FUNC(idsearch);
+ACMD_FUNC(mapinfo);
+ACMD_FUNC(dye); //** by fritz
+ACMD_FUNC(hair_style); //** by fritz
+ACMD_FUNC(hair_color); //** by fritz
+ACMD_FUNC(stat_all); //** by fritz
+ACMD_FUNC(char_block); // by Yor
+ACMD_FUNC(char_ban); // by Yor
+ACMD_FUNC(char_unblock); // by Yor
+ACMD_FUNC(char_unban); // by Yor
+ACMD_FUNC(mount_peco); // by Valaris
+ACMD_FUNC(char_mount_peco); // by Yor
+ACMD_FUNC(guildspy); // [Syrus22]
+ACMD_FUNC(partyspy); // [Syrus22]
+ACMD_FUNC(repairall); // [Valaris]
+ACMD_FUNC(guildrecall); // by Yor
+ACMD_FUNC(partyrecall); // by Yor
+ACMD_FUNC(nuke); // [Valaris]
+ACMD_FUNC(shownpc);
+ACMD_FUNC(hidenpc);
+ACMD_FUNC(loadnpc);
+ACMD_FUNC(unloadnpc);
+ACMD_FUNC(servertime); // by Yor
+ACMD_FUNC(chardelitem); // by Yor
+ACMD_FUNC(jail); // by Yor
+ACMD_FUNC(unjail); // by Yor
+ACMD_FUNC(jailfor); // Alias Meruru
+ACMD_FUNC(jailtime); // Coltaro
+ACMD_FUNC(charjailtime); // Coltaro
+ACMD_FUNC(disguise); // [Valaris]
+ACMD_FUNC(undisguise); // by Yor
+ACMD_FUNC(chardisguise); // Kalaspuff
+ACMD_FUNC(charundisguise); // Kalaspuff
+ACMD_FUNC(email); // by Yor
+ACMD_FUNC(effect);//by Apple
+ACMD_FUNC(character_cart_list); // by Yor
+ACMD_FUNC(addwarp); // by MouseJstr
+ACMD_FUNC(follow); // by MouseJstr
+ACMD_FUNC(skillon); // by MouseJstr
+ACMD_FUNC(skilloff); // by MouseJstr
+ACMD_FUNC(killer); // by MouseJstr
+ACMD_FUNC(npcmove); // by MouseJstr
+ACMD_FUNC(killable); // by MouseJstr
+ACMD_FUNC(charkillable); // by MouseJstr
+ACMD_FUNC(dropall); // by MouseJstr
+ACMD_FUNC(chardropall); // by MouseJstr
+ACMD_FUNC(storeall); // by MouseJstr
+ACMD_FUNC(charstoreall); // by MouseJstr
+ACMD_FUNC(skillid); // by MouseJstr
+ACMD_FUNC(useskill); // by MouseJstr
+ACMD_FUNC(summon);
+ACMD_FUNC(rain);
+ACMD_FUNC(snow);
+ACMD_FUNC(sakura);
+ACMD_FUNC(clouds);
+ACMD_FUNC(clouds2); // [Valaris]
+ACMD_FUNC(fog);
+ACMD_FUNC(fireworks);
+ACMD_FUNC(leaves);
+ACMD_FUNC(adjgmlvl); // by MouseJstr
+ACMD_FUNC(adjcmdlvl); // by MouseJstr
+ACMD_FUNC(trade); // by MouseJstr
+ACMD_FUNC(send); // by davidsiaw
+ACMD_FUNC(setbattleflag); // by MouseJstr
+ACMD_FUNC(unmute); // [Valaris]
+ACMD_FUNC(clearweather); // Dexity
+ACMD_FUNC(uptime); // by MC Cameri
+ACMD_FUNC(changesex); // by MC Cameri
+ACMD_FUNC(mute); // celest
+ACMD_FUNC(refresh); // by MC Cameri
+ACMD_FUNC(petid); // by MC Cameri
+ACMD_FUNC(identify); // by MC Cameri
+ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
+ACMD_FUNC(misceffect); // by MC Cameri
+ACMD_FUNC(mobsearch);
+ACMD_FUNC(cleanmap);
+ACMD_FUNC(npctalk);
+ACMD_FUNC(pettalk);
+ACMD_FUNC(users);
+ACMD_FUNC(reset);
+ACMD_FUNC(autoloot); // Improved version imported from Freya.
+
+#ifndef TXT_ONLY
+ACMD_FUNC(checkmail); // [Valaris]
+ACMD_FUNC(listmail); // [Valaris]
+ACMD_FUNC(listnewmail); // [Valaris]
+ACMD_FUNC(readmail); // [Valaris]
+ACMD_FUNC(sendmail); // [Valaris]
+ACMD_FUNC(sendprioritymail); // [Valaris]
+ACMD_FUNC(deletemail); // [Valaris]
+ACMD_FUNC(refreshonline); // [Valaris]
+#endif /* TXT_ONLY */
+
+ACMD_FUNC(skilltree); // by MouseJstr
+
+ACMD_FUNC(marry); // by MouseJstr
+ACMD_FUNC(divorce); // by MouseJstr
+
+ACMD_FUNC(grind); // by MouseJstr
+ACMD_FUNC(grind2); // by MouseJstr
+
+#ifdef DMALLOC
+ACMD_FUNC(dmstart); // by MouseJstr
+ACMD_FUNC(dmtick); // by MouseJstr
+#endif
+
+ACMD_FUNC(jumptoid); // by Dino9021
+ACMD_FUNC(jumptoid2); // by Dino9021
+ACMD_FUNC(recallid); // by Dino9021
+ACMD_FUNC(recallid2); // by Dino9021
+ACMD_FUNC(kickid); // by Dino9021
+ACMD_FUNC(kickid2); // by Dino9021
+ACMD_FUNC(reviveid); // by Dino9021
+ACMD_FUNC(reviveid2); // by Dino9021
+ACMD_FUNC(killid); // by Dino9021
+ACMD_FUNC(killid2); // by Dino9021
+ACMD_FUNC(charkillableid); // by Dino9021
+ACMD_FUNC(charkillableid2); // by Dino9021
+ACMD_FUNC(sound);
+ACMD_FUNC(undisguiseall);
+ACMD_FUNC(disguiseall);
+ACMD_FUNC(changelook);
+ACMD_FUNC(mobinfo); //by Lupus
+ACMD_FUNC(exp); // by Skotlex
+ACMD_FUNC(adopt); // by Veider
+
+ACMD_FUNC(version); // by Ancyker
+
+ACMD_FUNC(mutearea); // by MouseJstr
+ACMD_FUNC(shuffle); // by MouseJstr
+ACMD_FUNC(rates); // by MouseJstr
+
+ACMD_FUNC(iteminfo); // Lupus
+ACMD_FUNC(whodrops); //Skotlex
+ACMD_FUNC(mapflag); // Lupus
+ACMD_FUNC(me); //added by massdriller, code by lordalfa
+ACMD_FUNC(monsterignore); // [Valaris]
+ACMD_FUNC(fakename); //[Valaris]
+ACMD_FUNC(size); //[Valaris]
+ACMD_FUNC(showexp); //moved from charcommand [Kevin]
+ACMD_FUNC(showzeny);
+ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
+ACMD_FUNC(autotrade);// durf
+ACMD_FUNC(changeleader);// [Skotlex]
+ACMD_FUNC(partyoption);// [Skotlex]
+ACMD_FUNC(changegm);// durf
+
+// Duel [LuzZza]
+ACMD_FUNC(invite);
+ACMD_FUNC(duel);
+ACMD_FUNC(leave);
+ACMD_FUNC(accept);
+ACMD_FUNC(reject);
+
+ACMD_FUNC(away); // LuzZza
+ACMD_FUNC(main); // LuzZza
+
+ACMD_FUNC(clone); // [Valaris]
+ACMD_FUNC(tonpc); // LuzZza
+ACMD_FUNC(commands); // [Skotlex]
+ACMD_FUNC(noask); //LuzZza
+ACMD_FUNC(request); //[Skotlex]
+
+ACMD_FUNC(homlevel); //[orn]
+ACMD_FUNC(homevolution); //[orn]
+ACMD_FUNC(makehomun); //[orn]
+ACMD_FUNC(homfriendly); //[orn]
+ACMD_FUNC(homhungry); //[orn]
+ACMD_FUNC(homtalk); //[orn]
+ACMD_FUNC(hominfo); //[Toms]
+ACMD_FUNC(showmobs); //KarLaeda
+
+/*==========================================
+ *AtCommandInfo atcommand_info[]構造体の定義
+ *------------------------------------------
+ */
+
+// First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
+// to set default level, read atcommand_athena.conf first please.
+static AtCommandInfo atcommand_info[] = {
+ { AtCommand_Rura, "@rura", 40, atcommand_rura },
+ { AtCommand_Warp, "@warp", 40, atcommand_rura },
+ { AtCommand_Where, "@where", 1, atcommand_where },
+ { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
+ { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
+ { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
+ { AtCommand_Jump, "@jump", 40, atcommand_jump },
+ { AtCommand_Who, "@who", 20, atcommand_who },
+ { AtCommand_Who, "@whois", 20, atcommand_who },
+ { AtCommand_Who, "@w", 20, atcommand_who },
+ { AtCommand_Who2, "@who2", 20, atcommand_who2 },
+ { AtCommand_Who3, "@who3", 20, atcommand_who3 },
+ { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
+ { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
+ { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
+ { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
+ { AtCommand_Save, "@save", 40, atcommand_save },
+ { AtCommand_Load, "@return", 40, atcommand_load },
+ { AtCommand_Load, "@load", 40, atcommand_load },
+ { AtCommand_Speed, "@speed", 40, atcommand_speed },
+ { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
+ { AtCommand_Storage, "@storage", 1, atcommand_storage },
+ { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
+ { AtCommand_Option, "@option", 40, atcommand_option },
+ { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
+ { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
+ { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
+ { AtCommand_Die, "@die", 1, atcommand_die },
+ { AtCommand_Kill, "@kill", 60, atcommand_kill },
+ { AtCommand_Alive, "@alive", 60, atcommand_alive },
+ { AtCommand_Kami, "@kami", 40, atcommand_kami },
+ { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
+ { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
+ { AtCommand_Heal, "@heal", 40, atcommand_heal },
+ { AtCommand_Item, "@item", 60, atcommand_item },
+ { AtCommand_Item2, "@item2", 60, atcommand_item2 },
+ { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
+ { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
+ { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
+ { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
+ { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
+ { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
+ { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
+ { AtCommand_H, "@h", 20, atcommand_help },
+ { AtCommand_Help, "@help", 20, atcommand_help },
+ { AtCommand_H2, "@h2", 20, atcommand_help2 },
+ { AtCommand_Help2, "@help2", 20, atcommand_help2 },
+ { AtCommand_GM, "@gm", 100,atcommand_gm },
+ { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
+ { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
+ { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
+ { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
+ { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
+ { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
+ { AtCommand_Model, "@model", 20, atcommand_model },
+ { AtCommand_Go, "@go", 10, atcommand_go },
+ { AtCommand_Spawn, "@monster", 50, atcommand_monster },
+ { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
+ { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
+ { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
+ { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
+ { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
+ { AtCommand_Refine, "@refine", 60, atcommand_refine },
+ { AtCommand_Produce, "@produce", 60, atcommand_produce },
+ { AtCommand_Memo, "@memo", 40, atcommand_memo },
+ { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
+ { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
+ { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
+ { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
+ { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
+ { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
+ { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
+ { AtCommand_Strength, "@str", 60, atcommand_param },
+ { AtCommand_Agility, "@agi", 60, atcommand_param },
+ { AtCommand_Vitality, "@vit", 60, atcommand_param },
+ { AtCommand_Intelligence, "@int", 60, atcommand_param },
+ { AtCommand_Dexterity, "@dex", 60, atcommand_param },
+ { AtCommand_Luck, "@luk", 60, atcommand_param },
+ { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
+ { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
+ { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
+ { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
+ { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
+ { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
+ { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
+ { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
+ { AtCommand_Revive, "@revive", 60, atcommand_revive },
+ { AtCommand_Night, "@night", 80, atcommand_night },
+ { AtCommand_Day, "@day", 80, atcommand_day },
+ { AtCommand_Doom, "@doom", 80, atcommand_doom },
+ { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
+ { AtCommand_Raise, "@raise", 80, atcommand_raise },
+ { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
+ { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
+ { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
+ { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
+ { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
+ { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
+ { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
+ { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
+ { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
+ { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
+ { AtCommand_Party, "@party", 1, atcommand_party },
+ { AtCommand_Guild, "@guild", 50, atcommand_guild },
+ { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
+ { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
+ { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
+ { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
+ { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
+ { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
+ { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
+ { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
+ { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
+ { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
+ { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
+ { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
+ { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
+ { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
+ { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
+ { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
+ { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
+ { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
+ { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
+ { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
+ { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
+ { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
+ { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
+ { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
+ { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
+ { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
+ { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
+ { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
+ { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
+ { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
+ { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
+ { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
+ { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
+ { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
+ { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
+ { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
+ { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
+ { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
+ { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
+ { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
+ { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
+ { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
+ { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
+ { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
+ { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
+ { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
+ { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
+ { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
+ { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
+ { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
+ { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
+ { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
+ { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
+ { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
+ { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
+ { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
+ { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
+ { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
+ { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
+ { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
+ { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
+ { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
+ { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
+ { AtCommand_JailFor, "@jailfor", 20, atcommand_jailfor }, //Meruru
+ { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime }, //Change this to 0 in atcommand_conf.txt if you want it accessible to players (you most likely will ;))
+ { AtCommand_CharJailTime, "@charjailtime", 20, atcommand_charjailtime },
+ { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
+ { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
+ { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
+ { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
+ { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
+ { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
+ { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
+ { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
+ { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
+ { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
+ { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
+ { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
+ { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
+ { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
+ { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
+ { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
+ { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
+ { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
+ { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
+ { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
+ { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
+// { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
+ { AtCommand_Snow, "@snow", 99, atcommand_snow },
+ { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
+ { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
+ { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
+ { AtCommand_Fog, "@fog", 99, atcommand_fog },
+ { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
+ { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
+ { AtCommand_Summon, "@summon", 60, atcommand_summon },
+ { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
+ { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
+ { AtCommand_Trade, "@trade", 60, atcommand_trade },
+ { AtCommand_Send, "@send", 60, atcommand_send },
+ { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
+ { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
+ { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
+ { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
+ { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
+ { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
+ { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
+ { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
+ { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
+ { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
+ { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
+ { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
+ { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
+ { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
+ { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
+ { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
+ { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
+ { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
+ { AtCommand_Users, "@users", 40, atcommand_users },
+ { AtCommand_ResetState, "@reset", 40, atcommand_reset },
+
+#ifndef TXT_ONLY // sql-only commands
+ { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
+ { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
+ { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
+ { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
+ { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
+ { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
+ { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
+ { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
+
+#endif /* TXT_ONLY */
+ { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
+ { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
+ { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
+ { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
+ { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
+
+#ifdef DMALLOC
+ { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
+ { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
+#endif
+
+ { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
+ { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
+ { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
+ { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
+ { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
+ { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
+ { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
+ { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
+ { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
+ { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
+ { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
+ { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
+ { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
+ { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
+ { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
+ { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
+ { AtCommand_Sound, "@sound", 40, atcommand_sound },
+ { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
+ { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
+ { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
+ { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
+ { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
+ { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
+ { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
+ { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
+ { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
+ { AtCommand_Version, "@version", 1, atcommand_version },
+
+ { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
+ { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
+ { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
+ { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
+
+ { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
+ { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
+ { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
+ { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
+
+ { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
+ { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
+ { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
+ { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
+ { AtCommand_Size, "@size", 20, atcommand_size },
+ { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
+ { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
+ { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
+ { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
+ { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
+ { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
+ { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
+ { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
+ { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
+ { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
+ { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
+ { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
+ { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
+ { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
+ { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
+ { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
+ { AtCommand_Clone, "@clone", 50, atcommand_clone },
+ { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
+ { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
+ { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
+ { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
+ { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
+ { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
+
+ { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
+ { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
+ { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
+ { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
+ { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
+ { AtCommand_HomTalk, "@homtalk", 0, atcommand_homtalk },
+ { AtCommand_HomInfo, "@hominfo", 0, atcommand_hominfo },
+ { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
+// add new commands before this line
+ { AtCommand_Unknown, NULL, 1, NULL }
+};
+
+/*=========================================
+ * Generic variables
+ *-----------------------------------------
+ */
+char atcmd_output[200];
+char atcmd_player_name[100];
+char atcmd_temp[100];
+
+/*==========================================
+ * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
+ *------------------------------------------
+ */
+char *estr_lower(char *str)
+{
+ int i;
+
+ for (i=0; str[i]; i++)
+ if ((str[i] >= 65) && (str[i] <= 90))
+ str[i] += 32;
+ return str;
+}
+
+// compare function for sorting high to lowest
+int hightolow_compare (const void * a, const void * b)
+{
+ return ( *(int*)b - *(int*)a );
+}
+
+// compare function for sorting lowest to highest
+int lowtohigh_compare (const void * a, const void * b)
+{
+ return ( *(int*)a - *(int*)b );
+}
+
+//-----------------------------------------------------------
+// Return the message string of the specified number by [Yor]
+//-----------------------------------------------------------
+char * msg_txt(int msg_number) {
+ if (msg_number >= 0 && msg_number < MAX_MSG &&
+ msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
+ return msg_table[msg_number];
+
+ return "??";
+}
+
+//-----------------------------------------------------------
+// Returns Players title (from msg_athena.conf) [Lupus]
+//-----------------------------------------------------------
+char * player_title_txt(int level) {
+ if (level < battle_config.title_lvl1)
+ return ""; //w/o any titles
+
+ if (level >= battle_config.title_lvl8)
+ sprintf(atcmd_temp, msg_txt(332), level);
+ else
+ if (level >= battle_config.title_lvl7)
+ sprintf(atcmd_temp, msg_txt(331), level);
+ else
+ if (level >= battle_config.title_lvl6)
+ sprintf(atcmd_temp, msg_txt(330), level);
+ else
+ if (level >= battle_config.title_lvl5)
+ sprintf(atcmd_temp, msg_txt(329), level);
+ else
+ if (level >= battle_config.title_lvl4)
+ sprintf(atcmd_temp, msg_txt(328), level);
+ else
+ if (level >= battle_config.title_lvl3)
+ sprintf(atcmd_temp, msg_txt(327), level);
+ else
+ if (level >= battle_config.title_lvl2)
+ sprintf(atcmd_temp, msg_txt(326), level);
+ else
+ sprintf(atcmd_temp, msg_txt(325), level); //lvl1
+ return atcmd_temp;
+}
+
+//------------------------------------------------------------
+// E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
+//------------------------------------------------------------
+int e_mail_check(char *email) {
+ char ch;
+ char* last_arobas;
+
+ // athena limits
+ if (strlen(email) < 3 || strlen(email) > 39)
+ return 0;
+
+ // part of RFC limits (official reference of e-mail description)
+ if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
+ return 0;
+
+ if (email[strlen(email)-1] == '.')
+ return 0;
+
+ last_arobas = strrchr(email, '@');
+
+ if (strstr(last_arobas, "@.") != NULL ||
+ strstr(last_arobas, "..") != NULL)
+ return 0;
+
+ for(ch = 1; ch < 32; ch++) {
+ if (strchr(last_arobas, ch) != NULL) {
+ return 0;
+ break;
+ }
+ }
+
+ if (strchr(last_arobas, ' ') != NULL ||
+ strchr(last_arobas, ';') != NULL)
+ return 0;
+
+ // all correct
+ return 1;
+}
+
+/*==========================================
+ * get_atcommand_level @コマンドの必要レベルを取得
+ *------------------------------------------
+ */
+int get_atcommand_level(const AtCommandType type) {
+ int i;
+
+ for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
+ if (atcommand_info[i].type == type)
+ return atcommand_info[i].level;
+
+ return 100; // 100: command can not be used
+}
+
+AtCommandType
+atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
+ AtCommandInfo info;
+ AtCommandType type;
+
+ malloc_set(&info, 0, sizeof(info));
+
+ type = atcommand(sd, gmlvl, str, &info);
+ if (type != AtCommand_None) {
+ char command[100];
+ const char* p = str;
+
+ if (map[sd->bl.m].nocommand &&
+ gmlvl < map[sd->bl.m].nocommand)
+ { //Command not allowed on this map.
+ sprintf(atcmd_output, msg_txt(143));
+ clif_displaymessage(fd, atcmd_output);
+ return AtCommand_None;
+ }
+
+ malloc_tsetdword(command, '\0', sizeof(command));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ while (*p && !isspace(*p))
+ p++;
+ if (p - str >= sizeof(command)) // too long
+ return AtCommand_Unknown;
+ strncpy(command, str, p - str);
+ while (isspace(*p))
+ p++;
+
+ if (type == AtCommand_Unknown || info.proc == NULL) {
+ sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ if (info.proc(fd, sd, command, p) != 0) {
+ // Command can not be executed
+ sprintf(atcmd_output, msg_txt(154), command); // %s failed.
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+
+ return info.type;
+ }
+
+ return AtCommand_None;
+}
+
+/*==========================================
+ *is_atcommand @コマンドに存在するかどうか確認する
+ *------------------------------------------
+ */
+AtCommandType
+is_atcommand(const int fd, struct map_session_data* sd, const char* message) {
+ const char* str = message;
+ int s_flag = 0;
+
+ nullpo_retr(AtCommand_None, sd);
+
+ if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
+ return AtCommand_Unknown;
+ }
+
+ if (!message || !*message)
+ return AtCommand_None;
+
+ str += strlen(sd->status.name);
+ while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
+ if (*str == ':')
+ s_flag = 1;
+ str++;
+ }
+ if (!*str)
+ return AtCommand_None;
+
+ return atcommand_sub(fd,sd,str,pc_isGM(sd));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
+ char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
+
+ if (!info)
+ return AtCommand_None;
+ if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
+ return AtCommand_None;
+ if (!p || !*p) {
+ ShowError("at command message is empty\n");
+ return AtCommand_None;
+ }
+
+ if (*p == command_symbol) { // check first char.
+ char command[101];
+ int i = 0;
+ malloc_set(info, 0, sizeof(AtCommandInfo));
+ sscanf(p, "%100s", command);
+ command[sizeof(command)-1] = '\0';
+
+ while (atcommand_info[i].type != AtCommand_Unknown) {
+ if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
+ p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
+ break;
+ }
+ i++;
+ }
+
+ if (atcommand_info[i].type == AtCommand_Unknown) {
+ // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
+ if (level == 0)
+ return AtCommand_None;
+ else
+ return AtCommand_Unknown;
+ } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
+ log_atcommand(sd, message);
+ }
+ memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
+ } else {
+ return AtCommand_None;
+ }
+
+ return info->type;
+}
+
+/*==========================================
+ * Read Message Data
+ *------------------------------------------
+ */
+int msg_config_read(const char *cfgName) {
+ int msg_number;
+ char line[1024], w1[1024], w2[1024];
+ FILE *fp;
+ static int called = 1;
+
+ if ((fp = fopen(cfgName, "r")) == NULL) {
+ ShowError("Messages file not found: %s\n", cfgName);
+ return 1;
+ }
+
+ if ((--called) == 0)
+ malloc_tsetdword(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
+ while(fgets(line, sizeof(line)-1, fp)) {
+ if (line[0] == '/' && line[1] == '/')
+ continue;
+ if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
+ if (strcmpi(w1, "import") == 0) {
+ msg_config_read(w2);
+ } else {
+ msg_number = atoi(w1);
+ if (msg_number >= 0 && msg_number < MAX_MSG) {
+ if (msg_table[msg_number] != NULL)
+ aFree(msg_table[msg_number]);
+ msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
+ strcpy(msg_table[msg_number],w2);
+ // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
+ }
+ }
+ }
+ }
+ fclose(fp);
+
+ return 0;
+}
+
+/*==========================================
+ * Cleanup Message Data
+ *------------------------------------------
+ */
+void do_final_msg (void) {
+ int i;
+ for (i = 0; i < MAX_MSG; i++)
+ aFree(msg_table[i]);
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
+ int i;
+
+ for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
+ if (strcmpi(atcommand_info[i].command + 1, name) == 0)
+ return &atcommand_info[i];
+
+ return NULL;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_config_read(const char *cfgName) {
+ char line[1024], w1[1024], w2[1024];
+ AtCommandInfo* p;
+ FILE* fp;
+
+ if ((fp = fopen(cfgName, "r")) == NULL) {
+ ShowError("At commands configuration file not found: %s\n", cfgName);
+ return 1;
+ }
+
+ while (fgets(line, sizeof(line)-1, fp)) {
+ if (line[0] == '/' && line[1] == '/')
+ continue;
+
+ if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
+ continue;
+ p = get_atcommandinfo_byname(w1);
+ if (p != NULL) {
+ p->level = atoi(w2);
+ if (p->level > 100)
+ p->level = 100;
+ else if (p->level < 0)
+ p->level = 0;
+ }
+
+ if (strcmpi(w1, "import") == 0)
+ atcommand_config_read(w2);
+ else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
+ w2[0] != '/' && // symbol of standard ragnarok GM commands
+ w2[0] != '%' && // symbol of party chat speaking
+ w2[0] != '$' && // symbol of guild chat
+ w2[0] != '#') // symbol of charcommand
+ command_symbol = w2[0];
+ }
+ fclose(fp);
+
+ return 0;
+}
+
+/*==========================================
+// @ command processing functions
+ *------------------------------------------
+ */
+
+/*==========================================
+ * @commands Lists available @ commands to you (code 98% from Meruru)
+ *------------------------------------------
+ */
+int atcommand_commands(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char cz_line_buff[MESSAGE_SIZE+1];
+
+ register char *lpcz_cur = cz_line_buff;
+ register unsigned int ui_slen;
+
+ int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
+
+ malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
+ cz_line_buff[MESSAGE_SIZE] = 0;
+
+ clif_displaymessage(fd, msg_txt(273));
+
+ for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
+ {
+ if(gm_lvl < atcommand_info[i_cur_cmd].level)
+ continue;
+
+ count++;
+ ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
+
+ //rember not <= bc we need null terminator
+ if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
+ {
+ clif_displaymessage(fd,(char*)cz_line_buff);
+ lpcz_cur = cz_line_buff;
+ malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
+ cz_line_buff[MESSAGE_SIZE] = 0;
+ }
+
+ memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
+ lpcz_cur += ui_slen+(10-ui_slen%10);
+ }
+
+ clif_displaymessage(fd,(char*)cz_line_buff);
+ sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+}
+
+/*==========================================
+ * @send (used for testing packet sends from the client)
+ *------------------------------------------
+ */
+int atcommand_send(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int len=0,off,end,type;
+ long num;
+ (void)command; // not used
+
+ // read message type as hex number (without the 0x)
+ if(!message || !*message ||
+ !((sscanf(message, "len %x", &type)==1 && (len=1))
+ || sscanf(message, "%x", &type)==1) )
+ {
+ clif_displaymessage(fd, "Usage:");
+ clif_displaymessage(fd, " @send len <packet hex number>");
+ clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
+ clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
+ return -1;
+ }
+
+#define PARSE_ERROR(error,p) \
+ {\
+ clif_displaymessage(fd, (error));\
+ sprintf(atcmd_output, ">%s", (p));\
+ clif_displaymessage(fd, atcmd_output);\
+ }
+//define PARSE_ERROR
+
+#define CHECK_EOS(p) \
+ if(*(p) == 0){\
+ clif_displaymessage(fd, "Unexpected end of string");\
+ return -1;\
+ }
+//define CHECK_EOS
+
+#define SKIP_VALUE(p) \
+ {\
+ while(*(p) && !isspace(*(p))) ++(p); /* non-space */\
+ while(*(p) && isspace(*(p))) ++(p); /* space */\
+ }
+//define SKIP_VALUE
+
+#define GET_VALUE(p,num) \
+ {\
+ if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
+ PARSE_ERROR("Invalid number in:",(p));\
+ return -1;\
+ }\
+ }
+//define GET_VALUE
+
+ if (type > 0 && type < MAX_PACKET_DB) {
+
+ if(len)
+ {// show packet length
+ sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+
+ len=packet_db[sd->packet_ver][type].len;
+ off=2;
+ if(len == 0)
+ {// unknown packet - ERROR
+ sprintf(atcmd_output, "Unknown packet: 0x%x", type);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ } else if(len == -1)
+ {// dynamic packet
+ len=SHRT_MAX-4; // maximum length
+ off=4;
+ }
+ WFIFOHEAD(fd, len);
+ WFIFOW(fd,0)=TOW(type);
+
+ // parse packet contents
+ SKIP_VALUE(message);
+ while(*message != 0 && off < len){
+ if(isdigit(*message) || *message == '-' || *message == '+')
+ {// default (byte)
+ GET_VALUE(message,num);
+ WFIFOB(fd,off)=TOB(num);
+ ++off;
+ } else if(toupper(*message) == 'B')
+ {// byte
+ ++message;
+ GET_VALUE(message,num);
+ WFIFOB(fd,off)=TOB(num);
+ ++off;
+ } else if(toupper(*message) == 'W')
+ {// word (2 bytes)
+ ++message;
+ GET_VALUE(message,num);
+ WFIFOW(fd,off)=TOW(num);
+ off+=2;
+ } else if(toupper(*message) == 'L')
+ {// long word (4 bytes)
+ ++message;
+ GET_VALUE(message,num);
+ WFIFOL(fd,off)=TOL(num);
+ off+=4;
+ } else if(toupper(*message) == 'S')
+ {// string - escapes are valid
+ // get string length - num <= 0 means not fixed length (default)
+ ++message;
+ if(*message == '"'){
+ num=0;
+ } else {
+ GET_VALUE(message,num);
+ while(*message != '"')
+ {// find start of string
+ if(*message == 0 || isspace(*message)){
+ PARSE_ERROR("Not a string:",message);
+ return -1;
+ }
+ ++message;
+ }
+ }
+
+ // parse string
+ ++message;
+ CHECK_EOS(message);
+ end=(num<=0? 0: min(off+((int)num),len));
+ for(; *message != '"' && (off < end || end == 0); ++off){
+ if(*message == '\\'){
+ ++message;
+ CHECK_EOS(message);
+ switch(*message){
+ case 'a': num=0x07; break; // Bell
+ case 'b': num=0x08; break; // Backspace
+ case 't': num=0x09; break; // Horizontal tab
+ case 'n': num=0x0A; break; // Line feed
+ case 'v': num=0x0B; break; // Vertical tab
+ case 'f': num=0x0C; break; // Form feed
+ case 'r': num=0x0D; break; // Carriage return
+ case 'e': num=0x1B; break; // Escape
+ default: num=*message; break;
+ case 'x': // Hexadecimal
+ {
+ ++message;
+ CHECK_EOS(message);
+ if(!isxdigit(*message)){
+ PARSE_ERROR("Not a hexadecimal digit:",message);
+ return -1;
+ }
+ num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
+ if(isxdigit(*message)){
+ ++message;
+ CHECK_EOS(message);
+ num<<=8;
+ num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
+ }
+ WFIFOB(fd,off)=TOB(num);
+ ++message;
+ CHECK_EOS(message);
+ continue;
+ }
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7': // Octal
+ {
+ num=*message-'0'; // 1st octal digit
+ ++message;
+ CHECK_EOS(message);
+ if(isdigit(*message) && *message < '8'){
+ num<<=3;
+ num+=*message-'0'; // 2nd octal digit
+ ++message;
+ CHECK_EOS(message);
+ if(isdigit(*message) && *message < '8'){
+ num<<=3;
+ num+=*message-'0'; // 3rd octal digit
+ ++message;
+ CHECK_EOS(message);
+ }
+ }
+ WFIFOB(fd,off)=TOB(num);
+ continue;
+ }
+ }
+ } else
+ num=*message;
+ WFIFOB(fd,off)=TOB(num);
+ ++message;
+ CHECK_EOS(message);
+ }//for
+ while(*message != '"')
+ {// ignore extra characters
+ ++message;
+ CHECK_EOS(message);
+ }
+
+ // terminate the string
+ if(off < end)
+ {// fill the rest with 0's
+ memset(WFIFOP(fd,off),0,end-off);
+ off=end;
+ }
+ } else
+ {// unknown
+ PARSE_ERROR("Unknown type of value in:",message);
+ return -1;
+ }
+ SKIP_VALUE(message);
+ }
+
+ if(packet_db[sd->packet_ver][type].len == -1)
+ {// send dynamic packet
+ WFIFOW(fd,2)=TOW(off);
+ WFIFOSET(fd,off);
+ } else
+ {// send static packet
+ if(off < len)
+ memset(WFIFOP(fd,off),0,len-off);
+ WFIFOSET(fd,len);
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(259)); // Invalid packet
+ return -1;
+ }
+ sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+#undef PARSE_ERROR
+#undef CHECK_EOS
+#undef SKIP_VALUE
+#undef GET_VALUE
+}
+
+// @rura
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_rura(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char map_name[MAP_NAME_LENGTH];
+ unsigned short mapindex;
+ int x = 0, y = 0;
+ int m = -1;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+
+ if (!message || !*message ||
+ (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
+ sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
+
+ clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
+ return -1;
+ }
+
+ if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(map_name, ".gat");
+
+ mapindex = mapindex_name2id(map_name);
+ if (mapindex)
+ m = map_mapindex2mapid(mapindex);
+
+ if (!mapindex || m < 0) {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+
+ if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
+ clif_displaymessage(fd, msg_txt(2));
+ x = y = 0; //Invalid cell, use random spot.
+ }
+ if (map[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;
+ }
+ if (pc_setpos(sd, mapindex, x, y, 3) == 0)
+ clif_displaymessage(fd, msg_txt(0)); // Warped.
+ else {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Displays where a character is. Corrected version by Silent. [Skotlex]
+ *------------------------------------------
+ */
+int atcommand_where(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int GM_level, pl_GM_level;
+
+ nullpo_retr(-1, sd);
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
+ return -1;
+ }
+ pl_sd = map_nick2sd(atcmd_player_name);
+
+ if (pl_sd == NULL)
+ return -1;
+
+ if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
+ return -1;
+
+ GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
+ pl_GM_level = pc_isGM(pl_sd);
+
+ if (battle_config.hide_GM_session) {
+ if(GM_level < pl_GM_level) {
+ if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
+ return -1;
+ }
+ }
+ }
+
+ snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
+ pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_jumpto(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
+ return -1;
+ }
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
+ if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
+ return -1;
+ if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
+ return -1;
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != 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), atcmd_player_name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_jump(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int x = 0, y = 0;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ sscanf(message, "%d %d", &x, &y);
+
+ if (x <= 0) //If coordinates are 'wrong', random jump.
+ x = -1;
+ if (y <= 0)
+ y = -1;
+ if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+ pc_setpos(sd, sd->mapindex, x, y, 3);
+ sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+}
+
+/*==========================================
+ * @who3 = Player name, his location
+ *------------------------------------------
+ */
+int atcommand_who3(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char temp0[100];
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, j, count, users;
+ int pl_GM_level, GM_level;
+ char match_text[100];
+ char player_name[NAME_LENGTH];
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if (sscanf(message, "%99[^\n]", match_text) < 1)
+ strcpy(match_text, "");
+ for (j = 0; match_text[j]; j++)
+ match_text[j] = tolower(match_text[j]);
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
+ for (j = 0; player_name[j]; j++)
+ player_name[j] = tolower(player_name[j]);
+ if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
+
+ if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
+ sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
+ } else {
+ atcmd_output[0]=0;
+ }
+ //Player name
+ sprintf(temp0, msg_txt(333), pl_sd->status.name);
+ strcat(atcmd_output,temp0);
+ //Player title, if exists
+ if (pl_GM_level > 0) {
+ //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
+ sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
+ strcat(atcmd_output,temp0);
+ }
+ //Players Location: map x y
+ sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ strcat(atcmd_output,temp0);
+
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ clif_displaymessage(fd, msg_txt(28)); // No player found.
+ else if (count == 1)
+ clif_displaymessage(fd, msg_txt(29)); // 1 player found.
+ else {
+ sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Player name, BLevel, Job,
+ *------------------------------------------
+ */
+int atcommand_who2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char temp0[100];
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, j, count, users;
+ int pl_GM_level, GM_level;
+ char match_text[100];
+ char player_name[NAME_LENGTH];
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if (sscanf(message, "%99[^\n]", match_text) < 1)
+ strcpy(match_text, "");
+ for (j = 0; match_text[j]; j++)
+ match_text[j] = tolower(match_text[j]);
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
+ for (j = 0; player_name[j]; j++)
+ player_name[j] = tolower(player_name[j]);
+ if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
+ //Players Name
+ //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
+ sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
+ //Player title, if exists
+ if (pl_GM_level > 0) {
+ //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
+ sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
+ strcat(atcmd_output,temp0);
+ }
+ //Players Base Level / Job name
+ //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
+ sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
+ strcat(atcmd_output,temp0);
+
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ clif_displaymessage(fd, msg_txt(28)); // No player found.
+ else if (count == 1)
+ clif_displaymessage(fd, msg_txt(29)); // 1 player found.
+ else {
+ sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Player name, Playrs Party / Guild name
+ *------------------------------------------
+ */
+int atcommand_who(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char temp0[100];
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, j, count, users;
+ int pl_GM_level, GM_level;
+ char match_text[100];
+ char player_name[NAME_LENGTH];
+ struct guild *g;
+ struct party_data *p;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(temp0, '\0', sizeof(temp0));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if (sscanf(message, "%99[^\n]", match_text) < 1)
+ strcpy(match_text, "");
+ for (j = 0; match_text[j]; j++)
+ match_text[j] = tolower(match_text[j]);
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
+ for (j = 0; player_name[j]; j++)
+ player_name[j] = tolower(player_name[j]);
+ if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
+ g = guild_search(pl_sd->status.guild_id);
+ p = party_search(pl_sd->status.party_id);
+ //Players Name
+ //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
+ sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
+ //Player title, if exists
+ if (pl_GM_level > 0) {
+ //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
+ sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
+ strcat(atcmd_output,temp0);
+ }
+ //Players Party if exists
+ if (p != NULL) {
+ //sprintf(temp0," | Party: '%s'", p->name);
+ sprintf(temp0, msg_txt(335), p->party.name);
+ strcat(atcmd_output,temp0);
+ }
+ //Players Guild if exists
+ if (g != NULL) {
+ //sprintf(temp0," | Guild: '%s'", g->name);
+ sprintf(temp0, msg_txt(336), g->name);
+ strcat(atcmd_output,temp0);
+ }
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ clif_displaymessage(fd, msg_txt(28)); // No player found.
+ else if (count == 1)
+ clif_displaymessage(fd, msg_txt(29)); // 1 player found.
+ else {
+ sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_whomap3(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, count, users;
+ int pl_GM_level, GM_level;
+ int map_id;
+ char map_name[MAP_NAME_LENGTH];
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+
+ if (!message || !*message)
+ map_id = sd->bl.m;
+ else {
+ sscanf(message, "%15s", map_name);
+ if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(map_name, ".gat");
+ if ((map_id = map_mapname2mapid(map_name)) < 0)
+ map_id = sd->bl.m;
+ }
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ if (pl_sd->bl.m == map_id) {
+ if (pl_GM_level > 0)
+ sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ else
+ sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
+ else if (count == 1)
+ sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
+ else {
+ sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
+ }
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_whomap2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, count, users;
+ int pl_GM_level, GM_level;
+ int map_id = 0;
+ char map_name[MAP_NAME_LENGTH];
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+
+ if (!message || !*message)
+ map_id = sd->bl.m;
+ else {
+ sscanf(message, "%15s", map_name);
+ if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(map_name, ".gat");
+ if ((map_id = map_mapname2mapid(map_name)) < 0)
+ map_id = sd->bl.m;
+ }
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ if (pl_sd->bl.m == map_id) {
+ if (pl_GM_level > 0)
+ sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ else
+ sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
+ else if (count == 1)
+ sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
+ else {
+ sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
+ }
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_whomap(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char temp0[100];
+ char temp1[100];
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, count, users;
+ int pl_GM_level, GM_level;
+ int map_id = 0;
+ char map_name[MAP_NAME_LENGTH];
+ struct guild *g;
+ struct party_data *p;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(temp0, '\0', sizeof(temp0));
+ malloc_tsetdword(temp1, '\0', sizeof(temp1));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+
+ if (!message || !*message)
+ map_id = sd->bl.m;
+ else {
+ sscanf(message, "%15s", map_name);
+ if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(map_name, ".gat");
+ if ((map_id = map_mapname2mapid(map_name)) < 0)
+ map_id = sd->bl.m;
+ }
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ if (pl_sd->bl.m == map_id) {
+ g = guild_search(pl_sd->status.guild_id);
+ if (g == NULL)
+ sprintf(temp1, "None");
+ else
+ sprintf(temp1, "%s", g->name);
+ p = party_search(pl_sd->status.party_id);
+ if (p == NULL)
+ sprintf(temp0, "None");
+ else
+ sprintf(temp0, "%s", p->party.name);
+ if (pl_GM_level > 0)
+ sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
+ else
+ sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
+ else if (count == 1)
+ sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
+ else {
+ sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
+ }
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_whogm(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char temp0[100];
+ char temp1[100];
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, j, count, users;
+ int pl_GM_level, GM_level;
+ char match_text[100];
+ char player_name[NAME_LENGTH];
+ struct guild *g;
+ struct party_data *p;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(temp0, '\0', sizeof(temp0));
+ malloc_tsetdword(temp1, '\0', sizeof(temp1));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if (sscanf(message, "%99[^\n]", match_text) < 1)
+ strcpy(match_text, "");
+ for (j = 0; match_text[j]; j++)
+ match_text[j] = tolower(match_text[j]);
+
+ count = 0;
+ GM_level = pc_isGM(sd);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ pl_GM_level = pc_isGM(pl_sd);
+ if (pl_GM_level > 0) {
+ if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
+ memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
+ for (j = 0; player_name[j]; j++)
+ player_name[j] = tolower(player_name[j]);
+ if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
+ sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
+ clif_displaymessage(fd, atcmd_output);
+ sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ clif_displaymessage(fd, atcmd_output);
+ g = guild_search(pl_sd->status.guild_id);
+ if (g == NULL)
+ sprintf(temp1, "None");
+ else
+ sprintf(temp1, "%s", g->name);
+ p = party_search(pl_sd->status.party_id);
+ if (p == NULL)
+ sprintf(temp0, "None");
+ else
+ sprintf(temp0, "%s", p->party.name);
+ sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
+ clif_displaymessage(fd, atcmd_output);
+ count++;
+ }
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ clif_displaymessage(fd, msg_txt(150)); // No GM found.
+ else if (count == 1)
+ clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
+ else {
+ sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+int atcommand_whozeny(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, j, count,c, users;
+ char match_text[100];
+ char player_name[NAME_LENGTH];
+ int *zeny;
+ int *counted;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(match_text, '\0', sizeof(match_text));
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if (sscanf(message, "%99[^\n]", match_text) < 1)
+ strcpy(match_text, "");
+ for (j = 0; match_text[j]; j++)
+ match_text[j] = tolower(match_text[j]);
+
+ count = 0;
+ pl_allsd = map_getallusers(&users);
+ if (users < 1)
+ {
+ clif_displaymessage(fd, msg_txt(28)); // No player found.
+ return 0;
+ }
+ zeny = (int *)aMallocA(users*sizeof(int));
+ counted = (int *)aMallocA(users*sizeof(int));
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
+ for (j = 0; player_name[j]; j++)
+ player_name[j] = tolower(player_name[j]);
+ if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
+ zeny[count]=pl_sd->status.zeny;
+ counted[i]=0;
+ count++;
+ }
+ }
+ }
+
+ qsort(zeny, count, sizeof(int), hightolow_compare);
+ for (c = 0; c < count && c < 50; c++) {
+ if(!zeny[c])
+ continue;
+ for (i = 0; i < users; i++) {
+ if(!zeny[c])
+ continue;
+ if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
+ if(pl_sd->status.zeny==zeny[c]) {
+ sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
+ clif_displaymessage(fd, atcmd_output);
+ zeny[c]=0;
+ counted[i]=1;
+ }
+ }
+ }
+ }
+
+ if (count == 0)
+ clif_displaymessage(fd, msg_txt(28)); // No player found.
+ else if (count == 1)
+ clif_displaymessage(fd, msg_txt(29)); // 1 player found.
+ else {
+ sprintf(atcmd_output, msg_txt(30), count); // %d players found.
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ aFree(zeny);
+ aFree(counted);
+
+ return 0;
+}
+
+
+// cause random emote on all online players [Valaris]
+int atcommand_happyhappyjoyjoy(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i,e, users;
+
+ nullpo_retr(-1, sd);
+
+ pl_allsd = map_getallusers(&users);
+
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i])) {
+ e=rand()%40;
+ if(e==34)
+ e = 0;
+ clif_emotion(&pl_sd->bl,e);
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_save(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
+ if (sd->status.pet_id > 0 && sd->pd)
+ intif_save_petdata(sd->status.account_id, &sd->pd->pet);
+
+ chrif_save(sd,0);
+
+ clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_load(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int m;
+
+ nullpo_retr(-1, sd);
+
+ m = map_mapindex2mapid(sd->status.save_point.map);
+ if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(249));
+ 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, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
+ clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_speed(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int speed;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message) {
+ sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ speed = atoi(message);
+ if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
+ sd->base_status.speed = speed;
+ status_calc_bl(&sd->bl, SCB_SPEED);
+ clif_displaymessage(fd, msg_txt(8)); // Speed changed.
+ } else {
+ sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_charspeed(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ int speed;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
+ sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { //GM level check
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+
+ if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
+ pl_sd->base_status.speed = speed;
+ status_calc_bl(&pl_sd->bl, SCB_SPEED);
+ clif_displaymessage(fd, msg_txt(8)); // Speed changed.
+ if(pl_sd->fd)
+ clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
+ } else {
+ sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_storage(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ if (storage_storageopen(sd) == 1)
+ { //Already open.
+ clif_displaymessage(fd, msg_txt(250));
+ return -1;
+ }
+ return 0;
+}
+
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_guildstorage(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct storage *stor; //changes from Freya/Yor
+ nullpo_retr(-1, sd);
+
+ if (sd->status.guild_id > 0) {
+ if (sd->state.storage_flag) {
+ clif_displaymessage(fd, msg_txt(251));
+ return -1;
+ }
+ if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
+ clif_displaymessage(fd, msg_txt(251));
+ return -1;
+ }
+ storage_guild_storageopen(sd);
+ } else {
+ clif_displaymessage(fd, msg_txt(252));
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_option(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int param1 = 0, param2 = 0, param3 = 0;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
+ clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
+ return -1;
+ }
+
+ sd->sc.opt1 = param1;
+ sd->sc.opt2 = param2;
+ if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
+ clif_cartlist(sd);
+ clif_updatestatus(sd, SP_CARTINFO);
+ }
+ pc_setoption(sd, param3);
+
+ clif_displaymessage(fd, msg_txt(9)); // Options changed.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_hide(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (sd->sc.option & OPTION_INVISIBLE) {
+ sd->sc.option &= ~OPTION_INVISIBLE;
+ if (sd->disguise)
+ status_set_viewdata(&sd->bl, sd->disguise);
+ else
+ status_set_viewdata(&sd->bl, sd->status.class_);
+ clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
+ } else {
+ sd->sc.option |= OPTION_INVISIBLE;
+ sd->vd.class_ = INVISIBLE_CLASS;
+ clif_displaymessage(fd, msg_txt(11)); // Invisible: On
+ }
+ clif_changeoption(&sd->bl);
+
+ return 0;
+}
+
+/*==========================================
+ * 転職する upperを指定すると転生や養子にもなれる
+ *------------------------------------------
+ */
+int atcommand_jobchange(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int job = 0, upper = 0;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
+
+ int i, found = 0;
+ const struct { char name[16]; int id; } jobs[] = {
+ { "novice", 0 },
+ { "swordsman", 1 },
+ { "mage", 2 },
+ { "archer", 3 },
+ { "acolyte", 4 },
+ { "merchant", 5 },
+ { "thief", 6 },
+ { "knight", 7 },
+ { "priest", 8 },
+ { "priestess", 8 },
+ { "wizard", 9 },
+ { "blacksmith", 10 },
+ { "hunter", 11 },
+ { "assassin", 12 },
+ { "crusader", 14 },
+ { "monk", 15 },
+ { "sage", 16 },
+ { "rogue", 17 },
+ { "alchemist", 18 },
+ { "bard", 19 },
+ { "dancer", 20 },
+ { "super novice", 23 },
+ { "supernovice", 23 },
+ { "gunslinger", 24 },
+ { "gunner", 24 },
+ { "ninja", 25 },
+ { "high novice", 4001 },
+ { "swordsman high", 4002 },
+ { "mage high", 4003 },
+ { "archer high", 4004 },
+ { "acolyte high", 4005 },
+ { "merchant high", 4006 },
+ { "thief high", 4007 },
+ { "lord knight", 4008 },
+ { "high priest", 4009 },
+ { "high priestess", 4009 },
+ { "high wizard", 4010 },
+ { "whitesmith", 4011 },
+ { "sniper", 4012 },
+ { "assassin cross", 4013 },
+ { "paladin", 4015 },
+ { "champion", 4016 },
+ { "professor", 4017 },
+ { "stalker", 4018 },
+ { "creator", 4019 },
+ { "clown", 4020 },
+ { "gypsy", 4021 },
+ { "baby novice", 4023 },
+ { "baby swordsman", 4024 },
+ { "baby mage", 4025 },
+ { "baby archer", 4026 },
+ { "baby acolyte", 4027 },
+ { "baby merchant", 4028 },
+ { "baby thief", 4029 },
+ { "baby knight", 4030 },
+ { "baby priest", 4031 },
+ { "baby priestess", 4031 },
+ { "baby wizard", 4032 },
+ { "baby blacksmith",4033 },
+ { "baby hunter", 4034 },
+ { "baby assassin", 4035 },
+ { "baby crusader", 4037 },
+ { "baby monk", 4038 },
+ { "baby sage", 4039 },
+ { "baby rogue", 4040 },
+ { "baby alchemist", 4041 },
+ { "baby bard", 4042 },
+ { "baby dancer", 4043 },
+ { "super baby", 4045 },
+ { "taekwon", 4046 },
+ { "taekwon boy", 4046 },
+ { "taekwon girl", 4046 },
+ { "star gladiator", 4047 },
+ { "soul linker", 4049 },
+ };
+
+ for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
+ if (strncmpi(message, jobs[i].name, 16) == 0) {
+ job = jobs[i].id;
+ upper = 0;
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
+ return -1;
+ }
+ }
+
+ if (job == 37 ||job == 45)
+ return 0;
+
+ if ((job >= 0 && job < MAX_PC_CLASS))
+ {
+ int j;
+
+ for (j=0; j < MAX_INVENTORY; j++) {
+ if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
+ pc_unequipitem(sd, j, 3);
+ }
+ if (pc_jobchange(sd, job, upper) == 0)
+ clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
+ else {
+ clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_die(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ clif_specialeffect(&sd->bl,450,SELF);
+ status_kill(&sd->bl);
+ clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_kill(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != 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;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_alive(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (!status_revive(&sd->bl, 100, 100))
+ return -1;
+ clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
+ return 0;
+}
+
+/*==========================================
+ * +kamic [LuzZza]
+ *------------------------------------------
+ */
+int atcommand_kami(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+
+ unsigned long color=0;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if(*(command + 5) != 'c' && *(command + 5) != 'C') {
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
+ return -1;
+ }
+
+ sscanf(message, "%199[^\n]", atcmd_output);
+ intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
+
+ } else {
+
+ if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
+ clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
+ return -1;
+ }
+
+ if(color > 0xFFFFFF) {
+ clif_displaymessage(fd, "Invalid color.");
+ return -1;
+ }
+
+ intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
+ }
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_heal(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int hp = 0, sp = 0; // [Valaris] thanks to fov
+ nullpo_retr(-1, sd);
+
+ sscanf(message, "%d %d", &hp, &sp);
+
+ if (hp == 0 && sp == 0) {
+ if (!status_percent_heal(&sd->bl, 100, 100))
+ clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
+ else
+ clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
+ return 0;
+ }
+
+ if(hp > 0 && sp >= 0) {
+ if(!status_heal(&sd->bl, hp, sp, 0))
+ clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
+ else
+ clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
+ return 0;
+ }
+
+ if(hp < 0 && sp <= 0) {
+ status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
+ clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
+ clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
+ return 0;
+ }
+
+ //Opposing signs.
+ if (hp) {
+ if (hp > 0)
+ status_heal(&sd->bl, hp, 0, 0);
+ else {
+ status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
+ clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
+ }
+ }
+
+ if (sp) {
+ if (sp > 0)
+ status_heal(&sd->bl, 0, sp, 0);
+ else
+ status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
+ }
+
+ clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
+ return 0;
+}
+
+/*==========================================
+ * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
+ *------------------------------------------
+ */
+int atcommand_item(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char item_name[100];
+ int number = 0, item_id, flag;
+ struct item item_tmp;
+ struct item_data *item_data;
+ int get_count, i;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+
+ if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
+ clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
+ return -1;
+ }
+
+ if (number <= 0)
+ number = 1;
+
+ if ((item_data = itemdb_searchname(item_name)) == NULL &&
+ (item_data = itemdb_exists(atoi(item_name))) == NULL)
+ {
+ clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
+ return -1;
+ }
+
+ item_id = item_data->nameid;
+ get_count = number;
+ //Check if it's stackable.
+ if (!itemdb_isstackable2(item_data))
+ get_count = 1;
+
+ for (i = 0; i < number; i += get_count) {
+ // if not pet egg
+ if (!pet_create_egg(sd, item_id)) {
+ malloc_set(&item_tmp, 0, sizeof(item_tmp));
+ item_tmp.nameid = item_id;
+ item_tmp.identify = 1;
+
+ if ((flag = pc_additem(sd, &item_tmp, get_count)))
+ clif_additem(sd, 0, 0, flag);
+ }
+ }
+
+ //Logs (A)dmins items [Lupus]
+ if(log_config.enable_logs&0x400)
+ log_pick_pc(sd, "A", item_id, number, NULL);
+
+ clif_displaymessage(fd, msg_txt(18)); // Item created.
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_item2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct item item_tmp;
+ struct item_data *item_data;
+ char item_name[100];
+ int item_id, number = 0;
+ int identify = 0, refine = 0, attr = 0;
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ int flag;
+ int loop, get_count, i;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+
+ if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
+ clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
+ clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
+ return -1;
+ }
+
+ if (number <= 0)
+ number = 1;
+
+ item_id = 0;
+ if ((item_data = itemdb_searchname(item_name)) != NULL ||
+ (item_data = itemdb_exists(atoi(item_name))) != NULL)
+ item_id = item_data->nameid;
+
+ if (item_id > 500) {
+ loop = 1;
+ get_count = number;
+ if (item_data->type == 4 || item_data->type == 5 ||
+ item_data->type == 7 || item_data->type == 8) {
+ loop = number;
+ get_count = 1;
+ if (item_data->type == 7) {
+ identify = 1;
+ refine = 0;
+ }
+ if (item_data->type == 8)
+ refine = 0;
+ if (refine > 10)
+ refine = 10;
+ } else {
+ identify = 1;
+ refine = attr = 0;
+ }
+ for (i = 0; i < loop; i++) {
+ malloc_set(&item_tmp, 0, sizeof(item_tmp));
+ item_tmp.nameid = item_id;
+ item_tmp.identify = identify;
+ item_tmp.refine = refine;
+ item_tmp.attribute = attr;
+ item_tmp.card[0] = c1;
+ item_tmp.card[1] = c2;
+ item_tmp.card[2] = c3;
+ item_tmp.card[3] = c4;
+ if ((flag = pc_additem(sd, &item_tmp, get_count)))
+ clif_additem(sd, 0, 0, flag);
+ }
+
+ //Logs (A)dmins items [Lupus]
+ if(log_config.enable_logs&0x400)
+ log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
+
+ clif_displaymessage(fd, msg_txt(18)); // Item created.
+ } else {
+ clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_itemreset(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ nullpo_retr(-1, sd);
+
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
+
+ //Logs (A)dmins items [Lupus]
+ if(log_config.enable_logs&0x400)
+ log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
+
+ pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
+ }
+ }
+ clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
+
+ return 0;
+}
+
+/*==========================================
+ * Atcommand @lvlup
+ *------------------------------------------
+ */
+int atcommand_baselevelup(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int level=0, i=0, status_point=0;
+ nullpo_retr(-1, sd);
+ level = atoi(message);
+
+ if (!message || !*message || !level) {
+ clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
+ return -1;
+ }
+
+ if (level > 0) {
+ if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
+ clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
+ return -1;
+ } /* End Addition */
+ if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
+ level = pc_maxbaselv(sd) - sd->status.base_level;
+ for (i = 1; i <= level; i++)
+ status_point += (sd->status.base_level + i + 14) / 5;
+
+ if (sd->status.status_point > USHRT_MAX - status_point)
+ sd->status.status_point = USHRT_MAX;
+ else
+ sd->status.status_point += status_point;
+ sd->status.base_level += (unsigned int)level;
+ clif_updatestatus(sd, SP_BASELEVEL);
+ clif_updatestatus(sd, SP_NEXTBASEEXP);
+ clif_updatestatus(sd, SP_STATUSPOINT);
+ status_calc_pc(sd, 0);
+ status_percent_heal(&sd->bl, 100, 100);
+ clif_misceffect(&sd->bl, 0);
+ clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
+ } else {
+ if (sd->status.base_level == 1) {
+ clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
+ return -1;
+ }
+ level*=-1;
+ if ((unsigned int)level >= sd->status.base_level)
+ level = sd->status.base_level-1;
+ if (sd->status.status_point > 0) {
+ for (i = 0; i > -level; i--)
+ status_point += (sd->status.base_level + i + 14) / 5;
+ if (sd->status.status_point < status_point)
+ pc_resetstate(sd);
+ if (sd->status.status_point < status_point)
+ sd->status.status_point = 0;
+ else
+ sd->status.status_point -= status_point;
+ clif_updatestatus(sd, SP_STATUSPOINT);
+ } /* to add: remove status points from stats */
+ sd->status.base_level -= (unsigned int)level;
+ clif_updatestatus(sd, SP_BASELEVEL);
+ clif_updatestatus(sd, SP_NEXTBASEEXP);
+ status_calc_pc(sd, 0);
+ clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_joblevelup(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int level=0;
+ nullpo_retr(-1, sd);
+
+ level = atoi(message);
+
+ if (!message || !*message || !level) {
+ clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
+ return -1;
+ }
+ if (level > 0) {
+ if (sd->status.job_level == pc_maxjoblv(sd)) {
+ clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
+ return -1;
+ }
+ if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
+ level = pc_maxjoblv(sd) - sd->status.job_level;
+ sd->status.job_level += (unsigned int)level;
+ clif_updatestatus(sd, SP_JOBLEVEL);
+ clif_updatestatus(sd, SP_NEXTJOBEXP);
+ if (sd->status.skill_point > USHRT_MAX - level)
+ sd->status.skill_point = USHRT_MAX;
+ else
+ sd->status.skill_point += level;
+ clif_updatestatus(sd, SP_SKILLPOINT);
+ status_calc_pc(sd, 0);
+ clif_misceffect(&sd->bl, 1);
+ clif_displaymessage(fd, msg_txt(24)); // Job level raised.
+ } else {
+ if (sd->status.job_level == 1) {
+ clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
+ return -1;
+ }
+ level *=-1;
+ if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
+ level = sd->status.job_level-1;
+ sd->status.job_level -= (unsigned int)level;
+ clif_updatestatus(sd, SP_JOBLEVEL);
+ clif_updatestatus(sd, SP_NEXTJOBEXP);
+ if (sd->status.skill_point < level)
+ pc_resetskill(sd,0); //Reset skills since we need to substract more points.
+ if (sd->status.skill_point < level)
+ sd->status.skill_point = 0;
+ else
+ sd->status.skill_point -= level;
+ clif_updatestatus(sd, SP_SKILLPOINT);
+ status_calc_pc(sd, 0);
+ clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @help
+ *------------------------------------------
+ */
+int atcommand_help(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char buf[2048], w1[2048], w2[2048];
+ int i, gm_level;
+ FILE* fp;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(buf, '\0', sizeof(buf));
+
+ if ((fp = fopen(help_txt, "r")) != NULL) {
+ clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
+ gm_level = pc_isGM(sd);
+ while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
+ if (buf[0] == '/' && buf[1] == '/')
+ continue;
+ for (i = 0; buf[i] != '\0'; i++) {
+ if (buf[i] == '\r' || buf[i] == '\n') {
+ buf[i] = '\0';
+ break;
+ }
+ }
+ if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
+ clif_displaymessage(fd, buf);
+ else if (gm_level >= atoi(w1))
+ clif_displaymessage(fd, w2);
+ }
+ fclose(fp);
+ } else {
+ clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @help2 - Char commands [Kayla]
+ *------------------------------------------
+ */
+int atcommand_help2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char buf[2048], w1[2048], w2[2048];
+ int i, gm_level;
+ FILE* fp;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(buf, '\0', sizeof(buf));
+
+ if ((fp = fopen(help2_txt, "r")) != NULL) {
+ clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
+ gm_level = pc_isGM(sd);
+ while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
+ if (buf[0] == '/' && buf[1] == '/')
+ continue;
+ for (i = 0; buf[i] != '\0'; i++) {
+ if (buf[i] == '\r' || buf[i] == '\n') {
+ buf[i] = '\0';
+ break;
+ }
+ }
+ if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
+ clif_displaymessage(fd, buf);
+ else if (gm_level >= atoi(w1))
+ clif_displaymessage(fd, w2);
+ }
+ fclose(fp);
+ } else {
+ clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/*==========================================
+ * @gm
+ *------------------------------------------
+ */
+int atcommand_gm(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char password[100];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(password, '\0', sizeof(password));
+
+ if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
+ clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
+ return -1;
+ }
+
+ if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
+ clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
+ return -1;
+ } else
+ chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_pvpoff(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+
+ if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
+ clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
+ return -1;
+ }
+
+ if (map[sd->bl.m].flag.pvp) {
+ map[sd->bl.m].flag.pvp = 0;
+ clif_send0199(sd->bl.m, 0);
+
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) { //人数分ループ
+ if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
+ clif_pvpset(pl_sd, 0, 0, 2);
+ if (pl_sd->pvp_timer != -1) {
+ delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
+ pl_sd->pvp_timer = -1;
+ }
+ }
+ }
+ clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
+ } else {
+ clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_pvpon(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+
+ if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
+ clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
+ return -1;
+ }
+
+ if (!map[sd->bl.m].flag.pvp) {
+ map[sd->bl.m].flag.pvp = 1;
+ clif_send0199(sd->bl.m, 1);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
+ pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
+ pl_sd->pvp_rank = 0;
+ pl_sd->pvp_lastusers = 0;
+ pl_sd->pvp_point = 5;
+ pl_sd->pvp_won = 0;
+ pl_sd->pvp_lost = 0;
+ }
+ }
+ clif_displaymessage(fd, msg_txt(32)); // PvP: On.
+ } else {
+ clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_gvgoff(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.gvg) {
+ map[sd->bl.m].flag.gvg = 0;
+ clif_send0199(sd->bl.m, 0);
+ clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
+ } else {
+ clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_gvgon(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (!map[sd->bl.m].flag.gvg) {
+ map[sd->bl.m].flag.gvg = 1;
+ clif_send0199(sd->bl.m, 3);
+ clif_displaymessage(fd, msg_txt(34)); // GvG: On.
+ } else {
+ clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_model(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int hair_style = 0, hair_color = 0, cloth_color = 0;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
+ sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
+ MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
+ hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
+ cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
+ /* Removed because this check is TOO strange. [Skotlex]
+ //秒フ色変更
+ if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
+ //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
+ //秒フ色未実装職の判定
+ clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
+ return -1;
+ } else {
+ */
+ pc_changelook(sd, LOOK_HAIR, hair_style);
+ pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
+ pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
+ clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
+// }
+ } else {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @dye && @ccolor
+ *------------------------------------------
+ */
+int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
+{
+ int cloth_color = 0;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
+ sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
+ pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
+ clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
+ } else {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @hairstyle && @hstyle
+ *------------------------------------------
+ */
+int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
+{
+ int hair_style = 0;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
+ sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
+ /* Removed because this check is TOO strange. [Skotlex]
+ if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
+ clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
+ return -1;
+ } else {
+ */
+ pc_changelook(sd, LOOK_HAIR, hair_style);
+ clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
+// }
+ } else {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @charhairstyle by [MouseJstr]
+ *------------------------------------------
+ */
+int
+atcommand_charhairstyle(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ return 0;
+}
+
+/*==========================================
+ * @haircolor && @hcolor
+ *------------------------------------------
+ */
+int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
+{
+ int hair_color = 0;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
+ sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
+ /* Removed for being such a strange check. [Skotlex]
+ if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
+ clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
+ return -1;
+ } else {
+ */
+ pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
+ clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
+// }
+ } else {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @go [city_number or city_name] - Updated by Harbin
+ *------------------------------------------
+ */
+int atcommand_go(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ int town;
+ char map_name[MAP_NAME_LENGTH];
+ int m;
+
+ const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
+ { MAP_PRONTERA, 156, 191 }, // 0=Prontera
+ { MAP_MORROC, 156, 93 }, // 1=Morroc
+ { MAP_GEFFEN, 119, 59 }, // 2=Geffen
+ { MAP_PAYON, 162, 233 }, // 3=Payon
+ { MAP_ALBERTA, 192, 147 }, // 4=Alberta
+ { MAP_IZLUDE, 128, 114 }, // 5=Izlude
+ { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
+ { MAP_LUTIE, 147, 134 }, // 7=Lutie
+ { MAP_COMODO, 209, 143 }, // 8=Comodo
+ { MAP_YUNO, 157, 51 }, // 9=Yuno
+ { MAP_AMATSU, 198, 84 }, // 10=Amatsu
+ { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
+ { MAP_UMBALA, 89, 157 }, // 12=Umbala
+ { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
+ { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
+ { "new_zone01.gat", 53, 111 }, // 15=Training Grounds
+ { MAP_JAIL, 23, 61 }, // 16=Prison
+ { MAP_JAWAII, 249, 127 }, // 17=Jawaii
+ { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
+ { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
+ { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
+ { MAP_EINBECH, 70, 95 }, // 21=Einbech
+ { MAP_HUGEL, 96, 145 }, // 22=Hugel
+ };
+
+ nullpo_retr(-1, sd);
+
+ if(map[sd->bl.m].flag.nogo) {
+ clif_displaymessage(sd->fd,"You can not use @go on this map.");
+ return 0;
+ }
+
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ // get the number
+ town = atoi(message);
+
+ // if no value, display all value
+ if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
+ clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
+ clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
+ clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
+ clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
+ clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
+ clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
+ clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
+ clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
+ clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
+ clif_displaymessage(fd, " 21=Einbech 22=Hugel");
+ return -1;
+ } else {
+ // get possible name of the city and add .gat if not in the name
+ map_name[MAP_NAME_LENGTH-1] = '\0';
+ for (i = 0; map_name[i]; i++)
+ map_name[i] = tolower(map_name[i]);
+ if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(map_name, ".gat");
+ // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
+ if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
+ town = 0;
+ } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
+ town = 1;
+ } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
+ town = 2;
+ } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
+ town = 3;
+ } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
+ town = 4;
+ } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
+ town = 5;
+ } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
+ strcmp(map_name, "al.gat") == 0) { // al (de baran)
+ town = 6;
+ } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
+ strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
+ strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
+ town = 7;
+ } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
+ town = 8;
+ } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
+ town = 9;
+ } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
+ town = 10;
+ } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
+ town = 11;
+ } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
+ town = 12;
+ } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
+ town = 13;
+ } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
+ town = 14;
+ } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
+ strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
+ strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
+ town = 15;
+ } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
+ strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
+ town = 16;
+ } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
+ town = 17;
+ } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
+ strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
+ town = 18;
+ } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
+ town = 19;
+ } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
+ strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
+ town = 20;
+ } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
+ town = 21;
+ } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
+ town = 22;
+ }
+
+ if (town >= -3 && town <= -1) {
+ if (sd->status.memo_point[-town-1].map) {
+ m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
+ if (m >= 0 && map[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;
+ }
+ if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
+ clif_displaymessage(fd, msg_txt(0)); // Warped.
+ } else {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+ } else {
+ sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+ } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
+ m = map_mapname2mapid((char *)data[town].map);
+ if (m >= 0 && map[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;
+ }
+ if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
+ clif_displaymessage(fd, msg_txt(0)); // Warped.
+ } else {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+ } else { // if you arrive here, you have an error in town variable when reading of names
+ clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_monster(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char name[NAME_LENGTH];
+ char monster[NAME_LENGTH];
+ int mob_id;
+ int number = 0;
+ int count;
+ int i, k, range;
+ short mx, my;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(name, '\0', sizeof(name));
+ malloc_tsetdword(monster, '\0', sizeof(monster));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
+ return -1;
+ }
+ if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
+ sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
+ //All data can be left as it is.
+ } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
+ //Here, it is possible name was not given and we are using monster for it.
+ if (count < 3) //Blank mob's name.
+ name[0] = '\0';
+ } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
+ //All data can be left as it is.
+ } else if (sscanf(message, "%23s", monster) > 0) {
+ //As before, name may be already filled.
+ name[0] = '\0';
+ } else {
+ clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
+ return -1;
+ }
+
+ if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
+ mob_id = mobdb_checkid(atoi(monster));
+
+ if (mob_id == 0) {
+ clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
+ return -1;
+ }
+
+ if (mob_id == MOBID_EMPERIUM) {
+ clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
+ return -1;
+ }
+
+ if (number <= 0)
+ number = 1;
+
+ if (strlen(name) < 1)
+ strcpy(name, "--ja--");
+
+ // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
+ if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
+ number = battle_config.atc_spawn_quantity_limit;
+
+ if (battle_config.etc_log)
+ ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
+
+ count = 0;
+ range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
+ for (i = 0; i < number; i++) {
+ map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
+ k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
+ count += (k != 0) ? 1 : 0;
+ }
+
+ if (count != 0)
+ if (number == count)
+ clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
+ else {
+ sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
+ clif_displaymessage(fd, atcmd_output);
+ }
+ else {
+ clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
+ return -1;
+ }
+
+ return 0;
+}
+
+// small monster spawning [Valaris]
+int atcommand_monstersmall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message) {
+ char name[NAME_LENGTH] = "";
+ char monster[NAME_LENGTH] = "";
+ int mob_id = 0;
+ int number = 0;
+ int x = 0;
+ int y = 0;
+ int count;
+ int i;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Give a monster name/id please.");
+ return -1;
+ }
+
+ if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
+ sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
+ sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
+ clif_displaymessage(fd, "Give a monster name/id please.");
+ return -1;
+ }
+
+ // If monster identifier/name argument is a name
+ if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
+ mob_id = atoi(monster);
+
+ if (mob_id == 0) {
+ clif_displaymessage(fd, msg_txt(40));
+ return -1;
+ }
+
+ if (mob_id == MOBID_EMPERIUM) {
+ clif_displaymessage(fd, msg_txt(83));
+ return -1;
+ }
+
+ if (mobdb_checkid(mob_id) == 0) {
+ clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
+ return -1;
+ }
+
+ if (number <= 0)
+ number = 1;
+
+ if (strlen(name) < 1)
+ strcpy(name, "--ja--");
+
+ // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
+ if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
+ number = battle_config.atc_spawn_quantity_limit;
+
+ count = 0;
+ for (i = 0; i < number; i++) {
+ int mx, my;
+ if (x <= 0)
+ mx = sd->bl.x + (rand() % 11 - 5);
+ else
+ mx = x;
+ if (y <= 0)
+ my = sd->bl.y + (rand() % 11 - 5);
+ else
+ my = y;
+ count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
+ }
+
+ if (count != 0)
+ clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
+ else
+ clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
+
+ return 0;
+}
+// big monster spawning [Valaris]
+int atcommand_monsterbig(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message) {
+ char name[NAME_LENGTH] = "";
+ char monster[NAME_LENGTH] = "";
+ int mob_id = 0;
+ int number = 0;
+ int x = 0;
+ int y = 0;
+ int count;
+ int i;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Give a monster name/id please.");
+ return -1;
+ }
+
+ if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
+ sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
+ sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
+ clif_displaymessage(fd, "Give a monster name/id please.");
+ return -1;
+ }
+
+ // If monster identifier/name argument is a name
+ if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
+ mob_id = atoi(monster);
+
+ if (mob_id == 0) {
+ clif_displaymessage(fd, msg_txt(40));
+ return -1;
+ }
+
+ if (mob_id == MOBID_EMPERIUM) {
+ clif_displaymessage(fd, msg_txt(83));
+ return -1;
+ }
+
+ if (mobdb_checkid(mob_id) == 0) {
+ clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
+ return -1;
+ }
+
+ if (number <= 0)
+ number = 1;
+
+ if (strlen(name) < 1)
+ strcpy(name, "--ja--");
+
+ // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
+ if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
+ number = battle_config.atc_spawn_quantity_limit;
+
+ count = 0;
+ for (i = 0; i < number; i++) {
+ int mx, my;
+ if (x <= 0)
+ mx = sd->bl.x + (rand() % 11 - 5);
+ else
+ mx = x;
+ if (y <= 0)
+ my = sd->bl.y + (rand() % 11 - 5);
+ else
+ my = y;
+ count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
+ }
+
+ if (count != 0)
+ clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
+ else
+ clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static int atkillmonster_sub(struct block_list *bl, va_list ap) {
+ struct mob_data *md;
+ int flag;
+
+ nullpo_retr(0, ap);
+ nullpo_retr(0, md=(struct mob_data *)bl);
+ flag = va_arg(ap, int);
+
+ if (md->guardian_data)
+ return 0; //Do not touch WoE mobs!
+
+ if (flag)
+ status_zap(bl,md->status.hp, 0);
+ else
+ status_kill(bl);
+ return 1;
+}
+void atcommand_killmonster_sub(
+ const int fd, struct map_session_data* sd, const char* message,
+ const int drop)
+{
+ int map_id;
+ char map_name[MAP_NAME_LENGTH];
+
+ if (!sd) return;
+
+ malloc_tsetdword(map_name, '\0', sizeof(map_name));
+
+ if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
+ map_id = sd->bl.m;
+ else {
+ if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(map_name, ".gat");
+ if ((map_id = map_mapname2mapid(map_name)) < 0)
+ map_id = sd->bl.m;
+ }
+
+ map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
+
+ clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
+
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_killmonster(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if (!sd) return 0;
+ atcommand_killmonster_sub(fd, sd, message, 1);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_killmonster2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if (!sd) return 0;
+ atcommand_killmonster_sub(fd, sd, message, 0);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_refine(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i,j, position = 0, refine = 0, current_position, final_refine;
+ int count;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
+ clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
+ return -1;
+ }
+
+ if (refine < -MAX_REFINE)
+ refine = -MAX_REFINE;
+ else if (refine > MAX_REFINE)
+ refine = MAX_REFINE;
+ else if (refine == 0)
+ refine = 1;
+
+ count = 0;
+ for (j = 0; j < EQI_MAX-1; j++) {
+ if ((i = sd->equip_index[j]) < 0)
+ continue;
+ if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
+ continue;
+ if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
+ continue;
+ if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
+ continue;
+
+ if(position && !(sd->status.inventory[i].equip & position))
+ continue;
+
+ final_refine = sd->status.inventory[i].refine + refine;
+ if (final_refine > MAX_REFINE)
+ final_refine = MAX_REFINE;
+ else if (final_refine < 0)
+ final_refine = 0;
+ if (sd->status.inventory[i].refine != final_refine) {
+ sd->status.inventory[i].refine = final_refine;
+ current_position = sd->status.inventory[i].equip;
+ pc_unequipitem(sd, i, 3);
+ clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
+ clif_delitem(sd, i, 1);
+ clif_additem(sd, i, 1, 0);
+ pc_equipitem(sd, i, current_position);
+ clif_misceffect(&sd->bl, 3);
+ count++;
+ }
+ }
+
+ if (count == 0)
+ clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
+ else if (count == 1)
+ clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
+ else {
+ sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_produce(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char item_name[100];
+ int item_id, attribute = 0, star = 0;
+ int flag = 0;
+ struct item_data *item_data;
+ struct item tmp_item;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+
+ if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
+ clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
+ return -1;
+ }
+
+ item_id = 0;
+ if ((item_data = itemdb_searchname(item_name)) == NULL &&
+ (item_data = itemdb_exists(atoi(item_name))) == NULL)
+ {
+ sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+ item_id = item_data->nameid;
+ if (itemdb_isequip2(item_data)) {
+ if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
+ attribute = ATTRIBUTE_NORMAL;
+ if (star < MIN_STAR || star > MAX_STAR)
+ star = 0;
+ malloc_set(&tmp_item, 0, sizeof tmp_item);
+ tmp_item.nameid = item_id;
+ tmp_item.amount = 1;
+ tmp_item.identify = 1;
+ tmp_item.card[0] = CARD0_FORGE;
+ tmp_item.card[1] = item_data->type==IT_WEAPON?
+ ((star*5) << 8) + attribute:0;
+ tmp_item.card[2] = GetWord(sd->status.char_id, 0);
+ tmp_item.card[3] = GetWord(sd->status.char_id, 1);
+ clif_produceeffect(sd, 0, item_id);
+ clif_misceffect(&sd->bl, 3);
+
+ //Logs (A)dmins items [Lupus]
+ if(log_config.enable_logs&0x400)
+ log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
+
+ if ((flag = pc_additem(sd, &tmp_item, 1)))
+ clif_additem(sd, 0, 0, flag);
+ } else {
+ sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Sub-function to display actual memo points
+ *------------------------------------------
+ */
+void atcommand_memo_sub(struct map_session_data* sd) {
+ int i;
+
+ if (!sd) return;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
+ for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
+ if (sd->status.memo_point[i].map)
+ sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
+ else
+ sprintf(atcmd_output, msg_txt(171), i); // %d - void
+ clif_displaymessage(sd->fd, atcmd_output);
+ }
+
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_memo(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int position = 0;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d", &position) < 1)
+ atcommand_memo_sub(sd);
+ else {
+ if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
+ if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(253));
+ return -1;
+ }
+ if (sd->status.memo_point[position].map) {
+ sprintf(atcmd_output, msg_txt(172), position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
+ clif_displaymessage(fd, atcmd_output);
+ }
+ sd->status.memo_point[position].map = map[sd->bl.m].index;
+ sd->status.memo_point[position].x = sd->bl.x;
+ sd->status.memo_point[position].y = sd->bl.y;
+ clif_skill_memo(sd, 0);
+ if (pc_checkskill(sd, AL_WARP) <= (position + 1))
+ clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
+ atcommand_memo_sub(sd);
+ } else {
+ sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
+ clif_displaymessage(fd, atcmd_output);
+ atcommand_memo_sub(sd);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_gat(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int y;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ for (y = 2; y >= -2; y--) {
+ sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
+ map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
+ map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
+ map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
+
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_packet(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ static int packet_mode = 0;
+ int i, x = 0, y = 0;
+ nullpo_retr(-1, sd);
+
+ if (strstr(command, "packetmode")) {
+ packet_mode = atoi(message);
+ clif_displaymessage(fd, "Packet mode changed.");
+ return 0;
+ }
+
+ if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
+ clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
+ return -1;
+ }
+ if (i == 1) y = 1;
+
+ switch (packet_mode)
+ {
+ case 0:
+ clif_status_change(&sd->bl, x, y);
+ break;
+ case 1:
+ sd->status.skill[sd->cloneskill_id].id=0;
+ sd->status.skill[sd->cloneskill_id].lv=0;
+ sd->status.skill[sd->cloneskill_id].flag=0;
+ sd->cloneskill_id = x;
+ sd->status.skill[x].id = x;
+ sd->status.skill[x].lv = skill_get_max(x);
+ sd->status.skill[x].flag = 13;//cloneskill flag
+ clif_skillinfoblock(sd);
+ break;
+ case 2:
+ clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
+ case 3:
+ clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
+ default:
+ break;
+ //added later
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @waterlevel [Skotlex]
+ *------------------------------------------
+ */
+
+int atcommand_waterlevel(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int newlevel;
+ if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
+ sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+
+ if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
+ if (newlevel > 0)
+ sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
+ else
+ sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ return 0;
+}
+
+/*==========================================
+ * @stpoint (Rewritten by [Yor])
+ *------------------------------------------
+ */
+int atcommand_statuspoint(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int point, new_status_point;
+
+ if (!message || !*message || (point = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
+ return -1;
+ }
+
+ if (point > 0 && sd->status.status_point > USHRT_MAX - point)
+ new_status_point = USHRT_MAX;
+ else
+ if (point < 0 && sd->status.status_point < -point)
+ new_status_point = 0;
+ else
+ new_status_point = sd->status.status_point + point;
+ if (new_status_point != (int)sd->status.status_point) {
+ sd->status.status_point = (unsigned short)new_status_point;
+ clif_updatestatus(sd, SP_STATUSPOINT);
+ clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
+ } else {
+ if (point < 0)
+ clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
+ else
+ clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @skpoint (Rewritten by [Yor])
+ *------------------------------------------
+ */
+int atcommand_skillpoint(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int point, new_skill_point;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (point = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
+ return -1;
+ }
+
+ if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
+ new_skill_point = USHRT_MAX;
+ else if (point < 0 && sd->status.skill_point < -point)
+ new_skill_point = 0;
+ else
+ new_skill_point = sd->status.skill_point + point;
+
+ if (new_skill_point != (int)sd->status.skill_point) {
+ sd->status.skill_point = (unsigned short)new_skill_point;
+ clif_updatestatus(sd, SP_SKILLPOINT);
+ clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
+ } else {
+ if (point < 0)
+ clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
+ else
+ clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @zeny (Rewritten by [Yor])
+ *------------------------------------------
+ */
+int atcommand_zeny(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int zeny, new_zeny;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (zeny = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
+ return -1;
+ }
+
+ new_zeny = sd->status.zeny + zeny;
+ if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
+ new_zeny = MAX_ZENY;
+ else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
+ new_zeny = 0;
+
+ if (new_zeny != sd->status.zeny) {
+ sd->status.zeny = new_zeny;
+ clif_updatestatus(sd, SP_ZENY);
+ clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
+ } else {
+ if (zeny < 0)
+ clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
+ else
+ clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_param(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int index, value = 0, new_value, max;
+ const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
+ short* status[6];
+ //we don't use direct initialization because it isn't part of the c standard.
+ nullpo_retr(-1, sd);
+
+ status[0] = &sd->status.str;
+ status[1] = &sd->status.agi;
+ status[2] = &sd->status.vit;
+ status[3] = &sd->status.int_;
+ status[4] = &sd->status.dex;
+ status[5] = &sd->status.luk;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
+ sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ index = -1;
+ for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
+ if (strcmpi(command, param[index]) == 0)
+ break;
+ }
+ if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
+ // normaly impossible...
+ sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ }
+
+ max = pc_maxparameter(sd);
+ if (value > 0 && *status[index] > max - value)
+ new_value = max;
+ else if (value < 0 && *status[index] <= -value)
+ new_value = 1;
+ else
+ new_value = *status[index] + value;
+
+ if (new_value != (int)*status[index]) {
+ *status[index] = new_value;
+ clif_updatestatus(sd, SP_STR + index);
+ clif_updatestatus(sd, SP_USTR + index);
+ status_calc_pc(sd, 0);
+ clif_displaymessage(fd, msg_txt(42)); // Stat changed.
+ } else {
+ if (value < 0)
+ clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
+ else
+ clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+//** Stat all by fritz (rewritten by [Yor])
+int atcommand_stat_all(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int index, count, value = 0, max, new_value;
+ short* status[6];
+ //we don't use direct initialization because it isn't part of the c standard.
+ nullpo_retr(-1, sd);
+
+ status[0] = &sd->status.str;
+ status[1] = &sd->status.agi;
+ status[2] = &sd->status.vit;
+ status[3] = &sd->status.int_;
+ status[4] = &sd->status.dex;
+ status[5] = &sd->status.luk;
+
+ if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
+ value = pc_maxparameter(sd);
+
+ count = 0;
+ max = pc_maxparameter(sd);
+ for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
+
+ if (value > 0 && *status[index] > max - value)
+ new_value = max;
+ else if (value < 0 && *status[index] <= -value)
+ new_value = 1;
+ else
+ new_value = *status[index] +value;
+
+ if (new_value != (int)*status[index]) {
+ *status[index] = new_value;
+ clif_updatestatus(sd, SP_STR + index);
+ clif_updatestatus(sd, SP_USTR + index);
+ status_calc_pc(sd, 0);
+ count++;
+ }
+ }
+
+ if (count > 0) // if at least 1 stat modified
+ clif_displaymessage(fd, msg_txt(84)); // All stats changed!
+ else {
+ if (value < 0)
+ clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
+ else
+ clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_guildlevelup(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int level = 0;
+ short added_level;
+ struct guild *guild_info;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
+ clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
+ return -1;
+ }
+
+ if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
+ clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
+ return -1;
+ }
+ if (strcmp(sd->status.name, guild_info->master) != 0) {
+ clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
+ return -1;
+ }
+
+ added_level = (short)level;
+ if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
+ added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
+ else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
+ added_level = 1 - guild_info->guild_lv;
+
+ if (added_level != 0) {
+ intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
+ clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
+ } else {
+ clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_makeegg(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct item_data *item_data;
+ int id, pet_id;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
+ return -1;
+ }
+
+ if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
+ id = item_data->nameid;
+ else if ((id = mobdb_searchname(message)) == 0) // for monster name
+ id = atoi(message);
+
+ pet_id = search_petDB_index(id, PET_CLASS);
+ if (pet_id < 0)
+ pet_id = search_petDB_index(id, PET_EGG);
+ if (pet_id >= 0) {
+ sd->catch_target_class = pet_db[pet_id].class_;
+ intif_create_pet(
+ sd->status.account_id, sd->status.char_id,
+ (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
+ (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
+ 100, 0, 1, pet_db[pet_id].jname);
+ } else {
+ clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_hatch(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (sd->status.pet_id <= 0)
+ clif_sendegg(sd);
+ else {
+ clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_petfriendly(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int friendly;
+ struct pet_data *pd;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (friendly = atoi(message)) < 0) {
+ clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
+ return -1;
+ }
+
+ pd = sd->pd;
+ if (!pd) {
+ clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
+ return -1;
+ }
+
+ if (friendly < 0 || friendly > 1000)
+ {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+
+ if (friendly == pd->pet.intimate) {
+ clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
+ return -1;
+ }
+ pd->pet.intimate = friendly;
+ clif_send_petstatus(sd);
+ clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_pethungry(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int hungry;
+ struct pet_data *pd;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (hungry = atoi(message)) < 0) {
+ clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
+ return -1;
+ }
+
+ pd = sd->pd;
+ if (!sd->status.pet_id || !pd) {
+ clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
+ return -1;
+ }
+ if (hungry < 0 || hungry > 100) {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+ if (hungry == pd->pet.hungry) {
+ clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
+ return -1;
+ }
+
+ pd->pet.hungry = hungry;
+ clif_send_petstatus(sd);
+ clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_petrename(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct pet_data *pd;
+ nullpo_retr(-1, sd);
+ if (!sd->status.pet_id || !sd->pd) {
+ clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
+ return -1;
+ }
+ pd = sd->pd;
+ if (!pd->pet.rename_flag) {
+ clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
+ return -1;
+ }
+
+ pd->pet.rename_flag = 0;
+ intif_save_petdata(sd->status.account_id, &pd->pet);
+ clif_send_petstatus(sd);
+ clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int
+atcommand_recall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
+ return -1;
+ }
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
+ if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
+ return -1;
+ if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
+ return -1;
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
+ if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
+ return -1;
+ }
+ if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
+ return -1;
+ }
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
+ 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(3)); // Character not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_revive(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
+ return -1;
+ }
+
+ pl_sd = map_nick2sd(atcmd_player_name);
+
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (!status_revive(&sd->bl, 100, 0))
+ return -1;
+
+ clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(fd, msg_txt(51)); // Character revived.
+ return 0;
+}
+
+/*==========================================
+ * charblock command (usage: charblock <player_name>)
+ * This command do a definitiv ban on a player
+ *------------------------------------------
+ */
+int atcommand_char_block(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
+ return -1;
+ }
+
+ // check player name
+ if (strlen(atcmd_player_name) < 4) {
+ clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
+ return -1;
+ } else if (strlen(atcmd_player_name) > 23) {
+ clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
+ return -1;
+ } else {
+ chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
+ clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * charban command (usage: charban <time> <player_name>)
+ * This command do a limited ban on a player
+ * Time is done as follows:
+ * Adjustment value (-1, 1, +1, etc...)
+ * Modified element:
+ * a or y: year
+ * m: month
+ * j or d: day
+ * h: hour
+ * mn: minute
+ * s: second
+ * <example> @ban +1m-2mn1s-6y test_player
+ * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
+ *------------------------------------------
+ */
+int atcommand_char_ban(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char * modif_p;
+ int year, month, day, hour, minute, second, value;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
+ clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
+ return -1;
+ }
+
+ atcmd_output[sizeof(atcmd_output)-1] = '\0';
+
+ modif_p = atcmd_output;
+ year = month = day = hour = minute = second = 0;
+ while (modif_p[0] != '\0') {
+ value = atoi(modif_p);
+ if (value == 0)
+ modif_p++;
+ else {
+ if (modif_p[0] == '-' || modif_p[0] == '+')
+ modif_p++;
+ while (modif_p[0] >= '0' && modif_p[0] <= '9')
+ modif_p++;
+ if (modif_p[0] == 's') {
+ second = value;
+ modif_p++;
+ } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
+ minute = value;
+ modif_p = modif_p + 2;
+ } else if (modif_p[0] == 'h') {
+ hour = value;
+ modif_p++;
+ } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
+ day = value;
+ modif_p++;
+ } else if (modif_p[0] == 'm') {
+ month = value;
+ modif_p++;
+ } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
+ year = value;
+ modif_p++;
+ } else if (modif_p[0] != '\0') {
+ modif_p++;
+ }
+ }
+ }
+ if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
+ clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
+ return -1;
+ }
+
+ // check player name
+ if (strlen(atcmd_player_name) < 4) {
+ clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
+ return -1;
+ } else if (strlen(atcmd_player_name) > 23) {
+ clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
+ return -1;
+ } else {
+ chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
+ clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * charunblock command (usage: charunblock <player_name>)
+ *------------------------------------------
+ */
+int atcommand_char_unblock(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
+ return -1;
+ }
+
+ // check player name
+ if (strlen(atcmd_player_name) < 4) {
+ clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
+ return -1;
+ } else if (strlen(atcmd_player_name) > 23) {
+ clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
+ return -1;
+ } else {
+ // send answer to login server via char-server
+ chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
+ clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * charunban command (usage: charunban <player_name>)
+ *------------------------------------------
+ */
+int atcommand_char_unban(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
+ return -1;
+ }
+
+ // check player name
+ if (strlen(atcmd_player_name) < 4) {
+ clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
+ return -1;
+ } else if (strlen(atcmd_player_name) > 23) {
+ clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
+ return -1;
+ } else {
+ // send answer to login server via char-server
+ chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
+ clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_night(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ if (night_flag != 1) {
+ map_night_timer(night_timer_tid, 0, 0, 1);
+ } else {
+ clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_day(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ if (night_flag != 0) {
+ map_day_timer(day_timer_tid, 0, 0, 1);
+ } else {
+ clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_doom(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+ clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
+ pl_allsd = map_getallusers(&users);
+ for(i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
+ status_kill(&pl_sd->bl);
+ clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
+ }
+ }
+ clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_doommap(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+ clif_specialeffect(&sd->bl,450,ALL_CLIENT);
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
+ pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
+ {
+ status_kill(&pl_sd->bl);
+// clif_specialeffect(&pl_sd->bl,450,1);
+ clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
+ }
+ }
+ clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static void atcommand_raise_sub(struct map_session_data* sd)
+{
+ if (!sd->state.auth || !status_isdead(&sd->bl))
+ return;
+
+ if(!status_revive(&sd->bl, 100, 100))
+ return;
+ clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_raise(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i, users;
+ struct map_session_data **all_sd;
+
+ nullpo_retr(-1, sd);
+
+ all_sd = map_getallusers(&users);
+
+ for (i = 0; i < users; i++) {
+ atcommand_raise_sub(all_sd[i]);
+ }
+ clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_raisemap(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data **pl_allsd;
+ int i, users;
+
+ nullpo_retr(-1, sd);
+
+ pl_allsd = map_getallusers(&users);
+
+ for (i = 0; i < users; i++) {
+ if (sd->bl.m == pl_allsd[i]->bl.m)
+ atcommand_raise_sub(pl_allsd[i]);
+ }
+ clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_kick(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != 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;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_kickall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+
+ pl_allsd = map_getallusers(&users);
+
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
+ if (sd->status.account_id != pl_sd->status.account_id)
+ clif_GM_kick(sd, pl_sd, 0);
+ }
+ }
+
+ clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_allskill(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ pc_allskillup(sd); // all skills
+ sd->status.skill_point = 0; // 0 skill points
+ clif_updatestatus(sd, SP_SKILLPOINT); // update
+ clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_questskill(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int skill_id;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (skill_id = atoi(message)) < 0) {
+ clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
+ return -1;
+ }
+
+ if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
+ if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
+ if (pc_checkskill(sd, skill_id) == 0) {
+ pc_skill(sd, skill_id, 1, 0);
+ clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
+ } else {
+ clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_lostskill(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int skill_id;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (skill_id = atoi(message)) < 0) {
+ clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
+ return -1;
+ }
+
+ if (skill_id >= 0 && skill_id < MAX_SKILL) {
+ if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
+ if (pc_checkskill(sd, skill_id) > 0) {
+ sd->status.skill[skill_id].lv = 0;
+ sd->status.skill[skill_id].flag = 0;
+ clif_skillinfoblock(sd);
+ clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
+ } else {
+ clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_spiritball(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int number;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || (number = atoi(message)) < 0) {
+ clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
+ return -1;
+ }
+
+ // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
+ if (number > 500)
+ number = 500;
+
+ if (number >= 0 && number <= 0x7FFF) {
+ if (sd->spiritball != number || number > 499) {
+ if (sd->spiritball > 0)
+ pc_delspiritball(sd, sd->spiritball, 1);
+ sd->spiritball = number;
+ clif_spiritball(sd);
+ // no message, player can look the difference
+ if (number > 1000)
+ clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
+ } else {
+ clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_party(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char party[NAME_LENGTH];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(party, '\0', sizeof(party));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
+ clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
+ return -1;
+ }
+
+ party_create(sd, party, 0, 0);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_guild(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char guild[NAME_LENGTH];
+ int prev;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(guild, '\0', sizeof(guild));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
+ clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
+ return -1;
+ }
+
+ prev = battle_config.guild_emperium_check;
+ battle_config.guild_emperium_check = 0;
+ guild_create(sd, guild);
+ battle_config.guild_emperium_check = prev;
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_agitstart(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (agit_flag == 1) {
+ clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
+ return -1;
+ }
+
+ agit_flag = 1;
+ guild_agit_start();
+ clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_agitend(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (agit_flag == 0) {
+ clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
+ return -1;
+ }
+
+ agit_flag = 0;
+ guild_agit_end();
+ clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
+
+ return 0;
+}
+
+/*==========================================
+ * @mapexitでマップサーバーを終了させる
+ *------------------------------------------
+ */
+int atcommand_mapexit(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
+ clif_GM_kick(sd, pl_sd, 0);
+ }
+ clif_GM_kick(sd, sd, 0);
+
+ flush_fifos();
+
+ runflag = 0;
+
+ return 0;
+}
+
+/*==========================================
+ * idsearch <part_of_name>: revrited by [Yor]
+ *------------------------------------------
+ */
+int atcommand_idsearch(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char item_name[100];
+ unsigned int i, match;
+ struct item_data *item_array[MAX_SEARCH];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
+ clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
+ return -1;
+ }
+
+ sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
+ clif_displaymessage(fd, atcmd_output);
+ match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
+ if (match > MAX_SEARCH) {
+ sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
+ clif_displaymessage(fd, atcmd_output);
+ match = MAX_SEARCH;
+ }
+ for(i = 0; i < match; i++) {
+ sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
+ clif_displaymessage(fd, atcmd_output);
+ }
+ sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ * Recall All Characters Online To Your Location
+ *------------------------------------------
+ */
+int atcommand_recallall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i;
+ int count, users;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
+ return -1;
+ }
+
+ count = 0;
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
+ 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.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ count++;
+ else {
+ if (pc_isdead(pl_sd)) { //Wake them up
+ pc_setstand(pl_sd);
+ pc_setrestartvalue(pl_sd,1);
+ }
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ }
+ }
+ }
+
+ clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
+ if (count) {
+ sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Recall online characters of a guild to your location
+ *------------------------------------------
+ */
+int atcommand_guildrecall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users, count;
+ char guild_name[NAME_LENGTH];
+ struct guild *g;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
+ return -1;
+ }
+
+ if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
+ return -1;
+ }
+
+ if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
+ (g = guild_search(atoi(message))) != NULL) {
+ count = 0;
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
+ pl_sd->status.guild_id == g->guild_id) {
+ if (pc_isGM(pl_sd) > pc_isGM(sd))
+ continue; //Skip GMs greater than you.
+ if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ count++;
+ else
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ }
+ }
+ sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
+ clif_displaymessage(fd, atcmd_output);
+ if (count) {
+ sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Recall online characters of a party to your location
+ *------------------------------------------
+ */
+int atcommand_partyrecall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ struct map_session_data *pl_sd, **pl_allsd;
+ char party_name[NAME_LENGTH];
+ struct party_data *p;
+ int count, users;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(party_name, '\0', sizeof(party_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
+ return -1;
+ }
+
+ if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
+ return -1;
+ }
+
+ if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
+ (p = party_search(atoi(message))) != NULL) {
+ count = 0;
+
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
+ pl_sd->status.party_id == p->party.party_id) {
+ if (pc_isGM(pl_sd) > pc_isGM(sd))
+ continue; //Skip GMs greater than you.
+ if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ count++;
+ else
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ }
+ }
+ sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
+ clif_displaymessage(fd, atcmd_output);
+ if (count) {
+ sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_reloaditemdb(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ itemdb_reload();
+ clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_reloadmobdb(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ mob_reload();
+ read_petdb();
+ merc_reload();
+ clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_reloadskilldb(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ skill_reload();
+ merc_skill_reload();
+ clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
+
+ return 0;
+}
+
+/*==========================================
+ * @reloadatcommand
+ * atcommand_athena.conf のリロード
+ *------------------------------------------
+ */
+int
+atcommand_reloadatcommand(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ atcommand_config_read(ATCOMMAND_CONF_FILENAME);
+ clif_displaymessage(fd, msg_txt(254));
+ return 0;
+}
+/*==========================================
+ * @reloadbattleconf
+ * battle_athena.conf のリロード
+ *------------------------------------------
+ */
+int
+atcommand_reloadbattleconf(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct Battle_Config prev_config;
+ memcpy(&prev_config, &battle_config, sizeof(prev_config));
+
+ battle_config_read(BATTLE_CONF_FILENAME);
+
+ if (memcmp(&prev_config.item_rate_mvp,
+ &battle_config.item_rate_mvp,
+ sizeof(battle_config.item_rate_mvp)+
+ sizeof(battle_config.item_rate_common)+
+ sizeof(battle_config.item_rate_common_boss)+
+ sizeof(battle_config.item_rate_card)+
+ sizeof(battle_config.item_rate_card_boss)+
+ sizeof(battle_config.item_rate_equip)+
+ sizeof(battle_config.item_rate_equip_boss)+
+ sizeof(battle_config.item_rate_heal)+
+ sizeof(battle_config.item_rate_heal_boss)+
+ sizeof(battle_config.item_rate_use)+
+ sizeof(battle_config.item_rate_use_boss)+
+ sizeof(battle_config.item_rate_treasure)+
+ sizeof(battle_config.item_rate_adddrop)+
+ sizeof(battle_config.logarithmic_drops)+
+ sizeof(battle_config.item_drop_common_min)+
+ sizeof(battle_config.item_drop_common_max)+
+ sizeof(battle_config.item_drop_card_min)+
+ sizeof(battle_config.item_drop_card_max)+
+ sizeof(battle_config.item_drop_equip_min)+
+ sizeof(battle_config.item_drop_equip_max)+
+ sizeof(battle_config.item_drop_mvp_min)+
+ sizeof(battle_config.item_drop_mvp_max)+
+ sizeof(battle_config.item_drop_heal_min)+
+ sizeof(battle_config.item_drop_heal_max)+
+ sizeof(battle_config.item_drop_use_min)+
+ sizeof(battle_config.item_drop_use_max)+
+ sizeof(battle_config.item_drop_treasure_min)+
+ sizeof(battle_config.item_drop_treasure_max)
+ ) != 0)
+ { //Drop rates changed.
+ mob_reload(); //Needed as well so rate changes take effect.
+#ifndef TXT_ONLY
+ chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
+#endif
+ }
+ clif_displaymessage(fd, msg_txt(255));
+ return 0;
+}
+/*==========================================
+ * @reloadstatusdb
+ * job_db1.txt job_db2.txt job_db2-2.txt
+ * refine_db.txt size_fix.txt
+ * のリロード
+ *------------------------------------------
+ */
+int
+atcommand_reloadstatusdb(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ status_readdb();
+ clif_displaymessage(fd, msg_txt(256));
+ return 0;
+}
+/*==========================================
+ * @reloadpcdb
+ * exp.txt skill_tree.txt attr_fix.txt
+ * のリロード
+ *------------------------------------------
+ */
+int
+atcommand_reloadpcdb(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ pc_readdb();
+ clif_displaymessage(fd, msg_txt(257));
+ return 0;
+}
+
+/*==========================================
+ * @reloadmotd [Valaris]
+ * Reloads motd.txt
+ *------------------------------------------
+ */
+int
+atcommand_reloadmotd(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ pc_read_motd();
+ clif_displaymessage(fd, msg_txt(268));
+ return 0;
+}
+
+
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_reloadscript(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
+ atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
+ atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
+ flush_fifos();
+
+ //do_init_npc();
+ script_reload();
+ npc_reload();
+
+ clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_reloadgmdb( // by [Yor]
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ chrif_reloadGMdb();
+
+ clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
+
+ return 0;
+}
+
+/*==========================================
+ * @mapinfo <map name> [0-3] by MC_Cameri
+ * => Shows information about the map [map name]
+ * 0 = no additional information
+ * 1 = Show users in that map and their location
+ * 2 = Shows NPCs in that map
+ * 3 = Shows the shops/chats in that map (not implemented)
+ *------------------------------------------
+ */
+int atcommand_mapinfo(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ struct npc_data *nd = NULL;
+ struct chat_data *cd = NULL;
+ char direction[12];
+ int m_id, i, chat_num, users, list = 0;
+ unsigned short m_index;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(direction, '\0', sizeof(direction));
+
+ sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
+
+ if (list < 0 || list > 3) {
+ clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
+ return -1;
+ }
+
+ if (atcmd_player_name[0] == '\0') {
+ memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
+ atcmd_player_name[MAP_NAME_LENGTH] = '\0';
+ m_id = map_mapindex2mapid(sd->mapindex);
+ } else {
+ if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
+ strcat(atcmd_player_name, ".gat");
+ m_id = map_mapname2mapid(atcmd_player_name);
+ }
+ if (m_id < 0) {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+ m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
+
+ clif_displaymessage(fd, "------ Map Info ------");
+ chat_num = 0;
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
+ chat_num++;
+ }
+ }
+ sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
+ clif_displaymessage(fd, atcmd_output);
+ if (map[m_id].flag.alias)
+ strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
+ clif_displaymessage(fd, "------ Map Flags ------");
+ strcpy(atcmd_output,"PvP Flags: ");
+ if (map[m_id].flag.pvp)
+ strcat(atcmd_output, "Pvp ON | ");
+ if (map[m_id].flag.pvp_noguild)
+ strcat(atcmd_output, "NoGuild | ");
+ if (map[m_id].flag.pvp_noparty)
+ strcat(atcmd_output, "NoParty | ");
+ if (map[m_id].flag.pvp_nightmaredrop)
+ strcat(atcmd_output, "NightmareDrop | ");
+ if (map[m_id].flag.pvp_nocalcrank)
+ strcat(atcmd_output, "NoCalcRank | ");
+ clif_displaymessage(fd, atcmd_output);
+
+ strcpy(atcmd_output,"GvG Flags: ");
+ if (map[m_id].flag.gvg)
+ strcat(atcmd_output, "GvG ON | ");
+ if (map[m_id].flag.gvg_dungeon)
+ strcat(atcmd_output, "GvG Dungeon | ");
+ if (map[m_id].flag.gvg_castle)
+ strcat(atcmd_output, "GvG Castle | ");
+ if (map[m_id].flag.gvg_noparty)
+ strcat(atcmd_output, "NoParty | ");
+ clif_displaymessage(fd, atcmd_output);
+
+ strcpy(atcmd_output,"Teleport Flags: ");
+ if (map[m_id].flag.noteleport)
+ strcat(atcmd_output, "NoTeleport | ");
+ if (map[m_id].flag.monster_noteleport)
+ strcat(atcmd_output, "Monster NoTeleport | ");
+ if (map[m_id].flag.nowarp)
+ strcat(atcmd_output, "NoWarp | ");
+ if (map[m_id].flag.nowarpto)
+ strcat(atcmd_output, "NoWarpTo | ");
+ if (map[m_id].flag.noreturn)
+ strcat(atcmd_output, "NoReturn | ");
+ if (map[m_id].flag.nogo)
+ strcat(atcmd_output, "NoGo | ");
+ if (map[m_id].flag.nomemo)
+ strcat(atcmd_output, "NoMemo | ");
+ clif_displaymessage(fd, atcmd_output);
+
+ sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
+ clif_displaymessage(fd, atcmd_output);
+
+ if (map[m_id].flag.nosave) {
+ if (!map[m_id].save.map)
+ sprintf(atcmd_output, "No Save (Return to last Save Point)");
+ else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
+ sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
+ else
+ sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
+ mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ strcpy(atcmd_output,"Weather Flags: ");
+ if (map[m_id].flag.snow)
+ strcat(atcmd_output, "Snow | ");
+ if (map[m_id].flag.fog)
+ strcat(atcmd_output, "Fog | ");
+ if (map[m_id].flag.sakura)
+ strcat(atcmd_output, "Sakura | ");
+ if (map[m_id].flag.clouds)
+ strcat(atcmd_output, "Clouds | ");
+ if (map[m_id].flag.clouds2)
+ strcat(atcmd_output, "Clouds2 | ");
+ if (map[m_id].flag.fireworks)
+ strcat(atcmd_output, "Fireworks | ");
+ if (map[m_id].flag.leaves)
+ strcat(atcmd_output, "Leaves | ");
+ if (map[m_id].flag.rain)
+ strcat(atcmd_output, "Rain | ");
+ if (map[m_id].flag.indoors)
+ strcat(atcmd_output, "Indoors | ");
+ if (map[m_id].flag.nightenabled)
+ strcat(atcmd_output, "Displays Night | ");
+ clif_displaymessage(fd, atcmd_output);
+
+ strcpy(atcmd_output,"Other Flags: ");
+ if (map[m_id].flag.nobranch)
+ strcat(atcmd_output, "NoBranch | ");
+ if (map[m_id].flag.notrade)
+ strcat(atcmd_output, "NoTrade | ");
+ if (map[m_id].flag.novending)
+ strcat(atcmd_output, "NoVending | ");
+ if (map[m_id].flag.nodrop)
+ strcat(atcmd_output, "NoDrop | ");
+ if (map[m_id].flag.noskill)
+ strcat(atcmd_output, "NoSkill | ");
+ if (map[m_id].flag.noicewall)
+ strcat(atcmd_output, "NoIcewall | ");
+
+ clif_displaymessage(fd, atcmd_output);
+
+ strcpy(atcmd_output,"Other Flags: ");
+ if (map[m_id].nocommand)
+ strcat(atcmd_output, "NoCommand | ");
+ if (map[m_id].flag.nobaseexp)
+ strcat(atcmd_output, "NoBaseEXP | ");
+ if (map[m_id].flag.nojobexp)
+ strcat(atcmd_output, "NoJobEXP | ");
+ if (map[m_id].flag.nomobloot)
+ strcat(atcmd_output, "NoMobLoot | ");
+ if (map[m_id].flag.nomvploot)
+ strcat(atcmd_output, "NoMVPLoot | ");
+ if (map[m_id].flag.partylock)
+ strcat(atcmd_output, "PartyLock | ");
+ if (map[m_id].flag.guildlock)
+ strcat(atcmd_output, "GuildLock | ");
+ clif_displaymessage(fd, atcmd_output);
+
+
+ switch (list) {
+ case 0:
+ // Do nothing. It's list 0, no additional display.
+ break;
+ case 1:
+ clif_displaymessage(fd, "----- Players in Map -----");
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
+ sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
+ pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+ break;
+ case 2:
+ clif_displaymessage(fd, "----- NPCs in Map -----");
+ for (i = 0; i < map[m_id].npc_num;) {
+ nd = map[m_id].npc[i];
+ switch(nd->ud.dir) {
+ case 0: strcpy(direction, "North"); break;
+ case 1: strcpy(direction, "North West"); break;
+ case 2: strcpy(direction, "West"); break;
+ case 3: strcpy(direction, "South West"); break;
+ case 4: strcpy(direction, "South"); break;
+ case 5: strcpy(direction, "South East"); break;
+ case 6: strcpy(direction, "East"); break;
+ case 7: strcpy(direction, "North East"); break;
+ case 9: strcpy(direction, "North"); break;
+ default: strcpy(direction, "Unknown"); break;
+ }
+ sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
+ ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ break;
+ case 3:
+ clif_displaymessage(fd, "----- Chats in Map -----");
+ for (i = 0; i < users; i++) {
+ if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
+ pl_sd->mapindex == m_index &&
+ cd->usersd[0] == pl_sd) {
+ sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
+ i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
+ clif_displaymessage(fd, atcmd_output);
+ sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
+ cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+ break;
+ default: // normally impossible to arrive here
+ clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
+ return -1;
+ break;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_mount_peco(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ if (!pc_isriding(sd)) { // if actually no peco
+ if (pc_checkskill(sd, KN_RIDING)) {
+ pc_setoption(sd, sd->sc.option | 0x0020);
+ clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
+ } else {
+ clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
+ return -1;
+ }
+ } else { //Dismount
+ pc_setoption(sd, sd->sc.option & ~0x0020);
+ clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_char_mount_peco(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+
+ if (!pc_isriding(pl_sd)) { // if actually no peco
+ if (pc_checkskill(pl_sd, KN_RIDING)) {
+ pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
+ clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
+ } else {
+ clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
+ return -1;
+ }
+ } else { //Dismount
+ pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
+ clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *Spy Commands by Syrus22
+ *------------------------------------------
+ */
+int atcommand_guildspy(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char guild_name[NAME_LENGTH];
+ struct guild *g;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!enable_spy)
+ {
+ clif_displaymessage(fd, "The mapserver has spy command support disabled.");
+ return -1;
+ }
+ if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
+ return -1;
+ }
+
+ if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
+ (g = guild_search(atoi(message))) != NULL) {
+ if (sd->guildspy == g->guild_id) {
+ sd->guildspy = 0;
+ sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ sd->guildspy = g->guild_id;
+ sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
+ clif_displaymessage(fd, atcmd_output);
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_partyspy(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char party_name[NAME_LENGTH];
+ struct party_data *p;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(party_name, '\0', sizeof(party_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!enable_spy)
+ {
+ clif_displaymessage(fd, "The mapserver has spy command support disabled.");
+ return -1;
+ }
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
+ return -1;
+ }
+
+ if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
+ (p = party_search(atoi(message))) != NULL) {
+ if (sd->partyspy == p->party.party_id) {
+ sd->partyspy = 0;
+ sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ sd->partyspy = p->party.party_id;
+ sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
+ clif_displaymessage(fd, atcmd_output);
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @repairall [Valaris]
+ *------------------------------------------
+ */
+int atcommand_repairall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int count, i;
+ nullpo_retr(-1, sd);
+
+ count = 0;
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
+ sd->status.inventory[i].attribute = 0;
+ clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
+ count++;
+ }
+ }
+
+ if (count > 0) {
+ clif_misceffect(&sd->bl, 3);
+ clif_equiplist(sd);
+ clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
+ } else {
+ clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
+ return -1;
+ }
+
+ return 0;
+}
+
+// Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
+int atcommand_nuke(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
+ skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
+ clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
+ } 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;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @tonpc
+ *------------------------------------------
+ */
+int atcommand_tonpc(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+
+ char npcname[NAME_LENGTH];
+ struct npc_data *nd;
+
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(npcname, 0, sizeof(npcname));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
+ clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
+ return -1;
+ }
+
+ if ((nd = npc_name2id(npcname)) != NULL) {
+ if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
+ clif_displaymessage(fd, msg_txt(0)); // Warped.
+ else
+ return -1;
+ } else {
+ clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_shownpc(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char NPCname[NAME_LENGTH];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
+ clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
+ return -1;
+ }
+
+ if (npc_name2id(NPCname) != NULL) {
+ npc_enable(NPCname, 1);
+ clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
+ } else {
+ clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int atcommand_hidenpc(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char NPCname[NAME_LENGTH];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
+ clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
+ return -1;
+ }
+
+ if (npc_name2id(NPCname) != NULL) {
+ npc_enable(NPCname, 0);
+ clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
+ } else {
+ clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+int atcommand_loadnpc(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ FILE *fp;
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
+ return -1;
+ }
+
+ // check if script file exists
+ if ((fp = fopen(message, "r")) == NULL) {
+ clif_displaymessage(fd, msg_txt(261));
+ return -1;
+ }
+ fclose(fp);
+
+ // add to list of script sources and run it
+ npc_addsrcfile((char *)message);
+ npc_parsesrcfile((char *)message);
+
+ clif_displaymessage(fd, msg_txt(262));
+
+ return 0;
+}
+
+int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct npc_data *nd;
+ char NPCname[NAME_LENGTH];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
+ clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
+ return -1;
+ }
+
+ if ((nd = npc_name2id(NPCname)) != NULL) {
+ npc_unload_duplicates(nd);
+ npc_unload(nd);
+ clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
+ } else {
+ clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * time in txt for time command (by [Yor])
+ *------------------------------------------
+ */
+char * txt_time(unsigned int duration) {
+ int days, hours, minutes, seconds;
+ char temp[256];
+ static char temp1[256];
+
+ malloc_tsetdword(temp, '\0', sizeof(temp));
+ malloc_tsetdword(temp1, '\0', sizeof(temp1));
+
+ days = duration / (60 * 60 * 24);
+ duration = duration - (60 * 60 * 24 * days);
+ hours = duration / (60 * 60);
+ duration = duration - (60 * 60 * hours);
+ minutes = duration / 60;
+ seconds = duration - (60 * minutes);
+
+ if (days < 2)
+ sprintf(temp, msg_txt(219), days); // %d day
+ else
+ sprintf(temp, msg_txt(220), days); // %d days
+ if (hours < 2)
+ sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
+ else
+ sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
+ if (minutes < 2)
+ sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
+ else
+ sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
+ if (seconds < 2)
+ sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
+ else
+ sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
+
+ return temp1;
+}
+
+/*==========================================
+ * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
+ * Calculation management of GM modification (@day/@night GM commands) is done
+ *------------------------------------------
+ */
+int atcommand_servertime(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct TimerData * timer_data;
+ struct TimerData * timer_data2;
+ time_t time_server; // variable for number of seconds (used with time() function)
+ struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
+ char temp[256];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(temp, '\0', sizeof(temp));
+
+ time(&time_server); // get time in seconds since 1/1/1970
+ datetime = localtime(&time_server); // convert seconds in structure
+ // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
+ strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
+ clif_displaymessage(fd, temp);
+
+ if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
+ if (night_flag == 0)
+ clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
+ else
+ clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
+ } else if (battle_config.night_duration == 0)
+ if (night_flag == 1) { // we start with night
+ timer_data = get_timer(day_timer_tid);
+ sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
+ clif_displaymessage(fd, temp);
+ clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
+ } else
+ clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
+ else if (battle_config.day_duration == 0)
+ if (night_flag == 0) { // we start with day
+ timer_data = get_timer(night_timer_tid);
+ sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ clif_displaymessage(fd, temp);
+ clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
+ } else
+ clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
+ else {
+ if (night_flag == 0) {
+ timer_data = get_timer(night_timer_tid);
+ timer_data2 = get_timer(day_timer_tid);
+ sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ clif_displaymessage(fd, temp);
+ if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
+ sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
+ else
+ sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
+ clif_displaymessage(fd, temp);
+ sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
+ clif_displaymessage(fd, temp);
+ } else {
+ timer_data = get_timer(day_timer_tid);
+ timer_data2 = get_timer(night_timer_tid);
+ sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
+ clif_displaymessage(fd, temp);
+ if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
+ sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
+ else
+ sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
+ clif_displaymessage(fd, temp);
+ sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
+ clif_displaymessage(fd, temp);
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
+ * removes <quantity> item from a character
+ * item can be equiped or not.
+ * Inspired from a old command created by RoVeRT
+ *------------------------------------------
+ */
+int atcommand_chardelitem(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ char item_name[100];
+ int i, number = 0, item_id, item_position, count;
+ struct item_data *item_data;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(item_name, '\0', sizeof(item_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
+ clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
+ return -1;
+ }
+
+ item_id = 0;
+ if ((item_data = itemdb_searchname(item_name)) != NULL ||
+ (item_data = itemdb_exists(atoi(item_name))) != NULL)
+ item_id = item_data->nameid;
+
+ if (item_id > 500) {
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
+ item_position = pc_search_inventory(pl_sd, item_id);
+ if (item_position >= 0) {
+ count = 0;
+ for(i = 0; i < number && item_position >= 0; i++) {
+
+ //Logs (A)dmins items [Lupus]
+ if(log_config.enable_logs&0x400)
+ log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
+
+ pc_delitem(pl_sd, item_position, 1, 0);
+ count++;
+ item_position = pc_search_inventory(pl_sd, item_id); // for next loop
+ }
+ sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
+ clif_displaymessage(pl_sd->fd, atcmd_output);
+ if (number == count)
+ sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
+ else
+ sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
+ return -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(19)); // Invalid item ID or name.
+ return -1;
+ }
+
+ return 0;
+}
+
+//Added by Coltaro
+//We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
+//Well, using time_t could still work but for some reason that looks like more coding x_x
+static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
+ const int factor_year = 518400; //12*30*24*60 = 518400
+ const int factor_month = 43200; //30*24*60 = 43200
+ const int factor_day = 1440; //24*60 = 1440
+ const int factor_hour = 60;
+
+ *year = jailtime/factor_year;
+ jailtime -= *year*factor_year;
+ *month = jailtime/factor_month;
+ jailtime -= *month*factor_month;
+ *day = jailtime/factor_day;
+ jailtime -= *day*factor_day;
+ *hour = jailtime/factor_hour;
+ jailtime -= *hour*factor_hour;
+ *minute = jailtime;
+
+ *year = *year > 0? *year : 0;
+ *month = *month > 0? *month : 0;
+ *day = *day > 0? *day : 0;
+ *hour = *hour > 0? *hour : 0;
+ *minute = *minute > 0? *minute : 0;
+ return;
+}
+
+/*==========================================
+ * @jail <char_name> by [Yor]
+ * Special warp! No check with nowarp and nowarpto flag
+ *------------------------------------------
+ */
+int atcommand_jail(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ int x, y;
+ unsigned short m_index;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can jail only lower or same GM
+ 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->mapindex == mapindex_name2id(MAP_JAIL))
+ { //Already jailed
+ clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
+ return -1;
+ }
+
+ switch(rand() % 2) { //Jail Locations
+ case 0:
+ m_index = mapindex_name2id(MAP_JAIL);
+ x = 24;
+ y = 75;
+ break;
+ default:
+ m_index = mapindex_name2id(MAP_JAIL);
+ x = 49;
+ y = 75;
+ break;
+ }
+ if (pc_setpos(pl_sd, m_index, x, y, 3)) {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+
+ pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
+ clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
+ clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
+ return 0;
+}
+
+/*==========================================
+ * @unjail/@discharge <char_name> by [Yor]
+ * Special warp! No check with nowarp and nowarpto flag
+ *------------------------------------------
+ */
+int atcommand_unjail(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ unsigned short m_index;
+ int x=0, y=0;
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
+
+ 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->mapindex != mapindex_name2id(MAP_JAIL)) {
+ clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
+ return -1;
+ }
+
+ if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
+ { //Retrieve return map.
+ m_index = pl_sd->sc.data[SC_JAILED].val3;
+ x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
+ y = pl_sd->sc.data[SC_JAILED].val4>>16;
+ status_change_end(&pl_sd->bl,SC_JAILED,-1);
+ } else
+ m_index = mapindex_name2id(MAP_PRONTERA);
+
+ if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
+ pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
+ ) { //Send to Prontera is saved SC map fails.
+ pc_setsavepoint(pl_sd, m_index, x, y);
+ clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
+ clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
+ } else {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+ return 0;
+}
+
+int atcommand_jailfor(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int year, month, day, hour, minute, value;
+ char * modif_p;
+ int jailtime = 0,x,y;
+ short m_index = 0;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
+ clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
+ return -1;
+ }
+
+ atcmd_output[sizeof(atcmd_output)-1] = '\0';
+
+ modif_p = atcmd_output;
+ year = month = day = hour = minute = 0;
+ while (modif_p[0] != '\0') {
+ value = atoi(modif_p);
+ if (value == 0)
+ modif_p++;
+ else {
+ if (modif_p[0] == '-' || modif_p[0] == '+')
+ modif_p++;
+ while (modif_p[0] >= '0' && modif_p[0] <= '9')
+ modif_p++;
+ if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
+ minute = value;
+ modif_p = modif_p + 2;
+ } else if (modif_p[0] == 'h') {
+ hour = value;
+ modif_p++;
+ } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
+ day = value;
+ modif_p++;
+ } else if (modif_p[0] == 'm') {
+ month = value;
+ modif_p++;
+ } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
+ year = value;
+ modif_p++;
+ } else if (modif_p[0] != '\0') {
+ modif_p++;
+ }
+ }
+ }
+
+ if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
+ clif_displaymessage(fd, "Invalid time for jail command.");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(pl_sd) > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+
+ jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
+
+ if(jailtime==0) {
+ clif_displaymessage(fd, "Invalid time for jail command.");
+ return -1;
+ }
+
+ //Added by Coltaro
+ if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
+ { //Update the player's jail time
+ jailtime += pl_sd->sc.data[SC_JAILED].val1;
+ if (jailtime <= 0) {
+ jailtime = 0;
+ clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
+ clif_displaymessage(fd, msg_txt(121)); // Player unjailed
+ } else {
+ get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
+ sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
+ clif_displaymessage(pl_sd->fd, atcmd_output);
+ sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
+ clif_displaymessage(fd, atcmd_output);
+ }
+ } else if (jailtime < 0) {
+ clif_displaymessage(fd, "Invalid time for jail command.");
+ return -1;
+ }
+
+ //Jail locations, add more as you wish.
+ switch(rand()%2)
+ {
+ case 1: //Jail #1
+ m_index = mapindex_name2id(MAP_JAIL);
+ x = 49; y = 75;
+ break;
+ default: //Default Jail
+ m_index = mapindex_name2id(MAP_JAIL);
+ x = 24; y = 75;
+ break;
+ }
+
+ sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
+ return 0;
+}
+
+
+//By Coltaro
+int atcommand_jailtime(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+ {
+ int year, month, day, hour, minute;
+
+ nullpo_retr(-1, sd);
+
+ if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
+ clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
+ return -1;
+ }
+
+ if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1 || sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
+ clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
+ return -1;
+ }
+
+ //Get remaining jail time
+ get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
+ sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
+
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+//By Coltaro
+int atcommand_charjailtime(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+ {
+ struct map_session_data* pl_sd;
+ int year, month, day, hour, minute;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
+ if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
+ clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
+ return -1;
+ }
+ if (!pl_sd->sc.count || pl_sd->sc.data[SC_JAILED].timer == -1 || pl_sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail?)
+ clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
+ return -1;
+ }
+ //Get remaining jail time
+ get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
+ sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @disguise <mob_id> by [Valaris] (simplified by [Yor])
+ *------------------------------------------
+ */
+int atcommand_disguise(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int id = 0;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
+ return -1;
+ }
+
+ if ((id = atoi(message)) > 0)
+ { //Acquired an ID
+ if (!mobdb_checkid(id) && !npcdb_checkid(id))
+ id = 0; //Invalid id for either mobs or npcs.
+ } else { //Acquired a Name
+ if ((id = mobdb_searchname(message)) == 0)
+ {
+ struct npc_data* nd = npc_name2id(message);
+ if (nd != NULL)
+ id = nd->n;
+ }
+ }
+
+ if (id == 0)
+ { // Monster/NPC name/id hasn't been found.
+ clif_displaymessage(fd, msg_txt(123));
+ return -1;
+ }
+
+ pc_disguise(sd, id);
+ clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
+
+ return 0;
+}
+
+/*==========================================
+ * DisguiseAll
+ *------------------------------------------
+ */
+
+int atcommand_disguiseall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int mob_id=0, i=0, users;
+ struct map_session_data *pl_sd, **pl_allsd;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
+ return -1;
+ }
+
+ if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
+ mob_id = atoi(message);
+
+ if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
+ pl_allsd = map_getallusers(&users);
+ for(i=0; i < users; i++) {
+ if((pl_sd = pl_allsd[i]))
+ pc_disguise(pl_sd, mob_id);
+ }
+ clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @undisguise by [Yor]
+ *------------------------------------------
+ */
+int atcommand_undisguise(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (sd->disguise) {
+ pc_disguise(sd, 0);
+ clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
+ } else {
+ clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * UndisguiseAll
+ *------------------------------------------
+ */
+int atcommand_undisguiseall(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd, **pl_allsd;
+ int i, users;
+ nullpo_retr(-1, sd);
+
+ pl_allsd = map_getallusers(&users);
+
+ for(i=0; i < users; i++) {
+ if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
+ pc_disguise(pl_sd, 0);
+ }
+ clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
+
+ return 0;
+}
+/*==========================================
+ * @exp by [Skotlex]
+ *------------------------------------------
+ */
+int atcommand_exp(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char output[200];
+ double nextb, nextj;
+ nullpo_retr(-1, sd);
+ malloc_tsetdword(output, '\0', sizeof(output));
+
+ nextb = pc_nextbaseexp(sd);
+ if (nextb)
+ nextb = sd->status.base_exp*100.0/nextb;
+
+ nextj = pc_nextjobexp(sd);
+ if (nextj)
+ nextj = sd->status.job_exp*100.0/nextj;
+
+ sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
+ clif_displaymessage(fd, output);
+ return 0;
+}
+
+
+/*==========================================
+ * @broadcast by [Valaris]
+ *------------------------------------------
+ */
+int atcommand_broadcast(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
+ return -1;
+ }
+
+ sprintf(atcmd_output, "%s : %s", sd->status.name, message);
+ intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
+
+ return 0;
+}
+
+/*==========================================
+ * @localbroadcast by [Valaris]
+ *------------------------------------------
+ */
+int atcommand_localbroadcast(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
+ return -1;
+ }
+
+ sprintf(atcmd_output, "%s : %s", sd->status.name, message);
+
+ clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
+
+ return 0;
+}
+
+/*==========================================
+ * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
+ *------------------------------------------
+ */
+int atcommand_chardisguise(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int mob_id;
+ char mob_name[NAME_LENGTH];
+ struct map_session_data* pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(mob_name, '\0', sizeof(mob_name));
+
+ if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
+ clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
+ return -1;
+ }
+
+ if ((mob_id = atoi(mob_name)) > 0)
+ { //Acquired an ID
+ if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
+ mob_id = 0; //Invalid id for either mobs or npcs.
+ } else { //Acquired a Name
+ if ((mob_id = mobdb_searchname(mob_name)) == 0)
+ {
+ struct npc_data* nd = npc_name2id(mob_name);
+ if (nd != NULL)
+ mob_id = nd->n;
+ }
+ }
+
+ if (mob_id == 0)
+ {
+ clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
+ pc_disguise(pl_sd, mob_id);
+ clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
+ } 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;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @charundisguise <character> by Kalaspuff (based off Yor's work)
+ *------------------------------------------
+ */
+int atcommand_charundisguise(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data* pl_sd;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
+ if (pl_sd->disguise)
+ pc_disguise(pl_sd, 0);
+ else {
+ clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
+ return -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;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @email <actual@email> <new@email> by [Yor]
+ *------------------------------------------
+ */
+int atcommand_email(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char actual_email[100];
+ char new_email[100];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(actual_email, '\0', sizeof(actual_email));
+ malloc_tsetdword(new_email, '\0', sizeof(new_email));
+
+ if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
+ clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
+ return -1;
+ }
+
+ if (e_mail_check(actual_email) == 0) {
+ clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
+ return -1;
+ } else if (e_mail_check(new_email) == 0) {
+ clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
+ return -1;
+ } else if (strcmpi(new_email, "a@a.com") == 0) {
+ clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
+ return -1;
+ } else if (strcmpi(actual_email, new_email) == 0) {
+ clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
+ return -1;
+ } else {
+ chrif_changeemail(sd->status.account_id, actual_email, new_email);
+ clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *@effect
+ *------------------------------------------
+ */
+int atcommand_effect(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int type = 0, flag = 0;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
+ clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
+ return -1;
+ }
+
+ clif_specialeffect(&sd->bl, type, flag);
+ clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
+
+ return 0;
+}
+
+/*==========================================
+ * @charcartlist <character>: Displays the items list of a player's cart.
+ *------------------------------------------
+ */
+int
+atcommand_character_cart_list(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char outputtmp[200];
+ struct map_session_data *pl_sd;
+ struct item_data *item_data, *item_temp;
+ int i, j, count, counter, counter2;
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
+
+ if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
+ counter = 0;
+ count = 0;
+ for (i = 0; i < MAX_CART; i++) {
+ if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
+ counter = counter + pl_sd->status.cart[i].amount;
+ count++;
+ if (count == 1) {
+ sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ if (pl_sd->status.cart[i].refine)
+ sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
+ else
+ sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
+ clif_displaymessage(fd, atcmd_output);
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ counter2 = 0;
+ for (j = 0; j < item_data->slot; j++) {
+ if (pl_sd->status.cart[i].card[j]) {
+ if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
+ if (atcmd_output[0] == '\0')
+ sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
+ else
+ sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
+ strcat(atcmd_output, outputtmp);
+ }
+ }
+ }
+ if (atcmd_output[0] != '\0') {
+ atcmd_output[strlen(atcmd_output) - 2] = ')';
+ atcmd_output[strlen(atcmd_output) - 1] = '\0';
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+ }
+ if (count == 0)
+ clif_displaymessage(fd, "No item found in the cart of this player.");
+ else {
+ sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
+ 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(3)); // Character not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @killer by MouseJstr
+ * enable killing players even when not in pvp
+ *------------------------------------------
+ */
+int
+atcommand_killer(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ sd->state.killer = !sd->state.killer;
+
+ if(sd->state.killer)
+ clif_displaymessage(fd, msg_txt(241));
+ else
+ clif_displaymessage(fd, msg_txt(287));
+
+ return 0;
+}
+
+/*==========================================
+ * @killable by MouseJstr
+ * enable other people killing you
+ *------------------------------------------
+ */
+int
+atcommand_killable(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ sd->state.killable = !sd->state.killable;
+
+ if(sd->state.killable)
+ clif_displaymessage(fd, msg_txt(242));
+ else
+ clif_displaymessage(fd, msg_txt(288));
+
+ return 0;
+}
+
+/*==========================================
+ * @charkillable by MouseJstr
+ * enable another player to be killed
+ *------------------------------------------
+ */
+int
+atcommand_charkillable(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if((pl_sd=map_nick2sd((char *) message)) == NULL)
+ return -1;
+
+ 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;
+}
+
+
+/*==========================================
+ * @skillon by MouseJstr
+ * turn skills on for the map
+ *------------------------------------------
+ */
+int
+atcommand_skillon(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ map[sd->bl.m].flag.noskill = 0;
+ clif_displaymessage(fd, msg_txt(244));
+ return 0;
+}
+
+/*==========================================
+ * @skilloff by MouseJstr
+ * Turn skills off on the map
+ *------------------------------------------
+ */
+int
+atcommand_skilloff(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ map[sd->bl.m].flag.noskill = 1;
+ clif_displaymessage(fd, msg_txt(243));
+ return 0;
+}
+
+/*==========================================
+ * @npcmove by MouseJstr
+ *
+ * move a npc
+ *------------------------------------------
+ */
+int
+atcommand_npcmove(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int x = 0, y = 0, m;
+ struct npc_data *nd = 0;
+ nullpo_retr(-1, sd);
+
+
+ if (!message || !*message)
+ return -1;
+
+ malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
+
+ if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
+ clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
+ return -1;
+ }
+
+ //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
+// nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
+
+ if ((nd = npc_name2id(atcmd_player_name)) == NULL)
+ return -1;
+
+ if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
+ return -1; //Not on a map.
+
+ if (x < 0) x = 0;
+ else if (x >= map[m].xs) x = map[m].xs-1;
+ if (y < 0) y = 0;
+ else if (y >= map[m].ys) y = map[m].ys-1;
+ map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
+ map_moveblock(&nd->bl, x, y, gettick());
+ map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
+
+ return 0;
+}
+
+/*==========================================
+ * @addwarp by MouseJstr
+ *
+ * Create a new static warp point.
+ *------------------------------------------
+ */
+int
+atcommand_addwarp(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char w1[64], w3[64], w4[64];
+ int x,y,ret;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
+ return -1;
+
+ sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
+ sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
+ sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
+
+ ret = npc_parse_warp(w1, "warp", w3, w4);
+
+ sprintf(atcmd_output, "New warp NPC => %s",w3);
+
+ clif_displaymessage(fd, atcmd_output);
+
+ return ret;
+}
+
+/*==========================================
+ * @follow by [MouseJstr]
+ *
+ * Follow a player .. staying no more then 5 spaces away
+ *------------------------------------------
+ */
+int
+atcommand_follow(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ if (sd->followtarget == -1)
+ return -1;
+
+ pc_stop_following (sd);
+ clif_displaymessage(fd, "Follow mode OFF.");
+ return 0;
+ }
+ if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
+ if (sd->followtarget == pl_sd->bl.id) {
+ pc_stop_following (sd);
+ clif_displaymessage(fd, "Follow mode OFF.");
+ } else {
+ pc_follow(sd, pl_sd->bl.id);
+ clif_displaymessage(fd, "Follow mode ON.");
+ }
+ return 0;
+ } else {
+ clif_displaymessage(fd, "Character not found.");
+ return -1;
+ }
+
+ return 1;
+}
+
+
+/*==========================================
+ * @dropall by [MouseJstr]
+ *
+ * Drop all your possession on the ground
+ *------------------------------------------
+ */
+int
+atcommand_dropall(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ nullpo_retr(-1, sd);
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].amount) {
+ if(sd->status.inventory[i].equip != 0)
+ pc_unequipitem(sd, i, 3);
+ pc_dropitem(sd, i, sd->status.inventory[i].amount);
+ }
+ }
+ return 0;
+}
+/*==========================================
+ * @chardropall by [MouseJstr]
+ *
+ * Throw all the characters possessions on the ground. Normally
+ * done in response to them being disrespectful of a GM
+ *------------------------------------------
+ */
+int
+atcommand_chardropall(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ struct map_session_data *pl_sd = NULL;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if((pl_sd=map_nick2sd((char *) message)) == NULL)
+ return -1;
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (pl_sd->status.inventory[i].amount) {
+ if(pl_sd->status.inventory[i].equip != 0)
+ pc_unequipitem(pl_sd, i, 3);
+ pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
+ }
+ }
+
+ clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
+ clif_displaymessage(fd, "It is done");
+ //clif_displaymessage(fd, "It is offical.. your a jerk");
+
+ return 0;
+}
+/*==========================================
+ * @storeall by [MouseJstr]
+ *
+ * Put everything into storage to simplify your inventory to make
+ * debugging easie
+ *------------------------------------------
+ */
+int
+atcommand_storeall(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ nullpo_retr(-1, sd);
+
+ if (sd->state.storage_flag != 1)
+ { //Open storage.
+ switch (storage_storageopen(sd)) {
+ case 2: //Try again
+ clif_displaymessage(fd, "run this command again..");
+ return 0;
+ case 1: //Failure
+ clif_displaymessage(fd, "You can't open the storage currently.");
+ return -1;
+ }
+ }
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].amount) {
+ if(sd->status.inventory[i].equip != 0)
+ pc_unequipitem(sd, i, 3);
+ storage_storageadd(sd, i, sd->status.inventory[i].amount);
+ }
+ }
+ storage_storageclose(sd);
+
+ clif_displaymessage(fd, "It is done");
+ return 0;
+}
+/*==========================================
+ * @charstoreall by [MouseJstr]
+ *
+ * A way to screw with players who piss you off
+ *------------------------------------------
+ */
+int
+atcommand_charstoreall(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ struct map_session_data *pl_sd = NULL;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if((pl_sd=map_nick2sd((char *) message)) == NULL)
+ return -1;
+
+ if (pl_sd->state.storage_flag != 1)
+ { //Open storage.
+ switch (storage_storageopen(pl_sd)) {
+ case 2: //Try again
+ clif_displaymessage(fd, "Had to open the characters storage window...");
+ clif_displaymessage(fd, "run this command again..");
+ return 0;
+ case 1: //Failure
+ clif_displaymessage(fd, "The character currently can't use the storage.");
+ return 1;
+ }
+ }
+
+ for (i = 0; i < MAX_INVENTORY; i++) {
+ if (pl_sd->status.inventory[i].amount) {
+ if(pl_sd->status.inventory[i].equip != 0)
+ pc_unequipitem(pl_sd, i, 3);
+ storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
+ }
+ }
+ storage_storageclose(pl_sd);
+
+ clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
+ clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
+ clif_displaymessage(pl_sd->fd, " -- the management");
+
+ clif_displaymessage(fd, "It is done");
+
+ return 0;
+}
+/*==========================================
+ * @skillid by [MouseJstr]
+ *
+ * lookup a skill by name
+ *------------------------------------------
+ */
+int
+atcommand_skillid(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int skillen, idx;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ skillen = strlen(message);
+
+ for (idx = 0; idx < MAX_SKILL_DB; idx++) {
+ if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
+ (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
+ {
+ sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @useskill by [MouseJstr]
+ *
+ * A way of using skills without having to find them in the skills menu
+ *------------------------------------------
+ */
+int
+atcommand_useskill(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ struct block_list *bl;
+ int skillnum;
+ int skilllv;
+ char target[255];
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
+ clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
+ return -1;
+ }
+ if((pl_sd=map_nick2sd(target)) == NULL) {
+ return -1;
+ }
+
+ if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
+ && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
+ bl = &sd->hd->bl;
+ else
+ bl = &sd->bl;
+
+ if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
+ unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
+ else
+ unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
+
+ return 0;
+}
+
+/*==========================================
+ * @skilltree by [MouseJstr]
+ *
+ * prints the skill tree for a player required to get to a skill
+ *------------------------------------------
+ */
+int
+atcommand_skilltree(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int skillnum, skillidx = -1;
+ int meets = 1, j, c=0;
+ char target[NAME_LENGTH], *tbl;
+ struct skill_tree_entry *ent;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
+ clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
+ return -1;
+ }
+ if((pl_sd=map_nick2sd(target)) == NULL)
+ return -1;
+
+ c = pc_calc_skilltree_normalize_job(pl_sd);
+ c = pc_mapid2jobid(c, pl_sd->status.sex);
+
+ tbl = job_name(c);
+
+ sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
+ tbl, pc_checkskill(pl_sd, 1));
+ clif_displaymessage(fd, atcmd_output);
+
+ for (j = 0; skill_tree[c][j].id != 0; j++) {
+ if (skill_tree[c][j].id == skillnum) {
+ skillidx = j;
+ break;
+ }
+ }
+
+ if (skillidx == -1) {
+ sprintf(atcmd_output, "I do not believe the player can use that skill");
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+
+ ent = &skill_tree[c][skillidx];
+
+ for(j=0;j<5;j++)
+ if( ent->need[j].id &&
+ pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
+ {
+ char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
+ sprintf(atcmd_output, "player requires level %d of skill %s",
+ ent->need[j].lv, desc);
+ clif_displaymessage(fd, atcmd_output);
+ meets = 0;
+ }
+
+ if (meets == 1) {
+ sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
+ clif_displaymessage(fd, atcmd_output);
+ }
+
+ return 0;
+}
+
+// Hand a ring with partners name on it to this char
+void getring (struct map_session_data *sd)
+{
+ int flag,item_id = 0;
+ struct item item_tmp;
+ if(sd->status.sex==0)
+ item_id = 2635;
+ else
+ item_id = 2634;
+
+ malloc_set(&item_tmp,0,sizeof(item_tmp));
+ item_tmp.nameid=item_id;
+ item_tmp.identify=1;
+ item_tmp.card[0]=255;
+ item_tmp.card[2]=sd->status.partner_id;
+ item_tmp.card[3]=sd->status.partner_id >> 16;
+
+ //Logs (A)dmins items [Lupus]
+ if(log_config.enable_logs&0x400)
+ log_pick_pc(sd, "A", item_id, 1, &item_tmp);
+
+ if((flag = pc_additem(sd,&item_tmp,1))) {
+ clif_additem(sd,0,0,flag);
+ map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
+ }
+
+}
+
+
+/*==========================================
+ * @marry by [MouseJstr], fixed by Lupus
+ *
+ * Marry two players
+ *------------------------------------------
+ */
+int
+atcommand_marry(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd1 = NULL;
+ struct map_session_data *pl_sd2 = NULL;
+ char player1[128], player2[128]; //Length used for return error msgs
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
+ clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
+ return -1;
+ }
+
+ if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
+ sprintf(player2, "Cannot find player '%s' online", player1);
+ clif_displaymessage(fd, player2);
+ return -1;
+ }
+
+ if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
+ sprintf(player1, "Cannot find player '%s' online", player2);
+ clif_displaymessage(fd, player1);
+ return -1;
+ }
+
+ if (pc_marriage(pl_sd1, pl_sd2) == 0) {
+ clif_displaymessage(fd, "They are married.. wish them well");
+ clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
+ // Auto-give named rings (Aru)
+ getring (pl_sd1);
+ getring (pl_sd2);
+ return 0;
+ }
+ return -1;
+}
+
+/*==========================================
+ * @divorce by [MouseJstr], fixed by [Lupus]
+ *
+ * divorce two players
+ *------------------------------------------
+ */
+int
+atcommand_divorce(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
+ clif_displaymessage(fd, "Usage: @divorce <player>.");
+ return -1;
+ }
+
+ if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
+ if (pc_divorce(pl_sd) != 0) {
+ sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ } else {
+ sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+ }
+ sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+}
+
+
+#ifdef DMALLOC
+unsigned long dmark_;
+int
+atcommand_dmstart(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ dmark_ = dmalloc_mark();
+
+ clif_displaymessage(fd, "debug mark set");
+
+ return 0;
+}
+
+int
+atcommand_dmtick(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
+ dmark_ = dmalloc_mark();
+ clif_displaymessage(fd, "malloc changes logged");
+
+ return 0;
+}
+#endif
+
+/*==========================================
+ * @grind by [MouseJstr]
+ *------------------------------------------
+ */
+int
+atcommand_grind(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int skillnum;
+ int inf;
+ char target[NAME_LENGTH];
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if(sscanf(message, "%23s", target) != 1) {
+ clif_displaymessage(fd, "Usage: @grind <target>");
+ return -1;
+ }
+ if((pl_sd=map_nick2sd(target)) == NULL)
+ return -1;
+
+ for (skillnum = 1; skillnum < 500; skillnum++) {
+ sd->status.sp = sd->status.max_sp;
+ atcommand_alive(fd, sd, command, message);
+
+ inf = skill_get_inf(skillnum);
+
+ if (inf & INF_GROUND_SKILL)
+ unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
+ else if (!(inf & INF_SUPPORT_SKILL))
+ unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @grind2 by [MouseJstr]
+ *------------------------------------------
+ */
+int
+atcommand_grind2(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i;
+ short x, y;
+
+ for (i = 1000; i < MAX_MOB_DB; i++) {
+ if (!mobdb_checkid(i))
+ continue;
+ map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
+ mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @changelook by [Celest]
+ *------------------------------------------
+ */
+int
+atcommand_changelook(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i, j = 0, k = 0;
+ int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
+
+ if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
+ clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
+ clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
+ return -1;
+ } else if (i == 2) {
+ if (j < 1) j = 1;
+ else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
+ j = pos[j - 1];
+ } else if (i == 1) { // position not defined, use HEAD_TOP as default
+ k = j; // swap
+ j = LOOK_HEAD_TOP;
+ }
+
+ clif_changelook(&sd->bl,j,k);
+
+ return 0;
+}
+
+/*==========================================
+ *Turns on/off Autotrade for a specific player
+ *------------------------------------------
+ *by durf (changed by Lupus)
+ */
+int
+atcommand_autotrade(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (sd->vender_id) //check if player's vending
+ {
+ sd->state.autotrade = 1;
+ clif_authfail_fd(fd, 15);
+ }
+ else
+ {
+ //"You should be vending to use @Autotrade."
+ clif_displaymessage(fd, msg_txt(549));
+ }
+ return 0;
+}
+
+
+/*==========================================
+ * Changes Master of your Guild to a specified guild member
+ *------------------------------------------
+ *by durf (changed by Lupus)
+ */
+int
+atcommand_changegm(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct guild *g;
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
+ {
+ clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
+ return -1;
+ }
+ if (strlen(message)==0)
+ {
+ clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
+ return -1;
+ }
+
+ if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
+ clif_displaymessage(fd, "Target character must be online and be a guildmate.");
+ return -1;
+ }
+
+ guild_gm_change(sd->status.guild_id, pl_sd);
+ return 0;
+}
+
+/*==========================================
+ *Changes the leader of a party.
+ *------------------------------------------
+ *by Skotlex
+ */
+int
+atcommand_changeleader(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct party_data *p;
+ struct map_session_data *pl_sd;
+ int mi, pl_mi;
+ nullpo_retr(-1, sd);
+
+ if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
+ { //Need to be a party leader.
+ clif_displaymessage(fd, msg_txt(282));
+ return -1;
+ }
+
+ for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
+
+ if (mi == MAX_PARTY)
+ return -1; //Shouldn't happen
+
+ if (!p->party.member[mi].leader)
+ { //Need to be a party leader.
+ clif_displaymessage(fd, msg_txt(282));
+ return -1;
+ }
+
+ if (strlen(message)==0)
+ {
+ clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
+ return -1;
+ }
+
+ if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
+ clif_displaymessage(fd, msg_txt(283));
+ return -1;
+ }
+
+ for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
+
+ if (pl_mi == MAX_PARTY)
+ return -1; //Shouldn't happen
+
+ //Change leadership.
+ p->party.member[mi].leader = 0;
+ if (p->data[mi].sd->fd)
+ clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
+ p->party.member[pl_mi].leader = 1;
+ if (p->data[pl_mi].sd->fd)
+ clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
+
+ intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
+ //Update info.
+ clif_party_main_info(p,-1);
+ clif_party_info(p,-1);
+
+ return 0;
+}
+
+/*==========================================
+ * Used to change the item share setting of a party.
+ *------------------------------------------
+ *by Skotlex
+ */
+int
+atcommand_partyoption(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct party_data *p;
+ int mi, option;
+ char w1[15], w2[15];
+ nullpo_retr(-1, sd);
+
+ if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
+ {
+ clif_displaymessage(fd, msg_txt(282));
+ return -1;
+ }
+
+ for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
+
+ if (mi == MAX_PARTY)
+ return -1; //Shouldn't happen
+
+ if (!p->party.member[mi].leader)
+ {
+ clif_displaymessage(fd, msg_txt(282));
+ return -1;
+ }
+
+ if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
+ {
+ clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
+ return -1;
+ }
+ w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
+ option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
+
+ //Change item share type.
+ if (option != p->party.item)
+ party_changeoption(sd, p->party.exp, option);
+ else
+ clif_displaymessage(fd, msg_txt(286));
+
+ return 0;
+}
+
+/*==========================================
+ *Turns on/off AutoLoot for a specific player
+ *------------------------------------------
+ *by Upa-Kun
+ */
+int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
+{
+ // autoloot command with value
+ int rate;
+
+ nullpo_retr(-1, sd);
+
+ // autoloot command without value
+ if(!message || !*message)
+ {
+ // autoloot on -> off
+ if(sd->state.autoloot)
+ {
+ clif_displaymessage(fd, "Autoloot is now off.");
+ sd->state.autoloot = 0;
+ return 0;
+ // autoloot off -> on
+ } else {
+ clif_displaymessage(fd, "Autoloot is now on.");
+ sd->state.autoloot = 10000;
+ return 0;
+ }
+ }
+
+ // get maximum droprate limit
+ rate = (int)(atof(message) * 100.);
+
+ // check for invalid value
+ if(rate > 10000)
+ {
+ clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
+ return 0;
+ }
+
+ // autoloot value is 0, turn autoloot off
+ if(rate == 0)
+ {
+ if(sd->state.autoloot == 0)
+ clif_displaymessage(fd, "Autoloot is already off.");
+ else {
+ clif_displaymessage(fd, "Autoloot is now off.");
+ sd->state.autoloot = 0;
+ }
+ return 0;
+ }
+
+ // autoloot value is 100, turn autoloot on
+ if(rate == 10000)
+ {
+ if(sd->state.autoloot == 10000)
+ clif_displaymessage(fd, "Autoloot is already on.");
+ else {
+ clif_displaymessage(fd, "Autoloot is now on.");
+ sd->state.autoloot = 10000;
+ }
+ return 0;
+ }
+
+ // autoloot value is between 0 and 100
+ snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.", rate/100.);
+ clif_displaymessage(fd, atcmd_output);
+ sd->state.autoloot = rate;
+
+ return 0;
+}
+
+
+/*==========================================
+ * It is made to rain.
+ *------------------------------------------
+ */
+int
+atcommand_rain(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.rain) {
+ map[sd->bl.m].flag.rain=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "The rain has stopped.");
+ } else {
+ map[sd->bl.m].flag.rain=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "It is made to rain.");
+ }
+ return 0;
+}
+/*==========================================
+ * It is made to snow.
+ *------------------------------------------
+ */
+int
+atcommand_snow(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.snow) {
+ map[sd->bl.m].flag.snow=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Snow has stopped falling.");
+ } else {
+ map[sd->bl.m].flag.snow=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "It is made to snow.");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Cherry tree snowstorm is made to fall. (Sakura)
+ *------------------------------------------
+ */
+int
+atcommand_sakura(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.sakura) {
+ map[sd->bl.m].flag.sakura=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
+ } else {
+ map[sd->bl.m].flag.sakura=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
+ }
+ return 0;
+}
+
+/*==========================================
+ * Clouds appear.
+ *------------------------------------------
+ */
+int
+atcommand_clouds(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.clouds) {
+ map[sd->bl.m].flag.clouds=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "The clouds has disappear.");
+ } else {
+ map[sd->bl.m].flag.clouds=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Clouds appear.");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Different type of clouds using effect 516
+ *------------------------------------------
+ */
+int
+atcommand_clouds2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.clouds2) {
+ map[sd->bl.m].flag.clouds2=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "The alternative clouds disappear.");
+ } else {
+ map[sd->bl.m].flag.clouds2=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Alternative clouds appear.");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Fog hangs over.
+ *------------------------------------------
+ */
+int
+atcommand_fog(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.fog) {
+ map[sd->bl.m].flag.fog=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "The fog has gone.");
+ } else {
+ map[sd->bl.m].flag.fog=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Fog hangs over.");
+ }
+ return 0;
+}
+
+/*==========================================
+ * Fallen leaves fall.
+ *------------------------------------------
+ */
+int
+atcommand_leaves(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.leaves) {
+ map[sd->bl.m].flag.leaves=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Leaves no longer fall.");
+ } else {
+ map[sd->bl.m].flag.leaves=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Fallen leaves fall.");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Fireworks appear.
+ *------------------------------------------
+ */
+int
+atcommand_fireworks(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ if (map[sd->bl.m].flag.fireworks) {
+ map[sd->bl.m].flag.fireworks=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Fireworks are ended.");
+ } else {
+ map[sd->bl.m].flag.fireworks=1;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, "Fireworks are launched.");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * Clearing Weather Effects by Dexity
+ *------------------------------------------
+ */
+int
+atcommand_clearweather(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ map[sd->bl.m].flag.rain=0;
+ map[sd->bl.m].flag.snow=0;
+ map[sd->bl.m].flag.sakura=0;
+ map[sd->bl.m].flag.clouds=0;
+ map[sd->bl.m].flag.clouds2=0;
+ map[sd->bl.m].flag.fog=0;
+ map[sd->bl.m].flag.fireworks=0;
+ map[sd->bl.m].flag.leaves=0;
+ clif_weather(sd->bl.m);
+ clif_displaymessage(fd, msg_txt(291));
+
+ return 0;
+}
+
+/*===============================================================
+ * Sound Command - plays a sound for everyone! [Codemaster]
+ *---------------------------------------------------------------
+ */
+int
+atcommand_sound(
+ const int fd, struct map_session_data *sd,
+ const char *command, const char *message)
+{
+ char sound_file[100];
+
+ if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
+ clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
+ return -1;
+ }
+
+ malloc_tsetdword(sound_file, '\0', sizeof(sound_file));
+ if(sscanf(message, "%99[^\n]", sound_file) < 1)
+ return -1;
+
+ if(strstr(sound_file, ".wav") == NULL)
+ strcat(sound_file, ".wav");
+
+ clif_soundeffectall(&sd->bl, sound_file,0,2);
+
+ return 0;
+}
+
+/*==========================================
+ * MOB Search
+ *------------------------------------------
+ */
+static int atmobsearch_sub(struct block_list *bl,va_list ap)
+{
+ int mob_id,fd;
+ static int number=0;
+ struct mob_data *md;
+
+ nullpo_retr(0, bl);
+
+ if(!ap){
+ number=0;
+ return 0;
+ }
+ mob_id = va_arg(ap,int);
+ fd = va_arg(ap,int);
+
+ md = (struct mob_data *)bl;
+
+ if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
+ snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
+ ++number,bl->x, bl->y,md->name);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ return 0;
+}
+int atcommand_mobsearch(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char mob_name[100];
+ int mob_id,map_id = 0;
+
+ nullpo_retr(-1, sd);
+
+ if (sscanf(message, "%99[^\n]", mob_name) < 0)
+ return -1;
+
+ if ((mob_id = atoi(mob_name)) == 0)
+ mob_id = mobdb_searchname(mob_name);
+ if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
+ snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+ if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
+ strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
+// strcpy(mob_name,mob_db(mob_id)->name); // --en--
+
+ map_id = sd->bl.m;
+
+ snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
+ mob_name, mapindex_id2name(sd->mapindex));
+ clif_displaymessage(fd, atcmd_output);
+
+ map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
+
+ atmobsearch_sub(&sd->bl,0); // 番号リセット
+
+ return 0;
+}
+/*==========================================
+ * ドロップアイテムの掃除
+ *------------------------------------------
+ */
+/*==========================================
+ * cleanmap
+ *------------------------------------------
+ */
+static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
+{
+ nullpo_retr(0, bl);
+ map_clearflooritem(bl->id);
+
+ return 0;
+}
+
+int
+atcommand_cleanmap(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
+ sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
+ sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
+ BL_ITEM);
+ clif_displaymessage(fd, "All dropped items have been cleaned up.");
+ return 0;
+}
+
+/*==========================================
+ * NPC/PETに話させる
+ *------------------------------------------
+ */
+int
+atcommand_npctalk(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char name[NAME_LENGTH],mes[100],temp[100];
+ struct npc_data *nd;
+
+ if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
+ return -1;
+
+ if (!(nd = npc_name2id(name)))
+ return -1;
+
+ snprintf(temp, sizeof temp ,"%s : %s",name,mes);
+ clif_message(&nd->bl, temp);
+
+ return 0;
+}
+int
+atcommand_pettalk(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char mes[100],temp[100];
+ struct pet_data *pd;
+
+ nullpo_retr(-1, sd);
+
+ if(!sd->status.pet_id || !(pd=sd->pd))
+ return -1;
+
+ if (sd->sc.count && //no "chatting" while muted.
+ (sd->sc.data[SC_BERSERK].timer!=-1 ||
+ (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
+ return -1;
+
+ if (sscanf(message, "%99[^\n]", mes) < 1)
+ return -1;
+
+ snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
+ clif_message(&pd->bl, temp);
+
+ return 0;
+}
+
+/*==========================================
+ * @users
+ * サーバー内の人数マップを表示させる
+ * 手抜きのため汚くなっているのは仕様です。
+ *------------------------------------------
+ */
+
+static struct dbt *users_db = NULL;
+static int users_all;
+
+static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
+ int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
+ users_all++;
+ uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
+ return 0;
+}
+
+static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
+ char buf[256];
+ struct map_session_data* sd = va_arg(va,struct map_session_data*);
+ sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
+ clif_displaymessage(sd->fd,buf);
+ return 0;
+}
+
+int
+atcommand_users(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char buf[256];
+ users_all = 0;
+
+ users_db->clear(users_db, NULL);
+ clif_foreachclient(atcommand_users_sub1);
+ users_db->foreach(users_db,atcommand_users_sub2,sd);
+ sprintf(buf,"all : %d",users_all);
+ clif_displaymessage(fd,buf);
+ return 0;
+}
+
+int
+atcommand_reset(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ pc_resetstate(sd);
+ pc_resetskill(sd,1);
+ sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int
+atcommand_summon(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char name[NAME_LENGTH];
+ int mob_id = 0;
+ int duration = 0;
+ struct mob_data *md;
+ unsigned int tick=gettick();
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if (sscanf(message, "%23s %d", name, &duration) < 1)
+ return -1;
+
+ if (duration < 1)
+ duration =1;
+ else if (duration > 60)
+ duration =60;
+
+ if ((mob_id = atoi(name)) == 0)
+ mob_id = mobdb_searchname(name);
+ if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
+ return -1;
+
+ md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
+
+ if(md){
+ md->master_id=sd->bl.id;
+ md->special_state.ai=1;
+ md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
+ clif_misceffect2(&md->bl,344);
+ mob_spawn(md);
+ sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
+ clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
+ }
+
+ return 0;
+}
+
+
+/*==========================================
+ * @adjcmdlvl by [MouseJstr]
+ *
+ * Temp adjust the GM level required to use a GM command
+ *
+ * Used during beta testing to allow players to use GM commands
+ * for short periods of time
+ *------------------------------------------
+ */
+int
+atcommand_adjcmdlvl(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i, newlev;
+ char cmd[100];
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
+ clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
+ return -1;
+ }
+
+ for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
+ if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
+ atcommand_info[i].level = newlev;
+ clif_displaymessage(fd, "@command level changed.");
+ return 0;
+ }
+
+ clif_displaymessage(fd, "@command not found.");
+ return -1;
+}
+
+/*==========================================
+ * @adjgmlvl by [MouseJstr]
+ *
+ * Create a temp GM
+ *
+ * Used during beta testing to allow players to use GM commands
+ * for short periods of time
+ *------------------------------------------
+ */
+int
+atcommand_adjgmlvl(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int newlev;
+ char user[NAME_LENGTH];
+ struct map_session_data *pl_sd;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
+ clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
+ return -1;
+ }
+
+ if((pl_sd=map_nick2sd((char *) user)) == NULL)
+ return -1;
+
+ pc_set_gm_level(pl_sd->status.account_id, newlev);
+
+ return 0;
+}
+
+
+/*==========================================
+ * @trade by [MouseJstr]
+ *
+ * Open a trade window with a remote player
+ *
+ * If I have to jump to a remote player one more time, I am
+ * gonna scream!
+ *------------------------------------------
+ */
+int
+atcommand_trade(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if((pl_sd=map_nick2sd((char *) message)) != NULL) {
+ trade_traderequest(sd, pl_sd);
+ return 0;
+ }
+ return -1;
+}
+
+/*==========================================
+ * @setbattleflag by [MouseJstr]
+ *
+ * set a battle_config flag without having to reboot
+ */
+int
+atcommand_setbattleflag(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char flag[128], value[128];
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
+ clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
+ return -1;
+ }
+
+ if (battle_set_value(flag, value) == 0)
+ clif_displaymessage(fd, "unknown battle_config flag");
+ else
+ clif_displaymessage(fd, "battle_config set as requested");
+
+ return 0;
+}
+
+
+/*===========================
+ * @unmute [Valaris]
+ *===========================
+*/
+int atcommand_unmute(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if((pl_sd=map_nick2sd((char *) message)) != NULL) {
+ if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
+ pl_sd->status.manner = 0;
+ status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
+ clif_displaymessage(sd->fd,"Player unmuted");
+ }
+ else
+ clif_displaymessage(sd->fd,"Player is not muted");
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @uptime by MC Cameri
+ *------------------------------------------
+ */
+int
+atcommand_uptime(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
+ minute = 60, days = 0, hours = 0, minutes = 0;
+ nullpo_retr(-1, sd);
+
+ seconds = get_uptime();
+ days = seconds/day;
+ seconds -= (seconds/day>0)?(seconds/day)*day:0;
+ hours = seconds/hour;
+ seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
+ minutes = seconds/minute;
+ seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
+
+ snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ * @changesex <sex>
+ * => Changes one's sex. Argument sex can be
+ * 0 or 1, m or f, male or female.
+ *------------------------------------------
+ */
+int
+atcommand_changesex(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
+ return 0;
+}
+
+/*================================================
+ * @mute - Mutes a player for a set amount of time
+ *------------------------------------------------
+ */
+int atcommand_mute(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int manner;
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
+ clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
+ return -1;
+ }
+
+ if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
+ if (pc_isGM(pl_sd) > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ clif_GM_silence(sd, pl_sd, 0);
+ pl_sd->status.manner -= manner;
+ if(pl_sd->status.manner < 0)
+ sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
+ }
+ else {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @refresh (like @jumpto <<yourself>>)
+ *------------------------------------------
+ */
+int atcommand_refresh(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+ clif_refresh(sd);
+ return 0;
+}
+
+/*==========================================
+ * @petid <part of pet name>
+ * => Displays a list of matching pets.
+ *------------------------------------------
+ */
+int
+atcommand_petid(const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char searchtext[100];
+ char temp0[100];
+ char temp1[100];
+ int cnt = 0, i = 0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+ if (sscanf(message, "%99s", searchtext) < 1)
+ return -1;
+ estr_lower(searchtext);
+ snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
+ clif_displaymessage(fd,temp0);
+ while (i < MAX_PET_DB) {
+ strcpy(temp1,pet_db[i].name);
+ strcpy(temp1, estr_lower(temp1));
+ strcpy(temp0,pet_db[i].jname);
+ strcpy(temp0, estr_lower(temp1));
+ if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
+ snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
+ pet_db[i].jname);
+ if (cnt >= 100) { // Only if there are custom pets
+ clif_displaymessage(fd, "Be more specific, can't send more than"
+ " 100 results.");
+ } else {
+ clif_displaymessage(fd, temp0);
+ }
+ cnt++;
+ }
+ i++;
+ }
+ snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
+ clif_displaymessage(fd, temp0);
+ return 0;
+}
+
+/*==========================================
+ * @identify
+ * => GM's magnifier.
+ *------------------------------------------
+ */
+int
+atcommand_identify(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int i,num;
+
+ nullpo_retr(-1, sd);
+
+ for(i=num=0;i<MAX_INVENTORY;i++){
+ if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
+ num++;
+ }
+ }
+ if (num > 0) {
+ clif_item_identify_list(sd);
+ } else {
+ clif_displaymessage(fd,"There are no items to appraise.");
+ }
+ return 0;
+}
+
+/*==========================================
+ * @gmotd (Global MOTD)
+ * by davidsiaw :P
+ *------------------------------------------
+ */
+int
+atcommand_gmotd(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char buf[256];
+ FILE *fp;
+ nullpo_retr(-1, sd);
+ if( (fp = fopen(motd_txt, "r"))!=NULL){
+ while (fgets(buf, 250, fp) != NULL){
+ int i;
+ for( i=0; buf[i]; i++){
+ if( buf[i]=='\r' || buf[i]=='\n'){
+ buf[i]=0;
+ break;
+ }
+ }
+ intif_GMmessage(buf,strlen(buf)+1,8);
+ }
+ fclose(fp);
+ }
+ return 0;
+}
+
+int atcommand_misceffect(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int effect = 0;
+ nullpo_retr(-1, sd);
+ if (!message || !*message)
+ return -1;
+ if (sscanf(message, "%d", &effect) < 1)
+ return -1;
+ clif_misceffect(&sd->bl,effect);
+
+ return 0;
+}
+
+/*==========================================
+ * Jump to a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+
+int atcommand_jumptoid(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int cid=0;
+ struct map_session_data *pl_sd;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
+ return -1;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Jump to a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+
+int atcommand_jumptoid2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int aid=0;
+ struct map_session_data *pl_sd;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
+ return -1;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Recall a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_recallid(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int cid=0;
+ struct map_session_data *pl_sd;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
+ return -1;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Recall a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_recallid2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int aid=0;
+ struct map_session_data *pl_sd;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
+ return -1;
+ }
+
+ 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 (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;
+}
+
+/*==========================================
+ * Kick a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_kickid(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ int cid=0;
+
+ 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;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Kick a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_kickid2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd;
+ int aid=0;
+
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
+ return -1;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Revive a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_reviveid(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int cid=0;
+ struct map_session_data *pl_sd;
+
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
+ return -1;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Revive a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_reviveid2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int aid=0;
+ struct map_session_data *pl_sd;
+
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
+ return -1;
+ }
+
+ pl_sd = map_id2sd(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;
+}
+
+/*==========================================
+ * Kill a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_killid(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int cid=0;
+ struct map_session_data *pl_sd;
+
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
+ return -1;
+ }
+
+ pl_sd = map_charid2sd(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;
+}
+
+/*==========================================
+ * Kill a player by PID number
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int atcommand_killid2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int aid=0;
+ struct map_session_data *pl_sd;
+
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
+ return -1;
+ }
+
+ 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;
+}
+
+/*==========================================
+ * Make a player killable, by PID
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int
+atcommand_charkillableid(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int cid=0;
+
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID.");
+ return -1;
+ }
+
+ pl_sd = map_charid2sd(cid);
+
+ 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;
+ if(pl_sd->state.killable)
+ clif_displaymessage(fd, msg_txt(289));
+ else
+ clif_displaymessage(fd, msg_txt(290));
+ return 0;
+}
+
+
+/*==========================================
+ * Make a player killable, by PID
+ * Original by Dino9021
+ * Added in by nsstrunks
+ *------------------------------------------
+ */
+int
+atcommand_charkillableid2(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct map_session_data *pl_sd = NULL;
+ int aid=0;
+
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID.");
+ return -1;
+ }
+
+ 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))
+ {
+ 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;
+
+ if(pl_sd->state.killable)
+ clif_displaymessage(fd, msg_txt(289));
+ else
+ clif_displaymessage(fd, msg_txt(290));
+
+ return 0;
+}
+
+#ifndef TXT_ONLY /* Begin SQL-Only commands */
+
+/*==========================================
+ * Mail System commands by [Valaris]
+ *------------------------------------------
+ */
+int atcommand_listmail(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if(!mail_server_enable)
+ return 0;
+
+ nullpo_retr(-1, sd);
+
+ if(strlen(command)==12)
+ mail_check(sd,3);
+ else if(strlen(command)==9)
+ mail_check(sd,2);
+ else
+ mail_check(sd,1);
+ return 0;
+}
+
+int atcommand_readmail(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int index;
+ if(!mail_server_enable)
+ return 0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(sd->fd,"You must specify a message number.");
+ return 0;
+ }
+
+ index = atoi(message);
+ if (index < 1) {
+ clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
+ return 0;
+ }
+
+ if(strlen(command)==11)
+ mail_delete(sd,index);
+ else
+ mail_read(sd,index);
+
+ return 0;
+}
+
+int atcommand_sendmail(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char name[NAME_LENGTH],text[80];
+
+ if(!mail_server_enable)
+ return 0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message) {
+ clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
+ return 0;
+ }
+
+ if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
+ (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
+ clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
+ return 0;
+ }
+
+ if(strlen(command)==17)
+ mail_send(sd,name,text,1);
+ else
+ mail_send(sd,name,text,0);
+
+ return 0;
+}
+
+/*==========================================
+ * Refresh online command for SQL [Valaris]
+ * Will refresh and check online column of
+ * players and set correctly.
+ *------------------------------------------
+ */
+int atcommand_refreshonline(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ send_users_tochar(-1, gettick(), 0, 0);
+ return 0;
+}
+
+#endif /* end sql only */
+
+/*==========================================
+ * Show Monster DB Info v 1.0
+ * originally by [Lupus] eAthena
+ *------------------------------------------
+ */
+int atcommand_mobinfo(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ unsigned char msize[3][7] = {"Small", "Medium", "Large"};
+ unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
+ unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
+ char atcmd_output2[200];
+ struct item_data *item_data;
+ struct mob_db *mob, *mob_array[MAX_SEARCH];
+ int count;
+ int i, j, k;
+
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output2, '\0', sizeof(atcmd_output2));
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
+ return -1;
+ }
+
+ // If monster identifier/name argument is a name
+ if ((i = mobdb_checkid(atoi(message))))
+ {
+ mob_array[0] = mob_db(i);
+ count = 1;
+ } else
+ count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
+
+ if (!count) {
+ clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
+ return -1;
+ }
+
+ if (count > MAX_SEARCH) {
+ sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
+ clif_displaymessage(fd, atcmd_output);
+ count = MAX_SEARCH;
+ }
+ for (k = 0; k < count; k++) {
+ mob = mob_array[k];
+
+ // stats
+ if (mob->mexp)
+ sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
+ else
+ sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
+ clif_displaymessage(fd, atcmd_output);
+ sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
+ clif_displaymessage(fd, atcmd_output);
+ sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
+ mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
+ mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
+ clif_displaymessage(fd, atcmd_output);
+
+ sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
+ mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
+ mob->range2 , mob->range3, msize[mob->status.size],
+ mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
+ clif_displaymessage(fd, atcmd_output);
+ // drops
+ clif_displaymessage(fd, " Drops:");
+ strcpy(atcmd_output, " ");
+ j = 0;
+ for (i = 0; i < MAX_MOB_DROP; i++) {
+ if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
+ continue;
+ if (item_data->slot)
+ sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
+ else
+ sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
+ strcat(atcmd_output, atcmd_output2);
+ if (++j % 3 == 0) {
+ clif_displaymessage(fd, atcmd_output);
+ strcpy(atcmd_output, " ");
+ }
+ }
+ if (j == 0)
+ clif_displaymessage(fd, "This monster has no drops.");
+ else if (j % 3 != 0)
+ clif_displaymessage(fd, atcmd_output);
+ // mvp
+ if (mob->mexp) {
+ sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
+ clif_displaymessage(fd, atcmd_output);
+ strcpy(atcmd_output, " MVP Items:");
+ j = 0;
+ for (i = 0; i < 3; i++) {
+ if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
+ continue;
+ if (mob->mvpitem[i].p > 0) {
+ j++;
+ if (j == 1)
+ sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
+ else
+ sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
+ strcat(atcmd_output, atcmd_output2);
+ }
+ }
+ if (j == 0)
+ clif_displaymessage(fd, "This monster has no MVP prizes.");
+ else
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+ return 0;
+}
+
+/*=========================================
+* @showmobs by KarLaeda
+* => For 5 sec displays the mobs on minimap
+*------------------------------------------
+*/
+int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
+{
+ struct map_session_data *sd;
+
+ if (!session[id] || (sd = session[id]->session_data) == NULL)
+ return 0;
+
+ clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
+ return 1;
+}
+static int atshowmobs_sub(struct block_list *bl,va_list ap)
+{
+ int mob_id,fd;
+ struct map_session_data* sd;
+ static int number=0;
+ struct mob_data *md;
+
+ if(!ap){
+ number=0;
+ return 0;
+ }
+ mob_id = va_arg(ap,int);
+ fd = va_arg(ap,int);
+ sd = va_arg(ap,struct map_session_data*);
+
+ md = (struct mob_data *)bl;
+
+ if(md->special_state.ai || md->master_id)
+ return 0; //Hide slaves and player summoned mobs. [Skotlex]
+
+ if(fd && (mob_id==-1 || (md->class_==mob_id))){
+ clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
+ add_timer(gettick()+5000, atshowmobs_timer, fd, number);
+ }
+ return 0;
+}
+int atcommand_showmobs(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char mob_name[100];
+ int mob_id,map_id = 0;
+
+ nullpo_retr(-1, sd);
+
+ if (sscanf(message, "%99[^\n]", mob_name) < 0)
+ return -1;
+
+ if ((mob_id = atoi(mob_name)) == 0)
+ mob_id = mobdb_searchname(mob_name);
+ if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
+ snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+// Uncomment the following line to show mini-bosses & MVP.
+//#define SHOW_MVP
+#ifndef SHOW_MVP
+ if(mob_db(mob_id)->status.mode&MD_BOSS){
+ snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+#endif
+ if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
+ strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
+// strcpy(mob_name,mob_db(mob_id)->name); // --en--
+
+ map_id = sd->bl.m;
+
+ snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
+ mob_name, mapindex_id2name(sd->mapindex));
+ clif_displaymessage(fd, atcmd_output);
+
+ map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
+
+ atshowmobs_sub(&sd->bl,0);
+
+ return 0;
+}
+
+/*==========================================
+ * homunculus level up [orn]
+ *------------------------------------------
+ */
+int atcommand_homlevel(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ TBL_HOM * hd;
+ int level = 0, i = 0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if ( !merc_is_hom_active(sd->hd) )
+ return 1 ;
+
+ level = atoi(message);
+ hd = sd->hd;
+
+ for (i = 1; i <= level && hd->exp_next; i++){
+ hd->homunculus.exp += hd->exp_next;
+ merc_hom_levelup(hd);
+ }
+ status_calc_homunculus(hd,0);
+ status_percent_heal(&hd->bl, 100, 100);
+ clif_misceffect2(&hd->bl,568);
+ return 0;
+}
+
+/*==========================================
+ * homunculus evolution H [orn]
+ *------------------------------------------
+ */
+int atcommand_homevolution(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ if (sd->hd && sd->hd->homunculusDB->evo_class)
+ {
+ merc_hom_evolution(sd->hd) ;
+ }
+ return 0;
+}
+
+/*==========================================
+ * call choosen homunculus [orn]
+ *------------------------------------------
+ */
+int
+atcommand_makehomun(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int homunid;
+ nullpo_retr(-1, sd);
+ if(sscanf(message, "%d", &homunid)<1)
+ return -1;
+ if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
+ return -1;
+ if(sd->status.hom_id == 0)
+ {
+ merc_create_homunculus_request(sd,homunid);
+ }
+ else
+ {
+ clif_displaymessage(fd,msg_txt(450));
+ }
+ return 0;
+}
+
+/*==========================================
+ * modify homunculus intimacy [orn]
+ *------------------------------------------
+ */
+int atcommand_homfriendly(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int friendly = 0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ friendly = atoi(message);
+ if (merc_is_hom_active(sd->hd)) {
+ if (friendly > 0 && friendly <= 1000) {
+ sd->hd->homunculus.intimacy = friendly * 100 ;
+ clif_send_homdata(sd,SP_INTIMATE,friendly);
+ } else {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * modify homunculus hunger [orn]
+ *------------------------------------------
+ */
+int atcommand_homhungry(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int hungry = 0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ hungry = atoi(message);
+ if (sd->status.hom_id > 0 && sd->hd) {
+ struct homun_data *hd = sd->hd;
+ if (hungry >= 0 && hungry <= 100) {
+ hd->homunculus.hunger = hungry;
+ clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
+ } else {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * modify homunculus hunger [orn]
+ *------------------------------------------
+ */
+int atcommand_homtalk(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char mes[100],temp[100];
+
+ nullpo_retr(-1, sd);
+
+ if(!merc_is_hom_active(sd->hd))
+ return -1;
+
+ if (sscanf(message, "%99[^\n]", mes) < 1)
+ return -1;
+
+ snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
+ clif_message(&sd->hd->bl, temp);
+
+ return 0;
+}
+
+/*==========================================
+ * Show homunculus stats
+ *------------------------------------------
+ */
+int atcommand_hominfo(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct homun_data *hd;
+ struct status_data *status;
+ nullpo_retr(-1, sd);
+
+ if(!merc_is_hom_active(sd->hd))
+ return -1;
+ hd = sd->hd;
+ status = status_get_status_data(&hd->bl);
+ clif_displaymessage(fd, "Homunculus stats :");
+
+ snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
+ status->hp, status->max_hp, status->sp, status->max_sp);
+ clif_displaymessage(fd, atcmd_output);
+
+ snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
+ status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
+ clif_displaymessage(fd, atcmd_output);
+
+ snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
+ hd->homunculus.hunger, hd->homunculus.intimacy/100);
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+
+/*==========================================
+ * Show Items DB Info v 1.0
+ * originally by [Lupus] eAthena
+ *------------------------------------------
+ */
+int atcommand_iteminfo(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
+ //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
+
+ struct item_data *item_data, *item_array[MAX_SEARCH];
+ int i, count = 1;
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
+ return -1;
+ }
+ if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
+ count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
+
+ if (!count) {
+ clif_displaymessage(fd, "Item not found.");
+ return -1;
+ }
+
+ if (count > MAX_SEARCH) {
+ sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
+ clif_displaymessage(fd, atcmd_output);
+ count = MAX_SEARCH;
+ }
+ for (i = 0; i < count; i++) {
+ item_data = item_array[i];
+ sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
+ item_data->name,item_data->jname,item_data->slot,item_data->nameid,
+ item_data->type < 12 ? itype[item_data->type] : "BUG!",
+ (item_data->script==NULL)? "None" : "With script"
+ );
+ clif_displaymessage(fd, atcmd_output);
+
+ sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
+ clif_displaymessage(fd, atcmd_output);
+
+ if (item_data->maxchance == 10000)
+ strcpy(atcmd_output, " - Available in the shops only");
+ else if (item_data->maxchance)
+ sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
+ else
+ strcpy(atcmd_output, " - Monsters don't drop this item");
+ clif_displaymessage(fd, atcmd_output);
+
+ }
+ return 0;
+}
+
+/*==========================================
+ * Show who drops the item.
+ *------------------------------------------
+ */
+int atcommand_whodrops(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ struct item_data *item_data, *item_array[MAX_SEARCH];
+ int i,j, count = 1;
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
+ return -1;
+ }
+ if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
+ count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
+
+ if (!count) {
+ clif_displaymessage(fd, "Item not found.");
+ return -1;
+ }
+
+ if (count > MAX_SEARCH) {
+ sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
+ clif_displaymessage(fd, atcmd_output);
+ count = MAX_SEARCH;
+ }
+ for (i = 0; i < count; i++) {
+ item_data = item_array[i];
+ sprintf(atcmd_output, "Item: '%s'[%d]",
+ item_data->jname,item_data->slot);
+ clif_displaymessage(fd, atcmd_output);
+
+ if (item_data->mob[0].chance == 0) {
+ strcpy(atcmd_output, " - Item is not dropped by mobs.");
+ clif_displaymessage(fd, atcmd_output);
+ } else {
+ sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
+ clif_displaymessage(fd, atcmd_output);
+
+ for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
+ {
+ sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+ }
+ return 0;
+}
+
+/*==========================================
+ * @adopt by [Veider]
+ *
+ * adopt a novice
+ *------------------------------------------
+ */
+int
+atcommand_adopt(const int fd, struct map_session_data* sd,
+const char* command, const char* message)
+{
+ struct map_session_data *pl_sd1 = NULL;
+ struct map_session_data *pl_sd2 = NULL;
+ struct map_session_data *pl_sd3 = NULL;
+ char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
+ clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
+ return -1;
+ }
+
+ if (battle_config.etc_log)
+ printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
+
+ if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
+ sprintf(player2, "Cannot find player %s online", player1);
+ clif_displaymessage(fd, player2);
+ return -1;
+ }
+
+ if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
+ sprintf(player1, "Cannot find player %s online", player2);
+ clif_displaymessage(fd, player1);
+ return -1;
+ }
+
+ if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
+ sprintf(player1, "Cannot find player %s online", player3);
+ clif_displaymessage(fd, player1);
+ return -1;
+ }
+
+ if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
+ clif_displaymessage(fd, "They are too young to be parents!");
+ return -1;
+ }
+
+ if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
+ clif_displaymessage(fd, "They are family.. wish them luck");
+ return 0;
+ }
+ else
+ return -1;
+}
+
+int atcommand_version(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ const char * revision;
+
+ if ((revision = get_svn_revision()) != 0) {
+ sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
+ clif_displaymessage(fd,atcmd_output);
+ } else
+ clif_displaymessage(fd,"Cannot determine SVN revision");
+
+ return 0;
+}
+
+
+static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
+{
+
+ int time, id;
+ struct map_session_data *pl_sd = (struct map_session_data *)bl;
+ if (pl_sd == NULL)
+ return 0;
+
+ id = va_arg(ap, int);
+ time = va_arg(ap, int);
+
+ if (id != bl->id && !pc_isGM(pl_sd)) {
+ pl_sd->status.manner -= time;
+ if (pl_sd->status.manner < 0)
+ sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
+ else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
+ status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
+ }
+ return 0;
+}
+
+/*==========================================
+ * @mutearea by MouseJstr
+ *------------------------------------------
+ */
+int atcommand_mutearea(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int time;
+ nullpo_retr(0, sd);
+
+ time = atoi(message);
+ if (!time)
+ time = 15; // 15 minutes default
+ map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
+ sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
+ sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
+
+ return 0;
+}
+
+static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
+{
+ struct map_session_data *pl_sd = (struct map_session_data *) bl;
+ if (bl == NULL)
+ return 0;
+
+ if (!pc_isGM(pl_sd))
+ pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
+
+ return 0;
+}
+
+/*==========================================
+ * @shuffle by MouseJstr
+ *------------------------------------------
+ */
+int atcommand_shuffle(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(0, sd);
+
+ if (strcmp(message, "area")== 0) {
+ map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
+ sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
+ sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
+ } else if (strcmp(message, "map")== 0) {
+ map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
+ } else if (strcmp(message, "world") == 0) {
+ struct map_session_data **pl_allsd;
+ int i, users;
+ pl_allsd = map_getallusers(&users);
+ for (i = 0; i < users; i++)
+ atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
+ } else
+ clif_displaymessage(fd, "options are area, map, or world");
+
+ return 0;
+}
+
+int atcommand_rates(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char buf[255];
+
+ nullpo_retr(0, sd);
+
+ sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
+ battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
+
+ clif_displaymessage(fd, buf);
+
+ return 0;
+}
+
+/*==========================================
+ * @me by lordalfa
+ * => Displays the OUTPUT string on top of
+ * the Visible players Heads.
+ *------------------------------------------
+ */
+
+int atcommand_me(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char tempmes[200];
+ nullpo_retr(-1, sd);
+
+ malloc_tsetdword(tempmes, '\0', sizeof(tempmes));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+
+ if (sd->sc.count && //no "chatting" while muted.
+ (sd->sc.data[SC_BERSERK].timer!=-1 ||
+ (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
+ return -1;
+
+ if (!message || !*message) {
+ clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
+ return -1;
+ }
+
+ sscanf(message, "%199[^\n]", tempmes);
+ sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
+ clif_disp_overhead(sd, atcmd_output);
+
+ return 0;
+
+}
+
+/*==========================================
+ * @size
+ * => Resize your character sprite. [Valaris]
+ *------------------------------------------
+ */
+int atcommand_size(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int size=0;
+
+ nullpo_retr(-1, sd);
+
+ if (!message || !*message)
+ return -1;
+
+ if (sscanf(message,"%d", &size) < 1)
+ return -1;
+
+ if(sd->state.size) {
+ sd->state.size=0;
+ pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
+ }
+
+ if(size==1) {
+ sd->state.size=1;
+ clif_specialeffect(&sd->bl,420,AREA);
+ } else if(size==2) {
+ sd->state.size=2;
+ clif_specialeffect(&sd->bl,422,AREA);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * @monsterignore
+ * => Makes monsters ignore you. [Valaris]
+ *------------------------------------------
+ */
+
+int atcommand_monsterignore(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ nullpo_retr(-1, sd);
+
+ if (!sd->state.monster_ignore) {
+ sd->state.monster_ignore = 1;
+ clif_displaymessage(sd->fd, "You are now inmune to attacks.");
+ } else {
+ sd->state.monster_ignore = 0;
+ clif_displaymessage(sd->fd, "Returned to normal state.");
+ }
+
+ return 0;
+}
+/*==========================================
+ * @fakename
+ * => Gives your character a fake name. [Valaris]
+ *------------------------------------------
+ */
+int atcommand_fakename(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+
+ char name[NAME_LENGTH];
+ nullpo_retr(-1, sd);
+
+ if((!message || !*message) && strlen(sd->fakename) > 1) {
+ sd->fakename[0]='\0';
+ clif_charnameack(0, &sd->bl);
+ clif_displaymessage(sd->fd,"Returned to real name.");
+ return 0;
+ }
+
+ if (!message || !*message) {
+ clif_displaymessage(sd->fd,"You must enter a name.");
+ return 0;
+ }
+
+
+ if (sscanf(message, "%23[^\n]", name) < 1) {
+ return 0;
+ }
+
+ if(strlen(name) < 2) {
+ clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
+ return 0;
+ }
+
+ memcpy(sd->fakename,name,NAME_LENGTH-1);
+ clif_charnameack(0, &sd->bl);
+ clif_displaymessage(sd->fd,"Fake name enabled.");
+
+ return 0;
+}
+/*==========================================
+ * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
+ * => Shows information about the map flags [map name]
+ * Also set flags
+ *------------------------------------------
+ */
+int atcommand_mapflag(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+// WIP
+ return 0;
+}
+
+/*===================================
+ * Remove some messages
+ *-----------------------------------
+ */
+int atcommand_showexp(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if (sd->state.showexp) {
+ sd->state.showexp = 0;
+ clif_displaymessage(fd, "Gained exp will not be shown.");
+ return 0;
+ }
+
+ sd->state.showexp = 1;
+ clif_displaymessage(fd, "Gained exp is now shown");
+ return 0;
+}
+
+int atcommand_showzeny(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if (sd->state.showzeny) {
+ sd->state.showzeny = 0;
+ clif_displaymessage(fd, "Gained zeny will not be shown.");
+ return 0;
+ }
+
+ sd->state.showzeny = 1;
+ clif_displaymessage(fd, "Gained zeny is now shown");
+ return 0;
+}
+
+int atcommand_showdelay(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if (sd->state.showdelay) {
+ sd->state.showdelay = 0;
+ clif_displaymessage(fd, "Skill delay failures won't be shown.");
+ return 0;
+ }
+
+ sd->state.showdelay = 1;
+ clif_displaymessage(fd, "Skill delay failures are shown now.");
+ return 0;
+}
+
+/*==========================================
+ * Duel organizing functions [LuzZza]
+ *
+ * @duel [limit|nick] - create a duel
+ * @invite <nick> - invite player
+ * @accept - accept invitation
+ * @reject - reject invitation
+ * @leave - leave duel
+ *------------------------------------------
+ */
+int atcommand_invite(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ unsigned int did = sd->duel_group;
+ struct map_session_data *target_sd = map_nick2sd((char *)message);
+
+ if(did <= 0) {
+ // "Duel: @invite without @duel."
+ clif_displaymessage(fd, msg_txt(350));
+ return 0;
+ }
+
+ if(duel_list[did].max_players_limit > 0 &&
+ duel_list[did].members_count >= duel_list[did].max_players_limit) {
+
+ // "Duel: Limit of players is reached."
+ clif_displaymessage(fd, msg_txt(351));
+ return 0;
+ }
+
+ if(target_sd == NULL) {
+ // "Duel: Player not found."
+ clif_displaymessage(fd, msg_txt(352));
+ return 0;
+ }
+
+ if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
+ // "Duel: Player already in duel."
+ clif_displaymessage(fd, msg_txt(353));
+ return 0;
+ }
+
+ if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
+ {
+ sprintf(atcmd_output, msg_txt(364), message);
+ clif_displaymessage(fd, atcmd_output);
+ return 0;
+ }
+
+ duel_invite(did, sd, target_sd);
+ // "Duel: Invitation has been sent."
+ clif_displaymessage(fd, msg_txt(354));
+ return 0;
+}
+
+int atcommand_duel(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char output[256];
+ unsigned int maxpl=0, newduel;
+ struct map_session_data *target_sd;
+
+ /* // Commnted because it can be disabled in at-comms conf.
+ if(!battle_config.duel_enable) {
+ clif_displaymessage(fd, "Duel: duel is disable.");
+ return 0;
+ }
+ */
+
+ if(sd->duel_group > 0) {
+ duel_showinfo(sd->duel_group, sd);
+ return 0;
+ }
+
+ if(sd->duel_invite > 0) {
+ // "Duel: @duel without @reject."
+ clif_displaymessage(fd, msg_txt(355));
+ return 0;
+ }
+
+ if(!duel_checktime(sd)) {
+ // "Duel: You can take part in duel only one time per %d minutes."
+ sprintf(output, msg_txt(356), battle_config.duel_time_interval);
+ clif_displaymessage(fd, output);
+ return 0;
+ }
+
+ if(strlen(message) > 0) {
+ if(sscanf(message, "%d", &maxpl) >= 1) {
+ if(maxpl < 2 || maxpl > 65535) {
+ clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
+ return 0;
+ }
+ duel_create(sd, maxpl);
+ } else {
+ target_sd = map_nick2sd((char *)message);
+ if(target_sd != NULL) {
+ if((newduel = duel_create(sd, 2)) != -1) {
+ if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
+ clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
+ return 0;
+ }
+ duel_invite(newduel, sd, target_sd);
+ clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
+ }
+ } else {
+ // "Duel: Player not found."
+ clif_displaymessage(fd, msg_txt(352));
+ return 0;
+ }
+ }
+ } else
+ duel_create(sd, 0);
+
+ return 0;
+}
+
+
+int atcommand_leave(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if(sd->duel_group <= 0) {
+ // "Duel: @leave without @duel."
+ clif_displaymessage(fd, msg_txt(358));
+ return 0;
+ }
+
+ duel_leave(sd->duel_group, sd);
+ clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
+ return 0;
+}
+
+int atcommand_accept(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char output[256];
+
+ if(!duel_checktime(sd)) {
+ // "Duel: You can take part in duel only one time per %d minutes."
+ sprintf(output, msg_txt(356), battle_config.duel_time_interval);
+ clif_displaymessage(fd, output);
+ return 0;
+ }
+
+ if(sd->duel_invite <= 0) {
+ // "Duel: @accept without invititation."
+ clif_displaymessage(fd, msg_txt(360));
+ return 0;
+ }
+
+ duel_accept(sd->duel_invite, sd);
+ // "Duel: Invitation has been accepted."
+ clif_displaymessage(fd, msg_txt(361));
+ return 0;
+}
+
+int atcommand_reject(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if(sd->duel_invite <= 0) {
+ // "Duel: @reject without invititation."
+ clif_displaymessage(fd, msg_txt(362));
+ return 0;
+ }
+
+ duel_reject(sd->duel_invite, sd);
+ // "Duel: Invitation has been rejected."
+ clif_displaymessage(fd, msg_txt(363));
+ return 0;
+}
+
+/*===================================
+ * Away message (@away, @aw) [LuzZza]
+ *-----------------------------------
+ */
+int atcommand_away(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if(strlen(message) > 0) {
+ if(strlen(message) > 128)
+ return -1;
+ strcpy(sd->away_message, message);
+ //"Away automessage has been activated."
+ clif_displaymessage(fd, msg_txt(546));
+ } else {
+ if(strlen(sd->away_message) > 0) {
+ sd->away_message[0] = 0;
+ //"Away automessage has been disabled."
+ clif_displaymessage(fd, msg_txt(547));
+ return 0;
+ }
+ //"Usage: @away,@aw <message>. Enter empty message for disable it."
+ clif_displaymessage(fd, msg_txt(548));
+ }
+ return 0;
+}
+
+// @clone/@slaveclone/@evilclone <playername> [Valaris]
+int atcommand_clone(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ int x=0,y=0,flag=0,master=0,i=0;
+ struct map_session_data *pl_sd=NULL;
+
+ if (!message || !*message) {
+ clif_displaymessage(sd->fd,"You must enter a name or character ID.");
+ return 0;
+ }
+
+ if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
+ clif_displaymessage(fd, msg_txt(3));
+ return 0;
+ }
+
+ if(pc_isGM(pl_sd) > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(126));
+ return 0;
+ }
+
+ if (strcmpi(command, "@clone") == 0)
+ flag = 1;
+ else if (strcmpi(command, "@slaveclone") == 0) {
+ flag = 2;
+ master = sd->bl.id;
+ if (battle_config.atc_slave_clone_limit
+ && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
+ clif_displaymessage(fd, msg_txt(127));
+ return 0;
+ }
+ }
+
+ do {
+ x = sd->bl.x + (rand() % 10 - 5);
+ y = sd->bl.y + (rand() % 10 - 5);
+ } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
+
+ if (i >= 10) {
+ x = sd->bl.x;
+ y = sd->bl.y;
+ }
+
+ if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
+ clif_displaymessage(fd, msg_txt(128+flag*2));
+ return 0;
+ }
+ clif_displaymessage(fd, msg_txt(129+flag*2));
+ return 0;
+}
+
+/*===================================
+ * Main chat [LuzZza]
+ * Usage: @main <on|off|message>
+ *-----------------------------------
+ */
+int atcommand_main(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if(strlen(message) > 0) {
+
+ if(strcmpi(message, "on") == 0) {
+ if(!sd->state.mainchat) {
+ sd->state.mainchat = 1;
+ clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
+ } else {
+ clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
+ }
+ } else if(strcmpi(message, "off") == 0) {
+ if(sd->state.mainchat) {
+ sd->state.mainchat = 0;
+ clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
+ } else {
+ clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
+ }
+ } else {
+ if(!sd->state.mainchat) {
+ sd->state.mainchat = 1;
+ clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
+ }
+ if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
+ clif_displaymessage(fd, msg_txt(387));
+ return -1;
+ }
+ sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
+ // I use 0xFE000000 color for signalizing that this message is
+ // main chat message. 0xFE000000 is invalid color, same using
+ // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
+ intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
+ }
+
+ } else {
+
+ if(sd->state.mainchat)
+ // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
+ clif_displaymessage(fd, msg_txt(384));
+ else
+ // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
+ clif_displaymessage(fd, msg_txt(385));
+ }
+ return 0;
+}
+
+/*=====================================
+ * Autorejecting Invites/Deals [LuzZza]
+ * Usage: @noask
+ *-------------------------------------
+ */
+int atcommand_noask(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+
+ if(sd->state.noask) {
+ clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
+ sd->state.noask = 0;
+ } else {
+ clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
+ sd->state.noask = 1;
+ }
+
+ return 0;
+}
+
+/*=====================================
+ * Send a @request message to all GMs of lowest_gm_level.
+ * Usage: @request <petition>
+ *-------------------------------------
+ */
+int atcommand_request(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ if (!message || !*message) {
+ clif_displaymessage(sd->fd,msg_txt(277));
+ return -1;
+ }
+
+ sprintf(atcmd_output, msg_txt(278), message);
+ intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
+ clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
+ clif_displaymessage(sd->fd,msg_txt(279));
+ return 0;
+}
+
+void do_init_atcommand() {
+ users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
+ duel_count = 0;
+ malloc_tsetdword(&duel_list[0], 0, sizeof(duel_list));
+ add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
+ return;
+}
+
+void do_final_atcommand() {
+ users_db->destroy(users_db,NULL);
+}
diff --git a/src/map/clif.c b/src/map/clif.c
index 825fabb8b..69b7d1af8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1,12342 +1,12301 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#define DUMP_UNKNOWN_PACKET 0
-#define DUMP_ALL_PACKETS 0
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <time.h>
-
-#include "../common/socket.h"
-#include "../common/timer.h"
-#include "../common/malloc.h"
-#include "../common/version.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-
-#include "map.h"
-#include "chrif.h"
-#include "clif.h"
-#include "pc.h"
-#include "status.h"
-#include "npc.h"
-#include "itemdb.h"
-#include "chat.h"
-#include "trade.h"
-#include "storage.h"
-#include "script.h"
-#include "skill.h"
-#include "atcommand.h"
-#include "charcommand.h"
-#include "intif.h"
-#include "battle.h"
-#include "mob.h"
-#include "party.h"
-#include "unit.h"
-#include "guild.h"
-#include "vending.h"
-#include "pet.h"
-#include "mercenary.h" //[orn]
-#include "log.h"
-
-#include "irc.h"
-
-struct Clif_Config {
- int packet_db_ver; //Preferred packet version.
- int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex]
-} clif_config;
-
-struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
-
-static const int packet_len_table[MAX_PACKET_DB] = {
- 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-//#0x0040
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
-#if PACKETVER < 2
- 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6,
-#else // 78-7b 亀島以降 lv99エフェクト用
- 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
-#endif
-//#0x0080
- 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 2, -1, -1, -1, 0, // 0x8b changed to 2 (was 23)
- 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6,
- 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6,
- 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3,
-//#0x00C0
- 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 3, 2, 27, // 0xcd change to 3 (was 6)
- 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1,
- 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2,
- 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10,
-
-//#0x0100
- 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1,
- 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16,
- 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1,
- 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26,
-//#0x0140
- 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6,
- 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42,
- -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14,186,182,
- 14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
-//#0x0180
- 6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
-#if PACKETVER < 1
- 90, 86, 24, 6, 30,102, 8, 4, 8, 4, 14, 10, -1, 6, 2, 6,
-#else // 196 comodo以降 状態表示アイコン用
- 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, -1, 6, 2, 6,
-#endif
- 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
- 11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
-//#0x01C0, Set 0x1d5=-1
- 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 3, 9, 9, 30, 6, 28,
- 8, 14, 10, 35, 6, -1, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
- 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
- -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
-//#0x200
- 26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 32, 10, // 0x20c change to 0 (was 19)
- 22, 0, 26, 26, 42, 6, 6, 2, 2,282,282,10, 10, -1, -1, 66,
- 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 64, 5, 71, 5,
- 12, 26, 9, 11, -1, -1, 10, 2, 282, 11, 4, 36, -1,-1, 4, 2,
- -1, -1, -1, -1, -1, 3, 4, 8, -1, 3, 70, 4, 8,12, 4, 10,
- 3, 32, -1, 3, 3, 5, 5, 8, 2, 3, -1, -1, 4,-1, 4
-};
-
-//Converts item type in case of pet eggs.
-#define itemtype(a) (a == 7)?4:a
-
-#define WBUFPOS(p,pos,x,y,dir) { unsigned char *__p = (p); __p+=(pos); __p[0] = (x)>>2; __p[1] = ((x)<<6) | (((y)>>4)&0x3f); __p[2] = ((y)<<4)|((dir)&0xf); }
-#define WBUFPOS2(p,pos,x0,y0,x1,y1) { unsigned char *__p = (p); __p+=(pos); __p[0] = (unsigned char)((x0)>>2); __p[1] = (unsigned char)(((x0)<<6) | (((y0)>>4)&0x3f)); __p[2] = (unsigned char)(((y0)<<4) | (((x1)>>6)&0x0f)); __p[3]=(unsigned char)(((x1)<<2) | (((y1)>>8)&0x03)); __p[4]=(unsigned char)(y1); }
-
-#define WFIFOPOS(fd,pos,x,y,dir) { WBUFPOS (WFIFOP(fd,pos),0,x,y,dir); }
-#define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); }
-
-//To make the assignation of the level based on limits clearer/easier. [Skotlex]
-#define clif_setlevel(lv) (lv<battle_config.max_lv?lv:battle_config.max_lv-(lv<battle_config.aura_lv?1:0));
-
-//Removed sd->npc_shopid because there is no packet sent from the client when you cancel a buy!
-//Quick check to know if the player shouldn't be "busy" with something else to deny action requests. [Skotlex]
-#define clif_cant_act(sd) (sd->npc_id || sd->vender_id || sd->chatID || sd->sc.opt1 || sd->state.trading || sd->state.storage_flag)
-
-// Checks if SD is in a trade/shop (where messing with the inventory can cause problems/exploits)
-#define clif_trading(sd) (sd->npc_id || sd->vender_id || sd->state.trading )
-
-//To idenfity disguised characters.
-#define disguised(bl) (bl->type==BL_PC && ((TBL_PC*)bl)->disguise)
-static char map_ip_str[128];
-static in_addr_t map_ip;
-static in_addr_t bind_ip = INADDR_ANY;
-static int map_port = 5121;
-int map_fd;
-char talkie_mes[MESSAGE_SIZE];
-
-//These two will be used to verify the incoming player's validity.
-//It helps identify their client packet version correctly. [Skotlex]
-static int max_account_id = DEFAULT_MAX_ACCOUNT_ID;
-static int max_char_id = DEFAULT_MAX_CHAR_ID;
-
-int clif_parse (int fd);
-static void clif_hpmeter_single(int fd, struct map_session_data *sd);
-
-/*==========================================
- * map鯖のip設定
- *------------------------------------------
- */
-int clif_setip(char *ip)
-{
- char ip_str[16];
- map_ip = resolve_hostbyname(ip,NULL,ip_str);
- if (!map_ip) {
- ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
- return 0;
- }
-
- strncpy(map_ip_str, ip, sizeof(map_ip_str));
- ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip_str);
- return 1;
-}
-
-void clif_setbindip(char *ip)
-{
- unsigned char ip_str[4];
- bind_ip = resolve_hostbyname(ip,ip_str,NULL);
- if (bind_ip) {
- ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip, ip_str[0], ip_str[1], ip_str[2], ip_str[3]);
- } else {
- ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
- }
-}
-
-/*==========================================
- * map鯖のport設定
- *------------------------------------------
- */
-void clif_setport(int port)
-{
- map_port = port;
-}
-
-/*==========================================
- * map鯖のip読み出し
- *------------------------------------------
- */
-in_addr_t clif_getip(void)
-{
- return map_ip;
-}
-
-//Returns the ip casted as a basic type, to avoid needing to include the socket/net related libs by calling modules.
-unsigned long clif_getip_long(void)
-{
- return (unsigned long)map_ip;
-}
-
-//Refreshes map_server ip, returns the new ip if the ip changed, otherwise it
-//returns 0.
-unsigned long clif_refresh_ip(void) {
- in_addr_t new_ip;
-
- new_ip = resolve_hostbyname(map_ip_str, NULL, NULL);
- if (new_ip && new_ip != map_ip) {
- map_ip = new_ip;
- ShowInfo("Updating IP resolution of [%s].\n",map_ip_str);
- return (unsigned long)map_ip;
- }
- return 0;
-}
-
-/*==========================================
- * map鯖のport読み出し
- *------------------------------------------
- */
-int clif_getport(void)
-{
- return map_port;
-}
-
-/*==========================================
- * Counts connected players.
- *------------------------------------------
- */
-int clif_countusers(void)
-{
- int users = 0, i;
- struct map_session_data *sd;
-
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) &&
- sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd)))
- users++;
- }
- return users;
-}
-
-/*==========================================
- * 全てのclientに対してfunc()実行
- *------------------------------------------
- */
-
-int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //recoded by sasuke, bug when player count gets higher [Kevin]
-{
- int i;
- va_list ap;
- struct map_session_data *sd;
-
- va_start(ap,func);
-
- for(i = 0; i < fd_max; i++) {
- if ( session[i] && session[i]->func_parse == clif_parse) {
- sd = (struct map_session_data*)session[i]->session_data;
- if ( sd && sd->state.auth && !sd->state.waitingdisconnect )
- func(sd, ap);
- }
- }
-
- va_end(ap);
- return 0;
-}
-
-/*==========================================
- * clif_sendでAREA*指定時用
- *------------------------------------------
- */
-int clif_send_sub(struct block_list *bl, va_list ap)
-{
- struct block_list *src_bl;
- struct map_session_data *sd;
- unsigned char *buf;
- int len, type, fd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, sd = (struct map_session_data *)bl);
-
- fd = sd->fd;
- if (!fd) //Don't send to disconnected clients.
- return 0;
-
- buf = va_arg(ap,unsigned char*);
- len = va_arg(ap,int);
- nullpo_retr(0, src_bl = va_arg(ap,struct block_list*));
- type = va_arg(ap,int);
-
- switch(type) {
- case AREA_WOS:
- if (bl == src_bl)
- return 0;
- break;
- case AREA_WOC:
- if (sd->chatID || bl == src_bl)
- return 0;
- break;
- case AREA_WOSC:
- {
- struct map_session_data *ssd = (struct map_session_data *)src_bl;
- if (ssd && (src_bl->type == BL_PC) && sd->chatID && (sd->chatID == ssd->chatID))
- return 0;
- }
- break;
- }
-
- if (session[fd] != NULL) {
- WFIFOHEAD(fd, len);
- if (WFIFOP(fd,0) == buf) {
- printf("WARNING: Invalid use of clif_send function\n");
- printf(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0));
- printf(" Please correct your code.\n");
- // don't send to not move the pointer of the packet for next sessions in the loop
- } else {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- memcpy(WFIFOP(fd,0), buf, len);
- //Check if hidden, better to modify the char's buffer than the
- //given buffer to prevent intravision affecting the packet as
- //it's being received by everyone. [Skotlex]
- /* New implementation... not quite correct yet as the client no longer
- * displays correctly the SI_INTRAVISION effect.
- if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 )
- && bl != src_bl && WFIFOW(fd,0) == 0x0196)
- { //New intravision method, just modify the status change/start packet. [Skotlex]
- switch (WFIFOW(fd,2)) {
- case SI_HIDING:
- case SI_CLOAKING:
- case SI_CHASEWALK:
- WFIFOW(fd,2) = SI_INTRAVISION;
- }
- }
- */
-
- // Previous implementation.
- if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 ) && bl != src_bl) {
-
- struct status_change *sc = status_get_sc(src_bl);
- if(sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK)))
- { //optionの修正
- switch(((unsigned short*)buf)[0])
- {
-#if PACKETVER > 6
- case 0x229:
- WFIFOL(fd,10) &= ~(OPTION_HIDE|OPTION_CLOAK);
- break;
- case 0x22a:
- case 0x22b:
- case 0x22c:
- WFIFOL(fd,12) &=~(OPTION_HIDE|OPTION_CLOAK);
- break;
-#endif
-#if PACKETVER > 3
- case 0x119:
- WFIFOW(fd,10) &= ~(OPTION_HIDE|OPTION_CLOAK);
- break;
- case 0x1d8:
- case 0x1d9:
- case 0x1da:
-#endif
- case 0x78:
- case 0x79:
- case 0x7a:
- case 0x7b:
- case 0x7c:
- WFIFOW(fd,12) &=~(OPTION_HIDE|OPTION_CLOAK);
- break;
- }
- }
- }
- WFIFOSET(fd,len);
- }
- }
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
- int i;
- struct map_session_data *sd = NULL;
- struct party_data *p = NULL;
- struct guild *g = NULL;
- int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd;
-
- if (type != ALL_CLIENT &&
- type != CHAT_MAINCHAT) {
- nullpo_retr(0, bl);
- if (bl->type == BL_PC) {
- sd = (struct map_session_data *)bl;
- }
- }
-
- switch(type) {
- case ALL_CLIENT: //All player clients.
- for (i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data *)session[i]->session_data) != NULL&&
- sd->state.auth) {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(i, len);
- memcpy(WFIFOP(i,0), buf, len);
- WFIFOSET(i,len);
- }
- }
- }
- break;
- case ALL_SAMEMAP: //All players on the same map
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.auth && sd->bl.m == bl->m) {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(i,len);
- memcpy(WFIFOP(i,0), buf, len);
- WFIFOSET(i,len);
- }
- }
- }
- break;
- case AREA:
- case AREA_WOSC:
- if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
- clif_send (buf, len, bl, SELF);
- case AREA_WOC:
- case AREA_WOS:
- map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
- BL_PC, buf, len, bl, type);
- break;
- case AREA_CHAT_WOC:
- map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
- bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
- break;
- case CHAT:
- case CHAT_WOS:
- {
- struct chat_data *cd;
- if (sd) {
- cd = (struct chat_data*)map_id2bl(sd->chatID);
- } else if (bl->type == BL_CHAT) {
- cd = (struct chat_data*)bl;
- } else break;
- if (cd == NULL)
- break;
- for(i = 0; i < cd->users; i++) {
- if (type == CHAT_WOS && cd->usersd[i] == sd)
- continue;
- if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- if ((fd=cd->usersd[i]->fd) >0 && session[fd]) // Added check to see if session exists [PoW]
- {
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- }
- }
- }
- break;
- case CHAT_MAINCHAT: //[LuzZza]
- for(i=1; i<fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.mainchat && (fd=sd->fd))
- {
- WFIFOHEAD(fd, len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd, len);
- }
- }
- break;
- case PARTY_AREA:
- case PARTY_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case PARTY:
- case PARTY_WOS:
- case PARTY_SAMEMAP:
- case PARTY_SAMEMAP_WOS:
- if (sd && sd->status.party_id)
- p = party_search(sd->status.party_id);
-
- if (p) {
- for(i=0;i<MAX_PARTY;i++){
- if ((sd = p->data[i].sd) == NULL)
- continue;
- if (!(fd=sd->fd) || session[fd] == NULL || sd->state.auth == 0
- || session[fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
- continue;
-
- if (sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
- continue;
-
- if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m)
- continue;
-
- if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
- (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
- continue;
-
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- }
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
- break;
- for (i = 1; i < fd_max; i++){ // partyspy [Syrus22]
-
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.auth && (fd=sd->fd) && sd->partyspy == p->party.party_id)
- {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- }
- }
- }
- break;
- case DUEL:
- case DUEL_WOS:
- if (!sd || !sd->duel_group) break; //Invalid usage.
-
- x0 = sd->duel_group; //Here we use x0 to store the duel group. [Skotlex]
- for (i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data *)session[i]->session_data) != NULL &&
- sd->state.auth && sd->duel_group == x0) {
- if (type == DUEL_WOS && bl->id == sd->bl.id)
- continue;
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) {
- WFIFOHEAD(i, len);
- memcpy(WFIFOP(i,0), buf, len);
- WFIFOSET(i,len);
- }
- }
- }
- break;
- case SELF:
- if (sd && (fd=sd->fd) && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- break;
-
-// New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex]
- case GUILD_AREA:
- case GUILD_AREA_WOS:
- x0 = bl->x - AREA_SIZE;
- y0 = bl->y - AREA_SIZE;
- x1 = bl->x + AREA_SIZE;
- y1 = bl->y + AREA_SIZE;
- case GUILD_SAMEMAP:
- case GUILD_SAMEMAP_WOS:
- case GUILD:
- case GUILD_WOS:
- if (sd && sd->status.guild_id)
- g = guild_search(sd->status.guild_id);
-
- if (g) {
- for(i = 0; i < g->max_member; i++) {
- if ((sd = g->member[i].sd) != NULL) {
- if (!(fd=sd->fd) || session[fd] == NULL || sd->state.auth == 0
- || session[fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
- continue;
-
- if (sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS))
- continue;
-
- if (type != GUILD && type != GUILD_WOS && sd->bl.m != bl->m)
- continue;
-
- if ((type == GUILD_AREA || type == GUILD_AREA_WOS) &&
- (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
- continue;
-
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- }
- }
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
- break;
- for (i = 1; i < fd_max; i++){ // guildspy [Syrus22]
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
- sd->state.auth && (fd=sd->fd) && sd->guildspy == g->guild_id) {
- if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
- WFIFOHEAD(fd,len);
- memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd,len);
- }
- }
- }
- }
- break;
-/* End [Valaris] */
-
- default:
- if (battle_config.error_log)
- ShowError("clif_send: Unrecognized type %d\n",type);
- return -1;
- }
-
- 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;
-}
-//
-// パケット作って送信
-//
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_authok(struct map_session_data *sd) {
- int fd;
-
- if (!sd->fd)
- return 0;
- fd = sd->fd;
-
- WFIFOHEAD(fd, packet_len_table[0x73]);
- WFIFOW(fd, 0) = 0x73;
- WFIFOL(fd, 2) = gettick();
- WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir);
- WFIFOB(fd, 9) = 5;
- WFIFOB(fd,10) = 5;
- WFIFOSET(fd,packet_len_table[0x73]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_authfail_fd(int fd, int type) {
- if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players!
- return 0;
-
- WFIFOHEAD(fd, packet_len_table[0x81]);
- WFIFOW(fd,0) = 0x81;
- WFIFOB(fd,2) = type;
- WFIFOSET(fd,packet_len_table[0x81]);
- clif_setwaitclose(fd);
- return 0;
-}
-
-/*==========================================
- * Used to know which is the max valid account/char id [Skotlex]
- *------------------------------------------
- */
-void clif_updatemaxid(int account_id, int char_id)
-{
- max_account_id = account_id;
- max_char_id = char_id;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_charselectok(int id) {
- struct map_session_data *sd;
- int fd;
-
- if ((sd = map_id2sd(id)) == NULL)
- return 1;
-
- if (!sd->fd)
- return 1;
-
- fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb3]);
- WFIFOW(fd,0) = 0xb3;
- WFIFOB(fd,2) = 1;
- WFIFOSET(fd,packet_len_table[0xb3]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
- int view;
-
- nullpo_retr(0, fitem);
-
- //009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
- WBUFW(buf, 0) = 0x9e;
- WBUFL(buf, 2) = fitem->bl.id;
- if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
- WBUFW(buf, 6) = view;
- else
- WBUFW(buf, 6) = fitem->item_data.nameid;
- WBUFB(buf, 8) = fitem->item_data.identify;
- WBUFW(buf, 9) = fitem->bl.x;
- WBUFW(buf,11) = fitem->bl.y;
- WBUFB(buf,13) = fitem->subx;
- WBUFB(buf,14) = fitem->suby;
- WBUFW(buf,15) = fitem->item_data.amount;
-
- return packet_len_table[0x9e];
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_dropflooritem(struct flooritem_data *fitem) {
- unsigned char buf[64];
-
- nullpo_retr(0, fitem);
-
- if (fitem->item_data.nameid <= 0)
- return 0;
- clif_set009e(fitem, buf);
- clif_send(buf, packet_len_table[0x9e], &fitem->bl, AREA);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
- unsigned char buf[16];
-
- nullpo_retr(0, fitem);
-
- WBUFW(buf,0) = 0xa1;
- WBUFL(buf,2) = fitem->bl.id;
-
- if (fd == 0) {
- clif_send(buf, packet_len_table[0xa1], &fitem->bl, AREA);
- } else {
- WFIFOHEAD(fd,packet_len_table[0xa1]);
- memcpy(WFIFOP(fd,0), buf, 6);
- WFIFOSET(fd,packet_len_table[0xa1]);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_clearchar(struct block_list *bl, int type) {
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0) = 0x80;
- WBUFL(buf,2) = bl->id;
- WBUFB(buf,6) = type;
-
- clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
- if(disguised(bl)) {
- WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len_table[0x80], bl, SELF);
- }
-
- return 0;
-}
-
-static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data) {
- struct block_list *bl = (struct block_list *)id;
-
- clif_clearchar(bl,data);
- aFree(bl);
- return 0;
-}
-
-int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
- struct block_list *tbl;
- tbl = aMalloc(sizeof (struct block_list));
- memcpy (tbl, bl, sizeof (struct block_list));
- add_timer(tick, clif_clearchar_delay_sub, (int)tbl, type);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_clearchar_id(int id, int type, int fd) {
-
- WFIFOHEAD(fd, packet_len_table[0x80]);
- WFIFOW(fd,0) = 0x80;
- WFIFOL(fd,2) = id;
- WFIFOB(fd,6) = (char)type; // Why use int for a char in the first place?
- WFIFOSET(fd, packet_len_table[0x80]);
-
- return 0;
-}
-
-void clif_get_weapon_view(TBL_PC* sd, unsigned short *rhand, unsigned short *lhand)
-{
-#if PACKETVER > 3
- struct item_data *id;
-#endif
-
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- {
- *rhand = *lhand = 0;
- return;
- }
-
-#if PACKETVER < 4
- *rhand = sd->status.weapon;
- *lhand = sd->status.shield;
-#else
- if (sd->equip_index[EQI_HAND_R] >= 0 &&
- sd->inventory_data[sd->equip_index[EQI_HAND_R]])
- {
- id = sd->inventory_data[sd->equip_index[EQI_HAND_R]];
- if (id->view_id > 0)
- *rhand = id->view_id;
- else
- *rhand = id->nameid;
- } else
- *rhand = 0;
-
- if (sd->equip_index[EQI_HAND_L] >= 0 &&
- sd->equip_index[EQI_HAND_L] != sd->equip_index[EQI_HAND_R] &&
- sd->inventory_data[sd->equip_index[EQI_HAND_L]])
- {
- id = sd->inventory_data[sd->equip_index[EQI_HAND_L]];
- if (id->view_id > 0)
- *lhand = id->view_id;
- else
- *lhand = id->nameid;
- } else
- *lhand = 0;
-#endif
-}
-
-static void clif_get_guild_data(struct block_list *bl, long *guild_id, short *emblem_id)
-{
- //TODO: There has to be a way to clean this up.
- switch (bl->type) {
- case BL_PC:
- *guild_id = ((TBL_PC*)bl)->status.guild_id;
- *emblem_id = ((TBL_PC*)bl)->guild_emblem_id;
- break;
- case BL_MOB:
- if (((TBL_MOB*)bl)->guardian_data) {
- *guild_id =((TBL_MOB*)bl)->guardian_data->guild_id;
- *emblem_id =((TBL_MOB*)bl)->guardian_data->emblem_id;
- }
- break;
- case BL_NPC:
- if (bl->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) {
- struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id);
- if (g) {
- *guild_id =g->guild_id;
- *emblem_id =g->emblem_id;
- }
- }
- break;
- default:
- *guild_id = status_get_guild_id(bl);
- }
- return;
-}
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned char *buf) {
- struct status_change *sc;
- struct map_session_data *sd;
- long guild_id=0;
- unsigned short emblem_id=0, lv;
- unsigned short dir;
-
- nullpo_retr(0, bl);
- BL_CAST(BL_PC, bl, sd);
- sc = status_get_sc(bl);
-
- clif_get_guild_data(bl, &guild_id, &emblem_id);
- dir = unit_getdir(bl);
- lv = status_get_lv(bl);
- if(pcdb_checkid(vd->class_)) {
-#if PACKETVER > 6
- malloc_set(buf,0,packet_len_table[0x22a]);
-
- WBUFW(buf,0)=0x22a;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFL(buf,12)=sc->option;
- WBUFL(buf,44)=sc->opt3;
- }
- WBUFW(buf,16)=vd->class_;
- WBUFW(buf,18)=vd->hair_style;
- WBUFW(buf,20)=vd->weapon;
- WBUFW(buf,22)=vd->shield;
- WBUFW(buf,24)=vd->head_bottom;
- WBUFW(buf,26)=vd->head_top;
- WBUFW(buf,28)=vd->head_mid;
- WBUFW(buf,30)=vd->hair_color;
- WBUFW(buf,32)=vd->cloth_color;
- WBUFW(buf,34)=sd?sd->head_dir:0;
- WBUFL(buf,36)=guild_id;
- WBUFW(buf,40)=emblem_id;
- if (sd) {
- WBUFW(buf,42)=sd->status.manner;
- WBUFB(buf,48)=sd->status.karma;
- }
- WBUFB(buf,49)=vd->sex;
- WBUFPOS(buf,50,bl->x,bl->y,dir);
- WBUFB(buf,53)=5;
- WBUFB(buf,54)=5;
- WBUFB(buf,55)=vd->dead_sit;
- WBUFW(buf,56)=clif_setlevel(lv);
- return packet_len_table[0x22a];
-#elif PACKETVER > 3
- malloc_set(buf,0,packet_len_table[0x1d8]);
-
- WBUFW(buf,0)=0x1d8;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,42)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->shield;
- WBUFW(buf,22)=vd->head_bottom;
- WBUFW(buf,24)=vd->head_top;
- WBUFW(buf,26)=vd->head_mid;
- WBUFW(buf,28)=vd->hair_color;
- WBUFW(buf,30)=vd->cloth_color;
- WBUFW(buf,32)=sd?sd->head_dir:0;
- WBUFL(buf,34)=guild_id;
- WBUFW(buf,38)=emblem_id;
- if (sd) {
- WBUFW(buf,40)=sd->status.manner;
- WBUFB(buf,44)=sd->status.karma;
- }
- WBUFB(buf,45)=vd->sex;
- WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=vd->dead_sit;
- WBUFW(buf,52)=clif_setlevel(lv);
- return packet_len_table[0x1d8];
-#else
- malloc_set(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,42)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->head_bottom;
- WBUFW(buf,22)=vd->shield;
- WBUFW(buf,24)=vd->head_top;
- WBUFW(buf,26)=vd->head_mid;
- WBUFW(buf,28)=vd->hair_color;
- WBUFW(buf,30)=vd->cloth_color;
- WBUFW(buf,32)=sd?sd->head_dir:0;
- WBUFL(buf,34)=guild_id;
- WBUFL(buf,38)=emblem_id;
- if (sd)
- WBUFB(buf,44)=sd->status.karma;
- WBUFB(buf,45)=vd->sex;
- WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFB(buf,51)=vd->dead_sit;
- WBUFW(buf,52)=clif_setlevel(lv);
- return packet_len_table[0x78];
-#endif
- }
- //Non-player sprites need just a few fields filled.
- malloc_set(buf,0,packet_len_table[0x78]);
-
- WBUFW(buf,0)=0x78;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,42)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style; //Required for pets.
- WBUFW(buf,20)=vd->head_bottom; //Pet armor
- if (bl->type == BL_NPC && vd->class_ == 722)
- { //The hell, why flags work like this?
- WBUFL(buf,22)=emblem_id;
- WBUFL(buf,26)=guild_id;
- }
- WBUFW(buf,32)=dir;
- WBUFL(buf,34)=guild_id;
- WBUFL(buf,38)=emblem_id;
- WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- WBUFW(buf,52)=clif_setlevel(lv);
- return packet_len_table[0x78];
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit_data *ud, unsigned char *buf) {
- struct status_change *sc;
- struct map_session_data *sd;
- long guild_id=0;
- unsigned short emblem_id=0, lv;
-
- nullpo_retr(0, bl);
- BL_CAST(BL_PC, bl, sd);
- sc = status_get_sc(bl);
-
- clif_get_guild_data(bl, &guild_id, &emblem_id);
- lv = status_get_lv(bl);
-
- if(pcdb_checkid(vd->class_)) {
-#if PACKETVER > 6
- malloc_set(buf,0,packet_len_table[0x22c]);
-
- WBUFW(buf,0)=0x22c;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)= sc->opt1;
- WBUFW(buf,10)= sc->opt2;
- WBUFL(buf,12)= sc->option;
- WBUFL(buf,48)= sc->opt3;
- }
- WBUFW(buf,16)=vd->class_;
- WBUFW(buf,18)=vd->hair_style;
- WBUFW(buf,20)=vd->weapon;
- WBUFW(buf,22)=vd->shield;
- WBUFW(buf,24)=vd->head_bottom;
- WBUFL(buf,26)=gettick();
- WBUFW(buf,30)=vd->head_top;
- WBUFW(buf,32)=vd->head_mid;
- WBUFW(buf,34)=vd->hair_color;
- WBUFW(buf,36)=vd->cloth_color;
- WBUFW(buf,38)=sd?sd->head_dir:0;
- WBUFL(buf,40)=guild_id;
- WBUFW(buf,44)=emblem_id;
- if (sd) {
- WBUFW(buf,46)=sd->status.manner;
- WBUFB(buf,52)=sd->status.karma;
- }
- WBUFB(buf,53)=vd->sex;
- WBUFPOS2(buf,54,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,59)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,60)=0;
- WBUFB(buf,61)=0;
- WBUFW(buf,62)=clif_setlevel(lv);
-
- return packet_len_table[0x22c];
-#elif PACKETVER > 3
- malloc_set(buf,0,packet_len_table[0x1da]);
-
- WBUFW(buf,0)=0x1da;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,46)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->shield;
- WBUFW(buf,22)=vd->head_bottom;
- WBUFL(buf,24)=gettick();
- WBUFW(buf,28)=vd->head_top;
- WBUFW(buf,30)=vd->head_mid;
- WBUFW(buf,32)=vd->hair_color;
- WBUFW(buf,34)=vd->cloth_color;
- WBUFW(buf,36)=sd?sd->head_dir:0;
- WBUFL(buf,38)=guild_id;
- WBUFW(buf,42)=emblem_id;
- if (sd) {
- WBUFW(buf,44)=sd->status.manner;
- WBUFB(buf,48)=sd->status.karma;
- }
- WBUFB(buf,49)=vd->sex;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(lv);
-
- return packet_len_table[0x1da];
-#else
- malloc_set(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,46)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style;
- WBUFW(buf,18)=vd->weapon;
- WBUFW(buf,20)=vd->head_bottom;
- WBUFL(buf,22)=gettick();
- WBUFW(buf,26)=vd->shield;
- WBUFW(buf,28)=vd->head_top;
- WBUFW(buf,30)=vd->head_mid;
- WBUFW(buf,32)=vd->hair_color;
- WBUFW(buf,34)=vd->cloth_color;
- WBUFW(buf,36)=sd?sd->head_dir:0;
- WBUFL(buf,38)=guild_id;
- WBUFL(buf,42)=emblem_id;
- if (sd)
- WBUFB(buf,48)=sd->status.karma;
- WBUFB(buf,49)=vd->sex;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(lv);
-
- return packet_len_table[0x7b];
-#endif
- }
- //Non-player sprites only require a few fields.
-#if PACKETVER > 6
- malloc_set(buf,0,packet_len_table[0x22c]);
-
- WBUFW(buf,0)=0x22c;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFL(buf,12)=sc->option;
- WBUFL(buf,48)=sc->opt3;
- }
- WBUFW(buf,16)=vd->class_;
- WBUFW(buf,18)=vd->hair_style; //For pets
- WBUFW(buf,24)=vd->head_bottom; //Pet armor
- WBUFL(buf,26)=gettick();
- WBUFW(buf,38)=unit_getdir(bl);
- WBUFL(buf,40)=guild_id;
- WBUFL(buf,44)=emblem_id;
- WBUFPOS2(buf,54,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,59)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,60)=0;
- WBUFB(buf,61)=0;
- WBUFW(buf,62)=clif_setlevel(lv);
- return packet_len_table[0x22c];
-#else
- malloc_set(buf,0,packet_len_table[0x7b]);
-
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- WBUFW(buf,46)=sc->opt3;
- }
- WBUFW(buf,14)=vd->class_;
- WBUFW(buf,16)=vd->hair_style; //For pets
- WBUFW(buf,20)=vd->head_bottom; //Pet armor
- WBUFL(buf,22)=gettick();
- WBUFW(buf,36)=unit_getdir(bl);
- WBUFL(buf,38)=guild_id;
- WBUFL(buf,42)=emblem_id;
- WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
- WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- WBUFW(buf,58)=clif_setlevel(lv);
- return packet_len_table[0x7b];
-#endif
-}
-
-//Modifies the buffer for disguise characters and sends it to self.
-//Flag = 0: change id to negative, buf will have disguise data.
-//Flag = 1: change id to positive, class and option to make your own char invisible.
-//Luckily, the offsets that need to be changed are the same in packets 0x78, 0x7b, 0x1d8 and 0x1da
-//But no longer holds true for those packet of PACKETVER 7.
-static void clif_setdisguise(struct map_session_data *sd, unsigned char *buf,int len, int flag) {
-
- if (flag) {
-#if PACKETVER > 6
- switch (WBUFW(buf,0)) {
- case 0x22c:
- case 0x22b:
- case 0x22a:
- WBUFL(buf,12)=OPTION_INVISIBLE;
- WBUFW(buf,16)=sd->status.class_;
- break;
- default:
-#endif
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,12)=OPTION_INVISIBLE;
- WBUFW(buf,14)=sd->status.class_;
-#if PACKETVER > 6
- break;
- }
-#endif
- } else {
- WBUFL(buf,2)=-sd->bl.id;
- }
- clif_send(buf, len, &sd->bl, SELF);
-}
-
-/*==========================================
- * クラスチェンジ typeはMobの場合は1で他は0?
- *------------------------------------------
- */
-int clif_class_change(struct block_list *bl,int class_,int type)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- if(!pcdb_checkid(class_)) {
- WBUFW(buf,0)=0x1b0;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFL(buf,7)=class_;
- clif_send(buf,packet_len_table[0x1b0],bl,AREA);
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static void clif_spiritball_single(int fd, struct map_session_data *sd)
-{
- WFIFOHEAD(fd, packet_len_table[0x1e1]);
- WFIFOW(fd,0)=0x1e1;
- WFIFOL(fd,2)=sd->bl.id;
- WFIFOW(fd,6)=sd->spiritball;
- WFIFOSET(fd, packet_len_table[0x1e1]);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_set0192(int fd, int m, int x, int y, int type) {
- WFIFOHEAD(fd, packet_len_table[0x192]);
- WFIFOW(fd,0) = 0x192;
- WFIFOW(fd,2) = x;
- WFIFOW(fd,4) = y;
- WFIFOW(fd,6) = type;
- memcpy(WFIFOP(fd,8),map[m].name,MAP_NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x192]);
-
- return 0;
-}
-
-// new and improved weather display [Valaris]
-static void clif_weather_sub(int fd, int id, int type) {
- WFIFOHEAD(fd, packet_len_table[0x1f3]);
- WFIFOW(fd,0) = 0x1f3;
- WFIFOL(fd,2) = id;
- WFIFOL(fd,6) = type;
- WFIFOSET(fd,packet_len_table[0x1f3]);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static void clif_weather_check(struct map_session_data *sd) {
- int m = sd->bl.m, fd = sd->fd;
-
- if (map[m].flag.snow
- || map[m].flag.clouds
- || map[m].flag.fog
- || map[m].flag.fireworks
- || map[m].flag.sakura
- || map[m].flag.leaves
- || map[m].flag.rain
- || map[m].flag.clouds2)
- {
- if (map[m].flag.snow)
- clif_weather_sub(fd, sd->bl.id, 162);
- if (map[m].flag.clouds)
- clif_weather_sub(fd, sd->bl.id, 233);
- if (map[m].flag.clouds2)
- clif_weather_sub(fd, sd->bl.id, 516);
- if (map[m].flag.fog)
- clif_weather_sub(fd, sd->bl.id, 515);
- if (map[m].flag.fireworks) {
- clif_weather_sub(fd, sd->bl.id, 297);
- clif_weather_sub(fd, sd->bl.id, 299);
- clif_weather_sub(fd, sd->bl.id, 301);
- }
- if (map[m].flag.sakura)
- clif_weather_sub(fd, sd->bl.id, 163);
- if (map[m].flag.leaves)
- clif_weather_sub(fd, sd->bl.id, 333);
- if (map[m].flag.rain)
- clif_weather_sub(fd, sd->bl.id, 161);
- }
-}
-
-int clif_weather(int m) {
- int i;
-
- struct map_session_data *sd=NULL;
-
- for(i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd = session[i]->session_data) != NULL &&
- sd->state.auth && sd->bl.m == m) {
- clif_weather_check(sd);
- }
- }
-
- return 0;
-}
-
-int clif_spawn(struct block_list *bl)
-{
- unsigned char buf[128];
- struct view_data *vd;
- nullpo_retr(0, bl);
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
-
- if (pcdb_checkid(vd->class_))
- { //Player spawn packet.
- clif_set0078(bl, vd, buf);
- switch(WBUFW(buf,0)) {
- case 0x78: //Convert to 0x79
- WBUFW(buf, 0) = 0x79;
- WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
- clif_send(buf, packet_len_table[0x79], bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x79], 0);
- break;
-#if PACKETVER > 3
- case 0x1d8: //Convert to 0x1d9
- WBUFW(buf, 0) = 0x1d9;
- WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
- clif_send(buf, packet_len_table[0x1d9], bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x1d9], 0);
- break;
-#endif
-#if PACKETVER > 6
- case 0x22a: //Convert to 0x22b
- WBUFW(buf, 0) = 0x22b;
- WBUFW(buf,55) = WBUFW(buf,56); //Lv is placed on offset 56
- clif_send(buf, packet_len_table[0x22b], bl, AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x22b], 0);
- break;
-#endif
- }
- } else { //Mob spawn packet.
- struct status_change *sc = status_get_sc(bl);
- malloc_tsetdword(buf,0,sizeof(buf));
- WBUFW(buf,0)=0x7c;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=status_get_speed(bl);
- if (sc) {
- WBUFW(buf,8)=sc->opt1;
- WBUFW(buf,10)=sc->opt2;
- WBUFW(buf,12)=sc->option;
- }
- WBUFW(buf,20)=vd->class_;
- WBUFW(buf,22)=vd->hair_style; //Required for pets.
- WBUFW(buf,24)=vd->head_bottom; //Pet armor
-
- WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl));
- clif_send(buf,packet_len_table[0x7c],bl,AREA_WOS);
- if (disguised(bl)) {
- WBUFL(buf,2)=-bl->id;
- clif_send(buf,packet_len_table[0x7c],bl,SELF);
- }
- }
-
- if (vd->cloth_color)
- clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
-
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
- if (sd->spiritball > 0)
- clif_spiritball(sd);
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(sd->state.size==1)
- clif_specialeffect(bl,421,AREA);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,AREA);
- }
- break;
- }
- return 0;
-}
-
-//[orn]
-int clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
-{
- struct status_data *status;
- unsigned char buf[128];
-
- nullpo_retr(0, hd);
-
- status = &hd->battle_status;
- malloc_set(buf,0,packet_len_table[0x22e]);
- WBUFW(buf,0)=0x22e;
- memcpy(WBUFP(buf,2),hd->homunculus.name,NAME_LENGTH);
- // Bit field, bit 0 : rename_flag (1 = already renamed), bit 1 : homunc vaporized (1 = true), bit 2 : homunc dead (1 = true)
- WBUFB(buf,26)=hd->homunculus.rename_flag | (hd->homunculus.vaporize << 1) | (hd->homunculus.hp?0:4);
- WBUFW(buf,27)=hd->homunculus.level;
- WBUFW(buf,29)=hd->homunculus.hunger;
- WBUFW(buf,31)=(unsigned short) (hd->homunculus.intimacy / 100) ;
- WBUFW(buf,33)=0; // equip id
- WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, SHRT_MAX);
- WBUFW(buf,37)=cap_value(status->matk_max, 0, SHRT_MAX);
- WBUFW(buf,39)=status->hit;
- WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious]
- WBUFW(buf,43)=status->def + status->vit ;
- WBUFW(buf,45)=status->mdef;
- WBUFW(buf,47)=status->flee;
- WBUFW(buf,49)=(flag)?0:status->amotion;
- if (status->max_hp > SHRT_MAX) {
- WBUFW(buf,51) = status->hp/(status->max_hp/100);
- WBUFW(buf,53) = 100;
- } else {
- WBUFW(buf,51)=status->hp;
- WBUFW(buf,53)=status->max_hp;
- }
- if (status->max_sp > SHRT_MAX) {
- WBUFW(buf,55) = status->sp/(status->max_sp/100);
- WBUFW(buf,57) = 100;
- } else {
- WBUFW(buf,55)=status->sp;
- WBUFW(buf,57)=status->max_sp;
- }
- WBUFL(buf,59)=hd->homunculus.exp;
- WBUFL(buf,63)=hd->exp_next;
- WBUFW(buf,67)=hd->homunculus.skillpts;
- WBUFW(buf,69)=1; // FIXME: Attackable? When exactly is a homun not attackable? [Skotlex]
- clif_send(buf,packet_len_table[0x22e],&sd->bl,SELF);
- return 0;
-}
-
-void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[orn]
- int fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x230]);
- nullpo_retv(sd->hd);
- WFIFOW(fd,0)=0x230;
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=sd->hd->bl.id;
- WFIFOL(fd,8)=param;
- WFIFOSET(fd,packet_len_table[0x230]);
-
- return;
-}
-
-int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
- struct homun_data *hd;
- int fd = sd->fd;
- int i,j,len=4,id;
- WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL);
-
- hd = sd->hd;
- if ( !hd )
- return 0 ;
-
- WFIFOW(fd,0)=0x235;
- for ( i = 0; i < MAX_HOMUNSKILL; i++){
- if( (id = hd->homunculus.hskill[i].id) != 0 ){
- j = id - HM_SKILLBASE - 1 ;
- WFIFOW(fd,len ) = id ;
- WFIFOW(fd,len+2) = skill_get_inf(id) ;
- WFIFOW(fd,len+4) = 0 ;
- WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv ;
- WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv) ;
- WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv) ;
- strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH) ;
- WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0;
- len+=37;
- }
- }
- WFIFOW(fd,2)=len;
- WFIFOSET(fd,len);
-
- return 0;
-}
-
-void clif_homskillup(struct map_session_data *sd, int skill_num) { //[orn]
- struct homun_data *hd;
- int fd=sd->fd, skillid;
- WFIFOHEAD(fd, packet_len_table[0x239]);
- nullpo_retv(sd);
- skillid = skill_num - HM_SKILLBASE - 1;
-
- hd=sd->hd;
-
- WFIFOW(fd,0) = 0x239;
- WFIFOW(fd,2) = skill_num;
- WFIFOW(fd,4) = hd->homunculus.hskill[skillid].lv;
- WFIFOW(fd,6) = skill_get_sp(skill_num,hd->homunculus.hskill[skillid].lv);
- WFIFOW(fd,8) = skill_get_range2(&hd->bl, skill_num,hd->homunculus.hskill[skillid].lv);
- WFIFOB(fd,10) = (hd->homunculus.hskill[skillid].lv < skill_get_max(hd->homunculus.hskill[skillid].id)) ? 1 : 0;
- WFIFOSET(fd,packet_len_table[0x239]);
-
- return;
-}
-
-void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) { //[orn]
- struct homun_data *hd;
- RFIFOHEAD(fd);
- nullpo_retv(sd);
-
- if((hd=sd->hd) == NULL)
- return;
-
- memcpy(hd->homunculus.name,RFIFOP(fd,2),24);
- hd->homunculus.rename_flag = 1;
- clif_hominfo(sd,hd,0);
- clif_charnameack(sd->fd,&hd->bl);
-}
-
-void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) { //[orn]
-
- nullpo_retv(sd);
-
- if(!merc_is_hom_active(sd->hd))
- return;
-
- if (!unit_can_move(&sd->hd->bl))
- return;
- unit_walktoxy(&sd->hd->bl, sd->bl.x,sd->bl.y-1, 0);
-}
-
-void clif_parse_HomMoveTo(int fd,struct map_session_data *sd) { //[orn]
- int x,y,cmd;
- RFIFOHEAD(fd);
- nullpo_retv(sd);
-
- if(!merc_is_hom_active(sd->hd))
- return;
-
- cmd = RFIFOW(fd,0);
- x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 1) >> 6);
- y = ((RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]+1) & 0x3f) << 4) +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
-
- if (!unit_can_move(&sd->hd->bl))
- return;
-
- unit_walktoxy(&(sd->hd->bl),x,y,0);
-}
-
-void clif_parse_HomAttack(int fd,struct map_session_data *sd) { //[orn]
- struct block_list *target;
- RFIFOHEAD(fd);
- nullpo_retv(sd);
-
- if(!merc_is_hom_active(sd->hd))
- return;
-
- if ((target = map_id2bl(RFIFOL(fd,6))) == NULL || status_isdead(target))
- return;
-
- merc_stop_walking(sd->hd, 1);
- merc_stop_attack(sd->hd);
- unit_attack(&sd->hd->bl,RFIFOL(fd,6),1) ;
-}
-
-void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
- int cmd;
-
- RFIFOHEAD(fd);
- cmd = RFIFOW(fd,0);
-
- if(!merc_is_hom_active(sd->hd))
- return;
-
- merc_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]));
-}
-
-int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn]
-{
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x22f]);
- WFIFOW(fd,0)=0x22f;
- WFIFOB(fd,2)=fail;
- WFIFOW(fd,3)=foodid;
- WFIFOSET(fd,packet_len_table[0x22f]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_walkok(struct map_session_data *sd)
-{
- int fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x87]);
- WFIFOW(fd,0)=0x87;
- WFIFOL(fd,2)=gettick();
- WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WFIFOB(fd,11)=0x88;
- WFIFOSET(fd,packet_len_table[0x87]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_movepc(struct map_session_data *sd) {
- unsigned char buf[256];
-
- nullpo_retr(0, sd);
-
- if (map[sd->bl.m].flag.snow
- || map[sd->bl.m].flag.clouds
- || map[sd->bl.m].flag.fog
- || map[sd->bl.m].flag.fireworks
- || map[sd->bl.m].flag.sakura
- || map[sd->bl.m].flag.leaves
- || map[sd->bl.m].flag.rain
- || map[sd->bl.m].flag.clouds2
- ) {
- malloc_set(buf,0,packet_len_table[0x7b]);
- WBUFW(buf,0)=0x7b;
- WBUFL(buf,2)=-10;
- WBUFW(buf,6)=sd->battle_status.speed;
- WBUFW(buf,8)=0;
- WBUFW(buf,10)=0;
- WBUFW(buf,12)=OPTION_INVISIBLE;
- WBUFW(buf,14)=100;
- WBUFL(buf,22)=gettick();
- WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
- WBUFB(buf,56)=5;
- WBUFB(buf,57)=5;
- clif_send(buf, packet_len_table[0x7b], &sd->bl, SELF);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_move(struct block_list *bl) {
- struct view_data *vd;
- struct unit_data *ud;
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, bl);
-
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
-
- ud = unit_bl2ud(bl);
- nullpo_retr(0, ud);
-
- len = clif_set007b(bl,vd,ud,buf);
- clif_send(buf,len,bl,AREA_WOS);
- if (disguised(bl))
- clif_setdisguise((TBL_PC*)bl, buf, len, 0);
-
- //Stupid client that needs this resent every time someone walks :X
- if(vd->cloth_color)
- clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
-
- switch(bl->type)
- {
- case BL_PC:
- {
- TBL_PC *sd = ((TBL_PC*)bl);
-// clif_movepc(sd);
- if(sd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(&sd->bl,423,AREA);
- else if(sd->state.size==1)
- clif_specialeffect(&sd->bl,421,AREA);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB *md = ((TBL_MOB*)bl);
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(&md->bl,423,AREA);
- else if(md->special_state.size==1)
- clif_specialeffect(&md->bl,421,AREA);
- }
- break;
- }
- return 0;
-}
-
-
-/*==========================================
- * Delays the map_quit of a player after they are disconnected. [Skotlex]
- *------------------------------------------
- */
-static int clif_delayquit(int tid, unsigned int tick, int id, int data) {
- struct map_session_data *sd = NULL;
-
- //Remove player from map server
- if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player.
- map_quit(sd);
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_quitsave(int fd,struct map_session_data *sd)
-{
- if (sd->state.waitingdisconnect || //Was already waiting to be disconnected.
- !battle_config.prevent_logout ||
- DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- map_quit(sd);
- else if (sd->fd)
- { //Disassociate session from player (session is deleted after this function was called)
- //And set a timer to make him quit later.
- session[sd->fd]->session_data = NULL;
- sd->fd = 0;
- add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0);
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-static int clif_waitclose(int tid, unsigned int tick, int id, int data) {
- if (session[id] && session[id]->func_parse == clif_parse) //Avoid disconnecting non-players, as pointed out by End of Exam [Skotlex]
- session[id]->eof = 1;
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_setwaitclose(int fd) {
- struct map_session_data *sd;
-
- // if player is not already in the game (double connection probably)
- if ((sd = (struct map_session_data*)session[fd]->session_data) == NULL) {
- // limited timer, just to send information.
- add_timer(gettick() + 1000, clif_waitclose, fd, 0);
- } else
- add_timer(gettick() + 5000, clif_waitclose, fd, 0);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_changemap(struct map_session_data *sd, short map, int x, int y) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
-
- WFIFOHEAD(fd, packet_len_table[0x91]);
- WFIFOW(fd,0) = 0x91;
- memcpy(WFIFOP(fd,2), mapindex_id2name(map), MAP_NAME_LENGTH);
- WFIFOW(fd,18) = x;
- WFIFOW(fd,20) = y;
- WFIFOSET(fd, packet_len_table[0x91]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int y, int ip, int port) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x92]);
- WFIFOW(fd,0) = 0x92;
- //Better not trust the null-terminator is there. [Skotlex]
- memcpy(WFIFOP(fd,2), mapname, MAP_NAME_LENGTH);
- WFIFOB(fd,17) = 0; //Null terminator for mapname
- WFIFOW(fd,18) = x;
- WFIFOW(fd,20) = y;
- WFIFOL(fd,22) = ip;
- WFIFOW(fd,26) = port;
- WFIFOSET(fd, packet_len_table[0x92]);
-
- return 0;
-}
-
-int clif_blown(struct block_list *bl) {
-//Previous Aegis versions simply used clif_fixpos, but it seems clif_slide works better on current clients.
-// return clif_fixpos(bl);
- return clif_slide(bl, bl->x, bl->y);
-
-}
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_fixpos(struct block_list *bl) {
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x88;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=bl->x;
- WBUFW(buf,8)=bl->y;
- clif_send(buf, packet_len_table[0x88], bl, AREA);
- if (disguised(bl)) {
- WBUFL(buf,2)=-bl->id;
- clif_send(buf, packet_len_table[0x88], bl, SELF);
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_npcbuysell(struct map_session_data* sd, int id) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xc4]);
- WFIFOW(fd,0)=0xc4;
- WFIFOL(fd,2)=id;
- WFIFOSET(fd,packet_len_table[0xc4]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
- struct item_data *id;
- int fd,i,val;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, nd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, 200 * 11 + 4);
- WFIFOW(fd,0)=0xc6;
- for(i=0;nd->u.shop_item[i].nameid > 0;i++){
- id = itemdb_search(nd->u.shop_item[i].nameid);
- val=nd->u.shop_item[i].value;
- WFIFOL(fd,4+i*11)=val;
- if (!id->flag.value_notdc)
- val=pc_modifybuyvalue(sd,val);
- WFIFOL(fd,8+i*11)=val;
- WFIFOB(fd,12+i*11)=itemtype(id->type);
- if (id->view_id > 0)
- WFIFOW(fd,13+i*11)=id->view_id;
- else
- WFIFOW(fd,13+i*11)=nd->u.shop_item[i].nameid;
- }
- WFIFOW(fd,2)=i*11+4;
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_selllist(struct map_session_data *sd) {
- int fd,i,c=0,val;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4);
- WFIFOW(fd,0)=0xc7;
- for(i=0;i<MAX_INVENTORY;i++) {
- if(sd->status.inventory[i].nameid > 0 && sd->inventory_data[i]) {
- if (!itemdb_cansell(&sd->status.inventory[i], pc_isGM(sd)))
- continue;
-
- val=sd->inventory_data[i]->value_sell;
- if (val < 0)
- continue;
- WFIFOW(fd,4+c*10)=i+2;
- WFIFOL(fd,6+c*10)=val;
- if (!sd->inventory_data[i]->flag.value_notoc)
- val=pc_modifysellvalue(sd,val);
- WFIFOL(fd,10+c*10)=val;
- c++;
- }
- }
- WFIFOW(fd,2)=c*10+4;
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
- int fd = sd->fd;
- int slen = strlen(mes) + 9;
- WFIFOHEAD(fd, slen);
- WFIFOW(fd,0)=0xb4;
- WFIFOW(fd,2)=slen;
- WFIFOL(fd,4)=npcid;
- strcpy((char*)WFIFOP(fd,8),mes);
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_scriptnext(struct map_session_data *sd,int npcid) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb5]);
- WFIFOW(fd,0)=0xb5;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0xb5]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_scriptclose(struct map_session_data *sd, int npcid) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xb6]);
- WFIFOW(fd,0)=0xb6;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0xb6]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
- int fd = sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x78]);
- sd->state.using_fake_npc = 1;
- malloc_set(WFIFOP(fd,0), 0, packet_len_table[0x78]);
- WFIFOW(fd,0)=0x78;
- WFIFOL(fd,2)=npcid;
- WFIFOW(fd,14)=111;
- WFIFOPOS(fd,46,sd->bl.x,sd->bl.y,sd->ud.dir);
- WFIFOB(fd,49)=5;
- WFIFOB(fd,50)=5;
- WFIFOSET(fd, packet_len_table[0x78]);
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
- int fd = sd->fd;
- int slen = strlen(mes) + 8;
- struct block_list *bl = NULL;
- WFIFOHEAD(fd, slen);
-
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
-
- WFIFOW(fd,0)=0xb7;
- WFIFOW(fd,2)=slen;
- WFIFOL(fd,4)=npcid;
- strcpy((char*)WFIFOP(fd,8),mes);
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_scriptinput(struct map_session_data *sd, int npcid) {
- int fd;
- struct block_list *bl = NULL;
-
- nullpo_retr(0, sd);
-
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x142]);
- WFIFOW(fd,0)=0x142;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0x142]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
- int fd;
- struct block_list *bl = NULL;
-
- nullpo_retr(0, sd);
-
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
- bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
- bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
- clif_sendfakenpc(sd, npcid);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x1d4]);
- WFIFOW(fd,0)=0x1d4;
- WFIFOL(fd,2)=npcid;
- WFIFOSET(fd,packet_len_table[0x1d4]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x144]);
- WFIFOW(fd,0)=0x144;
- WFIFOL(fd,2)=npc_id;
- WFIFOL(fd,6)=type;
- WFIFOL(fd,10)=x;
- WFIFOL(fd,14)=y;
- WFIFOB(fd,18)=id;
- WFIFOL(fd,19)=color;
- WFIFOSET(fd,packet_len_table[0x144]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_cutin(struct map_session_data *sd, char *image, int type) {
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x1b3]);
- WFIFOW(fd,0)=0x1b3;
- strncpy((char*)WFIFOP(fd,2),image,64);
- WFIFOB(fd,66)=type;
- WFIFOSET(fd,packet_len_table[0x1b3]);
-
- return 0;
-}
-
-/*==========================================
- * Fills in card data from the given item and into the buffer. [Skotlex]
- *------------------------------------------
- */
-static void clif_addcards(unsigned char* buf, struct item* item)
-{
- int i=0,j;
- if (item == NULL) { //Blank data
- WBUFW(buf,0)=0;
- WBUFW(buf,2)=0;
- WBUFW(buf,4)=0;
- WBUFW(buf,6)=0;
- return;
- }
- if(item->card[0]==CARD0_PET) { //pet eggs
- WBUFW(buf,0)=0;
- WBUFW(buf,2)=0;
- WBUFW(buf,4)=0;
- WBUFW(buf,6)=item->card[3]; //Pet renamed flag.
- return;
- }
- if(item->card[0]==CARD0_FORGE || item->card[0]==CARD0_CREATE) { //Forged/created items
- WBUFW(buf,0)=item->card[0];
- WBUFW(buf,2)=item->card[1];
- WBUFW(buf,4)=item->card[2];
- WBUFW(buf,6)=item->card[3];
- return;
- }
- //Client only receives four cards.. so randomly send them a set of cards. [Skotlex]
- if (MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4)
- i = rand()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rand()%3;
-
- //Normal items.
- if (item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,0)=j;
- else
- WBUFW(buf,0)= item->card[i];
-
- if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,2)=j;
- else
- WBUFW(buf,2)=item->card[i];
-
- if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,4)=j;
- else
- WBUFW(buf,4)=item->card[i];
-
- if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
- WBUFW(buf,6)=j;
- else
- WBUFW(buf,6)=item->card[i];
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
- int fd;
- unsigned char *buf;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- if (!session_isActive(fd)) //Sasuke-
- return 0;
-
- WFIFOHEAD(fd,packet_len_table[0xa0]);
- buf = WFIFOP(fd,0);
- if(fail) {
- WBUFW(buf,0)=0xa0;
- WBUFW(buf,2)=n+2;
- WBUFW(buf,4)=amount;
- WBUFW(buf,6)=0;
- WBUFB(buf,8)=0;
- WBUFB(buf,9)=0;
- WBUFB(buf,10)=0;
- WBUFW(buf,11)=0;
- WBUFW(buf,13)=0;
- WBUFW(buf,15)=0;
- WBUFW(buf,17)=0;
- WBUFW(buf,19)=0;
- WBUFB(buf,21)=0;
- WBUFB(buf,22)=fail;
- } else {
- if (n<0 || n>=MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL)
- return 1;
-
- WBUFW(buf,0)=0xa0;
- WBUFW(buf,2)=n+2;
- WBUFW(buf,4)=amount;
- if (sd->inventory_data[n]->view_id > 0)
- WBUFW(buf,6)=sd->inventory_data[n]->view_id;
- else
- WBUFW(buf,6)=sd->status.inventory[n].nameid;
- WBUFB(buf,8)=sd->status.inventory[n].identify;
- WBUFB(buf,9)=sd->status.inventory[n].attribute;
- WBUFB(buf,10)=sd->status.inventory[n].refine;
- clif_addcards(WBUFP(buf,11), &sd->status.inventory[n]);
- WBUFW(buf,19)=pc_equippoint(sd,n);
- WBUFB(buf,21)=itemtype(sd->inventory_data[n]->type);
- WBUFB(buf,22)=fail;
- }
-
- WFIFOSET(fd,packet_len_table[0xa0]);
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_delitem(struct map_session_data *sd,int n,int amount)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0xaf]);
- WFIFOW(fd,0)=0xaf;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=amount;
-
- WFIFOSET(fd,packet_len_table[0xaf]);
-
- return 0;
-}
-
-// Simplifies inventory/cart/storage packets by handling the packet section relevant to items. [Skotlex]
-// Equip is >= 0 for equippable items (holds the equip-point, is 0 for pet
-// armor/egg) -1 for stackable items, -2 for stackable items where arrows must send in the equip-point.
-void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip)
-{
- if (id->view_id > 0)
- WBUFW(buf,n)=id->view_id;
- else
- WBUFW(buf,n)=i->nameid;
- WBUFB(buf,n+2)=itemtype(id->type);
- WBUFB(buf,n+3)=i->identify;
- if (equip >= 0) { //Equippable item
- WBUFW(buf,n+4)=equip;
- WBUFW(buf,n+6)=i->equip;
- WBUFB(buf,n+8)=i->attribute;
- WBUFB(buf,n+9)=i->refine;
- } else { //Stackable item.
- WBUFW(buf,n+4)=i->amount;
- if (equip == -2 && id->equip == EQP_AMMO)
- WBUFW(buf,n+6)=EQP_AMMO;
- else
- WBUFW(buf,n+6)=0;
- }
-
-}
-
-//Unified inventory function which sends all of the inventory (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
-void clif_inventorylist(struct map_session_data *sd)
-{
- int i,n,ne,fd = sd->fd,arrow=-1;
- unsigned char *buf;
- unsigned char bufe[MAX_INVENTORY*20+4];
-#if PACKETVER < 5
- const int s = 10; //Entry size.
-#else
- const int s = 18;
-#endif
- WFIFOHEAD(fd, MAX_INVENTORY * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_INVENTORY;i++){
- if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
- continue;
-
- if(!itemdb_isstackable2(sd->inventory_data[i]))
- { //Non-stackable (Equippable)
- WBUFW(bufe,ne*20+4)=i+2;
- clif_item_sub(bufe, ne*20+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
- clif_addcards(WBUFP(bufe, ne*20+16), &sd->status.inventory[i]);
- ne++;
- } else { //Stackable.
- WBUFW(buf,n*s+4)=i+2;
- clif_item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2);
- if (sd->inventory_data[i]->equip == EQP_AMMO &&
- sd->status.inventory[i].equip)
- arrow=i;
-#if PACKETVER >= 5
- clif_addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]);
-#endif
- n++;
- }
- }
- if (n) {
-#if PACKETVER < 5
- WBUFW(buf,0)=0xa3;
-#else
- WBUFW(buf,0)=0x1ee;
-#endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(arrow >= 0)
- clif_arrowequip(sd,arrow);
-
- if(ne){
- WBUFW(bufe,0)=0xa4;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
-
-}
-
-//Required when items break/get-repaired. Only sends equippable item list.
-void clif_equiplist(struct map_session_data *sd)
-{
- int i,n,fd = sd->fd;
- unsigned char *buf;
- WFIFOHEAD(fd, MAX_INVENTORY * 20 + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0;i<MAX_INVENTORY;i++){
- if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
- continue;
-
- if(itemdb_isstackable2(sd->inventory_data[i]))
- continue;
- //Equippable
- WBUFW(buf,n*20+4)=i+2;
- clif_item_sub(buf, n*20+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
- clif_addcards(WBUFP(buf, n*20+16), &sd->status.inventory[i]);
- n++;
- }
- if (n) {
- WBUFW(buf,0)=0xa4;
- WBUFW(buf,2)=4+n*20;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
-}
-
-//Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
-void clif_storagelist(struct map_session_data *sd,struct storage *stor)
-{
- struct item_data *id;
- int i,n,ne,fd=sd->fd;
- unsigned char *buf;
- unsigned char bufe[MAX_STORAGE*20+4];
-#if PACKETVER < 5
- const int s = 10; //Entry size.
-#else
- const int s = 18;
-#endif
- WFIFOHEAD(fd,MAX_STORAGE * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_STORAGE;i++){
- if(stor->storage_[i].nameid<=0)
- continue;
- id = itemdb_search(stor->storage_[i].nameid);
- if(!itemdb_isstackable2(id))
- { //Equippable
- WBUFW(bufe,ne*20+4)=i+1;
- clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
- ne++;
- } else { //Stackable
- WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
-#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
-#endif
- n++;
- }
- }
- if(n){
-#if PACKETVER < 5
- WBUFW(buf,0)=0xa5;
-#else
- WBUFW(buf,0)=0x1f0;
-#endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(ne){
- WBUFW(bufe,0)=0xa6;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
-}
-
-//Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
-void clif_guildstoragelist(struct map_session_data *sd,struct guild_storage *stor)
-{
- struct item_data *id;
- int i,n,ne,fd=sd->fd;
- unsigned char *buf;
- unsigned char bufe[MAX_GUILD_STORAGE*20+4];
-#if PACKETVER < 5
- const int s = 10; //Entry size.
-#else
- const int s = 18;
-#endif
- WFIFOHEAD(fd,MAX_GUILD_STORAGE * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_GUILD_STORAGE;i++){
- if(stor->storage_[i].nameid<=0)
- continue;
- id = itemdb_search(stor->storage_[i].nameid);
- if(!itemdb_isstackable2(id))
- { //Equippable
- WBUFW(bufe,ne*20+4)=i+1;
- clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
- ne++;
- } else { //Stackable
- WBUFW(buf,n*s+4)=i+1;
- clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
-#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
-#endif
- n++;
- }
- }
- if(n){
-#if PACKETVER < 5
- WBUFW(buf,0)=0xa5;
-#else
- WBUFW(buf,0)=0x1f0;
-#endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(ne){
- WBUFW(bufe,0)=0xa6;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
-}
-
-void clif_cartlist(struct map_session_data *sd)
-{
- struct item_data *id;
- int i,n,ne,fd=sd->fd;
- unsigned char *buf;
- unsigned char bufe[MAX_CART*20+4];
-#if PACKETVER < 5
- const int s = 10; //Entry size.
-#else
- const int s = 18;
-#endif
- WFIFOHEAD(fd, MAX_CART * s + 4);
- buf = WFIFOP(fd,0);
-
- for(i=0,n=0,ne=0;i<MAX_CART;i++){
- if(sd->status.cart[i].nameid<=0)
- continue;
- id = itemdb_search(sd->status.cart[i].nameid);
- if(!itemdb_isstackable2(id))
- { //Equippable
- WBUFW(bufe,ne*20+4)=i+2;
- clif_item_sub(bufe, ne*20+6, &sd->status.cart[i], id, id->equip);
- clif_addcards(WBUFP(bufe, ne*20+16), &sd->status.cart[i]);
- ne++;
- } else { //Stackable
- WBUFW(buf,n*s+4)=i+2;
- clif_item_sub(buf, n*s+6, &sd->status.cart[i], id,-1);
-#if PACKETVER >= 5
- clif_addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]);
-#endif
- n++;
- }
- }
- if(n){
-#if PACKETVER < 5
- WBUFW(buf,0)=0x123;
-#else
- WBUFW(buf,0)=0x1ef;
-#endif
- WBUFW(buf,2)=4+n*s;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- if(ne){
- WBUFW(bufe,0)=0x122;
- WBUFW(bufe,2)=4+ne*20;
- clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
- }
- return;
-}
-
-// Guild XY locators [Valaris]
-int clif_guild_xy(struct map_session_data *sd)
-{
- unsigned char buf[10];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x1eb;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=sd->bl.x;
- WBUFW(buf,8)=sd->bl.y;
- clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
-
- return 0;
-}
-
-/*==========================================
- * Sends x/y dot to a single fd. [Skotlex]
- *------------------------------------------
- */
-
-int clif_guild_xy_single(int fd, struct map_session_data *sd)
-{
- WFIFOHEAD(fd,packet_len_table[0x1eb]);
- WFIFOW(fd,0)=0x1eb;
- WFIFOL(fd,2)=sd->status.account_id;
- WFIFOW(fd,6)=sd->bl.x;
- WFIFOW(fd,8)=sd->bl.y;
- WFIFOSET(fd,packet_len_table[0x1eb]);
- return 0;
-}
-
-// Guild XY locators [Valaris]
-int clif_guild_xy_remove(struct map_session_data *sd)
-{
- unsigned char buf[10];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x1eb;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=-1;
- WBUFW(buf,8)=-1;
- clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
-
- return 0;
-}
-
-/*==========================================
- * ステータスを送りつける
- * 表示専用数字はこの中で計算して送る
- *------------------------------------------
- */
-int clif_updatestatus(struct map_session_data *sd,int type)
-{
- int fd,len=8;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
-
- if ( !session_isActive(fd) ) // Invalid pointer fix, by sasuke [Kevin]
- return 0;
-
- WFIFOHEAD(fd, 14);
- WFIFOW(fd,0)=0xb0;
- WFIFOW(fd,2)=type;
- switch(type){
- // 00b0
- case SP_WEIGHT:
- pc_checkweighticon(sd);
- WFIFOW(fd,0)=0xb0; //Need to re-set as pc_checkweighticon can alter the buffer. [Skotlex]
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=sd->weight;
- break;
- case SP_MAXWEIGHT:
- WFIFOL(fd,4)=sd->max_weight;
- break;
- case SP_SPEED:
- WFIFOL(fd,4)=sd->battle_status.speed;
- break;
- case SP_BASELEVEL:
- WFIFOL(fd,4)=sd->status.base_level;
- break;
- case SP_JOBLEVEL:
- WFIFOL(fd,4)=sd->status.job_level;
- break;
- case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance]
- WFIFOL(fd,4)=sd->status.karma;
- break;
- case SP_MANNER:
- WFIFOL(fd,4)=sd->status.manner;
- clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
- break;
- case SP_STATUSPOINT:
- WFIFOL(fd,4)=sd->status.status_point;
- break;
- case SP_SKILLPOINT:
- WFIFOL(fd,4)=sd->status.skill_point;
- break;
- case SP_HIT:
- WFIFOL(fd,4)=sd->battle_status.hit;
- break;
- case SP_FLEE1:
- WFIFOL(fd,4)=sd->battle_status.flee;
- break;
- case SP_FLEE2:
- WFIFOL(fd,4)=sd->battle_status.flee2/10;
- break;
- case SP_MAXHP:
- WFIFOL(fd,4)=sd->battle_status.max_hp;
- break;
- case SP_MAXSP:
- WFIFOL(fd,4)=sd->battle_status.max_sp;
- break;
- case SP_HP:
- WFIFOL(fd,4)=sd->battle_status.hp;
- if (battle_config.disp_hpmeter)
- clif_hpmeter(sd);
- if (!battle_config.party_hp_mode && sd->status.party_id)
- clif_party_hp(sd);
- break;
- case SP_SP:
- WFIFOL(fd,4)=sd->battle_status.sp;
- break;
- case SP_ASPD:
- WFIFOL(fd,4)=sd->battle_status.amotion;
- break;
- case SP_ATK1:
- WFIFOL(fd,4)=sd->battle_status.batk +sd->battle_status.rhw.atk +sd->battle_status.lhw->atk;
- break;
- case SP_DEF1:
- WFIFOL(fd,4)=sd->battle_status.def;
- break;
- case SP_MDEF1:
- WFIFOL(fd,4)=sd->battle_status.mdef;
- break;
- case SP_ATK2:
- WFIFOL(fd,4)=sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2;
- break;
- case SP_DEF2:
- WFIFOL(fd,4)=sd->battle_status.def2;
- break;
- case SP_MDEF2:
- //negative check (in case you have something like Berserk active)
- len = sd->battle_status.mdef2 - (sd->battle_status.vit>>1);
- if (len < 0) len = 0;
- WFIFOL(fd,4)= len;
- len = 8;
- break;
- case SP_CRITICAL:
- WFIFOL(fd,4)=sd->battle_status.cri/10;
- break;
- case SP_MATK1:
- WFIFOL(fd,4)=sd->battle_status.matk_max;
- break;
- case SP_MATK2:
- WFIFOL(fd,4)=sd->battle_status.matk_min;
- break;
-
-
- case SP_ZENY:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.zeny;
- break;
- case SP_BASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.base_exp;
- break;
- case SP_JOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=sd->status.job_exp;
- break;
- case SP_NEXTBASEEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextbaseexp(sd);
- break;
- case SP_NEXTJOBEXP:
- WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextjobexp(sd);
- break;
-
- // 00be 終了
- case SP_USTR:
- case SP_UAGI:
- case SP_UVIT:
- case SP_UINT:
- case SP_UDEX:
- case SP_ULUK:
- WFIFOW(fd,0)=0xbe;
- WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR);
- len=5;
- break;
-
- // 013a 終了
- case SP_ATTACKRANGE:
- WFIFOW(fd,0)=0x13a;
- WFIFOW(fd,2)=sd->battle_status.rhw.range;
- len=4;
- break;
-
- // 0141 終了
- case SP_STR:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.str;
- WFIFOL(fd,10)=sd->battle_status.str - sd->status.str;
- len=14;
- break;
- case SP_AGI:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.agi;
- WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi;
- len=14;
- break;
- case SP_VIT:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.vit;
- WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit;
- len=14;
- break;
- case SP_INT:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.int_;
- WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_;
- len=14;
- break;
- case SP_DEX:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.dex;
- WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex;
- len=14;
- break;
- case SP_LUK:
- WFIFOW(fd,0)=0x141;
- WFIFOL(fd,2)=type;
- WFIFOL(fd,6)=sd->status.luk;
- WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk;
- len=14;
- break;
-
- case SP_CARTINFO:
- WFIFOW(fd,0)=0x121;
- WFIFOW(fd,2)=sd->cart_num;
- WFIFOW(fd,4)=sd->cart_max_num;
- WFIFOL(fd,6)=sd->cart_weight;
- WFIFOL(fd,10)=sd->cart_max_weight;
- len=14;
- break;
-
- default:
- if(battle_config.error_log)
- ShowError("clif_updatestatus : unrecognized type %d\n",type);
- return 1;
- }
- WFIFOSET(fd,len);
-
- return 0;
-}
-int clif_changestatus(struct block_list *bl,int type,int val)
-{
- unsigned char buf[12];
- struct map_session_data *sd = NULL;
-
- nullpo_retr(0, bl);
-
- if(bl->type == BL_PC)
- sd = (struct map_session_data *)bl;
-
-//printf("clif_changestatus id:%d type:%d val:%d\n",bl->id,type,val);
- if(sd){
- WBUFW(buf,0)=0x1ab;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=type;
- switch(type){
- case SP_MANNER:
- WBUFL(buf,8)=val;
- break;
- default:
- if(battle_config.error_log)
- ShowError("clif_changestatus : unrecognized type %d.\n",type);
- return 1;
- }
- clif_send(buf,packet_len_table[0x1ab],bl,AREA_WOS);
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_changelook(struct block_list *bl,int type,int val)
-{
- unsigned char buf[32];
- struct map_session_data *sd = NULL;
- struct view_data *vd;
- vd = status_get_viewdata(bl);
- nullpo_retr(0, vd);
-
- BL_CAST(BL_PC, bl, sd);
-
- switch(type) {
- case LOOK_WEAPON:
- if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
- else vd->weapon = val;
- break;
- case LOOK_SHIELD:
- if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
- else vd->shield = val;
- break;
- case LOOK_BASE:
- vd->class_ = val;
- if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS)
- vd->weapon = vd->shield = 0;
- if (vd->cloth_color && (
- (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
- ))
- clif_changelook(bl,LOOK_CLOTHES_COLOR,0);
- break;
- case LOOK_HAIR:
- vd->hair_style = val;
- break;
- case LOOK_HEAD_BOTTOM:
- vd->head_bottom = val;
- break;
- case LOOK_HEAD_TOP:
- vd->head_top = val;
- break;
- case LOOK_HEAD_MID:
- vd->head_mid = val;
- break;
- case LOOK_HAIR_COLOR:
- vd->hair_color = val;
- break;
- case LOOK_CLOTHES_COLOR:
- if (val && (
- (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
- (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
- ))
- val = 0;
- vd->cloth_color = val;
- break;
- case LOOK_SHOES:
-#if PACKETVER > 3
- if (sd) {
- int n;
- if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
- if(sd->inventory_data[n]->view_id > 0)
- val = sd->inventory_data[n]->view_id;
- else
- val = sd->status.inventory[n].nameid;
- }
- val = 0;
- }
-#endif
- //Shoes? No packet uses this....
- break;
- }
-#if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFB(buf,7)=val;
- clif_send(buf,packet_len_table[0xc3],bl,AREA);
-#else
- if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_WEAPON;
- WBUFW(buf,7)=vd->weapon;
- WBUFW(buf,9)=vd->shield;
- clif_send(buf,packet_len_table[0x1d7],bl,AREA);
- }
- else
- {
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif_send(buf,packet_len_table[0x1d7],bl,AREA);
- }
-#endif
- return 0;
-}
-
-//Sends a change-base-look packet required for traps as they are triggered.
-void clif_changetraplook(struct block_list *bl,int val)
-{
- unsigned char buf[32];
-#if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_BASE;
- WBUFB(buf,7)=val;
- clif_send(buf,packet_len_table[0xc3],bl,AREA);
-#else
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=LOOK_BASE;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif_send(buf,packet_len_table[0x1d7],bl,AREA);
-#endif
-
-
-}
-//For the stupid cloth-dye bug. Resends the given view data
-//to the area specified by bl.
-void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area)
-{
- unsigned char buf[32];
-#if PACKETVER < 4
- WBUFW(buf,0)=0xc3;
- WBUFL(buf,2)=id;
- WBUFB(buf,6)=type;
- WBUFB(buf,7)=val;
- clif_send(buf,packet_len_table[0xc3],bl,area);
-#else
- WBUFW(buf,0)=0x1d7;
- WBUFL(buf,2)=id;
- WBUFB(buf,6)=type;
- WBUFW(buf,7)=val;
- WBUFW(buf,9)=0;
- clif_send(buf,packet_len_table[0x1d7],bl,area);
-#endif
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_initialstatus(struct map_session_data *sd)
-{
- int fd;
- unsigned char *buf;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xbd]);
- buf=WFIFOP(fd,0);
-
- WBUFW(buf,0)=0xbd;
- WBUFW(buf,2)=(sd->status.status_point > SHRT_MAX)? SHRT_MAX:sd->status.status_point;
- WBUFB(buf,4)=(sd->status.str > UCHAR_MAX)? UCHAR_MAX:sd->status.str;
- WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
- WBUFB(buf,6)=(sd->status.agi > UCHAR_MAX)? UCHAR_MAX:sd->status.agi;
- WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
- WBUFB(buf,8)=(sd->status.vit > UCHAR_MAX)? UCHAR_MAX:sd->status.vit;
- WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
- WBUFB(buf,10)=(sd->status.int_ > UCHAR_MAX)? UCHAR_MAX:sd->status.int_;
- WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
- WBUFB(buf,12)=(sd->status.dex > UCHAR_MAX)? UCHAR_MAX:sd->status.dex;
- WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
- WBUFB(buf,14)=(sd->status.luk > UCHAR_MAX)? UCHAR_MAX:sd->status.luk;
- WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
-
- WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw->atk;
- WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2; //atk bonus
- WBUFW(buf,20) = sd->battle_status.matk_max;
- WBUFW(buf,22) = sd->battle_status.matk_min;
- WBUFW(buf,24) = sd->battle_status.def; // def
- WBUFW(buf,26) = sd->battle_status.def2;
- WBUFW(buf,28) = sd->battle_status.mdef; // mdef
- fd = sd->battle_status.mdef2 - (sd->battle_status.vit>>1);
- if (fd < 0) fd = 0; //Negative check for Frenzy'ed characters.
- WBUFW(buf,30) = fd;
- fd = sd->fd;
- WBUFW(buf,32) = sd->battle_status.hit;
- WBUFW(buf,34) = sd->battle_status.flee;
- WBUFW(buf,36) = sd->battle_status.flee2/10;
- WBUFW(buf,38) = sd->battle_status.cri/10;
- WBUFW(buf,40) = sd->status.karma;
- WBUFW(buf,42) = sd->status.manner;
-
- WFIFOSET(fd,packet_len_table[0xbd]);
-
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
-
- clif_updatestatus(sd,SP_ATTACKRANGE);
- clif_updatestatus(sd,SP_ASPD);
-
- return 0;
-}
-
-/*==========================================
- *矢装備
- *------------------------------------------
- */
-int clif_arrowequip(struct map_session_data *sd,int val)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- pc_stop_attack(sd); // [Valaris]
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x013c]);
- WFIFOW(fd,0)=0x013c;
- WFIFOW(fd,2)=val+2;//矢のアイテムID
-
- WFIFOSET(fd,packet_len_table[0x013c]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_arrow_fail(struct map_session_data *sd,int type)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, packet_len_table[0x013b]);
- WFIFOW(fd,0)=0x013b;
- WFIFOW(fd,2)=type;
-
- WFIFOSET(fd,packet_len_table[0x013b]);
-
- return 0;
-}
-
-/*==========================================
- * 作成可能 矢リスト送信
- *------------------------------------------
- */
-int clif_arrow_create_list(struct map_session_data *sd)
-{
- int i, c, j;
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- WFIFOHEAD(fd, MAX_SKILL_ARROW_DB*2+4);
- WFIFOW(fd,0) = 0x1ad;
-
- for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
- if (skill_arrow_db[i].nameid > 0 &&
- (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 &&
- !sd->status.inventory[j].equip && sd->status.inventory[j].identify)
- {
- if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0)
- WFIFOW(fd,c*2+4) = j;
- else
- WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid;
- c++;
- }
- }
- WFIFOW(fd,2) = c*2+4;
- WFIFOSET(fd, WFIFOW(fd,2));
- if (c > 0) {
- sd->menuskill_id = AC_MAKINGARROW;
- sd->menuskill_lv = c;
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xbc]);
- WFIFOW(fd,0)=0xbc;
- WFIFOW(fd,2)=type;
- WFIFOB(fd,4)=ok;
- WFIFOB(fd,5)=val;
- WFIFOSET(fd,packet_len_table[0xbc]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xaa]);
- WFIFOW(fd,0)=0xaa;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=pos;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xaa]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xac]);
- WFIFOW(fd,0)=0xac;
- WFIFOW(fd,2)=n+2;
- WFIFOW(fd,4)=pos;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xac]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_misceffect(struct block_list* bl,int type)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0) = 0x19b;
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = type;
-
- clif_send(buf,packet_len_table[0x19b],bl,AREA);
-
- return 0;
-}
-int clif_misceffect2(struct block_list *bl, int type) {
- unsigned char buf[24];
-
- nullpo_retr(0, bl);
-
- malloc_set(buf, 0, packet_len_table[0x1f3]);
-
- WBUFW(buf,0) = 0x1f3;
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = type;
-
- clif_send(buf, packet_len_table[0x1f3], bl, AREA);
-
- return 0;
-
-}
-/*==========================================
- * 表示オプション変更
- *------------------------------------------
- */
-int clif_changeoption(struct block_list* bl)
-{
- unsigned char buf[32];
- struct status_change *sc;
-
- nullpo_retr(0, bl);
- sc = status_get_sc(bl);
- if (!sc) return 0; //How can an option change if there's no sc?
-
-#if PACKETVER > 6
- WBUFW(buf,0) = 0x229;
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc->opt1;
- WBUFW(buf,8) = sc->opt2;
- WBUFL(buf,10) = sc->option;
- WBUFB(buf,14) = 0; // ??
- if(disguised(bl)) {
- clif_send(buf,packet_len_table[0x229],bl,AREA_WOS);
- WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len_table[0x229],bl,SELF);
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,10) = OPTION_INVISIBLE;
- clif_send(buf,packet_len_table[0x229],bl,SELF);
- } else
- clif_send(buf,packet_len_table[0x229],bl,AREA);
-#else
- WBUFW(buf,0) = 0x119;
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc->opt1;
- WBUFW(buf,8) = sc->opt2;
- WBUFW(buf,10) = sc->option;
- WBUFB(buf,12) = 0; // ??
- if(disguised(bl)) {
- clif_send(buf,packet_len_table[0x119],bl,AREA_WOS);
- WBUFL(buf,2) = -bl->id;
- clif_send(buf,packet_len_table[0x119],bl,SELF);
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,10) = OPTION_INVISIBLE;
- clif_send(buf,packet_len_table[0x119],bl,SELF);
- } else
- clif_send(buf,packet_len_table[0x119],bl,AREA);
-#endif
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
-{
- nullpo_retr(0, sd);
-
- if(!ok) {
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xa8]);
- WFIFOW(fd,0)=0xa8;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xa8]);
- }
- else {
-#if PACKETVER < 3
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xa8]);
- WFIFOW(fd,0)=0xa8;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOB(fd,6)=ok;
- WFIFOSET(fd,packet_len_table[0xa8]);
-#else
- unsigned char buf[32];
-
- WBUFW(buf,0)=0x1c8;
- WBUFW(buf,2)=index+2;
- if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
- WBUFW(buf,4)=sd->inventory_data[index]->view_id;
- else
- WBUFW(buf,4)=sd->status.inventory[index].nameid;
- WBUFL(buf,6)=sd->bl.id;
- WBUFW(buf,10)=amount;
- WBUFB(buf,12)=ok;
- clif_send(buf,packet_len_table[0x1c8],&sd->bl,AREA);
-#endif
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_createchat(struct map_session_data *sd,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xd6]);
- WFIFOW(fd,0)=0xd6;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xd6]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_dispchat(struct chat_data *cd,int fd)
-{
- unsigned char buf[128]; // 最大title(60バイト)+17
-
- if(cd==NULL || *cd->owner==NULL)
- return 1;
-
- WBUFW(buf,0)=0xd7;
- WBUFW(buf,2)=strlen((const char*)cd->title)+17;
- WBUFL(buf,4)=(*cd->owner)->id;
- WBUFL(buf,8)=cd->bl.id;
- WBUFW(buf,12)=cd->limit;
- WBUFW(buf,14)=cd->users;
- WBUFB(buf,16)=cd->pub;
- strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
- if(fd){
- WFIFOHEAD(fd, WBUFW(buf,2));
- memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
- WFIFOSET(fd,WBUFW(buf,2));
- } else {
- clif_send(buf,WBUFW(buf,2),*cd->owner,AREA_WOSC);
- }
-
- return 0;
-}
-
-/*==========================================
- * chatの状態変更成功
- * 外部の人用と命令コード(d7->df)が違うだけ
- *------------------------------------------
- */
-int clif_changechatstatus(struct chat_data *cd)
-{
- unsigned char buf[128]; // 最大title(60バイト)+17
-
- if(cd==NULL || cd->usersd[0]==NULL)
- return 1;
-
- WBUFW(buf,0)=0xdf;
- WBUFW(buf,2)=strlen((char*)cd->title)+17;
- WBUFL(buf,4)=cd->usersd[0]->bl.id;
- WBUFL(buf,8)=cd->bl.id;
- WBUFW(buf,12)=cd->limit;
- WBUFW(buf,14)=cd->users;
- WBUFB(buf,16)=cd->pub;
- strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
- clif_send(buf,WBUFW(buf,2),&cd->usersd[0]->bl,CHAT);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_clearchat(struct chat_data *cd,int fd)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, cd);
-
- WBUFW(buf,0)=0xd8;
- WBUFL(buf,2)=cd->bl.id;
- if(fd){
- WFIFOHEAD(fd,packet_len_table[0xd8]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0xd8]);
- WFIFOSET(fd,packet_len_table[0xd8]);
- } else {
- clif_send(buf,packet_len_table[0xd8],*cd->owner,AREA_WOSC);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_joinchatfail(struct map_session_data *sd,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
-
- WFIFOHEAD(fd,packet_len_table[0xda]);
- WFIFOW(fd,0)=0xda;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xda]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
-{
- int fd;
- int i;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
-
- fd = sd->fd;
- if (!session_isActive(fd))
- return 0;
- WFIFOHEAD(fd, 8 + (28*cd->users));
- WFIFOW(fd, 0) = 0xdb;
- WFIFOW(fd, 2) = 8 + (28*cd->users);
- WFIFOL(fd, 4) = cd->bl.id;
- for (i = 0; i < cd->users; i++) {
- WFIFOL(fd, 8+i*28) = (i!=0) || ((*cd->owner)->type == BL_NPC);
- memcpy(WFIFOP(fd, 8+i*28+4), cd->usersd[i]->status.name, NAME_LENGTH);
- }
- WFIFOSET(fd, WFIFOW(fd, 2));
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_addchat(struct chat_data* cd,struct map_session_data *sd)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
-
- WBUFW(buf, 0) = 0x0dc;
- WBUFW(buf, 2) = cd->users;
- memcpy(WBUFP(buf, 4),sd->status.name,NAME_LENGTH);
- clif_send(buf,packet_len_table[0xdc],&sd->bl,CHAT_WOS);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd)
-{
- unsigned char buf[64];
-
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
-
- WBUFW(buf, 0) = 0xe1;
- WBUFL(buf, 2) = 1;
- memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,NAME_LENGTH);
- WBUFW(buf,30) = 0xe1;
- WBUFL(buf,32) = 0;
- memcpy(WBUFP(buf,36),sd->status.name,NAME_LENGTH);
-
- clif_send(buf,packet_len_table[0xe1]*2,&sd->bl,CHAT);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_leavechat(struct chat_data* cd,struct map_session_data *sd)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, sd);
- nullpo_retr(0, cd);
-
- WBUFW(buf, 0) = 0xdd;
- WBUFW(buf, 2) = cd->users-1;
- memcpy(WBUFP(buf,4),sd->status.name,NAME_LENGTH);
- WBUFB(buf,28) = 0;
-
- clif_send(buf,packet_len_table[0xdd],&sd->bl,CHAT);
-
- return 0;
-}
-
-/*==========================================
- * 取り引き要請受け
- *------------------------------------------
- */
-int clif_traderequest(struct map_session_data *sd,char *name)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
-
- WFIFOHEAD(fd,packet_len_table[0xe5]);
- WFIFOW(fd,0)=0xe5;
-
- strcpy((char*)WFIFOP(fd,2),name);
-
- WFIFOSET(fd,packet_len_table[0xe5]);
-
- return 0;
-}
-
-/*==========================================
- * 取り引き要求応答
- *------------------------------------------
- */
-int clif_tradestart(struct map_session_data *sd,int type)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xe7]);
- WFIFOW(fd,0)=0xe7;
- WFIFOB(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0xe7]);
-
- return 0;
-}
-
-/*==========================================
- * 相手方からのアイテム追加
- *------------------------------------------
- */
-int clif_tradeadditem(struct map_session_data *sd,struct map_session_data *tsd,int index,int amount)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, tsd);
-
- fd=tsd->fd;
- WFIFOHEAD(fd,packet_len_table[0xe9]);
- WFIFOW(fd,0)=0xe9;
- WFIFOL(fd,2)=amount;
- if(index==0){
- WFIFOW(fd,6) = 0; // type id
- WFIFOB(fd,8) = 0; //identify flag
- WFIFOB(fd,9) = 0; // attribute
- WFIFOB(fd,10)= 0; //refine
- WFIFOW(fd,11)= 0; //card (4w)
- WFIFOW(fd,13)= 0; //card (4w)
- WFIFOW(fd,15)= 0; //card (4w)
- WFIFOW(fd,17)= 0; //card (4w)
- }
- else{
- index-=2; //index fix
- if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
- WFIFOW(fd,6) = sd->inventory_data[index]->view_id;
- else
- WFIFOW(fd,6) = sd->status.inventory[index].nameid; // type id
- WFIFOB(fd,8) = sd->status.inventory[index].identify; //identify flag
- WFIFOB(fd,9) = sd->status.inventory[index].attribute; // attribute
- WFIFOB(fd,10)= sd->status.inventory[index].refine; //refine
- clif_addcards(WFIFOP(fd, 11), &sd->status.inventory[index]);
- }
- WFIFOSET(fd,packet_len_table[0xe9]);
-
- return 0;
-}
-
-/*==========================================
- * アイテム追加成功/失敗
- *------------------------------------------
- */
-int clif_tradeitemok(struct map_session_data *sd,int index,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xea]);
- WFIFOW(fd,0)=0xea;
- WFIFOW(fd,2)=index;
- WFIFOB(fd,4)=fail;
- WFIFOSET(fd,packet_len_table[0xea]);
-
- return 0;
-}
-
-/*==========================================
- * 取り引きok押し
- *------------------------------------------
- */
-int clif_tradedeal_lock(struct map_session_data *sd,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xec]);
- WFIFOW(fd,0)=0xec;
- WFIFOB(fd,2)=fail; // 0=you 1=the other person
- WFIFOSET(fd,packet_len_table[0xec]);
-
- return 0;
-}
-
-/*==========================================
- * 取り引きがキャンセルされました
- *------------------------------------------
- */
-int clif_tradecancelled(struct map_session_data *sd)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xee]);
- WFIFOW(fd,0)=0xee;
- WFIFOSET(fd,packet_len_table[0xee]);
-
- return 0;
-}
-
-/*==========================================
- * 取り引き完了
- *------------------------------------------
- */
-int clif_tradecompleted(struct map_session_data *sd,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf0]);
- WFIFOW(fd,0)=0xf0;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xf0]);
-
- return 0;
-}
-
-/*==========================================
- * カプラ倉庫のアイテム数を更新
- *------------------------------------------
- */
-int clif_updatestorageamount(struct map_session_data *sd,struct storage *stor)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf2]);
- WFIFOW(fd,0) = 0xf2; // update storage amount
- WFIFOW(fd,2) = stor->storage_amount; //items
- WFIFOW(fd,4) = MAX_STORAGE; //items max
- WFIFOSET(fd,packet_len_table[0xf2]);
-
- return 0;
-}
-
-/*==========================================
- * カプラ倉庫にアイテムを追加する
- *------------------------------------------
- */
-int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int index,int amount)
-{
- int view,fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf4]);
- WFIFOW(fd,0) =0xf4; // Storage item added
- WFIFOW(fd,2) =index+1; // index
- WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->storage_[index].nameid; // id
- WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
- WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage_[index].refine; //refine
- clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
- WFIFOSET(fd,packet_len_table[0xf4]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf2]);
- WFIFOW(fd,0) = 0xf2; // update storage amount
- WFIFOW(fd,2) = stor->storage_amount; //items
- WFIFOW(fd,4) = MAX_GUILD_STORAGE; //items max
- WFIFOSET(fd,packet_len_table[0xf2]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount)
-{
- int view,fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf4]);
- WFIFOW(fd,0) =0xf4; // Storage item added
- WFIFOW(fd,2) =index+1; // index
- WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->storage_[index].nameid; // id
- WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
- WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage_[index].refine; //refine
- clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
- WFIFOSET(fd,packet_len_table[0xf4]);
-
- return 0;
-}
-
-/*==========================================
- * カプラ倉庫からアイテムを取り去る
- *------------------------------------------
- */
-int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf6]);
- WFIFOW(fd,0)=0xf6; // Storage item removed
- WFIFOW(fd,2)=index+1;
- WFIFOL(fd,4)=amount;
- WFIFOSET(fd,packet_len_table[0xf6]);
-
- return 0;
-}
-
-/*==========================================
- * カプラ倉庫を閉じる
- *------------------------------------------
- */
-int clif_storageclose(struct map_session_data *sd)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xf8]);
- WFIFOW(fd,0)=0xf8; // Storage Closed
- WFIFOSET(fd,packet_len_table[0xf8]);
-
- return 0;
-}
-
-//
-// callback系 ?
-//
-/*==========================================
- * PC表示
- *------------------------------------------
- */
-void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
-{
- int len;
- if(dstsd->chatID){
- struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(dstsd->chatID);
- if(cd && cd->usersd[0]==dstsd)
- clif_dispchat(cd,sd->fd);
- }
- if(dstsd->vender_id)
- clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
-
- if(dstsd->spiritball > 0)
- clif_spiritball_single(sd->fd, dstsd);
-
- if((sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
- (battle_config.disp_hpmeter && (len = pc_isGM(sd)) >= battle_config.disp_hpmeter && len >= pc_isGM(dstsd))
- )
- clif_hpmeter_single(sd->fd, dstsd);
-
- if(dstsd->status.manner < 0)
- clif_changestatus(&dstsd->bl,SP_MANNER,dstsd->status.manner);
-
- // pvp circle for duel [LuzZza]
- /*
- if(dstsd->duel_group)
- clif_specialeffect(&dstsd->bl, 159, 4);
- */
-
-}
-void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
-{
- struct unit_data *ud;
- struct view_data *vd;
- int len, fd = sd->fd;
-
- vd = status_get_viewdata(bl);
-
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return;
-
- ud = unit_bl2ud(bl);
- if (ud && ud->walktimer != -1)
- {
-#if PACKETVER > 6
- WFIFOHEAD(fd, packet_len_table[0x22c]);
-#elif PACKETVER > 3
- WFIFOHEAD(fd, packet_len_table[0x1da]);
-#else
- WFIFOHEAD(fd, packet_len_table[0x7b]);
-#endif
- len = clif_set007b(bl,vd,ud,WFIFOP(fd,0));
- WFIFOSET(fd,len);
- } else {
-#if PACKETVER > 6
- WFIFOHEAD(fd,packet_len_table[0x22a]);
-#elif PACKETVER > 3
- WFIFOHEAD(fd,packet_len_table[0x1d8]);
-#else
- WFIFOHEAD(fd,packet_len_table[0x78]);
-#endif
- len = clif_set0078(bl,vd,WFIFOP(fd,0));
- WFIFOSET(fd,len);
- }
-
- if (vd->cloth_color)
- clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
-
- switch (bl->type)
- {
- case BL_PC:
- {
- TBL_PC* tsd = (TBL_PC*)bl;
- clif_getareachar_pc(sd, tsd);
- if(tsd->state.size==2) // tiny/big players [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(tsd->state.size==1)
- clif_specialeffect(bl,421,AREA);
- }
- break;
- case BL_NPC:
- {
- if(((TBL_NPC*)bl)->chat_id)
- clif_dispchat((struct chat_data*)map_id2bl(((TBL_NPC*)bl)->chat_id),sd->fd);
- }
- break;
- case BL_MOB:
- {
- TBL_MOB* md = (TBL_MOB*)bl;
- if(md->special_state.size==2) // tiny/big mobs [Valaris]
- clif_specialeffect(bl,423,AREA);
- else if(md->special_state.size==1)
- clif_specialeffect(bl,421,AREA);
- }
- break;
- }
-}
-
-/*==========================================
- * Older fix pos packet.
- *------------------------------------------
- */
-int clif_fixpos2(struct block_list* bl)
-{
- struct unit_data *ud;
- struct view_data *vd;
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, bl);
- ud = unit_bl2ud(bl);
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
-
- if(ud && ud->walktimer != -1)
- len = clif_set007b(bl,vd,ud,buf);
- else
- len = clif_set0078(bl,vd,buf);
-
- if (disguised(bl)) {
- clif_send(buf,len,bl,AREA_WOS);
- clif_setdisguise((TBL_PC*)bl, buf, len, 0);
- clif_setdisguise((TBL_PC*)bl, buf, len, 1);
- } else
- clif_send(buf,len,bl,AREA);
- return 0;
-}
-
-//Modifies the type of damage according to status changes [Skotlex]
-#define clif_calc_delay(type,delay) (type==1||type==4||type==0x0a)?type:(delay==0?9:type)
-
-/*==========================================
- * Estimates walk delay based on the damage criteria. [Skotlex]
- *------------------------------------------
- */
-static int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_) {
-
- if (type == 4 || type == 9 || damage <=0)
- return 0;
-
- if (bl->type == BL_PC) {
- if (battle_config.pc_walk_delay_rate != 100)
- delay = delay*battle_config.pc_walk_delay_rate/100;
- } else
- if (battle_config.walk_delay_rate != 100)
- delay = delay*battle_config.walk_delay_rate/100;
-
- if (div_ > 1) //Multi-hit skills mean higher delays.
- delay += battle_config.multihit_delay*(div_-1);
-
- return delay>0?delay:1; //Return 1 to specify there should be no noticeable delay, but you should stop walking.
-}
-
-/*==========================================
- * 通常攻撃エフェクト&ダメージ
- *------------------------------------------
- */
-int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,int type,int damage2)
-{
- unsigned char buf[256];
- struct status_change *sc;
-
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
-
- type = clif_calc_delay(type, ddelay); //Type defaults to 0 for normal attacks.
-
- sc = status_get_sc(dst);
-
- if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION].timer != -1) {
- if(damage > 0)
- damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- if(damage2 > 0)
- damage2 = damage2*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- }
- }
-
- WBUFW(buf,0)=0x8a;
- WBUFL(buf,2)=src->id;
- WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=tick;
- WBUFL(buf,14)=sdelay;
- WBUFL(buf,18)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFW(buf,22)=damage?div:0;
- WBUFW(buf,27)=damage2?div:0;
- } else {
- WBUFW(buf,22)=(damage > SHRT_MAX)?SHRT_MAX:damage;
- WBUFW(buf,27)=damage2;
- }
- WBUFW(buf,24)=div;
- WBUFB(buf,26)=type;
- clif_send(buf,packet_len_table[0x8a],src,AREA);
-
- if(disguised(src)) {
- WBUFL(buf,2)=-src->id;
- if(damage > 0)
- WBUFW(buf,22)=-1;
- if(damage2 > 0)
- WBUFW(buf,27)=-1;
- clif_send(buf,packet_len_table[0x8a],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,6)=-dst->id;
- if (disguised(src))
- WBUFL(buf,2)=src->id;
- else {
- if(damage > 0)
- WBUFW(buf,22)=-1;
- if(damage2 > 0)
- WBUFW(buf,27)=-1;
- }
- clif_send(buf,packet_len_table[0x8a],dst,SELF);
- }
- //Return adjusted can't walk delay for further processing.
- return clif_calc_walkdelay(dst,ddelay,type,damage+damage2,div);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
-{
- int view,fd;
- fd=sd->fd;
- //009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
- WFIFOHEAD(fd,packet_len_table[0x9d]);
-
- WFIFOW(fd,0)=0x9d;
- WFIFOL(fd,2)=fitem->bl.id;
- if((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
- WFIFOW(fd,6)=view;
- else
- WFIFOW(fd,6)=fitem->item_data.nameid;
- WFIFOB(fd,8)=fitem->item_data.identify;
- WFIFOW(fd,9)=fitem->bl.x;
- WFIFOW(fd,11)=fitem->bl.y;
- WFIFOW(fd,13)=fitem->item_data.amount;
- WFIFOB(fd,15)=fitem->subx;
- WFIFOB(fd,16)=fitem->suby;
- WFIFOSET(fd,packet_len_table[0x9d]);
-}
-
-/*==========================================
- * 場所スキルエフェクトが視界に入る
- *------------------------------------------
- */
-int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit)
-{
- int fd;
- struct block_list *bl;
-
- fd=sd->fd;
- bl=map_id2bl(unit->group->src_id);
-#if PACKETVER >= 3
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- WFIFOHEAD(fd,packet_len_table[0x1c9]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
- WFIFOW(fd, 0)=0x1c9;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y; // might be typo? [Lance]
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=1;
- WFIFOB(fd,16)=1;
- memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
- WFIFOSET(fd,packet_len_table[0x1c9]);
- return 0;
- }
-#endif
- WFIFOHEAD(fd,packet_len_table[0x11f]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x11f]);
- WFIFOW(fd, 0)=0x11f;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y;
- //Use invisible unit id for traps.
- if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP)
- WFIFOB(fd,14)=UNT_ATTACK_SKILLS;
- else
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=0;
- WFIFOSET(fd,packet_len_table[0x11f]);
-
- if(unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
- return 0;
-/* Previous implementation guess of packet 0x1c9, who can understand what all those fields are for? [Skotlex]
- WFIFOHEAD(fd,packet_len_table[0x1c9]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
- WFIFOW(fd, 0)=0x1c9;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y;
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=1;
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- WFIFOB(fd,16)=1;
- memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
- } else {
- WFIFOL(fd,15+1)=0; //1-4調べた限り固定
- WFIFOL(fd,15+5)=0; //5-8調べた限り固定
- //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
- WFIFOL(fd,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
- WFIFOL(fd,15+17)=0x004f37dd; //17-20調べた限り固定
- WFIFOL(fd,15+21)=0x0012f674; //21-24調べた限り固定
- WFIFOL(fd,15+25)=0x0012f664; //25-28調べた限り固定
- WFIFOL(fd,15+29)=0x0012f654; //29-32調べた限り固定
- WFIFOL(fd,15+33)=0x77527bbc; //33-36調べた限り固定
- //37-39
- WFIFOB(fd,15+40)=0x2d; //40調べた限り固定
- WFIFOL(fd,15+41)=0; //41-44調べた限り0固定
- WFIFOL(fd,15+45)=0; //45-48調べた限り0固定
- WFIFOL(fd,15+49)=0; //49-52調べた限り0固定
- WFIFOL(fd,15+53)=0x0048d919; //53-56調べた限り固定
- WFIFOL(fd,15+57)=0x0000003e; //57-60調べた限り固定
- WFIFOL(fd,15+61)=0x0012f66c; //61-64調べた限り固定
- //65-68
- //69-72
- if(bl) WFIFOL(fd,15+73)=bl->y; //73-76術者のY座標
- WFIFOL(fd,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
- WFIFOB(fd,15+81)=0xaa; //81終端文字0xaa
- }
-
- WFIFOSET(fd,packet_len_table[0x1c9]);
-#endif
- if(unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
-
- return 0;
-*/
-}
-
-/*==========================================
- * 場所スキルエフェクトが視界から消える
- *------------------------------------------
- */
-int clif_clearchar_skillunit(struct skill_unit *unit,int fd)
-{
- nullpo_retr(0, unit);
-
- WFIFOHEAD(fd,packet_len_table[0x120]);
- WFIFOW(fd, 0)=0x120;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOSET(fd,packet_len_table[0x120]);
- if(unit->group && unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_01ac(struct block_list *bl)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf, 0) = 0x1ac;
- WBUFL(buf, 2) = bl->id;
-
- clif_send(buf,packet_len_table[0x1ac],bl,AREA);
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
- int clif_getareachar(struct block_list* bl,va_list ap)
-{
- struct map_session_data *sd;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
- sd=va_arg(ap,struct map_session_data*);
-
- if (sd == NULL || !sd->fd || session[sd->fd] == NULL)
- return 0;
-
- switch(bl->type){
- case BL_ITEM:
- clif_getareachar_item(sd,(struct flooritem_data*) bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(sd,(TBL_SKILL*)bl);
- break;
- default:
- if(&sd->bl == bl)
- break;
- clif_getareachar_char(sd,bl);
- break;
- }
- return 0;
-}
-
-/*==========================================
- * tbl has gone out of view-size of bl
- *------------------------------------------
- */
-int clif_outsight(struct block_list *bl,va_list ap)
-{
- struct block_list *tbl;
- struct view_data *vd;
- TBL_PC *sd, *tsd;
- tbl=va_arg(ap,struct block_list*);
- if(bl == tbl) return 0;
- BL_CAST(BL_PC, bl, sd);
- BL_CAST(BL_PC, tbl, tsd);
-
- if (tsd && tsd->fd)
- { //tsd has lost sight of the bl object.
- switch(bl->type){
- case BL_PC:
- if (((TBL_PC*)bl)->vd.class_ != INVISIBLE_CLASS)
- clif_clearchar_id(bl->id,0,tsd->fd);
- if(sd->chatID){
- struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(sd->chatID);
- if(cd->usersd[0]==sd)
- clif_dispchat(cd,tsd->fd);
- }
- if(sd->vender_id)
- clif_closevendingboard(bl,tsd->fd);
- break;
- case BL_ITEM:
- clif_clearflooritem((struct flooritem_data*)bl,tsd->fd);
- break;
- case BL_SKILL:
- clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
- break;
- default:
- if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS)
- clif_clearchar_id(bl->id,0,tsd->fd);
- break;
- }
- }
- if (sd && sd->fd)
- { //sd is watching tbl go out of view.
- if ((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS)
- clif_clearchar_id(tbl->id,0,sd->fd);
- }
- return 0;
-}
-
-/*==========================================
- * tbl has come into view of bl
- *------------------------------------------
- */
-int clif_insight(struct block_list *bl,va_list ap)
-{
- struct block_list *tbl;
- TBL_PC *sd, *tsd;
- tbl=va_arg(ap,struct block_list*);
-
- if (bl == tbl) return 0;
-
- BL_CAST(BL_PC, bl, sd);
- BL_CAST(BL_PC, tbl, tsd);
-
- if (tsd && tsd->fd)
- { //Tell tsd that bl entered into his view
- switch(bl->type){
- case BL_ITEM:
- clif_getareachar_item(tsd,(struct flooritem_data*)bl);
- break;
- case BL_SKILL:
- clif_getareachar_skillunit(tsd,(TBL_SKILL*)bl);
- break;
- default:
- clif_getareachar_char(tsd,bl);
- break;
- }
- }
- if (sd && sd->fd)
- { //Tell sd that tbl walked into his view
- clif_getareachar_char(sd,tbl);
- }
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
-{
- int fd,id, inf2;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- if( (id=sd->status.skill[skillid].id) <= 0 )
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x147]);
- WFIFOW(fd,0)=0x147;
- WFIFOW(fd,2) = id;
- if(type < 0)
- WFIFOW(fd,4) = skill_get_inf(id);
- else
- WFIFOW(fd,4) = type;
- WFIFOW(fd,6) = 0;
- WFIFOW(fd,8) = sd->status.skill[skillid].lv;
- WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[skillid].lv);
- if(range < 0)
- range = skill_get_range2(&sd->bl, id,sd->status.skill[skillid].lv);
-
- WFIFOW(fd,12)= range;
- strncpy(WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH);
- inf2 = skill_get_inf2(id);
- if(((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
- !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL))) ||
- (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill))
- //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0;
- WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0;
- else
- WFIFOB(fd,38) = 0;
- WFIFOSET(fd,packet_len_table[0x147]);
-
- return 0;
-}
-
-/*==========================================
- * スキルリストを送信する
- *------------------------------------------
- */
-int clif_skillinfoblock(struct map_session_data *sd)
-{
- int fd;
- int i,c,len=4,id, inf2;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- if (!fd) return 0;
-
- WFIFOHEAD(fd, MAX_SKILL * 37 + 4);
- WFIFOW(fd,0)=0x10f;
- for ( i = c = 0; i < MAX_SKILL; i++){
- if( (id=sd->status.skill[i].id)!=0 ){
- WFIFOW(fd,len ) = id;
- WFIFOW(fd,len+2) = skill_get_inf(id);
- WFIFOW(fd,len+4) = 0;
- WFIFOW(fd,len+6) = sd->status.skill[i].lv;
- WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
- WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv);
- strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
- inf2 = skill_get_inf2(id);
- if(((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
- !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL))) ||
- (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
- WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[i].flag ==0 )? 1:0;
- else
- WFIFOB(fd,len+36) = 0;
- len+=37;
- c++;
- }
- }
- WFIFOW(fd,2)=len;
- WFIFOSET(fd,len);
-
- return 1;
-}
-
-/*==========================================
- * スキル割り振り通知
- *------------------------------------------
- */
-int clif_skillup(struct map_session_data *sd,int skill_num)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x10e]);
- WFIFOW(fd,0) = 0x10e;
- WFIFOW(fd,2) = skill_num;
- WFIFOW(fd,4) = sd->status.skill[skill_num].lv;
- WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv);
- WFIFOW(fd,8) = skill_get_range2(&sd->bl,skill_num,sd->status.skill[skill_num].lv);
- //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0;
- WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0;
- WFIFOSET(fd,packet_len_table[0x10e]);
-
- return 0;
-}
-
-/*==========================================
- * スキル詠唱エフェクトを送信する
- *------------------------------------------
- */
-int clif_skillcasting(struct block_list* bl,
- int src_id,int dst_id,int dst_x,int dst_y,int skill_num,int casttime)
-{
- int pl = skill_get_pl(skill_num);
- unsigned char buf[32];
- WBUFW(buf,0) = 0x13e;
- WBUFL(buf,2) = src_id;
- WBUFL(buf,6) = dst_id;
- WBUFW(buf,10) = dst_x;
- WBUFW(buf,12) = dst_y;
- WBUFW(buf,14) = skill_num;
- WBUFL(buf,16) = pl<0?0:pl; //Avoid sending negatives as element [Skotlex]
- WBUFL(buf,20) = casttime;
- clif_send(buf,packet_len_table[0x13e], bl, AREA);
- if (disguised(bl)) {
- WBUFL(buf,2) = -src_id;
- WBUFL(buf,20) = 0;
- clif_send(buf,packet_len_table[0x13e], bl, SELF);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_skillcastcancel(struct block_list* bl)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0) = 0x1b9;
- WBUFL(buf,2) = bl->id;
- clif_send(buf,packet_len_table[0x1b9], bl, AREA);
-
- return 0;
-}
-
-/*==========================================
- * スキル詠唱失敗
- *------------------------------------------
- */
-int clif_skill_fail(struct map_session_data *sd,int skill_id,int type,int btype)
-{
- int fd;
-
- if (!sd) { //Since this is the most common nullpo....
- ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id);
- return 0;
- }
-
- fd=sd->fd;
-
- if(battle_config.display_skill_fail&1)
- return 0; //Disable all skill failed messages
-
- if(type==0x4 && !sd->state.showdelay)
- return 0; //Disable delay failed messages
-
- if(skill_id == RG_SNATCHER && battle_config.display_skill_fail&4)
- return 0;
-
- if(skill_id == TF_POISON && battle_config.display_skill_fail&8)
- return 0;
-
- WFIFOHEAD(fd,packet_len_table[0x110]);
- WFIFOW(fd,0) = 0x110;
- WFIFOW(fd,2) = skill_id;
- WFIFOW(fd,4) = btype;
- WFIFOW(fd,6) = 0;
- WFIFOB(fd,8) = 0;
- WFIFOB(fd,9) = type;
- WFIFOSET(fd,packet_len_table[0x110]);
-
- return 1;
-}
-
-/*==========================================
- * スキル攻撃エフェクト&ダメージ
- *------------------------------------------
- */
-int clif_skill_damage(struct block_list *src,struct block_list *dst,
- unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
-{
- unsigned char buf[64];
- struct status_change *sc;
-
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
-
- type = (type>0)?type:skill_get_hit(skill_id);
- type = clif_calc_delay(type, ddelay);
- sc = status_get_sc(dst);
-
- if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION].timer != -1 && damage > 0)
- damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- }
-
-#if PACKETVER < 3
- WBUFW(buf,0)=0x114;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFL(buf,8)=dst->id;
- WBUFL(buf,12)=tick;
- WBUFL(buf,16)=sdelay;
- WBUFL(buf,20)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFW(buf,24)=damage?div:0;
- } else {
- WBUFW(buf,24)=damage;
- }
- WBUFW(buf,26)=skill_lv;
- WBUFW(buf,28)=div;
- WBUFB(buf,30)=type;
- clif_send(buf,packet_len_table[0x114],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x114],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,8)=-dst->id;
- if (disguised(src))
- WBUFL(buf,4)=src->id;
- else if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x114],dst,SELF);
- }
-#else
- WBUFW(buf,0)=0x1de;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFL(buf,8)=dst->id;
- WBUFL(buf,12)=tick;
- WBUFL(buf,16)=sdelay;
- WBUFL(buf,20)=ddelay;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFL(buf,24)=damage?div:0;
- } else {
- WBUFL(buf,24)=damage;
- }
- WBUFW(buf,28)=skill_lv;
- WBUFW(buf,30)=div;
- WBUFB(buf,32)=type;
- clif_send(buf,packet_len_table[0x1de],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x1de],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,8)=-dst->id;
- if (disguised(src))
- WBUFL(buf,4)=src->id;
- else if(damage > 0)
- WBUFW(buf,24)=-1;
- clif_send(buf,packet_len_table[0x1de],dst,SELF);
- }
-#endif
-
- //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
- return clif_calc_walkdelay(dst,ddelay,type,damage,div);
-}
-
-/*==========================================
- * 吹き飛ばしスキル攻撃エフェクト&ダメージ
- *------------------------------------------
- */
-int clif_skill_damage2(struct block_list *src,struct block_list *dst,
- unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
-{
- unsigned char buf[64];
- struct status_change *sc;
-
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
-
- type = (type>0)?type:skill_get_hit(skill_id);
- type = clif_calc_delay(type, ddelay);
- sc = status_get_sc(dst);
-
- if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION].timer != -1 && damage > 0)
- damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
- }
-
- WBUFW(buf,0)=0x115;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFL(buf,8)=dst->id;
- WBUFL(buf,12)=tick;
- WBUFL(buf,16)=sdelay;
- WBUFL(buf,20)=ddelay;
- WBUFW(buf,24)=dst->x;
- WBUFW(buf,26)=dst->y;
- if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
- WBUFW(buf,28)=damage?div:0;
- } else {
- WBUFW(buf,28)=damage;
- }
- WBUFW(buf,30)=skill_lv;
- WBUFW(buf,32)=div;
- WBUFB(buf,34)=type;
- clif_send(buf,packet_len_table[0x115],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- if(damage > 0)
- WBUFW(buf,28)=-1;
- clif_send(buf,packet_len_table[0x115],src,SELF);
- }
- if (disguised(dst)) {
- WBUFL(buf,8)=-dst->id;
- if (disguised(src))
- WBUFL(buf,4)=src->id;
- else if(damage > 0)
- WBUFW(buf,28)=-1;
- clif_send(buf,packet_len_table[0x115],dst,SELF);
- }
-
- //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
- return clif_calc_walkdelay(dst,ddelay,type,damage,div);
-}
-
-/*==========================================
- * 支援/回復スキルエフェクト
- *------------------------------------------
- */
-int clif_skill_nodamage(struct block_list *src,struct block_list *dst,
- int skill_id,int heal,int fail)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, dst);
-
- WBUFW(buf,0)=0x11a;
- WBUFW(buf,2)=skill_id;
- WBUFW(buf,4)=(heal > SHRT_MAX)? SHRT_MAX:heal;
- WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=src?src->id:0;
- WBUFB(buf,14)=fail;
- clif_send(buf,packet_len_table[0x11a],dst,AREA);
-
- if (disguised(dst)) {
- WBUFL(buf,6)=-dst->id;
- clif_send(buf,packet_len_table[0x115],dst,SELF);
- }
-
- if(src && disguised(src)) {
- WBUFL(buf,10)=-src->id;
- if (disguised(dst))
- WBUFL(buf,6)=dst->id;
- clif_send(buf,packet_len_table[0x115],src,SELF);
- }
-
- return fail;
-}
-
-/*==========================================
- * 場所スキルエフェクト
- *------------------------------------------
- */
-int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, src);
-
- WBUFW(buf,0)=0x117;
- WBUFW(buf,2)=skill_id;
- WBUFL(buf,4)=src->id;
- WBUFW(buf,8)=val;
- WBUFW(buf,10)=x;
- WBUFW(buf,12)=y;
- WBUFL(buf,14)=tick;
- clif_send(buf,packet_len_table[0x117],src,AREA);
- if(disguised(src)) {
- WBUFL(buf,4)=-src->id;
- clif_send(buf,packet_len_table[0x117],src,SELF);
- }
-
- return 0;
-}
-
-/*==========================================
- * 場所スキルエフェクト表示
- *------------------------------------------
- */
-int clif_skill_setunit(struct skill_unit *unit)
-{
- unsigned char buf[128];
- struct block_list *bl;
-
- nullpo_retr(0, unit);
-
- bl=map_id2bl(unit->group->src_id);
-
-// These are invisible client-side, but are necessary because
-// otherwise the client will not know who caused the attack.
-// if (unit->group->unit_id == UNT_ATTACK_SKILLS)
-// return 0;
-
-#if PACKETVER >= 3
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
- WBUFW(buf, 0)=0x1c9;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
- WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- } else {
- WBUFB(buf,14)=unit->group->unit_id;
- }
- WBUFB(buf,15)=1;
- WBUFB(buf,16)=1;
- memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
- clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
- return 0;
- }
-#endif
- malloc_set(WBUFP(buf, 0),0,packet_len_table[0x11f]);
- WBUFW(buf, 0)=0x11f;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
- WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- } else {
- WBUFB(buf,14)=unit->group->unit_id;
- }
- WBUFB(buf,15)=0;
- clif_send(buf,packet_len_table[0x11f],&unit->bl,AREA);
- return 0;
-
-/* Previous mysterious implementation noone really understands. [Skotlex]
- malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
- WBUFW(buf, 0)=0x1c9;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- WBUFB(buf,14)=unit->group->unit_id;
- WBUFB(buf,15)=1;
- if(unit->group->unit_id==0xb0) { // Graffiti [Valaris]
- WBUFB(buf,16)=1;
- memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
- } else {
- WBUFL(buf,15+1)=0; //1-4調べた限り固定
- WBUFL(buf,15+5)=0; //5-8調べた限り固定
- //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
- WBUFL(buf,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
- WBUFL(buf,15+17)=0x004f37dd; //17-20調べた限り固定(0x1b2で0x004fdbddだった)
- WBUFL(buf,15+21)=0x0012f674; //21-24調べた限り固定
- WBUFL(buf,15+25)=0x0012f664; //25-28調べた限り固定
- WBUFL(buf,15+29)=0x0012f654; //29-32調べた限り固定
- WBUFL(buf,15+33)=0x77527bbc; //33-36調べた限り固定
- //37-39
- WBUFB(buf,15+40)=0x2d; //40調べた限り固定
- WBUFL(buf,15+41)=0; //41-44調べた限り0固定
- WBUFL(buf,15+45)=0; //45-48調べた限り0固定
- WBUFL(buf,15+49)=0; //49-52調べた限り0固定
- WBUFL(buf,15+53)=0x0048d919; //53-56調べた限り固定(0x01b2で0x00495119だった)
- WBUFL(buf,15+57)=0x0000003e; //57-60調べた限り固定
- WBUFL(buf,15+61)=0x0012f66c; //61-64調べた限り固定
- //65-68
- //69-72
- if(bl) WBUFL(buf,15+73)=bl->y; //73-76術者のY座標
- WBUFL(buf,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
- WBUFB(buf,15+81)=0xaa; //81終端文字0xaa
- }
- clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
-#endif
- return 0;
-*/
-}
-/*==========================================
- * 場所スキルエフェクト削除
- *------------------------------------------
- */
-int clif_skill_delunit(struct skill_unit *unit)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, unit);
-
- WBUFW(buf, 0)=0x120;
- WBUFL(buf, 2)=unit->bl.id;
- clif_send(buf,packet_len_table[0x120],&unit->bl,AREA);
- return 0;
-}
-/*==========================================
- * ワープ場所選択
- *------------------------------------------
- */
-int clif_skill_warppoint(struct map_session_data *sd,int skill_num,int skill_lv,
- const char *map1,const char *map2,const char *map3,const char *map4)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x11c]);
- WFIFOW(fd,0)=0x11c;
- WFIFOW(fd,2)=skill_num;
- strncpy((char*)WFIFOP(fd, 4),map1,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,20),map2,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,36),map3,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,52),map4,MAP_NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x11c]);
- sd->menuskill_id = skill_num;
- if (skill_num == AL_WARP)
- sd->menuskill_lv = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here.
- else
- sd->menuskill_lv = skill_lv;
- return 0;
-}
-/*==========================================
- * メモ応答
- *------------------------------------------
- */
-int clif_skill_memo(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
-
- WFIFOHEAD(fd,packet_len_table[0x11e]);
- WFIFOW(fd,0)=0x11e;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x11e]);
- return 0;
-}
-int clif_skill_teleportmessage(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x189]);
- WFIFOW(fd,0)=0x189;
- WFIFOW(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x189]);
- return 0;
-}
-
-/*==========================================
- * モンスター情報
- *------------------------------------------
- */
-int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
-{
- struct status_data *status;
- unsigned char buf[64];
- int i;//, fix;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, dst);
-
- if(dst->type!=BL_MOB )
- return 0;
-
- status = status_get_status_data(dst);
-
- WBUFW(buf, 0)=0x18c;
- WBUFW(buf, 2)=status_get_class(dst);
- WBUFW(buf, 4)=status_get_lv(dst);
- WBUFW(buf, 6)=status->size;
- WBUFL(buf, 8)=status->hp;
- WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0)
- +(battle_config.estimation_type&2?status->def2:0);
- WBUFW(buf,14)=status->race;
- WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0)
- +(battle_config.estimation_type&2?status->mdef2:0);
- WBUFW(buf,18)= status->def_ele;
- for(i=0;i<9;i++)
- WBUFB(buf,20+i)= (unsigned char)battle_attr_fix(NULL,dst,100,i+1,status->def_ele, status->ele_lv);
-// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex]
-// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_fix(NULL,dst,100,i+1,status->def_ele, status->ele_lv))<0?0:fix);
-
- clif_send(buf,packet_len_table[0x18c],&sd->bl,
- sd->status.party_id>0?PARTY_SAMEMAP:SELF);
- return 0;
-}
-/*==========================================
- * アイテム合成可能リスト
- *------------------------------------------
- */
-int clif_skill_produce_mix_list(struct map_session_data *sd, int trigger)
-{
- int i,c,view,fd;
- nullpo_retr(0, sd);
-
- if(sd->menuskill_id == AM_PHARMACY)
- return 0; //Avoid resending the menu twice or more times...
- fd=sd->fd;
- WFIFOHEAD(fd, MAX_SKILL_PRODUCE_DB * 8 + 8);
- WFIFOW(fd, 0)=0x18d;
-
- for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
- if( skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger, 1) ){
- if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
- WFIFOW(fd,c*8+ 4)= view;
- else
- WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid;
- WFIFOW(fd,c*8+ 6)= 0x0012;
- WFIFOL(fd,c*8+ 8)= sd->status.char_id;
- c++;
- }
- }
- WFIFOW(fd, 2)=c*8+8;
- WFIFOSET(fd,WFIFOW(fd,2));
- if(c > 0) {
- sd->menuskill_id = AM_PHARMACY;
- sd->menuskill_lv = trigger;
- return 1;
- }
- return 0;
-}
-
-/*==========================================
- * Sends a status change packet to the object only, used for loading status changes. [Skotlex]
- *------------------------------------------
- */
-int clif_status_load(struct block_list *bl,int type, int flag)
-{
- int fd;
- if (type == SI_BLANK) //It shows nothing on the client...
- return 0;
-
- if (bl->type != BL_PC)
- return 0;
-
- fd = ((struct map_session_data*)bl)->fd;
-
- WFIFOHEAD(fd,packet_len_table[0x196]);
- WFIFOW(fd,0)=0x0196;
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=bl->id;
- WFIFOB(fd,8)=flag; //Status start
- WFIFOSET(fd, packet_len_table[0x196]);
- return 0;
-}
-/*==========================================
- * 状態異常アイコン/メッセージ表示
- *------------------------------------------
- */
-int clif_status_change(struct block_list *bl,int type,int flag)
-{
- unsigned char buf[16];
-
- if (type == SI_BLANK) //It shows nothing on the client...
- return 0;
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x0196;
- WBUFW(buf,2)=type;
- WBUFL(buf,4)=bl->id;
- WBUFB(buf,8)=flag;
- clif_send(buf,packet_len_table[0x196],bl,AREA);
- return 0;
-}
-
-/*==========================================
- * Send message (modified by [Yor])
- *------------------------------------------
- */
-int clif_displaymessage(const int fd, char* mes)
-{
- // invalid pointer?
- nullpo_retr(-1, mes);
-
- //Console [Wizputer] //Scrapped, as these are shared by disconnected players =X [Skotlex]
- if (fd == 0)
- return 0;
- else {
- int len_mes = strlen(mes);
-
- if (len_mes > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
- WFIFOHEAD(fd, 5 + len_mes);
- WFIFOW(fd,0) = 0x8e;
- WFIFOW(fd,2) = 5 + len_mes; // 4 + len + NULL teminate
- memcpy(WFIFOP(fd,4), mes, len_mes + 1);
- WFIFOSET(fd, 5 + len_mes);
- }
- }
-
- return 0;
-}
-
-/*==========================================
- * 天の声を送信する
- *------------------------------------------
- */
-int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
-{
- unsigned char *buf;
- int lp;
-
- lp = (flag & 0x10) ? 8 : 4;
- buf = (unsigned char*)aMallocA((len + lp + 8)*sizeof(unsigned char));
-
- WBUFW(buf,0) = 0x9a;
- WBUFW(buf,2) = len + lp;
- WBUFL(buf,4) = 0x65756c62; //"blue":
- memcpy(WBUFP(buf,lp), mes, len);
- flag &= 0x07;
- clif_send(buf, WBUFW(buf,2), bl,
- (flag == 1) ? ALL_SAMEMAP :
- (flag == 2) ? AREA :
- (flag == 3) ? SELF :
- ALL_CLIENT);
- if(buf) aFree(buf);
-
- if(use_irc && irc_announce_flag && !flag)
- irc_announce(mes);
-
- return 0;
-}
-
-/*==========================================
- * グローバルメッセージ
- *------------------------------------------
- */
-void clif_GlobalMessage(struct block_list *bl,char *message)
-{
- char buf[100];
- int len;
-
- nullpo_retv(bl);
-
- if(!message)
- return;
-
- len = strlen(message)+1;
-
- WBUFW(buf,0)=0x8d;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=bl->id;
- strncpy((char *) WBUFP(buf,8),message,len);
- clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT);
-}
-
-/*==========================================
- * Send main chat message [LuzZza]
- *------------------------------------------
- */
-void clif_MainChatMessage(char* message) {
-
- char buf[200];
- int len;
-
- if(!message)
- return;
-
- len = strlen(message)+1;
- if (len+8 > sizeof(buf)) {
- ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message);
- len = sizeof(buf)-8;
- }
- WBUFW(buf,0)=0x8d;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=0;
- strncpy((char *) WBUFP(buf,8),message,len);
- clif_send((unsigned char *) buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT);
-}
-
-/*==========================================
- * Does an announce message in the given color.
- *------------------------------------------
- */
-int clif_announce(struct block_list *bl, char* mes, int len, unsigned long color, int flag)
-{
- unsigned char *buf;
- buf = (unsigned char*)aMallocA((len + 16)*sizeof(unsigned char));
- WBUFW(buf,0) = 0x1c3;
- WBUFW(buf,2) = len + 16;
- WBUFL(buf,4) = color;
- WBUFW(buf,8) = 0x190; //Font style? Type?
- WBUFW(buf,10) = 0x0c; //12? Font size?
- WBUFL(buf,12) = 0; //Unknown!
- memcpy(WBUFP(buf,16), mes, len);
-
- flag &= 0x07;
- clif_send(buf, WBUFW(buf,2), bl,
- (flag == 1) ? ALL_SAMEMAP :
- (flag == 2) ? AREA :
- (flag == 3) ? SELF :
- ALL_CLIENT);
-
- if(buf) aFree(buf);
- return 0;
-}
-/*==========================================
- * HPSP回復エフェクトを送信する
- *------------------------------------------
- */
-int clif_heal(int fd,int type,int val)
-{
- WFIFOHEAD(fd,packet_len_table[0x13d]);
- WFIFOW(fd,0)=0x13d;
- WFIFOW(fd,2)=type;
- WFIFOW(fd,4)=val;
- WFIFOSET(fd,packet_len_table[0x13d]);
-
- return 0;
-}
-
-/*==========================================
- * 復活する
- *------------------------------------------
- */
-int clif_resurrection(struct block_list *bl,int type)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x148;
- WBUFL(buf,2)=bl->id;
- WBUFW(buf,6)=type;
-
- clif_send(buf,packet_len_table[0x148],bl,type==1 ? AREA : AREA_WOS);
- if (disguised(bl))
- clif_spawn(bl);
-
- return 0;
-}
-
-/*==========================================
- * PVP実装?(仮)
- *------------------------------------------
- */
-int clif_set0199(int fd,int type)
-{
- WFIFOHEAD(fd,packet_len_table[0x199]);
- WFIFOW(fd,0)=0x199;
- WFIFOW(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0x199]);
-
- return 0;
-}
-
-/*==========================================
- * PVP実装?(仮)
- *------------------------------------------
- */
-int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
-{
- nullpo_retr(0, sd);
-
- if(type == 2) {
- WFIFOHEAD(sd->fd,packet_len_table[0x19a]);
- WFIFOW(sd->fd,0) = 0x19a;
- WFIFOL(sd->fd,2) = sd->bl.id;
- WFIFOL(sd->fd,6) = pvprank;
- WFIFOL(sd->fd,10) = pvpnum;
- WFIFOSET(sd->fd,packet_len_table[0x19a]);
- } else {
- unsigned char buf[32];
- WBUFW(buf,0) = 0x19a;
- WBUFL(buf,2) = sd->bl.id;
- if(sd->sc.option&(OPTION_HIDE|OPTION_CLOAK))
- WBUFL(buf,6) = ULONG_MAX; //On client displays as --
- else
- WBUFL(buf,6) = pvprank;
- WBUFL(buf,10) = pvpnum;
- if(sd->sc.option&OPTION_INVISIBLE)
- clif_send(buf,packet_len_table[0x19a],&sd->bl,SELF);
- else if(!type)
- clif_send(buf,packet_len_table[0x19a],&sd->bl,AREA);
- else
- clif_send(buf,packet_len_table[0x19a],&sd->bl,ALL_SAMEMAP);
- }
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_send0199(int map,int type)
-{
- struct block_list bl;
- unsigned char buf[16];
-
- bl.id = 0;
- bl.type = BL_NUL;
- bl.m = map;
- WBUFW(buf,0)=0x199;
- WBUFW(buf,2)=type;
- clif_send(buf,packet_len_table[0x199],&bl,ALL_SAMEMAP);
-
- return 0;
-}
-
-/*==========================================
- * 精錬エフェクトを送信する
- *------------------------------------------
- */
-int clif_refine(int fd,struct map_session_data *sd,int fail,int index,int val)
-{
- WFIFOHEAD(fd,packet_len_table[0x188]);
- WFIFOW(fd,0)=0x188;
- WFIFOW(fd,2)=fail;
- WFIFOW(fd,4)=index+2;
- WFIFOW(fd,6)=val;
- WFIFOSET(fd,packet_len_table[0x188]);
-
- return 0;
-}
-
-/*==========================================
- * Wisp/page is transmitted to the destination player
- *------------------------------------------
- */
-int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B
-{
-// printf("clif_wis_message(%d, %s, %s)\n", fd, nick, mes);
-
- WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4);
- WFIFOW(fd,0) = 0x97;
- WFIFOW(fd,2) = mes_len + NAME_LENGTH + 4;
- memcpy(WFIFOP(fd,4), nick, NAME_LENGTH);
- memcpy(WFIFOP(fd,28), mes, mes_len);
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-
-/*==========================================
- * The transmission result of Wisp/page is transmitted to the source player
- *------------------------------------------
- */
-int clif_wis_end(int fd, int flag) // R 0098 <type>.B: 0: success to send wisper, 1: target character is not loged in, 2: ignored by target, 3: everyone ignored by target
-{
- WFIFOHEAD(fd,packet_len_table[0x98]);
- WFIFOW(fd,0) = 0x98;
- WFIFOW(fd,2) = flag;
- WFIFOSET(fd,packet_len_table[0x98]);
- return 0;
-}
-
-/*==========================================
- * キャラID名前引き結果を送信する
- *------------------------------------------
- */
-int clif_solved_charname(struct map_session_data *sd,int char_id)
-{
- char *p= map_charid2nick(char_id);
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- if(p!=NULL){
- WFIFOHEAD(fd,packet_len_table[0x194]);
- WFIFOW(fd,0)=0x194;
- WFIFOL(fd,2)=char_id;
- memcpy(WFIFOP(fd,6), p, NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x194]);
- }else{
- map_reqchariddb(sd,char_id);
- chrif_searchcharid(char_id);
- }
- return 0;
-}
-
-/*==========================================
- * カードの挿入可能リストを返す
- *------------------------------------------
- */
-int clif_use_card(struct map_session_data *sd,int idx)
-{
- int i,c,ep;
- int fd=sd->fd;
-
- nullpo_retr(0, sd);
- if (idx < 0 || idx >= MAX_INVENTORY) //Crash-fix from bad packets.
- return 0;
-
- if (!sd->inventory_data[idx] || sd->inventory_data[idx]->type != IT_CARD)
- return 0; //Avoid parsing invalid item indexes (no card/no item)
-
- ep=sd->inventory_data[idx]->equip;
- WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x017b;
-
- for(i=c=0;i<MAX_INVENTORY;i++){
- int j;
-
- if(sd->inventory_data[i] == NULL)
- continue;
- if(sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR)
- continue;
- if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it
- continue;
-
- if(sd->status.inventory[i].identify==0 ) //Not identified
- continue;
-
- if((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part.
- continue;
-
- if(sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_HAND_L) //Shield card won't go on left weapon.
- continue;
-
- for(j=0;j<sd->inventory_data[i]->slot;j++){
- if( sd->status.inventory[i].card[j]==0 )
- break;
- }
- if(j==sd->inventory_data[i]->slot) // No room
- continue;
-
- WFIFOW(fd,4+c*2)=i+2;
- c++;
- }
- WFIFOW(fd,2)=4+c*2;
- WFIFOSET(fd,WFIFOW(fd,2));
-
- return 0;
-}
-/*==========================================
- * カードの挿入終了
- *------------------------------------------
- */
-int clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x17d]);
- WFIFOW(fd,0)=0x17d;
- WFIFOW(fd,2)=idx_equip+2;
- WFIFOW(fd,4)=idx_card+2;
- WFIFOB(fd,6)=flag;
- WFIFOSET(fd,packet_len_table[0x17d]);
- return 0;
-}
-
-/*==========================================
- * 鑑定可能アイテムリスト送信
- *------------------------------------------
- */
-int clif_item_identify_list(struct map_session_data *sd)
-{
- int i,c;
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
-
- WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x177;
- for(i=c=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid > 0 && !sd->status.inventory[i].identify){
- WFIFOW(fd,c*2+4)=i+2;
- c++;
- }
- }
- if(c > 0) {
- WFIFOW(fd,2)=c*2+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = MC_IDENTIFY;
- sd->menuskill_lv = c;
- }
- return 0;
-}
-
-/*==========================================
- * 鑑定結果
- *------------------------------------------
- */
-int clif_item_identified(struct map_session_data *sd,int idx,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x179]);
- WFIFOW(fd, 0)=0x179;
- WFIFOW(fd, 2)=idx+2;
- WFIFOB(fd, 4)=flag;
- WFIFOSET(fd,packet_len_table[0x179]);
- return 0;
-}
-
-/*==========================================
- * 修理可能アイテムリスト送信
- *------------------------------------------
- */
-int clif_item_repair_list(struct map_session_data *sd,struct map_session_data *dstsd)
-{
- int i,c;
- int fd;
- int nameid;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, dstsd);
-
- fd=sd->fd;
-
- WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
- WFIFOW(fd,0)=0x1fc;
- for(i=c=0;i<MAX_INVENTORY;i++){
- if((nameid=dstsd->status.inventory[i].nameid) > 0 && dstsd->status.inventory[i].attribute!=0){// && skill_can_repair(sd,nameid)){
- WFIFOW(fd,c*13+4) = i;
- WFIFOW(fd,c*13+6) = nameid;
- WFIFOL(fd,c*13+8) = sd->status.char_id;
- WFIFOL(fd,c*13+12)= dstsd->status.char_id;
- WFIFOB(fd,c*13+16)= c;
- c++;
- }
- }
- if(c > 0) {
- WFIFOW(fd,2)=c*13+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = BS_REPAIRWEAPON;
- sd->menuskill_lv = dstsd->bl.id;
- }else
- clif_skill_fail(sd,sd->ud.skillid,0,0);
-
- return 0;
-}
-int clif_item_repaireffect(struct map_session_data *sd,int nameid,int flag)
-{
- int view,fd;
-
- nullpo_retr(0, sd);
- fd=sd->fd;
-
- WFIFOHEAD(fd,packet_len_table[0x1fe]);
- WFIFOW(fd, 0)=0x1fe;
- if((view = itemdb_viewid(nameid)) > 0)
- WFIFOW(fd, 2)=view;
- else
- WFIFOW(fd, 2)=nameid;
- WFIFOB(fd, 4)=flag;
- WFIFOSET(fd,packet_len_table[0x1fe]);
-
- return 0;
-}
-
-/*==========================================
- * Weapon Refining - Taken from jAthena
- *------------------------------------------
- */
-int clif_item_refine_list(struct map_session_data *sd)
-{
- int i,c;
- int fd;
- int skilllv;
- int wlv;
- int refine_item[5];
-
- nullpo_retr(0, sd);
-
- skilllv = pc_checkskill(sd,WS_WEAPONREFINE);
-
- fd=sd->fd;
-
- refine_item[0] = -1;
- refine_item[1] = pc_search_inventory(sd,1010);
- refine_item[2] = pc_search_inventory(sd,1011);
- refine_item[3] = refine_item[4] = pc_search_inventory(sd,984);
-
- WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
- WFIFOW(fd,0)=0x221;
- for(i=c=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skilllv &&
- sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 &&
- refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&0x0022)){
- WFIFOW(fd,c*13+ 4)=i+2;
- WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid;
- WFIFOW(fd,c*13+ 8)=0; //TODO: Wonder what are these for? Perhaps ID of weapon's crafter if any?
- WFIFOW(fd,c*13+10)=0;
- WFIFOB(fd,c*13+12)=c;
- c++;
- }
- }
- WFIFOW(fd,2)=c*13+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- sd->menuskill_id = WS_WEAPONREFINE;
- sd->menuskill_lv = skilllv;
-
- return 0;
-}
-
-/*==========================================
- * アイテムによる一時的なスキル効果
- *------------------------------------------
- */
-int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv,const char *name)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x147]);
- WFIFOW(fd, 0)=0x147;
- WFIFOW(fd, 2)=skillid;
- WFIFOW(fd, 4)=skill_get_inf(skillid);
- WFIFOW(fd, 6)=0;
- WFIFOW(fd, 8)=skilllv;
- WFIFOW(fd,10)=skill_get_sp(skillid,skilllv);
- WFIFOW(fd,12)=skill_get_range2(&sd->bl, skillid,skilllv);
- strncpy((char*)WFIFOP(fd,14),name,NAME_LENGTH);
- WFIFOB(fd,38)=0;
- WFIFOSET(fd,packet_len_table[0x147]);
- return 0;
-}
-
-/*==========================================
- * カートにアイテム追加
- *------------------------------------------
- */
-int clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
-{
- int view,fd;
- unsigned char *buf;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x124]);
- buf=WFIFOP(fd,0);
- if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0)
- return 1;
-
- WBUFW(buf,0)=0x124;
- WBUFW(buf,2)=n+2;
- WBUFL(buf,4)=amount;
- if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0)
- WBUFW(buf,8)=view;
- else
- WBUFW(buf,8)=sd->status.cart[n].nameid;
- WBUFB(buf,10)=sd->status.cart[n].identify;
- WBUFB(buf,11)=sd->status.cart[n].attribute;
- WBUFB(buf,12)=sd->status.cart[n].refine;
- clif_addcards(WBUFP(buf,13), &sd->status.cart[n]);
- WFIFOSET(fd,packet_len_table[0x124]);
- return 0;
-}
-
-/*==========================================
- * カートからアイテム削除
- *------------------------------------------
- */
-int clif_cart_delitem(struct map_session_data *sd,int n,int amount)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
-
- WFIFOHEAD(fd,packet_len_table[0x125]);
- WFIFOW(fd,0)=0x125;
- WFIFOW(fd,2)=n+2;
- WFIFOL(fd,4)=amount;
-
- WFIFOSET(fd,packet_len_table[0x125]);
-
- return 0;
-}
-
-/*==========================================
- * 露店開設
- *------------------------------------------
- */
-int clif_openvendingreq(struct map_session_data *sd,int num)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x12d]);
- WFIFOW(fd,0)=0x12d;
- WFIFOW(fd,2)=num;
- WFIFOSET(fd,packet_len_table[0x12d]);
-
- return 0;
-}
-
-/*==========================================
- * 露店看板表示
- *------------------------------------------
- */
-int clif_showvendingboard(struct block_list* bl,char *message,int fd)
-{
- unsigned char buf[128];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x131;
- WBUFL(buf,2)=bl->id;
- strncpy((char*)WBUFP(buf,6),message,80);
- if(fd){
- WFIFOHEAD(fd,packet_len_table[0x131]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0x131]);
- WFIFOSET(fd,packet_len_table[0x131]);
- }else{
- clif_send(buf,packet_len_table[0x131],bl,AREA_WOS);
- }
- return 0;
-}
-
-/*==========================================
- * 露店看板消去
- *------------------------------------------
- */
-int clif_closevendingboard(struct block_list* bl,int fd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x132;
- WBUFL(buf,2)=bl->id;
- if(fd){
- WFIFOHEAD(fd,packet_len_table[0x132]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0x132]);
- WFIFOSET(fd,packet_len_table[0x132]);
- }else{
- clif_send(buf,packet_len_table[0x132],bl,AREA_WOS);
- }
-
- return 0;
-}
-/*==========================================
- * 露店アイテムリスト
- *------------------------------------------
- */
-int clif_vendinglist(struct map_session_data *sd,int id,struct vending *vending)
-{
- struct item_data *data;
- int i,n,index,fd;
- struct map_session_data *vsd;
- unsigned char *buf;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, vending);
- nullpo_retr(0, vsd=map_id2sd(id));
-
- fd=sd->fd;
- WFIFOHEAD(fd, 8+vsd->vend_num*22);
- buf = WFIFOP(fd,0);
- for(i=0,n=0;i<vsd->vend_num;i++){
- if(vending[i].amount<=0)
- continue;
- WBUFL(buf,8+n*22)=vending[i].value;
- WBUFW(buf,12+n*22)=vending[i].amount;
- WBUFW(buf,14+n*22)=(index=vending[i].index)+2;
- if(vsd->status.cart[index].nameid <= 0 || vsd->status.cart[index].amount <= 0)
- continue;
- data = itemdb_search(vsd->status.cart[index].nameid);
- WBUFB(buf,16+n*22)=itemtype(data->type);
- if(data->view_id > 0)
- WBUFW(buf,17+n*22)=data->view_id;
- else
- WBUFW(buf,17+n*22)=vsd->status.cart[index].nameid;
- WBUFB(buf,19+n*22)=vsd->status.cart[index].identify;
- WBUFB(buf,20+n*22)=vsd->status.cart[index].attribute;
- WBUFB(buf,21+n*22)=vsd->status.cart[index].refine;
- clif_addcards(WBUFP(buf, 22+n*22), &vsd->status.cart[index]);
- n++;
- }
- if(n > 0){
- WBUFW(buf,0)=0x133;
- WBUFW(buf,2)=8+n*22;
- WBUFL(buf,4)=id;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
-
- return 0;
-}
-
-/*==========================================
- * 露店アイテム購入失敗
- *------------------------------------------
-*/
-int clif_buyvending(struct map_session_data *sd,int index,int amount,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x135]);
- WFIFOW(fd,0)=0x135;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOB(fd,6)=fail;
- WFIFOSET(fd,packet_len_table[0x135]);
-
- return 0;
-}
-
-/*==========================================
- * 露店開設成功
- *------------------------------------------
-*/
-int clif_openvending(struct map_session_data *sd,int id,struct vending *vending)
-{
- struct item_data *data;
- int i,n,index,fd;
- unsigned char *buf;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd, 8+sd->vend_num*22);
- buf = WFIFOP(fd,0);
- for(i=0,n=0;i<sd->vend_num;i++){
- if (sd->vend_num > 2+pc_checkskill(sd,MC_VENDING)) return 0;
- WBUFL(buf,8+n*22)=vending[i].value;
- WBUFW(buf,12+n*22)=(index=vending[i].index)+2;
- WBUFW(buf,14+n*22)=vending[i].amount;
- if(sd->status.cart[index].nameid <= 0 || sd->status.cart[index].amount <= 0 || !sd->status.cart[index].identify ||
- sd->status.cart[index].attribute==1) // Prevent unidentified and broken items from being sold [Valaris]
- continue;
- data = itemdb_search(sd->status.cart[index].nameid);
- WBUFB(buf,16+n*22)=itemtype(data->type);
- if(data->view_id > 0)
- WBUFW(buf,17+n*22)=data->view_id;
- else
- WBUFW(buf,17+n*22)=sd->status.cart[index].nameid;
- WBUFB(buf,19+n*22)=sd->status.cart[index].identify;
- WBUFB(buf,20+n*22)=sd->status.cart[index].attribute;
- WBUFB(buf,21+n*22)=sd->status.cart[index].refine;
- clif_addcards(WBUFP(buf, 22+n*22), &sd->status.cart[index]);
- n++;
- }
- if(n > 0){
- WBUFW(buf,0)=0x136;
- WBUFW(buf,2)=8+n*22;
- WBUFL(buf,4)=id;
- WFIFOSET(fd,WFIFOW(fd,2));
- }
- return n;
-}
-
-/*==========================================
- * 露店アイテム販売報告
- *------------------------------------------
-*/
-int clif_vendingreport(struct map_session_data *sd,int index,int amount)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x137]);
- WFIFOW(fd,0)=0x137;
- WFIFOW(fd,2)=index+2;
- WFIFOW(fd,4)=amount;
- WFIFOSET(fd,packet_len_table[0x137]);
-
- return 0;
-}
-/*==========================================
- * パーティ作成完了
- *------------------------------------------
- */
-int clif_party_created(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xfa]);
- WFIFOW(fd,0)=0xfa;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0xfa]);
- return 0;
-}
-
-int clif_party_main_info(struct party_data *p, int fd)
-{
- struct map_session_data *sd;
- int i;
- unsigned char buf[96];
-
- for (i=0; i<MAX_PARTY && !p->party.member[i].leader; i++);
- if (i >= MAX_PARTY) return 0; //Should never happen...
- sd = p->data[i].sd;
- WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= p->party.member[i].account_id;
- WBUFL(buf,6)= 0; //We don't know yet what this long is about.
- WBUFW(buf,10)=sd?sd->bl.x:0;
- WBUFW(buf,12)=sd?sd->bl.y:0;
- WBUFB(buf,14)=(p->party.member[i].online)?0:1; //This byte is also unconfirmed...
- memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
- memcpy(WBUFP(buf,39), p->party.member[i].name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(p->party.member[i].map), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->party.item&1)?1:0;
- WBUFB(buf,80) = (p->party.item&2)?1:0;
- if(fd>=0){
- WFIFOHEAD(fd,packet_len_table[0x1e9]);
- memcpy(WFIFOP(fd,0),buf,packet_len_table[0x1e9]);
- WFIFOSET(fd,packet_len_table[0x1e9]);
- return 1;
- }
- if (!sd) {
- for (i=0; i<MAX_PARTY && !p->data[i].sd; i++)
- if (i >= MAX_PARTY) return 0; //Should never happen...
- sd=p->data[i].sd;
- }
- clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY);
- return 1;
-}
-
-int clif_party_join_info(struct party *p, struct map_session_data *sd)
-{
- unsigned char buf[96];
- WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= sd->status.account_id;
- WBUFL(buf,6)= 0; //Apparently setting this to 1 makes you adoptable.
- WBUFW(buf,10)=sd->bl.x;
- WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=0; //Unconfirmed byte.
- memcpy(WBUFP(buf,15), p->name, NAME_LENGTH);
- memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
- WBUFB(buf,79) = (p->item&1)?1:0;
- WBUFB(buf,80) = (p->item&2)?1:0;
- clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY_WOS);
- return 1;
-}
-
-
-/*==========================================
- * パーティ情報送信
- *------------------------------------------
- */
-int clif_party_info(struct party_data *p,int fd)
-{
- unsigned char buf[1024];
- int i,c;
- struct map_session_data *sd=NULL;
-
- nullpo_retr(0, p);
-
- WBUFW(buf,0)=0xfb;
- memcpy(WBUFP(buf,4),p->party.name,NAME_LENGTH);
- for(i=c=0;i<MAX_PARTY;i++){
- struct party_member *m=&p->party.member[i];
- if(!m->account_id)
- continue;
- if(sd==NULL) sd=p->data[i].sd;
- WBUFL(buf,28+c*46)=m->account_id;
- memcpy(WBUFP(buf,28+c*46+ 4),m->name,NAME_LENGTH);
- memcpy(WBUFP(buf,28+c*46+28),mapindex_id2name(m->map),MAP_NAME_LENGTH);
- WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
- WBUFB(buf,28+c*46+45)=(m->online)?0:1;
- c++;
- }
- WBUFW(buf,2)=28+c*46;
- if(fd>=0){ // fdが設定されてるならそれに送る
- WFIFOHEAD(fd, 28+c*46);
- memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
- WFIFOSET(fd,WFIFOW(fd,2));
- return 9;
- }
- if(sd!=NULL)
- clif_send(buf,WBUFW(buf,2),&sd->bl,PARTY);
- return 0;
-}
-/*==========================================
- * パーティ勧誘
- *------------------------------------------
- */
-int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
-{
- int fd;
- struct party_data *p;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, tsd);
-
- fd=tsd->fd;
-
- if( (p=party_search(sd->status.party_id))==NULL )
- return 0;
-
- WFIFOHEAD(fd,packet_len_table[0xfe]);
- WFIFOW(fd,0)=0xfe;
- WFIFOL(fd,2)=sd->status.account_id;
- memcpy(WFIFOP(fd,6),p->party.name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0xfe]);
- return 0;
-}
-
-/*==========================================
- * Party invitation result. Flag values are:
- * 0 -> char is already in a party
- * 1 -> party invite was rejected
- * 2 -> party invite was accepted
- * 3 -> party is full
- * 4 -> char of the same account already joined the party
- *------------------------------------------
- */
-int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xfd]);
- WFIFOW(fd,0)=0xfd;
- memcpy(WFIFOP(fd,2),nick,NAME_LENGTH);
- WFIFOB(fd,26)=flag;
- WFIFOSET(fd,packet_len_table[0xfd]);
- return 0;
-}
-
-/*==========================================
- * パーティ設定送信
- * flag & 0x001=exp変更ミス
- * 0x010=item変更ミス
- * 0x100=一人にのみ送信
- *------------------------------------------
- */
-int clif_party_option(struct party_data *p,struct map_session_data *sd,int flag)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, p);
-
-// if(battle_config.etc_log)
-// printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
- if(sd==NULL && flag==0){
- int i;
- for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
- if (i < MAX_PARTY)
- sd = p->data[i].sd;
- }
- if(sd==NULL)
- return 0;
- WBUFW(buf,0)=0x101;
- WBUFW(buf,2)=((flag&0x01)?2:p->party.exp);
- WBUFW(buf,4)=0; //NOTE: We don't know yet what this is for, it is NOT for item share rules, though. [Skotlex]
- if(flag==0)
- clif_send(buf,packet_len_table[0x101],&sd->bl,PARTY);
- else {
- WFIFOHEAD(sd->fd,packet_len_table[0x101]);
- memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x101]);
- WFIFOSET(sd->fd,packet_len_table[0x101]);
- }
- return 0;
-}
-/*==========================================
- * パーティ脱退(脱退前に呼ぶこと)
- *------------------------------------------
- */
-int clif_party_leaved(struct party_data *p,struct map_session_data *sd,int account_id,char *name,int flag)
-{
- unsigned char buf[64];
- int i;
-
- nullpo_retr(0, p);
-
- WBUFW(buf,0)=0x105;
- WBUFL(buf,2)=account_id;
- memcpy(WBUFP(buf,6),name,NAME_LENGTH);
- WBUFB(buf,30)=flag&0x0f;
-
- if((flag&0xf0)==0){
- if(sd==NULL) {
- for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
- if (i < MAX_PARTY)
- sd = p->data[i].sd;
- }
- if (sd)
- clif_send(buf,packet_len_table[0x105],&sd->bl,PARTY);
- } else if (sd!=NULL) {
- WFIFOHEAD(sd->fd,packet_len_table[0x105]);
- memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x105]);
- WFIFOSET(sd->fd,packet_len_table[0x105]);
- }
- return 0;
-}
-/*==========================================
- * パーティメッセージ送信
- *------------------------------------------
- */
-int clif_party_message(struct party_data *p,int account_id,char *mes,int len)
-{
- struct map_session_data *sd;
- int i;
-
- nullpo_retr(0, p);
-
- for(i=0; i < MAX_PARTY && !p->data[i].sd;i++);
- if(i < MAX_PARTY){
- unsigned char buf[1024];
- sd = p->data[i].sd;
- WBUFW(buf,0)=0x109;
- WBUFW(buf,2)=len+8;
- WBUFL(buf,4)=account_id;
- memcpy(WBUFP(buf,8),mes,len);
- clif_send(buf,len+8,&sd->bl,PARTY);
- }
- return 0;
-}
-/*==========================================
- * パーティ座標通知
- *------------------------------------------
- */
-int clif_party_xy(struct map_session_data *sd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x107;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=sd->bl.x;
- WBUFW(buf,8)=sd->bl.y;
- clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
-
- return 0;
-}
-
-/*==========================================
- * Sends x/y dot to a single fd. [Skotlex]
- *------------------------------------------
- */
-
-int clif_party_xy_single(int fd, struct map_session_data *sd)
-{
- WFIFOHEAD(fd,packet_len_table[0x107]);
- WFIFOW(fd,0)=0x107;
- WFIFOL(fd,2)=sd->status.account_id;
- WFIFOW(fd,6)=sd->bl.x;
- WFIFOW(fd,8)=sd->bl.y;
- WFIFOSET(fd,packet_len_table[0x107]);
- return 0;
-}
-
-
-/*==========================================
- * パーティHP通知
- *------------------------------------------
- */
-int clif_party_hp(struct map_session_data *sd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x106;
- WBUFL(buf,2)=sd->status.account_id;
- if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
- WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
- WBUFW(buf,8) = 100;
- } else {
- WBUFW(buf,6) = sd->battle_status.hp;
- WBUFW(buf,8) = sd->battle_status.max_hp;
- }
- clif_send(buf,packet_len_table[0x106],&sd->bl,PARTY_AREA_WOS);
- return 0;
-}
-
-/*==========================================
- * Sends HP bar to a single fd. [Skotlex]
- *------------------------------------------
- */
-static void clif_hpmeter_single(int fd, struct map_session_data *sd)
-{
- WFIFOHEAD(fd,packet_len_table[0x106]);
- WFIFOW(fd,0) = 0x106;
- WFIFOL(fd,2) = sd->status.account_id;
- if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
- WFIFOW(fd,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
- WFIFOW(fd,8) = 100;
- } else {
- WFIFOW(fd,6) = sd->battle_status.hp;
- WFIFOW(fd,8) = sd->battle_status.max_hp;
- }
- WFIFOSET (fd, packet_len_table[0x106]);
-}
-
-/*==========================================
- * GMへ場所とHP通知
- *------------------------------------------
- */
-int clif_hpmeter(struct map_session_data *sd)
-{
- struct map_session_data *sd2;
- unsigned char buf[16];
- int i, x0, y0, x1, y1;
- int level;
-
- nullpo_retr(0, sd);
-
- x0 = sd->bl.x - AREA_SIZE;
- y0 = sd->bl.y - AREA_SIZE;
- x1 = sd->bl.x + AREA_SIZE;
- y1 = sd->bl.y + AREA_SIZE;
-
- WBUFW(buf,0) = 0x106;
- WBUFL(buf,2) = sd->status.account_id;
- if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
- WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
- WBUFW(buf,8) = 100;
- } else {
- WBUFW(buf,6) = sd->battle_status.hp;
- WBUFW(buf,8) = sd->battle_status.max_hp;
- }
- for (i = 0; i < fd_max; i++) {
- if (session[i] && session[i]->func_parse == clif_parse &&
- (sd2 = (struct map_session_data*)session[i]->session_data) &&
- sd != sd2 && sd2->state.auth) {
- if (sd2->bl.m != sd->bl.m ||
- sd2->bl.x < x0 || sd2->bl.y < y0 ||
- sd2->bl.x > x1 || sd2->bl.y > y1 ||
- (level = pc_isGM(sd2)) < battle_config.disp_hpmeter ||
- level < pc_isGM(sd))
- continue;
- WFIFOHEAD (i, packet_len_table[0x106]);
- memcpy (WFIFOP(i,0), buf, packet_len_table[0x106]);
- WFIFOSET (i, packet_len_table[0x106]);
- }
- }
-
- return 0;
-}
-
-/*==========================================
- * パーティ場所移動(未使用)
- *------------------------------------------
- */
-int clif_party_move(struct party *p,struct map_session_data *sd,int online)
-{
- unsigned char buf[128];
-
- nullpo_retr(0, sd);
- nullpo_retr(0, p);
-
- WBUFW(buf, 0)=0x104;
- WBUFL(buf, 2)=sd->status.account_id;
- WBUFL(buf, 6)=0;
- WBUFW(buf,10)=sd->bl.x;
- WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=!online;
- memcpy(WBUFP(buf,15),p->name, NAME_LENGTH);
- memcpy(WBUFP(buf,39),sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63),map[sd->bl.m].name, MAP_NAME_LENGTH);
- clif_send(buf,packet_len_table[0x104],&sd->bl,PARTY);
- return 0;
-}
-/*==========================================
- * 攻撃するために移動が必要
- *------------------------------------------
- */
-int clif_movetoattack(struct map_session_data *sd,struct block_list *bl)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, bl);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x139]);
- WFIFOW(fd, 0)=0x139;
- WFIFOL(fd, 2)=bl->id;
- WFIFOW(fd, 6)=bl->x;
- WFIFOW(fd, 8)=bl->y;
- WFIFOW(fd,10)=sd->bl.x;
- WFIFOW(fd,12)=sd->bl.y;
- WFIFOW(fd,14)=sd->battle_status.rhw.range;
- WFIFOSET(fd,packet_len_table[0x139]);
- return 0;
-}
-/*==========================================
- * 製造エフェクト
- *------------------------------------------
- */
-int clif_produceeffect(struct map_session_data *sd,int flag,int nameid)
-{
- int view,fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- // 名前の登録と送信を先にしておく
- if( map_charid2nick(sd->status.char_id)==NULL )
- map_addchariddb(sd->status.char_id,sd->status.name);
- clif_solved_charname(sd,sd->status.char_id);
-
- WFIFOHEAD(fd,packet_len_table[0x18f]);
- WFIFOW(fd, 0)=0x18f;
- WFIFOW(fd, 2)=flag;
- if((view = itemdb_viewid(nameid)) > 0)
- WFIFOW(fd, 4)=view;
- else
- WFIFOW(fd, 4)=nameid;
- WFIFOSET(fd,packet_len_table[0x18f]);
- return 0;
-}
-
-// pet
-int clif_catch_process(struct map_session_data *sd)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x19e]);
- WFIFOW(fd,0)=0x19e;
- WFIFOSET(fd,packet_len_table[0x19e]);
- sd->menuskill_id = SA_TAMINGMONSTER;
- if (sd->ud.skillid == SA_TAMINGMONSTER)
- sd->menuskill_lv = 0; //Free catch
- else
- sd->menuskill_lv = sd->itemid; //Consume catch
- return 0;
-}
-
-int clif_pet_rulet(struct map_session_data *sd,int data)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1a0]);
- WFIFOW(fd,0)=0x1a0;
- WFIFOB(fd,2)=data;
- WFIFOSET(fd,packet_len_table[0x1a0]);
-
- return 0;
-}
-
-/*==========================================
- * pet卵リスト作成
- *------------------------------------------
- */
-int clif_sendegg(struct map_session_data *sd)
-{
- //R 01a6 <len>.w <index>.w*
- int i,n=0,fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m))
- { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex]
- clif_displaymessage(fd, "Pets are not allowed in Guild Wars.");
- return 0;
- }
- WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
- WFIFOW(fd,0)=0x1a6;
- if(sd->status.pet_id <= 0) {
- for(i=0,n=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL ||
- sd->inventory_data[i]->type!=IT_PETEGG ||
- sd->status.inventory[i].amount<=0)
- continue;
- WFIFOW(fd,n*2+4)=i+2;
- n++;
- }
- }
- WFIFOW(fd,2)=4+n*2;
- WFIFOSET(fd,WFIFOW(fd,2));
-
- sd->menuskill_id = SA_TAMINGMONSTER;
- sd->menuskill_lv = -1;
- return 0;
-}
-
-int clif_send_petdata(struct map_session_data *sd,int type,int param)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, sd->pd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1a4]);
- WFIFOW(fd,0)=0x1a4;
- WFIFOB(fd,2)=type;
- WFIFOL(fd,3)=sd->pd->bl.id;
- WFIFOL(fd,7)=param;
- WFIFOSET(fd,packet_len_table[0x1a4]);
-
- return 0;
-}
-
-int clif_send_petstatus(struct map_session_data *sd)
-{
- int fd;
- struct s_pet *pet;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, sd->pd);
-
- fd=sd->fd;
- pet = &sd->pd->pet;
- WFIFOHEAD(fd,packet_len_table[0x1a2]);
- WFIFOW(fd,0)=0x1a2;
- memcpy(WFIFOP(fd,2),pet->name,NAME_LENGTH);
- WFIFOB(fd,26)=(battle_config.pet_rename == 1)? 0:pet->rename_flag;
- WFIFOW(fd,27)=pet->level;
- WFIFOW(fd,29)=pet->hungry;
- WFIFOW(fd,31)=pet->intimate;
- WFIFOW(fd,33)=pet->equip;
- WFIFOSET(fd,packet_len_table[0x1a2]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_pet_emotion(struct pet_data *pd,int param)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, pd);
-
- malloc_set(buf,0,packet_len_table[0x1aa]);
-
- WBUFW(buf,0)=0x1aa;
- WBUFL(buf,2)=pd->bl.id;
- if(param >= 100 && pd->petDB->talk_convert_class) {
- if(pd->petDB->talk_convert_class < 0)
- return 0;
- else if(pd->petDB->talk_convert_class > 0) {
- param -= (pd->pet.class_ - 100)*100;
- param += (pd->petDB->talk_convert_class - 100)*100;
- }
- }
- WBUFL(buf,6)=param;
-
- clif_send(buf,packet_len_table[0x1aa],&pd->bl,AREA);
-
- return 0;
-}
-
-int clif_pet_performance(struct block_list *bl,int param)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- malloc_set(buf,0,packet_len_table[0x1a4]);
-
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=4;
- WBUFL(buf,3)=bl->id;
- WBUFL(buf,7)=param;
-
- clif_send(buf,packet_len_table[0x1a4],bl,AREA);
-
- return 0;
-}
-
-int clif_pet_equip(struct pet_data *pd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, pd);
-
- malloc_set(buf,0,packet_len_table[0x1a4]);
-
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=3;
- WBUFL(buf,3)=pd->bl.id;
- WBUFL(buf,7)=pd->vd.shield;
- clif_send(buf,packet_len_table[0x1a4],&pd->bl,AREA);
-
- return 0;
-}
-
-int clif_pet_food(struct map_session_data *sd,int foodid,int fail)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1a3]);
- WFIFOW(fd,0)=0x1a3;
- WFIFOB(fd,2)=fail;
- WFIFOW(fd,3)=foodid;
- WFIFOSET(fd,packet_len_table[0x1a3]);
-
- return 0;
-}
-
-/*==========================================
- * オートスペル リスト送信
- *------------------------------------------
- */
-int clif_autospell(struct map_session_data *sd,int skilllv)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1cd]);
- WFIFOW(fd, 0)=0x1cd;
-
- if(skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0)
- WFIFOL(fd,2)= MG_NAPALMBEAT;
- else
- WFIFOL(fd,2)= 0x00000000;
- if(skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0)
- WFIFOL(fd,6)= MG_COLDBOLT;
- else
- WFIFOL(fd,6)= 0x00000000;
- if(skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0)
- WFIFOL(fd,10)= MG_FIREBOLT;
- else
- WFIFOL(fd,10)= 0x00000000;
- if(skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0)
- WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
- else
- WFIFOL(fd,14)= 0x00000000;
- if(skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0)
- WFIFOL(fd,18)= MG_SOULSTRIKE;
- else
- WFIFOL(fd,18)= 0x00000000;
- if(skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0)
- WFIFOL(fd,22)= MG_FIREBALL;
- else
- WFIFOL(fd,22)= 0x00000000;
- if(skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0)
- WFIFOL(fd,26)= MG_FROSTDIVER;
- else
- WFIFOL(fd,26)= 0x00000000;
-
- WFIFOSET(fd,packet_len_table[0x1cd]);
- sd->menuskill_id = SA_AUTOSPELL;
- sd->menuskill_lv = skilllv;
-
- return 0;
-}
-
-/*==========================================
- * ディボーションの青い糸
- *------------------------------------------
- */
-int clif_devotion(struct map_session_data *sd)
-{
- unsigned char buf[56];
- int i,n;
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x1cf;
- WBUFL(buf,2)=sd->bl.id;
- for(i=0,n=0;i<5;i++) {
- if (!sd->devotion[i])
- continue;
- WBUFL(buf,6+4*n)=sd->devotion[i];
- n++;
- }
- for(;n<5;n++)
- WBUFL(buf,6+4*n)=0;
-
- WBUFB(buf,26)=8;
- WBUFB(buf,27)=0;
-
- clif_send(buf,packet_len_table[0x1cf],&sd->bl,AREA);
- return 0;
-}
-
-int clif_marionette(struct block_list *src, struct block_list *target)
-{
- unsigned char buf[56];
- int n;
-
- WBUFW(buf,0)=0x1cf;
- WBUFL(buf,2)=src->id;
- for(n=0;n<5;n++)
- WBUFL(buf,6+4*n)=0;
- if (target) //The target goes on the second slot.
- WBUFL(buf,6+4) = target->id;
- WBUFB(buf,26)=8;
- WBUFB(buf,27)=0;
-
- clif_send(buf,packet_len_table[0x1cf],src,AREA);
- return 0;
-}
-
-/*==========================================
- * 氣球
- *------------------------------------------
- */
-int clif_spiritball(struct map_session_data *sd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x1d0;
- WBUFL(buf,2)=sd->bl.id;
- WBUFW(buf,6)=sd->spiritball;
- clif_send(buf,packet_len_table[0x1d0],&sd->bl,AREA);
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_combo_delay(struct block_list *bl,int wait)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x1d2;
- WBUFL(buf,2)=bl->id;
- WBUFL(buf,6)=wait;
- clif_send(buf,packet_len_table[0x1d2],bl,AREA);
-
- return 0;
-}
-/*==========================================
- *白刃取り
- *------------------------------------------
- */
-int clif_bladestop(struct block_list *src,struct block_list *dst,
- int _bool)
-{
- unsigned char buf[32];
-
- nullpo_retr(0, src);
- nullpo_retr(0, dst);
-
- WBUFW(buf,0)=0x1d1;
- WBUFL(buf,2)=src->id;
- WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=_bool;
-
- clif_send(buf,packet_len_table[0x1d1],src,AREA);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_changemapcell(int m,int x,int y,int cell_type,int type)
-{
- struct block_list bl;
- unsigned char buf[32];
-
- bl.type = BL_NUL;
- bl.m = m;
- bl.x = x;
- bl.y = y;
- WBUFW(buf,0) = 0x192;
- WBUFW(buf,2) = x;
- WBUFW(buf,4) = y;
- WBUFW(buf,6) = cell_type;
- memcpy(WBUFP(buf,8),map[m].name,MAP_NAME_LENGTH);
- if(!type)
- clif_send(buf,packet_len_table[0x192],&bl,AREA);
- else
- clif_send(buf,packet_len_table[0x192],&bl,ALL_SAMEMAP);
-
- return 0;
-}
-
-/*==========================================
- * MVPエフェクト
- *------------------------------------------
- */
-int clif_mvp_effect(struct map_session_data *sd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf,0)=0x10c;
- WBUFL(buf,2)=sd->bl.id;
- clif_send(buf,packet_len_table[0x10c],&sd->bl,AREA);
- return 0;
-}
-/*==========================================
- * MVPアイテム所得
- *------------------------------------------
- */
-int clif_mvp_item(struct map_session_data *sd,int nameid)
-{
- int view,fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x10a]);
- WFIFOW(fd,0)=0x10a;
- if((view = itemdb_viewid(nameid)) > 0)
- WFIFOW(fd,2)=view;
- else
- WFIFOW(fd,2)=nameid;
- WFIFOSET(fd,packet_len_table[0x10a]);
- return 0;
-}
-/*==========================================
- * MVP経験値所得
- *------------------------------------------
- */
-int clif_mvp_exp(struct map_session_data *sd,unsigned long exp)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x10b]);
- WFIFOW(fd,0)=0x10b;
- WFIFOL(fd,2)=exp;
- WFIFOSET(fd,packet_len_table[0x10b]);
- return 0;
-}
-
-/*==========================================
- * ギルド作成可否通知
- *------------------------------------------
- */
-int clif_guild_created(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x167]);
- WFIFOW(fd,0)=0x167;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x167]);
- return 0;
-}
-/*==========================================
- * ギルド所属通知
- *------------------------------------------
- */
-int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g)
-{
- int ps,fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
-
- fd=sd->fd;
- ps=guild_getposition(sd,g);
-
- WFIFOHEAD(fd,packet_len_table[0x16c]);
- malloc_set(WFIFOP(fd,0),0,packet_len_table[0x16c]);
- WFIFOW(fd,0)=0x16c;
- WFIFOL(fd,2)=g->guild_id;
- WFIFOL(fd,6)=g->emblem_id;
- WFIFOL(fd,10)=g->position[ps].mode;
- memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x16c]);
- return 0;
-}
-/*==========================================
- * ギルドメンバログイン通知
- *------------------------------------------
- */
-int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
-{
- unsigned char buf[64];
-
- nullpo_retr(0, g);
-
- WBUFW(buf, 0)=0x16d;
- WBUFL(buf, 2)=g->member[idx].account_id;
- WBUFL(buf, 6)=g->member[idx].char_id;
- WBUFL(buf,10)=flag;
- if(g->member[idx].sd==NULL){
- struct map_session_data *sd=guild_getavailablesd(g);
- if(sd!=NULL)
- clif_send(buf,packet_len_table[0x16d],&sd->bl,GUILD);
- }else
- clif_send(buf,packet_len_table[0x16d],&g->member[idx].sd->bl,GUILD_WOS);
- return 0;
-}
-
-// Function `clif_guild_memberlogin_notice` sends info about
-// logins and logouts of a guild member to the rest members.
-// But at the 1st time (after a player login or map changing)
-// the client won't show the message.
-// So I suggest use this function for sending "first-time-info"
-// to some player on entering the game or changing location.
-// At next time the client would always show the message.
-// The function sends all the statuses in the single packet
-// to economize traffic. [LuzZza]
-int clif_guild_send_onlineinfo(struct map_session_data *sd) {
-
- struct guild *g;
- char buf[14*128];
- int i, count=0, p_len;
-
- nullpo_retr(0, sd);
-
- p_len = packet_len_table[0x16d];
-
- if(!(g = guild_search(sd->status.guild_id)))
- return 0;
-
- for(i=0; i<g->max_member; i++) {
-
- if(g->member[i].account_id > 0 &&
- g->member[i].account_id != sd->status.account_id) {
-
- WBUFW(buf,count*p_len) = 0x16d;
- WBUFL(buf,count*p_len+2) = g->member[i].account_id;
- WBUFL(buf,count*p_len+6) = g->member[i].char_id;
- WBUFL(buf,count*p_len+10) = g->member[i].online;
- count++;
- }
- }
-
- clif_send(buf,p_len*count,&sd->bl,SELF);
-
- return 0;
-}
-
-/*==========================================
- * ギルドマスター通知(14dへの応答)
- *------------------------------------------
- */
-int clif_guild_masterormember(struct map_session_data *sd)
-{
- int type=0x57,fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- if(sd->state.gmaster_flag)
- type=0xd7;
- WFIFOHEAD(fd,packet_len_table[0x14e]);
- WFIFOW(fd,0)=0x14e;
- WFIFOL(fd,2)=type;
- WFIFOSET(fd,packet_len_table[0x14e]);
- return 0;
-}
-/*==========================================
- * Basic Info (Territories [Valaris])
- *------------------------------------------
- */
-int clif_guild_basicinfo(struct map_session_data *sd)
-{
- int fd,i,t=0;
- struct guild *g;
- struct guild_castle *gc=NULL;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
-
- WFIFOHEAD(fd,packet_len_table[0x1b6]);
- WFIFOW(fd, 0)=0x1b6;//0x150;
- WFIFOL(fd, 2)=g->guild_id;
- WFIFOL(fd, 6)=g->guild_lv;
- WFIFOL(fd,10)=g->connect_member;
- WFIFOL(fd,14)=g->max_member;
- WFIFOL(fd,18)=g->average_lv;
- WFIFOL(fd,22)=g->exp;
- WFIFOL(fd,26)=g->next_exp;
- WFIFOL(fd,30)=0; // 上納
- WFIFOL(fd,34)=0; // VW(性格の悪さ?:性向グラフ左右)
- WFIFOL(fd,38)=0; // RF(正義の度合い?:性向グラフ上下)
- WFIFOL(fd,42)=0; // 人数?
- memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH);
- memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH);
-
- for(i=0;i<MAX_GUILDCASTLE;i++){
- gc=guild_castle_search(i);
- if(!gc) continue;
- if(g->guild_id == gc->guild_id) t++;
- }
- if (t>=0 && t<=MAX_GUILDCASTLE) //(0=None, 1..24 = N of Casles) [Lupus]
- strncpy((char*)WFIFOP(fd,94),msg_txt(300+t),20);
- else
- strncpy((char*)WFIFOP(fd,94),msg_txt(299),20);
-
- WFIFOSET(fd,packet_len_table[WFIFOW(fd,0)]);
- clif_guild_emblem(sd,g); // Guild emblem vanish fix [Valaris]
- return 0;
-}
-
-/*==========================================
- * ギルド同盟/敵対情報
- *------------------------------------------
- */
-int clif_guild_allianceinfo(struct map_session_data *sd)
-{
- int fd,i,c;
- struct guild *g;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDALLIANCE * 32 + 4);
- WFIFOW(fd, 0)=0x14c;
- for(i=c=0;i<MAX_GUILDALLIANCE;i++){
- struct guild_alliance *a=&g->alliance[i];
- if(a->guild_id>0){
- WFIFOL(fd,c*32+4)=a->opposition;
- WFIFOL(fd,c*32+8)=a->guild_id;
- memcpy(WFIFOP(fd,c*32+12),a->name,NAME_LENGTH);
- c++;
- }
- }
- WFIFOW(fd, 2)=c*32+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-
-/*==========================================
- * ギルドメンバーリスト
- *------------------------------------------
- */
-int clif_guild_memberlist(struct map_session_data *sd)
-{
- int fd;
- int i,c;
- struct guild *g;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- if (!fd)
- return 0;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
-
- WFIFOHEAD(fd, g->max_member * 104 + 4);
- WFIFOW(fd, 0)=0x154;
- for(i=0,c=0;i<g->max_member;i++){
- struct guild_member *m=&g->member[i];
- if(m->account_id==0)
- continue;
- WFIFOL(fd,c*104+ 4)=m->account_id;
- WFIFOL(fd,c*104+ 8)=m->char_id;
- WFIFOW(fd,c*104+12)=m->hair;
- WFIFOW(fd,c*104+14)=m->hair_color;
- WFIFOW(fd,c*104+16)=m->gender;
- WFIFOW(fd,c*104+18)=m->class_;
- WFIFOW(fd,c*104+20)=m->lv;
- WFIFOL(fd,c*104+22)=m->exp;
- WFIFOL(fd,c*104+26)=m->online;
- WFIFOL(fd,c*104+30)=m->position;
- malloc_tsetword(WFIFOP(fd,c*104+34),0,50); // メモ?
- memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH);
- c++;
- }
- WFIFOW(fd, 2)=c*104+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-/*==========================================
- * ギルド役職名リスト
- *------------------------------------------
- */
-int clif_guild_positionnamelist(struct map_session_data *sd)
-{
- int i,fd;
- struct guild *g;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDPOSITION * 28 + 4);
- WFIFOW(fd, 0)=0x166;
- for(i=0;i<MAX_GUILDPOSITION;i++){
- WFIFOL(fd,i*28+4)=i;
- memcpy(WFIFOP(fd,i*28+8),g->position[i].name,NAME_LENGTH);
- }
- WFIFOW(fd,2)=i*28+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-/*==========================================
- * ギルド役職情報リスト
- *------------------------------------------
- */
-int clif_guild_positioninfolist(struct map_session_data *sd)
-{
- int i,fd;
- struct guild *g;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDPOSITION * 16 + 4);
- WFIFOW(fd, 0)=0x160;
- for(i=0;i<MAX_GUILDPOSITION;i++){
- struct guild_position *p=&g->position[i];
- WFIFOL(fd,i*16+ 4)=i;
- WFIFOL(fd,i*16+ 8)=p->mode;
- WFIFOL(fd,i*16+12)=i;
- WFIFOL(fd,i*16+16)=p->exp_mode;
- }
- WFIFOW(fd, 2)=i*16+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-/*==========================================
- * ギルド役職変更通知
- *------------------------------------------
- */
-int clif_guild_positionchanged(struct guild *g,int idx)
-{
- struct map_session_data *sd;
- unsigned char buf[128];
-
- nullpo_retr(0, g);
-
- WBUFW(buf, 0)=0x174;
- WBUFW(buf, 2)=44;
- WBUFL(buf, 4)=idx;
- WBUFL(buf, 8)=g->position[idx].mode;
- WBUFL(buf,12)=idx;
- WBUFL(buf,16)=g->position[idx].exp_mode;
- memcpy(WBUFP(buf,20),g->position[idx].name,NAME_LENGTH);
- if( (sd=guild_getavailablesd(g))!=NULL )
- clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
- return 0;
-}
-/*==========================================
- * ギルドメンバ変更通知
- *------------------------------------------
- */
-int clif_guild_memberpositionchanged(struct guild *g,int idx)
-{
- struct map_session_data *sd;
- unsigned char buf[64];
-
- nullpo_retr(0, g);
-
- WBUFW(buf, 0)=0x156;
- WBUFW(buf, 2)=16;
- WBUFL(buf, 4)=g->member[idx].account_id;
- WBUFL(buf, 8)=g->member[idx].char_id;
- WBUFL(buf,12)=g->member[idx].position;
- if( (sd=guild_getavailablesd(g))!=NULL )
- clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
- return 0;
-}
-/*==========================================
- * ギルドエンブレム送信
- *------------------------------------------
- */
-int clif_guild_emblem(struct map_session_data *sd,struct guild *g)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
-
- fd=sd->fd;
-
- if(g->emblem_len<=0)
- return 0;
- WFIFOHEAD(fd,g->emblem_len+12);
- WFIFOW(fd,0)=0x152;
- WFIFOW(fd,2)=g->emblem_len+12;
- WFIFOL(fd,4)=g->guild_id;
- WFIFOL(fd,8)=g->emblem_id;
- memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len);
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-/*==========================================
- * ギルドスキル送信
- *------------------------------------------
- */
-int clif_guild_skillinfo(struct map_session_data *sd)
-{
- int fd;
- int i,id,c,up=1;
- struct guild *g;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd, MAX_GUILDSKILL * 37 + 6);
- WFIFOW(fd,0)=0x0162;
- WFIFOW(fd,4)=g->skill_point;
- for(i=c=0;i<MAX_GUILDSKILL;i++){
- if(g->skill[i].id>0 && guild_check_skill_require(g,g->skill[i].id)){
- WFIFOW(fd,c*37+ 6) = id = g->skill[i].id;
- WFIFOW(fd,c*37+ 8) = skill_get_inf(id);
- WFIFOW(fd,c*37+10) = 0;
- WFIFOW(fd,c*37+12) = g->skill[i].lv;
- WFIFOW(fd,c*37+14) = skill_get_sp(id,g->skill[i].lv);
- WFIFOW(fd,c*37+16) = skill_get_range(id,g->skill[i].lv);
- strncpy(WFIFOP(fd,c*37+18), skill_get_name(id), NAME_LENGTH);
- if(g->skill[i].lv < guild_skill_get_max(id) && (sd == g->member[0].sd))
- up = 1;
- else
- up = 0;
- WFIFOB(fd,c*37+42)= up;
- c++;
- }
- }
- WFIFOW(fd,2)=c*37+6;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-/*==========================================
- * ギルド告知送信
- *------------------------------------------
- */
-int clif_guild_notice(struct map_session_data *sd,struct guild *g)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
-
- fd = sd->fd;
-
- if ( !session_isActive(fd) ) //null pointer right here [Kevin]
- return 0;
-
- if (fd <= 0)
- return 0;
- if(*g->mes1==0 && *g->mes2==0)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x16f]);
- WFIFOW(fd,0)=0x16f;
- memcpy(WFIFOP(fd,2),g->mes1,60);
- memcpy(WFIFOP(fd,62),g->mes2,120);
- WFIFOSET(fd,packet_len_table[0x16f]);
- return 0;
-}
-
-/*==========================================
- * ギルドメンバ勧誘
- *------------------------------------------
- */
-int clif_guild_invite(struct map_session_data *sd,struct guild *g)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, g);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x16a]);
- WFIFOW(fd,0)=0x16a;
- WFIFOL(fd,2)=g->guild_id;
- memcpy(WFIFOP(fd,6),g->name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x16a]);
- return 0;
-}
-/*==========================================
- * ギルドメンバ勧誘結果
- *------------------------------------------
- */
-int clif_guild_inviteack(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x169]);
- WFIFOW(fd,0)=0x169;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x169]);
- return 0;
-}
-/*==========================================
- * ギルドメンバ脱退通知
- *------------------------------------------
- */
-int clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes)
-{
- unsigned char buf[128];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf, 0)=0x15a;
- memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
- memcpy(WBUFP(buf,26),mes,40);
- clif_send(buf,packet_len_table[0x15a],&sd->bl,GUILD);
- return 0;
-}
-/*==========================================
- * ギルドメンバ追放通知
- *------------------------------------------
- */
-int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char *mes,
- int account_id)
-{
- unsigned char buf[128];
-
- nullpo_retr(0, sd);
-
- WBUFW(buf, 0)=0x15c;
- memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
- memcpy(WBUFP(buf,26),mes,40);
- memcpy(WBUFP(buf,66),"dummy",NAME_LENGTH);
- clif_send(buf,packet_len_table[0x15c],&sd->bl,GUILD);
- return 0;
-}
-/*==========================================
- * ギルド追放メンバリスト
- *------------------------------------------
- */
-int clif_guild_expulsionlist(struct map_session_data *sd)
-{
- int fd;
- int i,c;
- struct guild *g;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- g=guild_search(sd->status.guild_id);
- if(g==NULL)
- return 0;
- WFIFOHEAD(fd,MAX_GUILDEXPULSION * 88 + 4);
- WFIFOW(fd,0)=0x163;
- for(i=c=0;i<MAX_GUILDEXPULSION;i++){
- struct guild_expulsion *e=&g->expulsion[i];
- if(e->account_id>0){
- memcpy(WFIFOP(fd,c*88+ 4),e->name,NAME_LENGTH);
- memcpy(WFIFOP(fd,c*88+28),e->acc,24);
- memcpy(WFIFOP(fd,c*88+52),e->mes,44);
- c++;
- }
- }
- WFIFOW(fd,2)=c*88+4;
- WFIFOSET(fd,WFIFOW(fd,2));
- return 0;
-}
-
-/*==========================================
- * ギルド会話
- *------------------------------------------
- */
-int clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
-{
- struct map_session_data *sd;
- unsigned char *buf;
-
- buf = (unsigned char*)aMallocA((len + 4)*sizeof(unsigned char));
-
- WBUFW(buf, 0) = 0x17f;
- WBUFW(buf, 2) = len + 4;
- memcpy(WBUFP(buf,4), mes, len);
-
- if ((sd = guild_getavailablesd(g)) != NULL)
- clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD);
-
- if(buf) aFree(buf);
-
- return 0;
-}
-/*==========================================
- * ギルドスキル割り振り通知
- *------------------------------------------
- */
-int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,11);
- WFIFOW(fd,0) = 0x10e;
- WFIFOW(fd,2) = skill_num;
- WFIFOW(fd,4) = lv;
- WFIFOW(fd,6) = skill_get_sp(skill_num,lv);
- WFIFOW(fd,8) = skill_get_range(skill_num,lv);
- WFIFOB(fd,10) = 1;
- WFIFOSET(fd,11);
- return 0;
-}
-/*==========================================
- * ギルド同盟要請
- *------------------------------------------
- */
-int clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x171]);
- WFIFOW(fd,0)=0x171;
- WFIFOL(fd,2)=account_id;
- memcpy(WFIFOP(fd,6),name,NAME_LENGTH);
- WFIFOSET(fd,packet_len_table[0x171]);
- return 0;
-}
-/*==========================================
- * ギルド同盟結果
- *------------------------------------------
- */
-int clif_guild_allianceack(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x173]);
- WFIFOW(fd,0)=0x173;
- WFIFOL(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x173]);
- return 0;
-}
-/*==========================================
- * ギルド関係解消通知
- *------------------------------------------
- */
-int clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- if (fd <= 0)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x184]);
- WFIFOW(fd,0)=0x184;
- WFIFOL(fd,2)=guild_id;
- WFIFOL(fd,6)=flag;
- WFIFOSET(fd,packet_len_table[0x184]);
- return 0;
-}
-/*==========================================
- * ギルド敵対結果
- *------------------------------------------
- */
-int clif_guild_oppositionack(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x181]);
- WFIFOW(fd,0)=0x181;
- WFIFOB(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x181]);
- return 0;
-}
-/*==========================================
- * ギルド関係追加
- *------------------------------------------
- */
-/*int clif_guild_allianceadded(struct guild *g,int idx)
-{
- unsigned char buf[64];
- WBUFW(fd,0)=0x185;
- WBUFL(fd,2)=g->alliance[idx].opposition;
- WBUFL(fd,6)=g->alliance[idx].guild_id;
- memcpy(WBUFP(fd,10),g->alliance[idx].name,NAME_LENGTH);
- clif_send(buf,packet_len_table[0x185],guild_getavailablesd(g),GUILD);
- return 0;
-}*/
-
-/*==========================================
- * ギルド解散通知
- *------------------------------------------
- */
-int clif_guild_broken(struct map_session_data *sd,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x15e]);
- WFIFOW(fd,0)=0x15e;
- WFIFOL(fd,2)=flag;
- WFIFOSET(fd,packet_len_table[0x15e]);
- return 0;
-}
-
-/*==========================================
- * エモーション
- *------------------------------------------
- */
-void clif_emotion(struct block_list *bl,int type)
-{
- unsigned char buf[8];
-
- nullpo_retv(bl);
-
- WBUFW(buf,0)=0xc0;
- WBUFL(buf,2)=bl->id;
- WBUFB(buf,6)=type;
- clif_send(buf,packet_len_table[0xc0],bl,AREA);
-}
-
-/*==========================================
- * トーキーボックス
- *------------------------------------------
- */
-void clif_talkiebox(struct block_list *bl,char* talkie)
-{
- unsigned char buf[86];
-
- nullpo_retv(bl);
-
- WBUFW(buf,0)=0x191;
- WBUFL(buf,2)=bl->id;
- memcpy(WBUFP(buf,6),talkie,MESSAGE_SIZE);
- clif_send(buf,packet_len_table[0x191],bl,AREA);
-}
-
-/*==========================================
- * 結婚エフェクト
- *------------------------------------------
- */
-void clif_wedding_effect(struct block_list *bl) {
- unsigned char buf[6];
-
- nullpo_retv(bl);
-
- WBUFW(buf,0) = 0x1ea;
- WBUFL(buf,2) = bl->id;
- clif_send(buf, packet_len_table[0x1ea], bl, AREA);
-}
-/*==========================================
- * あなたに逢いたい使用時名前叫び
- *------------------------------------------
-
-void clif_callpartner(struct map_session_data *sd)
-{
- unsigned char buf[26];
- char *p;
-
- nullpo_retv(sd);
-
- if(sd->status.partner_id){
- WBUFW(buf,0)=0x1e6;
- p = map_charid2nick(sd->status.partner_id);
- if(p){
- memcpy(WBUFP(buf,2),p,NAME_LENGTH);
- }else{
- map_reqchariddb(sd,sd->status.partner_id);
- chrif_searchcharid(sd->status.partner_id);
- WBUFB(buf,2) = 0;
- }
- clif_send(buf,packet_len_table[0x1e6],&sd->bl,AREA);
- }
- return;
-}
-*/
-/*==========================================
- * Adopt baby [Celest]
- *------------------------------------------
- */
-void clif_adopt_process(struct map_session_data *sd)
-{
- int fd;
- nullpo_retv(sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1f8]);
- WFIFOW(fd,0)=0x1f8;
- WFIFOSET(fd,packet_len_table[0x1f8]);
-}
-/*==========================================
- * Marry [DracoRPG]
- *------------------------------------------
- */
-void clif_marriage_process(struct map_session_data *sd)
-{
- int fd;
- nullpo_retv(sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1e4]);
- WFIFOW(fd,0)=0x1e4;
- WFIFOSET(fd,packet_len_table[0x1e4]);
-}
-
-
-/*==========================================
- * Notice of divorce
- *------------------------------------------
- */
-void clif_divorced(struct map_session_data *sd, char *name)
-{
- int fd;
- nullpo_retv(sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x205]);
- WFIFOW(fd,0)=0x205;
- memcpy(WFIFOP(fd,2), name, NAME_LENGTH);
- WFIFOSET(fd, packet_len_table[0x205]);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
- nullpo_retv(sd);
-
- WFIFOHEAD(fd,packet_len_table[0x1f6]);
- WFIFOW(fd,0)=0x1f6;
- WFIFOSET(fd, packet_len_table[0x1f6]);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ReqMarriage(int fd, struct map_session_data *sd) {
- nullpo_retv(sd);
-
- WFIFOHEAD(fd,packet_len_table[0x1e2]);
- WFIFOW(fd,0)=0x1e2;
- WFIFOSET(fd, packet_len_table[0x1e2]);
-}
-
-/*==========================================
- * 座る
- *------------------------------------------
- */
-void clif_sitting(struct map_session_data *sd)
-{
- unsigned char buf[64];
-
- nullpo_retv(sd);
-
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 2;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
-{
- int fd;
- nullpo_retr(0, sd);
- fd = sd->fd;
- if (!fd || !len) return 0; //Disconnected player.
- WFIFOHEAD(fd, len+5);
- WFIFOW(fd, 0) = 0x17f;
- WFIFOW(fd, 2) = len + 5;
- memcpy(WFIFOP(fd,4), mes, len);
- WFIFOSET(fd, WFIFOW(fd,2));
- return 1;
-}
-
-/*==========================================
- * Displays a message using the guild-chat colors to the specified targets. [Skotlex]
- *------------------------------------------
- */
-void clif_disp_message(struct block_list *src, char *mes, int len, int type)
-{
- unsigned char buf[1024];
- if (!len) return;
- WBUFW(buf, 0) = 0x17f;
- WBUFW(buf, 2) = len + 5;
- memcpy(WBUFP(buf,4), mes, len);
- clif_send(buf, WBUFW(buf,2), src, type);
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-
-int clif_GM_kickack(struct map_session_data *sd, int id)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xcd]);
- WFIFOW(fd,0) = 0xcd;
- WFIFOL(fd,2) = id;
- WFIFOSET(fd, packet_len_table[0xcd]);
- return 0;
-}
-
-void clif_parse_QuitGame(int fd,struct map_session_data *sd);
-
-int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type)
-{
- int fd = tsd->fd;
- WFIFOHEAD(fd,packet_len_table[0x18b]);
- if(type)
- clif_GM_kickack(sd,tsd->status.account_id);
- if (!fd) {
- map_quit(tsd);
- return 0;
- }
-
- WFIFOW(fd,0) = 0x18b;
- WFIFOW(fd,2) = 0;
- WFIFOSET(fd,packet_len_table[0x18b]);
- clif_setwaitclose(fd);
- return 0;
-}
-
-int clif_GM_silence(struct map_session_data *sd, struct map_session_data *tsd, int type)
-{
- int fd;
-
- nullpo_retr(0, sd);
- nullpo_retr(0, tsd);
-
- fd = tsd->fd;
- if (fd <= 0)
- return 0;
- WFIFOHEAD(fd,packet_len_table[0x14b]);
- WFIFOW(fd,0) = 0x14b;
- WFIFOB(fd,2) = 0;
- memcpy(WFIFOP(fd,3), sd->status.name, NAME_LENGTH);
- WFIFOSET(fd, packet_len_table[0x14b]);
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-
-int clif_timedout(struct map_session_data *sd)
-{
- nullpo_retr(0, sd);
-
- ShowInfo("%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' timed out.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id);
- clif_authfail_fd(sd->fd,3); // Even if player is not on we still send anyway
- clif_setwaitclose(sd->fd); // Set session to EOF
- return 0;
-}
-
-/*==========================================
- * Wis拒否許可応答
- *------------------------------------------
- */
-int clif_wisexin(struct map_session_data *sd,int type,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xd1]);
- WFIFOW(fd,0)=0xd1;
- WFIFOB(fd,2)=type;
- WFIFOB(fd,3)=flag;
- WFIFOSET(fd,packet_len_table[0xd1]);
-
- return 0;
-}
-/*==========================================
- * Wis全拒否許可応答
- *------------------------------------------
- */
-int clif_wisall(struct map_session_data *sd,int type,int flag)
-{
- int fd;
-
- nullpo_retr(0, sd);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0xd2]);
- WFIFOW(fd,0)=0xd2;
- WFIFOB(fd,2)=type;
- WFIFOB(fd,3)=flag;
- WFIFOSET(fd,packet_len_table[0xd2]);
-
- return 0;
-}
-/*==========================================
- * サウンドエフェクト
- *------------------------------------------
- */
-void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *name,int type)
-{
- int fd;
-
- nullpo_retv(sd);
- nullpo_retv(bl);
-
- fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x1d3]);
- WFIFOW(fd,0)=0x1d3;
- memcpy(WFIFOP(fd,2),name,NAME_LENGTH);
- WFIFOB(fd,26)=type;
- WFIFOL(fd,27)=0;
- WFIFOL(fd,31)=bl->id;
- WFIFOSET(fd,packet_len_table[0x1d3]);
-
- return;
-}
-
-int clif_soundeffectall(struct block_list *bl, char *name, int type, int coverage)
-{
- unsigned char buf[40];
- malloc_set(buf, 0, packet_len_table[0x1d3]);
-
- if(coverage < 0 || coverage > 22){
- ShowError("clif_soundeffectall: undefined coverage.\n");
- return 0;
- }
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0)=0x1d3;
- memcpy(WBUFP(buf,2), name, NAME_LENGTH);
- WBUFB(buf,26)=type;
- WBUFL(buf,27)=0;
- WBUFL(buf,31)=bl->id;
- clif_send(buf, packet_len_table[0x1d3], bl, coverage);
-
- return 0;
-}
-
-// displaying special effects (npcs, weather, etc) [Valaris]
-int clif_specialeffect(struct block_list *bl, int type, int flag)
-{
- unsigned char buf[24];
-
- nullpo_retr(0, bl);
-
- malloc_set(buf, 0, packet_len_table[0x1f3]);
-
- WBUFW(buf,0) = 0x1f3;
- WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = type;
-
- clif_send(buf, packet_len_table[0x1f3], bl, flag);
-
- if (disguised(bl)) {
- WBUFL(buf,2) = -bl->id;
- clif_send(buf, packet_len_table[0x1f3], bl, SELF);
- }
- return 0;
-}
-
-// refresh the client's screen, getting rid of any effects
-int clif_refresh(struct map_session_data *sd) {
- nullpo_retr(-1, sd);
- clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
- clif_inventorylist(sd);
- if(pc_iscarton(sd)){
- clif_cartlist(sd);
- clif_updatestatus(sd,SP_CARTINFO);
- }
- clif_updatestatus(sd,SP_MAXWEIGHT);
- clif_updatestatus(sd,SP_WEIGHT);
- map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
- clif_weather_check(sd);
- return 0;
-}
-
-// updates the object's (bl) name on client
-int clif_charnameack (int fd, struct block_list *bl)
-{
- unsigned char buf[103];
- int cmd = 0x95;
-
- nullpo_retr(0, bl);
-
- WBUFW(buf,0) = cmd;
- WBUFL(buf,2) = bl->id;
-
- switch(bl->type) {
- case BL_PC:
- {
- struct map_session_data *ssd = (struct map_session_data *)bl;
- struct party_data *p = NULL;
- struct guild *g = NULL;
-
- //Requesting your own "shadow" name. [Skotlex]
- if (ssd->fd == fd && ssd->disguise)
- WBUFL(buf,2) = -bl->id;
-
- if (strlen(ssd->fakename)>1) {
- memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH);
- break;
- }
- memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
-
- if (ssd->status.party_id > 0)
- p = party_search(ssd->status.party_id);
-
- if (ssd->status.guild_id > 0)
- g = guild_search(ssd->status.guild_id);
-
- if (p == NULL && g == NULL)
- break;
-
- WBUFW(buf, 0) = cmd = 0x195;
- if (p)
- memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
- else
- WBUFB(buf,30) = 0;
-
- if (g)
- {
- int i, ps = -1;
- for(i = 0; i < g->max_member; i++) {
- if (g->member[i].account_id == ssd->status.account_id &&
- g->member[i].char_id == ssd->status.char_id )
- {
- ps = g->member[i].position;
- break;
- }
- }
- if (ps >= 0 && ps < MAX_GUILDPOSITION)
- {
- memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
- memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
- } else { //Assume no guild.
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- } else {
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- }
- break;
- //[blackhole89]
- case BL_HOM:
- memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH);
- break;
- case BL_PET:
- memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH);
- break;
- case BL_NPC:
- memcpy(WBUFP(buf,6), ((TBL_NPC*)bl)->name, NAME_LENGTH);
- break;
- case BL_MOB:
- {
- struct mob_data *md = (struct mob_data *)bl;
- nullpo_retr(0, md);
-
- memcpy(WBUFP(buf,6), md->name, NAME_LENGTH);
- if (md->guardian_data && md->guardian_data->guild_id) {
- WBUFW(buf, 0) = cmd = 0x195;
- WBUFB(buf,30) = 0;
- memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH);
- memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH);
- } else if (battle_config.show_mob_info) {
- char mobhp[50], *str_p = mobhp;
-
- WBUFW(buf, 0) = cmd = 0x195;
- if (battle_config.show_mob_info&4)
- str_p += sprintf(str_p, "Lv. %d | ", md->level);
- if (battle_config.show_mob_info&1)
- str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
- if (battle_config.show_mob_info&2)
- str_p += sprintf(str_p, "HP: %d%% | ",
- md->status.max_hp > 10000?
- md->status.hp/(md->status.max_hp/100):
- 100*md->status.hp/md->status.max_hp);
- //Even thought mobhp ain't a name, we send it as one so the client
- //can parse it. [Skotlex]
- if (str_p != mobhp) {
- *(str_p-3) = '\0'; //Remove trailing space + pipe.
- memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH);
- WBUFB(buf,54) = 0;
- memcpy(WBUFP(buf,78), mobhp, NAME_LENGTH);
- }
- }
- }
- break;
- case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
-// memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
-// break;
- return 0;
- default:
- if (battle_config.error_log)
- ShowError("clif_parse_GetCharNameRequest : bad type %d(%d)\n", bl->type, bl->id);
- return 0;
- }
-
- // if no receipient specified just update nearby clients
- if (fd == 0)
- clif_send(buf, packet_len_table[cmd], bl, AREA);
- else {
- WFIFOHEAD(fd, packet_len_table[cmd]);
- memcpy(WFIFOP(fd, 0), buf, packet_len_table[cmd]);
- WFIFOSET(fd, packet_len_table[cmd]);
- }
-
- return 0;
-}
-
-//Used to update when a char leaves a party/guild. [Skotlex]
-//Needed because when you send a 0x95 packet, the client will not remove the cached party/guild info that is not sent.
-int clif_charnameupdate (struct map_session_data *ssd)
-{
- unsigned char buf[103];
- int cmd = 0x195;
- struct party_data *p = NULL;
- struct guild *g = NULL;
-
- nullpo_retr(0, ssd);
-
- if (strlen(ssd->fakename)>1)
- return 0; //No need to update as the party/guild was not displayed anyway.
-
- WBUFW(buf,0) = cmd;
- WBUFL(buf,2) = ssd->bl.id;
-
- memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
-
- if (ssd->status.party_id > 0)
- p = party_search(ssd->status.party_id);
-
- if (ssd->status.guild_id > 0)
- g = guild_search(ssd->status.guild_id);
-
- if (p)
- memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
- else
- WBUFB(buf,30) = 0;
-
- if (g)
- {
- int i, ps = -1;
- for(i = 0; i < g->max_member; i++) {
- if (g->member[i].account_id == ssd->status.account_id &&
- g->member[i].char_id == ssd->status.char_id )
- {
- ps = g->member[i].position;
- break;
- }
- }
- if (ps >= 0 && ps < MAX_GUILDPOSITION)
- {
- memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
- memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
- } else { //Assume no guild.
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
- } else {
- WBUFB(buf,54) = 0;
- WBUFB(buf,78) = 0;
- }
-
- // Update nearby clients
- clif_send(buf, packet_len_table[cmd], &ssd->bl, AREA);
- return 0;
-}
-
-int clif_slide(struct block_list *bl, int x, int y){
- unsigned char buf[10];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf, 0) = 0x01ff;
- WBUFL(buf, 2) = bl->id;
- WBUFW(buf, 6) = x;
- WBUFW(buf, 8) = y;
-
- clif_send(buf, packet_len_table[0x1ff], bl, AREA);
- return 0;
-}
-
-/*------------------------------------------
- * @me command by lordalfa, rewritten implementation by Skotlex
- *------------------------------------------
-*/
-int clif_disp_overhead(struct map_session_data *sd, char* mes)
-{
- unsigned char buf[256]; //This should be more than sufficient, the theorical max is MESSAGE_SIZE+NAME_LENGTH + 8 (pads and extra inserted crap)
- int len_mes = strlen(mes)+1; //Account for \0
-
- if (len_mes + 8 >= 256) {
- if (battle_config.error_log)
- ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes);
- len_mes = 247; //Trunk it to avoid problems.
- }
- // send message to others
- WBUFW(buf,0) = 0x8d;
- WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id)
- WBUFL(buf,4) = sd->bl.id;
- memcpy(WBUFP(buf,8), mes, len_mes);
- clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC);
-
- // send back message to the speaker
- WBUFW(buf,0) = 0x8e;
- WBUFW(buf, 2) = len_mes + 4;
- memcpy(WBUFP(buf,4), mes, len_mes);
- clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
-
- return 0;
-}
-
-/*==========================
- * Minimap fix [Kevin]
- * Remove dot from minimap
- *--------------------------
-*/
-int clif_party_xy_remove(struct map_session_data *sd)
-{
- unsigned char buf[16];
- nullpo_retr(0, sd);
- WBUFW(buf,0)=0x107;
- WBUFL(buf,2)=sd->status.account_id;
- WBUFW(buf,6)=-1;
- WBUFW(buf,8)=-1;
- clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
- return 0;
-}
-
-//Displays gospel-buff information (thanks to Rayce):
-//Type determines message based on this table:
-/*
- 0x15 End all negative status
- 0x16 Immunity to all status
- 0x17 MaxHP +100%
- 0x18 MaxSP +100%
- 0x19 All stats +20
- 0x1c Enchant weapon with Holy element
- 0x1d Enchant armor with Holy element
- 0x1e DEF +25%
- 0x1f ATK +100%
- 0x20 HIT/Flee +50
- 0x28 Full strip failed because of coating (unrelated to gospel, maybe for ST_FULLSTRIP)
-*/
-void clif_gospel_info(struct map_session_data *sd, int type)
-{
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x215]);
- WFIFOW(fd,0)=0x215;
- WFIFOL(fd,2)=type;
- WFIFOSET(fd, packet_len_table[0x215]);
-
-}
-/*==========================================
- * Info about Star Glaldiator save map [Komurka]
- * type: 1: Information, 0: Map registered
- *------------------------------------------
- */
-void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsigned char type)
-{
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- memcpy(WFIFOP(fd,2),mapindex_id2name(sd->feel_map[feel_level].index), MAP_NAME_LENGTH);
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=feel_level;
- WFIFOB(fd,31)=type?1:0;
- WFIFOSET(fd, packet_len_table[0x20e]);
-}
-
-/*==========================================
- * Info about Star Glaldiator hate mob [Komurka]
- * type: 1: Register mob, 0: Information.
- *------------------------------------------
- */
-void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type)
-{
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- if (pcdb_checkid(class_))
- strncpy(WFIFOP(fd,2),job_name(class_), NAME_LENGTH);
- else if (mobdb_checkid(class_))
- strncpy(WFIFOP(fd,2),mob_db(class_)->jname, NAME_LENGTH);
- else //Really shouldn't happen...
- malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH);
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=hate_level;
- WFIFOB(fd,31)=type?10:11; //Register/Info
- WFIFOSET(fd, packet_len_table[0x20e]);
-}
-
-/*==========================================
- * Info about TaeKwon Do TK_MISSION mob [Skotlex]
- *------------------------------------------
- */
-void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress)
-{
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- strncpy(WFIFOP(fd,2),mob_db(mob_id)->jname, NAME_LENGTH);
- WFIFOL(fd,26)=mob_id;
- WFIFOB(fd,30)=progress; //Message to display
- WFIFOB(fd,31)=20;
- WFIFOSET(fd, packet_len_table[0x20e]);
-}
-
-/*==========================================
- * Feel/Hate reset (thanks to Rayce) [Skotlex]
- *------------------------------------------
- */
-void clif_feel_hate_reset(struct map_session_data *sd)
-{
- int fd=sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x20e]);
- WFIFOW(fd,0)=0x20e;
- malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH); //Blank name as all was reset.
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=0; //Feel/hate level: irrelevant
- WFIFOB(fd,31)=30;
- WFIFOSET(fd, packet_len_table[0x20e]);
-}
-
-// ---------------------
-// clif_guess_PacketVer
-// ---------------------
-// Parses a WantToConnection packet to try to identify which is the packet version used. [Skotlex]
-static int clif_guess_PacketVer(int fd, int get_previous)
-{
- static int packet_ver = -1;
- int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex
- RFIFOHEAD(fd);
-
- if (get_previous) //For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex]
- return packet_ver;
-
- //By default, start searching on the default one.
- packet_ver = clif_config.packet_db_ver;
- cmd = RFIFOW(fd,0);
- packet_len = RFIFOREST(fd);
-
- if (
- cmd == clif_config.connect_cmd[packet_ver] &&
- packet_len == packet_db[packet_ver][cmd].len &&
- ((value = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) == 0 || value == 1) &&
- (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) > 700000 && //Account ID is valid
- value <= max_account_id &&
- (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) > 0 && //Char ID is valid
- value <= max_char_id &&
- (int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) > 0 //Login 1 is a positive value (?)
- )
- return clif_config.packet_db_ver; //Default packet version found.
-
- for (packet_ver = MAX_PACKET_VER; packet_ver > 0; packet_ver--)
- { //Start guessing the version, giving priority to the newer ones. [Skotlex]
- if (cmd != clif_config.connect_cmd[packet_ver] || //it is not a wanttoconnection for this version.
- packet_len != packet_db[packet_ver][cmd].len) //The size of the wantoconnection packet does not matches.
- continue;
-
- if (
- (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < 700000 || value > max_account_id
- || (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) < 1 || value > max_char_id
- //What is login 1? In my tests it is a very very high value.
- || (int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) < 1
- //This check seems redundant, all wanttoconnection packets have the gender on the very
- //last byte of the packet.
- || (value = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) < 0 || value > 1
- )
- continue;
-
- return packet_ver; //This is our best guess.
- }
- packet_ver = -1;
- return -1;
-}
-
-// ------------
-// clif_parse_*
-// ------------
-// パケット読み取って色々操作
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
-{
- struct map_session_data *old_sd;
- int cmd, account_id, char_id, login_id1, sex;
- unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex]
- int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
- RFIFOHEAD(fd);
-
- if (sd) {
- if (battle_config.error_log)
- ShowError("clif_parse_WantToConnection : invalid request (character already logged in)?\n");
- return;
- }
-
- packet_ver = clif_guess_PacketVer(fd, 1);
- cmd = RFIFOW(fd,0);
-
- if (packet_ver <= 0)
- return;
-
- account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]);
- char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
- login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
- client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
- sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
-
- if ((old_sd = map_id2sd(account_id)) != NULL)
- { // if same account already connected, we disconnect the 2 sessions
- //Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex]
- if (old_sd->state.finalsave || !old_sd->state.auth)
- ; //Previous player is not done loading.
- //Or he has quit, but is not done saving on the charserver.
- else if (old_sd->fd)
- clif_authfail_fd(old_sd->fd, 2); // same id
- else
- map_quit(old_sd);
- clif_authfail_fd(fd, 8); // still recognizes last connection
- return;
- }
- sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
- sd->fd = fd;
- sd->packet_ver = packet_ver;
- session[fd]->session_data = sd;
-
- pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
- WFIFOHEAD(fd,4);
- WFIFOL(fd,0) = sd->bl.id;
- WFIFOSET(fd,4);
- chrif_authreq(sd);
- return;
-}
-
-static int clif_nighttimer(int tid, unsigned int tick, int id, int data)
-{
- TBL_PC *sd;
- sd=map_id2sd(id);
- if (!sd) return 0;
-
- //Check if character didn't instant-warped after logging in.
- if (sd->bl.prev!=NULL) {
- sd->state.night = 1;
- clif_status_load(&sd->bl, SI_NIGHT, 1);
- }
- return 0;
-}
-
-/*==========================================
- * 007d クライアント側マップ読み込み完了
- * map侵入時に必要なデータを全て送りつける
- *------------------------------------------
- */
-void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
-{
- if(sd->bl.prev != NULL)
- return;
-
- if (!sd->state.auth)
- { //Character loading is not complete yet!
- //Let pc_reg_received reinvoke this when ready.
- sd->state.connect_new = 0;
- return;
- }
-
- if (sd->state.rewarp)
- { //Rewarp player.
- sd->state.rewarp = 0;
- clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
- return;
- }
-
- // look
-#if PACKETVER < 4
- clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
- clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
-#else
- clif_changelook(&sd->bl,LOOK_WEAPON,0);
-#endif
-
- if(sd->vd.cloth_color)
- clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
-
- // item
- pc_checkitem(sd);
- clif_inventorylist(sd);
-
- // cart
- if(pc_iscarton(sd)){
- clif_cartlist(sd);
- clif_updatestatus(sd,SP_CARTINFO);
- }
-
- // weight max , now
- clif_updatestatus(sd,SP_MAXWEIGHT);
- clif_updatestatus(sd,SP_WEIGHT);
-
- if(battle_config.pc_invincible_time > 0) {
- if(map_flag_gvg(sd->bl.m))
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1);
- else
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
- }
- map_addblock(&sd->bl); // ブロック登録
- clif_spawn(&sd->bl); // spawn
-
- // Party
- if(sd->status.party_id) {
- party_send_movemap(sd);
- clif_party_hp(sd); // Show hp after displacement [LuzZza]
- }
-
- // guild
- if(sd->status.guild_id)
- guild_send_memberinfoshort(sd,1);
-
- if(map[sd->bl.m].flag.pvp){
- if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
- if (!map[sd->bl.m].flag.pvp_nocalcrank)
- sd->pvp_timer= add_timer(gettick()+200,
- pc_calc_pvprank_timer,sd->bl.id,0);
- sd->pvp_rank=0;
- sd->pvp_lastusers=0;
- sd->pvp_point=5;
- sd->pvp_won=0;
- sd->pvp_lost=0;
- }
- clif_set0199(fd,1);
- } else
- // set flag, if it's a duel [LuzZza]
- if(sd->duel_group)
- clif_set0199(fd, 1);
-
- if (map[sd->bl.m].flag.gvg_dungeon)
- clif_set0199(fd,2); //TODO: Figure out the real thing to do here.
-
- if(map_flag_gvg(sd->bl.m))
- clif_set0199(fd,3);
-
- // pet
- if(sd->pd) {
- map_addblock(&sd->pd->bl);
- clif_spawn(&sd->pd->bl);
- clif_send_petdata(sd,0,0);
- clif_send_petdata(sd,5,battle_config.pet_hair_style);
- clif_send_petstatus(sd);
-// skill_unit_move(&sd->pd->bl,gettick(),1);
- }
-
- //homunculus [blackhole89]
- if(merc_is_hom_active(sd->hd)) {
- map_addblock(&sd->hd->bl);
- clif_spawn(&sd->hd->bl);
- clif_hominfo(sd,sd->hd,1);
- clif_hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice
- clif_send_homdata(sd,0,0);
- clif_homskillinfoblock(sd);
- //Homunc mimic their master's speed on each map change. [Skotlex]
- if (battle_config.slaves_inherit_speed&1)
- status_calc_bl(&sd->hd->bl, SCB_SPEED);
-// Since hom is inmune to land effects, unneeded.
-// skill_unit_move(&sd->hd->bl,gettick(),1);
- }
-
- if(sd->state.connect_new) {
- int lv;
- struct guild *g;
- sd->state.connect_new = 0;
- clif_skillinfoblock(sd);
- clif_updatestatus(sd,SP_NEXTBASEEXP);
- clif_updatestatus(sd,SP_NEXTJOBEXP);
- clif_updatestatus(sd,SP_SKILLPOINT);
- clif_initialstatus(sd);
-
- if (sd->sc.option&OPTION_FALCON)
- clif_status_load(&sd->bl, SI_FALCON, 1);
-
- if (sd->sc.option&OPTION_RIDING)
- clif_status_load(&sd->bl, SI_RIDING, 1);
-
- if(sd->status.manner < 0)
- sc_start(&sd->bl,SC_NOCHAT,100,0,0);
-
- //Auron reported that This skill only triggers when you logon on the map o.O [Skotlex]
- if ((lv = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) {
- if(sd->bl.m == sd->feel_map[0].m
- || sd->bl.m == sd->feel_map[1].m
- || sd->bl.m == sd->feel_map[2].m)
- sc_start(&sd->bl, SC_KNOWLEDGE, 100, lv, skill_get_time(SG_KNOWLEDGE, lv));
- }
-
- if(sd->pd && sd->pd->pet.intimate > 900)
- clif_pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd));
- if(sd->hd)
- merc_hom_init_timers(sd->hd);
-
- if (sd->status.guild_id > 0 && !sd->state.gmaster_flag &&
- (g=guild_search(sd->status.guild_id)) &&
- strcmp(sd->status.name,g->master) == 0)
- { //Block Guild Skills to prevent logout/login reuse exploiting. [Skotlex]
- guild_block_skill(sd, 300000);
- //Also set the Guild Master flag.
- sd->state.gmaster_flag = g;
- }
-
- //Delayed night effect on log-on fix for the glow-issue. Thanks to Larry.
- if (night_flag && map[sd->bl.m].flag.nightenabled)
- add_timer(gettick()+1000,clif_nighttimer,sd->bl.id,0);
-
- // Notify everyone that this char logged in [Skotlex].
- clif_foreachclient(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
-
- //Login Event
- npc_script_event(sd, NPCE_LOGIN);
- } else {
- //For some reason the client "loses" these on map-change.
- clif_updatestatus(sd,SP_STR);
- clif_updatestatus(sd,SP_AGI);
- clif_updatestatus(sd,SP_VIT);
- clif_updatestatus(sd,SP_INT);
- clif_updatestatus(sd,SP_DEX);
- clif_updatestatus(sd,SP_LUK);
-
- sd->state.using_fake_npc = 0;
-
- //New 'night' effect by dynamix [Skotlex]
- if (night_flag && map[sd->bl.m].flag.nightenabled)
- { //Display night.
- if (sd->state.night) //It must be resent because otherwise players get this annoying aura...
- clif_status_load(&sd->bl, SI_NIGHT, 0);
- else
- sd->state.night = 1;
- clif_status_load(&sd->bl, SI_NIGHT, 1);
- } else if (sd->state.night) { //Clear night display.
- sd->state.night = 0;
- clif_status_load(&sd->bl, SI_NIGHT, 0);
- }
-
- if(sd->npc_id)
- npc_event_dequeue(sd);
- }
-
- // Lance
- if(sd->state.event_loadmap && map[sd->bl.m].flag.loadevent){
- pc_setregstr(sd, add_str("@maploaded$"), map[sd->bl.m].name);
- npc_script_event(sd, NPCE_LOADMAP);
- }
-
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
- clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka]
-
- clif_weather_check(sd);
-
- map_foreachinarea(clif_getareachar,sd->bl.m,
- sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,sd->bl.x+AREA_SIZE,sd->bl.y+AREA_SIZE,
- BL_ALL,sd);
-
- // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first)
- if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
- npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
- else
- sd->areanpc_id = 0;
-
- // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris]
- if(pc_isdead(sd))
- clif_clearchar_area(&sd->bl,1);
-
-// Uncomment if you want to make player face in the same direction he was facing right before warping. [Skotlex]
-// else
-// clif_changed_dir(&sd->bl, SELF);
-// Trigger skill effects if you appear standing on them
- if(!battle_config.pc_invincible_time)
- skill_unit_move(&sd->bl,gettick(),1);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_TickSend(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- sd->client_tick=RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
-
- WFIFOHEAD(fd, packet_len_table[0x7f]);
- WFIFOW(fd,0)=0x7f;
- WFIFOL(fd,2)=gettick();
- WFIFOSET(fd,packet_len_table[0x7f]);
- return;
-}
-
-static int clif_walktoxy_timer(int tid, unsigned int tick, int id, int data)
-{
- struct map_session_data *sd;
- short x,y;
-
- if (!session[id] || (sd = session[id]->session_data) == NULL)
- return 0;
-
- if (!unit_can_move(&sd->bl))
- return 0;
-
- x = data>>16;
- y = data&0xffff;
-
- unit_walktoxy(&sd->bl, x, y, 0);
- return 1;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
- int x, y;
- int cmd;
- unsigned int tick;
- RFIFOHEAD(fd);
-
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
-
- if (clif_cant_act(sd) && sd->sc.opt1 != OPT1_STONEWAIT)
- return;
-
- if(sd->sc.count && sd->sc.data[SC_RUN].timer != -1)
- return;
-
- pc_stop_attack(sd);
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
-
- cmd = RFIFOW(fd,0);
- x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 1) >> 6);
- y = ((RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]+1) & 0x3f) << 4) +
- (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
- //Set last idle time... [Skotlex]
- sd->idletime = last_tick;
-
- tick = gettick();
- if (DIFF_TICK(sd->ud.canmove_tick, tick) > 0 &&
- DIFF_TICK(sd->ud.canmove_tick, tick) < 2000)
- { // Delay walking command. [Skotlex]
- add_timer(sd->ud.canmove_tick+1, clif_walktoxy_timer, fd, (x<<16)|y);
- return;
- }
- if (!unit_can_move(&sd->bl))
- return;
- unit_walktoxy(&sd->bl, x, y, 0);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_QuitGame(int fd, struct map_session_data *sd) {
- WFIFOHEAD(fd,packet_len_table[0x18b]);
- WFIFOW(fd,0) = 0x18b;
-
- /* Rovert's prevent logout option fixed [Valaris] */
- if (sd->sc.data[SC_CLOAKING].timer==-1 && sd->sc.data[SC_HIDING].timer==-1 &&
- (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- ) {
- clif_setwaitclose(fd);
- WFIFOW(fd,2)=0;
- } else {
- WFIFOW(fd,2)=1;
- }
- WFIFOSET(fd,packet_len_table[0x18b]);
-}
-
-
-/*==========================================
- *
- *------------------------------------------
- */
-void check_fake_id(int fd, struct map_session_data *sd, int target_id) {
- // if player asks for the fake player (only bot and modified client can see a hiden player)
-/* if (target_id == server_char_id) {
- char message_to_gm[strlen(msg_txt(536)) + strlen(msg_txt(540)) + strlen(msg_txt(507)) + strlen(msg_txt(508))];
- sprintf(message_to_gm, msg_txt(536), sd->status.name, sd->status.account_id); // Character '%s' (account: %d) try to use a bot (it tries to detect a fake player).
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // if we block people
- if (battle_config.ban_bot < 0) {
- chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(540)); // This player has been definitivly blocked.
- // if we ban people
- } else if (battle_config.ban_bot > 0) {
- chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_bot, 0); // type: 2 - ban (year, month, day, hour, minute, second)
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(507), battle_config.ban_bot); // This player has been banned for %d minute(s).
- } else { // impossible to display: we don't send fake player if battle_config.ban_bot is == 0
- // message about the ban
- sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
- }
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // send this info cause the bot ask until get an answer, damn spam
- malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
- WPACKETW(0) = 0x95;
- WPACKETL(2) = server_char_id;
- strncpy(WPACKETP(6), sd->status.name, 24);
- SENDPACKET(fd, packet_len_table[0x95]);
- // take fake player out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_char_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- // take fake mob out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_fake_mob_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- }
-
- // if player asks for the fake mob (only bot and modified client can see a hiden mob)
- if (target_id == server_fake_mob_id) {
- int fake_mob;
- char message_to_gm[strlen(msg_txt(537)) + strlen(msg_txt(540)) + strlen(msg_txt(507)) + strlen(msg_txt(508))];
- sprintf(message_to_gm, msg_txt(537), sd->status.name, sd->status.account_id); // Character '%s' (account: %d) try to use a bot (it tries to detect a fake mob).
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // if we block people
- if (battle_config.ban_bot < 0) {
- chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(540)); // This player has been definitivly blocked.
- // if we ban people
- } else if (battle_config.ban_bot > 0) {
- chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_bot, 0); // type: 2 - ban (year, month, day, hour, minute, second)
- clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
- // message about the ban
- sprintf(message_to_gm, msg_txt(507), battle_config.ban_bot); // This player has been banned for %d minute(s).
- } else { // impossible to display: we don't send fake player if battle_config.ban_bot is == 0
- // message about the ban
- sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
- }
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
- // send this info cause the bot ask until get an answer, damn spam
- malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
- WPACKETW(0) = 0x95;
- WPACKETL(2) = server_fake_mob_id;
- fake_mob = fake_mob_list[(sd->bl.m + sd->fd + sd->status.char_id) % (sizeof(fake_mob_list) / sizeof(fake_mob_list[0]))]; // never same mob
- if (!mobdb_checkid(fake_mob))
- fake_mob = 1002; // poring (default)
- strncpy(WPACKETP(6), mob_db[fake_mob].name, 24);
- SENDPACKET(fd, packet_len_table[0x95]);
- // take fake mob out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_fake_mob_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- // take fake player out of screen
- WPACKETW(0) = 0x80;
- WPACKETL(2) = server_char_id;
- WPACKETB(6) = 0;
- SENDPACKET(fd, packet_len_table[0x80]);
- }
-*/
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
- int account_id;
- struct block_list* bl;
- struct status_change *sc;
- RFIFOHEAD(fd);
-
- account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
-
- if(account_id<0 && -account_id == sd->bl.id) // for disguises [Valaris]
- account_id= sd->bl.id;
-
- bl = map_id2bl(account_id);
- //Is this possible? Lagged clients could request names of already gone mobs/players. [Skotlex]
- if (!bl) return;
-
- sc = status_get_sc(bl);
- if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && pc_isGM(sd) < battle_config.hack_info_GM_level)
- {
- //GM characters (with client side GM enabled are able to see invisible stuff) [Lance]
- //Asked name of invisible player, this shouldn't be possible!
- //Possible bot? Thanks to veider and qspirit
- //FIXME: Still isn't perfected as clients keep asking for this on legitimate situations.
- unsigned char gm_msg[256];
- sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requests name of invisible chars.", sd->status.name, sd->status.account_id);
- ShowWarning(gm_msg);
- // information is sended to all online GM
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
- return;
- }
- clif_charnameack(fd, bl);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <len>.w <str>.?B
- char *message, *buf, buf2[128];
- RFIFOHEAD(fd);
- WFIFOHEAD(fd, RFIFOW(fd,2) + 4);
-
- message = (unsigned char*)RFIFOP(fd,4);
- if (strlen(message) < strlen(sd->status.name) || //If the incoming string is too short...
- strncmp(message, sd->status.name, strlen(sd->status.name)) != 0) //Or the name does not matches...
- {
- //Hacked message, or infamous "client desynch" issue where they pick
- //one char while loading another. Just kick them out to correct it.
- clif_setwaitclose(fd);
- return;
- }
-
- if ((is_atcommand(fd, sd, message) != AtCommand_None) ||
- (is_charcommand(fd, sd, message) != CharCommand_None))
- return;
-
- if (sd->sc.count &&
- (sd->sc.data[SC_BERSERK].timer != -1 ||
- (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
- return;
-
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
-
- if (RFIFOW(fd,2)+4 < 128)
- buf = buf2; //Use a static buffer.
- else
- buf = (unsigned char*)aMallocA((RFIFOW(fd,2) + 4)*sizeof(char));
-
- // send message to others
- WBUFW(buf,0) = 0x8d;
- WBUFW(buf,2) = RFIFOW(fd,2) + 4; // len of message - 4 + 8
- WBUFL(buf,4) = sd->bl.id;
- memcpy(WBUFP(buf,8), message, RFIFOW(fd,2) - 4);
- clif_send(buf, WBUFW(buf,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
-
- if(buf != buf2) aFree(buf);
-
- // send back message to the speaker
- memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));
- WFIFOW(fd,0) = 0x8e;
- WFIFOSET(fd, WFIFOW(fd,2));
-
-#ifdef PCRE_SUPPORT
- map_foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, message, strlen(message), &sd->bl);
- map_foreachinrange(mob_chat_sub, &sd->bl, AREA_SIZE, BL_MOB, message, strlen(message), &sd->bl);
-#endif
-
- // Celest
- if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { //Super Novice.
- int next = pc_nextbaseexp(sd);
- if (next > 0 && (sd->status.base_exp * 1000 / next)% 100 == 0) {
- switch (sd->state.snovice_flag) {
- case 0:
- if (strstr(message, msg_txt(504)))
- sd->state.snovice_flag++;
- break;
- case 1:
- sprintf(buf2, msg_txt(505), sd->status.name);
- if (strstr(message, buf2))
- sd->state.snovice_flag++;
- break;
- case 2:
- if (strstr(message, msg_txt(506)))
- sd->state.snovice_flag++;
- break;
- case 3:
- if (skillnotok(MO_EXPLOSIONSPIRITS,sd))
- break; //Do not override the noskill mapflag. [Skotlex]
- clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,-1,
- sc_start(&sd->bl,SkillStatusChangeTable(MO_EXPLOSIONSPIRITS),100,
- 17,skill_get_time(MO_EXPLOSIONSPIRITS,1))); //Lv17-> +50 critical (noted by Poki) [Skotlex]
- sd->state.snovice_flag = 0;
- break;
- }
- }
- }
- return;
-}
-
-int clif_message(struct block_list *bl, char* msg)
-{
- unsigned short msg_len = strlen(msg) + 1;
- unsigned char buf[256];
-
- nullpo_retr(0, bl);
-
- WBUFW(buf, 0) = 0x8d;
- WBUFW(buf, 2) = msg_len + 8;
- WBUFL(buf, 4) = bl->id;
- memcpy(WBUFP(buf, 8), msg, msg_len);
-
- clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); // by Gengar
-
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_MapMove(int fd, struct map_session_data *sd) {
-// /m /mapmove (as @rura GM command)
- char output[30]; // 17+4+4=26, 30 max.
- char message[34]; // "/mm "+output
- char map_name[MAP_NAME_LENGTH]; //Err... map names are 15+'\0' in size, not 16+'\0' [Skotlex]
- RFIFOHEAD(fd);
-
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_MapMove))) {
- memcpy(map_name, RFIFOP(fd,2), MAP_NAME_LENGTH-1);
- map_name[MAP_NAME_LENGTH-1]='\0';
- sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
- atcommand_rura(fd, sd, "@rura", output);
- if((log_config.gm) && (get_atcommand_level(AtCommand_MapMove) >= log_config.gm)) {
- sprintf(message, "/mm %s", output);
- log_atcommand(sd, message);
- }
- }
-
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_changed_dir(struct block_list *bl, int type) {
- unsigned char buf[64];
-
- WBUFW(buf,0) = 0x9c;
- WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
- WBUFB(buf,8) = unit_getdir(bl);
-
- clif_send(buf, packet_len_table[0x9c], bl, type);
- if (disguised(bl)) {
- WBUFL(buf,2) = -bl->id;
- WBUFW(buf,6) = 0;
- clif_send(buf, packet_len_table[0x9c], bl, SELF);
- }
-
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ChangeDir(int fd, struct map_session_data *sd) {
- unsigned char headdir, dir;
- RFIFOHEAD(fd);
-
- headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- pc_setdir(sd, dir, headdir);
-
- clif_changed_dir(&sd->bl, AREA_WOS);
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_Emotion(int fd, struct map_session_data *sd) {
- unsigned char buf[64];
- RFIFOHEAD(fd);
-
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
- if (RFIFOB(fd,2) == 34) {// prevent use of the mute emote [Valaris]
- clif_skill_fail(sd, 1, 0, 1);
- return;
- }
- // fix flood of emotion icon (ro-proxy): flood only the hacker player
- if (sd->emotionlasttime >= time(NULL)) {
- sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
- clif_skill_fail(sd, 1, 0, 1);
- return;
- }
- sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
-
- WBUFW(buf,0) = 0xc0;
- WBUFL(buf,2) = sd->bl.id;
- WBUFB(buf,6) = RFIFOB(fd,2);
- clif_send(buf, packet_len_table[0xc0], &sd->bl, AREA);
- } else
- clif_skill_fail(sd, 1, 0, 1);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
- WFIFOHEAD(fd,packet_len_table[0xc2]);
- WFIFOW(fd,0) = 0xc2;
- WFIFOL(fd,2) = map_getusers();
- WFIFOSET(fd,packet_len_table[0xc2]);
-}
-
-void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)
-{
- unsigned char buf[64];
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
-
- if (sd->sc.count &&
- (sd->sc.data[SC_TRICKDEAD].timer != -1 ||
- sd->sc.data[SC_AUTOCOUNTER].timer != -1 ||
- sd->sc.data[SC_BLADESTOP].timer != -1))
- return;
-
- pc_stop_walking(sd, 1);
- pc_stop_attack(sd);
-
- if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
- target_id = sd->bl.id;
-
- switch(action_type) {
- case 0x00: // once attack
- case 0x07: // continuous attack
-
- if (clif_cant_act(sd) || sd->sc.option&OPTION_HIDE)
- return;
-
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
- if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
- clif_skill_fail(sd, 1, 4, 0);
- return;
- }
- }
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
-
- sd->idletime = last_tick;
- unit_attack(&sd->bl, target_id, action_type != 0);
- break;
- case 0x02: // sitdown
- if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) {
- clif_skill_fail(sd, 1, 0, 2);
- break;
- }
- if(pc_issit(sd)) {
- //Bugged client? Just refresh them.
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 2;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
- return;
- }
-
- if (sd->ud.skilltimer != -1 || sd->sc.opt1)
- break;
-
- if (sd->sc.count && (
- sd->sc.data[SC_DANCING].timer != -1 ||
- (sd->sc.data[SC_GRAVITATION].timer != -1 && sd->sc.data[SC_GRAVITATION].val3 == BCT_SELF)
- )) //No sitting during these states neither.
- break;
- pc_setsit(sd);
- skill_sit(sd, 1);
- clif_sitting(sd);
- break;
- case 0x03: // standup
- if (!pc_issit(sd)) {
- //Bugged client? Just refresh them.
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 3;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
- return;
- }
- pc_setstand(sd);
- skill_sit(sd, 0);
- WBUFW(buf, 0) = 0x8a;
- WBUFL(buf, 2) = sd->bl.id;
- WBUFB(buf,26) = 3;
- clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
- break;
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- clif_parse_ActionRequest_sub(sd,
- RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
- RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
- gettick()
- );
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_Restart(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- switch(RFIFOB(fd,2)) {
- case 0x00:
- if (pc_isdead(sd)) {
- pc_setstand(sd);
- pc_setrestartvalue(sd, 3);
- if (sd->sc.count && battle_config.debuff_on_logout&2) {
- //For some reason food buffs are removed when you respawn.
- if(sd->sc.data[SC_STRFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_STRFOOD,-1);
- if(sd->sc.data[SC_AGIFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_AGIFOOD,-1);
- if(sd->sc.data[SC_VITFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_VITFOOD,-1);
- if(sd->sc.data[SC_INTFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_INTFOOD,-1);
- if(sd->sc.data[SC_DEXFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_DEXFOOD,-1);
- if(sd->sc.data[SC_LUKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_LUKFOOD,-1);
- if(sd->sc.data[SC_HITFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_HITFOOD,-1);
- if(sd->sc.data[SC_FLEEFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_FLEEFOOD,-1);
- if(sd->sc.data[SC_BATKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_BATKFOOD,-1);
- if(sd->sc.data[SC_WATKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_WATKFOOD,-1);
- if(sd->sc.data[SC_MATKFOOD].timer!=-1)
- status_change_end(&sd->bl,SC_MATKFOOD,-1);
- }
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 2);
- }
- // in case the player's status somehow wasn't updated yet [Celest]
- else if (sd->battle_status.hp <= 0)
- pc_setdead(sd);
- break;
- case 0x01:
- /* Rovert's Prevent logout option - Fixed [Valaris] */
- if (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- { //Send to char-server for character selection.
- chrif_charselectreq(sd, session[fd]->client_addr.sin_addr.s_addr);
- } else {
- WFIFOHEAD(fd,packet_len_table[0x18b]);
- WFIFOW(fd,0)=0x18b;
- WFIFOW(fd,2)=1;
-
- WFIFOSET(fd,packet_len_table[0x018b]);
- }
- break;
- }
-}
-
-/*==========================================
- * Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B)
- *------------------------------------------
- */
-void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <nick>.24B <message>.?B // rewritten by [Yor]
- char *command, *msg;
- struct map_session_data *dstsd;
- int i=0;
- struct npc_data *npc;
- char split_data[10][50];
- char target[NAME_LENGTH+1];
- char output[256];
- unsigned int len;
- RFIFOHEAD(fd);
- len = RFIFOW(fd,2); //Packet length
- if (len < 28)
- { //Invalid packet, specified size is less than minimum! [Skotlex]
- ShowWarning("Hack on Whisper: %s (AID/CID: %d:%d)!\n", sd->status.name, sd->status.account_id, sd->status.char_id);
- clif_setwaitclose(fd);
- return;
- }
- if (len == 28) return; //Not sure if client really lets you send a blank line.
- len-=28; //Message length
- // 24+3+(RFIFOW(fd,2)-28)+1 <- last 1 is '\0'
- command = (char*)aMallocA((NAME_LENGTH+4+len) * sizeof(char));
- //No need for out of memory checks, malloc.c aborts the map when that happens.
- msg = command;
- msg+= sprintf(command, "%s : ", sd->status.name);
- memcpy(msg, RFIFOP(fd, 28), len);
- msg[len]='\0'; //Force a terminator
- if ((is_charcommand(fd, sd, command) != CharCommand_None) ||
- (is_atcommand(fd, sd, command) != AtCommand_None)) {
- aFree(command);
- return;
- }
- if (sd->sc.count &&
- (sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT))) {
- aFree(command);
- return;
- }
-
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) {
- aFree(command);
- return;
- }
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
-
- memcpy(&target,RFIFOP(fd, 4),NAME_LENGTH);
- target[NAME_LENGTH]='\0';
-
- //Chat Logging type 'W' / Whisper
- if(log_config.chat&1 //we log everything then
- || ( log_config.chat&2 //if Whisper bit is on
- && ( !agit_flag || !(log_config.chat&16) ))) //if WOE ONLY flag is off or AGIT is OFF
- log_chat("W", 0, sd->status.char_id, sd->status.account_id, (char*)mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, msg);
-
- //-------------------------------------------------------//
- // Lordalfa - Paperboy - To whisper NPC commands //
- //-------------------------------------------------------//
- if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) >4)) {
- char *str= target+4; //Skip the NPC: string part.
- if ((npc = npc_name2id(str)))
- {
- char *split;
- str = msg;
- for( i=0; i < 10; ++i )
- {// Splits the message using '#' as separators
- split = strchr(str,'#');
- if( split == NULL )
- { // use the remaining string
- strncpy(split_data[i], str, sizeof(split_data[0])/sizeof(char));
- split_data[i][sizeof(split_data[0])/sizeof(char)-1] = '\0';
- for( ++i; i < 10; ++i )
- split_data[i][0] = '\0';
- break;
- }
- *split = '\0';
- strncpy(split_data[i], str, sizeof(split_data[0])/sizeof(char));
- split_data[i][sizeof(split_data[0])/sizeof(char)-1] = '\0';
- str = split+1;
- }
-
- for (i=0;i<10;i++)
- {
- sprintf(output, "@whispervar%d$", i);
- set_var(sd,output,(char *) split_data[i]);
- }
-
- sprintf(output, "%s::OnWhisperGlobal", npc->name);
- npc_event(sd,output,0); // Calls the NPC label
-
- aFree(command);
- return;
- }
- }
-
- // Main chat [LuzZza]
- if(strcmpi(target, main_chat_nick) == 0) {
- if(!sd->state.mainchat)
- clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
- else {
- snprintf(output, sizeof(output)/sizeof(char), msg_txt(386), sd->status.name, msg);
- intif_announce(output, strlen(output) + 1, 0xFE000000, 0);
- }
- aFree(command);
- return;
- }
-
- // searching destination character
- dstsd = map_nick2sd(target);
- // player is not on this map-server
- // At this point, don't send wisp/page if it's not exactly the same name, because (example)
- // if there are 'Test' player on an other map-server and 'test' player on this map-server,
- // and if we ask for 'Test', we must not contact 'test' player
- // so, we send information to inter-server, which is the only one which decide (and copy correct name).
- if (dstsd == NULL ||
- strcmp(dstsd->status.name, target) != 0)
- { // send message to inter-server
- intif_wis_message(sd, target, msg, len);
- aFree(command);
- return;
- }
- // player is on this map-server
- if (dstsd->fd == fd) {
- // if you send to your self, don't send anything to others
- // but, normaly, it's impossible!
- clif_wis_message(fd, wisp_server_name,
- "You can not page yourself. Sorry.",
- strlen("You can not page yourself. Sorry.") + 1);
- aFree(command);
- return;
- }
- // otherwise, send message and answer immediatly
- if (dstsd->state.ignoreAll) {
- if (dstsd->sc.option & OPTION_INVISIBLE && pc_isGM(sd) < pc_isGM(dstsd))
- clif_wis_end(fd, 1); // 1: target character is not loged in
- else
- clif_wis_end(fd, 3); // 3: everyone ignored by target
- aFree(command);
- return;
- }
- // if player ignore the source character
- for(i = 0; i < MAX_IGNORE_LIST &&
- dstsd->ignore[i].name[0] != '\0' &&
- strcmp(dstsd->ignore[i].name, sd->status.name) != 0
- ; i++);
-
- if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0')
- { //Ignored
- clif_wis_end(fd, 2); // 2: ignored by target
- aFree(command);
- return;
- }
-
- // if source player not found in ignore list
- if(dstsd->away_message[0] != '\0') { // Send away automessage [LuzZza]
- //(Automessage has been sent)
- sprintf(output, "%s %s", msg, msg_txt(543));
- clif_wis_message(dstsd->fd, sd->status.name, output, strlen(output) + 1);
- clif_wis_end(fd, 0); // 0: success to send wisper
- if(dstsd->state.autotrade)
- //"Away [AT] - \"%s\""
- sprintf(output, msg_txt(544), dstsd->away_message);
- else
- //"Away - \"%s\""
- sprintf(output, msg_txt(545), dstsd->away_message);
- aFree(command);
- clif_wis_message(fd, dstsd->status.name, output, strlen(output) + 1);
- return;
- }
- // Normal message
- clif_wis_message(dstsd->fd, sd->status.name, msg, len);
- clif_wis_end(fd, 0); // 0: success to send wisper
- aFree(command);
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_GMmessage(int fd, struct map_session_data *sd) {
-// /b
- char message[MESSAGE_SIZE];
- RFIFOHEAD(fd);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast))) {
- intif_GMmessage((char*)RFIFOP(fd,4), RFIFOW(fd,2)-4, 0);
- if((log_config.gm) && (get_atcommand_level(AtCommand_Broadcast) >= log_config.gm)) {
- snprintf(message, RFIFOW(fd,2)-1, "/b %s", RFIFOP(fd,4));
- log_atcommand(sd, message);
- }
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
- struct flooritem_data *fitem;
- int map_object_id;
- RFIFOHEAD(fd);
-
- map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
-
- fitem = (struct flooritem_data*)map_id2bl(map_object_id);
-
- do {
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- break;
- }
-
- if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
- break;
-
- if (clif_cant_act(sd))
- break;
-
- //Disable cloaking/chasewalking characters from looting [Skotlex]
- if(pc_iscloaking(sd) || pc_ischasewalk(sd))
- break;
-
- if(sd->sc.count && (
- sd->sc.data[SC_TRICKDEAD].timer != -1 ||
- sd->sc.data[SC_BLADESTOP].timer != -1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM))
- )
- break;
-
- if (!pc_takeitem(sd, fitem))
- break;
- return;
- } while (0);
- // Client REQUIRES a fail packet or you can no longer pick items.
- clif_additem(sd,0,0,6);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_DropItem(int fd, struct map_session_data *sd) {
- int item_index, item_amount;
- RFIFOHEAD(fd);
-
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
-
- if (clif_cant_act(sd))
- return;
-
- if (sd->sc.count && (
- sd->sc.data[SC_AUTOCOUNTER].timer != -1 ||
- sd->sc.data[SC_BLADESTOP].timer != -1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM)
- ))
- return;
-
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- if (!pc_dropitem(sd, item_index, item_amount))
- //Because the client does not likes being ignored.
- clif_delitem(sd, item_index,0);
-
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_UseItem(int fd, struct map_session_data *sd) {
- int n;
- RFIFOHEAD(fd);
-
- if (pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl, 1);
- return;
- }
-
- if (sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT)
- return;
-
- //This flag enables you to use items while in an NPC. [Skotlex]
- if (sd->npc_id) {
- if (sd->npc_id != sd->npc_item_flag)
- return;
- } else
- if (clif_trading(sd))
- return;
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
-
- //Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex]
- sd->idletime = last_tick;
- n = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
-
- if(n <0 || n >= MAX_INVENTORY)
- return;
- if (!pc_useitem(sd,n))
- clif_useitemack(sd,n,0,0); //Send an empty ack packet or the client gets stuck.
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_EquipItem(int fd,struct map_session_data *sd)
-{
- int index;
- RFIFOHEAD(fd);
-
- if(pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl,1);
- return;
- }
- index = RFIFOW(fd,2)-2;
- if (index < 0 || index >= MAX_INVENTORY)
- return; //Out of bounds check.
-
- if(sd->npc_id) {
- if (sd->npc_id != sd->npc_item_flag)
- return;
- } else if (sd->state.storage_flag || sd->sc.opt1)
- ; //You can equip/unequip stuff while storage is open/under status changes
- else if (clif_cant_act(sd))
- return;
-
- if(sd->sc.data[SC_BLADESTOP].timer!=-1 || sd->sc.data[SC_BERSERK].timer!=-1 )
- return;
-
- if(!sd->status.inventory[index].identify) { // 未鑑定
- clif_equipitemack(sd,index,0,0); // fail
- return;
- }
- //ペット用装備であるかないか
- if(sd->inventory_data[index]) {
- if(sd->inventory_data[index]->type != IT_PETARMOR){
- if(sd->inventory_data[index]->type == IT_AMMO)
- pc_equipitem(sd,index,EQP_AMMO); //Client doesn't sends the position.
- else
- pc_equipitem(sd,index,RFIFOW(fd,4));
- } else
- pet_equipitem(sd,index);
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
-{
- int index;
- RFIFOHEAD(fd);
-
- if(pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl,1);
- return;
- }
-
- if (sd->state.storage_flag)
- ; //You can equip/unequip stuff while storage is open.
- else if (clif_cant_act(sd))
- return;
-
- index = RFIFOW(fd,2)-2;
-
- pc_unequipitem(sd,index,1);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
-{
- struct block_list *bl;
- RFIFOHEAD(fd);
-
- if(pc_isdead(sd)) {
- clif_clearchar_area(&sd->bl,1);
- return;
- }
-
- if (clif_cant_act(sd))
- return;
-
- bl = map_id2bl(RFIFOL(fd,2));
- if (!bl) return;
- switch (bl->type) {
- case BL_MOB:
- if (!((TBL_MOB *)bl)->nd || !mob_script_callback((TBL_MOB *)bl, &sd->bl, CALLBACK_NPCCLICK))
- clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
- break;
- case BL_PC:
- clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
- break;
- case BL_NPC:
- npc_click(sd,(TBL_NPC*)bl);
- break;
- }
- return;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->state.trading)
- return;
- npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
-{
- int fail=0,n;
- unsigned short *item_list;
- RFIFOHEAD(fd);
-
- n = (RFIFOW(fd,2)-4) /4;
- item_list = (unsigned short*)RFIFOP(fd,4);
-
- if (sd->state.trading|| !sd->npc_shopid)
- fail = 1;
- else
- fail = npc_buylist(sd,n,item_list);
-
- sd->npc_shopid = 0; //Clear shop data.
- WFIFOHEAD(fd,packet_len_table[0xca]);
- WFIFOW(fd,0)=0xca;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xca]);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
-{
- int fail=0,n;
- unsigned short *item_list;
- RFIFOHEAD(fd);
-
- n = (RFIFOW(fd,2)-4) /4;
- item_list = (unsigned short*)RFIFOP(fd,4);
-
- if (sd->state.trading || !sd->npc_shopid)
- fail = 1;
- else
- fail = npc_selllist(sd,n,item_list);
-
- sd->npc_shopid = 0; //Clear shop data.
-
- WFIFOHEAD(fd,packet_len_table[0xcb]);
- WFIFOW(fd,0)=0xcb;
- WFIFOB(fd,2)=fail;
- WFIFOSET(fd,packet_len_table[0xcb]);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
- return;
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){
- chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
- } else
- clif_skill_fail(sd,1,0,3);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- chat_changechatowner(sd,(char*)RFIFOP(fd,6));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- chat_kickchat(sd,(char*)RFIFOP(fd,2));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_ChatLeave(int fd,struct map_session_data *sd)
-{
- chat_leavechat(sd);
-}
-
-//Handles notifying asker and rejecter of what has just ocurred.
-//Type is used to determine the correct msg_txt to use:
-//0:
-static void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type)
-{
- char *msg, output[256];
- // Your request has been rejected by autoreject option.
- msg = msg_txt(392);
- clif_disp_onlyself(src, msg, strlen(msg));
- //Notice that a request was rejected.
- snprintf(output, 256, msg_txt(393+type), src->status.name, 256);
- clif_disp_onlyself(target, output, strlen(output));
-}
-
-/*==========================================
- * 取引要請を相手に送る
- *------------------------------------------
- */
-void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
-{
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- t_sd = map_id2sd(RFIFOL(fd,2));
-
- if(!sd->chatID && clif_cant_act(sd))
- return; //You can trade while in a chatroom.
-
- // @noask [LuzZza]
- if(t_sd) {
- if (t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 0);
- return;
- }
- if(!t_sd->chatID && clif_cant_act(t_sd))
- return;
- }
-
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){
- trade_traderequest(sd,t_sd);
- } else
- clif_skill_fail(sd,1,0,0);
-}
-
-/*==========================================
- * 取引要請
- *------------------------------------------
- */
-void clif_parse_TradeAck(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- trade_tradeack(sd,RFIFOB(fd,2));
-}
-
-/*==========================================
- * アイテム追加
- *------------------------------------------
- */
-void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- trade_tradeadditem(sd,RFIFOW(fd,2),RFIFOL(fd,4));
-}
-
-/*==========================================
- * アイテム追加完了(ok押し)
- *------------------------------------------
- */
-void clif_parse_TradeOk(int fd,struct map_session_data *sd)
-{
- trade_tradeok(sd);
-}
-
-/*==========================================
- * 取引キャンセル
- *------------------------------------------
- */
-void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
-{
- trade_tradecancel(sd);
-}
-
-/*==========================================
- * 取引許諾(trade押し)
- *------------------------------------------
- */
-void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
-{
- trade_tradecommit(sd);
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_StopAttack(int fd,struct map_session_data *sd)
-{
- pc_stop_attack(sd);
-}
-
-/*==========================================
- * カートへアイテムを移す
- *------------------------------------------
- */
-void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
-
- if (clif_trading(sd))
- return;
- pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
-}
-/*==========================================
- * カートからアイテムを出す
- *------------------------------------------
- */
-void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
-}
-
-/*==========================================
- * 付属品(鷹,ペコ,カート)をはずす
- *------------------------------------------
- */
-void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
-{
- //Can only remove Cart/Riding/Falcon.
- pc_setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON));
-}
-
-/*==========================================
- * チェンジカート
- *------------------------------------------
- */
-void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- pc_setcart(sd,RFIFOW(fd,2));
-}
-
-/*==========================================
- * ステータスアップ
- *------------------------------------------
- */
-void clif_parse_StatusUp(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- pc_statusup(sd,RFIFOW(fd,2));
-}
-
-/*==========================================
- * スキルレベルアップ
- *------------------------------------------
- */
-void clif_parse_SkillUp(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- pc_skillup(sd,RFIFOW(fd,2));
-}
-
-static void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, int skillnum, int skilllv, int target_id)
-{
- int lv;
-
- if (!hd)
- return;
-
- if (skillnotok_hom(skillnum, hd)) //[orn]
- return;
-
- if (hd->bl.id != target_id &&
- skill_get_inf(skillnum)&INF_SELF_SKILL)
- target_id = hd->bl.id; //What good is it to mess up the target in self skills? Wished I knew... [Skotlex]
-
- if (hd->ud.skilltimer != -1) {
- if (skillnum != SA_CASTCANCEL)
- return;
- } else if (DIFF_TICK(tick, hd->ud.canact_tick) < 0)
- return;
-
- lv = merc_hom_checkskill(hd, skillnum);
- if (skilllv > lv)
- skilllv = lv;
-
- if (skilllv)
- unit_skilluse_id(&hd->bl, target_id, skillnum, skilllv);
-}
-
-/*==========================================
- * スキル使用(ID指定)
- *------------------------------------------
- */
-void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
- int skillnum, skilllv, tmp, target_id;
- unsigned int tick = gettick();
- RFIFOHEAD(fd);
-
- if (clif_cant_act(sd))
- return;
- if (pc_issit(sd))
- return;
-
- skilllv = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- if (skilllv < 1) skilllv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex]
- skillnum = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
-
- //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
- sd->idletime = last_tick;
-
- tmp = skill_get_inf(skillnum);
- if (tmp&INF_GROUND_SKILL)
- return; //Using a ground skill on a target? WRONG.
-
- if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL) {
- clif_parse_UseSkillToId_homun(sd->hd, sd, tick, skillnum, skilllv, target_id);
- return;
- }
-
- if (skillnotok(skillnum, sd))
- return;
-
- if (sd->bl.id != target_id && !sd->state.skill_flag && tmp&INF_SELF_SKILL)
- target_id = sd->bl.id; //What good is it to mess up the target in self skills? Wished I knew... [Skotlex]
-
- if (sd->ud.skilltimer != -1) {
- if (skillnum != SA_CASTCANCEL)
- return;
- } else if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
- clif_skill_fail(sd, skillnum, 4, 0);
- return;
- }
-
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
-
- if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
- target_id = sd->bl.id;
-
- if (sd->skillitem == skillnum) {
- if (skilllv != sd->skillitemlv)
- skilllv = sd->skillitemlv;
- unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
- return;
- }
-
- sd->skillitem = sd->skillitemlv = 0;
- if (skillnum == MO_EXTREMITYFIST) {
- if ((sd->sc.data[SC_COMBO].timer == -1 ||
- (sd->sc.data[SC_COMBO].val1 != MO_COMBOFINISH &&
- sd->sc.data[SC_COMBO].val1 != CH_TIGERFIST &&
- sd->sc.data[SC_COMBO].val1 != CH_CHAINCRUSH))) {
- if (!sd->state.skill_flag ) {
- sd->state.skill_flag = 1;
- clif_skillinfo(sd, MO_EXTREMITYFIST, INF_ATTACK_SKILL, -1);
- return;
- } else if (sd->bl.id == target_id) {
- clif_skillinfo(sd, MO_EXTREMITYFIST, INF_ATTACK_SKILL, -1);
- return;
- }
- }
- }
- if (skillnum == TK_JUMPKICK) {
- if (sd->sc.data[SC_COMBO].timer == -1 ||
- sd->sc.data[SC_COMBO].val1 != TK_JUMPKICK) {
- if (!sd->state.skill_flag ) {
- sd->state.skill_flag = 1;
- clif_skillinfo(sd, TK_JUMPKICK, INF_ATTACK_SKILL, -1);
- return;
- } else if (sd->bl.id == target_id) {
- clif_skillinfo(sd, TK_JUMPKICK, INF_ATTACK_SKILL, -1);
- return;
- }
- }
- }
-
- if (skillnum >= GD_SKILLBASE) {
- if (sd->state.gmaster_flag)
- skilllv = guild_checkskill(sd->state.gmaster_flag, skillnum);
- else
- skilllv = 0;
- } else {
- tmp = pc_checkskill(sd, skillnum);
- if (skilllv > tmp)
- skilllv = tmp;
- }
-
- if (skilllv)
- unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
-
- if (sd->state.skill_flag)
- sd->state.skill_flag = 0;
-}
-
-/*==========================================
- * スキル使用(場所指定)
- *------------------------------------------
- */
-void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilllv, int skillnum, int x, int y, int skillmoreinfo)
-{
- int lv;
- unsigned int tick = gettick();
- RFIFOHEAD(fd);
-
- //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
- sd->idletime = last_tick;
-
- if (skillnotok(skillnum, sd))
- return;
-
- if (!(skill_get_inf(skillnum)&INF_GROUND_SKILL))
- return; //Using a target skill on the ground? WRONG.
-
- if (skillmoreinfo != -1) {
- if (pc_issit(sd)) {
- clif_skill_fail(sd, skillnum, 0, 0);
- return;
- }
- memcpy(talkie_mes, RFIFOP(fd,skillmoreinfo), MESSAGE_SIZE);
- talkie_mes[MESSAGE_SIZE-1] = '\0'; //Overflow protection [Skotlex]
- }
-
- if (sd->ud.skilltimer != -1)
- return;
- if (DIFF_TICK(tick, sd->ud.canact_tick) < 0)
- {
- clif_skill_fail(sd, skillnum, 4, 0);
- return;
- }
-
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if (sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
- if (sd->skillitem == skillnum) {
- if (skilllv != sd->skillitemlv)
- skilllv = sd->skillitemlv;
- unit_skilluse_pos(&sd->bl, x, y, skillnum, skilllv);
- } else {
- sd->skillitem = sd->skillitemlv = 0;
- if ((lv = pc_checkskill(sd, skillnum)) > 0) {
- if (skilllv > lv)
- skilllv = lv;
- unit_skilluse_pos(&sd->bl, x, y, skillnum,skilllv);
- }
- }
-}
-
-
-void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- if (clif_cant_act(sd))
- return;
- if (pc_issit(sd))
- return;
-
- clif_parse_UseSkillToPosSub(fd, sd,
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //skill lv
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //skill num
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
- -1 //Skill more info.
- );
-}
-
-void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- if (clif_cant_act(sd))
- return;
- if (pc_issit(sd))
- return;
-
- clif_parse_UseSkillToPosSub(fd, sd,
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //Skill lv
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //Skill num
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
- RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
- packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[4] //skill more info
- );
-}
-/*==========================================
- * スキル使用(map指定)
- *------------------------------------------
- */
-void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
-
- if (clif_cant_act(sd))
- return;
-
- if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
- return;
-
- if(sd->invincible_timer != -1)
- pc_delinvincibletimer(sd);
-
- skill_castend_map(sd,RFIFOW(fd,2),(char*)RFIFOP(fd,4));
-}
-/*==========================================
- * メモ要求
- *------------------------------------------
- */
-void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
-{
- if (!pc_isdead(sd))
- pc_memo(sd,-1);
-}
-/*==========================================
- * アイテム合成
- *------------------------------------------
- */
-void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
-
- if (sd->menuskill_id != AM_PHARMACY)
- return;
-
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- skill_produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1);
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-/*==========================================
- * 武器修理
- *------------------------------------------
- */
-void clif_parse_RepairItem(int fd, struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
-
- if (sd->menuskill_id != BS_REPAIRWEAPON)
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- skill_repairweapon(sd,RFIFOW(fd,2));
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) {
- int idx;
- RFIFOHEAD(fd);
-
- if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit?
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- skill_weaponrefine(sd, idx-2);
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
-{
- unsigned char select;
- RFIFOHEAD(fd);
-
- select = RFIFOB(fd,6);
- if((select > sd->max_menu && select != 0xff) || !select){
- ShowWarning("Hack on NPC Select Menu: %s (AID: %d)!\n",sd->status.name,sd->bl.id);
- clif_GM_kick(sd,sd,0);
- } else {
- sd->npc_menu=select;
- npc_scriptcont(sd,RFIFOL(fd,2));
- }
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
-#ifdef __WIN32
- //For some extraordinarily eerie reason that noone has figured out yet,
- //windows native compiles NEED this nullpo_retv or the function is not found!
- nullpo_retv(sd);
-#endif
- npc_scriptcont(sd,RFIFOL(fd,2));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
-#define RFIFOL_(fd,pos) (*(int*)(session[fd]->rdata+session[fd]->rdata_pos+(pos)))
- //Input Value overflow Exploit FIX
- sd->npc_amount=RFIFOL_(fd,6); //fixed by Lupus. npc_amount is (int) but was RFIFOL changing it to (unsigned int)
-#undef RFIFOL_
-
- npc_scriptcont(sd,RFIFOL(fd,2));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
-{
- short message_len;
- RFIFOHEAD(fd);
- message_len = RFIFOW(fd,2)-7;
-
- if(message_len < 1)
- return; //Blank message?
-
- if(message_len >= sizeof(sd->npc_str)){
- ShowWarning("clif: input string too long !\n");
- message_len = sizeof(sd->npc_str);
- }
-
- // Exploit prevention if crafted packets (without null) is being sent. [Lance]
- memcpy(sd->npc_str,RFIFOP(fd,8),message_len);
- sd->npc_str[message_len-1]=0;
- npc_scriptcont(sd,RFIFOL(fd,4));
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
- npc_scriptcont(sd,RFIFOL(fd,2));
-}
-
-/*==========================================
- * アイテム鑑定
- *------------------------------------------
- */
-void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->menuskill_id != MC_IDENTIFY)
- return;
- skill_identify(sd,RFIFOW(fd,2)-2);
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-/*==========================================
- * 矢作成
- *------------------------------------------
- */
-void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->menuskill_id != AC_MAKINGARROW)
- return;
- if (clif_trading(sd)) {
- //Make it fail to avoid shop exploits where you sell something different than you see.
- clif_skill_fail(sd,sd->ud.skillid,0,0);
- sd->menuskill_lv = sd->menuskill_id = 0;
- return;
- }
- skill_arrow_create(sd,RFIFOW(fd,2));
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-/*==========================================
- * オートスペル受信
- *------------------------------------------
- */
-void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->menuskill_id != SA_AUTOSPELL)
- return;
- skill_autospell(sd,RFIFOW(fd,2));
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-/*==========================================
- * カード使用
- *------------------------------------------
- */
-void clif_parse_UseCard(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->state.trading!= 0)
- return;
- clif_use_card(sd,RFIFOW(fd,2)-2);
-}
-/*==========================================
- * カード挿入装備選択
- *------------------------------------------
- */
-void clif_parse_InsertCard(int fd,struct map_session_data *sd)
-{
- RFIFOHEAD(fd);
- if (sd->state.trading!= 0)
- return;
- pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
-}
-
-/*==========================================
- * 0193 キャラID名前引き
- *------------------------------------------
- */
-void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
- int char_id;
- RFIFOHEAD(fd);
-
- char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
- clif_solved_charname(sd, char_id);
-}
-
-/*==========================================
- * 0197 /resetskill /resetstate
- *------------------------------------------
- */
-void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState)) {
- switch(RFIFOW(fd,2)){
- case 0:
- pc_resetstate(sd);
- break;
- case 1:
- pc_resetskill(sd,1);
- break;
- }
- if((log_config.gm) && (get_atcommand_level(AtCommand_ResetState) >= log_config.gm)) {
- log_atcommand(sd, RFIFOW(fd,2) ? "/resetskill" : "/resetstate");
- }
- }
-}
-
-/*==========================================
- * 019c /lb等
- *------------------------------------------
- */
-void clif_parse_LGMmessage(int fd, struct map_session_data *sd) {
- unsigned char buf[512];
- char message[MESSAGE_SIZE];
- RFIFOHEAD(fd);
-
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_LocalBroadcast))) {
- WBUFW(buf,0) = 0x9a;
- WBUFW(buf,2) = RFIFOW(fd,2);
- memcpy(WBUFP(buf,4), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
- clif_send(buf, RFIFOW(fd,2), &sd->bl, ALL_SAMEMAP);
- if((log_config.gm) && (get_atcommand_level(AtCommand_LocalBroadcast) >= log_config.gm)) {
- snprintf(message, RFIFOW(fd,2), "/lb %s", RFIFOP(fd,4));
- log_atcommand(sd, message);
- }
- }
-}
-
-/*==========================================
- * カプラ倉庫へ入れる
- *------------------------------------------
- */
-void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) {
- int item_index, item_amount;
- RFIFOHEAD(fd);
-
- if (clif_trading(sd))
- return;
-
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
- if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
- return;
-
- if (sd->state.storage_flag == 1)
- storage_storageadd(sd, item_index, item_amount);
- else if (sd->state.storage_flag == 2)
- storage_guild_storageadd(sd, item_index, item_amount);
-}
-
-/*==========================================
- * カプラ倉庫から出す
- *------------------------------------------
- */
-void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) {
- int item_index, item_amount;
- RFIFOHEAD(fd);
-
- item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1;
- item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
-
- if (sd->state.storage_flag == 1)
- storage_storageget(sd, item_index, item_amount);
- else if(sd->state.storage_flag == 2)
- storage_guild_storageget(sd, item_index, item_amount);
-}
-
-/*==========================================
- * カプラ倉庫へカートから入れる
- *------------------------------------------
- */
-void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- if(sd->vender_id)
- return;
-
- if (sd->state.storage_flag == 1)
- storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
- storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
-}
-
-/*==========================================
- * カプラ倉庫から出す
- *------------------------------------------
- */
-void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- if (sd->vender_id)
- return;
- if (sd->state.storage_flag == 1)
- storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
- storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
-}
-
-/*==========================================
- * カプラ倉庫を閉じる
- *------------------------------------------
- */
-void clif_parse_CloseKafra(int fd, struct map_session_data *sd) {
- if (sd->state.storage_flag == 1)
- storage_storageclose(sd);
- else if (sd->state.storage_flag == 2)
- storage_guild_storageclose(sd);
-}
-
-/*==========================================
- * パーティを作る
- *------------------------------------------
- */
-void clif_parse_CreateParty(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
- return;
- }
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) {
- party_create(sd,(char*)RFIFOP(fd,2),0,0);
- } else
- clif_skill_fail(sd,1,0,4);
-}
-
-/*==========================================
- * パーティを作る
- *------------------------------------------
- */
-void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
- return;
- }
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){
- RFIFOHEAD(fd);
- party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
- } else
- clif_skill_fail(sd,1,0,4);
-}
-
-/*==========================================
- * パーティに勧誘
- *------------------------------------------
- */
-void clif_parse_PartyInvite(int fd, struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
- return;
- }
-
- t_sd = map_id2sd(RFIFOL(fd,2));
-
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 1);
- return;
- }
-
- party_invite(sd, t_sd);
-}
-
-/*==========================================
- * パーティ勧誘返答
- *------------------------------------------
- */
-void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){
- party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
- } else {
- party_reply_invite(sd,RFIFOL(fd,2),-1);
- clif_skill_fail(sd,1,0,4);
- }
-}
-
-/*==========================================
- * パーティ脱退要求
- *------------------------------------------
- */
-void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
- return;
- }
- party_leave(sd);
-}
-
-/*==========================================
- * パーティ除名要求
- *------------------------------------------
- */
-void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.partylock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(227));
- return;
- }
- party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
-}
-
-/*==========================================
- * パーティ設定変更要求
- *------------------------------------------
- */
-void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
- struct party_data *p;
- RFIFOHEAD(fd);
-
- if(!sd->status.party_id)
- return;
-
- p = party_search(sd->status.party_id);
- if (!p) return;
- //The client no longer can change the item-field, therefore it always
- //comes as zero. Here, resend the item data as it is.
-// party_changeoption(sd, RFIFOW(fd,2), RFIFOW(fd,4));
- party_changeoption(sd, RFIFOW(fd,2), p->party.item);
-}
-
-/*==========================================
- * パーティメッセージ送信要求
- *------------------------------------------
- */
-void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4)) != CharCommand_None ||
- is_atcommand(fd, sd, (char*)RFIFOP(fd,4)) != AtCommand_None)
- return;
-
- if (sd->sc.count && (
- sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
- ))
- return;
-
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
-
- party_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
-}
-
-/*==========================================
- * 露店閉鎖
- *------------------------------------------
- */
-void clif_parse_CloseVending(int fd, struct map_session_data *sd) {
- vending_closevending(sd);
-}
-
-/*==========================================
- * 露店アイテムリスト要求
- *------------------------------------------
- */
-void clif_parse_VendingListReq(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- vending_vendinglistreq(sd,RFIFOL(fd,2));
- if(sd->npc_id)
- npc_event_dequeue(sd);
-}
-
-/*==========================================
- * 露店アイテム購入
- *------------------------------------------
- */
-void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- vending_purchasereq(sd, RFIFOW(fd,2), RFIFOL(fd,4), RFIFOP(fd,8));
-}
-
-/*==========================================
- * 露店開設
- *------------------------------------------
- */
-void clif_parse_OpenVending(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (clif_trading(sd))
- return;
- if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
- return;
- vending_openvending(sd, RFIFOW(fd,2), (char*)RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85));
-}
-
-/*==========================================
- * ギルドを作る
- *------------------------------------------
- */
-void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
- guild_create(sd, (char*)RFIFOP(fd,6));
-}
-
-/*==========================================
- * ギルドマスターかどうか確認
- *------------------------------------------
- */
-void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) {
- clif_guild_masterormember(sd);
-}
-
-/*==========================================
- * ギルド情報要求
- *------------------------------------------
- */
-void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- switch(RFIFOL(fd,2)){
- case 0: // ギルド基本情報、同盟敵対情報
- clif_guild_basicinfo(sd);
- clif_guild_allianceinfo(sd);
- break;
- case 1: // メンバーリスト、役職名リスト
- clif_guild_positionnamelist(sd);
- clif_guild_memberlist(sd);
- break;
- case 2: // 役職名リスト、役職情報リスト
- clif_guild_positionnamelist(sd);
- clif_guild_positioninfolist(sd);
- break;
- case 3: // スキルリスト
- clif_guild_skillinfo(sd);
- break;
- case 4: // 追放リスト
- clif_guild_expulsionlist(sd);
- break;
- default:
- if (battle_config.error_log)
- ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
- break;
- }
-}
-
-/*==========================================
- * ギルド役職変更
- *------------------------------------------
- */
-void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
- int i;
- RFIFOHEAD(fd);
-
- for(i = 4; i < RFIFOW(fd,2); i += 40 ){
- guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
- }
-}
-
-/*==========================================
- * ギルドメンバ役職変更
- *------------------------------------------
- */
-void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) {
- int i;
- RFIFOHEAD(fd);
-
- for(i=4;i<RFIFOW(fd,2);i+=12){
- guild_change_memberposition(sd->status.guild_id,
- RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
- }
-}
-
-/*==========================================
- * ギルドエンブレム要求
- *------------------------------------------
- */
-void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) {
- struct guild *g;
- RFIFOHEAD(fd);
- g=guild_search(RFIFOL(fd,2));
- if(g!=NULL)
- clif_guild_emblem(sd,g);
-}
-
-/*==========================================
- * ギルドエンブレム変更
- *------------------------------------------
- */
-void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4));
-}
-
-/*==========================================
- * ギルド告知変更
- *------------------------------------------
- */
-void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
-}
-
-/*==========================================
- * ギルド勧誘
- *------------------------------------------
- */
-void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
-
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
-
- t_sd = map_id2sd(RFIFOL(fd,2));
-
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 2);
- return;
- }
-
- guild_invite(sd,t_sd);
-}
-
-/*==========================================
- * ギルド勧誘返信
- *------------------------------------------
- */
-void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
-}
-
-/*==========================================
- * ギルド脱退
- *------------------------------------------
- */
-void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
- guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
-}
-
-/*==========================================
- * ギルド追放
- *------------------------------------------
- */
-void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
- guild_expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
-}
-
-/*==========================================
- * ギルド会話
- *------------------------------------------
- */
-void clif_parse_GuildMessage(int fd,struct map_session_data *sd) {
- RFIFOHEAD(fd);
-
- if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4)) != CharCommand_None ||
- is_atcommand(fd, sd, (char*)RFIFOP(fd, 4)) != AtCommand_None)
- return;
-
- if (sd->sc.count && (
- sd->sc.data[SC_BERSERK].timer!=-1 ||
- (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
- ))
- return;
-
- if (battle_config.min_chat_delay)
- { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
- return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
- }
-
- guild_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
-}
-
-/*==========================================
- * ギルド同盟要求
- *------------------------------------------
- */
-void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
-
- RFIFOHEAD(fd);
-
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
-
- t_sd = map_id2sd(RFIFOL(fd,2));
-
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 3);
- return;
- }
-
- guild_reqalliance(sd,t_sd);
-}
-
-/*==========================================
- * ギルド同盟要求返信
- *------------------------------------------
- */
-void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
-}
-
-/*==========================================
- * ギルド関係解消
- *------------------------------------------
- */
-void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
- guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
-}
-
-/*==========================================
- * ギルド敵対
- *------------------------------------------
- */
-void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
-
- struct map_session_data *t_sd;
- RFIFOHEAD(fd);
-
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
-
- t_sd = map_id2sd(RFIFOL(fd,2));
-
- // @noask [LuzZza]
- if(t_sd && t_sd->state.noask) {
- clif_noask_sub(sd, t_sd, 4);
- return;
- }
-
- guild_opposition(sd,t_sd);
-}
-
-/*==========================================
- * ギルド解散
- *------------------------------------------
- */
-void clif_parse_GuildBreak(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if(map[sd->bl.m].flag.guildlock)
- { //Guild locked.
- clif_displaymessage(fd, msg_txt(228));
- return;
- }
- guild_break(sd,(char*)RFIFOP(fd,2));
-}
-
-// pet
-void clif_parse_PetMenu(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- pet_menu(sd,RFIFOB(fd,2));
-}
-
-void clif_parse_CatchPet(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- pet_catch_process2(sd,RFIFOL(fd,2));
-}
-
-void clif_parse_SelectEgg(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_lv != -1)
- return;
- pet_select_egg(sd,RFIFOW(fd,2)-2);
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-
-void clif_parse_SendEmotion(int fd, struct map_session_data *sd) {
- if(sd->pd) {
- RFIFOHEAD(fd);
- clif_pet_emotion(sd->pd,RFIFOL(fd,2));
- }
-}
-
-void clif_parse_ChangePetName(int fd, struct map_session_data *sd) {
- RFIFOHEAD(fd);
- pet_change_name(sd,(char*)RFIFOP(fd,2), 0);
-}
-
-// Kick (right click menu for GM "(name) force to quit")
-void clif_parse_GMKick(int fd, struct map_session_data *sd) {
- struct block_list *target;
- int tid;
- char message[MESSAGE_SIZE];
-
- RFIFOHEAD(fd);
- tid = RFIFOL(fd,2);
-
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Kick))) {
- target = map_id2bl(tid);
- if (target) {
- if (target->type == BL_PC) {
- struct map_session_data *tsd = (struct map_session_data *)target;
- if (pc_isGM(sd) > pc_isGM(tsd)) {
- clif_GM_kick(sd, tsd, 1);
- if((log_config.gm) && (get_atcommand_level(AtCommand_Kick) >= log_config.gm)) {
- sprintf(message, "/kick %d", tsd->status.char_id);
- log_atcommand(sd, message);
- }
- } else
- clif_GM_kickack(sd, 0);
- } else if (target->type == BL_MOB) {
- status_percent_damage(&sd->bl, target, 100, 0);
- sprintf(message, "/kick %d %d %d %d", tid, target->id, target->type, target->subtype);
- if((log_config.gm) && (get_atcommand_level(AtCommand_Kick) >= log_config.gm)) {
- sprintf(message, "/kick %s", ((struct mob_data*)target)->db->sprite);
- log_atcommand(sd, message);
- }
- } else
- clif_GM_kickack(sd, 0);
- } else
- clif_GM_kickack(sd, 0);
- }
-}
-
-/*==========================================
- * /shift
- *------------------------------------------
- */
-void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor]
- char player_name[NAME_LENGTH];
- char message[MESSAGE_SIZE];
-
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_JumpTo))) {
- RFIFOHEAD(fd);
- memcpy(player_name, RFIFOP(fd,2), NAME_LENGTH);
- atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
- if((log_config.gm) && (get_atcommand_level(AtCommand_JumpTo) >= log_config.gm)) {
- sprintf(message, "/shift %s", player_name);
- log_atcommand(sd, message);
- }
- }
-
- return;
-}
-
-/*==========================================
- * /recall
- *------------------------------------------
- */
-void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT
- char player_name[NAME_LENGTH];
- char message[MESSAGE_SIZE];
-
- malloc_tsetdword(player_name, '\0', sizeof(player_name));
-
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) {
- RFIFOHEAD(fd);
- memcpy(player_name, RFIFOP(fd,2), NAME_LENGTH);
- atcommand_recall(fd, sd, "@recall", player_name); // as @recall
- if((log_config.gm) && (get_atcommand_level(AtCommand_Recall) >= log_config.gm)) {
- sprintf(message, "/recall %s", player_name);
- log_atcommand(sd, message);
- }
- }
-
- return;
-}
-
-/*==========================================
- * /monster /item rewriten by [Yor]
- *------------------------------------------
- */
-void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
- char monster_item_name[NAME_LENGTH+10]; //Additional space is for logging, eg: "@monster Poring"
- int level;
-
- malloc_tsetdword(monster_item_name, '\0', sizeof(monster_item_name));
-
- if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
- RFIFOHEAD(fd);
- memcpy(monster_item_name, RFIFOP(fd,2), NAME_LENGTH);
-
- if (mobdb_searchname(monster_item_name) != 0) {
- if (pc_isGM(sd) >= (level =get_atcommand_level(AtCommand_Spawn))) // changed from AtCommand_Monster for Skots [Reddozen]
- {
- atcommand_monster(fd, sd, "@spawn", monster_item_name); // as @spawn
- if(log_config.gm && level >= log_config.gm)
- { //Log action. [Skotlex]
- snprintf(monster_item_name, sizeof(monster_item_name)-1, "@spawn %s", RFIFOP(fd,2));
- log_atcommand(sd, monster_item_name);
- }
- }
- } else if (itemdb_searchname(monster_item_name) != NULL) {
- if (pc_isGM(sd) >= (level = get_atcommand_level(AtCommand_Item)))
- {
- atcommand_item(fd, sd, "@item", monster_item_name); // as @item
- if(log_config.gm && level >= log_config.gm)
- { //Log action. [Skotlex]
- snprintf(monster_item_name, sizeof(monster_item_name)-1, "@item %s", RFIFOP(fd,2));
- log_atcommand(sd, monster_item_name);
- }
- }
- }
- }
-}
-
-void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yor]
- if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
- (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) {
- if (sd->sc.option & OPTION_INVISIBLE) {
- sd->sc.option &= ~OPTION_INVISIBLE;
- if (sd->disguise)
- status_set_viewdata(&sd->bl, sd->disguise);
- else
- status_set_viewdata(&sd->bl, sd->status.class_);
- clif_displaymessage(fd, "Invisible: Off.");
- } else {
- sd->sc.option |= OPTION_INVISIBLE;
- //Experimental hidden mode, changes your view class to invisible [Skotlex]
- sd->vd.class_ = INVISIBLE_CLASS;
- clif_displaymessage(fd, "Invisible: On.");
- if((log_config.gm) && (get_atcommand_level(AtCommand_Hide) >= log_config.gm)) {
- log_atcommand(sd, "/hide");
- }
- }
- clif_changeoption(&sd->bl);
- }
-}
-
-/*==========================================
- * GMによるチャット禁止時間付与
- *------------------------------------------
- */
-void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
-{
- int type, limit, level;
- struct block_list *bl;
- struct map_session_data *dstsd;
-
- RFIFOHEAD(fd);
- bl = map_id2bl(RFIFOL(fd,2));
- if (!bl || bl->type != BL_PC)
- return;
- nullpo_retv(dstsd =(struct map_session_data *)bl);
-
- type = RFIFOB(fd,6);
- limit = RFIFOW(fd,7);
- if (type == 0)
- limit = 0 - limit;
-
- //If type is 2 and the ids don't match, this is a crafted hacked packet!
- //Disabled because clients keep self-muting when you give players public @ commands... [Skotlex]
- if (type == 2/* && sd->bl.id != dstsd->bl.id*/)
- return;
-
- if (
- ((level = pc_isGM(sd)) > pc_isGM(dstsd) && level >= get_atcommand_level(AtCommand_Mute))
- || (type == 2 && !level)) {
- clif_GM_silence(sd, dstsd, ((type == 2) ? 1 : type));
- dstsd->status.manner -= limit;
- if(dstsd->status.manner < 0)
- sc_start(bl,SC_NOCHAT,100,0,0);
- else
- {
- dstsd->status.manner = 0;
- status_change_end(bl,SC_NOCHAT,-1);
- }
- }
-
- return;
-}
-/*==========================================
- * GMによるチャット禁止時間参照(?)
- *------------------------------------------
- */
-void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
-{
- int tid;
- RFIFOHEAD(fd);
- tid = RFIFOL(fd,2);
-
- WFIFOHEAD(fd,packet_len_table[0x1e0]);
- WFIFOW(fd,0) = 0x1e0;
- WFIFOL(fd,2) = tid;
- sprintf((char*)WFIFOP(fd,6),"%d",tid);
-// memcpy(WFIFOP(fd,6), "TESTNAME", 24);
- WFIFOSET(fd, packet_len_table[0x1e0]);
-
- return;
-}
-
-static int pstrcmp(const void *a, const void *b)
-{
- char *name1 = (char *)a;
- char *name2 = (char *)b;
- if (name1[0] && name2[0])
- return strcmp(name1, name2);
- //Since names are sorted in ascending order, send blank entries to the bottom.
- if (name1[0])
- return -1;
- if (name2[0])
- return 1;
- return 0;
-}
-
-void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
- char output[512];
- char *nick; // S 00cf <nick>.24B <type>.B: 00 (/ex nick) deny speech from nick, 01 (/in nick) allow speech from nick
- int i;
- WFIFOHEAD(fd,packet_len_table[0xd1]);
- RFIFOHEAD(fd);
-
- malloc_tsetdword(output, '\0', sizeof(output));
-
- nick = (char*)RFIFOP(fd,2); // speed up
- nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name have at maximum 23 characters
-
- WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
- WFIFOB(fd,2) = RFIFOB(fd,26);
- // do nothing only if nick can not exist
- if (strlen(nick) < 4) {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name,
- "This player name is not valid.",
- strlen("This player name is not valid.")+1);
- return;
- }
- // name can exist
- // deny action (we add nick only if it's not already exist
- if (RFIFOB(fd,26) == 0) { // Add block
- for(i = 0; i < MAX_IGNORE_LIST &&
- sd->ignore[i].name[0] != '\0' &&
- strcmp(sd->ignore[i].name, nick) != 0
- ; i++);
-
- if (i == MAX_IGNORE_LIST) { //Full List
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name,
- "You can not block more people.",
- strlen("You can not block more people.") + 1);
- if (strcmp(wisp_server_name, nick) == 0)
- { // to found possible bot users who automaticaly ignore people.
- sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
- }
- return;
- }
- if(sd->ignore[i].name[0] != '\0')
- { //Name already exists.
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name,
- "This player is already blocked.",
- strlen("This player is already blocked.") + 1);
- if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
- sprintf(output, "Character '%s' (account: %d) has tried AGAIN to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
- }
- return;
- }
- //Insert in position i
- memcpy(sd->ignore[i].name, nick, NAME_LENGTH-1);
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d1]);
- if (strcmp(wisp_server_name, nick) == 0)
- { // to found possible bot users who automaticaly ignore people.
- sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
- // send something to be inform and force bot to ignore twice... If GM receiving block + block again, it's a bot :)
- clif_wis_message(fd, wisp_server_name,
- "Adding me in your ignore list will not block my wisps.",
- strlen("Adding me in your ignore list will not block my wisps.") + 1);
- }
- //Sort the ignore list.
- qsort (sd->ignore[0].name, MAX_IGNORE_LIST, sizeof(sd->ignore[0].name), pstrcmp);
- return;
- }
- //Remove name
- for(i = 0; i < MAX_IGNORE_LIST &&
- sd->ignore[i].name[0] != '\0' &&
- strcmp(sd->ignore[i].name, nick) != 0
- ; i++);
-
- if (i == MAX_IGNORE_LIST || sd->ignore[i].name[i] == '\0')
- { //Not found
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d1]);
- clif_wis_message(fd, wisp_server_name,
- "This player is not blocked by you.",
- strlen("This player is not blocked by you.") + 1);
- return;
- }
- //Move everything one place down to overwrite removed entry.
- memmove(sd->ignore[i].name, sd->ignore[i+1].name,
- (MAX_IGNORE_LIST-i-1)*sizeof(sd->ignore[0].name));
- malloc_tsetdword(sd->ignore[MAX_IGNORE_LIST-1].name, 0, sizeof(sd->ignore[0].name));
- // success
- WFIFOB(fd,3) = 0;
- WFIFOSET(fd, packet_len_table[0x0d1]);
-
-// for debug only
-// for(i = 0; i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0'; i++) /
-// ShowDebug("Ignored player: '%s'\n", sd->ignore[i].name);
- return;
-}
-
-void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
- //printf("Ignore all: state: %d\n", RFIFOB(fd,2));
- RFIFOHEAD(fd);
- WFIFOHEAD(fd,packet_len_table[0xd2]);
- // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
- // S 00d0 <type>len.B: 00 (/exall) deny all speech, 01 (/inall) allow all speech
- WFIFOW(fd,0) = 0x0d2;
- WFIFOB(fd,2) = RFIFOB(fd,2);
- if (RFIFOB(fd,2) == 0) { //Deny all
- if (sd->state.ignoreAll) {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d2]);
- clif_wis_message(fd, wisp_server_name,
- "You already block everyone.",
- strlen("You already block everyone.") + 1);
- return;
- }
- sd->state.ignoreAll = 1;
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d2]);
- return;
- }
- //Unblock everyone
- if (!sd->state.ignoreAll) {
- WFIFOB(fd,3) = 1; // fail
- WFIFOSET(fd, packet_len_table[0x0d2]);
- clif_wis_message(fd, wisp_server_name,
- "You already allow everyone.",
- strlen("You already allow everyone.") + 1);
- return;
- }
- sd->state.ignoreAll = 0;
- WFIFOB(fd,3) = 0; // success
- WFIFOSET(fd, packet_len_table[0x0d2]);
- return;
-}
-
-/*==========================================
- * Wis拒否リスト
- *------------------------------------------
- */
-void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
-{
- int i;
-
- WFIFOHEAD(fd, 4 + (NAME_LENGTH * MAX_IGNORE_LIST));
- WFIFOW(fd,0) = 0xd4;
-
- for(i = 0; i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0'; i++)
- memcpy(WFIFOP(fd, 4 + i * NAME_LENGTH),sd->ignore[i].name, NAME_LENGTH);
-
- WFIFOW(fd,2) = 4 + i * NAME_LENGTH;
- WFIFOSET(fd, WFIFOW(fd,2));
- return;
-}
-
-/*==========================================
- * スパノビの/doridoriによるSPR2倍
- *------------------------------------------
- */
-void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) {
- if (sd->state.doridori) return;
-
- switch (sd->class_&MAPID_UPPERMASK)
- {
- case MAPID_SOUL_LINKER:
- case MAPID_STAR_GLADIATOR:
- case MAPID_TAEKWON:
- if (!sd->state.rest)
- break;
- case MAPID_SUPER_NOVICE:
- sd->state.doridori=1;
- break;
- }
- return;
-}
-/*==========================================
- * スパノビの爆裂波動
- *------------------------------------------
- */
-void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
-{
- if(sd){
- int nextbaseexp=pc_nextbaseexp(sd);
- if (battle_config.etc_log){
- if(nextbaseexp != 0)
- ShowInfo("SuperNovice explosionspirits!! %d %d %d %d\n",sd->bl.id,sd->status.class_,sd->status.base_exp,(int)((double)1000*sd->status.base_exp/nextbaseexp));
- else
- ShowInfo("SuperNovice explosionspirits!! %d %d %d 000\n",sd->bl.id,sd->status.class_,sd->status.base_exp);
- }
- if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_exp > 0 && nextbaseexp > 0 && (int)((double)1000*sd->status.base_exp/nextbaseexp)%100==0){
- clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,5,
- sc_start(&sd->bl,SkillStatusChangeTable(MO_EXPLOSIONSPIRITS),100,
- 5,skill_get_time(MO_EXPLOSIONSPIRITS,5)));
- }
- }
- return;
-}
-
-// random notes:
-// 0x214: monster/player info ?
-
-/*==========================================
- * Friends List
- *------------------------------------------
- */
-void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online)
-{ //Toggles a single friend online/offline [Skotlex]
- int i, fd = sd->fd;
-
- //Seek friend.
- for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id &&
- (sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
-
- if(i == MAX_FRIENDS || sd->status.friends[i].char_id == 0)
- return; //Not found
-
- WFIFOHEAD(fd,packet_len_table[0x206]);
- WFIFOW(fd, 0) = 0x206;
- WFIFOL(fd, 2) = sd->status.friends[i].account_id;
- WFIFOL(fd, 6) = sd->status.friends[i].char_id;
- WFIFOB(fd,10) = !online; //Yeah, a 1 here means "logged off", go figure...
- WFIFOSET(fd, packet_len_table[0x206]);
-}
-
-//Subfunction called from clif_foreachclient to toggle friends on/off [Skotlex]
-int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap)
-{
- int account_id, char_id, online;
- account_id = va_arg(ap, int);
- char_id = va_arg(ap, int);
- online = va_arg(ap, int);
- clif_friendslist_toggle(sd, account_id, char_id, online);
- return 0;
-}
-
-//For sending the whole friends list.
-void clif_friendslist_send(struct map_session_data *sd) {
- int i = 0, n, fd = sd->fd;
-
- // Send friends list
- WFIFOHEAD(fd, MAX_FRIENDS * 32 + 4);
- WFIFOW(fd, 0) = 0x201;
- for(i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id; i++)
- {
- WFIFOL(fd, 4 + 32 * i + 0) = sd->status.friends[i].account_id;
- WFIFOL(fd, 4 + 32 * i + 4) = sd->status.friends[i].char_id;
- memcpy(WFIFOP(fd, 4 + 32 * i + 8), &sd->status.friends[i].name, NAME_LENGTH);
- }
-
- if (i) {
- WFIFOW(fd,2) = 4 + 32 * i;
- WFIFOSET(fd, WFIFOW(fd,2));
- }
-
- for (n = 0; n < i; n++)
- { //Sending the online players
- if (map_charid2sd(sd->status.friends[n].char_id))
- clif_friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1);
- }
-}
-
-
-// Status for adding friend - 0: successfull 1: not exist/rejected 2: over limit
-void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_data *f_sd, int type)
-{
- int fd;
- nullpo_retv(sd);
-
- fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x209]);
- WFIFOW(fd,0) = 0x209;
- WFIFOW(fd,2) = type;
- if (f_sd)
- {
- WFIFOW(fd,4) = f_sd->status.account_id;
- WFIFOW(fd,8) = f_sd->status.char_id;
- memcpy(WFIFOP(fd, 12), f_sd->status.name,NAME_LENGTH);
- }
- WFIFOSET(fd, packet_len_table[0x209]);
-}
-
-void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) {
- struct map_session_data *f_sd;
- int i, f_fd;
- RFIFOHEAD(fd);
-
- f_sd = map_nick2sd((char*)RFIFOP(fd,2));
-
- // Friend doesn't exist (no player with this name)
- if (f_sd == NULL) {
- clif_displaymessage(fd, msg_txt(3));
- return;
- }
-
- // @noask [LuzZza]
- if(f_sd->state.noask) {
- clif_noask_sub(sd, f_sd, 5);
- return;
- }
-
- // Friend already exists
- for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id != 0; i++) {
- if (sd->status.friends[i].char_id == f_sd->status.char_id) {
- clif_displaymessage(fd, "Friend already exists.");
- return;
- }
- }
-
- if (i == MAX_FRIENDS) {
- //No space, list full.
- clif_friendslist_reqack(sd, f_sd, 2);
- return;
- }
-
- f_fd = f_sd->fd;
- WFIFOHEAD(f_fd,packet_len_table[0x207]);
- WFIFOW(f_fd,0) = 0x207;
- WFIFOL(f_fd,2) = sd->status.account_id;
- WFIFOL(f_fd,6) = sd->status.char_id;
- memcpy(WFIFOP(f_fd,10), sd->status.name, NAME_LENGTH);
- WFIFOSET(f_fd, packet_len_table[0x207]);
-
- return;
-}
-
-void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) {
- //<W: id> <L: Player 1 chara ID> <L: Player 1 AID> <B: Response>
- struct map_session_data *f_sd;
- int char_id, account_id;
- char reply;
- RFIFOHEAD(fd);
-
- account_id = RFIFOL(fd,2);
- char_id = RFIFOL(fd,6);
- reply = RFIFOB(fd,10);
- //printf ("reply: %d %d %d\n", char_id, id, reply);
-
- f_sd = map_id2sd(account_id); //The account id is the same as the bl.id of players.
- if (f_sd == NULL)
- return;
-
- if (reply == 0)
- clif_friendslist_reqack(f_sd, sd, 1);
- else {
- int i;
- // Find an empty slot
- for (i = 0; i < MAX_FRIENDS; i++)
- if (f_sd->status.friends[i].char_id == 0)
- break;
- if (i == MAX_FRIENDS) {
- clif_friendslist_reqack(f_sd, sd, 2);
- return;
- }
-
- f_sd->status.friends[i].account_id = sd->status.account_id;
- f_sd->status.friends[i].char_id = sd->status.char_id;
- memcpy(f_sd->status.friends[i].name, sd->status.name, NAME_LENGTH);
- clif_friendslist_reqack(f_sd, sd, 0);
-
- if (battle_config.friend_auto_add) {
- // Also add f_sd to sd's friendlist.
- for (i = 0; i < MAX_FRIENDS; i++) {
- if (sd->status.friends[i].char_id == f_sd->status.char_id)
- return; //No need to add anything.
- if (sd->status.friends[i].char_id == 0)
- break;
- }
- if (i == MAX_FRIENDS) {
- clif_friendslist_reqack(sd, f_sd, 2);
- return;
- }
-
- sd->status.friends[i].account_id = f_sd->status.account_id;
- sd->status.friends[i].char_id = f_sd->status.char_id;
- memcpy(sd->status.friends[i].name, f_sd->status.name, NAME_LENGTH);
- clif_friendslist_reqack(sd, f_sd, 0);
- }
- }
-
- return;
-}
-
-void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) {
- // 0x203 </o> <ID to be removed W 4B>
- int account_id, char_id;
- int i, j;
- RFIFOHEAD(fd);
-
- account_id = RFIFOL(fd,2);
- char_id = RFIFOL(fd,6);
-
- // Search friend
- for (i = 0; i < MAX_FRIENDS &&
- (sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
-
- if (i == MAX_FRIENDS) {
- clif_displaymessage(fd, "Name not found in list.");
- return;
- }
-
- // move all chars down
- for(j = i + 1; j < MAX_FRIENDS; j++)
- memcpy(&sd->status.friends[j-1], &sd->status.friends[j], sizeof(sd->status.friends[0]));
-
- malloc_set(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
- clif_displaymessage(fd, "Friend removed");
-
- WFIFOHEAD(fd,packet_len_table[0x20a]);
- WFIFOW(fd,0) = 0x20a;
- WFIFOL(fd,2) = account_id;
- WFIFOL(fd,6) = char_id;
- WFIFOSET(fd, packet_len_table[0x20a]);
-// clif_friendslist_send(sd); //This is not needed anymore.
-
- return;
-}
-
-/*==========================================
- * /killall
- *------------------------------------------
- */
-void clif_parse_GMKillAll(int fd,struct map_session_data *sd)
-{
- char message[50];
-
- strncpy(message,sd->status.name, NAME_LENGTH);
- is_atcommand(fd, sd, strcat(message," : @kickall"));
-
- return;
-}
-
-/*==========================================
- * /pvpinfo
- *------------------------------------------
- */
-void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
-{
- WFIFOHEAD(fd,packet_len_table[0x210]);
- WFIFOW(fd,0) = 0x210;
- //WFIFOL(fd,2) = 0; // not sure what for yet
- //WFIFOL(fd,6) = 0;
- WFIFOL(fd,10) = sd->pvp_won; // times won
- WFIFOL(fd,14) = sd->pvp_lost; // times lost
- WFIFOL(fd,18) = sd->pvp_point;
- WFIFOSET(fd, packet_len_table[0x210]);
-
- return;
-}
-
-/*==========================================
- * /blacksmith
- *------------------------------------------
- */
-void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
-{
- int i;
- char *name;
-
- WFIFOHEAD(fd,packet_len_table[0x219]);
- WFIFOW(fd,0) = 0x219;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (smith_fame_list[i].id > 0) {
- if (strcmp(smith_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(smith_fame_list[i].id)) != NULL)
- {
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), name, NAME_LENGTH);
- } else
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), smith_fame_list[i].name, NAME_LENGTH);
- } else
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "None", 5);
- WFIFOL(fd, 242 + i * 4) = smith_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "Unavailable", 12);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
-
- WFIFOSET(fd, packet_len_table[0x219]);
-}
-
-int clif_fame_blacksmith(struct map_session_data *sd, int points)
-{
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x21b]);
- WFIFOW(fd,0) = 0x21b;
- WFIFOL(fd,2) = points;
- WFIFOL(fd,6) = sd->status.fame;
- WFIFOSET(fd, packet_len_table[0x21b]);
-
- return 0;
-}
-
-/*==========================================
- * /alchemist
- *------------------------------------------
- */
-void clif_parse_Alchemist(int fd,struct map_session_data *sd)
-{
- int i;
- char *name;
-
- WFIFOHEAD(fd,packet_len_table[0x21a]);
- WFIFOW(fd,0) = 0x21a;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (chemist_fame_list[i].id > 0) {
- if (strcmp(chemist_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(chemist_fame_list[i].id)) != NULL)
- {
- memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), chemist_fame_list[i].name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = chemist_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
-
- WFIFOSET(fd, packet_len_table[0x21a]);
-}
-
-int clif_fame_alchemist(struct map_session_data *sd, int points)
-{
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x21c]);
- WFIFOW(fd,0) = 0x21c;
- WFIFOL(fd,2) = points;
- WFIFOL(fd,6) = sd->status.fame;
- WFIFOSET(fd, packet_len_table[0x21c]);
-
- return 0;
-}
-
-/*==========================================
- * /taekwon
- *------------------------------------------
- */
-void clif_parse_Taekwon(int fd,struct map_session_data *sd)
-{
- int i;
- char *name;
-
- WFIFOHEAD(fd,packet_len_table[0x226]);
- WFIFOW(fd,0) = 0x226;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (taekwon_fame_list[i].id > 0) {
- if (strcmp(taekwon_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(taekwon_fame_list[i].id)) != NULL)
- {
- memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), taekwon_fame_list[i].name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = taekwon_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
- WFIFOSET(fd, packet_len_table[0x226]);
-}
-
-int clif_fame_taekwon(struct map_session_data *sd, int points)
-{
- int fd = sd->fd;
- WFIFOHEAD(fd,packet_len_table[0x224]);
- WFIFOW(fd,0) = 0x224;
- WFIFOL(fd,2) = points;
- WFIFOL(fd,6) = sd->status.fame;
- WFIFOSET(fd, packet_len_table[0x224]);
-
- return 0;
-}
-
-/*==========================================
- * PK Ranking table?
- *------------------------------------------
- */
-void clif_parse_RankingPk(int fd,struct map_session_data *sd)
-{
- int i;
-
- WFIFOHEAD(fd,packet_len_table[0x238]);
- WFIFOW(fd,0) = 0x238;
- for(i=0;i<10;i++){
- memcpy(WFIFOP(fd,i*24+2), "Unknown", NAME_LENGTH);
- WFIFOL(fd,i*4+242) = 0;
- }
- WFIFOSET(fd, packet_len_table[0x238]);
- return;
-}
-
-/*==========================================
- * SG Feel save OK [Komurka]
- *------------------------------------------
- */
-void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
-{
- char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"};
- int i;
- if (sd->menuskill_id != SG_FEEL)
- return;
- i = sd->menuskill_lv-1;
- if (i<0 || i > 2) return; //Bug?
-
- sd->feel_map[i].index = map[sd->bl.m].index;
- sd->feel_map[i].m = sd->bl.m;
- pc_setglobalreg(sd,feel_var[i],map[sd->bl.m].index);
-
-//Are these really needed? Shouldn't they show up automatically from the feel save packet?
-// clif_misceffect2(&sd->bl, 0x1b0);
-// clif_misceffect2(&sd->bl, 0x21f);
- clif_feel_info(sd, i, 0);
- sd->menuskill_lv = sd->menuskill_id = 0;
-}
-
-/*==========================================
- * Question about Star Glaldiator save map [Komurka]
- *------------------------------------------
- */
-void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv) {
- WFIFOHEAD(fd,packet_len_table[0x253]);
- WFIFOW(fd,0)=0x253;
- WFIFOSET(fd, packet_len_table[0x253]);
- sd->menuskill_id=SG_FEEL;
- sd->menuskill_lv=skilllv;
-}
-
-void clif_parse_AdoptRequest(int fd,struct map_session_data *sd) {
- //TODO: add somewhere the adopt code, checks for exploits, etc, etc.
- //Missing packets are the client's reply packets to the adopt request one.
- //[Skotlex]
- int account_id;
- struct map_session_data *sd2;
- RFIFOHEAD(fd);
-
- account_id = RFIFOL(fd,2);
- sd2 = map_id2sd(account_id);
- if(sd2 && sd2->fd && sd2 != sd && sd2->status.party_id == sd->status.party_id) { //FIXME: No checks whatsoever are in place yet!
- fd = sd2->fd;
- WFIFOHEAD(fd,packet_len_table[0x1f9]);
- WFIFOW(fd,0)=0x1f9;
- WFIFOSET(fd, packet_len_table[0x1f9]);
- }
-}
-/*==========================================
- * パケットデバッグ
- *------------------------------------------
- */
-void clif_parse_debug(int fd,struct map_session_data *sd)
-{
- int i, cmd, len;
- RFIFOHEAD(fd);
-
- cmd = RFIFOW(fd,0);
- len = sd?packet_db[sd->packet_ver][cmd].len:RFIFOREST(fd); //With no session, just read the remaining in the buffer.
- ShowDebug("packet debug 0x%4X\n",cmd);
- printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i=0;i<len;i++){
- if((i&15)==0)
- printf("\n%04X ",i);
- printf("%02X ",RFIFOB(fd,i));
- }
- printf("\n");
-}
-
-/*==========================================
- * クライアントからのパケット解析
- * socket.cのdo_parsepacketから呼び出される
- *------------------------------------------
- */
-int clif_parse(int fd) {
- int packet_len = 0, cmd, packet_ver, dump = 0;
- struct map_session_data *sd;
- RFIFOHEAD(fd);
-
- if (fd <= 0)
- { //Just in case, there are some checks for this later down below anyway which should be removed. [Skotlex]
- ShowError("clif_parse: Received invalid session %d\n", fd);
- return 0;
- }
-
- sd = (struct map_session_data*)session[fd]->session_data;
-
- if (sd && sd->fd != fd)
- { //FIXME: Temporal debug until a certain mysterious crash is fixed.
- ShowError("Player's connection value is incorrect! %d != %d\n", sd->fd, fd);
- sd->fd = fd;
- }
-
- if (session[fd]->eof) {
- if (sd) {
- if (sd->state.autotrade) {
- //Disassociate character from the socket connection.
- session[fd]->session_data = NULL;
- sd->fd = 0;
- ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n",
- (pc_isGM(sd))?"GM ":"",sd->status.name);
- } else
- if (sd->state.auth) {
- // Player logout display [Valaris]
- ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n",
- (pc_isGM(sd))?"GM ":"",sd->status.name);
- clif_quitsave(fd, sd);
- } else {
- ShowInfo("Player AID:%d/CID:%d (not authenticated) logged off.\n",
- sd->bl.id, sd->status.char_id);
- map_quit(sd);
- }
- } else {
- unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
- ShowInfo("Closed connection from '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip[0],ip[1],ip[2],ip[3]);
- }
- do_close(fd);
- return 0;
- }
-
- if (RFIFOREST(fd) < 2)
- return 0;
-
-// printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
-
- cmd = RFIFOW(fd,0);
-
- // 管理用パケット処理
- if (cmd >= 30000) {
- switch(cmd) {
- case 0x7530: { //Why are we letting people know which version we are running?
- WFIFOHEAD(fd, 10);
- WFIFOW(fd,0) = 0x7531;
- WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
- WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
- WFIFOB(fd,4) = ATHENA_REVISION;
- WFIFOB(fd,5) = ATHENA_RELEASE_FLAG;
- WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG;
- WFIFOB(fd,7) = ATHENA_SERVER_MAP;
- WFIFOW(fd,8) = ATHENA_MOD_VERSION;
- WFIFOSET(fd,10);
- RFIFOSKIP(fd,2);
- break;
- }
- case 0x7532: // 接続の切断
- ShowWarning("clif_parse: session #%d disconnected for sending packet 0x04%x\n", fd, cmd);
- session[fd]->eof=1;
- break;
- default:
- ShowWarning("Unknown incoming packet (command: 0x%04x, session: %d), disconnecting.\n", cmd, fd);
- session[fd]->eof=1;
- break;
- }
- return 0;
- }
-
- // get packet version before to parse
- packet_ver = 0;
- if (sd) {
- packet_ver = sd->packet_ver;
- if (packet_ver < 0 || packet_ver > MAX_PACKET_VER) { // This should never happen unless we have some corrupted memory issues :X [Skotlex]
- session[fd]->eof = 1;
- return 0;
- }
- } else {
- // check authentification packet to know packet version
- packet_ver = clif_guess_PacketVer(fd, 0);
- // check if version is accepted
- if (packet_ver < 5 || // reject really old client versions
- (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
- (packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0) ||
- packet_ver > MAX_PACKET_VER) // no packet version support yet
- {
- ShowInfo("clif_parse: Disconnecting session #%d for not having latest client version (has version %d).\n", fd, packet_ver);
- WFIFOHEAD(fd, 23);
- WFIFOW(fd,0) = 0x6a;
- WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version
- WFIFOSET(fd,23);
- packet_len = RFIFOREST(fd);
- RFIFOSKIP(fd, packet_len);
- clif_setwaitclose(fd);
- if (session[fd]->func_send) //socket.c doesn't wants to send the data when left on it's own... [Skotlex]
- session[fd]->func_send(fd);
- return 0;
- }
- }
-
- // ゲーム用以外パケットか、認証を終える前に0072以外が来たら、切断する
- if (cmd >= MAX_PACKET_DB || packet_db[packet_ver][cmd].len == 0) { // if packet is not inside these values: session is incorrect?? or auth packet is unknown
- ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd);
- session[fd]->eof = 1;
- return 0;
- }
-
- // パケット長を計算
- packet_len = packet_db[packet_ver][cmd].len;
- if (packet_len == -1) {
- if (RFIFOREST(fd) < 4)
- return 0; // 可変長パケットで長さの所までデータが来てない
-
- packet_len = RFIFOW(fd,2);
- if (packet_len < 4 || packet_len > 32768) {
- ShowWarning("clif_parse: Packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", cmd, packet_len, fd);
- session[fd]->eof =1;
- return 0;
- }
- }
- if ((int)RFIFOREST(fd) < packet_len)
- return 0; // まだ1パケット分データが揃ってない
-
-#if DUMP_ALL_PACKETS
- {
- int i;
- FILE *fp;
- char packet_txt[256] = "save/packet.txt";
- time_t now;
- dump = 1;
-
- if ((fp = fopen(packet_txt, "a")) == NULL) {
- ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
- return 1;
- } else {
- time(&now);
- if (sd && sd->state.auth) {
- if (sd->status.name != NULL)
- fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent packet:\n",
- asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
- else
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
- } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
-
- fprintf(fp, "\tsession #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
- fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i = 0; i < packet_len; i++) {
- if ((i & 15) == 0)
- fprintf(fp, "\n\t%04X ", i);
- fprintf(fp, "%02X ", RFIFOB(fd,i));
- }
- fprintf(fp, "\n\n");
- fclose(fp);
- }
- }
-#endif
-
- if (sd && sd->state.waitingdisconnect == 1) {
- // 切断待ちの場合パケットを処理しない
- } else if (packet_db[packet_ver][cmd].func) {
- if (sd && sd->bl.prev == NULL &&
- packet_db[packet_ver][cmd].func != clif_parse_LoadEndAck)
- ; //Only valid packet when player is not on a map is the finish-loading packet.
- else
- if (sd
- || packet_db[packet_ver][cmd].func == clif_parse_WantToConnection
- || packet_db[packet_ver][cmd].func == clif_parse_debug
- ) //Only execute the function when there's an sd (except for debug/wanttoconnect packets)
- packet_db[packet_ver][cmd].func(fd, sd);
- }
-#if DUMP_UNKNOWN_PACKET
- else if (battle_config.error_log)
- {
- int i;
- FILE *fp;
- char packet_txt[256] = "save/packet.txt";
- time_t now;
- dump = 1;
-
- if ((fp = fopen(packet_txt, "a")) == NULL) {
- ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
- return 1;
- } else {
- time(&now);
- if (sd && sd->state.auth) {
- fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
- asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
- } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
- fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
-
- fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i = 0; i < packet_len; i++) {
- if ((i & 15) == 0)
- fprintf(fp, "\n\t%04X ", i);
- fprintf(fp, "%02X ", RFIFOB(fd,i));
- }
- fprintf(fp, "\n\n");
- fclose(fp);
- }
- }
-#endif
-
- if (dump) {
- int i;
- if (fd)
- ShowDebug("\nclif_parse: session #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
- printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
- for(i = 0; i < packet_len; i++) {
- if ((i & 15) == 0)
- printf("\n%04X ",i);
- printf("%02X ", RFIFOB(fd,i));
- }
- printf("\n");
- if (sd && sd->state.auth) {
- if (sd->status.name != NULL)
- printf("\nAccount ID %d, character ID %d, player name %s.\n",
- sd->status.account_id, sd->status.char_id, sd->status.name);
- else
- printf("\nAccount ID %d.\n", sd->bl.id);
- } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
- printf("\nAccount ID %d.\n", sd->bl.id);
- }
-
- RFIFOSKIP(fd, packet_len);
-
- return 0;
-}
-
-/*==========================================
- * パケットデータベース読み込み
- *------------------------------------------
- */
-static int packetdb_readdb(void)
-{
- FILE *fp;
- char line[1024];
- int ln=0;
- int cmd,i,j,k,packet_ver;
- char *str[64],*p,*str2[64],*p2,w1[64],w2[64];
-
- struct {
- void (*func)(int, struct map_session_data *);
- char *name;
- } clif_parse_func[]={
- {clif_parse_WantToConnection,"wanttoconnection"},
- {clif_parse_LoadEndAck,"loadendack"},
- {clif_parse_TickSend,"ticksend"},
- {clif_parse_WalkToXY,"walktoxy"},
- {clif_parse_QuitGame,"quitgame"},
- {clif_parse_GetCharNameRequest,"getcharnamerequest"},
- {clif_parse_GlobalMessage,"globalmessage"},
- {clif_parse_MapMove,"mapmove"},
- {clif_parse_ChangeDir,"changedir"},
- {clif_parse_Emotion,"emotion"},
- {clif_parse_HowManyConnections,"howmanyconnections"},
- {clif_parse_ActionRequest,"actionrequest"},
- {clif_parse_Restart,"restart"},
- {clif_parse_Wis,"wis"},
- {clif_parse_GMmessage,"gmmessage"},
- {clif_parse_TakeItem,"takeitem"},
- {clif_parse_DropItem,"dropitem"},
- {clif_parse_UseItem,"useitem"},
- {clif_parse_EquipItem,"equipitem"},
- {clif_parse_UnequipItem,"unequipitem"},
- {clif_parse_NpcClicked,"npcclicked"},
- {clif_parse_NpcBuySellSelected,"npcbuysellselected"},
- {clif_parse_NpcBuyListSend,"npcbuylistsend"},
- {clif_parse_NpcSellListSend,"npcselllistsend"},
- {clif_parse_CreateChatRoom,"createchatroom"},
- {clif_parse_ChatAddMember,"chataddmember"},
- {clif_parse_ChatRoomStatusChange,"chatroomstatuschange"},
- {clif_parse_ChangeChatOwner,"changechatowner"},
- {clif_parse_KickFromChat,"kickfromchat"},
- {clif_parse_ChatLeave,"chatleave"},
- {clif_parse_TradeRequest,"traderequest"},
- {clif_parse_TradeAck,"tradeack"},
- {clif_parse_TradeAddItem,"tradeadditem"},
- {clif_parse_TradeOk,"tradeok"},
- {clif_parse_TradeCancel,"tradecancel"},
- {clif_parse_TradeCommit,"tradecommit"},
- {clif_parse_StopAttack,"stopattack"},
- {clif_parse_PutItemToCart,"putitemtocart"},
- {clif_parse_GetItemFromCart,"getitemfromcart"},
- {clif_parse_RemoveOption,"removeoption"},
- {clif_parse_ChangeCart,"changecart"},
- {clif_parse_StatusUp,"statusup"},
- {clif_parse_SkillUp,"skillup"},
- {clif_parse_UseSkillToId,"useskilltoid"},
- {clif_parse_UseSkillToPos,"useskilltopos"},
- {clif_parse_UseSkillToPosMoreInfo,"useskilltoposinfo"},
- {clif_parse_UseSkillMap,"useskillmap"},
- {clif_parse_RequestMemo,"requestmemo"},
- {clif_parse_ProduceMix,"producemix"},
- {clif_parse_NpcSelectMenu,"npcselectmenu"},
- {clif_parse_NpcNextClicked,"npcnextclicked"},
- {clif_parse_NpcAmountInput,"npcamountinput"},
- {clif_parse_NpcStringInput,"npcstringinput"},
- {clif_parse_NpcCloseClicked,"npccloseclicked"},
- {clif_parse_ItemIdentify,"itemidentify"},
- {clif_parse_SelectArrow,"selectarrow"},
- {clif_parse_AutoSpell,"autospell"},
- {clif_parse_UseCard,"usecard"},
- {clif_parse_InsertCard,"insertcard"},
- {clif_parse_RepairItem,"repairitem"},
- {clif_parse_WeaponRefine,"weaponrefine"},
- {clif_parse_SolveCharName,"solvecharname"},
- {clif_parse_ResetChar,"resetchar"},
- {clif_parse_LGMmessage,"lgmmessage"},
- {clif_parse_MoveToKafra,"movetokafra"},
- {clif_parse_MoveFromKafra,"movefromkafra"},
- {clif_parse_MoveToKafraFromCart,"movetokafrafromcart"},
- {clif_parse_MoveFromKafraToCart,"movefromkafratocart"},
- {clif_parse_CloseKafra,"closekafra"},
- {clif_parse_CreateParty,"createparty"},
- {clif_parse_CreateParty2,"createparty2"},
- {clif_parse_PartyInvite,"partyinvite"},
- {clif_parse_ReplyPartyInvite,"replypartyinvite"},
- {clif_parse_LeaveParty,"leaveparty"},
- {clif_parse_RemovePartyMember,"removepartymember"},
- {clif_parse_PartyChangeOption,"partychangeoption"},
- {clif_parse_PartyMessage,"partymessage"},
- {clif_parse_CloseVending,"closevending"},
- {clif_parse_VendingListReq,"vendinglistreq"},
- {clif_parse_PurchaseReq,"purchasereq"},
- {clif_parse_OpenVending,"openvending"},
- {clif_parse_CreateGuild,"createguild"},
- {clif_parse_GuildCheckMaster,"guildcheckmaster"},
- {clif_parse_GuildRequestInfo,"guildrequestinfo"},
- {clif_parse_GuildChangePositionInfo,"guildchangepositioninfo"},
- {clif_parse_GuildChangeMemberPosition,"guildchangememberposition"},
- {clif_parse_GuildRequestEmblem,"guildrequestemblem"},
- {clif_parse_GuildChangeEmblem,"guildchangeemblem"},
- {clif_parse_GuildChangeNotice,"guildchangenotice"},
- {clif_parse_GuildInvite,"guildinvite"},
- {clif_parse_GuildReplyInvite,"guildreplyinvite"},
- {clif_parse_GuildLeave,"guildleave"},
- {clif_parse_GuildExpulsion,"guildexplusion"},
- {clif_parse_GuildMessage,"guildmessage"},
- {clif_parse_GuildRequestAlliance,"guildrequestalliance"},
- {clif_parse_GuildReplyAlliance,"guildreplyalliance"},
- {clif_parse_GuildDelAlliance,"guilddelalliance"},
- {clif_parse_GuildOpposition,"guildopposition"},
- {clif_parse_GuildBreak,"guildbreak"},
- {clif_parse_PetMenu,"petmenu"},
- {clif_parse_CatchPet,"catchpet"},
- {clif_parse_SelectEgg,"selectegg"},
- {clif_parse_SendEmotion,"sendemotion"},
- {clif_parse_ChangePetName,"changepetname"},
- {clif_parse_GMKick,"gmkick"},
- {clif_parse_GMHide,"gmhide"},
- {clif_parse_GMReqNoChat,"gmreqnochat"},
- {clif_parse_GMReqNoChatCount,"gmreqnochatcount"},
- {clif_parse_NoviceDoriDori,"sndoridori"},
- {clif_parse_NoviceExplosionSpirits,"snexplosionspirits"},
- {clif_parse_PMIgnore,"wisexin"},
- {clif_parse_PMIgnoreList,"wisexlist"},
- {clif_parse_PMIgnoreAll,"wisall"},
- {clif_parse_FriendsListAdd,"friendslistadd"},
- {clif_parse_FriendsListRemove,"friendslistremove"},
- {clif_parse_FriendsListReply,"friendslistreply"},
- {clif_parse_GMKillAll,"killall"},
- {clif_parse_Recall,"summon"},
- {clif_parse_GM_Monster_Item,"itemmonster"},
- {clif_parse_Shift,"shift"},
- {clif_parse_Blacksmith,"blacksmith"},
- {clif_parse_Alchemist,"alchemist"},
- {clif_parse_Taekwon,"taekwon"},
- {clif_parse_RankingPk,"rankingpk"},
- {clif_parse_FeelSaveOk,"feelsaveok"},
- {clif_parse_AdoptRequest,"adopt"},
- {clif_parse_debug,"debug"},
- //[blackhole89] //[orn]
- {clif_parse_ChangeHomunculusName,"changehomunculusname"},
- {clif_parse_HomMoveToMaster,"hommovetomaster"},
- {clif_parse_HomMoveTo,"hommoveto"},
- {clif_parse_HomAttack,"homattack"},
- {clif_parse_HomMenu,"hommenu"},
- {NULL,NULL}
- };
-
- sprintf(line, "%s/packet_db.txt", db_path);
- if( (fp=fopen(line,"r"))==NULL ){
- ShowFatalError("can't read %s\n", line);
- exit(1);
- }
-
- clif_config.packet_db_ver = MAX_PACKET_VER;
- packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
- while(fgets(line,1020,fp)){
- if(line[0]=='/' && line[1]=='/')
- continue;
- if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) {
- if(strcmpi(w1,"packet_ver")==0) {
- int prev_ver = packet_ver;
- packet_ver = atoi(w2);
- if (packet_ver > MAX_PACKET_VER)
- { //Check to avoid overflowing. [Skotlex]
- ShowWarning("The packet_db table only has support up to version %d\n", MAX_PACKET_VER);
- break;
- }
- // copy from previous version into new version and continue
- // - indicating all following packets should be read into the newer version
- memcpy(&packet_db[packet_ver], &packet_db[prev_ver], sizeof(packet_db[0]));
- continue;
- } else if(strcmpi(w1,"packet_db_ver")==0) {
- //This is the preferred version.
- if(strcmpi(w2,"default")==0)
- clif_config.packet_db_ver = MAX_PACKET_VER;
- else {
- // to manually set the packet DB version
- clif_config.packet_db_ver = atoi(w2);
- // check for invalid version
- if (clif_config.packet_db_ver > MAX_PACKET_VER ||
- clif_config.packet_db_ver < 0)
- clif_config.packet_db_ver = MAX_PACKET_VER;
- }
- continue;
- }
- }
-
- malloc_tsetdword(str,0,sizeof(str));
- for(j=0,p=line;j<4 && p;j++){
- str[j]=p;
- p=strchr(p,',');
- if(p) *p++=0;
- }
- if(str[0]==NULL)
- continue;
- cmd=strtol(str[0],(char **)NULL,0);
- if(cmd<=0 || cmd>=MAX_PACKET_DB)
- continue;
- if(str[1]==NULL){
- ShowError("packet_db: packet len error\n");
- continue;
- }
- k = atoi(str[1]);
- packet_db[packet_ver][cmd].len = k;
-
- if(str[2]==NULL){
- packet_db[packet_ver][cmd].func = NULL;
- ln++;
- continue;
- }
- for(j=0;j<sizeof(clif_parse_func)/sizeof(clif_parse_func[0]);j++){
- if(clif_parse_func[j].name != NULL &&
- strcmp(str[2],clif_parse_func[j].name)==0)
- {
- if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func)
- { //If we are updating a function, we need to zero up the previous one. [Skotlex]
- for(i=0;i<MAX_PACKET_DB;i++){
- if (packet_db[packet_ver][i].func == clif_parse_func[j].func)
- {
- malloc_tsetword(&packet_db[packet_ver][i], 0, sizeof(struct packet_db));
- break;
- }
- }
- }
- packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
- break;
- }
- }
- // set the identifying cmd for the packet_db version
- if (strcmp(str[2],"wanttoconnection")==0)
- clif_config.connect_cmd[packet_ver] = cmd;
-
- if(str[3]==NULL){
- ShowError("packet_db: packet error\n");
- exit(1);
- }
- for(j=0,p2=str[3];p2;j++){
- str2[j]=p2;
- p2=strchr(p2,':');
- if(p2) *p2++=0;
- k = atoi(str2[j]);
- // if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db) // not used for now
- packet_db[packet_ver][cmd].pos[j] = k;
- }
-
- ln++;
-// if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */)
-// printf("packet_db ver %d: %d 0x%x %d %s %p\n",packet_ver,ln,cmd,packet_db[packet_ver][cmd].len,str[2],packet_db[packet_ver][cmd].func);
- }
- fclose(fp);
- if (!clif_config.connect_cmd[clif_config.packet_db_ver])
- { //Locate the nearest version that we still support. [Skotlex]
- for(j = clif_config.packet_db_ver; j >= 0 && !clif_config.connect_cmd[j]; j--);
-
- clif_config.packet_db_ver = j?j:MAX_PACKET_VER;
- }
- ShowStatus("Done reading packet database from '"CL_WHITE"%s"CL_RESET"'. Using default packet version: "CL_WHITE"%d"CL_RESET".\n", "packet_db.txt", clif_config.packet_db_ver);
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------
- */
-int do_init_clif(void) {
-
- clif_config.packet_db_ver = -1; // the main packet version of the DB
- malloc_tsetdword(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
-
- malloc_tsetword(packet_db,0,sizeof(packet_db));
- //Using the packet_db file is the only way to set up packets now [Skotlex]
- packetdb_readdb();
-
- set_defaultparse(clif_parse);
- if (!make_listen_bind(bind_ip,map_port)) {
- ShowFatalError("cant bind game port\n");
- exit(1);
- }
-
- add_timer_func_list(clif_waitclose, "clif_waitclose");
- add_timer_func_list(clif_clearchar_delay_sub, "clif_clearchar_delay_sub");
- add_timer_func_list(clif_delayquit, "clif_delayquit");
- add_timer_func_list(clif_nighttimer, "clif_nighttimer");
- add_timer_func_list(clif_walktoxy_timer, "clif_walktoxy_timer");
- return 0;
-}
-
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#define DUMP_UNKNOWN_PACKET 0
+#define DUMP_ALL_PACKETS 0
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <time.h>
+
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/malloc.h"
+#include "../common/version.h"
+#include "../common/nullpo.h"
+#include "../common/showmsg.h"
+
+#include "map.h"
+#include "chrif.h"
+#include "clif.h"
+#include "pc.h"
+#include "status.h"
+#include "npc.h"
+#include "itemdb.h"
+#include "chat.h"
+#include "trade.h"
+#include "storage.h"
+#include "script.h"
+#include "skill.h"
+#include "atcommand.h"
+#include "charcommand.h"
+#include "intif.h"
+#include "battle.h"
+#include "mob.h"
+#include "party.h"
+#include "unit.h"
+#include "guild.h"
+#include "vending.h"
+#include "pet.h"
+#include "mercenary.h" //[orn]
+#include "log.h"
+
+#include "irc.h"
+
+struct Clif_Config {
+ int packet_db_ver; //Preferred packet version.
+ int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex]
+} clif_config;
+
+struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
+
+static const int packet_len_table[MAX_PACKET_DB] = {
+ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+//#0x0040
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 55, 17, 3, 37, 46, -1, 23, -1, 3,108, 3, 2,
+#if PACKETVER < 2
+ 3, 28, 19, 11, 3, -1, 9, 5, 52, 51, 56, 58, 41, 2, 6, 6,
+#else // 78-7b 亀島以降 lv99エフェクト用
+ 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6,
+#endif
+//#0x0080
+ 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 2, -1, -1, -1, 0, // 0x8b changed to 2 (was 23)
+ 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6,
+ 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6,
+ 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3,
+//#0x00C0
+ 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 3, 2, 27, // 0xcd change to 3 (was 6)
+ 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1,
+ 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2,
+ 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10,
+
+//#0x0100
+ 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1,
+ 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16,
+ 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1,
+ 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26,
+//#0x0140
+ 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6,
+ 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42,
+ -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14,186,182,
+ 14, 30, 10, 3, -1, 6,106, -1, 4, 5, 4, -1, 6, 7, -1, -1,
+//#0x0180
+ 6, 3,106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6,
+#if PACKETVER < 1
+ 90, 86, 24, 6, 30,102, 8, 4, 8, 4, 14, 10, -1, 6, 2, 6,
+#else // 196 comodo以降 状態表示アイコン用
+ 90, 86, 24, 6, 30,102, 9, 4, 8, 4, 14, 10, -1, 6, 2, 6,
+#endif
+ 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4,
+ 11, 7, -1, 67, 12, 18,114, 6, 3, 6, 26, 26, 26, 26, 2, 3,
+//#0x01C0, Set 0x1d5=-1
+ 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 3, 9, 9, 30, 6, 28,
+ 8, 14, 10, 35, 6, -1, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6,
+ 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1,
+ -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
+//#0x200
+ 26, -1, 26, 10, 18, 26, 11, 34, 14, 36, 10, 0, 0, -1, 32, 10, // 0x20c change to 0 (was 19)
+ 22, 0, 26, 26, 42, 6, 6, 2, 2,282,282,10, 10, -1, -1, 66,
+ 10, -1, -1, 8, 10, 2,282, 18, 18, 15, 58, 57, 64, 5, 71, 5,
+ 12, 26, 9, 11, -1, -1, 10, 2, 282, 11, 4, 36, -1,-1, 4, 2,
+ -1, -1, -1, -1, -1, 3, 4, 8, -1, 3, 70, 4, 8,12, 4, 10,
+ 3, 32, -1, 3, 3, 5, 5, 8, 2, 3, -1, -1, 4,-1, 4
+};
+
+//Converts item type in case of pet eggs.
+#define itemtype(a) (a == 7)?4:a
+
+#define WBUFPOS(p,pos,x,y,dir) { unsigned char *__p = (p); __p+=(pos); __p[0] = (x)>>2; __p[1] = ((x)<<6) | (((y)>>4)&0x3f); __p[2] = ((y)<<4)|((dir)&0xf); }
+#define WBUFPOS2(p,pos,x0,y0,x1,y1) { unsigned char *__p = (p); __p+=(pos); __p[0] = (unsigned char)((x0)>>2); __p[1] = (unsigned char)(((x0)<<6) | (((y0)>>4)&0x3f)); __p[2] = (unsigned char)(((y0)<<4) | (((x1)>>6)&0x0f)); __p[3]=(unsigned char)(((x1)<<2) | (((y1)>>8)&0x03)); __p[4]=(unsigned char)(y1); }
+
+#define WFIFOPOS(fd,pos,x,y,dir) { WBUFPOS (WFIFOP(fd,pos),0,x,y,dir); }
+#define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); }
+
+//To make the assignation of the level based on limits clearer/easier. [Skotlex]
+#define clif_setlevel(lv) (lv<battle_config.max_lv?lv:battle_config.max_lv-(lv<battle_config.aura_lv?1:0));
+
+//Removed sd->npc_shopid because there is no packet sent from the client when you cancel a buy!
+//Quick check to know if the player shouldn't be "busy" with something else to deny action requests. [Skotlex]
+#define clif_cant_act(sd) (sd->npc_id || sd->vender_id || sd->chatID || sd->sc.opt1 || sd->state.trading || sd->state.storage_flag)
+
+// Checks if SD is in a trade/shop (where messing with the inventory can cause problems/exploits)
+#define clif_trading(sd) (sd->npc_id || sd->vender_id || sd->state.trading )
+
+//To idenfity disguised characters.
+#define disguised(bl) (bl->type==BL_PC && ((TBL_PC*)bl)->disguise)
+static char map_ip_str[128];
+static in_addr_t map_ip;
+static in_addr_t bind_ip = INADDR_ANY;
+static int map_port = 5121;
+int map_fd;
+char talkie_mes[MESSAGE_SIZE];
+
+//These two will be used to verify the incoming player's validity.
+//It helps identify their client packet version correctly. [Skotlex]
+static int max_account_id = DEFAULT_MAX_ACCOUNT_ID;
+static int max_char_id = DEFAULT_MAX_CHAR_ID;
+
+int clif_parse (int fd);
+static void clif_hpmeter_single(int fd, struct map_session_data *sd);
+
+/*==========================================
+ * map鯖のip設定
+ *------------------------------------------
+ */
+int clif_setip(char *ip)
+{
+ char ip_str[16];
+ map_ip = resolve_hostbyname(ip,NULL,ip_str);
+ if (!map_ip) {
+ ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
+ return 0;
+ }
+
+ strncpy(map_ip_str, ip, sizeof(map_ip_str));
+ ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip_str);
+ return 1;
+}
+
+void clif_setbindip(char *ip)
+{
+ unsigned char ip_str[4];
+ bind_ip = resolve_hostbyname(ip,ip_str,NULL);
+ if (bind_ip) {
+ ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip, ip_str[0], ip_str[1], ip_str[2], ip_str[3]);
+ } else {
+ ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
+ }
+}
+
+/*==========================================
+ * map鯖のport設定
+ *------------------------------------------
+ */
+void clif_setport(int port)
+{
+ map_port = port;
+}
+
+/*==========================================
+ * map鯖のip読み出し
+ *------------------------------------------
+ */
+in_addr_t clif_getip(void)
+{
+ return map_ip;
+}
+
+//Returns the ip casted as a basic type, to avoid needing to include the socket/net related libs by calling modules.
+unsigned long clif_getip_long(void)
+{
+ return (unsigned long)map_ip;
+}
+
+//Refreshes map_server ip, returns the new ip if the ip changed, otherwise it
+//returns 0.
+unsigned long clif_refresh_ip(void) {
+ in_addr_t new_ip;
+
+ new_ip = resolve_hostbyname(map_ip_str, NULL, NULL);
+ if (new_ip && new_ip != map_ip) {
+ map_ip = new_ip;
+ ShowInfo("Updating IP resolution of [%s].\n",map_ip_str);
+ return (unsigned long)map_ip;
+ }
+ return 0;
+}
+
+/*==========================================
+ * map鯖のport読み出し
+ *------------------------------------------
+ */
+int clif_getport(void)
+{
+ return map_port;
+}
+
+/*==========================================
+ * Counts connected players.
+ *------------------------------------------
+ */
+int clif_countusers(void)
+{
+ int users = 0, i;
+ struct map_session_data *sd;
+
+ for(i = 0; i < fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data*)session[i]->session_data) &&
+ sd->state.auth && !(battle_config.hide_GM_session && pc_isGM(sd)))
+ users++;
+ }
+ return users;
+}
+
+/*==========================================
+ * 全てのclientに対してfunc()実行
+ *------------------------------------------
+ */
+
+int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) //recoded by sasuke, bug when player count gets higher [Kevin]
+{
+ int i;
+ va_list ap;
+ struct map_session_data *sd;
+
+ va_start(ap,func);
+
+ for(i = 0; i < fd_max; i++) {
+ if ( session[i] && session[i]->func_parse == clif_parse) {
+ sd = (struct map_session_data*)session[i]->session_data;
+ if ( sd && sd->state.auth && !sd->state.waitingdisconnect )
+ func(sd, ap);
+ }
+ }
+
+ va_end(ap);
+ return 0;
+}
+
+/*==========================================
+ * clif_sendでAREA*指定時用
+ *------------------------------------------
+ */
+int clif_send_sub(struct block_list *bl, va_list ap)
+{
+ struct block_list *src_bl;
+ struct map_session_data *sd;
+ unsigned char *buf;
+ int len, type, fd;
+
+ nullpo_retr(0, bl);
+ nullpo_retr(0, ap);
+ nullpo_retr(0, sd = (struct map_session_data *)bl);
+
+ fd = sd->fd;
+ if (!fd) //Don't send to disconnected clients.
+ return 0;
+
+ buf = va_arg(ap,unsigned char*);
+ len = va_arg(ap,int);
+ nullpo_retr(0, src_bl = va_arg(ap,struct block_list*));
+ type = va_arg(ap,int);
+
+ switch(type) {
+ case AREA_WOS:
+ if (bl == src_bl)
+ return 0;
+ break;
+ case AREA_WOC:
+ if (sd->chatID || bl == src_bl)
+ return 0;
+ break;
+ case AREA_WOSC:
+ {
+ struct map_session_data *ssd = (struct map_session_data *)src_bl;
+ if (ssd && (src_bl->type == BL_PC) && sd->chatID && (sd->chatID == ssd->chatID))
+ return 0;
+ }
+ break;
+ }
+
+ if (session[fd] != NULL) {
+ WFIFOHEAD(fd, len);
+ if (WFIFOP(fd,0) == buf) {
+ printf("WARNING: Invalid use of clif_send function\n");
+ printf(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0));
+ printf(" Please correct your code.\n");
+ // don't send to not move the pointer of the packet for next sessions in the loop
+ } else {
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ memcpy(WFIFOP(fd,0), buf, len);
+ //Check if hidden, better to modify the char's buffer than the
+ //given buffer to prevent intravision affecting the packet as
+ //it's being received by everyone. [Skotlex]
+ /* New implementation... not quite correct yet as the client no longer
+ * displays correctly the SI_INTRAVISION effect.
+ if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 )
+ && bl != src_bl && WFIFOW(fd,0) == 0x0196)
+ { //New intravision method, just modify the status change/start packet. [Skotlex]
+ switch (WFIFOW(fd,2)) {
+ case SI_HIDING:
+ case SI_CLOAKING:
+ case SI_CHASEWALK:
+ WFIFOW(fd,2) = SI_INTRAVISION;
+ }
+ }
+ */
+
+ // Previous implementation.
+ if ((sd->special_state.intravision || sd->sc.data[SC_INTRAVISION].timer != -1 ) && bl != src_bl) {
+
+ struct status_change *sc = status_get_sc(src_bl);
+ if(sc && (sc->option&(OPTION_HIDE|OPTION_CLOAK)))
+ { //optionの修正
+ switch(((unsigned short*)buf)[0])
+ {
+#if PACKETVER > 6
+ case 0x229:
+ WFIFOL(fd,10) &= ~(OPTION_HIDE|OPTION_CLOAK);
+ break;
+ case 0x22a:
+ case 0x22b:
+ case 0x22c:
+ WFIFOL(fd,12) &=~(OPTION_HIDE|OPTION_CLOAK);
+ break;
+#endif
+#if PACKETVER > 3
+ case 0x119:
+ WFIFOW(fd,10) &= ~(OPTION_HIDE|OPTION_CLOAK);
+ break;
+ case 0x1d8:
+ case 0x1d9:
+ case 0x1da:
+#endif
+ case 0x78:
+ case 0x79:
+ case 0x7a:
+ case 0x7b:
+ case 0x7c:
+ WFIFOW(fd,12) &=~(OPTION_HIDE|OPTION_CLOAK);
+ break;
+ }
+ }
+ }
+ WFIFOSET(fd,len);
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) {
+ int i;
+ struct map_session_data *sd = NULL;
+ struct party_data *p = NULL;
+ struct guild *g = NULL;
+ int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd;
+
+ if (type != ALL_CLIENT &&
+ type != CHAT_MAINCHAT) {
+ nullpo_retr(0, bl);
+ if (bl->type == BL_PC) {
+ sd = (struct map_session_data *)bl;
+ }
+ }
+
+ switch(type) {
+ case ALL_CLIENT: //All player clients.
+ for (i = 0; i < fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data *)session[i]->session_data) != NULL&&
+ sd->state.auth) {
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(i, len);
+ memcpy(WFIFOP(i,0), buf, len);
+ WFIFOSET(i,len);
+ }
+ }
+ }
+ break;
+ case ALL_SAMEMAP: //All players on the same map
+ for(i = 0; i < fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
+ sd->state.auth && sd->bl.m == bl->m) {
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(i,len);
+ memcpy(WFIFOP(i,0), buf, len);
+ WFIFOSET(i,len);
+ }
+ }
+ }
+ break;
+ case AREA:
+ case AREA_WOSC:
+ if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
+ clif_send (buf, len, bl, SELF);
+ case AREA_WOC:
+ case AREA_WOS:
+ map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
+ BL_PC, buf, len, bl, type);
+ break;
+ case AREA_CHAT_WOC:
+ map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
+ bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
+ break;
+ case CHAT:
+ case CHAT_WOS:
+ {
+ struct chat_data *cd;
+ if (sd) {
+ cd = (struct chat_data*)map_id2bl(sd->chatID);
+ } else if (bl->type == BL_CHAT) {
+ cd = (struct chat_data*)bl;
+ } else break;
+ if (cd == NULL)
+ break;
+ for(i = 0; i < cd->users; i++) {
+ if (type == CHAT_WOS && cd->usersd[i] == sd)
+ continue;
+ if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ if ((fd=cd->usersd[i]->fd) >0 && session[fd]) // Added check to see if session exists [PoW]
+ {
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
+ }
+ }
+ }
+ break;
+ case CHAT_MAINCHAT: //[LuzZza]
+ for(i=1; i<fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
+ sd->state.mainchat && (fd=sd->fd))
+ {
+ WFIFOHEAD(fd, len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd, len);
+ }
+ }
+ break;
+ case PARTY_AREA:
+ case PARTY_AREA_WOS:
+ x0 = bl->x - AREA_SIZE;
+ y0 = bl->y - AREA_SIZE;
+ x1 = bl->x + AREA_SIZE;
+ y1 = bl->y + AREA_SIZE;
+ case PARTY:
+ case PARTY_WOS:
+ case PARTY_SAMEMAP:
+ case PARTY_SAMEMAP_WOS:
+ if (sd && sd->status.party_id)
+ p = party_search(sd->status.party_id);
+
+ if (p) {
+ for(i=0;i<MAX_PARTY;i++){
+ if ((sd = p->data[i].sd) == NULL)
+ continue;
+ if (!(fd=sd->fd) || session[fd] == NULL || sd->state.auth == 0
+ || session[fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
+ continue;
+
+ if (sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS))
+ continue;
+
+ if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m)
+ continue;
+
+ if ((type == PARTY_AREA || type == PARTY_AREA_WOS) &&
+ (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
+ continue;
+
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
+ }
+ if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
+ break;
+ for (i = 1; i < fd_max; i++){ // partyspy [Syrus22]
+
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
+ sd->state.auth && (fd=sd->fd) && sd->partyspy == p->party.party_id)
+ {
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
+ }
+ }
+ }
+ break;
+ case DUEL:
+ case DUEL_WOS:
+ if (!sd || !sd->duel_group) break; //Invalid usage.
+
+ x0 = sd->duel_group; //Here we use x0 to store the duel group. [Skotlex]
+ for (i = 0; i < fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data *)session[i]->session_data) != NULL &&
+ sd->state.auth && sd->duel_group == x0) {
+ if (type == DUEL_WOS && bl->id == sd->bl.id)
+ continue;
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) {
+ WFIFOHEAD(i, len);
+ memcpy(WFIFOP(i,0), buf, len);
+ WFIFOSET(i,len);
+ }
+ }
+ }
+ break;
+ case SELF:
+ if (sd && (fd=sd->fd) && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
+ break;
+
+// New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex]
+ case GUILD_AREA:
+ case GUILD_AREA_WOS:
+ x0 = bl->x - AREA_SIZE;
+ y0 = bl->y - AREA_SIZE;
+ x1 = bl->x + AREA_SIZE;
+ y1 = bl->y + AREA_SIZE;
+ case GUILD_SAMEMAP:
+ case GUILD_SAMEMAP_WOS:
+ case GUILD:
+ case GUILD_WOS:
+ if (sd && sd->status.guild_id)
+ g = guild_search(sd->status.guild_id);
+
+ if (g) {
+ for(i = 0; i < g->max_member; i++) {
+ if ((sd = g->member[i].sd) != NULL) {
+ if (!(fd=sd->fd) || session[fd] == NULL || sd->state.auth == 0
+ || session[fd]->session_data == NULL || sd->packet_ver > MAX_PACKET_VER)
+ continue;
+
+ if (sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS))
+ continue;
+
+ if (type != GUILD && type != GUILD_WOS && sd->bl.m != bl->m)
+ continue;
+
+ if ((type == GUILD_AREA || type == GUILD_AREA_WOS) &&
+ (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1))
+ continue;
+
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
+ }
+ }
+ if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
+ break;
+ for (i = 1; i < fd_max; i++){ // guildspy [Syrus22]
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = (struct map_session_data*)session[i]->session_data) != NULL &&
+ sd->state.auth && (fd=sd->fd) && sd->guildspy == g->guild_id) {
+ if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version
+ WFIFOHEAD(fd,len);
+ memcpy(WFIFOP(fd,0), buf, len);
+ WFIFOSET(fd,len);
+ }
+ }
+ }
+ }
+ break;
+/* End [Valaris] */
+
+ default:
+ if (battle_config.error_log)
+ ShowError("clif_send: Unrecognized type %d\n",type);
+ return -1;
+ }
+
+ return 0;
+}
+
+//
+// パケット作って送信
+//
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_authok(struct map_session_data *sd) {
+ int fd;
+
+ if (!sd->fd)
+ return 0;
+ fd = sd->fd;
+
+ WFIFOHEAD(fd, packet_len_table[0x73]);
+ WFIFOW(fd, 0) = 0x73;
+ WFIFOL(fd, 2) = gettick();
+ WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir);
+ WFIFOB(fd, 9) = 5;
+ WFIFOB(fd,10) = 5;
+ WFIFOSET(fd,packet_len_table[0x73]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_authfail_fd(int fd, int type) {
+ if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players!
+ return 0;
+
+ WFIFOHEAD(fd, packet_len_table[0x81]);
+ WFIFOW(fd,0) = 0x81;
+ WFIFOB(fd,2) = type;
+ WFIFOSET(fd,packet_len_table[0x81]);
+ clif_setwaitclose(fd);
+ return 0;
+}
+
+/*==========================================
+ * Used to know which is the max valid account/char id [Skotlex]
+ *------------------------------------------
+ */
+void clif_updatemaxid(int account_id, int char_id)
+{
+ max_account_id = account_id;
+ max_char_id = char_id;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_charselectok(int id) {
+ struct map_session_data *sd;
+ int fd;
+
+ if ((sd = map_id2sd(id)) == NULL)
+ return 1;
+
+ if (!sd->fd)
+ return 1;
+
+ fd = sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0xb3]);
+ WFIFOW(fd,0) = 0xb3;
+ WFIFOB(fd,2) = 1;
+ WFIFOSET(fd,packet_len_table[0xb3]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf) {
+ int view;
+
+ nullpo_retr(0, fitem);
+
+ //009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
+ WBUFW(buf, 0) = 0x9e;
+ WBUFL(buf, 2) = fitem->bl.id;
+ if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
+ WBUFW(buf, 6) = view;
+ else
+ WBUFW(buf, 6) = fitem->item_data.nameid;
+ WBUFB(buf, 8) = fitem->item_data.identify;
+ WBUFW(buf, 9) = fitem->bl.x;
+ WBUFW(buf,11) = fitem->bl.y;
+ WBUFB(buf,13) = fitem->subx;
+ WBUFB(buf,14) = fitem->suby;
+ WBUFW(buf,15) = fitem->item_data.amount;
+
+ return packet_len_table[0x9e];
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_dropflooritem(struct flooritem_data *fitem) {
+ unsigned char buf[64];
+
+ nullpo_retr(0, fitem);
+
+ if (fitem->item_data.nameid <= 0)
+ return 0;
+ clif_set009e(fitem, buf);
+ clif_send(buf, packet_len_table[0x9e], &fitem->bl, AREA);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_clearflooritem(struct flooritem_data *fitem, int fd) {
+ unsigned char buf[16];
+
+ nullpo_retr(0, fitem);
+
+ WBUFW(buf,0) = 0xa1;
+ WBUFL(buf,2) = fitem->bl.id;
+
+ if (fd == 0) {
+ clif_send(buf, packet_len_table[0xa1], &fitem->bl, AREA);
+ } else {
+ WFIFOHEAD(fd,packet_len_table[0xa1]);
+ memcpy(WFIFOP(fd,0), buf, 6);
+ WFIFOSET(fd,packet_len_table[0xa1]);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_clearchar(struct block_list *bl, int type) {
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0) = 0x80;
+ WBUFL(buf,2) = bl->id;
+ WBUFB(buf,6) = type;
+
+ clif_send(buf, packet_len_table[0x80], bl, type == 1 ? AREA : AREA_WOS);
+ if(disguised(bl)) {
+ WBUFL(buf,2) = -bl->id;
+ clif_send(buf, packet_len_table[0x80], bl, SELF);
+ }
+
+ return 0;
+}
+
+static int clif_clearchar_delay_sub(int tid, unsigned int tick, int id, int data) {
+ struct block_list *bl = (struct block_list *)id;
+
+ clif_clearchar(bl,data);
+ aFree(bl);
+ return 0;
+}
+
+int clif_clearchar_delay(unsigned int tick, struct block_list *bl, int type) {
+ struct block_list *tbl;
+ tbl = aMalloc(sizeof (struct block_list));
+ memcpy (tbl, bl, sizeof (struct block_list));
+ add_timer(tick, clif_clearchar_delay_sub, (int)tbl, type);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_clearchar_id(int id, int type, int fd) {
+
+ WFIFOHEAD(fd, packet_len_table[0x80]);
+ WFIFOW(fd,0) = 0x80;
+ WFIFOL(fd,2) = id;
+ WFIFOB(fd,6) = (char)type; // Why use int for a char in the first place?
+ WFIFOSET(fd, packet_len_table[0x80]);
+
+ return 0;
+}
+
+void clif_get_weapon_view(TBL_PC* sd, unsigned short *rhand, unsigned short *lhand)
+{
+#if PACKETVER > 3
+ struct item_data *id;
+#endif
+
+ if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
+ {
+ *rhand = *lhand = 0;
+ return;
+ }
+
+#if PACKETVER < 4
+ *rhand = sd->status.weapon;
+ *lhand = sd->status.shield;
+#else
+ if (sd->equip_index[EQI_HAND_R] >= 0 &&
+ sd->inventory_data[sd->equip_index[EQI_HAND_R]])
+ {
+ id = sd->inventory_data[sd->equip_index[EQI_HAND_R]];
+ if (id->view_id > 0)
+ *rhand = id->view_id;
+ else
+ *rhand = id->nameid;
+ } else
+ *rhand = 0;
+
+ if (sd->equip_index[EQI_HAND_L] >= 0 &&
+ sd->equip_index[EQI_HAND_L] != sd->equip_index[EQI_HAND_R] &&
+ sd->inventory_data[sd->equip_index[EQI_HAND_L]])
+ {
+ id = sd->inventory_data[sd->equip_index[EQI_HAND_L]];
+ if (id->view_id > 0)
+ *lhand = id->view_id;
+ else
+ *lhand = id->nameid;
+ } else
+ *lhand = 0;
+#endif
+}
+
+static void clif_get_guild_data(struct block_list *bl, long *guild_id, short *emblem_id)
+{
+ //TODO: There has to be a way to clean this up.
+ switch (bl->type) {
+ case BL_PC:
+ *guild_id = ((TBL_PC*)bl)->status.guild_id;
+ *emblem_id = ((TBL_PC*)bl)->guild_emblem_id;
+ break;
+ case BL_MOB:
+ if (((TBL_MOB*)bl)->guardian_data) {
+ *guild_id =((TBL_MOB*)bl)->guardian_data->guild_id;
+ *emblem_id =((TBL_MOB*)bl)->guardian_data->emblem_id;
+ }
+ break;
+ case BL_NPC:
+ if (bl->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) {
+ struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id);
+ if (g) {
+ *guild_id =g->guild_id;
+ *emblem_id =g->emblem_id;
+ }
+ }
+ break;
+ default:
+ *guild_id = status_get_guild_id(bl);
+ }
+ return;
+}
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned char *buf) {
+ struct status_change *sc;
+ struct map_session_data *sd;
+ long guild_id=0;
+ unsigned short emblem_id=0, lv;
+ unsigned short dir;
+
+ nullpo_retr(0, bl);
+ BL_CAST(BL_PC, bl, sd);
+ sc = status_get_sc(bl);
+
+ clif_get_guild_data(bl, &guild_id, &emblem_id);
+ dir = unit_getdir(bl);
+ lv = status_get_lv(bl);
+ if(pcdb_checkid(vd->class_)) {
+#if PACKETVER > 6
+ malloc_set(buf,0,packet_len_table[0x22a]);
+
+ WBUFW(buf,0)=0x22a;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFL(buf,12)=sc->option;
+ WBUFL(buf,44)=sc->opt3;
+ }
+ WBUFW(buf,16)=vd->class_;
+ WBUFW(buf,18)=vd->hair_style;
+ WBUFW(buf,20)=vd->weapon;
+ WBUFW(buf,22)=vd->shield;
+ WBUFW(buf,24)=vd->head_bottom;
+ WBUFW(buf,26)=vd->head_top;
+ WBUFW(buf,28)=vd->head_mid;
+ WBUFW(buf,30)=vd->hair_color;
+ WBUFW(buf,32)=vd->cloth_color;
+ WBUFW(buf,34)=sd?sd->head_dir:0;
+ WBUFL(buf,36)=guild_id;
+ WBUFW(buf,40)=emblem_id;
+ if (sd) {
+ WBUFW(buf,42)=sd->status.manner;
+ WBUFB(buf,48)=sd->status.karma;
+ }
+ WBUFB(buf,49)=vd->sex;
+ WBUFPOS(buf,50,bl->x,bl->y,dir);
+ WBUFB(buf,53)=5;
+ WBUFB(buf,54)=5;
+ WBUFB(buf,55)=vd->dead_sit;
+ WBUFW(buf,56)=clif_setlevel(lv);
+ return packet_len_table[0x22a];
+#elif PACKETVER > 3
+ malloc_set(buf,0,packet_len_table[0x1d8]);
+
+ WBUFW(buf,0)=0x1d8;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,42)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->shield;
+ WBUFW(buf,22)=vd->head_bottom;
+ WBUFW(buf,24)=vd->head_top;
+ WBUFW(buf,26)=vd->head_mid;
+ WBUFW(buf,28)=vd->hair_color;
+ WBUFW(buf,30)=vd->cloth_color;
+ WBUFW(buf,32)=sd?sd->head_dir:0;
+ WBUFL(buf,34)=guild_id;
+ WBUFW(buf,38)=emblem_id;
+ if (sd) {
+ WBUFW(buf,40)=sd->status.manner;
+ WBUFB(buf,44)=sd->status.karma;
+ }
+ WBUFB(buf,45)=vd->sex;
+ WBUFPOS(buf,46,bl->x,bl->y,dir);
+ WBUFB(buf,49)=5;
+ WBUFB(buf,50)=5;
+ WBUFB(buf,51)=vd->dead_sit;
+ WBUFW(buf,52)=clif_setlevel(lv);
+ return packet_len_table[0x1d8];
+#else
+ malloc_set(buf,0,packet_len_table[0x78]);
+
+ WBUFW(buf,0)=0x78;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,42)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->head_bottom;
+ WBUFW(buf,22)=vd->shield;
+ WBUFW(buf,24)=vd->head_top;
+ WBUFW(buf,26)=vd->head_mid;
+ WBUFW(buf,28)=vd->hair_color;
+ WBUFW(buf,30)=vd->cloth_color;
+ WBUFW(buf,32)=sd?sd->head_dir:0;
+ WBUFL(buf,34)=guild_id;
+ WBUFL(buf,38)=emblem_id;
+ if (sd)
+ WBUFB(buf,44)=sd->status.karma;
+ WBUFB(buf,45)=vd->sex;
+ WBUFPOS(buf,46,bl->x,bl->y,dir);
+ WBUFB(buf,49)=5;
+ WBUFB(buf,50)=5;
+ WBUFB(buf,51)=vd->dead_sit;
+ WBUFW(buf,52)=clif_setlevel(lv);
+ return packet_len_table[0x78];
+#endif
+ }
+ //Non-player sprites need just a few fields filled.
+ malloc_set(buf,0,packet_len_table[0x78]);
+
+ WBUFW(buf,0)=0x78;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,42)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style; //Required for pets.
+ WBUFW(buf,20)=vd->head_bottom; //Pet armor
+ if (bl->type == BL_NPC && vd->class_ == 722)
+ { //The hell, why flags work like this?
+ WBUFL(buf,22)=emblem_id;
+ WBUFL(buf,26)=guild_id;
+ }
+ WBUFW(buf,32)=dir;
+ WBUFL(buf,34)=guild_id;
+ WBUFL(buf,38)=emblem_id;
+ WBUFPOS(buf,46,bl->x,bl->y,dir);
+ WBUFB(buf,49)=5;
+ WBUFB(buf,50)=5;
+ WBUFW(buf,52)=clif_setlevel(lv);
+ return packet_len_table[0x78];
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit_data *ud, unsigned char *buf) {
+ struct status_change *sc;
+ struct map_session_data *sd;
+ long guild_id=0;
+ unsigned short emblem_id=0, lv;
+
+ nullpo_retr(0, bl);
+ BL_CAST(BL_PC, bl, sd);
+ sc = status_get_sc(bl);
+
+ clif_get_guild_data(bl, &guild_id, &emblem_id);
+ lv = status_get_lv(bl);
+
+ if(pcdb_checkid(vd->class_)) {
+#if PACKETVER > 6
+ malloc_set(buf,0,packet_len_table[0x22c]);
+
+ WBUFW(buf,0)=0x22c;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)= sc->opt1;
+ WBUFW(buf,10)= sc->opt2;
+ WBUFL(buf,12)= sc->option;
+ WBUFL(buf,48)= sc->opt3;
+ }
+ WBUFW(buf,16)=vd->class_;
+ WBUFW(buf,18)=vd->hair_style;
+ WBUFW(buf,20)=vd->weapon;
+ WBUFW(buf,22)=vd->shield;
+ WBUFW(buf,24)=vd->head_bottom;
+ WBUFL(buf,26)=gettick();
+ WBUFW(buf,30)=vd->head_top;
+ WBUFW(buf,32)=vd->head_mid;
+ WBUFW(buf,34)=vd->hair_color;
+ WBUFW(buf,36)=vd->cloth_color;
+ WBUFW(buf,38)=sd?sd->head_dir:0;
+ WBUFL(buf,40)=guild_id;
+ WBUFW(buf,44)=emblem_id;
+ if (sd) {
+ WBUFW(buf,46)=sd->status.manner;
+ WBUFB(buf,52)=sd->status.karma;
+ }
+ WBUFB(buf,53)=vd->sex;
+ WBUFPOS2(buf,54,bl->x,bl->y,ud->to_x,ud->to_y);
+ WBUFB(buf,59)=0x88; // Deals with acceleration in directions. [Valaris]
+ WBUFB(buf,60)=0;
+ WBUFB(buf,61)=0;
+ WBUFW(buf,62)=clif_setlevel(lv);
+
+ return packet_len_table[0x22c];
+#elif PACKETVER > 3
+ malloc_set(buf,0,packet_len_table[0x1da]);
+
+ WBUFW(buf,0)=0x1da;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,46)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->shield;
+ WBUFW(buf,22)=vd->head_bottom;
+ WBUFL(buf,24)=gettick();
+ WBUFW(buf,28)=vd->head_top;
+ WBUFW(buf,30)=vd->head_mid;
+ WBUFW(buf,32)=vd->hair_color;
+ WBUFW(buf,34)=vd->cloth_color;
+ WBUFW(buf,36)=sd?sd->head_dir:0;
+ WBUFL(buf,38)=guild_id;
+ WBUFW(buf,42)=emblem_id;
+ if (sd) {
+ WBUFW(buf,44)=sd->status.manner;
+ WBUFB(buf,48)=sd->status.karma;
+ }
+ WBUFB(buf,49)=vd->sex;
+ WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
+ WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
+ WBUFB(buf,56)=5;
+ WBUFB(buf,57)=5;
+ WBUFW(buf,58)=clif_setlevel(lv);
+
+ return packet_len_table[0x1da];
+#else
+ malloc_set(buf,0,packet_len_table[0x7b]);
+
+ WBUFW(buf,0)=0x7b;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,46)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style;
+ WBUFW(buf,18)=vd->weapon;
+ WBUFW(buf,20)=vd->head_bottom;
+ WBUFL(buf,22)=gettick();
+ WBUFW(buf,26)=vd->shield;
+ WBUFW(buf,28)=vd->head_top;
+ WBUFW(buf,30)=vd->head_mid;
+ WBUFW(buf,32)=vd->hair_color;
+ WBUFW(buf,34)=vd->cloth_color;
+ WBUFW(buf,36)=sd?sd->head_dir:0;
+ WBUFL(buf,38)=guild_id;
+ WBUFL(buf,42)=emblem_id;
+ if (sd)
+ WBUFB(buf,48)=sd->status.karma;
+ WBUFB(buf,49)=vd->sex;
+ WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
+ WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
+ WBUFB(buf,56)=5;
+ WBUFB(buf,57)=5;
+ WBUFW(buf,58)=clif_setlevel(lv);
+
+ return packet_len_table[0x7b];
+#endif
+ }
+ //Non-player sprites only require a few fields.
+#if PACKETVER > 6
+ malloc_set(buf,0,packet_len_table[0x22c]);
+
+ WBUFW(buf,0)=0x22c;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFL(buf,12)=sc->option;
+ WBUFL(buf,48)=sc->opt3;
+ }
+ WBUFW(buf,16)=vd->class_;
+ WBUFW(buf,18)=vd->hair_style; //For pets
+ WBUFW(buf,24)=vd->head_bottom; //Pet armor
+ WBUFL(buf,26)=gettick();
+ WBUFW(buf,38)=unit_getdir(bl);
+ WBUFL(buf,40)=guild_id;
+ WBUFL(buf,44)=emblem_id;
+ WBUFPOS2(buf,54,bl->x,bl->y,ud->to_x,ud->to_y);
+ WBUFB(buf,59)=0x88; // Deals with acceleration in directions. [Valaris]
+ WBUFB(buf,60)=0;
+ WBUFB(buf,61)=0;
+ WBUFW(buf,62)=clif_setlevel(lv);
+ return packet_len_table[0x22c];
+#else
+ malloc_set(buf,0,packet_len_table[0x7b]);
+
+ WBUFW(buf,0)=0x7b;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ WBUFW(buf,46)=sc->opt3;
+ }
+ WBUFW(buf,14)=vd->class_;
+ WBUFW(buf,16)=vd->hair_style; //For pets
+ WBUFW(buf,20)=vd->head_bottom; //Pet armor
+ WBUFL(buf,22)=gettick();
+ WBUFW(buf,36)=unit_getdir(bl);
+ WBUFL(buf,38)=guild_id;
+ WBUFL(buf,42)=emblem_id;
+ WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y);
+ WBUFB(buf,55)=0x88; // Deals with acceleration in directions. [Valaris]
+ WBUFB(buf,56)=5;
+ WBUFB(buf,57)=5;
+ WBUFW(buf,58)=clif_setlevel(lv);
+ return packet_len_table[0x7b];
+#endif
+}
+
+//Modifies the buffer for disguise characters and sends it to self.
+//Flag = 0: change id to negative, buf will have disguise data.
+//Flag = 1: change id to positive, class and option to make your own char invisible.
+//Luckily, the offsets that need to be changed are the same in packets 0x78, 0x7b, 0x1d8 and 0x1da
+//But no longer holds true for those packet of PACKETVER 7.
+static void clif_setdisguise(struct map_session_data *sd, unsigned char *buf,int len, int flag) {
+
+ if (flag) {
+#if PACKETVER > 6
+ switch (WBUFW(buf,0)) {
+ case 0x22c:
+ case 0x22b:
+ case 0x22a:
+ WBUFL(buf,12)=OPTION_INVISIBLE;
+ WBUFW(buf,16)=sd->status.class_;
+ break;
+ default:
+#endif
+ WBUFL(buf,2)=sd->bl.id;
+ WBUFW(buf,12)=OPTION_INVISIBLE;
+ WBUFW(buf,14)=sd->status.class_;
+#if PACKETVER > 6
+ break;
+ }
+#endif
+ } else {
+ WBUFL(buf,2)=-sd->bl.id;
+ }
+ clif_send(buf, len, &sd->bl, SELF);
+}
+
+/*==========================================
+ * クラスチェンジ typeはMobの場合は1で他は0?
+ *------------------------------------------
+ */
+int clif_class_change(struct block_list *bl,int class_,int type)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ if(!pcdb_checkid(class_)) {
+ WBUFW(buf,0)=0x1b0;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=type;
+ WBUFL(buf,7)=class_;
+ clif_send(buf,packet_len_table[0x1b0],bl,AREA);
+ }
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static void clif_spiritball_single(int fd, struct map_session_data *sd)
+{
+ WFIFOHEAD(fd, packet_len_table[0x1e1]);
+ WFIFOW(fd,0)=0x1e1;
+ WFIFOL(fd,2)=sd->bl.id;
+ WFIFOW(fd,6)=sd->spiritball;
+ WFIFOSET(fd, packet_len_table[0x1e1]);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static int clif_set0192(int fd, int m, int x, int y, int type) {
+ WFIFOHEAD(fd, packet_len_table[0x192]);
+ WFIFOW(fd,0) = 0x192;
+ WFIFOW(fd,2) = x;
+ WFIFOW(fd,4) = y;
+ WFIFOW(fd,6) = type;
+ memcpy(WFIFOP(fd,8),map[m].name,MAP_NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0x192]);
+
+ return 0;
+}
+
+// new and improved weather display [Valaris]
+static void clif_weather_sub(int fd, int id, int type) {
+ WFIFOHEAD(fd, packet_len_table[0x1f3]);
+ WFIFOW(fd,0) = 0x1f3;
+ WFIFOL(fd,2) = id;
+ WFIFOL(fd,6) = type;
+ WFIFOSET(fd,packet_len_table[0x1f3]);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static void clif_weather_check(struct map_session_data *sd) {
+ int m = sd->bl.m, fd = sd->fd;
+
+ if (map[m].flag.snow
+ || map[m].flag.clouds
+ || map[m].flag.fog
+ || map[m].flag.fireworks
+ || map[m].flag.sakura
+ || map[m].flag.leaves
+ || map[m].flag.rain
+ || map[m].flag.clouds2)
+ {
+ if (map[m].flag.snow)
+ clif_weather_sub(fd, sd->bl.id, 162);
+ if (map[m].flag.clouds)
+ clif_weather_sub(fd, sd->bl.id, 233);
+ if (map[m].flag.clouds2)
+ clif_weather_sub(fd, sd->bl.id, 516);
+ if (map[m].flag.fog)
+ clif_weather_sub(fd, sd->bl.id, 515);
+ if (map[m].flag.fireworks) {
+ clif_weather_sub(fd, sd->bl.id, 297);
+ clif_weather_sub(fd, sd->bl.id, 299);
+ clif_weather_sub(fd, sd->bl.id, 301);
+ }
+ if (map[m].flag.sakura)
+ clif_weather_sub(fd, sd->bl.id, 163);
+ if (map[m].flag.leaves)
+ clif_weather_sub(fd, sd->bl.id, 333);
+ if (map[m].flag.rain)
+ clif_weather_sub(fd, sd->bl.id, 161);
+ }
+}
+
+int clif_weather(int m) {
+ int i;
+
+ struct map_session_data *sd=NULL;
+
+ for(i = 0; i < fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd = session[i]->session_data) != NULL &&
+ sd->state.auth && sd->bl.m == m) {
+ clif_weather_check(sd);
+ }
+ }
+
+ return 0;
+}
+
+int clif_spawn(struct block_list *bl)
+{
+ unsigned char buf[128];
+ struct view_data *vd;
+ nullpo_retr(0, bl);
+ vd = status_get_viewdata(bl);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return 0;
+
+ if (pcdb_checkid(vd->class_))
+ { //Player spawn packet.
+ clif_set0078(bl, vd, buf);
+ switch(WBUFW(buf,0)) {
+ case 0x78: //Convert to 0x79
+ WBUFW(buf, 0) = 0x79;
+ WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
+ clif_send(buf, packet_len_table[0x79], bl, AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x79], 0);
+ break;
+#if PACKETVER > 3
+ case 0x1d8: //Convert to 0x1d9
+ WBUFW(buf, 0) = 0x1d9;
+ WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
+ clif_send(buf, packet_len_table[0x1d9], bl, AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x1d9], 0);
+ break;
+#endif
+#if PACKETVER > 6
+ case 0x22a: //Convert to 0x22b
+ WBUFW(buf, 0) = 0x22b;
+ WBUFW(buf,55) = WBUFW(buf,56); //Lv is placed on offset 56
+ clif_send(buf, packet_len_table[0x22b], bl, AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, packet_len_table[0x22b], 0);
+ break;
+#endif
+ }
+ } else { //Mob spawn packet.
+ struct status_change *sc = status_get_sc(bl);
+ malloc_tsetdword(buf,0,sizeof(buf));
+ WBUFW(buf,0)=0x7c;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=status_get_speed(bl);
+ if (sc) {
+ WBUFW(buf,8)=sc->opt1;
+ WBUFW(buf,10)=sc->opt2;
+ WBUFW(buf,12)=sc->option;
+ }
+ WBUFW(buf,20)=vd->class_;
+ WBUFW(buf,22)=vd->hair_style; //Required for pets.
+ WBUFW(buf,24)=vd->head_bottom; //Pet armor
+
+ WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl));
+ clif_send(buf,packet_len_table[0x7c],bl,AREA_WOS);
+ if (disguised(bl)) {
+ WBUFL(buf,2)=-bl->id;
+ clif_send(buf,packet_len_table[0x7c],bl,SELF);
+ }
+ }
+
+ if (vd->cloth_color)
+ clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
+
+ switch (bl->type)
+ {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+ if (sd->spiritball > 0)
+ clif_spiritball(sd);
+ if(sd->state.size==2) // tiny/big players [Valaris]
+ clif_specialeffect(bl,423,AREA);
+ else if(sd->state.size==1)
+ clif_specialeffect(bl,421,AREA);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==2) // tiny/big mobs [Valaris]
+ clif_specialeffect(&md->bl,423,AREA);
+ else if(md->special_state.size==1)
+ clif_specialeffect(&md->bl,421,AREA);
+ }
+ break;
+ }
+ return 0;
+}
+
+//[orn]
+int clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag)
+{
+ struct status_data *status;
+ unsigned char buf[128];
+
+ nullpo_retr(0, hd);
+
+ status = &hd->battle_status;
+ malloc_set(buf,0,packet_len_table[0x22e]);
+ WBUFW(buf,0)=0x22e;
+ memcpy(WBUFP(buf,2),hd->homunculus.name,NAME_LENGTH);
+ // Bit field, bit 0 : rename_flag (1 = already renamed), bit 1 : homunc vaporized (1 = true), bit 2 : homunc dead (1 = true)
+ WBUFB(buf,26)=hd->homunculus.rename_flag | (hd->homunculus.vaporize << 1) | (hd->homunculus.hp?0:4);
+ WBUFW(buf,27)=hd->homunculus.level;
+ WBUFW(buf,29)=hd->homunculus.hunger;
+ WBUFW(buf,31)=(unsigned short) (hd->homunculus.intimacy / 100) ;
+ WBUFW(buf,33)=0; // equip id
+ WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, SHRT_MAX);
+ WBUFW(buf,37)=cap_value(status->matk_max, 0, SHRT_MAX);
+ WBUFW(buf,39)=status->hit;
+ WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious]
+ WBUFW(buf,43)=status->def + status->vit ;
+ WBUFW(buf,45)=status->mdef;
+ WBUFW(buf,47)=status->flee;
+ WBUFW(buf,49)=(flag)?0:status->amotion;
+ if (status->max_hp > SHRT_MAX) {
+ WBUFW(buf,51) = status->hp/(status->max_hp/100);
+ WBUFW(buf,53) = 100;
+ } else {
+ WBUFW(buf,51)=status->hp;
+ WBUFW(buf,53)=status->max_hp;
+ }
+ if (status->max_sp > SHRT_MAX) {
+ WBUFW(buf,55) = status->sp/(status->max_sp/100);
+ WBUFW(buf,57) = 100;
+ } else {
+ WBUFW(buf,55)=status->sp;
+ WBUFW(buf,57)=status->max_sp;
+ }
+ WBUFL(buf,59)=hd->homunculus.exp;
+ WBUFL(buf,63)=hd->exp_next;
+ WBUFW(buf,67)=hd->homunculus.skillpts;
+ WBUFW(buf,69)=1; // FIXME: Attackable? When exactly is a homun not attackable? [Skotlex]
+ clif_send(buf,packet_len_table[0x22e],&sd->bl,SELF);
+ return 0;
+}
+
+void clif_send_homdata(struct map_session_data *sd, int type, int param) { //[orn]
+ int fd = sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x230]);
+ nullpo_retv(sd->hd);
+ WFIFOW(fd,0)=0x230;
+ WFIFOW(fd,2)=type;
+ WFIFOL(fd,4)=sd->hd->bl.id;
+ WFIFOL(fd,8)=param;
+ WFIFOSET(fd,packet_len_table[0x230]);
+
+ return;
+}
+
+int clif_homskillinfoblock(struct map_session_data *sd) { //[orn]
+ struct homun_data *hd;
+ int fd = sd->fd;
+ int i,j,len=4,id;
+ WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL);
+
+ hd = sd->hd;
+ if ( !hd )
+ return 0 ;
+
+ WFIFOW(fd,0)=0x235;
+ for ( i = 0; i < MAX_HOMUNSKILL; i++){
+ if( (id = hd->homunculus.hskill[i].id) != 0 ){
+ j = id - HM_SKILLBASE - 1 ;
+ WFIFOW(fd,len ) = id ;
+ WFIFOW(fd,len+2) = skill_get_inf(id) ;
+ WFIFOW(fd,len+4) = 0 ;
+ WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv ;
+ WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv) ;
+ WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv) ;
+ strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH) ;
+ WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0;
+ len+=37;
+ }
+ }
+ WFIFOW(fd,2)=len;
+ WFIFOSET(fd,len);
+
+ return 0;
+}
+
+void clif_homskillup(struct map_session_data *sd, int skill_num) { //[orn]
+ struct homun_data *hd;
+ int fd=sd->fd, skillid;
+ WFIFOHEAD(fd, packet_len_table[0x239]);
+ nullpo_retv(sd);
+ skillid = skill_num - HM_SKILLBASE - 1;
+
+ hd=sd->hd;
+
+ WFIFOW(fd,0) = 0x239;
+ WFIFOW(fd,2) = skill_num;
+ WFIFOW(fd,4) = hd->homunculus.hskill[skillid].lv;
+ WFIFOW(fd,6) = skill_get_sp(skill_num,hd->homunculus.hskill[skillid].lv);
+ WFIFOW(fd,8) = skill_get_range2(&hd->bl, skill_num,hd->homunculus.hskill[skillid].lv);
+ WFIFOB(fd,10) = (hd->homunculus.hskill[skillid].lv < skill_get_max(hd->homunculus.hskill[skillid].id)) ? 1 : 0;
+ WFIFOSET(fd,packet_len_table[0x239]);
+
+ return;
+}
+
+void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) { //[orn]
+ struct homun_data *hd;
+ RFIFOHEAD(fd);
+ nullpo_retv(sd);
+
+ if((hd=sd->hd) == NULL)
+ return;
+
+ memcpy(hd->homunculus.name,RFIFOP(fd,2),24);
+ hd->homunculus.rename_flag = 1;
+ clif_hominfo(sd,hd,0);
+ clif_charnameack(sd->fd,&hd->bl);
+}
+
+void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) { //[orn]
+
+ nullpo_retv(sd);
+
+ if(!merc_is_hom_active(sd->hd))
+ return;
+
+ if (!unit_can_move(&sd->hd->bl))
+ return;
+ unit_walktoxy(&sd->hd->bl, sd->bl.x,sd->bl.y-1, 0);
+}
+
+void clif_parse_HomMoveTo(int fd,struct map_session_data *sd) { //[orn]
+ int x,y,cmd;
+ RFIFOHEAD(fd);
+ nullpo_retv(sd);
+
+ if(!merc_is_hom_active(sd->hd))
+ return;
+
+ cmd = RFIFOW(fd,0);
+ x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
+ (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 1) >> 6);
+ y = ((RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]+1) & 0x3f) << 4) +
+ (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
+
+ if (!unit_can_move(&sd->hd->bl))
+ return;
+
+ unit_walktoxy(&(sd->hd->bl),x,y,0);
+}
+
+void clif_parse_HomAttack(int fd,struct map_session_data *sd) { //[orn]
+ struct block_list *target;
+ RFIFOHEAD(fd);
+ nullpo_retv(sd);
+
+ if(!merc_is_hom_active(sd->hd))
+ return;
+
+ if ((target = map_id2bl(RFIFOL(fd,6))) == NULL || status_isdead(target))
+ return;
+
+ merc_stop_walking(sd->hd, 1);
+ merc_stop_attack(sd->hd);
+ unit_attack(&sd->hd->bl,RFIFOL(fd,6),1) ;
+}
+
+void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
+ int cmd;
+
+ RFIFOHEAD(fd);
+ cmd = RFIFOW(fd,0);
+
+ if(!merc_is_hom_active(sd->hd))
+ return;
+
+ merc_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]));
+}
+
+int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn]
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x22f]);
+ WFIFOW(fd,0)=0x22f;
+ WFIFOB(fd,2)=fail;
+ WFIFOW(fd,3)=foodid;
+ WFIFOSET(fd,packet_len_table[0x22f]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_walkok(struct map_session_data *sd)
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x87]);
+ WFIFOW(fd,0)=0x87;
+ WFIFOL(fd,2)=gettick();
+ WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
+ WFIFOB(fd,11)=0x88;
+ WFIFOSET(fd,packet_len_table[0x87]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_movepc(struct map_session_data *sd) {
+ unsigned char buf[256];
+
+ nullpo_retr(0, sd);
+
+ if (map[sd->bl.m].flag.snow
+ || map[sd->bl.m].flag.clouds
+ || map[sd->bl.m].flag.fog
+ || map[sd->bl.m].flag.fireworks
+ || map[sd->bl.m].flag.sakura
+ || map[sd->bl.m].flag.leaves
+ || map[sd->bl.m].flag.rain
+ || map[sd->bl.m].flag.clouds2
+ ) {
+ malloc_set(buf,0,packet_len_table[0x7b]);
+ WBUFW(buf,0)=0x7b;
+ WBUFL(buf,2)=-10;
+ WBUFW(buf,6)=sd->battle_status.speed;
+ WBUFW(buf,8)=0;
+ WBUFW(buf,10)=0;
+ WBUFW(buf,12)=OPTION_INVISIBLE;
+ WBUFW(buf,14)=100;
+ WBUFL(buf,22)=gettick();
+ WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y);
+ WBUFB(buf,56)=5;
+ WBUFB(buf,57)=5;
+ clif_send(buf, packet_len_table[0x7b], &sd->bl, SELF);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_move(struct block_list *bl) {
+ struct view_data *vd;
+ struct unit_data *ud;
+ unsigned char buf[256];
+ int len;
+
+ nullpo_retr(0, bl);
+
+ vd = status_get_viewdata(bl);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return 0;
+
+ ud = unit_bl2ud(bl);
+ nullpo_retr(0, ud);
+
+ len = clif_set007b(bl,vd,ud,buf);
+ clif_send(buf,len,bl,AREA_WOS);
+ if (disguised(bl))
+ clif_setdisguise((TBL_PC*)bl, buf, len, 0);
+
+ //Stupid client that needs this resent every time someone walks :X
+ if(vd->cloth_color)
+ clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS);
+
+ switch(bl->type)
+ {
+ case BL_PC:
+ {
+ TBL_PC *sd = ((TBL_PC*)bl);
+// clif_movepc(sd);
+ if(sd->state.size==2) // tiny/big players [Valaris]
+ clif_specialeffect(&sd->bl,423,AREA);
+ else if(sd->state.size==1)
+ clif_specialeffect(&sd->bl,421,AREA);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB *md = ((TBL_MOB*)bl);
+ if(md->special_state.size==2) // tiny/big mobs [Valaris]
+ clif_specialeffect(&md->bl,423,AREA);
+ else if(md->special_state.size==1)
+ clif_specialeffect(&md->bl,421,AREA);
+ }
+ break;
+ }
+ return 0;
+}
+
+
+/*==========================================
+ * Delays the map_quit of a player after they are disconnected. [Skotlex]
+ *------------------------------------------
+ */
+static int clif_delayquit(int tid, unsigned int tick, int id, int data) {
+ struct map_session_data *sd = NULL;
+
+ //Remove player from map server
+ if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player.
+ map_quit(sd);
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_quitsave(int fd,struct map_session_data *sd)
+{
+ if (sd->state.waitingdisconnect || //Was already waiting to be disconnected.
+ !battle_config.prevent_logout ||
+ DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
+ map_quit(sd);
+ else if (sd->fd)
+ { //Disassociate session from player (session is deleted after this function was called)
+ //And set a timer to make him quit later.
+ session[sd->fd]->session_data = NULL;
+ sd->fd = 0;
+ add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0);
+ }
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+static int clif_waitclose(int tid, unsigned int tick, int id, int data) {
+ if (session[id] && session[id]->func_parse == clif_parse) //Avoid disconnecting non-players, as pointed out by End of Exam [Skotlex]
+ session[id]->eof = 1;
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_setwaitclose(int fd) {
+ struct map_session_data *sd;
+
+ // if player is not already in the game (double connection probably)
+ if ((sd = (struct map_session_data*)session[fd]->session_data) == NULL) {
+ // limited timer, just to send information.
+ add_timer(gettick() + 1000, clif_waitclose, fd, 0);
+ } else
+ add_timer(gettick() + 5000, clif_waitclose, fd, 0);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_changemap(struct map_session_data *sd, short map, int x, int y) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd = sd->fd;
+
+ WFIFOHEAD(fd, packet_len_table[0x91]);
+ WFIFOW(fd,0) = 0x91;
+ memcpy(WFIFOP(fd,2), mapindex_id2name(map), MAP_NAME_LENGTH);
+ WFIFOW(fd,18) = x;
+ WFIFOW(fd,20) = y;
+ WFIFOSET(fd, packet_len_table[0x91]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_changemapserver(struct map_session_data *sd, char *mapname, int x, int y, int ip, int port) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd = sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x92]);
+ WFIFOW(fd,0) = 0x92;
+ //Better not trust the null-terminator is there. [Skotlex]
+ memcpy(WFIFOP(fd,2), mapname, MAP_NAME_LENGTH);
+ WFIFOB(fd,17) = 0; //Null terminator for mapname
+ WFIFOW(fd,18) = x;
+ WFIFOW(fd,20) = y;
+ WFIFOL(fd,22) = ip;
+ WFIFOW(fd,26) = port;
+ WFIFOSET(fd, packet_len_table[0x92]);
+
+ return 0;
+}
+
+int clif_blown(struct block_list *bl) {
+//Previous Aegis versions simply used clif_fixpos, but it seems clif_slide works better on current clients.
+// return clif_fixpos(bl);
+ return clif_slide(bl, bl->x, bl->y);
+
+}
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_fixpos(struct block_list *bl) {
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x88;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=bl->x;
+ WBUFW(buf,8)=bl->y;
+ clif_send(buf, packet_len_table[0x88], bl, AREA);
+ if (disguised(bl)) {
+ WBUFL(buf,2)=-bl->id;
+ clif_send(buf, packet_len_table[0x88], bl, SELF);
+ }
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_npcbuysell(struct map_session_data* sd, int id) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0xc4]);
+ WFIFOW(fd,0)=0xc4;
+ WFIFOL(fd,2)=id;
+ WFIFOSET(fd,packet_len_table[0xc4]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_buylist(struct map_session_data *sd, struct npc_data *nd) {
+ struct item_data *id;
+ int fd,i,val;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, nd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, 200 * 11 + 4);
+ WFIFOW(fd,0)=0xc6;
+ for(i=0;nd->u.shop_item[i].nameid > 0;i++){
+ id = itemdb_search(nd->u.shop_item[i].nameid);
+ val=nd->u.shop_item[i].value;
+ WFIFOL(fd,4+i*11)=val;
+ if (!id->flag.value_notdc)
+ val=pc_modifybuyvalue(sd,val);
+ WFIFOL(fd,8+i*11)=val;
+ WFIFOB(fd,12+i*11)=itemtype(id->type);
+ if (id->view_id > 0)
+ WFIFOW(fd,13+i*11)=id->view_id;
+ else
+ WFIFOW(fd,13+i*11)=nd->u.shop_item[i].nameid;
+ }
+ WFIFOW(fd,2)=i*11+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_selllist(struct map_session_data *sd) {
+ int fd,i,c=0,val;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4);
+ WFIFOW(fd,0)=0xc7;
+ for(i=0;i<MAX_INVENTORY;i++) {
+ if(sd->status.inventory[i].nameid > 0 && sd->inventory_data[i]) {
+ if (!itemdb_cansell(&sd->status.inventory[i], pc_isGM(sd)))
+ continue;
+
+ val=sd->inventory_data[i]->value_sell;
+ if (val < 0)
+ continue;
+ WFIFOW(fd,4+c*10)=i+2;
+ WFIFOL(fd,6+c*10)=val;
+ if (!sd->inventory_data[i]->flag.value_notoc)
+ val=pc_modifysellvalue(sd,val);
+ WFIFOL(fd,10+c*10)=val;
+ c++;
+ }
+ }
+ WFIFOW(fd,2)=c*10+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_scriptmes(struct map_session_data *sd, int npcid, char *mes) {
+ int fd = sd->fd;
+ int slen = strlen(mes) + 9;
+ WFIFOHEAD(fd, slen);
+ WFIFOW(fd,0)=0xb4;
+ WFIFOW(fd,2)=slen;
+ WFIFOL(fd,4)=npcid;
+ strcpy((char*)WFIFOP(fd,8),mes);
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_scriptnext(struct map_session_data *sd,int npcid) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0xb5]);
+ WFIFOW(fd,0)=0xb5;
+ WFIFOL(fd,2)=npcid;
+ WFIFOSET(fd,packet_len_table[0xb5]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_scriptclose(struct map_session_data *sd, int npcid) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0xb6]);
+ WFIFOW(fd,0)=0xb6;
+ WFIFOL(fd,2)=npcid;
+ WFIFOSET(fd,packet_len_table[0xb6]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
+ int fd = sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x78]);
+ sd->state.using_fake_npc = 1;
+ malloc_set(WFIFOP(fd,0), 0, packet_len_table[0x78]);
+ WFIFOW(fd,0)=0x78;
+ WFIFOL(fd,2)=npcid;
+ WFIFOW(fd,14)=111;
+ WFIFOPOS(fd,46,sd->bl.x,sd->bl.y,sd->ud.dir);
+ WFIFOB(fd,49)=5;
+ WFIFOB(fd,50)=5;
+ WFIFOSET(fd, packet_len_table[0x78]);
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_scriptmenu(struct map_session_data *sd, int npcid, char *mes) {
+ int fd = sd->fd;
+ int slen = strlen(mes) + 8;
+ struct block_list *bl = NULL;
+ WFIFOHEAD(fd, slen);
+
+ if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
+ bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
+ clif_sendfakenpc(sd, npcid);
+
+ WFIFOW(fd,0)=0xb7;
+ WFIFOW(fd,2)=slen;
+ WFIFOL(fd,4)=npcid;
+ strcpy((char*)WFIFOP(fd,8),mes);
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_scriptinput(struct map_session_data *sd, int npcid) {
+ int fd;
+ struct block_list *bl = NULL;
+
+ nullpo_retr(0, sd);
+
+ if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
+ bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
+ clif_sendfakenpc(sd, npcid);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x142]);
+ WFIFOW(fd,0)=0x142;
+ WFIFOL(fd,2)=npcid;
+ WFIFOSET(fd,packet_len_table[0x142]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_scriptinputstr(struct map_session_data *sd, int npcid) {
+ int fd;
+ struct block_list *bl = NULL;
+
+ nullpo_retr(0, sd);
+
+ if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
+ bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
+ clif_sendfakenpc(sd, npcid);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x1d4]);
+ WFIFOW(fd,0)=0x1d4;
+ WFIFOL(fd,2)=npcid;
+ WFIFOSET(fd,packet_len_table[0x1d4]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x144]);
+ WFIFOW(fd,0)=0x144;
+ WFIFOL(fd,2)=npc_id;
+ WFIFOL(fd,6)=type;
+ WFIFOL(fd,10)=x;
+ WFIFOL(fd,14)=y;
+ WFIFOB(fd,18)=id;
+ WFIFOL(fd,19)=color;
+ WFIFOSET(fd,packet_len_table[0x144]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_cutin(struct map_session_data *sd, char *image, int type) {
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x1b3]);
+ WFIFOW(fd,0)=0x1b3;
+ strncpy((char*)WFIFOP(fd,2),image,64);
+ WFIFOB(fd,66)=type;
+ WFIFOSET(fd,packet_len_table[0x1b3]);
+
+ return 0;
+}
+
+/*==========================================
+ * Fills in card data from the given item and into the buffer. [Skotlex]
+ *------------------------------------------
+ */
+static void clif_addcards(unsigned char* buf, struct item* item)
+{
+ int i=0,j;
+ if (item == NULL) { //Blank data
+ WBUFW(buf,0)=0;
+ WBUFW(buf,2)=0;
+ WBUFW(buf,4)=0;
+ WBUFW(buf,6)=0;
+ return;
+ }
+ if(item->card[0]==CARD0_PET) { //pet eggs
+ WBUFW(buf,0)=0;
+ WBUFW(buf,2)=0;
+ WBUFW(buf,4)=0;
+ WBUFW(buf,6)=item->card[3]; //Pet renamed flag.
+ return;
+ }
+ if(item->card[0]==CARD0_FORGE || item->card[0]==CARD0_CREATE) { //Forged/created items
+ WBUFW(buf,0)=item->card[0];
+ WBUFW(buf,2)=item->card[1];
+ WBUFW(buf,4)=item->card[2];
+ WBUFW(buf,6)=item->card[3];
+ return;
+ }
+ //Client only receives four cards.. so randomly send them a set of cards. [Skotlex]
+ if (MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4)
+ i = rand()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rand()%3;
+
+ //Normal items.
+ if (item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
+ WBUFW(buf,0)=j;
+ else
+ WBUFW(buf,0)= item->card[i];
+
+ if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
+ WBUFW(buf,2)=j;
+ else
+ WBUFW(buf,2)=item->card[i];
+
+ if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
+ WBUFW(buf,4)=j;
+ else
+ WBUFW(buf,4)=item->card[i];
+
+ if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0)
+ WBUFW(buf,6)=j;
+ else
+ WBUFW(buf,6)=item->card[i];
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
+ int fd;
+ unsigned char *buf;
+
+ nullpo_retr(0, sd);
+
+ fd = sd->fd;
+ if (!session_isActive(fd)) //Sasuke-
+ return 0;
+
+ WFIFOHEAD(fd,packet_len_table[0xa0]);
+ buf = WFIFOP(fd,0);
+ if(fail) {
+ WBUFW(buf,0)=0xa0;
+ WBUFW(buf,2)=n+2;
+ WBUFW(buf,4)=amount;
+ WBUFW(buf,6)=0;
+ WBUFB(buf,8)=0;
+ WBUFB(buf,9)=0;
+ WBUFB(buf,10)=0;
+ WBUFW(buf,11)=0;
+ WBUFW(buf,13)=0;
+ WBUFW(buf,15)=0;
+ WBUFW(buf,17)=0;
+ WBUFW(buf,19)=0;
+ WBUFB(buf,21)=0;
+ WBUFB(buf,22)=fail;
+ } else {
+ if (n<0 || n>=MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL)
+ return 1;
+
+ WBUFW(buf,0)=0xa0;
+ WBUFW(buf,2)=n+2;
+ WBUFW(buf,4)=amount;
+ if (sd->inventory_data[n]->view_id > 0)
+ WBUFW(buf,6)=sd->inventory_data[n]->view_id;
+ else
+ WBUFW(buf,6)=sd->status.inventory[n].nameid;
+ WBUFB(buf,8)=sd->status.inventory[n].identify;
+ WBUFB(buf,9)=sd->status.inventory[n].attribute;
+ WBUFB(buf,10)=sd->status.inventory[n].refine;
+ clif_addcards(WBUFP(buf,11), &sd->status.inventory[n]);
+ WBUFW(buf,19)=pc_equippoint(sd,n);
+ WBUFB(buf,21)=itemtype(sd->inventory_data[n]->type);
+ WBUFB(buf,22)=fail;
+ }
+
+ WFIFOSET(fd,packet_len_table[0xa0]);
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_delitem(struct map_session_data *sd,int n,int amount)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0xaf]);
+ WFIFOW(fd,0)=0xaf;
+ WFIFOW(fd,2)=n+2;
+ WFIFOW(fd,4)=amount;
+
+ WFIFOSET(fd,packet_len_table[0xaf]);
+
+ return 0;
+}
+
+// Simplifies inventory/cart/storage packets by handling the packet section relevant to items. [Skotlex]
+// Equip is >= 0 for equippable items (holds the equip-point, is 0 for pet
+// armor/egg) -1 for stackable items, -2 for stackable items where arrows must send in the equip-point.
+void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip)
+{
+ if (id->view_id > 0)
+ WBUFW(buf,n)=id->view_id;
+ else
+ WBUFW(buf,n)=i->nameid;
+ WBUFB(buf,n+2)=itemtype(id->type);
+ WBUFB(buf,n+3)=i->identify;
+ if (equip >= 0) { //Equippable item
+ WBUFW(buf,n+4)=equip;
+ WBUFW(buf,n+6)=i->equip;
+ WBUFB(buf,n+8)=i->attribute;
+ WBUFB(buf,n+9)=i->refine;
+ } else { //Stackable item.
+ WBUFW(buf,n+4)=i->amount;
+ if (equip == -2 && id->equip == EQP_AMMO)
+ WBUFW(buf,n+6)=EQP_AMMO;
+ else
+ WBUFW(buf,n+6)=0;
+ }
+
+}
+
+//Unified inventory function which sends all of the inventory (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
+void clif_inventorylist(struct map_session_data *sd)
+{
+ int i,n,ne,fd = sd->fd,arrow=-1;
+ unsigned char *buf;
+ unsigned char bufe[MAX_INVENTORY*20+4];
+#if PACKETVER < 5
+ const int s = 10; //Entry size.
+#else
+ const int s = 18;
+#endif
+ WFIFOHEAD(fd, MAX_INVENTORY * s + 4);
+ buf = WFIFOP(fd,0);
+
+ for(i=0,n=0,ne=0;i<MAX_INVENTORY;i++){
+ if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
+ continue;
+
+ if(!itemdb_isstackable2(sd->inventory_data[i]))
+ { //Non-stackable (Equippable)
+ WBUFW(bufe,ne*20+4)=i+2;
+ clif_item_sub(bufe, ne*20+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
+ clif_addcards(WBUFP(bufe, ne*20+16), &sd->status.inventory[i]);
+ ne++;
+ } else { //Stackable.
+ WBUFW(buf,n*s+4)=i+2;
+ clif_item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2);
+ if (sd->inventory_data[i]->equip == EQP_AMMO &&
+ sd->status.inventory[i].equip)
+ arrow=i;
+#if PACKETVER >= 5
+ clif_addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]);
+#endif
+ n++;
+ }
+ }
+ if (n) {
+#if PACKETVER < 5
+ WBUFW(buf,0)=0xa3;
+#else
+ WBUFW(buf,0)=0x1ee;
+#endif
+ WBUFW(buf,2)=4+n*s;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ if(arrow >= 0)
+ clif_arrowequip(sd,arrow);
+
+ if(ne){
+ WBUFW(bufe,0)=0xa4;
+ WBUFW(bufe,2)=4+ne*20;
+ clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ }
+
+}
+
+//Required when items break/get-repaired. Only sends equippable item list.
+void clif_equiplist(struct map_session_data *sd)
+{
+ int i,n,fd = sd->fd;
+ unsigned char *buf;
+ WFIFOHEAD(fd, MAX_INVENTORY * 20 + 4);
+ buf = WFIFOP(fd,0);
+
+ for(i=0,n=0;i<MAX_INVENTORY;i++){
+ if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
+ continue;
+
+ if(itemdb_isstackable2(sd->inventory_data[i]))
+ continue;
+ //Equippable
+ WBUFW(buf,n*20+4)=i+2;
+ clif_item_sub(buf, n*20+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
+ clif_addcards(WBUFP(buf, n*20+16), &sd->status.inventory[i]);
+ n++;
+ }
+ if (n) {
+ WBUFW(buf,0)=0xa4;
+ WBUFW(buf,2)=4+n*20;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+}
+
+//Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
+void clif_storagelist(struct map_session_data *sd,struct storage *stor)
+{
+ struct item_data *id;
+ int i,n,ne,fd=sd->fd;
+ unsigned char *buf;
+ unsigned char bufe[MAX_STORAGE*20+4];
+#if PACKETVER < 5
+ const int s = 10; //Entry size.
+#else
+ const int s = 18;
+#endif
+ WFIFOHEAD(fd,MAX_STORAGE * s + 4);
+ buf = WFIFOP(fd,0);
+
+ for(i=0,n=0,ne=0;i<MAX_STORAGE;i++){
+ if(stor->storage_[i].nameid<=0)
+ continue;
+ id = itemdb_search(stor->storage_[i].nameid);
+ if(!itemdb_isstackable2(id))
+ { //Equippable
+ WBUFW(bufe,ne*20+4)=i+1;
+ clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
+ clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
+ ne++;
+ } else { //Stackable
+ WBUFW(buf,n*s+4)=i+1;
+ clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
+#if PACKETVER >= 5
+ clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
+#endif
+ n++;
+ }
+ }
+ if(n){
+#if PACKETVER < 5
+ WBUFW(buf,0)=0xa5;
+#else
+ WBUFW(buf,0)=0x1f0;
+#endif
+ WBUFW(buf,2)=4+n*s;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ if(ne){
+ WBUFW(bufe,0)=0xa6;
+ WBUFW(bufe,2)=4+ne*20;
+ clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ }
+}
+
+//Unified storage function which sends all of the storage (requires two packets, one for equipable items and one for stackable ones. [Skotlex]
+void clif_guildstoragelist(struct map_session_data *sd,struct guild_storage *stor)
+{
+ struct item_data *id;
+ int i,n,ne,fd=sd->fd;
+ unsigned char *buf;
+ unsigned char bufe[MAX_GUILD_STORAGE*20+4];
+#if PACKETVER < 5
+ const int s = 10; //Entry size.
+#else
+ const int s = 18;
+#endif
+ WFIFOHEAD(fd,MAX_GUILD_STORAGE * s + 4);
+ buf = WFIFOP(fd,0);
+
+ for(i=0,n=0,ne=0;i<MAX_GUILD_STORAGE;i++){
+ if(stor->storage_[i].nameid<=0)
+ continue;
+ id = itemdb_search(stor->storage_[i].nameid);
+ if(!itemdb_isstackable2(id))
+ { //Equippable
+ WBUFW(bufe,ne*20+4)=i+1;
+ clif_item_sub(bufe, ne*20+6, &stor->storage_[i], id, id->equip);
+ clif_addcards(WBUFP(bufe, ne*20+16), &stor->storage_[i]);
+ ne++;
+ } else { //Stackable
+ WBUFW(buf,n*s+4)=i+1;
+ clif_item_sub(buf, n*s+6, &stor->storage_[i], id,-1);
+#if PACKETVER >= 5
+ clif_addcards(WBUFP(buf,n*s+14), &stor->storage_[i]);
+#endif
+ n++;
+ }
+ }
+ if(n){
+#if PACKETVER < 5
+ WBUFW(buf,0)=0xa5;
+#else
+ WBUFW(buf,0)=0x1f0;
+#endif
+ WBUFW(buf,2)=4+n*s;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ if(ne){
+ WBUFW(bufe,0)=0xa6;
+ WBUFW(bufe,2)=4+ne*20;
+ clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ }
+}
+
+void clif_cartlist(struct map_session_data *sd)
+{
+ struct item_data *id;
+ int i,n,ne,fd=sd->fd;
+ unsigned char *buf;
+ unsigned char bufe[MAX_CART*20+4];
+#if PACKETVER < 5
+ const int s = 10; //Entry size.
+#else
+ const int s = 18;
+#endif
+ WFIFOHEAD(fd, MAX_CART * s + 4);
+ buf = WFIFOP(fd,0);
+
+ for(i=0,n=0,ne=0;i<MAX_CART;i++){
+ if(sd->status.cart[i].nameid<=0)
+ continue;
+ id = itemdb_search(sd->status.cart[i].nameid);
+ if(!itemdb_isstackable2(id))
+ { //Equippable
+ WBUFW(bufe,ne*20+4)=i+2;
+ clif_item_sub(bufe, ne*20+6, &sd->status.cart[i], id, id->equip);
+ clif_addcards(WBUFP(bufe, ne*20+16), &sd->status.cart[i]);
+ ne++;
+ } else { //Stackable
+ WBUFW(buf,n*s+4)=i+2;
+ clif_item_sub(buf, n*s+6, &sd->status.cart[i], id,-1);
+#if PACKETVER >= 5
+ clif_addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]);
+#endif
+ n++;
+ }
+ }
+ if(n){
+#if PACKETVER < 5
+ WBUFW(buf,0)=0x123;
+#else
+ WBUFW(buf,0)=0x1ef;
+#endif
+ WBUFW(buf,2)=4+n*s;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ if(ne){
+ WBUFW(bufe,0)=0x122;
+ WBUFW(bufe,2)=4+ne*20;
+ clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF);
+ }
+ return;
+}
+
+// Guild XY locators [Valaris]
+int clif_guild_xy(struct map_session_data *sd)
+{
+ unsigned char buf[10];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x1eb;
+ WBUFL(buf,2)=sd->status.account_id;
+ WBUFW(buf,6)=sd->bl.x;
+ WBUFW(buf,8)=sd->bl.y;
+ clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
+
+ return 0;
+}
+
+/*==========================================
+ * Sends x/y dot to a single fd. [Skotlex]
+ *------------------------------------------
+ */
+
+int clif_guild_xy_single(int fd, struct map_session_data *sd)
+{
+ WFIFOHEAD(fd,packet_len_table[0x1eb]);
+ WFIFOW(fd,0)=0x1eb;
+ WFIFOL(fd,2)=sd->status.account_id;
+ WFIFOW(fd,6)=sd->bl.x;
+ WFIFOW(fd,8)=sd->bl.y;
+ WFIFOSET(fd,packet_len_table[0x1eb]);
+ return 0;
+}
+
+// Guild XY locators [Valaris]
+int clif_guild_xy_remove(struct map_session_data *sd)
+{
+ unsigned char buf[10];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x1eb;
+ WBUFL(buf,2)=sd->status.account_id;
+ WBUFW(buf,6)=-1;
+ WBUFW(buf,8)=-1;
+ clif_send(buf,packet_len_table[0x1eb],&sd->bl,GUILD_SAMEMAP_WOS);
+
+ return 0;
+}
+
+/*==========================================
+ * ステータスを送りつける
+ * 表示専用数字はこの中で計算して送る
+ *------------------------------------------
+ */
+int clif_updatestatus(struct map_session_data *sd,int type)
+{
+ int fd,len=8;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+
+ if ( !session_isActive(fd) ) // Invalid pointer fix, by sasuke [Kevin]
+ return 0;
+
+ WFIFOHEAD(fd, 14);
+ WFIFOW(fd,0)=0xb0;
+ WFIFOW(fd,2)=type;
+ switch(type){
+ // 00b0
+ case SP_WEIGHT:
+ pc_checkweighticon(sd);
+ WFIFOW(fd,0)=0xb0; //Need to re-set as pc_checkweighticon can alter the buffer. [Skotlex]
+ WFIFOW(fd,2)=type;
+ WFIFOL(fd,4)=sd->weight;
+ break;
+ case SP_MAXWEIGHT:
+ WFIFOL(fd,4)=sd->max_weight;
+ break;
+ case SP_SPEED:
+ WFIFOL(fd,4)=sd->battle_status.speed;
+ break;
+ case SP_BASELEVEL:
+ WFIFOL(fd,4)=sd->status.base_level;
+ break;
+ case SP_JOBLEVEL:
+ WFIFOL(fd,4)=sd->status.job_level;
+ break;
+ case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance]
+ WFIFOL(fd,4)=sd->status.karma;
+ break;
+ case SP_MANNER:
+ WFIFOL(fd,4)=sd->status.manner;
+ clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner);
+ break;
+ case SP_STATUSPOINT:
+ WFIFOL(fd,4)=sd->status.status_point;
+ break;
+ case SP_SKILLPOINT:
+ WFIFOL(fd,4)=sd->status.skill_point;
+ break;
+ case SP_HIT:
+ WFIFOL(fd,4)=sd->battle_status.hit;
+ break;
+ case SP_FLEE1:
+ WFIFOL(fd,4)=sd->battle_status.flee;
+ break;
+ case SP_FLEE2:
+ WFIFOL(fd,4)=sd->battle_status.flee2/10;
+ break;
+ case SP_MAXHP:
+ WFIFOL(fd,4)=sd->battle_status.max_hp;
+ break;
+ case SP_MAXSP:
+ WFIFOL(fd,4)=sd->battle_status.max_sp;
+ break;
+ case SP_HP:
+ WFIFOL(fd,4)=sd->battle_status.hp;
+ if (battle_config.disp_hpmeter)
+ clif_hpmeter(sd);
+ if (!battle_config.party_hp_mode && sd->status.party_id)
+ clif_party_hp(sd);
+ break;
+ case SP_SP:
+ WFIFOL(fd,4)=sd->battle_status.sp;
+ break;
+ case SP_ASPD:
+ WFIFOL(fd,4)=sd->battle_status.amotion;
+ break;
+ case SP_ATK1:
+ WFIFOL(fd,4)=sd->battle_status.batk +sd->battle_status.rhw.atk +sd->battle_status.lhw->atk;
+ break;
+ case SP_DEF1:
+ WFIFOL(fd,4)=sd->battle_status.def;
+ break;
+ case SP_MDEF1:
+ WFIFOL(fd,4)=sd->battle_status.mdef;
+ break;
+ case SP_ATK2:
+ WFIFOL(fd,4)=sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2;
+ break;
+ case SP_DEF2:
+ WFIFOL(fd,4)=sd->battle_status.def2;
+ break;
+ case SP_MDEF2:
+ //negative check (in case you have something like Berserk active)
+ len = sd->battle_status.mdef2 - (sd->battle_status.vit>>1);
+ if (len < 0) len = 0;
+ WFIFOL(fd,4)= len;
+ len = 8;
+ break;
+ case SP_CRITICAL:
+ WFIFOL(fd,4)=sd->battle_status.cri/10;
+ break;
+ case SP_MATK1:
+ WFIFOL(fd,4)=sd->battle_status.matk_max;
+ break;
+ case SP_MATK2:
+ WFIFOL(fd,4)=sd->battle_status.matk_min;
+ break;
+
+
+ case SP_ZENY:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=sd->status.zeny;
+ break;
+ case SP_BASEEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=sd->status.base_exp;
+ break;
+ case SP_JOBEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=sd->status.job_exp;
+ break;
+ case SP_NEXTBASEEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=pc_nextbaseexp(sd);
+ break;
+ case SP_NEXTJOBEXP:
+ WFIFOW(fd,0)=0xb1;
+ WFIFOL(fd,4)=pc_nextjobexp(sd);
+ break;
+
+ // 00be 終了
+ case SP_USTR:
+ case SP_UAGI:
+ case SP_UVIT:
+ case SP_UINT:
+ case SP_UDEX:
+ case SP_ULUK:
+ WFIFOW(fd,0)=0xbe;
+ WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR);
+ len=5;
+ break;
+
+ // 013a 終了
+ case SP_ATTACKRANGE:
+ WFIFOW(fd,0)=0x13a;
+ WFIFOW(fd,2)=sd->battle_status.rhw.range;
+ len=4;
+ break;
+
+ // 0141 終了
+ case SP_STR:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.str;
+ WFIFOL(fd,10)=sd->battle_status.str - sd->status.str;
+ len=14;
+ break;
+ case SP_AGI:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.agi;
+ WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi;
+ len=14;
+ break;
+ case SP_VIT:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.vit;
+ WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit;
+ len=14;
+ break;
+ case SP_INT:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.int_;
+ WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_;
+ len=14;
+ break;
+ case SP_DEX:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.dex;
+ WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex;
+ len=14;
+ break;
+ case SP_LUK:
+ WFIFOW(fd,0)=0x141;
+ WFIFOL(fd,2)=type;
+ WFIFOL(fd,6)=sd->status.luk;
+ WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk;
+ len=14;
+ break;
+
+ case SP_CARTINFO:
+ WFIFOW(fd,0)=0x121;
+ WFIFOW(fd,2)=sd->cart_num;
+ WFIFOW(fd,4)=sd->cart_max_num;
+ WFIFOL(fd,6)=sd->cart_weight;
+ WFIFOL(fd,10)=sd->cart_max_weight;
+ len=14;
+ break;
+
+ default:
+ if(battle_config.error_log)
+ ShowError("clif_updatestatus : unrecognized type %d\n",type);
+ return 1;
+ }
+ WFIFOSET(fd,len);
+
+ return 0;
+}
+int clif_changestatus(struct block_list *bl,int type,int val)
+{
+ unsigned char buf[12];
+ struct map_session_data *sd = NULL;
+
+ nullpo_retr(0, bl);
+
+ if(bl->type == BL_PC)
+ sd = (struct map_session_data *)bl;
+
+//printf("clif_changestatus id:%d type:%d val:%d\n",bl->id,type,val);
+ if(sd){
+ WBUFW(buf,0)=0x1ab;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=type;
+ switch(type){
+ case SP_MANNER:
+ WBUFL(buf,8)=val;
+ break;
+ default:
+ if(battle_config.error_log)
+ ShowError("clif_changestatus : unrecognized type %d.\n",type);
+ return 1;
+ }
+ clif_send(buf,packet_len_table[0x1ab],bl,AREA_WOS);
+ }
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_changelook(struct block_list *bl,int type,int val)
+{
+ unsigned char buf[32];
+ struct map_session_data *sd = NULL;
+ struct view_data *vd;
+ vd = status_get_viewdata(bl);
+ nullpo_retr(0, vd);
+
+ BL_CAST(BL_PC, bl, sd);
+
+ switch(type) {
+ case LOOK_WEAPON:
+ if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
+ else vd->weapon = val;
+ break;
+ case LOOK_SHIELD:
+ if (sd) clif_get_weapon_view(sd, &vd->weapon, &vd->shield);
+ else vd->shield = val;
+ break;
+ case LOOK_BASE:
+ vd->class_ = val;
+ if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS)
+ vd->weapon = vd->shield = 0;
+ if (vd->cloth_color && (
+ (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
+ (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
+ ))
+ clif_changelook(bl,LOOK_CLOTHES_COLOR,0);
+ break;
+ case LOOK_HAIR:
+ vd->hair_style = val;
+ break;
+ case LOOK_HEAD_BOTTOM:
+ vd->head_bottom = val;
+ break;
+ case LOOK_HEAD_TOP:
+ vd->head_top = val;
+ break;
+ case LOOK_HEAD_MID:
+ vd->head_mid = val;
+ break;
+ case LOOK_HAIR_COLOR:
+ vd->hair_color = val;
+ break;
+ case LOOK_CLOTHES_COLOR:
+ if (val && (
+ (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) ||
+ (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette)
+ ))
+ val = 0;
+ vd->cloth_color = val;
+ break;
+ case LOOK_SHOES:
+#if PACKETVER > 3
+ if (sd) {
+ int n;
+ if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) {
+ if(sd->inventory_data[n]->view_id > 0)
+ val = sd->inventory_data[n]->view_id;
+ else
+ val = sd->status.inventory[n].nameid;
+ }
+ val = 0;
+ }
+#endif
+ //Shoes? No packet uses this....
+ break;
+ }
+#if PACKETVER < 4
+ WBUFW(buf,0)=0xc3;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=type;
+ WBUFB(buf,7)=val;
+ clif_send(buf,packet_len_table[0xc3],bl,AREA);
+#else
+ if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
+ WBUFW(buf,0)=0x1d7;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=LOOK_WEAPON;
+ WBUFW(buf,7)=vd->weapon;
+ WBUFW(buf,9)=vd->shield;
+ clif_send(buf,packet_len_table[0x1d7],bl,AREA);
+ }
+ else
+ {
+ WBUFW(buf,0)=0x1d7;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=type;
+ WBUFW(buf,7)=val;
+ WBUFW(buf,9)=0;
+ clif_send(buf,packet_len_table[0x1d7],bl,AREA);
+ }
+#endif
+ return 0;
+}
+
+//Sends a change-base-look packet required for traps as they are triggered.
+void clif_changetraplook(struct block_list *bl,int val)
+{
+ unsigned char buf[32];
+#if PACKETVER < 4
+ WBUFW(buf,0)=0xc3;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=LOOK_BASE;
+ WBUFB(buf,7)=val;
+ clif_send(buf,packet_len_table[0xc3],bl,AREA);
+#else
+ WBUFW(buf,0)=0x1d7;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=LOOK_BASE;
+ WBUFW(buf,7)=val;
+ WBUFW(buf,9)=0;
+ clif_send(buf,packet_len_table[0x1d7],bl,AREA);
+#endif
+
+
+}
+//For the stupid cloth-dye bug. Resends the given view data
+//to the area specified by bl.
+void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area)
+{
+ unsigned char buf[32];
+#if PACKETVER < 4
+ WBUFW(buf,0)=0xc3;
+ WBUFL(buf,2)=id;
+ WBUFB(buf,6)=type;
+ WBUFB(buf,7)=val;
+ clif_send(buf,packet_len_table[0xc3],bl,area);
+#else
+ WBUFW(buf,0)=0x1d7;
+ WBUFL(buf,2)=id;
+ WBUFB(buf,6)=type;
+ WBUFW(buf,7)=val;
+ WBUFW(buf,9)=0;
+ clif_send(buf,packet_len_table[0x1d7],bl,area);
+#endif
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_initialstatus(struct map_session_data *sd)
+{
+ int fd;
+ unsigned char *buf;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xbd]);
+ buf=WFIFOP(fd,0);
+
+ WBUFW(buf,0)=0xbd;
+ WBUFW(buf,2)=(sd->status.status_point > SHRT_MAX)? SHRT_MAX:sd->status.status_point;
+ WBUFB(buf,4)=(sd->status.str > UCHAR_MAX)? UCHAR_MAX:sd->status.str;
+ WBUFB(buf,5)=pc_need_status_point(sd,SP_STR);
+ WBUFB(buf,6)=(sd->status.agi > UCHAR_MAX)? UCHAR_MAX:sd->status.agi;
+ WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI);
+ WBUFB(buf,8)=(sd->status.vit > UCHAR_MAX)? UCHAR_MAX:sd->status.vit;
+ WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT);
+ WBUFB(buf,10)=(sd->status.int_ > UCHAR_MAX)? UCHAR_MAX:sd->status.int_;
+ WBUFB(buf,11)=pc_need_status_point(sd,SP_INT);
+ WBUFB(buf,12)=(sd->status.dex > UCHAR_MAX)? UCHAR_MAX:sd->status.dex;
+ WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX);
+ WBUFB(buf,14)=(sd->status.luk > UCHAR_MAX)? UCHAR_MAX:sd->status.luk;
+ WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK);
+
+ WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw->atk;
+ WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2; //atk bonus
+ WBUFW(buf,20) = sd->battle_status.matk_max;
+ WBUFW(buf,22) = sd->battle_status.matk_min;
+ WBUFW(buf,24) = sd->battle_status.def; // def
+ WBUFW(buf,26) = sd->battle_status.def2;
+ WBUFW(buf,28) = sd->battle_status.mdef; // mdef
+ fd = sd->battle_status.mdef2 - (sd->battle_status.vit>>1);
+ if (fd < 0) fd = 0; //Negative check for Frenzy'ed characters.
+ WBUFW(buf,30) = fd;
+ fd = sd->fd;
+ WBUFW(buf,32) = sd->battle_status.hit;
+ WBUFW(buf,34) = sd->battle_status.flee;
+ WBUFW(buf,36) = sd->battle_status.flee2/10;
+ WBUFW(buf,38) = sd->battle_status.cri/10;
+ WBUFW(buf,40) = sd->status.karma;
+ WBUFW(buf,42) = sd->status.manner;
+
+ WFIFOSET(fd,packet_len_table[0xbd]);
+
+ clif_updatestatus(sd,SP_STR);
+ clif_updatestatus(sd,SP_AGI);
+ clif_updatestatus(sd,SP_VIT);
+ clif_updatestatus(sd,SP_INT);
+ clif_updatestatus(sd,SP_DEX);
+ clif_updatestatus(sd,SP_LUK);
+
+ clif_updatestatus(sd,SP_ATTACKRANGE);
+ clif_updatestatus(sd,SP_ASPD);
+
+ return 0;
+}
+
+/*==========================================
+ *矢装備
+ *------------------------------------------
+ */
+int clif_arrowequip(struct map_session_data *sd,int val)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ pc_stop_attack(sd); // [Valaris]
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x013c]);
+ WFIFOW(fd,0)=0x013c;
+ WFIFOW(fd,2)=val+2;//矢のアイテムID
+
+ WFIFOSET(fd,packet_len_table[0x013c]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_arrow_fail(struct map_session_data *sd,int type)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, packet_len_table[0x013b]);
+ WFIFOW(fd,0)=0x013b;
+ WFIFOW(fd,2)=type;
+
+ WFIFOSET(fd,packet_len_table[0x013b]);
+
+ return 0;
+}
+
+/*==========================================
+ * 作成可能 矢リスト送信
+ *------------------------------------------
+ */
+int clif_arrow_create_list(struct map_session_data *sd)
+{
+ int i, c, j;
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd = sd->fd;
+ WFIFOHEAD(fd, MAX_SKILL_ARROW_DB*2+4);
+ WFIFOW(fd,0) = 0x1ad;
+
+ for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
+ if (skill_arrow_db[i].nameid > 0 &&
+ (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 &&
+ !sd->status.inventory[j].equip && sd->status.inventory[j].identify)
+ {
+ if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0)
+ WFIFOW(fd,c*2+4) = j;
+ else
+ WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid;
+ c++;
+ }
+ }
+ WFIFOW(fd,2) = c*2+4;
+ WFIFOSET(fd, WFIFOW(fd,2));
+ if (c > 0) {
+ sd->menuskill_id = AC_MAKINGARROW;
+ sd->menuskill_lv = c;
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_statusupack(struct map_session_data *sd,int type,int ok,int val)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xbc]);
+ WFIFOW(fd,0)=0xbc;
+ WFIFOW(fd,2)=type;
+ WFIFOB(fd,4)=ok;
+ WFIFOB(fd,5)=val;
+ WFIFOSET(fd,packet_len_table[0xbc]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xaa]);
+ WFIFOW(fd,0)=0xaa;
+ WFIFOW(fd,2)=n+2;
+ WFIFOW(fd,4)=pos;
+ WFIFOB(fd,6)=ok;
+ WFIFOSET(fd,packet_len_table[0xaa]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xac]);
+ WFIFOW(fd,0)=0xac;
+ WFIFOW(fd,2)=n+2;
+ WFIFOW(fd,4)=pos;
+ WFIFOB(fd,6)=ok;
+ WFIFOSET(fd,packet_len_table[0xac]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_misceffect(struct block_list* bl,int type)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0) = 0x19b;
+ WBUFL(buf,2) = bl->id;
+ WBUFL(buf,6) = type;
+
+ clif_send(buf,packet_len_table[0x19b],bl,AREA);
+
+ return 0;
+}
+int clif_misceffect2(struct block_list *bl, int type) {
+ unsigned char buf[24];
+
+ nullpo_retr(0, bl);
+
+ malloc_set(buf, 0, packet_len_table[0x1f3]);
+
+ WBUFW(buf,0) = 0x1f3;
+ WBUFL(buf,2) = bl->id;
+ WBUFL(buf,6) = type;
+
+ clif_send(buf, packet_len_table[0x1f3], bl, AREA);
+
+ return 0;
+
+}
+/*==========================================
+ * 表示オプション変更
+ *------------------------------------------
+ */
+int clif_changeoption(struct block_list* bl)
+{
+ unsigned char buf[32];
+ struct status_change *sc;
+
+ nullpo_retr(0, bl);
+ sc = status_get_sc(bl);
+ if (!sc) return 0; //How can an option change if there's no sc?
+
+#if PACKETVER > 6
+ WBUFW(buf,0) = 0x229;
+ WBUFL(buf,2) = bl->id;
+ WBUFW(buf,6) = sc->opt1;
+ WBUFW(buf,8) = sc->opt2;
+ WBUFL(buf,10) = sc->option;
+ WBUFB(buf,14) = 0; // ??
+ if(disguised(bl)) {
+ clif_send(buf,packet_len_table[0x229],bl,AREA_WOS);
+ WBUFL(buf,2) = -bl->id;
+ clif_send(buf,packet_len_table[0x229],bl,SELF);
+ WBUFL(buf,2) = bl->id;
+ WBUFL(buf,10) = OPTION_INVISIBLE;
+ clif_send(buf,packet_len_table[0x229],bl,SELF);
+ } else
+ clif_send(buf,packet_len_table[0x229],bl,AREA);
+#else
+ WBUFW(buf,0) = 0x119;
+ WBUFL(buf,2) = bl->id;
+ WBUFW(buf,6) = sc->opt1;
+ WBUFW(buf,8) = sc->opt2;
+ WBUFW(buf,10) = sc->option;
+ WBUFB(buf,12) = 0; // ??
+ if(disguised(bl)) {
+ clif_send(buf,packet_len_table[0x119],bl,AREA_WOS);
+ WBUFL(buf,2) = -bl->id;
+ clif_send(buf,packet_len_table[0x119],bl,SELF);
+ WBUFL(buf,2) = bl->id;
+ WBUFW(buf,10) = OPTION_INVISIBLE;
+ clif_send(buf,packet_len_table[0x119],bl,SELF);
+ } else
+ clif_send(buf,packet_len_table[0x119],bl,AREA);
+#endif
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_useitemack(struct map_session_data *sd,int index,int amount,int ok)
+{
+ nullpo_retr(0, sd);
+
+ if(!ok) {
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xa8]);
+ WFIFOW(fd,0)=0xa8;
+ WFIFOW(fd,2)=index+2;
+ WFIFOW(fd,4)=amount;
+ WFIFOB(fd,6)=ok;
+ WFIFOSET(fd,packet_len_table[0xa8]);
+ }
+ else {
+#if PACKETVER < 3
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xa8]);
+ WFIFOW(fd,0)=0xa8;
+ WFIFOW(fd,2)=index+2;
+ WFIFOW(fd,4)=amount;
+ WFIFOB(fd,6)=ok;
+ WFIFOSET(fd,packet_len_table[0xa8]);
+#else
+ unsigned char buf[32];
+
+ WBUFW(buf,0)=0x1c8;
+ WBUFW(buf,2)=index+2;
+ if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
+ WBUFW(buf,4)=sd->inventory_data[index]->view_id;
+ else
+ WBUFW(buf,4)=sd->status.inventory[index].nameid;
+ WBUFL(buf,6)=sd->bl.id;
+ WBUFW(buf,10)=amount;
+ WBUFB(buf,12)=ok;
+ clif_send(buf,packet_len_table[0x1c8],&sd->bl,AREA);
+#endif
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_createchat(struct map_session_data *sd,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xd6]);
+ WFIFOW(fd,0)=0xd6;
+ WFIFOB(fd,2)=fail;
+ WFIFOSET(fd,packet_len_table[0xd6]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_dispchat(struct chat_data *cd,int fd)
+{
+ unsigned char buf[128]; // 最大title(60バイト)+17
+
+ if(cd==NULL || *cd->owner==NULL)
+ return 1;
+
+ WBUFW(buf,0)=0xd7;
+ WBUFW(buf,2)=strlen((const char*)cd->title)+17;
+ WBUFL(buf,4)=(*cd->owner)->id;
+ WBUFL(buf,8)=cd->bl.id;
+ WBUFW(buf,12)=cd->limit;
+ WBUFW(buf,14)=cd->users;
+ WBUFB(buf,16)=cd->pub;
+ strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
+ if(fd){
+ WFIFOHEAD(fd, WBUFW(buf,2));
+ memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
+ WFIFOSET(fd,WBUFW(buf,2));
+ } else {
+ clif_send(buf,WBUFW(buf,2),*cd->owner,AREA_WOSC);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * chatの状態変更成功
+ * 外部の人用と命令コード(d7->df)が違うだけ
+ *------------------------------------------
+ */
+int clif_changechatstatus(struct chat_data *cd)
+{
+ unsigned char buf[128]; // 最大title(60バイト)+17
+
+ if(cd==NULL || cd->usersd[0]==NULL)
+ return 1;
+
+ WBUFW(buf,0)=0xdf;
+ WBUFW(buf,2)=strlen((char*)cd->title)+17;
+ WBUFL(buf,4)=cd->usersd[0]->bl.id;
+ WBUFL(buf,8)=cd->bl.id;
+ WBUFW(buf,12)=cd->limit;
+ WBUFW(buf,14)=cd->users;
+ WBUFB(buf,16)=cd->pub;
+ strcpy((char*)WBUFP(buf,17),(const char*)cd->title);
+ clif_send(buf,WBUFW(buf,2),&cd->usersd[0]->bl,CHAT);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_clearchat(struct chat_data *cd,int fd)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, cd);
+
+ WBUFW(buf,0)=0xd8;
+ WBUFL(buf,2)=cd->bl.id;
+ if(fd){
+ WFIFOHEAD(fd,packet_len_table[0xd8]);
+ memcpy(WFIFOP(fd,0),buf,packet_len_table[0xd8]);
+ WFIFOSET(fd,packet_len_table[0xd8]);
+ } else {
+ clif_send(buf,packet_len_table[0xd8],*cd->owner,AREA_WOSC);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_joinchatfail(struct map_session_data *sd,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+
+ WFIFOHEAD(fd,packet_len_table[0xda]);
+ WFIFOW(fd,0)=0xda;
+ WFIFOB(fd,2)=fail;
+ WFIFOSET(fd,packet_len_table[0xda]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_joinchatok(struct map_session_data *sd,struct chat_data* cd)
+{
+ int fd;
+ int i;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, cd);
+
+ fd = sd->fd;
+ if (!session_isActive(fd))
+ return 0;
+ WFIFOHEAD(fd, 8 + (28*cd->users));
+ WFIFOW(fd, 0) = 0xdb;
+ WFIFOW(fd, 2) = 8 + (28*cd->users);
+ WFIFOL(fd, 4) = cd->bl.id;
+ for (i = 0; i < cd->users; i++) {
+ WFIFOL(fd, 8+i*28) = (i!=0) || ((*cd->owner)->type == BL_NPC);
+ memcpy(WFIFOP(fd, 8+i*28+4), cd->usersd[i]->status.name, NAME_LENGTH);
+ }
+ WFIFOSET(fd, WFIFOW(fd, 2));
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_addchat(struct chat_data* cd,struct map_session_data *sd)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, cd);
+
+ WBUFW(buf, 0) = 0x0dc;
+ WBUFW(buf, 2) = cd->users;
+ memcpy(WBUFP(buf, 4),sd->status.name,NAME_LENGTH);
+ clif_send(buf,packet_len_table[0xdc],&sd->bl,CHAT_WOS);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_changechatowner(struct chat_data* cd,struct map_session_data *sd)
+{
+ unsigned char buf[64];
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, cd);
+
+ WBUFW(buf, 0) = 0xe1;
+ WBUFL(buf, 2) = 1;
+ memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,NAME_LENGTH);
+ WBUFW(buf,30) = 0xe1;
+ WBUFL(buf,32) = 0;
+ memcpy(WBUFP(buf,36),sd->status.name,NAME_LENGTH);
+
+ clif_send(buf,packet_len_table[0xe1]*2,&sd->bl,CHAT);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_leavechat(struct chat_data* cd,struct map_session_data *sd)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, cd);
+
+ WBUFW(buf, 0) = 0xdd;
+ WBUFW(buf, 2) = cd->users-1;
+ memcpy(WBUFP(buf,4),sd->status.name,NAME_LENGTH);
+ WBUFB(buf,28) = 0;
+
+ clif_send(buf,packet_len_table[0xdd],&sd->bl,CHAT);
+
+ return 0;
+}
+
+/*==========================================
+ * 取り引き要請受け
+ *------------------------------------------
+ */
+int clif_traderequest(struct map_session_data *sd,char *name)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+
+ WFIFOHEAD(fd,packet_len_table[0xe5]);
+ WFIFOW(fd,0)=0xe5;
+
+ strcpy((char*)WFIFOP(fd,2),name);
+
+ WFIFOSET(fd,packet_len_table[0xe5]);
+
+ return 0;
+}
+
+/*==========================================
+ * 取り引き要求応答
+ *------------------------------------------
+ */
+int clif_tradestart(struct map_session_data *sd,int type)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xe7]);
+ WFIFOW(fd,0)=0xe7;
+ WFIFOB(fd,2)=type;
+ WFIFOSET(fd,packet_len_table[0xe7]);
+
+ return 0;
+}
+
+/*==========================================
+ * 相手方からのアイテム追加
+ *------------------------------------------
+ */
+int clif_tradeadditem(struct map_session_data *sd,struct map_session_data *tsd,int index,int amount)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, tsd);
+
+ fd=tsd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xe9]);
+ WFIFOW(fd,0)=0xe9;
+ WFIFOL(fd,2)=amount;
+ if(index==0){
+ WFIFOW(fd,6) = 0; // type id
+ WFIFOB(fd,8) = 0; //identify flag
+ WFIFOB(fd,9) = 0; // attribute
+ WFIFOB(fd,10)= 0; //refine
+ WFIFOW(fd,11)= 0; //card (4w)
+ WFIFOW(fd,13)= 0; //card (4w)
+ WFIFOW(fd,15)= 0; //card (4w)
+ WFIFOW(fd,17)= 0; //card (4w)
+ }
+ else{
+ index-=2; //index fix
+ if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0)
+ WFIFOW(fd,6) = sd->inventory_data[index]->view_id;
+ else
+ WFIFOW(fd,6) = sd->status.inventory[index].nameid; // type id
+ WFIFOB(fd,8) = sd->status.inventory[index].identify; //identify flag
+ WFIFOB(fd,9) = sd->status.inventory[index].attribute; // attribute
+ WFIFOB(fd,10)= sd->status.inventory[index].refine; //refine
+ clif_addcards(WFIFOP(fd, 11), &sd->status.inventory[index]);
+ }
+ WFIFOSET(fd,packet_len_table[0xe9]);
+
+ return 0;
+}
+
+/*==========================================
+ * アイテム追加成功/失敗
+ *------------------------------------------
+ */
+int clif_tradeitemok(struct map_session_data *sd,int index,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xea]);
+ WFIFOW(fd,0)=0xea;
+ WFIFOW(fd,2)=index;
+ WFIFOB(fd,4)=fail;
+ WFIFOSET(fd,packet_len_table[0xea]);
+
+ return 0;
+}
+
+/*==========================================
+ * 取り引きok押し
+ *------------------------------------------
+ */
+int clif_tradedeal_lock(struct map_session_data *sd,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xec]);
+ WFIFOW(fd,0)=0xec;
+ WFIFOB(fd,2)=fail; // 0=you 1=the other person
+ WFIFOSET(fd,packet_len_table[0xec]);
+
+ return 0;
+}
+
+/*==========================================
+ * 取り引きがキャンセルされました
+ *------------------------------------------
+ */
+int clif_tradecancelled(struct map_session_data *sd)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xee]);
+ WFIFOW(fd,0)=0xee;
+ WFIFOSET(fd,packet_len_table[0xee]);
+
+ return 0;
+}
+
+/*==========================================
+ * 取り引き完了
+ *------------------------------------------
+ */
+int clif_tradecompleted(struct map_session_data *sd,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf0]);
+ WFIFOW(fd,0)=0xf0;
+ WFIFOB(fd,2)=fail;
+ WFIFOSET(fd,packet_len_table[0xf0]);
+
+ return 0;
+}
+
+/*==========================================
+ * カプラ倉庫のアイテム数を更新
+ *------------------------------------------
+ */
+int clif_updatestorageamount(struct map_session_data *sd,struct storage *stor)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, stor);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf2]);
+ WFIFOW(fd,0) = 0xf2; // update storage amount
+ WFIFOW(fd,2) = stor->storage_amount; //items
+ WFIFOW(fd,4) = MAX_STORAGE; //items max
+ WFIFOSET(fd,packet_len_table[0xf2]);
+
+ return 0;
+}
+
+/*==========================================
+ * カプラ倉庫にアイテムを追加する
+ *------------------------------------------
+ */
+int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int index,int amount)
+{
+ int view,fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, stor);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf4]);
+ WFIFOW(fd,0) =0xf4; // Storage item added
+ WFIFOW(fd,2) =index+1; // index
+ WFIFOL(fd,4) =amount; // amount
+ if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
+ WFIFOW(fd,8) =view;
+ else
+ WFIFOW(fd,8) =stor->storage_[index].nameid; // id
+ WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
+ WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
+ WFIFOB(fd,12)=stor->storage_[index].refine; //refine
+ clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
+ WFIFOSET(fd,packet_len_table[0xf4]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, stor);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf2]);
+ WFIFOW(fd,0) = 0xf2; // update storage amount
+ WFIFOW(fd,2) = stor->storage_amount; //items
+ WFIFOW(fd,4) = MAX_GUILD_STORAGE; //items max
+ WFIFOSET(fd,packet_len_table[0xf2]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount)
+{
+ int view,fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, stor);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf4]);
+ WFIFOW(fd,0) =0xf4; // Storage item added
+ WFIFOW(fd,2) =index+1; // index
+ WFIFOL(fd,4) =amount; // amount
+ if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
+ WFIFOW(fd,8) =view;
+ else
+ WFIFOW(fd,8) =stor->storage_[index].nameid; // id
+ WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
+ WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
+ WFIFOB(fd,12)=stor->storage_[index].refine; //refine
+ clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
+ WFIFOSET(fd,packet_len_table[0xf4]);
+
+ return 0;
+}
+
+/*==========================================
+ * カプラ倉庫からアイテムを取り去る
+ *------------------------------------------
+ */
+int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf6]);
+ WFIFOW(fd,0)=0xf6; // Storage item removed
+ WFIFOW(fd,2)=index+1;
+ WFIFOL(fd,4)=amount;
+ WFIFOSET(fd,packet_len_table[0xf6]);
+
+ return 0;
+}
+
+/*==========================================
+ * カプラ倉庫を閉じる
+ *------------------------------------------
+ */
+int clif_storageclose(struct map_session_data *sd)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xf8]);
+ WFIFOW(fd,0)=0xf8; // Storage Closed
+ WFIFOSET(fd,packet_len_table[0xf8]);
+
+ return 0;
+}
+
+//
+// callback系 ?
+//
+/*==========================================
+ * PC表示
+ *------------------------------------------
+ */
+void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd)
+{
+ int len;
+ if(dstsd->chatID){
+ struct chat_data *cd;
+ cd=(struct chat_data*)map_id2bl(dstsd->chatID);
+ if(cd && cd->usersd[0]==dstsd)
+ clif_dispchat(cd,sd->fd);
+ }
+ if(dstsd->vender_id)
+ clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
+
+ if(dstsd->spiritball > 0)
+ clif_spiritball_single(sd->fd, dstsd);
+
+ if((sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
+ (battle_config.disp_hpmeter && (len = pc_isGM(sd)) >= battle_config.disp_hpmeter && len >= pc_isGM(dstsd))
+ )
+ clif_hpmeter_single(sd->fd, dstsd);
+
+ if(dstsd->status.manner < 0)
+ clif_changestatus(&dstsd->bl,SP_MANNER,dstsd->status.manner);
+
+ // pvp circle for duel [LuzZza]
+ /*
+ if(dstsd->duel_group)
+ clif_specialeffect(&dstsd->bl, 159, 4);
+ */
+
+}
+void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
+{
+ struct unit_data *ud;
+ struct view_data *vd;
+ int len, fd = sd->fd;
+
+ vd = status_get_viewdata(bl);
+
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return;
+
+ ud = unit_bl2ud(bl);
+ if (ud && ud->walktimer != -1)
+ {
+#if PACKETVER > 6
+ WFIFOHEAD(fd, packet_len_table[0x22c]);
+#elif PACKETVER > 3
+ WFIFOHEAD(fd, packet_len_table[0x1da]);
+#else
+ WFIFOHEAD(fd, packet_len_table[0x7b]);
+#endif
+ len = clif_set007b(bl,vd,ud,WFIFOP(fd,0));
+ WFIFOSET(fd,len);
+ } else {
+#if PACKETVER > 6
+ WFIFOHEAD(fd,packet_len_table[0x22a]);
+#elif PACKETVER > 3
+ WFIFOHEAD(fd,packet_len_table[0x1d8]);
+#else
+ WFIFOHEAD(fd,packet_len_table[0x78]);
+#endif
+ len = clif_set0078(bl,vd,WFIFOP(fd,0));
+ WFIFOSET(fd,len);
+ }
+
+ if (vd->cloth_color)
+ clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
+
+ switch (bl->type)
+ {
+ case BL_PC:
+ {
+ TBL_PC* tsd = (TBL_PC*)bl;
+ clif_getareachar_pc(sd, tsd);
+ if(tsd->state.size==2) // tiny/big players [Valaris]
+ clif_specialeffect(bl,423,AREA);
+ else if(tsd->state.size==1)
+ clif_specialeffect(bl,421,AREA);
+ }
+ break;
+ case BL_NPC:
+ {
+ if(((TBL_NPC*)bl)->chat_id)
+ clif_dispchat((struct chat_data*)map_id2bl(((TBL_NPC*)bl)->chat_id),sd->fd);
+ }
+ break;
+ case BL_MOB:
+ {
+ TBL_MOB* md = (TBL_MOB*)bl;
+ if(md->special_state.size==2) // tiny/big mobs [Valaris]
+ clif_specialeffect(bl,423,AREA);
+ else if(md->special_state.size==1)
+ clif_specialeffect(bl,421,AREA);
+ }
+ break;
+ }
+}
+
+/*==========================================
+ * Older fix pos packet.
+ *------------------------------------------
+ */
+int clif_fixpos2(struct block_list* bl)
+{
+ struct unit_data *ud;
+ struct view_data *vd;
+ unsigned char buf[256];
+ int len;
+
+ nullpo_retr(0, bl);
+ ud = unit_bl2ud(bl);
+ vd = status_get_viewdata(bl);
+ if (!vd || vd->class_ == INVISIBLE_CLASS)
+ return 0;
+
+ if(ud && ud->walktimer != -1)
+ len = clif_set007b(bl,vd,ud,buf);
+ else
+ len = clif_set0078(bl,vd,buf);
+
+ if (disguised(bl)) {
+ clif_send(buf,len,bl,AREA_WOS);
+ clif_setdisguise((TBL_PC*)bl, buf, len, 0);
+ clif_setdisguise((TBL_PC*)bl, buf, len, 1);
+ } else
+ clif_send(buf,len,bl,AREA);
+ return 0;
+}
+
+//Modifies the type of damage according to status changes [Skotlex]
+#define clif_calc_delay(type,delay) (type==1||type==4||type==0x0a)?type:(delay==0?9:type)
+
+/*==========================================
+ * Estimates walk delay based on the damage criteria. [Skotlex]
+ *------------------------------------------
+ */
+static int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_) {
+
+ if (type == 4 || type == 9 || damage <=0)
+ return 0;
+
+ if (bl->type == BL_PC) {
+ if (battle_config.pc_walk_delay_rate != 100)
+ delay = delay*battle_config.pc_walk_delay_rate/100;
+ } else
+ if (battle_config.walk_delay_rate != 100)
+ delay = delay*battle_config.walk_delay_rate/100;
+
+ if (div_ > 1) //Multi-hit skills mean higher delays.
+ delay += battle_config.multihit_delay*(div_-1);
+
+ return delay>0?delay:1; //Return 1 to specify there should be no noticeable delay, but you should stop walking.
+}
+
+/*==========================================
+ * 通常攻撃エフェクト&ダメージ
+ *------------------------------------------
+ */
+int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,int type,int damage2)
+{
+ unsigned char buf[256];
+ struct status_change *sc;
+
+ nullpo_retr(0, src);
+ nullpo_retr(0, dst);
+
+ type = clif_calc_delay(type, ddelay); //Type defaults to 0 for normal attacks.
+
+ sc = status_get_sc(dst);
+
+ if(sc && sc->count) {
+ if(sc->data[SC_HALLUCINATION].timer != -1) {
+ if(damage > 0)
+ damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
+ if(damage2 > 0)
+ damage2 = damage2*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
+ }
+ }
+
+ WBUFW(buf,0)=0x8a;
+ WBUFL(buf,2)=src->id;
+ WBUFL(buf,6)=dst->id;
+ WBUFL(buf,10)=tick;
+ WBUFL(buf,14)=sdelay;
+ WBUFL(buf,18)=ddelay;
+ if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ WBUFW(buf,22)=damage?div:0;
+ WBUFW(buf,27)=damage2?div:0;
+ } else {
+ WBUFW(buf,22)=(damage > SHRT_MAX)?SHRT_MAX:damage;
+ WBUFW(buf,27)=damage2;
+ }
+ WBUFW(buf,24)=div;
+ WBUFB(buf,26)=type;
+ clif_send(buf,packet_len_table[0x8a],src,AREA);
+
+ if(disguised(src)) {
+ WBUFL(buf,2)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,22)=-1;
+ if(damage2 > 0)
+ WBUFW(buf,27)=-1;
+ clif_send(buf,packet_len_table[0x8a],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,6)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,2)=src->id;
+ else {
+ if(damage > 0)
+ WBUFW(buf,22)=-1;
+ if(damage2 > 0)
+ WBUFW(buf,27)=-1;
+ }
+ clif_send(buf,packet_len_table[0x8a],dst,SELF);
+ }
+ //Return adjusted can't walk delay for further processing.
+ return clif_calc_walkdelay(dst,ddelay,type,damage+damage2,div);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem)
+{
+ int view,fd;
+ fd=sd->fd;
+ //009d <ID>.l <item ID>.w <identify flag>.B <X>.w <Y>.w <amount>.w <subX>.B <subY>.B
+ WFIFOHEAD(fd,packet_len_table[0x9d]);
+
+ WFIFOW(fd,0)=0x9d;
+ WFIFOL(fd,2)=fitem->bl.id;
+ if((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
+ WFIFOW(fd,6)=view;
+ else
+ WFIFOW(fd,6)=fitem->item_data.nameid;
+ WFIFOB(fd,8)=fitem->item_data.identify;
+ WFIFOW(fd,9)=fitem->bl.x;
+ WFIFOW(fd,11)=fitem->bl.y;
+ WFIFOW(fd,13)=fitem->item_data.amount;
+ WFIFOB(fd,15)=fitem->subx;
+ WFIFOB(fd,16)=fitem->suby;
+ WFIFOSET(fd,packet_len_table[0x9d]);
+}
+
+/*==========================================
+ * 場所スキルエフェクトが視界に入る
+ *------------------------------------------
+ */
+int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit)
+{
+ int fd;
+ struct block_list *bl;
+
+ fd=sd->fd;
+ bl=map_id2bl(unit->group->src_id);
+#if PACKETVER >= 3
+ if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
+ WFIFOHEAD(fd,packet_len_table[0x1c9]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
+ WFIFOW(fd, 0)=0x1c9;
+ WFIFOL(fd, 2)=unit->bl.id;
+ WFIFOL(fd, 6)=unit->group->src_id;
+ WFIFOW(fd,10)=unit->bl.x;
+ WFIFOW(fd,12)=unit->bl.y; // might be typo? [Lance]
+ WFIFOB(fd,14)=unit->group->unit_id;
+ WFIFOB(fd,15)=1;
+ WFIFOB(fd,16)=1;
+ memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
+ WFIFOSET(fd,packet_len_table[0x1c9]);
+ return 0;
+ }
+#endif
+ WFIFOHEAD(fd,packet_len_table[0x11f]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x11f]);
+ WFIFOW(fd, 0)=0x11f;
+ WFIFOL(fd, 2)=unit->bl.id;
+ WFIFOL(fd, 6)=unit->group->src_id;
+ WFIFOW(fd,10)=unit->bl.x;
+ WFIFOW(fd,12)=unit->bl.y;
+ //Use invisible unit id for traps.
+ if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP)
+ WFIFOB(fd,14)=UNT_ATTACK_SKILLS;
+ else
+ WFIFOB(fd,14)=unit->group->unit_id;
+ WFIFOB(fd,15)=0;
+ WFIFOSET(fd,packet_len_table[0x11f]);
+
+ if(unit->group->skill_id == WZ_ICEWALL)
+ clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
+ return 0;
+/* Previous implementation guess of packet 0x1c9, who can understand what all those fields are for? [Skotlex]
+ WFIFOHEAD(fd,packet_len_table[0x1c9]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x1c9]);
+ WFIFOW(fd, 0)=0x1c9;
+ WFIFOL(fd, 2)=unit->bl.id;
+ WFIFOL(fd, 6)=unit->group->src_id;
+ WFIFOW(fd,10)=unit->bl.x;
+ WFIFOW(fd,12)=unit->bl.y;
+ WFIFOB(fd,14)=unit->group->unit_id;
+ WFIFOB(fd,15)=1;
+ if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
+ WFIFOB(fd,16)=1;
+ memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
+ } else {
+ WFIFOL(fd,15+1)=0; //1-4調べた限り固定
+ WFIFOL(fd,15+5)=0; //5-8調べた限り固定
+ //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
+ WFIFOL(fd,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
+ WFIFOL(fd,15+17)=0x004f37dd; //17-20調べた限り固定
+ WFIFOL(fd,15+21)=0x0012f674; //21-24調べた限り固定
+ WFIFOL(fd,15+25)=0x0012f664; //25-28調べた限り固定
+ WFIFOL(fd,15+29)=0x0012f654; //29-32調べた限り固定
+ WFIFOL(fd,15+33)=0x77527bbc; //33-36調べた限り固定
+ //37-39
+ WFIFOB(fd,15+40)=0x2d; //40調べた限り固定
+ WFIFOL(fd,15+41)=0; //41-44調べた限り0固定
+ WFIFOL(fd,15+45)=0; //45-48調べた限り0固定
+ WFIFOL(fd,15+49)=0; //49-52調べた限り0固定
+ WFIFOL(fd,15+53)=0x0048d919; //53-56調べた限り固定
+ WFIFOL(fd,15+57)=0x0000003e; //57-60調べた限り固定
+ WFIFOL(fd,15+61)=0x0012f66c; //61-64調べた限り固定
+ //65-68
+ //69-72
+ if(bl) WFIFOL(fd,15+73)=bl->y; //73-76術者のY座標
+ WFIFOL(fd,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
+ WFIFOB(fd,15+81)=0xaa; //81終端文字0xaa
+ }
+
+ WFIFOSET(fd,packet_len_table[0x1c9]);
+#endif
+ if(unit->group->skill_id == WZ_ICEWALL)
+ clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
+
+ return 0;
+*/
+}
+
+/*==========================================
+ * 場所スキルエフェクトが視界から消える
+ *------------------------------------------
+ */
+int clif_clearchar_skillunit(struct skill_unit *unit,int fd)
+{
+ nullpo_retr(0, unit);
+
+ WFIFOHEAD(fd,packet_len_table[0x120]);
+ WFIFOW(fd, 0)=0x120;
+ WFIFOL(fd, 2)=unit->bl.id;
+ WFIFOSET(fd,packet_len_table[0x120]);
+ if(unit->group && unit->group->skill_id == WZ_ICEWALL)
+ clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_01ac(struct block_list *bl)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf, 0) = 0x1ac;
+ WBUFL(buf, 2) = bl->id;
+
+ clif_send(buf,packet_len_table[0x1ac],bl,AREA);
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+ int clif_getareachar(struct block_list* bl,va_list ap)
+{
+ struct map_session_data *sd;
+
+ nullpo_retr(0, bl);
+ nullpo_retr(0, ap);
+
+ sd=va_arg(ap,struct map_session_data*);
+
+ if (sd == NULL || !sd->fd || session[sd->fd] == NULL)
+ return 0;
+
+ switch(bl->type){
+ case BL_ITEM:
+ clif_getareachar_item(sd,(struct flooritem_data*) bl);
+ break;
+ case BL_SKILL:
+ clif_getareachar_skillunit(sd,(TBL_SKILL*)bl);
+ break;
+ default:
+ if(&sd->bl == bl)
+ break;
+ clif_getareachar_char(sd,bl);
+ break;
+ }
+ return 0;
+}
+
+/*==========================================
+ * tbl has gone out of view-size of bl
+ *------------------------------------------
+ */
+int clif_outsight(struct block_list *bl,va_list ap)
+{
+ struct block_list *tbl;
+ struct view_data *vd;
+ TBL_PC *sd, *tsd;
+ tbl=va_arg(ap,struct block_list*);
+ if(bl == tbl) return 0;
+ BL_CAST(BL_PC, bl, sd);
+ BL_CAST(BL_PC, tbl, tsd);
+
+ if (tsd && tsd->fd)
+ { //tsd has lost sight of the bl object.
+ switch(bl->type){
+ case BL_PC:
+ if (((TBL_PC*)bl)->vd.class_ != INVISIBLE_CLASS)
+ clif_clearchar_id(bl->id,0,tsd->fd);
+ if(sd->chatID){
+ struct chat_data *cd;
+ cd=(struct chat_data*)map_id2bl(sd->chatID);
+ if(cd->usersd[0]==sd)
+ clif_dispchat(cd,tsd->fd);
+ }
+ if(sd->vender_id)
+ clif_closevendingboard(bl,tsd->fd);
+ break;
+ case BL_ITEM:
+ clif_clearflooritem((struct flooritem_data*)bl,tsd->fd);
+ break;
+ case BL_SKILL:
+ clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
+ break;
+ default:
+ if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS)
+ clif_clearchar_id(bl->id,0,tsd->fd);
+ break;
+ }
+ }
+ if (sd && sd->fd)
+ { //sd is watching tbl go out of view.
+ if ((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS)
+ clif_clearchar_id(tbl->id,0,sd->fd);
+ }
+ return 0;
+}
+
+/*==========================================
+ * tbl has come into view of bl
+ *------------------------------------------
+ */
+int clif_insight(struct block_list *bl,va_list ap)
+{
+ struct block_list *tbl;
+ TBL_PC *sd, *tsd;
+ tbl=va_arg(ap,struct block_list*);
+
+ if (bl == tbl) return 0;
+
+ BL_CAST(BL_PC, bl, sd);
+ BL_CAST(BL_PC, tbl, tsd);
+
+ if (tsd && tsd->fd)
+ { //Tell tsd that bl entered into his view
+ switch(bl->type){
+ case BL_ITEM:
+ clif_getareachar_item(tsd,(struct flooritem_data*)bl);
+ break;
+ case BL_SKILL:
+ clif_getareachar_skillunit(tsd,(TBL_SKILL*)bl);
+ break;
+ default:
+ clif_getareachar_char(tsd,bl);
+ break;
+ }
+ }
+ if (sd && sd->fd)
+ { //Tell sd that tbl walked into his view
+ clif_getareachar_char(sd,tbl);
+ }
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
+{
+ int fd,id, inf2;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ if( (id=sd->status.skill[skillid].id) <= 0 )
+ return 0;
+ WFIFOHEAD(fd,packet_len_table[0x147]);
+ WFIFOW(fd,0)=0x147;
+ WFIFOW(fd,2) = id;
+ if(type < 0)
+ WFIFOW(fd,4) = skill_get_inf(id);
+ else
+ WFIFOW(fd,4) = type;
+ WFIFOW(fd,6) = 0;
+ WFIFOW(fd,8) = sd->status.skill[skillid].lv;
+ WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[skillid].lv);
+ if(range < 0)
+ range = skill_get_range2(&sd->bl, id,sd->status.skill[skillid].lv);
+
+ WFIFOW(fd,12)= range;
+ strncpy(WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH);
+ inf2 = skill_get_inf2(id);
+ if(((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
+ !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL))) ||
+ (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill))
+ //WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_get_max(id) && sd->status.skill[skillid].flag ==0 )? 1:0;
+ WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[skillid].flag ==0 )? 1:0;
+ else
+ WFIFOB(fd,38) = 0;
+ WFIFOSET(fd,packet_len_table[0x147]);
+
+ return 0;
+}
+
+/*==========================================
+ * スキルリストを送信する
+ *------------------------------------------
+ */
+int clif_skillinfoblock(struct map_session_data *sd)
+{
+ int fd;
+ int i,c,len=4,id, inf2;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ if (!fd) return 0;
+
+ WFIFOHEAD(fd, MAX_SKILL * 37 + 4);
+ WFIFOW(fd,0)=0x10f;
+ for ( i = c = 0; i < MAX_SKILL; i++){
+ if( (id=sd->status.skill[i].id)!=0 ){
+ WFIFOW(fd,len ) = id;
+ WFIFOW(fd,len+2) = skill_get_inf(id);
+ WFIFOW(fd,len+4) = 0;
+ WFIFOW(fd,len+6) = sd->status.skill[i].lv;
+ WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
+ WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv);
+ strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
+ inf2 = skill_get_inf2(id);
+ if(((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
+ !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL))) ||
+ (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) )
+ WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_) && sd->status.skill[i].flag ==0 )? 1:0;
+ else
+ WFIFOB(fd,len+36) = 0;
+ len+=37;
+ c++;
+ }
+ }
+ WFIFOW(fd,2)=len;
+ WFIFOSET(fd,len);
+
+ return 1;
+}
+
+/*==========================================
+ * スキル割り振り通知
+ *------------------------------------------
+ */
+int clif_skillup(struct map_session_data *sd,int skill_num)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x10e]);
+ WFIFOW(fd,0) = 0x10e;
+ WFIFOW(fd,2) = skill_num;
+ WFIFOW(fd,4) = sd->status.skill[skill_num].lv;
+ WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv);
+ WFIFOW(fd,8) = skill_get_range2(&sd->bl,skill_num,sd->status.skill[skill_num].lv);
+ //WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_get_max(sd->status.skill[skill_num].id)) ? 1 : 0;
+ WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0;
+ WFIFOSET(fd,packet_len_table[0x10e]);
+
+ return 0;
+}
+
+/*==========================================
+ * スキル詠唱エフェクトを送信する
+ *------------------------------------------
+ */
+int clif_skillcasting(struct block_list* bl,
+ int src_id,int dst_id,int dst_x,int dst_y,int skill_num,int casttime)
+{
+ int pl = skill_get_pl(skill_num);
+ unsigned char buf[32];
+ WBUFW(buf,0) = 0x13e;
+ WBUFL(buf,2) = src_id;
+ WBUFL(buf,6) = dst_id;
+ WBUFW(buf,10) = dst_x;
+ WBUFW(buf,12) = dst_y;
+ WBUFW(buf,14) = skill_num;
+ WBUFL(buf,16) = pl<0?0:pl; //Avoid sending negatives as element [Skotlex]
+ WBUFL(buf,20) = casttime;
+ clif_send(buf,packet_len_table[0x13e], bl, AREA);
+ if (disguised(bl)) {
+ WBUFL(buf,2) = -src_id;
+ WBUFL(buf,20) = 0;
+ clif_send(buf,packet_len_table[0x13e], bl, SELF);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_skillcastcancel(struct block_list* bl)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0) = 0x1b9;
+ WBUFL(buf,2) = bl->id;
+ clif_send(buf,packet_len_table[0x1b9], bl, AREA);
+
+ return 0;
+}
+
+/*==========================================
+ * スキル詠唱失敗
+ *------------------------------------------
+ */
+int clif_skill_fail(struct map_session_data *sd,int skill_id,int type,int btype)
+{
+ int fd;
+
+ if (!sd) { //Since this is the most common nullpo....
+ ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id);
+ return 0;
+ }
+
+ fd=sd->fd;
+
+ if(battle_config.display_skill_fail&1)
+ return 0; //Disable all skill failed messages
+
+ if(type==0x4 && !sd->state.showdelay)
+ return 0; //Disable delay failed messages
+
+ if(skill_id == RG_SNATCHER && battle_config.display_skill_fail&4)
+ return 0;
+
+ if(skill_id == TF_POISON && battle_config.display_skill_fail&8)
+ return 0;
+
+ WFIFOHEAD(fd,packet_len_table[0x110]);
+ WFIFOW(fd,0) = 0x110;
+ WFIFOW(fd,2) = skill_id;
+ WFIFOW(fd,4) = btype;
+ WFIFOW(fd,6) = 0;
+ WFIFOB(fd,8) = 0;
+ WFIFOB(fd,9) = type;
+ WFIFOSET(fd,packet_len_table[0x110]);
+
+ return 1;
+}
+
+/*==========================================
+ * スキル攻撃エフェクト&ダメージ
+ *------------------------------------------
+ */
+int clif_skill_damage(struct block_list *src,struct block_list *dst,
+ unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
+{
+ unsigned char buf[64];
+ struct status_change *sc;
+
+ nullpo_retr(0, src);
+ nullpo_retr(0, dst);
+
+ type = (type>0)?type:skill_get_hit(skill_id);
+ type = clif_calc_delay(type, ddelay);
+ sc = status_get_sc(dst);
+
+ if(sc && sc->count) {
+ if(sc->data[SC_HALLUCINATION].timer != -1 && damage > 0)
+ damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
+ }
+
+#if PACKETVER < 3
+ WBUFW(buf,0)=0x114;
+ WBUFW(buf,2)=skill_id;
+ WBUFL(buf,4)=src->id;
+ WBUFL(buf,8)=dst->id;
+ WBUFL(buf,12)=tick;
+ WBUFL(buf,16)=sdelay;
+ WBUFL(buf,20)=ddelay;
+ if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ WBUFW(buf,24)=damage?div:0;
+ } else {
+ WBUFW(buf,24)=damage;
+ }
+ WBUFW(buf,26)=skill_lv;
+ WBUFW(buf,28)=div;
+ WBUFB(buf,30)=type;
+ clif_send(buf,packet_len_table[0x114],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x114],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,8)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,4)=src->id;
+ else if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x114],dst,SELF);
+ }
+#else
+ WBUFW(buf,0)=0x1de;
+ WBUFW(buf,2)=skill_id;
+ WBUFL(buf,4)=src->id;
+ WBUFL(buf,8)=dst->id;
+ WBUFL(buf,12)=tick;
+ WBUFL(buf,16)=sdelay;
+ WBUFL(buf,20)=ddelay;
+ if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ WBUFL(buf,24)=damage?div:0;
+ } else {
+ WBUFL(buf,24)=damage;
+ }
+ WBUFW(buf,28)=skill_lv;
+ WBUFW(buf,30)=div;
+ WBUFB(buf,32)=type;
+ clif_send(buf,packet_len_table[0x1de],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x1de],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,8)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,4)=src->id;
+ else if(damage > 0)
+ WBUFW(buf,24)=-1;
+ clif_send(buf,packet_len_table[0x1de],dst,SELF);
+ }
+#endif
+
+ //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
+ return clif_calc_walkdelay(dst,ddelay,type,damage,div);
+}
+
+/*==========================================
+ * 吹き飛ばしスキル攻撃エフェクト&ダメージ
+ *------------------------------------------
+ */
+int clif_skill_damage2(struct block_list *src,struct block_list *dst,
+ unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type)
+{
+ unsigned char buf[64];
+ struct status_change *sc;
+
+ nullpo_retr(0, src);
+ nullpo_retr(0, dst);
+
+ type = (type>0)?type:skill_get_hit(skill_id);
+ type = clif_calc_delay(type, ddelay);
+ sc = status_get_sc(dst);
+
+ if(sc && sc->count) {
+ if(sc->data[SC_HALLUCINATION].timer != -1 && damage > 0)
+ damage = damage*(5+sc->data[SC_HALLUCINATION].val1) + rand()%100;
+ }
+
+ WBUFW(buf,0)=0x115;
+ WBUFW(buf,2)=skill_id;
+ WBUFL(buf,4)=src->id;
+ WBUFL(buf,8)=dst->id;
+ WBUFL(buf,12)=tick;
+ WBUFL(buf,16)=sdelay;
+ WBUFL(buf,20)=ddelay;
+ WBUFW(buf,24)=dst->x;
+ WBUFW(buf,26)=dst->y;
+ if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
+ WBUFW(buf,28)=damage?div:0;
+ } else {
+ WBUFW(buf,28)=damage;
+ }
+ WBUFW(buf,30)=skill_lv;
+ WBUFW(buf,32)=div;
+ WBUFB(buf,34)=type;
+ clif_send(buf,packet_len_table[0x115],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ if(damage > 0)
+ WBUFW(buf,28)=-1;
+ clif_send(buf,packet_len_table[0x115],src,SELF);
+ }
+ if (disguised(dst)) {
+ WBUFL(buf,8)=-dst->id;
+ if (disguised(src))
+ WBUFL(buf,4)=src->id;
+ else if(damage > 0)
+ WBUFW(buf,28)=-1;
+ clif_send(buf,packet_len_table[0x115],dst,SELF);
+ }
+
+ //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex]
+ return clif_calc_walkdelay(dst,ddelay,type,damage,div);
+}
+
+/*==========================================
+ * 支援/回復スキルエフェクト
+ *------------------------------------------
+ */
+int clif_skill_nodamage(struct block_list *src,struct block_list *dst,
+ int skill_id,int heal,int fail)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, dst);
+
+ WBUFW(buf,0)=0x11a;
+ WBUFW(buf,2)=skill_id;
+ WBUFW(buf,4)=(heal > SHRT_MAX)? SHRT_MAX:heal;
+ WBUFL(buf,6)=dst->id;
+ WBUFL(buf,10)=src?src->id:0;
+ WBUFB(buf,14)=fail;
+ clif_send(buf,packet_len_table[0x11a],dst,AREA);
+
+ if (disguised(dst)) {
+ WBUFL(buf,6)=-dst->id;
+ clif_send(buf,packet_len_table[0x115],dst,SELF);
+ }
+
+ if(src && disguised(src)) {
+ WBUFL(buf,10)=-src->id;
+ if (disguised(dst))
+ WBUFL(buf,6)=dst->id;
+ clif_send(buf,packet_len_table[0x115],src,SELF);
+ }
+
+ return fail;
+}
+
+/*==========================================
+ * 場所スキルエフェクト
+ *------------------------------------------
+ */
+int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, src);
+
+ WBUFW(buf,0)=0x117;
+ WBUFW(buf,2)=skill_id;
+ WBUFL(buf,4)=src->id;
+ WBUFW(buf,8)=val;
+ WBUFW(buf,10)=x;
+ WBUFW(buf,12)=y;
+ WBUFL(buf,14)=tick;
+ clif_send(buf,packet_len_table[0x117],src,AREA);
+ if(disguised(src)) {
+ WBUFL(buf,4)=-src->id;
+ clif_send(buf,packet_len_table[0x117],src,SELF);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * 場所スキルエフェクト表示
+ *------------------------------------------
+ */
+int clif_skill_setunit(struct skill_unit *unit)
+{
+ unsigned char buf[128];
+ struct block_list *bl;
+
+ nullpo_retr(0, unit);
+
+ bl=map_id2bl(unit->group->src_id);
+
+// These are invisible client-side, but are necessary because
+// otherwise the client will not know who caused the attack.
+// if (unit->group->unit_id == UNT_ATTACK_SKILLS)
+// return 0;
+
+#if PACKETVER >= 3
+ if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
+ malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
+ WBUFW(buf, 0)=0x1c9;
+ WBUFL(buf, 2)=unit->bl.id;
+ WBUFL(buf, 6)=unit->group->src_id;
+ WBUFW(buf,10)=unit->bl.x;
+ WBUFW(buf,12)=unit->bl.y;
+ if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
+ WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
+ } else {
+ WBUFB(buf,14)=unit->group->unit_id;
+ }
+ WBUFB(buf,15)=1;
+ WBUFB(buf,16)=1;
+ memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
+ clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
+ return 0;
+ }
+#endif
+ malloc_set(WBUFP(buf, 0),0,packet_len_table[0x11f]);
+ WBUFW(buf, 0)=0x11f;
+ WBUFL(buf, 2)=unit->bl.id;
+ WBUFL(buf, 6)=unit->group->src_id;
+ WBUFW(buf,10)=unit->bl.x;
+ WBUFW(buf,12)=unit->bl.y;
+ if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
+ WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
+ } else {
+ WBUFB(buf,14)=unit->group->unit_id;
+ }
+ WBUFB(buf,15)=0;
+ clif_send(buf,packet_len_table[0x11f],&unit->bl,AREA);
+ return 0;
+
+/* Previous mysterious implementation noone really understands. [Skotlex]
+ malloc_set(WBUFP(buf, 0),0,packet_len_table[0x1c9]);
+ WBUFW(buf, 0)=0x1c9;
+ WBUFL(buf, 2)=unit->bl.id;
+ WBUFL(buf, 6)=unit->group->src_id;
+ WBUFW(buf,10)=unit->bl.x;
+ WBUFW(buf,12)=unit->bl.y;
+ WBUFB(buf,14)=unit->group->unit_id;
+ WBUFB(buf,15)=1;
+ if(unit->group->unit_id==0xb0) { // Graffiti [Valaris]
+ WBUFB(buf,16)=1;
+ memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
+ } else {
+ WBUFL(buf,15+1)=0; //1-4調べた限り固定
+ WBUFL(buf,15+5)=0; //5-8調べた限り固定
+ //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
+ WBUFL(buf,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
+ WBUFL(buf,15+17)=0x004f37dd; //17-20調べた限り固定(0x1b2で0x004fdbddだった)
+ WBUFL(buf,15+21)=0x0012f674; //21-24調べた限り固定
+ WBUFL(buf,15+25)=0x0012f664; //25-28調べた限り固定
+ WBUFL(buf,15+29)=0x0012f654; //29-32調べた限り固定
+ WBUFL(buf,15+33)=0x77527bbc; //33-36調べた限り固定
+ //37-39
+ WBUFB(buf,15+40)=0x2d; //40調べた限り固定
+ WBUFL(buf,15+41)=0; //41-44調べた限り0固定
+ WBUFL(buf,15+45)=0; //45-48調べた限り0固定
+ WBUFL(buf,15+49)=0; //49-52調べた限り0固定
+ WBUFL(buf,15+53)=0x0048d919; //53-56調べた限り固定(0x01b2で0x00495119だった)
+ WBUFL(buf,15+57)=0x0000003e; //57-60調べた限り固定
+ WBUFL(buf,15+61)=0x0012f66c; //61-64調べた限り固定
+ //65-68
+ //69-72
+ if(bl) WBUFL(buf,15+73)=bl->y; //73-76術者のY座標
+ WBUFL(buf,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
+ WBUFB(buf,15+81)=0xaa; //81終端文字0xaa
+ }
+ clif_send(buf,packet_len_table[0x1c9],&unit->bl,AREA);
+#endif
+ return 0;
+*/
+}
+/*==========================================
+ * 場所スキルエフェクト削除
+ *------------------------------------------
+ */
+int clif_skill_delunit(struct skill_unit *unit)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, unit);
+
+ WBUFW(buf, 0)=0x120;
+ WBUFL(buf, 2)=unit->bl.id;
+ clif_send(buf,packet_len_table[0x120],&unit->bl,AREA);
+ return 0;
+}
+/*==========================================
+ * ワープ場所選択
+ *------------------------------------------
+ */
+int clif_skill_warppoint(struct map_session_data *sd,int skill_num,int skill_lv,
+ const char *map1,const char *map2,const char *map3,const char *map4)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x11c]);
+ WFIFOW(fd,0)=0x11c;
+ WFIFOW(fd,2)=skill_num;
+ strncpy((char*)WFIFOP(fd, 4),map1,MAP_NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,20),map2,MAP_NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,36),map3,MAP_NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,52),map4,MAP_NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0x11c]);
+ sd->menuskill_id = skill_num;
+ if (skill_num == AL_WARP)
+ sd->menuskill_lv = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here.
+ else
+ sd->menuskill_lv = skill_lv;
+ return 0;
+}
+/*==========================================
+ * メモ応答
+ *------------------------------------------
+ */
+int clif_skill_memo(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+
+ WFIFOHEAD(fd,packet_len_table[0x11e]);
+ WFIFOW(fd,0)=0x11e;
+ WFIFOB(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x11e]);
+ return 0;
+}
+int clif_skill_teleportmessage(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x189]);
+ WFIFOW(fd,0)=0x189;
+ WFIFOW(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x189]);
+ return 0;
+}
+
+/*==========================================
+ * モンスター情報
+ *------------------------------------------
+ */
+int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst)
+{
+ struct status_data *status;
+ unsigned char buf[64];
+ int i;//, fix;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, dst);
+
+ if(dst->type!=BL_MOB )
+ return 0;
+
+ status = status_get_status_data(dst);
+
+ WBUFW(buf, 0)=0x18c;
+ WBUFW(buf, 2)=status_get_class(dst);
+ WBUFW(buf, 4)=status_get_lv(dst);
+ WBUFW(buf, 6)=status->size;
+ WBUFL(buf, 8)=status->hp;
+ WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0)
+ +(battle_config.estimation_type&2?status->def2:0);
+ WBUFW(buf,14)=status->race;
+ WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0)
+ +(battle_config.estimation_type&2?status->mdef2:0);
+ WBUFW(buf,18)= status->def_ele;
+ for(i=0;i<9;i++)
+ WBUFB(buf,20+i)= (unsigned char)battle_attr_fix(NULL,dst,100,i+1,status->def_ele, status->ele_lv);
+// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex]
+// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_fix(NULL,dst,100,i+1,status->def_ele, status->ele_lv))<0?0:fix);
+
+ clif_send(buf,packet_len_table[0x18c],&sd->bl,
+ sd->status.party_id>0?PARTY_SAMEMAP:SELF);
+ return 0;
+}
+/*==========================================
+ * アイテム合成可能リスト
+ *------------------------------------------
+ */
+int clif_skill_produce_mix_list(struct map_session_data *sd, int trigger)
+{
+ int i,c,view,fd;
+ nullpo_retr(0, sd);
+
+ if(sd->menuskill_id == AM_PHARMACY)
+ return 0; //Avoid resending the menu twice or more times...
+ fd=sd->fd;
+ WFIFOHEAD(fd, MAX_SKILL_PRODUCE_DB * 8 + 8);
+ WFIFOW(fd, 0)=0x18d;
+
+ for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){
+ if( skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger, 1) ){
+ if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0)
+ WFIFOW(fd,c*8+ 4)= view;
+ else
+ WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid;
+ WFIFOW(fd,c*8+ 6)= 0x0012;
+ WFIFOL(fd,c*8+ 8)= sd->status.char_id;
+ c++;
+ }
+ }
+ WFIFOW(fd, 2)=c*8+8;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ if(c > 0) {
+ sd->menuskill_id = AM_PHARMACY;
+ sd->menuskill_lv = trigger;
+ return 1;
+ }
+ return 0;
+}
+
+/*==========================================
+ * Sends a status change packet to the object only, used for loading status changes. [Skotlex]
+ *------------------------------------------
+ */
+int clif_status_load(struct block_list *bl,int type, int flag)
+{
+ int fd;
+ if (type == SI_BLANK) //It shows nothing on the client...
+ return 0;
+
+ if (bl->type != BL_PC)
+ return 0;
+
+ fd = ((struct map_session_data*)bl)->fd;
+
+ WFIFOHEAD(fd,packet_len_table[0x196]);
+ WFIFOW(fd,0)=0x0196;
+ WFIFOW(fd,2)=type;
+ WFIFOL(fd,4)=bl->id;
+ WFIFOB(fd,8)=flag; //Status start
+ WFIFOSET(fd, packet_len_table[0x196]);
+ return 0;
+}
+/*==========================================
+ * 状態異常アイコン/メッセージ表示
+ *------------------------------------------
+ */
+int clif_status_change(struct block_list *bl,int type,int flag)
+{
+ unsigned char buf[16];
+
+ if (type == SI_BLANK) //It shows nothing on the client...
+ return 0;
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x0196;
+ WBUFW(buf,2)=type;
+ WBUFL(buf,4)=bl->id;
+ WBUFB(buf,8)=flag;
+ clif_send(buf,packet_len_table[0x196],bl,AREA);
+ return 0;
+}
+
+/*==========================================
+ * Send message (modified by [Yor])
+ *------------------------------------------
+ */
+int clif_displaymessage(const int fd, char* mes)
+{
+ // invalid pointer?
+ nullpo_retr(-1, mes);
+
+ //Console [Wizputer] //Scrapped, as these are shared by disconnected players =X [Skotlex]
+ if (fd == 0)
+ return 0;
+ else {
+ int len_mes = strlen(mes);
+
+ if (len_mes > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
+ WFIFOHEAD(fd, 5 + len_mes);
+ WFIFOW(fd,0) = 0x8e;
+ WFIFOW(fd,2) = 5 + len_mes; // 4 + len + NULL teminate
+ memcpy(WFIFOP(fd,4), mes, len_mes + 1);
+ WFIFOSET(fd, 5 + len_mes);
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * 天の声を送信する
+ *------------------------------------------
+ */
+int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
+{
+ unsigned char *buf;
+ int lp;
+
+ lp = (flag & 0x10) ? 8 : 4;
+ buf = (unsigned char*)aMallocA((len + lp + 8)*sizeof(unsigned char));
+
+ WBUFW(buf,0) = 0x9a;
+ WBUFW(buf,2) = len + lp;
+ WBUFL(buf,4) = 0x65756c62; //"blue":
+ memcpy(WBUFP(buf,lp), mes, len);
+ flag &= 0x07;
+ clif_send(buf, WBUFW(buf,2), bl,
+ (flag == 1) ? ALL_SAMEMAP :
+ (flag == 2) ? AREA :
+ (flag == 3) ? SELF :
+ ALL_CLIENT);
+ if(buf) aFree(buf);
+
+ if(use_irc && irc_announce_flag && !flag)
+ irc_announce(mes);
+
+ return 0;
+}
+
+/*==========================================
+ * グローバルメッセージ
+ *------------------------------------------
+ */
+void clif_GlobalMessage(struct block_list *bl,char *message)
+{
+ char buf[100];
+ int len;
+
+ nullpo_retv(bl);
+
+ if(!message)
+ return;
+
+ len = strlen(message)+1;
+
+ WBUFW(buf,0)=0x8d;
+ WBUFW(buf,2)=len+8;
+ WBUFL(buf,4)=bl->id;
+ strncpy((char *) WBUFP(buf,8),message,len);
+ clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT);
+}
+
+/*==========================================
+ * Send main chat message [LuzZza]
+ *------------------------------------------
+ */
+void clif_MainChatMessage(char* message) {
+
+ char buf[200];
+ int len;
+
+ if(!message)
+ return;
+
+ len = strlen(message)+1;
+ if (len+8 > sizeof(buf)) {
+ ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message);
+ len = sizeof(buf)-8;
+ }
+ WBUFW(buf,0)=0x8d;
+ WBUFW(buf,2)=len+8;
+ WBUFL(buf,4)=0;
+ strncpy((char *) WBUFP(buf,8),message,len);
+ clif_send((unsigned char *) buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT);
+}
+
+/*==========================================
+ * Does an announce message in the given color.
+ *------------------------------------------
+ */
+int clif_announce(struct block_list *bl, char* mes, int len, unsigned long color, int flag)
+{
+ unsigned char *buf;
+ buf = (unsigned char*)aMallocA((len + 16)*sizeof(unsigned char));
+ WBUFW(buf,0) = 0x1c3;
+ WBUFW(buf,2) = len + 16;
+ WBUFL(buf,4) = color;
+ WBUFW(buf,8) = 0x190; //Font style? Type?
+ WBUFW(buf,10) = 0x0c; //12? Font size?
+ WBUFL(buf,12) = 0; //Unknown!
+ memcpy(WBUFP(buf,16), mes, len);
+
+ flag &= 0x07;
+ clif_send(buf, WBUFW(buf,2), bl,
+ (flag == 1) ? ALL_SAMEMAP :
+ (flag == 2) ? AREA :
+ (flag == 3) ? SELF :
+ ALL_CLIENT);
+
+ if(buf) aFree(buf);
+ return 0;
+}
+/*==========================================
+ * HPSP回復エフェクトを送信する
+ *------------------------------------------
+ */
+int clif_heal(int fd,int type,int val)
+{
+ WFIFOHEAD(fd,packet_len_table[0x13d]);
+ WFIFOW(fd,0)=0x13d;
+ WFIFOW(fd,2)=type;
+ WFIFOW(fd,4)=val;
+ WFIFOSET(fd,packet_len_table[0x13d]);
+
+ return 0;
+}
+
+/*==========================================
+ * 復活する
+ *------------------------------------------
+ */
+int clif_resurrection(struct block_list *bl,int type)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x148;
+ WBUFL(buf,2)=bl->id;
+ WBUFW(buf,6)=type;
+
+ clif_send(buf,packet_len_table[0x148],bl,type==1 ? AREA : AREA_WOS);
+ if (disguised(bl))
+ clif_spawn(bl);
+
+ return 0;
+}
+
+/*==========================================
+ * PVP実装?(仮)
+ *------------------------------------------
+ */
+int clif_set0199(int fd,int type)
+{
+ WFIFOHEAD(fd,packet_len_table[0x199]);
+ WFIFOW(fd,0)=0x199;
+ WFIFOW(fd,2)=type;
+ WFIFOSET(fd,packet_len_table[0x199]);
+
+ return 0;
+}
+
+/*==========================================
+ * PVP実装?(仮)
+ *------------------------------------------
+ */
+int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type)
+{
+ nullpo_retr(0, sd);
+
+ if(type == 2) {
+ WFIFOHEAD(sd->fd,packet_len_table[0x19a]);
+ WFIFOW(sd->fd,0) = 0x19a;
+ WFIFOL(sd->fd,2) = sd->bl.id;
+ WFIFOL(sd->fd,6) = pvprank;
+ WFIFOL(sd->fd,10) = pvpnum;
+ WFIFOSET(sd->fd,packet_len_table[0x19a]);
+ } else {
+ unsigned char buf[32];
+ WBUFW(buf,0) = 0x19a;
+ WBUFL(buf,2) = sd->bl.id;
+ if(sd->sc.option&(OPTION_HIDE|OPTION_CLOAK))
+ WBUFL(buf,6) = ULONG_MAX; //On client displays as --
+ else
+ WBUFL(buf,6) = pvprank;
+ WBUFL(buf,10) = pvpnum;
+ if(sd->sc.option&OPTION_INVISIBLE)
+ clif_send(buf,packet_len_table[0x19a],&sd->bl,SELF);
+ else if(!type)
+ clif_send(buf,packet_len_table[0x19a],&sd->bl,AREA);
+ else
+ clif_send(buf,packet_len_table[0x19a],&sd->bl,ALL_SAMEMAP);
+ }
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_send0199(int map,int type)
+{
+ struct block_list bl;
+ unsigned char buf[16];
+
+ bl.id = 0;
+ bl.type = BL_NUL;
+ bl.m = map;
+ WBUFW(buf,0)=0x199;
+ WBUFW(buf,2)=type;
+ clif_send(buf,packet_len_table[0x199],&bl,ALL_SAMEMAP);
+
+ return 0;
+}
+
+/*==========================================
+ * 精錬エフェクトを送信する
+ *------------------------------------------
+ */
+int clif_refine(int fd,struct map_session_data *sd,int fail,int index,int val)
+{
+ WFIFOHEAD(fd,packet_len_table[0x188]);
+ WFIFOW(fd,0)=0x188;
+ WFIFOW(fd,2)=fail;
+ WFIFOW(fd,4)=index+2;
+ WFIFOW(fd,6)=val;
+ WFIFOSET(fd,packet_len_table[0x188]);
+
+ return 0;
+}
+
+/*==========================================
+ * Wisp/page is transmitted to the destination player
+ *------------------------------------------
+ */
+int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B
+{
+// printf("clif_wis_message(%d, %s, %s)\n", fd, nick, mes);
+
+ WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4);
+ WFIFOW(fd,0) = 0x97;
+ WFIFOW(fd,2) = mes_len + NAME_LENGTH + 4;
+ memcpy(WFIFOP(fd,4), nick, NAME_LENGTH);
+ memcpy(WFIFOP(fd,28), mes, mes_len);
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+
+/*==========================================
+ * The transmission result of Wisp/page is transmitted to the source player
+ *------------------------------------------
+ */
+int clif_wis_end(int fd, int flag) // R 0098 <type>.B: 0: success to send wisper, 1: target character is not loged in, 2: ignored by target, 3: everyone ignored by target
+{
+ WFIFOHEAD(fd,packet_len_table[0x98]);
+ WFIFOW(fd,0) = 0x98;
+ WFIFOW(fd,2) = flag;
+ WFIFOSET(fd,packet_len_table[0x98]);
+ return 0;
+}
+
+/*==========================================
+ * キャラID名前引き結果を送信する
+ *------------------------------------------
+ */
+int clif_solved_charname(struct map_session_data *sd,int char_id)
+{
+ char *p= map_charid2nick(char_id);
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ if(p!=NULL){
+ WFIFOHEAD(fd,packet_len_table[0x194]);
+ WFIFOW(fd,0)=0x194;
+ WFIFOL(fd,2)=char_id;
+ memcpy(WFIFOP(fd,6), p, NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0x194]);
+ }else{
+ map_reqchariddb(sd,char_id);
+ chrif_searchcharid(char_id);
+ }
+ return 0;
+}
+
+/*==========================================
+ * カードの挿入可能リストを返す
+ *------------------------------------------
+ */
+int clif_use_card(struct map_session_data *sd,int idx)
+{
+ int i,c,ep;
+ int fd=sd->fd;
+
+ nullpo_retr(0, sd);
+ if (idx < 0 || idx >= MAX_INVENTORY) //Crash-fix from bad packets.
+ return 0;
+
+ if (!sd->inventory_data[idx] || sd->inventory_data[idx]->type != IT_CARD)
+ return 0; //Avoid parsing invalid item indexes (no card/no item)
+
+ ep=sd->inventory_data[idx]->equip;
+ WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
+ WFIFOW(fd,0)=0x017b;
+
+ for(i=c=0;i<MAX_INVENTORY;i++){
+ int j;
+
+ if(sd->inventory_data[i] == NULL)
+ continue;
+ if(sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR)
+ continue;
+ if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it
+ continue;
+
+ if(sd->status.inventory[i].identify==0 ) //Not identified
+ continue;
+
+ if((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part.
+ continue;
+
+ if(sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_HAND_L) //Shield card won't go on left weapon.
+ continue;
+
+ for(j=0;j<sd->inventory_data[i]->slot;j++){
+ if( sd->status.inventory[i].card[j]==0 )
+ break;
+ }
+ if(j==sd->inventory_data[i]->slot) // No room
+ continue;
+
+ WFIFOW(fd,4+c*2)=i+2;
+ c++;
+ }
+ WFIFOW(fd,2)=4+c*2;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ return 0;
+}
+/*==========================================
+ * カードの挿入終了
+ *------------------------------------------
+ */
+int clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x17d]);
+ WFIFOW(fd,0)=0x17d;
+ WFIFOW(fd,2)=idx_equip+2;
+ WFIFOW(fd,4)=idx_card+2;
+ WFIFOB(fd,6)=flag;
+ WFIFOSET(fd,packet_len_table[0x17d]);
+ return 0;
+}
+
+/*==========================================
+ * 鑑定可能アイテムリスト送信
+ *------------------------------------------
+ */
+int clif_item_identify_list(struct map_session_data *sd)
+{
+ int i,c;
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+
+ WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4);
+ WFIFOW(fd,0)=0x177;
+ for(i=c=0;i<MAX_INVENTORY;i++){
+ if(sd->status.inventory[i].nameid > 0 && !sd->status.inventory[i].identify){
+ WFIFOW(fd,c*2+4)=i+2;
+ c++;
+ }
+ }
+ if(c > 0) {
+ WFIFOW(fd,2)=c*2+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ sd->menuskill_id = MC_IDENTIFY;
+ sd->menuskill_lv = c;
+ }
+ return 0;
+}
+
+/*==========================================
+ * 鑑定結果
+ *------------------------------------------
+ */
+int clif_item_identified(struct map_session_data *sd,int idx,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x179]);
+ WFIFOW(fd, 0)=0x179;
+ WFIFOW(fd, 2)=idx+2;
+ WFIFOB(fd, 4)=flag;
+ WFIFOSET(fd,packet_len_table[0x179]);
+ return 0;
+}
+
+/*==========================================
+ * 修理可能アイテムリスト送信
+ *------------------------------------------
+ */
+int clif_item_repair_list(struct map_session_data *sd,struct map_session_data *dstsd)
+{
+ int i,c;
+ int fd;
+ int nameid;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, dstsd);
+
+ fd=sd->fd;
+
+ WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
+ WFIFOW(fd,0)=0x1fc;
+ for(i=c=0;i<MAX_INVENTORY;i++){
+ if((nameid=dstsd->status.inventory[i].nameid) > 0 && dstsd->status.inventory[i].attribute!=0){// && skill_can_repair(sd,nameid)){
+ WFIFOW(fd,c*13+4) = i;
+ WFIFOW(fd,c*13+6) = nameid;
+ WFIFOL(fd,c*13+8) = sd->status.char_id;
+ WFIFOL(fd,c*13+12)= dstsd->status.char_id;
+ WFIFOB(fd,c*13+16)= c;
+ c++;
+ }
+ }
+ if(c > 0) {
+ WFIFOW(fd,2)=c*13+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ sd->menuskill_id = BS_REPAIRWEAPON;
+ sd->menuskill_lv = dstsd->bl.id;
+ }else
+ clif_skill_fail(sd,sd->ud.skillid,0,0);
+
+ return 0;
+}
+int clif_item_repaireffect(struct map_session_data *sd,int nameid,int flag)
+{
+ int view,fd;
+
+ nullpo_retr(0, sd);
+ fd=sd->fd;
+
+ WFIFOHEAD(fd,packet_len_table[0x1fe]);
+ WFIFOW(fd, 0)=0x1fe;
+ if((view = itemdb_viewid(nameid)) > 0)
+ WFIFOW(fd, 2)=view;
+ else
+ WFIFOW(fd, 2)=nameid;
+ WFIFOB(fd, 4)=flag;
+ WFIFOSET(fd,packet_len_table[0x1fe]);
+
+ return 0;
+}
+
+/*==========================================
+ * Weapon Refining - Taken from jAthena
+ *------------------------------------------
+ */
+int clif_item_refine_list(struct map_session_data *sd)
+{
+ int i,c;
+ int fd;
+ int skilllv;
+ int wlv;
+ int refine_item[5];
+
+ nullpo_retr(0, sd);
+
+ skilllv = pc_checkskill(sd,WS_WEAPONREFINE);
+
+ fd=sd->fd;
+
+ refine_item[0] = -1;
+ refine_item[1] = pc_search_inventory(sd,1010);
+ refine_item[2] = pc_search_inventory(sd,1011);
+ refine_item[3] = refine_item[4] = pc_search_inventory(sd,984);
+
+ WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
+ WFIFOW(fd,0)=0x221;
+ for(i=c=0;i<MAX_INVENTORY;i++){
+ if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skilllv &&
+ sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 &&
+ refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&0x0022)){
+ WFIFOW(fd,c*13+ 4)=i+2;
+ WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid;
+ WFIFOW(fd,c*13+ 8)=0; //TODO: Wonder what are these for? Perhaps ID of weapon's crafter if any?
+ WFIFOW(fd,c*13+10)=0;
+ WFIFOB(fd,c*13+12)=c;
+ c++;
+ }
+ }
+ WFIFOW(fd,2)=c*13+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ sd->menuskill_id = WS_WEAPONREFINE;
+ sd->menuskill_lv = skilllv;
+
+ return 0;
+}
+
+/*==========================================
+ * アイテムによる一時的なスキル効果
+ *------------------------------------------
+ */
+int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv,const char *name)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x147]);
+ WFIFOW(fd, 0)=0x147;
+ WFIFOW(fd, 2)=skillid;
+ WFIFOW(fd, 4)=skill_get_inf(skillid);
+ WFIFOW(fd, 6)=0;
+ WFIFOW(fd, 8)=skilllv;
+ WFIFOW(fd,10)=skill_get_sp(skillid,skilllv);
+ WFIFOW(fd,12)=skill_get_range2(&sd->bl, skillid,skilllv);
+ strncpy((char*)WFIFOP(fd,14),name,NAME_LENGTH);
+ WFIFOB(fd,38)=0;
+ WFIFOSET(fd,packet_len_table[0x147]);
+ return 0;
+}
+
+/*==========================================
+ * カートにアイテム追加
+ *------------------------------------------
+ */
+int clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
+{
+ int view,fd;
+ unsigned char *buf;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x124]);
+ buf=WFIFOP(fd,0);
+ if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0)
+ return 1;
+
+ WBUFW(buf,0)=0x124;
+ WBUFW(buf,2)=n+2;
+ WBUFL(buf,4)=amount;
+ if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0)
+ WBUFW(buf,8)=view;
+ else
+ WBUFW(buf,8)=sd->status.cart[n].nameid;
+ WBUFB(buf,10)=sd->status.cart[n].identify;
+ WBUFB(buf,11)=sd->status.cart[n].attribute;
+ WBUFB(buf,12)=sd->status.cart[n].refine;
+ clif_addcards(WBUFP(buf,13), &sd->status.cart[n]);
+ WFIFOSET(fd,packet_len_table[0x124]);
+ return 0;
+}
+
+/*==========================================
+ * カートからアイテム削除
+ *------------------------------------------
+ */
+int clif_cart_delitem(struct map_session_data *sd,int n,int amount)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+
+ WFIFOHEAD(fd,packet_len_table[0x125]);
+ WFIFOW(fd,0)=0x125;
+ WFIFOW(fd,2)=n+2;
+ WFIFOL(fd,4)=amount;
+
+ WFIFOSET(fd,packet_len_table[0x125]);
+
+ return 0;
+}
+
+/*==========================================
+ * 露店開設
+ *------------------------------------------
+ */
+int clif_openvendingreq(struct map_session_data *sd,int num)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x12d]);
+ WFIFOW(fd,0)=0x12d;
+ WFIFOW(fd,2)=num;
+ WFIFOSET(fd,packet_len_table[0x12d]);
+
+ return 0;
+}
+
+/*==========================================
+ * 露店看板表示
+ *------------------------------------------
+ */
+int clif_showvendingboard(struct block_list* bl,char *message,int fd)
+{
+ unsigned char buf[128];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x131;
+ WBUFL(buf,2)=bl->id;
+ strncpy((char*)WBUFP(buf,6),message,80);
+ if(fd){
+ WFIFOHEAD(fd,packet_len_table[0x131]);
+ memcpy(WFIFOP(fd,0),buf,packet_len_table[0x131]);
+ WFIFOSET(fd,packet_len_table[0x131]);
+ }else{
+ clif_send(buf,packet_len_table[0x131],bl,AREA_WOS);
+ }
+ return 0;
+}
+
+/*==========================================
+ * 露店看板消去
+ *------------------------------------------
+ */
+int clif_closevendingboard(struct block_list* bl,int fd)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x132;
+ WBUFL(buf,2)=bl->id;
+ if(fd){
+ WFIFOHEAD(fd,packet_len_table[0x132]);
+ memcpy(WFIFOP(fd,0),buf,packet_len_table[0x132]);
+ WFIFOSET(fd,packet_len_table[0x132]);
+ }else{
+ clif_send(buf,packet_len_table[0x132],bl,AREA_WOS);
+ }
+
+ return 0;
+}
+/*==========================================
+ * 露店アイテムリスト
+ *------------------------------------------
+ */
+int clif_vendinglist(struct map_session_data *sd,int id,struct vending *vending)
+{
+ struct item_data *data;
+ int i,n,index,fd;
+ struct map_session_data *vsd;
+ unsigned char *buf;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, vending);
+ nullpo_retr(0, vsd=map_id2sd(id));
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, 8+vsd->vend_num*22);
+ buf = WFIFOP(fd,0);
+ for(i=0,n=0;i<vsd->vend_num;i++){
+ if(vending[i].amount<=0)
+ continue;
+ WBUFL(buf,8+n*22)=vending[i].value;
+ WBUFW(buf,12+n*22)=vending[i].amount;
+ WBUFW(buf,14+n*22)=(index=vending[i].index)+2;
+ if(vsd->status.cart[index].nameid <= 0 || vsd->status.cart[index].amount <= 0)
+ continue;
+ data = itemdb_search(vsd->status.cart[index].nameid);
+ WBUFB(buf,16+n*22)=itemtype(data->type);
+ if(data->view_id > 0)
+ WBUFW(buf,17+n*22)=data->view_id;
+ else
+ WBUFW(buf,17+n*22)=vsd->status.cart[index].nameid;
+ WBUFB(buf,19+n*22)=vsd->status.cart[index].identify;
+ WBUFB(buf,20+n*22)=vsd->status.cart[index].attribute;
+ WBUFB(buf,21+n*22)=vsd->status.cart[index].refine;
+ clif_addcards(WBUFP(buf, 22+n*22), &vsd->status.cart[index]);
+ n++;
+ }
+ if(n > 0){
+ WBUFW(buf,0)=0x133;
+ WBUFW(buf,2)=8+n*22;
+ WBUFL(buf,4)=id;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * 露店アイテム購入失敗
+ *------------------------------------------
+*/
+int clif_buyvending(struct map_session_data *sd,int index,int amount,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x135]);
+ WFIFOW(fd,0)=0x135;
+ WFIFOW(fd,2)=index+2;
+ WFIFOW(fd,4)=amount;
+ WFIFOB(fd,6)=fail;
+ WFIFOSET(fd,packet_len_table[0x135]);
+
+ return 0;
+}
+
+/*==========================================
+ * 露店開設成功
+ *------------------------------------------
+*/
+int clif_openvending(struct map_session_data *sd,int id,struct vending *vending)
+{
+ struct item_data *data;
+ int i,n,index,fd;
+ unsigned char *buf;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd, 8+sd->vend_num*22);
+ buf = WFIFOP(fd,0);
+ for(i=0,n=0;i<sd->vend_num;i++){
+ if (sd->vend_num > 2+pc_checkskill(sd,MC_VENDING)) return 0;
+ WBUFL(buf,8+n*22)=vending[i].value;
+ WBUFW(buf,12+n*22)=(index=vending[i].index)+2;
+ WBUFW(buf,14+n*22)=vending[i].amount;
+ if(sd->status.cart[index].nameid <= 0 || sd->status.cart[index].amount <= 0 || !sd->status.cart[index].identify ||
+ sd->status.cart[index].attribute==1) // Prevent unidentified and broken items from being sold [Valaris]
+ continue;
+ data = itemdb_search(sd->status.cart[index].nameid);
+ WBUFB(buf,16+n*22)=itemtype(data->type);
+ if(data->view_id > 0)
+ WBUFW(buf,17+n*22)=data->view_id;
+ else
+ WBUFW(buf,17+n*22)=sd->status.cart[index].nameid;
+ WBUFB(buf,19+n*22)=sd->status.cart[index].identify;
+ WBUFB(buf,20+n*22)=sd->status.cart[index].attribute;
+ WBUFB(buf,21+n*22)=sd->status.cart[index].refine;
+ clif_addcards(WBUFP(buf, 22+n*22), &sd->status.cart[index]);
+ n++;
+ }
+ if(n > 0){
+ WBUFW(buf,0)=0x136;
+ WBUFW(buf,2)=8+n*22;
+ WBUFL(buf,4)=id;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ }
+ return n;
+}
+
+/*==========================================
+ * 露店アイテム販売報告
+ *------------------------------------------
+*/
+int clif_vendingreport(struct map_session_data *sd,int index,int amount)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x137]);
+ WFIFOW(fd,0)=0x137;
+ WFIFOW(fd,2)=index+2;
+ WFIFOW(fd,4)=amount;
+ WFIFOSET(fd,packet_len_table[0x137]);
+
+ return 0;
+}
+/*==========================================
+ * パーティ作成完了
+ *------------------------------------------
+ */
+int clif_party_created(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xfa]);
+ WFIFOW(fd,0)=0xfa;
+ WFIFOB(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0xfa]);
+ return 0;
+}
+
+int clif_party_main_info(struct party_data *p, int fd)
+{
+ struct map_session_data *sd;
+ int i;
+ unsigned char buf[96];
+
+ for (i=0; i<MAX_PARTY && !p->party.member[i].leader; i++);
+ if (i >= MAX_PARTY) return 0; //Should never happen...
+ sd = p->data[i].sd;
+ WBUFW(buf,0)=0x1e9;
+ WBUFL(buf,2)= p->party.member[i].account_id;
+ WBUFL(buf,6)= 0; //We don't know yet what this long is about.
+ WBUFW(buf,10)=sd?sd->bl.x:0;
+ WBUFW(buf,12)=sd?sd->bl.y:0;
+ WBUFB(buf,14)=(p->party.member[i].online)?0:1; //This byte is also unconfirmed...
+ memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
+ memcpy(WBUFP(buf,39), p->party.member[i].name, NAME_LENGTH);
+ memcpy(WBUFP(buf,63), mapindex_id2name(p->party.member[i].map), MAP_NAME_LENGTH);
+ WBUFB(buf,79) = (p->party.item&1)?1:0;
+ WBUFB(buf,80) = (p->party.item&2)?1:0;
+ if(fd>=0){
+ WFIFOHEAD(fd,packet_len_table[0x1e9]);
+ memcpy(WFIFOP(fd,0),buf,packet_len_table[0x1e9]);
+ WFIFOSET(fd,packet_len_table[0x1e9]);
+ return 1;
+ }
+ if (!sd) {
+ for (i=0; i<MAX_PARTY && !p->data[i].sd; i++)
+ if (i >= MAX_PARTY) return 0; //Should never happen...
+ sd=p->data[i].sd;
+ }
+ clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY);
+ return 1;
+}
+
+int clif_party_join_info(struct party *p, struct map_session_data *sd)
+{
+ unsigned char buf[96];
+ WBUFW(buf,0)=0x1e9;
+ WBUFL(buf,2)= sd->status.account_id;
+ WBUFL(buf,6)= 0; //Apparently setting this to 1 makes you adoptable.
+ WBUFW(buf,10)=sd->bl.x;
+ WBUFW(buf,12)=sd->bl.y;
+ WBUFB(buf,14)=0; //Unconfirmed byte.
+ memcpy(WBUFP(buf,15), p->name, NAME_LENGTH);
+ memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
+ memcpy(WBUFP(buf,63), mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
+ WBUFB(buf,79) = (p->item&1)?1:0;
+ WBUFB(buf,80) = (p->item&2)?1:0;
+ clif_send(buf,packet_len_table[0x1e9],&sd->bl,PARTY_WOS);
+ return 1;
+}
+
+
+/*==========================================
+ * パーティ情報送信
+ *------------------------------------------
+ */
+int clif_party_info(struct party_data *p,int fd)
+{
+ unsigned char buf[1024];
+ int i,c;
+ struct map_session_data *sd=NULL;
+
+ nullpo_retr(0, p);
+
+ WBUFW(buf,0)=0xfb;
+ memcpy(WBUFP(buf,4),p->party.name,NAME_LENGTH);
+ for(i=c=0;i<MAX_PARTY;i++){
+ struct party_member *m=&p->party.member[i];
+ if(!m->account_id)
+ continue;
+ if(sd==NULL) sd=p->data[i].sd;
+ WBUFL(buf,28+c*46)=m->account_id;
+ memcpy(WBUFP(buf,28+c*46+ 4),m->name,NAME_LENGTH);
+ memcpy(WBUFP(buf,28+c*46+28),mapindex_id2name(m->map),MAP_NAME_LENGTH);
+ WBUFB(buf,28+c*46+44)=(m->leader)?0:1;
+ WBUFB(buf,28+c*46+45)=(m->online)?0:1;
+ c++;
+ }
+ WBUFW(buf,2)=28+c*46;
+ if(fd>=0){ // fdが設定されてるならそれに送る
+ WFIFOHEAD(fd, 28+c*46);
+ memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2));
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 9;
+ }
+ if(sd!=NULL)
+ clif_send(buf,WBUFW(buf,2),&sd->bl,PARTY);
+ return 0;
+}
+/*==========================================
+ * パーティ勧誘
+ *------------------------------------------
+ */
+int clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
+{
+ int fd;
+ struct party_data *p;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, tsd);
+
+ fd=tsd->fd;
+
+ if( (p=party_search(sd->status.party_id))==NULL )
+ return 0;
+
+ WFIFOHEAD(fd,packet_len_table[0xfe]);
+ WFIFOW(fd,0)=0xfe;
+ WFIFOL(fd,2)=sd->status.account_id;
+ memcpy(WFIFOP(fd,6),p->party.name,NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0xfe]);
+ return 0;
+}
+
+/*==========================================
+ * Party invitation result. Flag values are:
+ * 0 -> char is already in a party
+ * 1 -> party invite was rejected
+ * 2 -> party invite was accepted
+ * 3 -> party is full
+ * 4 -> char of the same account already joined the party
+ *------------------------------------------
+ */
+int clif_party_inviteack(struct map_session_data *sd,char *nick,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xfd]);
+ WFIFOW(fd,0)=0xfd;
+ memcpy(WFIFOP(fd,2),nick,NAME_LENGTH);
+ WFIFOB(fd,26)=flag;
+ WFIFOSET(fd,packet_len_table[0xfd]);
+ return 0;
+}
+
+/*==========================================
+ * パーティ設定送信
+ * flag & 0x001=exp変更ミス
+ * 0x010=item変更ミス
+ * 0x100=一人にのみ送信
+ *------------------------------------------
+ */
+int clif_party_option(struct party_data *p,struct map_session_data *sd,int flag)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, p);
+
+// if(battle_config.etc_log)
+// printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
+ if(sd==NULL && flag==0){
+ int i;
+ for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
+ if (i < MAX_PARTY)
+ sd = p->data[i].sd;
+ }
+ if(sd==NULL)
+ return 0;
+ WBUFW(buf,0)=0x101;
+ WBUFW(buf,2)=((flag&0x01)?2:p->party.exp);
+ WBUFW(buf,4)=0; //NOTE: We don't know yet what this is for, it is NOT for item share rules, though. [Skotlex]
+ if(flag==0)
+ clif_send(buf,packet_len_table[0x101],&sd->bl,PARTY);
+ else {
+ WFIFOHEAD(sd->fd,packet_len_table[0x101]);
+ memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x101]);
+ WFIFOSET(sd->fd,packet_len_table[0x101]);
+ }
+ return 0;
+}
+/*==========================================
+ * パーティ脱退(脱退前に呼ぶこと)
+ *------------------------------------------
+ */
+int clif_party_leaved(struct party_data *p,struct map_session_data *sd,int account_id,char *name,int flag)
+{
+ unsigned char buf[64];
+ int i;
+
+ nullpo_retr(0, p);
+
+ WBUFW(buf,0)=0x105;
+ WBUFL(buf,2)=account_id;
+ memcpy(WBUFP(buf,6),name,NAME_LENGTH);
+ WBUFB(buf,30)=flag&0x0f;
+
+ if((flag&0xf0)==0){
+ if(sd==NULL) {
+ for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
+ if (i < MAX_PARTY)
+ sd = p->data[i].sd;
+ }
+ if (sd)
+ clif_send(buf,packet_len_table[0x105],&sd->bl,PARTY);
+ } else if (sd!=NULL) {
+ WFIFOHEAD(sd->fd,packet_len_table[0x105]);
+ memcpy(WFIFOP(sd->fd,0),buf,packet_len_table[0x105]);
+ WFIFOSET(sd->fd,packet_len_table[0x105]);
+ }
+ return 0;
+}
+/*==========================================
+ * パーティメッセージ送信
+ *------------------------------------------
+ */
+int clif_party_message(struct party_data *p,int account_id,char *mes,int len)
+{
+ struct map_session_data *sd;
+ int i;
+
+ nullpo_retr(0, p);
+
+ for(i=0; i < MAX_PARTY && !p->data[i].sd;i++);
+ if(i < MAX_PARTY){
+ unsigned char buf[1024];
+ sd = p->data[i].sd;
+ WBUFW(buf,0)=0x109;
+ WBUFW(buf,2)=len+8;
+ WBUFL(buf,4)=account_id;
+ memcpy(WBUFP(buf,8),mes,len);
+ clif_send(buf,len+8,&sd->bl,PARTY);
+ }
+ return 0;
+}
+/*==========================================
+ * パーティ座標通知
+ *------------------------------------------
+ */
+int clif_party_xy(struct map_session_data *sd)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x107;
+ WBUFL(buf,2)=sd->status.account_id;
+ WBUFW(buf,6)=sd->bl.x;
+ WBUFW(buf,8)=sd->bl.y;
+ clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
+
+ return 0;
+}
+
+/*==========================================
+ * Sends x/y dot to a single fd. [Skotlex]
+ *------------------------------------------
+ */
+
+int clif_party_xy_single(int fd, struct map_session_data *sd)
+{
+ WFIFOHEAD(fd,packet_len_table[0x107]);
+ WFIFOW(fd,0)=0x107;
+ WFIFOL(fd,2)=sd->status.account_id;
+ WFIFOW(fd,6)=sd->bl.x;
+ WFIFOW(fd,8)=sd->bl.y;
+ WFIFOSET(fd,packet_len_table[0x107]);
+ return 0;
+}
+
+
+/*==========================================
+ * パーティHP通知
+ *------------------------------------------
+ */
+int clif_party_hp(struct map_session_data *sd)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x106;
+ WBUFL(buf,2)=sd->status.account_id;
+ if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
+ WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
+ WBUFW(buf,8) = 100;
+ } else {
+ WBUFW(buf,6) = sd->battle_status.hp;
+ WBUFW(buf,8) = sd->battle_status.max_hp;
+ }
+ clif_send(buf,packet_len_table[0x106],&sd->bl,PARTY_AREA_WOS);
+ return 0;
+}
+
+/*==========================================
+ * Sends HP bar to a single fd. [Skotlex]
+ *------------------------------------------
+ */
+static void clif_hpmeter_single(int fd, struct map_session_data *sd)
+{
+ WFIFOHEAD(fd,packet_len_table[0x106]);
+ WFIFOW(fd,0) = 0x106;
+ WFIFOL(fd,2) = sd->status.account_id;
+ if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
+ WFIFOW(fd,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
+ WFIFOW(fd,8) = 100;
+ } else {
+ WFIFOW(fd,6) = sd->battle_status.hp;
+ WFIFOW(fd,8) = sd->battle_status.max_hp;
+ }
+ WFIFOSET (fd, packet_len_table[0x106]);
+}
+
+/*==========================================
+ * GMへ場所とHP通知
+ *------------------------------------------
+ */
+int clif_hpmeter(struct map_session_data *sd)
+{
+ struct map_session_data *sd2;
+ unsigned char buf[16];
+ int i, x0, y0, x1, y1;
+ int level;
+
+ nullpo_retr(0, sd);
+
+ x0 = sd->bl.x - AREA_SIZE;
+ y0 = sd->bl.y - AREA_SIZE;
+ x1 = sd->bl.x + AREA_SIZE;
+ y1 = sd->bl.y + AREA_SIZE;
+
+ WBUFW(buf,0) = 0x106;
+ WBUFL(buf,2) = sd->status.account_id;
+ if (sd->battle_status.max_hp > SHRT_MAX) { //To correctly display the %hp bar. [Skotlex]
+ WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100);
+ WBUFW(buf,8) = 100;
+ } else {
+ WBUFW(buf,6) = sd->battle_status.hp;
+ WBUFW(buf,8) = sd->battle_status.max_hp;
+ }
+ for (i = 0; i < fd_max; i++) {
+ if (session[i] && session[i]->func_parse == clif_parse &&
+ (sd2 = (struct map_session_data*)session[i]->session_data) &&
+ sd != sd2 && sd2->state.auth) {
+ if (sd2->bl.m != sd->bl.m ||
+ sd2->bl.x < x0 || sd2->bl.y < y0 ||
+ sd2->bl.x > x1 || sd2->bl.y > y1 ||
+ (level = pc_isGM(sd2)) < battle_config.disp_hpmeter ||
+ level < pc_isGM(sd))
+ continue;
+ WFIFOHEAD (i, packet_len_table[0x106]);
+ memcpy (WFIFOP(i,0), buf, packet_len_table[0x106]);
+ WFIFOSET (i, packet_len_table[0x106]);
+ }
+ }
+
+ return 0;
+}
+
+/*==========================================
+ * パーティ場所移動(未使用)
+ *------------------------------------------
+ */
+int clif_party_move(struct party *p,struct map_session_data *sd,int online)
+{
+ unsigned char buf[128];
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, p);
+
+ WBUFW(buf, 0)=0x104;
+ WBUFL(buf, 2)=sd->status.account_id;
+ WBUFL(buf, 6)=0;
+ WBUFW(buf,10)=sd->bl.x;
+ WBUFW(buf,12)=sd->bl.y;
+ WBUFB(buf,14)=!online;
+ memcpy(WBUFP(buf,15),p->name, NAME_LENGTH);
+ memcpy(WBUFP(buf,39),sd->status.name, NAME_LENGTH);
+ memcpy(WBUFP(buf,63),map[sd->bl.m].name, MAP_NAME_LENGTH);
+ clif_send(buf,packet_len_table[0x104],&sd->bl,PARTY);
+ return 0;
+}
+/*==========================================
+ * 攻撃するために移動が必要
+ *------------------------------------------
+ */
+int clif_movetoattack(struct map_session_data *sd,struct block_list *bl)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, bl);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x139]);
+ WFIFOW(fd, 0)=0x139;
+ WFIFOL(fd, 2)=bl->id;
+ WFIFOW(fd, 6)=bl->x;
+ WFIFOW(fd, 8)=bl->y;
+ WFIFOW(fd,10)=sd->bl.x;
+ WFIFOW(fd,12)=sd->bl.y;
+ WFIFOW(fd,14)=sd->battle_status.rhw.range;
+ WFIFOSET(fd,packet_len_table[0x139]);
+ return 0;
+}
+/*==========================================
+ * 製造エフェクト
+ *------------------------------------------
+ */
+int clif_produceeffect(struct map_session_data *sd,int flag,int nameid)
+{
+ int view,fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ // 名前の登録と送信を先にしておく
+ if( map_charid2nick(sd->status.char_id)==NULL )
+ map_addchariddb(sd->status.char_id,sd->status.name);
+ clif_solved_charname(sd,sd->status.char_id);
+
+ WFIFOHEAD(fd,packet_len_table[0x18f]);
+ WFIFOW(fd, 0)=0x18f;
+ WFIFOW(fd, 2)=flag;
+ if((view = itemdb_viewid(nameid)) > 0)
+ WFIFOW(fd, 4)=view;
+ else
+ WFIFOW(fd, 4)=nameid;
+ WFIFOSET(fd,packet_len_table[0x18f]);
+ return 0;
+}
+
+// pet
+int clif_catch_process(struct map_session_data *sd)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x19e]);
+ WFIFOW(fd,0)=0x19e;
+ WFIFOSET(fd,packet_len_table[0x19e]);
+ sd->menuskill_id = SA_TAMINGMONSTER;
+ if (sd->ud.skillid == SA_TAMINGMONSTER)
+ sd->menuskill_lv = 0; //Free catch
+ else
+ sd->menuskill_lv = sd->itemid; //Consume catch
+ return 0;
+}
+
+int clif_pet_rulet(struct map_session_data *sd,int data)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1a0]);
+ WFIFOW(fd,0)=0x1a0;
+ WFIFOB(fd,2)=data;
+ WFIFOSET(fd,packet_len_table[0x1a0]);
+
+ return 0;
+}
+
+/*==========================================
+ * pet卵リスト作成
+ *------------------------------------------
+ */
+int clif_sendegg(struct map_session_data *sd)
+{
+ //R 01a6 <len>.w <index>.w*
+ int i,n=0,fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m))
+ { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex]
+ clif_displaymessage(fd, "Pets are not allowed in Guild Wars.");
+ return 0;
+ }
+ WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
+ WFIFOW(fd,0)=0x1a6;
+ if(sd->status.pet_id <= 0) {
+ for(i=0,n=0;i<MAX_INVENTORY;i++){
+ if(sd->status.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL ||
+ sd->inventory_data[i]->type!=IT_PETEGG ||
+ sd->status.inventory[i].amount<=0)
+ continue;
+ WFIFOW(fd,n*2+4)=i+2;
+ n++;
+ }
+ }
+ WFIFOW(fd,2)=4+n*2;
+ WFIFOSET(fd,WFIFOW(fd,2));
+
+ sd->menuskill_id = SA_TAMINGMONSTER;
+ sd->menuskill_lv = -1;
+ return 0;
+}
+
+int clif_send_petdata(struct map_session_data *sd,int type,int param)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, sd->pd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1a4]);
+ WFIFOW(fd,0)=0x1a4;
+ WFIFOB(fd,2)=type;
+ WFIFOL(fd,3)=sd->pd->bl.id;
+ WFIFOL(fd,7)=param;
+ WFIFOSET(fd,packet_len_table[0x1a4]);
+
+ return 0;
+}
+
+int clif_send_petstatus(struct map_session_data *sd)
+{
+ int fd;
+ struct s_pet *pet;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, sd->pd);
+
+ fd=sd->fd;
+ pet = &sd->pd->pet;
+ WFIFOHEAD(fd,packet_len_table[0x1a2]);
+ WFIFOW(fd,0)=0x1a2;
+ memcpy(WFIFOP(fd,2),pet->name,NAME_LENGTH);
+ WFIFOB(fd,26)=(battle_config.pet_rename == 1)? 0:pet->rename_flag;
+ WFIFOW(fd,27)=pet->level;
+ WFIFOW(fd,29)=pet->hungry;
+ WFIFOW(fd,31)=pet->intimate;
+ WFIFOW(fd,33)=pet->equip;
+ WFIFOSET(fd,packet_len_table[0x1a2]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_pet_emotion(struct pet_data *pd,int param)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, pd);
+
+ malloc_set(buf,0,packet_len_table[0x1aa]);
+
+ WBUFW(buf,0)=0x1aa;
+ WBUFL(buf,2)=pd->bl.id;
+ if(param >= 100 && pd->petDB->talk_convert_class) {
+ if(pd->petDB->talk_convert_class < 0)
+ return 0;
+ else if(pd->petDB->talk_convert_class > 0) {
+ param -= (pd->pet.class_ - 100)*100;
+ param += (pd->petDB->talk_convert_class - 100)*100;
+ }
+ }
+ WBUFL(buf,6)=param;
+
+ clif_send(buf,packet_len_table[0x1aa],&pd->bl,AREA);
+
+ return 0;
+}
+
+int clif_pet_performance(struct block_list *bl,int param)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, bl);
+
+ malloc_set(buf,0,packet_len_table[0x1a4]);
+
+ WBUFW(buf,0)=0x1a4;
+ WBUFB(buf,2)=4;
+ WBUFL(buf,3)=bl->id;
+ WBUFL(buf,7)=param;
+
+ clif_send(buf,packet_len_table[0x1a4],bl,AREA);
+
+ return 0;
+}
+
+int clif_pet_equip(struct pet_data *pd)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, pd);
+
+ malloc_set(buf,0,packet_len_table[0x1a4]);
+
+ WBUFW(buf,0)=0x1a4;
+ WBUFB(buf,2)=3;
+ WBUFL(buf,3)=pd->bl.id;
+ WBUFL(buf,7)=pd->vd.shield;
+ clif_send(buf,packet_len_table[0x1a4],&pd->bl,AREA);
+
+ return 0;
+}
+
+int clif_pet_food(struct map_session_data *sd,int foodid,int fail)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1a3]);
+ WFIFOW(fd,0)=0x1a3;
+ WFIFOB(fd,2)=fail;
+ WFIFOW(fd,3)=foodid;
+ WFIFOSET(fd,packet_len_table[0x1a3]);
+
+ return 0;
+}
+
+/*==========================================
+ * オートスペル リスト送信
+ *------------------------------------------
+ */
+int clif_autospell(struct map_session_data *sd,int skilllv)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1cd]);
+ WFIFOW(fd, 0)=0x1cd;
+
+ if(skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0)
+ WFIFOL(fd,2)= MG_NAPALMBEAT;
+ else
+ WFIFOL(fd,2)= 0x00000000;
+ if(skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0)
+ WFIFOL(fd,6)= MG_COLDBOLT;
+ else
+ WFIFOL(fd,6)= 0x00000000;
+ if(skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0)
+ WFIFOL(fd,10)= MG_FIREBOLT;
+ else
+ WFIFOL(fd,10)= 0x00000000;
+ if(skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0)
+ WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
+ else
+ WFIFOL(fd,14)= 0x00000000;
+ if(skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0)
+ WFIFOL(fd,18)= MG_SOULSTRIKE;
+ else
+ WFIFOL(fd,18)= 0x00000000;
+ if(skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0)
+ WFIFOL(fd,22)= MG_FIREBALL;
+ else
+ WFIFOL(fd,22)= 0x00000000;
+ if(skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0)
+ WFIFOL(fd,26)= MG_FROSTDIVER;
+ else
+ WFIFOL(fd,26)= 0x00000000;
+
+ WFIFOSET(fd,packet_len_table[0x1cd]);
+ sd->menuskill_id = SA_AUTOSPELL;
+ sd->menuskill_lv = skilllv;
+
+ return 0;
+}
+
+/*==========================================
+ * ディボーションの青い糸
+ *------------------------------------------
+ */
+int clif_devotion(struct map_session_data *sd)
+{
+ unsigned char buf[56];
+ int i,n;
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x1cf;
+ WBUFL(buf,2)=sd->bl.id;
+ for(i=0,n=0;i<5;i++) {
+ if (!sd->devotion[i])
+ continue;
+ WBUFL(buf,6+4*n)=sd->devotion[i];
+ n++;
+ }
+ for(;n<5;n++)
+ WBUFL(buf,6+4*n)=0;
+
+ WBUFB(buf,26)=8;
+ WBUFB(buf,27)=0;
+
+ clif_send(buf,packet_len_table[0x1cf],&sd->bl,AREA);
+ return 0;
+}
+
+int clif_marionette(struct block_list *src, struct block_list *target)
+{
+ unsigned char buf[56];
+ int n;
+
+ WBUFW(buf,0)=0x1cf;
+ WBUFL(buf,2)=src->id;
+ for(n=0;n<5;n++)
+ WBUFL(buf,6+4*n)=0;
+ if (target) //The target goes on the second slot.
+ WBUFL(buf,6+4) = target->id;
+ WBUFB(buf,26)=8;
+ WBUFB(buf,27)=0;
+
+ clif_send(buf,packet_len_table[0x1cf],src,AREA);
+ return 0;
+}
+
+/*==========================================
+ * 氣球
+ *------------------------------------------
+ */
+int clif_spiritball(struct map_session_data *sd)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x1d0;
+ WBUFL(buf,2)=sd->bl.id;
+ WBUFW(buf,6)=sd->spiritball;
+ clif_send(buf,packet_len_table[0x1d0],&sd->bl,AREA);
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_combo_delay(struct block_list *bl,int wait)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x1d2;
+ WBUFL(buf,2)=bl->id;
+ WBUFL(buf,6)=wait;
+ clif_send(buf,packet_len_table[0x1d2],bl,AREA);
+
+ return 0;
+}
+/*==========================================
+ *白刃取り
+ *------------------------------------------
+ */
+int clif_bladestop(struct block_list *src,struct block_list *dst,
+ int _bool)
+{
+ unsigned char buf[32];
+
+ nullpo_retr(0, src);
+ nullpo_retr(0, dst);
+
+ WBUFW(buf,0)=0x1d1;
+ WBUFL(buf,2)=src->id;
+ WBUFL(buf,6)=dst->id;
+ WBUFL(buf,10)=_bool;
+
+ clif_send(buf,packet_len_table[0x1d1],src,AREA);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_changemapcell(int m,int x,int y,int cell_type,int type)
+{
+ struct block_list bl;
+ unsigned char buf[32];
+
+ bl.type = BL_NUL;
+ bl.m = m;
+ bl.x = x;
+ bl.y = y;
+ WBUFW(buf,0) = 0x192;
+ WBUFW(buf,2) = x;
+ WBUFW(buf,4) = y;
+ WBUFW(buf,6) = cell_type;
+ memcpy(WBUFP(buf,8),map[m].name,MAP_NAME_LENGTH);
+ if(!type)
+ clif_send(buf,packet_len_table[0x192],&bl,AREA);
+ else
+ clif_send(buf,packet_len_table[0x192],&bl,ALL_SAMEMAP);
+
+ return 0;
+}
+
+/*==========================================
+ * MVPエフェクト
+ *------------------------------------------
+ */
+int clif_mvp_effect(struct map_session_data *sd)
+{
+ unsigned char buf[16];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf,0)=0x10c;
+ WBUFL(buf,2)=sd->bl.id;
+ clif_send(buf,packet_len_table[0x10c],&sd->bl,AREA);
+ return 0;
+}
+/*==========================================
+ * MVPアイテム所得
+ *------------------------------------------
+ */
+int clif_mvp_item(struct map_session_data *sd,int nameid)
+{
+ int view,fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x10a]);
+ WFIFOW(fd,0)=0x10a;
+ if((view = itemdb_viewid(nameid)) > 0)
+ WFIFOW(fd,2)=view;
+ else
+ WFIFOW(fd,2)=nameid;
+ WFIFOSET(fd,packet_len_table[0x10a]);
+ return 0;
+}
+/*==========================================
+ * MVP経験値所得
+ *------------------------------------------
+ */
+int clif_mvp_exp(struct map_session_data *sd,unsigned long exp)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x10b]);
+ WFIFOW(fd,0)=0x10b;
+ WFIFOL(fd,2)=exp;
+ WFIFOSET(fd,packet_len_table[0x10b]);
+ return 0;
+}
+
+/*==========================================
+ * ギルド作成可否通知
+ *------------------------------------------
+ */
+int clif_guild_created(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x167]);
+ WFIFOW(fd,0)=0x167;
+ WFIFOB(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x167]);
+ return 0;
+}
+/*==========================================
+ * ギルド所属通知
+ *------------------------------------------
+ */
+int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g)
+{
+ int ps,fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, g);
+
+ fd=sd->fd;
+ ps=guild_getposition(sd,g);
+
+ WFIFOHEAD(fd,packet_len_table[0x16c]);
+ malloc_set(WFIFOP(fd,0),0,packet_len_table[0x16c]);
+ WFIFOW(fd,0)=0x16c;
+ WFIFOL(fd,2)=g->guild_id;
+ WFIFOL(fd,6)=g->emblem_id;
+ WFIFOL(fd,10)=g->position[ps].mode;
+ memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0x16c]);
+ return 0;
+}
+/*==========================================
+ * ギルドメンバログイン通知
+ *------------------------------------------
+ */
+int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
+{
+ unsigned char buf[64];
+
+ nullpo_retr(0, g);
+
+ WBUFW(buf, 0)=0x16d;
+ WBUFL(buf, 2)=g->member[idx].account_id;
+ WBUFL(buf, 6)=g->member[idx].char_id;
+ WBUFL(buf,10)=flag;
+ if(g->member[idx].sd==NULL){
+ struct map_session_data *sd=guild_getavailablesd(g);
+ if(sd!=NULL)
+ clif_send(buf,packet_len_table[0x16d],&sd->bl,GUILD);
+ }else
+ clif_send(buf,packet_len_table[0x16d],&g->member[idx].sd->bl,GUILD_WOS);
+ return 0;
+}
+
+// Function `clif_guild_memberlogin_notice` sends info about
+// logins and logouts of a guild member to the rest members.
+// But at the 1st time (after a player login or map changing)
+// the client won't show the message.
+// So I suggest use this function for sending "first-time-info"
+// to some player on entering the game or changing location.
+// At next time the client would always show the message.
+// The function sends all the statuses in the single packet
+// to economize traffic. [LuzZza]
+int clif_guild_send_onlineinfo(struct map_session_data *sd) {
+
+ struct guild *g;
+ char buf[14*128];
+ int i, count=0, p_len;
+
+ nullpo_retr(0, sd);
+
+ p_len = packet_len_table[0x16d];
+
+ if(!(g = guild_search(sd->status.guild_id)))
+ return 0;
+
+ for(i=0; i<g->max_member; i++) {
+
+ if(g->member[i].account_id > 0 &&
+ g->member[i].account_id != sd->status.account_id) {
+
+ WBUFW(buf,count*p_len) = 0x16d;
+ WBUFL(buf,count*p_len+2) = g->member[i].account_id;
+ WBUFL(buf,count*p_len+6) = g->member[i].char_id;
+ WBUFL(buf,count*p_len+10) = g->member[i].online;
+ count++;
+ }
+ }
+
+ clif_send(buf,p_len*count,&sd->bl,SELF);
+
+ return 0;
+}
+
+/*==========================================
+ * ギルドマスター通知(14dへの応答)
+ *------------------------------------------
+ */
+int clif_guild_masterormember(struct map_session_data *sd)
+{
+ int type=0x57,fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ if(sd->state.gmaster_flag)
+ type=0xd7;
+ WFIFOHEAD(fd,packet_len_table[0x14e]);
+ WFIFOW(fd,0)=0x14e;
+ WFIFOL(fd,2)=type;
+ WFIFOSET(fd,packet_len_table[0x14e]);
+ return 0;
+}
+/*==========================================
+ * Basic Info (Territories [Valaris])
+ *------------------------------------------
+ */
+int clif_guild_basicinfo(struct map_session_data *sd)
+{
+ int fd,i,t=0;
+ struct guild *g;
+ struct guild_castle *gc=NULL;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+
+ WFIFOHEAD(fd,packet_len_table[0x1b6]);
+ WFIFOW(fd, 0)=0x1b6;//0x150;
+ WFIFOL(fd, 2)=g->guild_id;
+ WFIFOL(fd, 6)=g->guild_lv;
+ WFIFOL(fd,10)=g->connect_member;
+ WFIFOL(fd,14)=g->max_member;
+ WFIFOL(fd,18)=g->average_lv;
+ WFIFOL(fd,22)=g->exp;
+ WFIFOL(fd,26)=g->next_exp;
+ WFIFOL(fd,30)=0; // 上納
+ WFIFOL(fd,34)=0; // VW(性格の悪さ?:性向グラフ左右)
+ WFIFOL(fd,38)=0; // RF(正義の度合い?:性向グラフ上下)
+ WFIFOL(fd,42)=0; // 人数?
+ memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH);
+ memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH);
+
+ for(i=0;i<MAX_GUILDCASTLE;i++){
+ gc=guild_castle_search(i);
+ if(!gc) continue;
+ if(g->guild_id == gc->guild_id) t++;
+ }
+ if (t>=0 && t<=MAX_GUILDCASTLE) //(0=None, 1..24 = N of Casles) [Lupus]
+ strncpy((char*)WFIFOP(fd,94),msg_txt(300+t),20);
+ else
+ strncpy((char*)WFIFOP(fd,94),msg_txt(299),20);
+
+ WFIFOSET(fd,packet_len_table[WFIFOW(fd,0)]);
+ clif_guild_emblem(sd,g); // Guild emblem vanish fix [Valaris]
+ return 0;
+}
+
+/*==========================================
+ * ギルド同盟/敵対情報
+ *------------------------------------------
+ */
+int clif_guild_allianceinfo(struct map_session_data *sd)
+{
+ int fd,i,c;
+ struct guild *g;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+ WFIFOHEAD(fd, MAX_GUILDALLIANCE * 32 + 4);
+ WFIFOW(fd, 0)=0x14c;
+ for(i=c=0;i<MAX_GUILDALLIANCE;i++){
+ struct guild_alliance *a=&g->alliance[i];
+ if(a->guild_id>0){
+ WFIFOL(fd,c*32+4)=a->opposition;
+ WFIFOL(fd,c*32+8)=a->guild_id;
+ memcpy(WFIFOP(fd,c*32+12),a->name,NAME_LENGTH);
+ c++;
+ }
+ }
+ WFIFOW(fd, 2)=c*32+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+
+/*==========================================
+ * ギルドメンバーリスト
+ *------------------------------------------
+ */
+int clif_guild_memberlist(struct map_session_data *sd)
+{
+ int fd;
+ int i,c;
+ struct guild *g;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ if (!fd)
+ return 0;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+
+ WFIFOHEAD(fd, g->max_member * 104 + 4);
+ WFIFOW(fd, 0)=0x154;
+ for(i=0,c=0;i<g->max_member;i++){
+ struct guild_member *m=&g->member[i];
+ if(m->account_id==0)
+ continue;
+ WFIFOL(fd,c*104+ 4)=m->account_id;
+ WFIFOL(fd,c*104+ 8)=m->char_id;
+ WFIFOW(fd,c*104+12)=m->hair;
+ WFIFOW(fd,c*104+14)=m->hair_color;
+ WFIFOW(fd,c*104+16)=m->gender;
+ WFIFOW(fd,c*104+18)=m->class_;
+ WFIFOW(fd,c*104+20)=m->lv;
+ WFIFOL(fd,c*104+22)=m->exp;
+ WFIFOL(fd,c*104+26)=m->online;
+ WFIFOL(fd,c*104+30)=m->position;
+ malloc_tsetword(WFIFOP(fd,c*104+34),0,50); // メモ?
+ memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH);
+ c++;
+ }
+ WFIFOW(fd, 2)=c*104+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+/*==========================================
+ * ギルド役職名リスト
+ *------------------------------------------
+ */
+int clif_guild_positionnamelist(struct map_session_data *sd)
+{
+ int i,fd;
+ struct guild *g;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+ WFIFOHEAD(fd, MAX_GUILDPOSITION * 28 + 4);
+ WFIFOW(fd, 0)=0x166;
+ for(i=0;i<MAX_GUILDPOSITION;i++){
+ WFIFOL(fd,i*28+4)=i;
+ memcpy(WFIFOP(fd,i*28+8),g->position[i].name,NAME_LENGTH);
+ }
+ WFIFOW(fd,2)=i*28+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+/*==========================================
+ * ギルド役職情報リスト
+ *------------------------------------------
+ */
+int clif_guild_positioninfolist(struct map_session_data *sd)
+{
+ int i,fd;
+ struct guild *g;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+ WFIFOHEAD(fd, MAX_GUILDPOSITION * 16 + 4);
+ WFIFOW(fd, 0)=0x160;
+ for(i=0;i<MAX_GUILDPOSITION;i++){
+ struct guild_position *p=&g->position[i];
+ WFIFOL(fd,i*16+ 4)=i;
+ WFIFOL(fd,i*16+ 8)=p->mode;
+ WFIFOL(fd,i*16+12)=i;
+ WFIFOL(fd,i*16+16)=p->exp_mode;
+ }
+ WFIFOW(fd, 2)=i*16+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+/*==========================================
+ * ギルド役職変更通知
+ *------------------------------------------
+ */
+int clif_guild_positionchanged(struct guild *g,int idx)
+{
+ struct map_session_data *sd;
+ unsigned char buf[128];
+
+ nullpo_retr(0, g);
+
+ WBUFW(buf, 0)=0x174;
+ WBUFW(buf, 2)=44;
+ WBUFL(buf, 4)=idx;
+ WBUFL(buf, 8)=g->position[idx].mode;
+ WBUFL(buf,12)=idx;
+ WBUFL(buf,16)=g->position[idx].exp_mode;
+ memcpy(WBUFP(buf,20),g->position[idx].name,NAME_LENGTH);
+ if( (sd=guild_getavailablesd(g))!=NULL )
+ clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
+ return 0;
+}
+/*==========================================
+ * ギルドメンバ変更通知
+ *------------------------------------------
+ */
+int clif_guild_memberpositionchanged(struct guild *g,int idx)
+{
+ struct map_session_data *sd;
+ unsigned char buf[64];
+
+ nullpo_retr(0, g);
+
+ WBUFW(buf, 0)=0x156;
+ WBUFW(buf, 2)=16;
+ WBUFL(buf, 4)=g->member[idx].account_id;
+ WBUFL(buf, 8)=g->member[idx].char_id;
+ WBUFL(buf,12)=g->member[idx].position;
+ if( (sd=guild_getavailablesd(g))!=NULL )
+ clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
+ return 0;
+}
+/*==========================================
+ * ギルドエンブレム送信
+ *------------------------------------------
+ */
+int clif_guild_emblem(struct map_session_data *sd,struct guild *g)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, g);
+
+ fd=sd->fd;
+
+ if(g->emblem_len<=0)
+ return 0;
+ WFIFOHEAD(fd,g->emblem_len+12);
+ WFIFOW(fd,0)=0x152;
+ WFIFOW(fd,2)=g->emblem_len+12;
+ WFIFOL(fd,4)=g->guild_id;
+ WFIFOL(fd,8)=g->emblem_id;
+ memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len);
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+/*==========================================
+ * ギルドスキル送信
+ *------------------------------------------
+ */
+int clif_guild_skillinfo(struct map_session_data *sd)
+{
+ int fd;
+ int i,id,c,up=1;
+ struct guild *g;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+ WFIFOHEAD(fd, MAX_GUILDSKILL * 37 + 6);
+ WFIFOW(fd,0)=0x0162;
+ WFIFOW(fd,4)=g->skill_point;
+ for(i=c=0;i<MAX_GUILDSKILL;i++){
+ if(g->skill[i].id>0 && guild_check_skill_require(g,g->skill[i].id)){
+ WFIFOW(fd,c*37+ 6) = id = g->skill[i].id;
+ WFIFOW(fd,c*37+ 8) = skill_get_inf(id);
+ WFIFOW(fd,c*37+10) = 0;
+ WFIFOW(fd,c*37+12) = g->skill[i].lv;
+ WFIFOW(fd,c*37+14) = skill_get_sp(id,g->skill[i].lv);
+ WFIFOW(fd,c*37+16) = skill_get_range(id,g->skill[i].lv);
+ strncpy(WFIFOP(fd,c*37+18), skill_get_name(id), NAME_LENGTH);
+ if(g->skill[i].lv < guild_skill_get_max(id) && (sd == g->member[0].sd))
+ up = 1;
+ else
+ up = 0;
+ WFIFOB(fd,c*37+42)= up;
+ c++;
+ }
+ }
+ WFIFOW(fd,2)=c*37+6;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+/*==========================================
+ * ギルド告知送信
+ *------------------------------------------
+ */
+int clif_guild_notice(struct map_session_data *sd,struct guild *g)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, g);
+
+ fd = sd->fd;
+
+ if ( !session_isActive(fd) ) //null pointer right here [Kevin]
+ return 0;
+
+ if (fd <= 0)
+ return 0;
+ if(*g->mes1==0 && *g->mes2==0)
+ return 0;
+ WFIFOHEAD(fd,packet_len_table[0x16f]);
+ WFIFOW(fd,0)=0x16f;
+ memcpy(WFIFOP(fd,2),g->mes1,60);
+ memcpy(WFIFOP(fd,62),g->mes2,120);
+ WFIFOSET(fd,packet_len_table[0x16f]);
+ return 0;
+}
+
+/*==========================================
+ * ギルドメンバ勧誘
+ *------------------------------------------
+ */
+int clif_guild_invite(struct map_session_data *sd,struct guild *g)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, g);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x16a]);
+ WFIFOW(fd,0)=0x16a;
+ WFIFOL(fd,2)=g->guild_id;
+ memcpy(WFIFOP(fd,6),g->name,NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0x16a]);
+ return 0;
+}
+/*==========================================
+ * ギルドメンバ勧誘結果
+ *------------------------------------------
+ */
+int clif_guild_inviteack(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x169]);
+ WFIFOW(fd,0)=0x169;
+ WFIFOB(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x169]);
+ return 0;
+}
+/*==========================================
+ * ギルドメンバ脱退通知
+ *------------------------------------------
+ */
+int clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes)
+{
+ unsigned char buf[128];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf, 0)=0x15a;
+ memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
+ memcpy(WBUFP(buf,26),mes,40);
+ clif_send(buf,packet_len_table[0x15a],&sd->bl,GUILD);
+ return 0;
+}
+/*==========================================
+ * ギルドメンバ追放通知
+ *------------------------------------------
+ */
+int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char *mes,
+ int account_id)
+{
+ unsigned char buf[128];
+
+ nullpo_retr(0, sd);
+
+ WBUFW(buf, 0)=0x15c;
+ memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
+ memcpy(WBUFP(buf,26),mes,40);
+ memcpy(WBUFP(buf,66),"dummy",NAME_LENGTH);
+ clif_send(buf,packet_len_table[0x15c],&sd->bl,GUILD);
+ return 0;
+}
+/*==========================================
+ * ギルド追放メンバリスト
+ *------------------------------------------
+ */
+int clif_guild_expulsionlist(struct map_session_data *sd)
+{
+ int fd;
+ int i,c;
+ struct guild *g;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ g=guild_search(sd->status.guild_id);
+ if(g==NULL)
+ return 0;
+ WFIFOHEAD(fd,MAX_GUILDEXPULSION * 88 + 4);
+ WFIFOW(fd,0)=0x163;
+ for(i=c=0;i<MAX_GUILDEXPULSION;i++){
+ struct guild_expulsion *e=&g->expulsion[i];
+ if(e->account_id>0){
+ memcpy(WFIFOP(fd,c*88+ 4),e->name,NAME_LENGTH);
+ memcpy(WFIFOP(fd,c*88+28),e->acc,24);
+ memcpy(WFIFOP(fd,c*88+52),e->mes,44);
+ c++;
+ }
+ }
+ WFIFOW(fd,2)=c*88+4;
+ WFIFOSET(fd,WFIFOW(fd,2));
+ return 0;
+}
+
+/*==========================================
+ * ギルド会話
+ *------------------------------------------
+ */
+int clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
+{
+ struct map_session_data *sd;
+ unsigned char *buf;
+
+ buf = (unsigned char*)aMallocA((len + 4)*sizeof(unsigned char));
+
+ WBUFW(buf, 0) = 0x17f;
+ WBUFW(buf, 2) = len + 4;
+ memcpy(WBUFP(buf,4), mes, len);
+
+ if ((sd = guild_getavailablesd(g)) != NULL)
+ clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD);
+
+ if(buf) aFree(buf);
+
+ return 0;
+}
+/*==========================================
+ * ギルドスキル割り振り通知
+ *------------------------------------------
+ */
+int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,11);
+ WFIFOW(fd,0) = 0x10e;
+ WFIFOW(fd,2) = skill_num;
+ WFIFOW(fd,4) = lv;
+ WFIFOW(fd,6) = skill_get_sp(skill_num,lv);
+ WFIFOW(fd,8) = skill_get_range(skill_num,lv);
+ WFIFOB(fd,10) = 1;
+ WFIFOSET(fd,11);
+ return 0;
+}
+/*==========================================
+ * ギルド同盟要請
+ *------------------------------------------
+ */
+int clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x171]);
+ WFIFOW(fd,0)=0x171;
+ WFIFOL(fd,2)=account_id;
+ memcpy(WFIFOP(fd,6),name,NAME_LENGTH);
+ WFIFOSET(fd,packet_len_table[0x171]);
+ return 0;
+}
+/*==========================================
+ * ギルド同盟結果
+ *------------------------------------------
+ */
+int clif_guild_allianceack(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x173]);
+ WFIFOW(fd,0)=0x173;
+ WFIFOL(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x173]);
+ return 0;
+}
+/*==========================================
+ * ギルド関係解消通知
+ *------------------------------------------
+ */
+int clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd = sd->fd;
+ if (fd <= 0)
+ return 0;
+ WFIFOHEAD(fd,packet_len_table[0x184]);
+ WFIFOW(fd,0)=0x184;
+ WFIFOL(fd,2)=guild_id;
+ WFIFOL(fd,6)=flag;
+ WFIFOSET(fd,packet_len_table[0x184]);
+ return 0;
+}
+/*==========================================
+ * ギルド敵対結果
+ *------------------------------------------
+ */
+int clif_guild_oppositionack(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x181]);
+ WFIFOW(fd,0)=0x181;
+ WFIFOB(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x181]);
+ return 0;
+}
+/*==========================================
+ * ギルド関係追加
+ *------------------------------------------
+ */
+/*int clif_guild_allianceadded(struct guild *g,int idx)
+{
+ unsigned char buf[64];
+ WBUFW(fd,0)=0x185;
+ WBUFL(fd,2)=g->alliance[idx].opposition;
+ WBUFL(fd,6)=g->alliance[idx].guild_id;
+ memcpy(WBUFP(fd,10),g->alliance[idx].name,NAME_LENGTH);
+ clif_send(buf,packet_len_table[0x185],guild_getavailablesd(g),GUILD);
+ return 0;
+}*/
+
+/*==========================================
+ * ギルド解散通知
+ *------------------------------------------
+ */
+int clif_guild_broken(struct map_session_data *sd,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x15e]);
+ WFIFOW(fd,0)=0x15e;
+ WFIFOL(fd,2)=flag;
+ WFIFOSET(fd,packet_len_table[0x15e]);
+ return 0;
+}
+
+/*==========================================
+ * エモーション
+ *------------------------------------------
+ */
+void clif_emotion(struct block_list *bl,int type)
+{
+ unsigned char buf[8];
+
+ nullpo_retv(bl);
+
+ WBUFW(buf,0)=0xc0;
+ WBUFL(buf,2)=bl->id;
+ WBUFB(buf,6)=type;
+ clif_send(buf,packet_len_table[0xc0],bl,AREA);
+}
+
+/*==========================================
+ * トーキーボックス
+ *------------------------------------------
+ */
+void clif_talkiebox(struct block_list *bl,char* talkie)
+{
+ unsigned char buf[86];
+
+ nullpo_retv(bl);
+
+ WBUFW(buf,0)=0x191;
+ WBUFL(buf,2)=bl->id;
+ memcpy(WBUFP(buf,6),talkie,MESSAGE_SIZE);
+ clif_send(buf,packet_len_table[0x191],bl,AREA);
+}
+
+/*==========================================
+ * 結婚エフェクト
+ *------------------------------------------
+ */
+void clif_wedding_effect(struct block_list *bl) {
+ unsigned char buf[6];
+
+ nullpo_retv(bl);
+
+ WBUFW(buf,0) = 0x1ea;
+ WBUFL(buf,2) = bl->id;
+ clif_send(buf, packet_len_table[0x1ea], bl, AREA);
+}
+/*==========================================
+ * あなたに逢いたい使用時名前叫び
+ *------------------------------------------
+
+void clif_callpartner(struct map_session_data *sd)
+{
+ unsigned char buf[26];
+ char *p;
+
+ nullpo_retv(sd);
+
+ if(sd->status.partner_id){
+ WBUFW(buf,0)=0x1e6;
+ p = map_charid2nick(sd->status.partner_id);
+ if(p){
+ memcpy(WBUFP(buf,2),p,NAME_LENGTH);
+ }else{
+ map_reqchariddb(sd,sd->status.partner_id);
+ chrif_searchcharid(sd->status.partner_id);
+ WBUFB(buf,2) = 0;
+ }
+ clif_send(buf,packet_len_table[0x1e6],&sd->bl,AREA);
+ }
+ return;
+}
+*/
+/*==========================================
+ * Adopt baby [Celest]
+ *------------------------------------------
+ */
+void clif_adopt_process(struct map_session_data *sd)
+{
+ int fd;
+ nullpo_retv(sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1f8]);
+ WFIFOW(fd,0)=0x1f8;
+ WFIFOSET(fd,packet_len_table[0x1f8]);
+}
+/*==========================================
+ * Marry [DracoRPG]
+ *------------------------------------------
+ */
+void clif_marriage_process(struct map_session_data *sd)
+{
+ int fd;
+ nullpo_retv(sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1e4]);
+ WFIFOW(fd,0)=0x1e4;
+ WFIFOSET(fd,packet_len_table[0x1e4]);
+}
+
+
+/*==========================================
+ * Notice of divorce
+ *------------------------------------------
+ */
+void clif_divorced(struct map_session_data *sd, char *name)
+{
+ int fd;
+ nullpo_retv(sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x205]);
+ WFIFOW(fd,0)=0x205;
+ memcpy(WFIFOP(fd,2), name, NAME_LENGTH);
+ WFIFOSET(fd, packet_len_table[0x205]);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
+ nullpo_retv(sd);
+
+ WFIFOHEAD(fd,packet_len_table[0x1f6]);
+ WFIFOW(fd,0)=0x1f6;
+ WFIFOSET(fd, packet_len_table[0x1f6]);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ReqMarriage(int fd, struct map_session_data *sd) {
+ nullpo_retv(sd);
+
+ WFIFOHEAD(fd,packet_len_table[0x1e2]);
+ WFIFOW(fd,0)=0x1e2;
+ WFIFOSET(fd, packet_len_table[0x1e2]);
+}
+
+/*==========================================
+ * 座る
+ *------------------------------------------
+ */
+void clif_sitting(struct map_session_data *sd)
+{
+ unsigned char buf[64];
+
+ nullpo_retv(sd);
+
+ WBUFW(buf, 0) = 0x8a;
+ WBUFL(buf, 2) = sd->bl.id;
+ WBUFB(buf,26) = 2;
+ clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
+{
+ int fd;
+ nullpo_retr(0, sd);
+ fd = sd->fd;
+ if (!fd || !len) return 0; //Disconnected player.
+ WFIFOHEAD(fd, len+5);
+ WFIFOW(fd, 0) = 0x17f;
+ WFIFOW(fd, 2) = len + 5;
+ memcpy(WFIFOP(fd,4), mes, len);
+ WFIFOSET(fd, WFIFOW(fd,2));
+ return 1;
+}
+
+/*==========================================
+ * Displays a message using the guild-chat colors to the specified targets. [Skotlex]
+ *------------------------------------------
+ */
+void clif_disp_message(struct block_list *src, char *mes, int len, int type)
+{
+ unsigned char buf[1024];
+ if (!len) return;
+ WBUFW(buf, 0) = 0x17f;
+ WBUFW(buf, 2) = len + 5;
+ memcpy(WBUFP(buf,4), mes, len);
+ clif_send(buf, WBUFW(buf,2), src, type);
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+
+int clif_GM_kickack(struct map_session_data *sd, int id)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd = sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xcd]);
+ WFIFOW(fd,0) = 0xcd;
+ WFIFOL(fd,2) = id;
+ WFIFOSET(fd, packet_len_table[0xcd]);
+ return 0;
+}
+
+void clif_parse_QuitGame(int fd,struct map_session_data *sd);
+
+int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type)
+{
+ int fd = tsd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x18b]);
+ if(type)
+ clif_GM_kickack(sd,tsd->status.account_id);
+ if (!fd) {
+ map_quit(tsd);
+ return 0;
+ }
+
+ WFIFOW(fd,0) = 0x18b;
+ WFIFOW(fd,2) = 0;
+ WFIFOSET(fd,packet_len_table[0x18b]);
+ clif_setwaitclose(fd);
+ return 0;
+}
+
+int clif_GM_silence(struct map_session_data *sd, struct map_session_data *tsd, int type)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+ nullpo_retr(0, tsd);
+
+ fd = tsd->fd;
+ if (fd <= 0)
+ return 0;
+ WFIFOHEAD(fd,packet_len_table[0x14b]);
+ WFIFOW(fd,0) = 0x14b;
+ WFIFOB(fd,2) = 0;
+ memcpy(WFIFOP(fd,3), sd->status.name, NAME_LENGTH);
+ WFIFOSET(fd, packet_len_table[0x14b]);
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+
+int clif_timedout(struct map_session_data *sd)
+{
+ nullpo_retr(0, sd);
+
+ ShowInfo("%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' timed out.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id);
+ clif_authfail_fd(sd->fd,3); // Even if player is not on we still send anyway
+ clif_setwaitclose(sd->fd); // Set session to EOF
+ return 0;
+}
+
+/*==========================================
+ * Wis拒否許可応答
+ *------------------------------------------
+ */
+int clif_wisexin(struct map_session_data *sd,int type,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xd1]);
+ WFIFOW(fd,0)=0xd1;
+ WFIFOB(fd,2)=type;
+ WFIFOB(fd,3)=flag;
+ WFIFOSET(fd,packet_len_table[0xd1]);
+
+ return 0;
+}
+/*==========================================
+ * Wis全拒否許可応答
+ *------------------------------------------
+ */
+int clif_wisall(struct map_session_data *sd,int type,int flag)
+{
+ int fd;
+
+ nullpo_retr(0, sd);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0xd2]);
+ WFIFOW(fd,0)=0xd2;
+ WFIFOB(fd,2)=type;
+ WFIFOB(fd,3)=flag;
+ WFIFOSET(fd,packet_len_table[0xd2]);
+
+ return 0;
+}
+/*==========================================
+ * サウンドエフェクト
+ *------------------------------------------
+ */
+void clif_soundeffect(struct map_session_data *sd,struct block_list *bl,char *name,int type)
+{
+ int fd;
+
+ nullpo_retv(sd);
+ nullpo_retv(bl);
+
+ fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1d3]);
+ WFIFOW(fd,0)=0x1d3;
+ memcpy(WFIFOP(fd,2),name,NAME_LENGTH);
+ WFIFOB(fd,26)=type;
+ WFIFOL(fd,27)=0;
+ WFIFOL(fd,31)=bl->id;
+ WFIFOSET(fd,packet_len_table[0x1d3]);
+
+ return;
+}
+
+int clif_soundeffectall(struct block_list *bl, char *name, int type, int coverage)
+{
+ unsigned char buf[40];
+ malloc_set(buf, 0, packet_len_table[0x1d3]);
+
+ if(coverage < 0 || coverage > 22){
+ ShowError("clif_soundeffectall: undefined coverage.\n");
+ return 0;
+ }
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0)=0x1d3;
+ memcpy(WBUFP(buf,2), name, NAME_LENGTH);
+ WBUFB(buf,26)=type;
+ WBUFL(buf,27)=0;
+ WBUFL(buf,31)=bl->id;
+ clif_send(buf, packet_len_table[0x1d3], bl, coverage);
+
+ return 0;
+}
+
+// displaying special effects (npcs, weather, etc) [Valaris]
+int clif_specialeffect(struct block_list *bl, int type, int flag)
+{
+ unsigned char buf[24];
+
+ nullpo_retr(0, bl);
+
+ malloc_set(buf, 0, packet_len_table[0x1f3]);
+
+ WBUFW(buf,0) = 0x1f3;
+ WBUFL(buf,2) = bl->id;
+ WBUFL(buf,6) = type;
+
+ clif_send(buf, packet_len_table[0x1f3], bl, flag);
+
+ if (disguised(bl)) {
+ WBUFL(buf,2) = -bl->id;
+ clif_send(buf, packet_len_table[0x1f3], bl, SELF);
+ }
+ return 0;
+}
+
+// refresh the client's screen, getting rid of any effects
+int clif_refresh(struct map_session_data *sd) {
+ nullpo_retr(-1, sd);
+ clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
+ clif_inventorylist(sd);
+ if(pc_iscarton(sd)){
+ clif_cartlist(sd);
+ clif_updatestatus(sd,SP_CARTINFO);
+ }
+ clif_updatestatus(sd,SP_MAXWEIGHT);
+ clif_updatestatus(sd,SP_WEIGHT);
+ map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
+ clif_weather_check(sd);
+ return 0;
+}
+
+// updates the object's (bl) name on client
+int clif_charnameack (int fd, struct block_list *bl)
+{
+ unsigned char buf[103];
+ int cmd = 0x95;
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf,0) = cmd;
+ WBUFL(buf,2) = bl->id;
+
+ switch(bl->type) {
+ case BL_PC:
+ {
+ struct map_session_data *ssd = (struct map_session_data *)bl;
+ struct party_data *p = NULL;
+ struct guild *g = NULL;
+
+ //Requesting your own "shadow" name. [Skotlex]
+ if (ssd->fd == fd && ssd->disguise)
+ WBUFL(buf,2) = -bl->id;
+
+ if (strlen(ssd->fakename)>1) {
+ memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH);
+ break;
+ }
+ memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
+
+ if (ssd->status.party_id > 0)
+ p = party_search(ssd->status.party_id);
+
+ if (ssd->status.guild_id > 0)
+ g = guild_search(ssd->status.guild_id);
+
+ if (p == NULL && g == NULL)
+ break;
+
+ WBUFW(buf, 0) = cmd = 0x195;
+ if (p)
+ memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
+ else
+ WBUFB(buf,30) = 0;
+
+ if (g)
+ {
+ int i, ps = -1;
+ for(i = 0; i < g->max_member; i++) {
+ if (g->member[i].account_id == ssd->status.account_id &&
+ g->member[i].char_id == ssd->status.char_id )
+ {
+ ps = g->member[i].position;
+ break;
+ }
+ }
+ if (ps >= 0 && ps < MAX_GUILDPOSITION)
+ {
+ memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
+ memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
+ } else { //Assume no guild.
+ WBUFB(buf,54) = 0;
+ WBUFB(buf,78) = 0;
+ }
+ } else {
+ WBUFB(buf,54) = 0;
+ WBUFB(buf,78) = 0;
+ }
+ }
+ break;
+ //[blackhole89]
+ case BL_HOM:
+ memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH);
+ break;
+ case BL_PET:
+ memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH);
+ break;
+ case BL_NPC:
+ memcpy(WBUFP(buf,6), ((TBL_NPC*)bl)->name, NAME_LENGTH);
+ break;
+ case BL_MOB:
+ {
+ struct mob_data *md = (struct mob_data *)bl;
+ nullpo_retr(0, md);
+
+ memcpy(WBUFP(buf,6), md->name, NAME_LENGTH);
+ if (md->guardian_data && md->guardian_data->guild_id) {
+ WBUFW(buf, 0) = cmd = 0x195;
+ WBUFB(buf,30) = 0;
+ memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH);
+ memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH);
+ } else if (battle_config.show_mob_info) {
+ char mobhp[50], *str_p = mobhp;
+
+ WBUFW(buf, 0) = cmd = 0x195;
+ if (battle_config.show_mob_info&4)
+ str_p += sprintf(str_p, "Lv. %d | ", md->level);
+ if (battle_config.show_mob_info&1)
+ str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
+ if (battle_config.show_mob_info&2)
+ str_p += sprintf(str_p, "HP: %d%% | ",
+ md->status.max_hp > 10000?
+ md->status.hp/(md->status.max_hp/100):
+ 100*md->status.hp/md->status.max_hp);
+ //Even thought mobhp ain't a name, we send it as one so the client
+ //can parse it. [Skotlex]
+ if (str_p != mobhp) {
+ *(str_p-3) = '\0'; //Remove trailing space + pipe.
+ memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH);
+ WBUFB(buf,54) = 0;
+ memcpy(WBUFP(buf,78), mobhp, NAME_LENGTH);
+ }
+ }
+ }
+ break;
+ case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex]
+// memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH);
+// break;
+ return 0;
+ default:
+ if (battle_config.error_log)
+ ShowError("clif_parse_GetCharNameRequest : bad type %d(%d)\n", bl->type, bl->id);
+ return 0;
+ }
+
+ // if no receipient specified just update nearby clients
+ if (fd == 0)
+ clif_send(buf, packet_len_table[cmd], bl, AREA);
+ else {
+ WFIFOHEAD(fd, packet_len_table[cmd]);
+ memcpy(WFIFOP(fd, 0), buf, packet_len_table[cmd]);
+ WFIFOSET(fd, packet_len_table[cmd]);
+ }
+
+ return 0;
+}
+
+//Used to update when a char leaves a party/guild. [Skotlex]
+//Needed because when you send a 0x95 packet, the client will not remove the cached party/guild info that is not sent.
+int clif_charnameupdate (struct map_session_data *ssd)
+{
+ unsigned char buf[103];
+ int cmd = 0x195;
+ struct party_data *p = NULL;
+ struct guild *g = NULL;
+
+ nullpo_retr(0, ssd);
+
+ if (strlen(ssd->fakename)>1)
+ return 0; //No need to update as the party/guild was not displayed anyway.
+
+ WBUFW(buf,0) = cmd;
+ WBUFL(buf,2) = ssd->bl.id;
+
+ memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
+
+ if (ssd->status.party_id > 0)
+ p = party_search(ssd->status.party_id);
+
+ if (ssd->status.guild_id > 0)
+ g = guild_search(ssd->status.guild_id);
+
+ if (p)
+ memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH);
+ else
+ WBUFB(buf,30) = 0;
+
+ if (g)
+ {
+ int i, ps = -1;
+ for(i = 0; i < g->max_member; i++) {
+ if (g->member[i].account_id == ssd->status.account_id &&
+ g->member[i].char_id == ssd->status.char_id )
+ {
+ ps = g->member[i].position;
+ break;
+ }
+ }
+ if (ps >= 0 && ps < MAX_GUILDPOSITION)
+ {
+ memcpy(WBUFP(buf,54), g->name,NAME_LENGTH);
+ memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH);
+ } else { //Assume no guild.
+ WBUFB(buf,54) = 0;
+ WBUFB(buf,78) = 0;
+ }
+ } else {
+ WBUFB(buf,54) = 0;
+ WBUFB(buf,78) = 0;
+ }
+
+ // Update nearby clients
+ clif_send(buf, packet_len_table[cmd], &ssd->bl, AREA);
+ return 0;
+}
+
+int clif_slide(struct block_list *bl, int x, int y){
+ unsigned char buf[10];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf, 0) = 0x01ff;
+ WBUFL(buf, 2) = bl->id;
+ WBUFW(buf, 6) = x;
+ WBUFW(buf, 8) = y;
+
+ clif_send(buf, packet_len_table[0x1ff], bl, AREA);
+ return 0;
+}
+
+/*------------------------------------------
+ * @me command by lordalfa, rewritten implementation by Skotlex
+ *------------------------------------------
+*/
+int clif_disp_overhead(struct map_session_data *sd, char* mes)
+{
+ unsigned char buf[256]; //This should be more than sufficient, the theorical max is MESSAGE_SIZE+NAME_LENGTH + 8 (pads and extra inserted crap)
+ int len_mes = strlen(mes)+1; //Account for \0
+
+ if (len_mes + 8 >= 256) {
+ if (battle_config.error_log)
+ ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes);
+ len_mes = 247; //Trunk it to avoid problems.
+ }
+ // send message to others
+ WBUFW(buf,0) = 0x8d;
+ WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id)
+ WBUFL(buf,4) = sd->bl.id;
+ memcpy(WBUFP(buf,8), mes, len_mes);
+ clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC);
+
+ // send back message to the speaker
+ WBUFW(buf,0) = 0x8e;
+ WBUFW(buf, 2) = len_mes + 4;
+ memcpy(WBUFP(buf,4), mes, len_mes);
+ clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
+
+ return 0;
+}
+
+/*==========================
+ * Minimap fix [Kevin]
+ * Remove dot from minimap
+ *--------------------------
+*/
+int clif_party_xy_remove(struct map_session_data *sd)
+{
+ unsigned char buf[16];
+ nullpo_retr(0, sd);
+ WBUFW(buf,0)=0x107;
+ WBUFL(buf,2)=sd->status.account_id;
+ WBUFW(buf,6)=-1;
+ WBUFW(buf,8)=-1;
+ clif_send(buf,packet_len_table[0x107],&sd->bl,PARTY_SAMEMAP_WOS);
+ return 0;
+}
+
+//Displays gospel-buff information (thanks to Rayce):
+//Type determines message based on this table:
+/*
+ 0x15 End all negative status
+ 0x16 Immunity to all status
+ 0x17 MaxHP +100%
+ 0x18 MaxSP +100%
+ 0x19 All stats +20
+ 0x1c Enchant weapon with Holy element
+ 0x1d Enchant armor with Holy element
+ 0x1e DEF +25%
+ 0x1f ATK +100%
+ 0x20 HIT/Flee +50
+ 0x28 Full strip failed because of coating (unrelated to gospel, maybe for ST_FULLSTRIP)
+*/
+void clif_gospel_info(struct map_session_data *sd, int type)
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x215]);
+ WFIFOW(fd,0)=0x215;
+ WFIFOL(fd,2)=type;
+ WFIFOSET(fd, packet_len_table[0x215]);
+
+}
+/*==========================================
+ * Info about Star Glaldiator save map [Komurka]
+ * type: 1: Information, 0: Map registered
+ *------------------------------------------
+ */
+void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsigned char type)
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x20e]);
+ WFIFOW(fd,0)=0x20e;
+ memcpy(WFIFOP(fd,2),mapindex_id2name(sd->feel_map[feel_level].index), MAP_NAME_LENGTH);
+ WFIFOL(fd,26)=sd->bl.id;
+ WFIFOB(fd,30)=feel_level;
+ WFIFOB(fd,31)=type?1:0;
+ WFIFOSET(fd, packet_len_table[0x20e]);
+}
+
+/*==========================================
+ * Info about Star Glaldiator hate mob [Komurka]
+ * type: 1: Register mob, 0: Information.
+ *------------------------------------------
+ */
+void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type)
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x20e]);
+ WFIFOW(fd,0)=0x20e;
+ if (pcdb_checkid(class_))
+ strncpy(WFIFOP(fd,2),job_name(class_), NAME_LENGTH);
+ else if (mobdb_checkid(class_))
+ strncpy(WFIFOP(fd,2),mob_db(class_)->jname, NAME_LENGTH);
+ else //Really shouldn't happen...
+ malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH);
+ WFIFOL(fd,26)=sd->bl.id;
+ WFIFOB(fd,30)=hate_level;
+ WFIFOB(fd,31)=type?10:11; //Register/Info
+ WFIFOSET(fd, packet_len_table[0x20e]);
+}
+
+/*==========================================
+ * Info about TaeKwon Do TK_MISSION mob [Skotlex]
+ *------------------------------------------
+ */
+void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress)
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x20e]);
+ WFIFOW(fd,0)=0x20e;
+ strncpy(WFIFOP(fd,2),mob_db(mob_id)->jname, NAME_LENGTH);
+ WFIFOL(fd,26)=mob_id;
+ WFIFOB(fd,30)=progress; //Message to display
+ WFIFOB(fd,31)=20;
+ WFIFOSET(fd, packet_len_table[0x20e]);
+}
+
+/*==========================================
+ * Feel/Hate reset (thanks to Rayce) [Skotlex]
+ *------------------------------------------
+ */
+void clif_feel_hate_reset(struct map_session_data *sd)
+{
+ int fd=sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x20e]);
+ WFIFOW(fd,0)=0x20e;
+ malloc_tsetdword(WFIFOP(fd,2), 0, NAME_LENGTH); //Blank name as all was reset.
+ WFIFOL(fd,26)=sd->bl.id;
+ WFIFOB(fd,30)=0; //Feel/hate level: irrelevant
+ WFIFOB(fd,31)=30;
+ WFIFOSET(fd, packet_len_table[0x20e]);
+}
+
+// ---------------------
+// clif_guess_PacketVer
+// ---------------------
+// Parses a WantToConnection packet to try to identify which is the packet version used. [Skotlex]
+static int clif_guess_PacketVer(int fd, int get_previous)
+{
+ static int packet_ver = -1;
+ int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex
+ RFIFOHEAD(fd);
+
+ if (get_previous) //For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex]
+ return packet_ver;
+
+ //By default, start searching on the default one.
+ packet_ver = clif_config.packet_db_ver;
+ cmd = RFIFOW(fd,0);
+ packet_len = RFIFOREST(fd);
+
+ if (
+ cmd == clif_config.connect_cmd[packet_ver] &&
+ packet_len == packet_db[packet_ver][cmd].len &&
+ ((value = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) == 0 || value == 1) &&
+ (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) > 700000 && //Account ID is valid
+ value <= max_account_id &&
+ (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) > 0 && //Char ID is valid
+ value <= max_char_id &&
+ (int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) > 0 //Login 1 is a positive value (?)
+ )
+ return clif_config.packet_db_ver; //Default packet version found.
+
+ for (packet_ver = MAX_PACKET_VER; packet_ver > 0; packet_ver--)
+ { //Start guessing the version, giving priority to the newer ones. [Skotlex]
+ if (cmd != clif_config.connect_cmd[packet_ver] || //it is not a wanttoconnection for this version.
+ packet_len != packet_db[packet_ver][cmd].len) //The size of the wantoconnection packet does not matches.
+ continue;
+
+ if (
+ (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < 700000 || value > max_account_id
+ || (value = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) < 1 || value > max_char_id
+ //What is login 1? In my tests it is a very very high value.
+ || (int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) < 1
+ //This check seems redundant, all wanttoconnection packets have the gender on the very
+ //last byte of the packet.
+ || (value = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) < 0 || value > 1
+ )
+ continue;
+
+ return packet_ver; //This is our best guess.
+ }
+ packet_ver = -1;
+ return -1;
+}
+
+// ------------
+// clif_parse_*
+// ------------
+// パケット読み取って色々操作
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
+{
+ struct map_session_data *old_sd;
+ int cmd, account_id, char_id, login_id1, sex;
+ unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex]
+ int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
+ RFIFOHEAD(fd);
+
+ if (sd) {
+ if (battle_config.error_log)
+ ShowError("clif_parse_WantToConnection : invalid request (character already logged in)?\n");
+ return;
+ }
+
+ packet_ver = clif_guess_PacketVer(fd, 1);
+ cmd = RFIFOW(fd,0);
+
+ if (packet_ver <= 0)
+ return;
+
+ account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]);
+ char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]);
+ login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]);
+ client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]);
+ sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]);
+
+ if ((old_sd = map_id2sd(account_id)) != NULL)
+ { // if same account already connected, we disconnect the 2 sessions
+ //Check for characters with no connection (includes those that are using autotrade) [durf],[Skotlex]
+ if (old_sd->state.finalsave || !old_sd->state.auth)
+ ; //Previous player is not done loading.
+ //Or he has quit, but is not done saving on the charserver.
+ else if (old_sd->fd)
+ clif_authfail_fd(old_sd->fd, 2); // same id
+ else
+ map_quit(old_sd);
+ clif_authfail_fd(fd, 8); // still recognizes last connection
+ return;
+ }
+ sd = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
+ sd->fd = fd;
+ sd->packet_ver = packet_ver;
+ session[fd]->session_data = sd;
+
+ pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
+ WFIFOHEAD(fd,4);
+ WFIFOL(fd,0) = sd->bl.id;
+ WFIFOSET(fd,4);
+ chrif_authreq(sd);
+ return;
+}
+
+static int clif_nighttimer(int tid, unsigned int tick, int id, int data)
+{
+ TBL_PC *sd;
+ sd=map_id2sd(id);
+ if (!sd) return 0;
+
+ //Check if character didn't instant-warped after logging in.
+ if (sd->bl.prev!=NULL) {
+ sd->state.night = 1;
+ clif_status_load(&sd->bl, SI_NIGHT, 1);
+ }
+ return 0;
+}
+
+/*==========================================
+ * 007d クライアント側マップ読み込み完了
+ * map侵入時に必要なデータを全て送りつける
+ *------------------------------------------
+ */
+void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
+{
+ if(sd->bl.prev != NULL)
+ return;
+
+ if (!sd->state.auth)
+ { //Character loading is not complete yet!
+ //Let pc_reg_received reinvoke this when ready.
+ sd->state.connect_new = 0;
+ return;
+ }
+
+ if (sd->state.rewarp)
+ { //Rewarp player.
+ sd->state.rewarp = 0;
+ clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
+ return;
+ }
+
+ // look
+#if PACKETVER < 4
+ clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
+ clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
+#else
+ clif_changelook(&sd->bl,LOOK_WEAPON,0);
+#endif
+
+ if(sd->vd.cloth_color)
+ clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
+
+ // item
+ pc_checkitem(sd);
+ clif_inventorylist(sd);
+
+ // cart
+ if(pc_iscarton(sd)){
+ clif_cartlist(sd);
+ clif_updatestatus(sd,SP_CARTINFO);
+ }
+
+ // weight max , now
+ clif_updatestatus(sd,SP_MAXWEIGHT);
+ clif_updatestatus(sd,SP_WEIGHT);
+
+ if(battle_config.pc_invincible_time > 0) {
+ if(map_flag_gvg(sd->bl.m))
+ pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1);
+ else
+ pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
+ }
+ map_addblock(&sd->bl); // ブロック登録
+ clif_spawn(&sd->bl); // spawn
+
+ // Party
+ if(sd->status.party_id) {
+ party_send_movemap(sd);
+ clif_party_hp(sd); // Show hp after displacement [LuzZza]
+ }
+
+ // guild
+ if(sd->status.guild_id)
+ guild_send_memberinfoshort(sd,1);
+
+ if(map[sd->bl.m].flag.pvp){
+ if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
+ if (!map[sd->bl.m].flag.pvp_nocalcrank)
+ sd->pvp_timer= add_timer(gettick()+200,
+ pc_calc_pvprank_timer,sd->bl.id,0);
+ sd->pvp_rank=0;
+ sd->pvp_lastusers=0;
+ sd->pvp_point=5;
+ sd->pvp_won=0;
+ sd->pvp_lost=0;
+ }
+ clif_set0199(fd,1);
+ } else
+ // set flag, if it's a duel [LuzZza]
+ if(sd->duel_group)
+ clif_set0199(fd, 1);
+
+ if (map[sd->bl.m].flag.gvg_dungeon)
+ clif_set0199(fd,2); //TODO: Figure out the real thing to do here.
+
+ if(map_flag_gvg(sd->bl.m))
+ clif_set0199(fd,3);
+
+ // pet
+ if(sd->pd) {
+ map_addblock(&sd->pd->bl);
+ clif_spawn(&sd->pd->bl);
+ clif_send_petdata(sd,0,0);
+ clif_send_petdata(sd,5,battle_config.pet_hair_style);
+ clif_send_petstatus(sd);
+// skill_unit_move(&sd->pd->bl,gettick(),1);
+ }
+
+ //homunculus [blackhole89]
+ if(merc_is_hom_active(sd->hd)) {
+ map_addblock(&sd->hd->bl);
+ clif_spawn(&sd->hd->bl);
+ clif_hominfo(sd,sd->hd,1);
+ clif_hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice
+ clif_send_homdata(sd,0,0);
+ clif_homskillinfoblock(sd);
+ //Homunc mimic their master's speed on each map change. [Skotlex]
+ if (battle_config.slaves_inherit_speed&1)
+ status_calc_bl(&sd->hd->bl, SCB_SPEED);
+// Since hom is inmune to land effects, unneeded.
+// skill_unit_move(&sd->hd->bl,gettick(),1);
+ }
+
+ if(sd->state.connect_new) {
+ int lv;
+ struct guild *g;
+ sd->state.connect_new = 0;
+ clif_skillinfoblock(sd);
+ clif_updatestatus(sd,SP_NEXTBASEEXP);
+ clif_updatestatus(sd,SP_NEXTJOBEXP);
+ clif_updatestatus(sd,SP_SKILLPOINT);
+ clif_initialstatus(sd);
+
+ if (sd->sc.option&OPTION_FALCON)
+ clif_status_load(&sd->bl, SI_FALCON, 1);
+
+ if (sd->sc.option&OPTION_RIDING)
+ clif_status_load(&sd->bl, SI_RIDING, 1);
+
+ if(sd->status.manner < 0)
+ sc_start(&sd->bl,SC_NOCHAT,100,0,0);
+
+ //Auron reported that This skill only triggers when you logon on the map o.O [Skotlex]
+ if ((lv = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) {
+ if(sd->bl.m == sd->feel_map[0].m
+ || sd->bl.m == sd->feel_map[1].m
+ || sd->bl.m == sd->feel_map[2].m)
+ sc_start(&sd->bl, SC_KNOWLEDGE, 100, lv, skill_get_time(SG_KNOWLEDGE, lv));
+ }
+
+ if(sd->pd && sd->pd->pet.intimate > 900)
+ clif_pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd));
+ if(sd->hd)
+ merc_hom_init_timers(sd->hd);
+
+ if (sd->status.guild_id > 0 && !sd->state.gmaster_flag &&
+ (g=guild_search(sd->status.guild_id)) &&
+ strcmp(sd->status.name,g->master) == 0)
+ { //Block Guild Skills to prevent logout/login reuse exploiting. [Skotlex]
+ guild_block_skill(sd, 300000);
+ //Also set the Guild Master flag.
+ sd->state.gmaster_flag = g;
+ }
+
+ //Delayed night effect on log-on fix for the glow-issue. Thanks to Larry.
+ if (night_flag && map[sd->bl.m].flag.nightenabled)
+ add_timer(gettick()+1000,clif_nighttimer,sd->bl.id,0);
+
+ // Notify everyone that this char logged in [Skotlex].
+ clif_foreachclient(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
+
+ //Login Event
+ npc_script_event(sd, NPCE_LOGIN);
+ } else {
+ //For some reason the client "loses" these on map-change.
+ clif_updatestatus(sd,SP_STR);
+ clif_updatestatus(sd,SP_AGI);
+ clif_updatestatus(sd,SP_VIT);
+ clif_updatestatus(sd,SP_INT);
+ clif_updatestatus(sd,SP_DEX);
+ clif_updatestatus(sd,SP_LUK);
+
+ sd->state.using_fake_npc = 0;
+
+ //New 'night' effect by dynamix [Skotlex]
+ if (night_flag && map[sd->bl.m].flag.nightenabled)
+ { //Display night.
+ if (sd->state.night) //It must be resent because otherwise players get this annoying aura...
+ clif_status_load(&sd->bl, SI_NIGHT, 0);
+ else
+ sd->state.night = 1;
+ clif_status_load(&sd->bl, SI_NIGHT, 1);
+ } else if (sd->state.night) { //Clear night display.
+ sd->state.night = 0;
+ clif_status_load(&sd->bl, SI_NIGHT, 0);
+ }
+
+ if(sd->npc_id)
+ npc_event_dequeue(sd);
+ }
+
+ // Lance
+ if(sd->state.event_loadmap && map[sd->bl.m].flag.loadevent){
+ pc_setregstr(sd, add_str("@maploaded$"), map[sd->bl.m].name);
+ npc_script_event(sd, NPCE_LOADMAP);
+ }
+
+ if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
+ clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka]
+
+ clif_weather_check(sd);
+
+ map_foreachinarea(clif_getareachar,sd->bl.m,
+ sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,sd->bl.x+AREA_SIZE,sd->bl.y+AREA_SIZE,
+ BL_ALL,sd);
+
+ // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first)
+ if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
+ npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
+ else
+ sd->areanpc_id = 0;
+
+ // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris]
+ if(pc_isdead(sd))
+ clif_clearchar_area(&sd->bl,1);
+
+// Uncomment if you want to make player face in the same direction he was facing right before warping. [Skotlex]
+// else
+// clif_changed_dir(&sd->bl, SELF);
+// Trigger skill effects if you appear standing on them
+ if(!battle_config.pc_invincible_time)
+ skill_unit_move(&sd->bl,gettick(),1);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_TickSend(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ sd->client_tick=RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+
+ WFIFOHEAD(fd, packet_len_table[0x7f]);
+ WFIFOW(fd,0)=0x7f;
+ WFIFOL(fd,2)=gettick();
+ WFIFOSET(fd,packet_len_table[0x7f]);
+ return;
+}
+
+static int clif_walktoxy_timer(int tid, unsigned int tick, int id, int data)
+{
+ struct map_session_data *sd;
+ short x,y;
+
+ if (!session[id] || (sd = session[id]->session_data) == NULL)
+ return 0;
+
+ if (!unit_can_move(&sd->bl))
+ return 0;
+
+ x = data>>16;
+ y = data&0xffff;
+
+ unit_walktoxy(&sd->bl, x, y, 0);
+ return 1;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
+ int x, y;
+ int cmd;
+ unsigned int tick;
+ RFIFOHEAD(fd);
+
+ if (pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl, 1);
+ return;
+ }
+
+ if (clif_cant_act(sd) && sd->sc.opt1 != OPT1_STONEWAIT)
+ return;
+
+ if(sd->sc.count && sd->sc.data[SC_RUN].timer != -1)
+ return;
+
+ pc_stop_attack(sd);
+
+ if (sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+
+ cmd = RFIFOW(fd,0);
+ x = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]) * 4 +
+ (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 1) >> 6);
+ y = ((RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0]+1) & 0x3f) << 4) +
+ (RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
+ //Set last idle time... [Skotlex]
+ sd->idletime = last_tick;
+
+ tick = gettick();
+ if (DIFF_TICK(sd->ud.canmove_tick, tick) > 0 &&
+ DIFF_TICK(sd->ud.canmove_tick, tick) < 2000)
+ { // Delay walking command. [Skotlex]
+ add_timer(sd->ud.canmove_tick+1, clif_walktoxy_timer, fd, (x<<16)|y);
+ return;
+ }
+ if (!unit_can_move(&sd->bl))
+ return;
+ unit_walktoxy(&sd->bl, x, y, 0);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_QuitGame(int fd, struct map_session_data *sd) {
+ WFIFOHEAD(fd,packet_len_table[0x18b]);
+ WFIFOW(fd,0) = 0x18b;
+
+ /* Rovert's prevent logout option fixed [Valaris] */
+ if (sd->sc.data[SC_CLOAKING].timer==-1 && sd->sc.data[SC_HIDING].timer==-1 &&
+ (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
+ ) {
+ clif_setwaitclose(fd);
+ WFIFOW(fd,2)=0;
+ } else {
+ WFIFOW(fd,2)=1;
+ }
+ WFIFOSET(fd,packet_len_table[0x18b]);
+}
+
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void check_fake_id(int fd, struct map_session_data *sd, int target_id) {
+ // if player asks for the fake player (only bot and modified client can see a hiden player)
+/* if (target_id == server_char_id) {
+ char message_to_gm[strlen(msg_txt(536)) + strlen(msg_txt(540)) + strlen(msg_txt(507)) + strlen(msg_txt(508))];
+ sprintf(message_to_gm, msg_txt(536), sd->status.name, sd->status.account_id); // Character '%s' (account: %d) try to use a bot (it tries to detect a fake player).
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
+ // if we block people
+ if (battle_config.ban_bot < 0) {
+ chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
+ clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
+ // message about the ban
+ sprintf(message_to_gm, msg_txt(540)); // This player has been definitivly blocked.
+ // if we ban people
+ } else if (battle_config.ban_bot > 0) {
+ chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_bot, 0); // type: 2 - ban (year, month, day, hour, minute, second)
+ clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
+ // message about the ban
+ sprintf(message_to_gm, msg_txt(507), battle_config.ban_bot); // This player has been banned for %d minute(s).
+ } else { // impossible to display: we don't send fake player if battle_config.ban_bot is == 0
+ // message about the ban
+ sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
+ }
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
+ // send this info cause the bot ask until get an answer, damn spam
+ malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
+ WPACKETW(0) = 0x95;
+ WPACKETL(2) = server_char_id;
+ strncpy(WPACKETP(6), sd->status.name, 24);
+ SENDPACKET(fd, packet_len_table[0x95]);
+ // take fake player out of screen
+ WPACKETW(0) = 0x80;
+ WPACKETL(2) = server_char_id;
+ WPACKETB(6) = 0;
+ SENDPACKET(fd, packet_len_table[0x80]);
+ // take fake mob out of screen
+ WPACKETW(0) = 0x80;
+ WPACKETL(2) = server_fake_mob_id;
+ WPACKETB(6) = 0;
+ SENDPACKET(fd, packet_len_table[0x80]);
+ }
+
+ // if player asks for the fake mob (only bot and modified client can see a hiden mob)
+ if (target_id == server_fake_mob_id) {
+ int fake_mob;
+ char message_to_gm[strlen(msg_txt(537)) + strlen(msg_txt(540)) + strlen(msg_txt(507)) + strlen(msg_txt(508))];
+ sprintf(message_to_gm, msg_txt(537), sd->status.name, sd->status.account_id); // Character '%s' (account: %d) try to use a bot (it tries to detect a fake mob).
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
+ // if we block people
+ if (battle_config.ban_bot < 0) {
+ chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
+ clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
+ // message about the ban
+ sprintf(message_to_gm, msg_txt(540)); // This player has been definitivly blocked.
+ // if we ban people
+ } else if (battle_config.ban_bot > 0) {
+ chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_bot, 0); // type: 2 - ban (year, month, day, hour, minute, second)
+ clif_setwaitclose(sd->fd); // forced to disconnect because of the hack
+ // message about the ban
+ sprintf(message_to_gm, msg_txt(507), battle_config.ban_bot); // This player has been banned for %d minute(s).
+ } else { // impossible to display: we don't send fake player if battle_config.ban_bot is == 0
+ // message about the ban
+ sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
+ }
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm);
+ // send this info cause the bot ask until get an answer, damn spam
+ malloc_tsetdword(WPACKETP(0), 0, packet_len_table[0x95]);
+ WPACKETW(0) = 0x95;
+ WPACKETL(2) = server_fake_mob_id;
+ fake_mob = fake_mob_list[(sd->bl.m + sd->fd + sd->status.char_id) % (sizeof(fake_mob_list) / sizeof(fake_mob_list[0]))]; // never same mob
+ if (!mobdb_checkid(fake_mob))
+ fake_mob = 1002; // poring (default)
+ strncpy(WPACKETP(6), mob_db[fake_mob].name, 24);
+ SENDPACKET(fd, packet_len_table[0x95]);
+ // take fake mob out of screen
+ WPACKETW(0) = 0x80;
+ WPACKETL(2) = server_fake_mob_id;
+ WPACKETB(6) = 0;
+ SENDPACKET(fd, packet_len_table[0x80]);
+ // take fake player out of screen
+ WPACKETW(0) = 0x80;
+ WPACKETL(2) = server_char_id;
+ WPACKETB(6) = 0;
+ SENDPACKET(fd, packet_len_table[0x80]);
+ }
+*/
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
+ int account_id;
+ struct block_list* bl;
+ struct status_change *sc;
+ RFIFOHEAD(fd);
+
+ account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+
+ if(account_id<0 && -account_id == sd->bl.id) // for disguises [Valaris]
+ account_id= sd->bl.id;
+
+ bl = map_id2bl(account_id);
+ //Is this possible? Lagged clients could request names of already gone mobs/players. [Skotlex]
+ if (!bl) return;
+
+ sc = status_get_sc(bl);
+ if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && pc_isGM(sd) < battle_config.hack_info_GM_level)
+ {
+ //GM characters (with client side GM enabled are able to see invisible stuff) [Lance]
+ //Asked name of invisible player, this shouldn't be possible!
+ //Possible bot? Thanks to veider and qspirit
+ //FIXME: Still isn't perfected as clients keep asking for this on legitimate situations.
+ unsigned char gm_msg[256];
+ sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requests name of invisible chars.", sd->status.name, sd->status.account_id);
+ ShowWarning(gm_msg);
+ // information is sended to all online GM
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
+ return;
+ }
+ clif_charnameack(fd, bl);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <len>.w <str>.?B
+ char *message, *buf, buf2[128];
+ RFIFOHEAD(fd);
+ WFIFOHEAD(fd, RFIFOW(fd,2) + 4);
+
+ message = (unsigned char*)RFIFOP(fd,4);
+ if (strlen(message) < strlen(sd->status.name) || //If the incoming string is too short...
+ strncmp(message, sd->status.name, strlen(sd->status.name)) != 0) //Or the name does not matches...
+ {
+ //Hacked message, or infamous "client desynch" issue where they pick
+ //one char while loading another. Just kick them out to correct it.
+ clif_setwaitclose(fd);
+ return;
+ }
+
+ if ((is_atcommand(fd, sd, message) != AtCommand_None) ||
+ (is_charcommand(fd, sd, message) != CharCommand_None))
+ return;
+
+ if (sd->sc.count &&
+ (sd->sc.data[SC_BERSERK].timer != -1 ||
+ (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
+ return;
+
+ if (battle_config.min_chat_delay)
+ { //[Skotlex]
+ if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
+ return;
+ sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ }
+
+ if (RFIFOW(fd,2)+4 < 128)
+ buf = buf2; //Use a static buffer.
+ else
+ buf = (unsigned char*)aMallocA((RFIFOW(fd,2) + 4)*sizeof(char));
+
+ // send message to others
+ WBUFW(buf,0) = 0x8d;
+ WBUFW(buf,2) = RFIFOW(fd,2) + 4; // len of message - 4 + 8
+ WBUFL(buf,4) = sd->bl.id;
+ memcpy(WBUFP(buf,8), message, RFIFOW(fd,2) - 4);
+ clif_send(buf, WBUFW(buf,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
+
+ if(buf != buf2) aFree(buf);
+
+ // send back message to the speaker
+ memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));
+ WFIFOW(fd,0) = 0x8e;
+ WFIFOSET(fd, WFIFOW(fd,2));
+
+#ifdef PCRE_SUPPORT
+ map_foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, message, strlen(message), &sd->bl);
+ map_foreachinrange(mob_chat_sub, &sd->bl, AREA_SIZE, BL_MOB, message, strlen(message), &sd->bl);
+#endif
+
+ // Celest
+ if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { //Super Novice.
+ int next = pc_nextbaseexp(sd);
+ if (next > 0 && (sd->status.base_exp * 1000 / next)% 100 == 0) {
+ switch (sd->state.snovice_flag) {
+ case 0:
+ if (strstr(message, msg_txt(504)))
+ sd->state.snovice_flag++;
+ break;
+ case 1:
+ sprintf(buf2, msg_txt(505), sd->status.name);
+ if (strstr(message, buf2))
+ sd->state.snovice_flag++;
+ break;
+ case 2:
+ if (strstr(message, msg_txt(506)))
+ sd->state.snovice_flag++;
+ break;
+ case 3:
+ if (skillnotok(MO_EXPLOSIONSPIRITS,sd))
+ break; //Do not override the noskill mapflag. [Skotlex]
+ clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,-1,
+ sc_start(&sd->bl,SkillStatusChangeTable(MO_EXPLOSIONSPIRITS),100,
+ 17,skill_get_time(MO_EXPLOSIONSPIRITS,1))); //Lv17-> +50 critical (noted by Poki) [Skotlex]
+ sd->state.snovice_flag = 0;
+ break;
+ }
+ }
+ }
+ return;
+}
+
+int clif_message(struct block_list *bl, char* msg)
+{
+ unsigned short msg_len = strlen(msg) + 1;
+ unsigned char buf[256];
+
+ nullpo_retr(0, bl);
+
+ WBUFW(buf, 0) = 0x8d;
+ WBUFW(buf, 2) = msg_len + 8;
+ WBUFL(buf, 4) = bl->id;
+ memcpy(WBUFP(buf, 8), msg, msg_len);
+
+ clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); // by Gengar
+
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_MapMove(int fd, struct map_session_data *sd) {
+// /m /mapmove (as @rura GM command)
+ char output[30]; // 17+4+4=26, 30 max.
+ char message[34]; // "/mm "+output
+ char map_name[MAP_NAME_LENGTH]; //Err... map names are 15+'\0' in size, not 16+'\0' [Skotlex]
+ RFIFOHEAD(fd);
+
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_MapMove))) {
+ memcpy(map_name, RFIFOP(fd,2), MAP_NAME_LENGTH-1);
+ map_name[MAP_NAME_LENGTH-1]='\0';
+ sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
+ atcommand_rura(fd, sd, "@rura", output);
+ if((log_config.gm) && (get_atcommand_level(AtCommand_MapMove) >= log_config.gm)) {
+ sprintf(message, "/mm %s", output);
+ log_atcommand(sd, message);
+ }
+ }
+
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_changed_dir(struct block_list *bl, int type) {
+ unsigned char buf[64];
+
+ WBUFW(buf,0) = 0x9c;
+ WBUFL(buf,2) = bl->id;
+ WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
+ WBUFB(buf,8) = unit_getdir(bl);
+
+ clif_send(buf, packet_len_table[0x9c], bl, type);
+ if (disguised(bl)) {
+ WBUFL(buf,2) = -bl->id;
+ WBUFW(buf,6) = 0;
+ clif_send(buf, packet_len_table[0x9c], bl, SELF);
+ }
+
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ChangeDir(int fd, struct map_session_data *sd) {
+ unsigned char headdir, dir;
+ RFIFOHEAD(fd);
+
+ headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ pc_setdir(sd, dir, headdir);
+
+ clif_changed_dir(&sd->bl, AREA_WOS);
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_Emotion(int fd, struct map_session_data *sd) {
+ unsigned char buf[64];
+ RFIFOHEAD(fd);
+
+ if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
+ if (RFIFOB(fd,2) == 34) {// prevent use of the mute emote [Valaris]
+ clif_skill_fail(sd, 1, 0, 1);
+ return;
+ }
+ // fix flood of emotion icon (ro-proxy): flood only the hacker player
+ if (sd->emotionlasttime >= time(NULL)) {
+ sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
+ clif_skill_fail(sd, 1, 0, 1);
+ return;
+ }
+ sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
+
+ WBUFW(buf,0) = 0xc0;
+ WBUFL(buf,2) = sd->bl.id;
+ WBUFB(buf,6) = RFIFOB(fd,2);
+ clif_send(buf, packet_len_table[0xc0], &sd->bl, AREA);
+ } else
+ clif_skill_fail(sd, 1, 0, 1);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) {
+ WFIFOHEAD(fd,packet_len_table[0xc2]);
+ WFIFOW(fd,0) = 0xc2;
+ WFIFOL(fd,2) = map_getusers();
+ WFIFOSET(fd,packet_len_table[0xc2]);
+}
+
+void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick)
+{
+ unsigned char buf[64];
+ if (pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl, 1);
+ return;
+ }
+
+ if (sd->sc.count &&
+ (sd->sc.data[SC_TRICKDEAD].timer != -1 ||
+ sd->sc.data[SC_AUTOCOUNTER].timer != -1 ||
+ sd->sc.data[SC_BLADESTOP].timer != -1))
+ return;
+
+ pc_stop_walking(sd, 1);
+ pc_stop_attack(sd);
+
+ if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
+ target_id = sd->bl.id;
+
+ switch(action_type) {
+ case 0x00: // once attack
+ case 0x07: // continuous attack
+
+ if (clif_cant_act(sd) || sd->sc.option&OPTION_HIDE)
+ return;
+
+ if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
+ return;
+
+ if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
+ if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
+ clif_skill_fail(sd, 1, 4, 0);
+ return;
+ }
+ }
+ if (sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+
+ sd->idletime = last_tick;
+ unit_attack(&sd->bl, target_id, action_type != 0);
+ break;
+ case 0x02: // sitdown
+ if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) {
+ clif_skill_fail(sd, 1, 0, 2);
+ break;
+ }
+ if(pc_issit(sd)) {
+ //Bugged client? Just refresh them.
+ WBUFW(buf, 0) = 0x8a;
+ WBUFL(buf, 2) = sd->bl.id;
+ WBUFB(buf,26) = 2;
+ clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
+ return;
+ }
+
+ if (sd->ud.skilltimer != -1 || sd->sc.opt1)
+ break;
+
+ if (sd->sc.count && (
+ sd->sc.data[SC_DANCING].timer != -1 ||
+ (sd->sc.data[SC_GRAVITATION].timer != -1 && sd->sc.data[SC_GRAVITATION].val3 == BCT_SELF)
+ )) //No sitting during these states neither.
+ break;
+ pc_setsit(sd);
+ skill_sit(sd, 1);
+ clif_sitting(sd);
+ break;
+ case 0x03: // standup
+ if (!pc_issit(sd)) {
+ //Bugged client? Just refresh them.
+ WBUFW(buf, 0) = 0x8a;
+ WBUFL(buf, 2) = sd->bl.id;
+ WBUFB(buf,26) = 3;
+ clif_send(buf, packet_len_table[0x8a], &sd->bl, SELF);
+ return;
+ }
+ pc_setstand(sd);
+ skill_sit(sd, 0);
+ WBUFW(buf, 0) = 0x8a;
+ WBUFL(buf, 2) = sd->bl.id;
+ WBUFB(buf,26) = 3;
+ clif_send(buf, packet_len_table[0x8a], &sd->bl, AREA);
+ break;
+ }
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ clif_parse_ActionRequest_sub(sd,
+ RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
+ RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
+ gettick()
+ );
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_Restart(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ switch(RFIFOB(fd,2)) {
+ case 0x00:
+ if (pc_isdead(sd)) {
+ pc_setstand(sd);
+ pc_setrestartvalue(sd, 3);
+ if (sd->sc.count && battle_config.debuff_on_logout&2) {
+ //For some reason food buffs are removed when you respawn.
+ if(sd->sc.data[SC_STRFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_STRFOOD,-1);
+ if(sd->sc.data[SC_AGIFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_AGIFOOD,-1);
+ if(sd->sc.data[SC_VITFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_VITFOOD,-1);
+ if(sd->sc.data[SC_INTFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_INTFOOD,-1);
+ if(sd->sc.data[SC_DEXFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_DEXFOOD,-1);
+ if(sd->sc.data[SC_LUKFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_LUKFOOD,-1);
+ if(sd->sc.data[SC_HITFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_HITFOOD,-1);
+ if(sd->sc.data[SC_FLEEFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_FLEEFOOD,-1);
+ if(sd->sc.data[SC_BATKFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_BATKFOOD,-1);
+ if(sd->sc.data[SC_WATKFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_WATKFOOD,-1);
+ if(sd->sc.data[SC_MATKFOOD].timer!=-1)
+ status_change_end(&sd->bl,SC_MATKFOOD,-1);
+ }
+ pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 2);
+ }
+ // in case the player's status somehow wasn't updated yet [Celest]
+ else if (sd->battle_status.hp <= 0)
+ pc_setdead(sd);
+ break;
+ case 0x01:
+ /* Rovert's Prevent logout option - Fixed [Valaris] */
+ if (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
+ { //Send to char-server for character selection.
+ chrif_charselectreq(sd, session[fd]->client_addr.sin_addr.s_addr);
+ } else {
+ WFIFOHEAD(fd,packet_len_table[0x18b]);
+ WFIFOW(fd,0)=0x18b;
+ WFIFOW(fd,2)=1;
+
+ WFIFOSET(fd,packet_len_table[0x018b]);
+ }
+ break;
+ }
+}
+
+/*==========================================
+ * Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B)
+ *------------------------------------------
+ */
+void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <nick>.24B <message>.?B // rewritten by [Yor]
+ char *command, *msg;
+ struct map_session_data *dstsd;
+ int i=0;
+ struct npc_data *npc;
+ char split_data[10][50];
+ char target[NAME_LENGTH+1];
+ char output[256];
+ unsigned int len;
+ RFIFOHEAD(fd);
+ len = RFIFOW(fd,2); //Packet length
+ if (len < 28)
+ { //Invalid packet, specified size is less than minimum! [Skotlex]
+ ShowWarning("Hack on Whisper: %s (AID/CID: %d:%d)!\n", sd->status.name, sd->status.account_id, sd->status.char_id);
+ clif_setwaitclose(fd);
+ return;
+ }
+ if (len == 28) return; //Not sure if client really lets you send a blank line.
+ len-=28; //Message length
+ // 24+3+(RFIFOW(fd,2)-28)+1 <- last 1 is '\0'
+ command = (char*)aMallocA((NAME_LENGTH+4+len) * sizeof(char));
+ //No need for out of memory checks, malloc.c aborts the map when that happens.
+ msg = command;
+ msg+= sprintf(command, "%s : ", sd->status.name);
+ memcpy(msg, RFIFOP(fd, 28), len);
+ msg[len]='\0'; //Force a terminator
+ if ((is_charcommand(fd, sd, command) != CharCommand_None) ||
+ (is_atcommand(fd, sd, command) != AtCommand_None)) {
+ aFree(command);
+ return;
+ }
+ if (sd->sc.count &&
+ (sd->sc.data[SC_BERSERK].timer!=-1 ||
+ (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT))) {
+ aFree(command);
+ return;
+ }
+
+ if (battle_config.min_chat_delay)
+ { //[Skotlex]
+ if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) {
+ aFree(command);
+ return;
+ }
+ sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ }
+
+ memcpy(&target,RFIFOP(fd, 4),NAME_LENGTH);
+ target[NAME_LENGTH]='\0';
+
+ //Chat Logging type 'W' / Whisper
+ if(log_config.chat&1 //we log everything then
+ || ( log_config.chat&2 //if Whisper bit is on
+ && ( !agit_flag || !(log_config.chat&16) ))) //if WOE ONLY flag is off or AGIT is OFF
+ log_chat("W", 0, sd->status.char_id, sd->status.account_id, (char*)mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, msg);
+
+ //-------------------------------------------------------//
+ // Lordalfa - Paperboy - To whisper NPC commands //
+ //-------------------------------------------------------//
+ if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) >4)) {
+ char *str= target+4; //Skip the NPC: string part.
+ if ((npc = npc_name2id(str)))
+ {
+ char *split;
+ str = msg;
+ for( i=0; i < 10; ++i )
+ {// Splits the message using '#' as separators
+ split = strchr(str,'#');
+ if( split == NULL )
+ { // use the remaining string
+ strncpy(split_data[i], str, sizeof(split_data[0])/sizeof(char));
+ split_data[i][sizeof(split_data[0])/sizeof(char)-1] = '\0';
+ for( ++i; i < 10; ++i )
+ split_data[i][0] = '\0';
+ break;
+ }
+ *split = '\0';
+ strncpy(split_data[i], str, sizeof(split_data[0])/sizeof(char));
+ split_data[i][sizeof(split_data[0])/sizeof(char)-1] = '\0';
+ str = split+1;
+ }
+
+ for (i=0;i<10;i++)
+ {
+ sprintf(output, "@whispervar%d$", i);
+ set_var(sd,output,(char *) split_data[i]);
+ }
+
+ sprintf(output, "%s::OnWhisperGlobal", npc->name);
+ npc_event(sd,output,0); // Calls the NPC label
+
+ aFree(command);
+ return;
+ }
+ }
+
+ // Main chat [LuzZza]
+ if(strcmpi(target, main_chat_nick) == 0) {
+ if(!sd->state.mainchat)
+ clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
+ else {
+ snprintf(output, sizeof(output)/sizeof(char), msg_txt(386), sd->status.name, msg);
+ intif_announce(output, strlen(output) + 1, 0xFE000000, 0);
+ }
+ aFree(command);
+ return;
+ }
+
+ // searching destination character
+ dstsd = map_nick2sd(target);
+ // player is not on this map-server
+ // At this point, don't send wisp/page if it's not exactly the same name, because (example)
+ // if there are 'Test' player on an other map-server and 'test' player on this map-server,
+ // and if we ask for 'Test', we must not contact 'test' player
+ // so, we send information to inter-server, which is the only one which decide (and copy correct name).
+ if (dstsd == NULL ||
+ strcmp(dstsd->status.name, target) != 0)
+ { // send message to inter-server
+ intif_wis_message(sd, target, msg, len);
+ aFree(command);
+ return;
+ }
+ // player is on this map-server
+ if (dstsd->fd == fd) {
+ // if you send to your self, don't send anything to others
+ // but, normaly, it's impossible!
+ clif_wis_message(fd, wisp_server_name,
+ "You can not page yourself. Sorry.",
+ strlen("You can not page yourself. Sorry.") + 1);
+ aFree(command);
+ return;
+ }
+ // otherwise, send message and answer immediatly
+ if (dstsd->state.ignoreAll) {
+ if (dstsd->sc.option & OPTION_INVISIBLE && pc_isGM(sd) < pc_isGM(dstsd))
+ clif_wis_end(fd, 1); // 1: target character is not loged in
+ else
+ clif_wis_end(fd, 3); // 3: everyone ignored by target
+ aFree(command);
+ return;
+ }
+ // if player ignore the source character
+ for(i = 0; i < MAX_IGNORE_LIST &&
+ dstsd->ignore[i].name[0] != '\0' &&
+ strcmp(dstsd->ignore[i].name, sd->status.name) != 0
+ ; i++);
+
+ if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0')
+ { //Ignored
+ clif_wis_end(fd, 2); // 2: ignored by target
+ aFree(command);
+ return;
+ }
+
+ // if source player not found in ignore list
+ if(dstsd->away_message[0] != '\0') { // Send away automessage [LuzZza]
+ //(Automessage has been sent)
+ sprintf(output, "%s %s", msg, msg_txt(543));
+ clif_wis_message(dstsd->fd, sd->status.name, output, strlen(output) + 1);
+ clif_wis_end(fd, 0); // 0: success to send wisper
+ if(dstsd->state.autotrade)
+ //"Away [AT] - \"%s\""
+ sprintf(output, msg_txt(544), dstsd->away_message);
+ else
+ //"Away - \"%s\""
+ sprintf(output, msg_txt(545), dstsd->away_message);
+ aFree(command);
+ clif_wis_message(fd, dstsd->status.name, output, strlen(output) + 1);
+ return;
+ }
+ // Normal message
+ clif_wis_message(dstsd->fd, sd->status.name, msg, len);
+ clif_wis_end(fd, 0); // 0: success to send wisper
+ aFree(command);
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_GMmessage(int fd, struct map_session_data *sd) {
+// /b
+ char message[MESSAGE_SIZE];
+ RFIFOHEAD(fd);
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_Broadcast))) {
+ intif_GMmessage((char*)RFIFOP(fd,4), RFIFOW(fd,2)-4, 0);
+ if((log_config.gm) && (get_atcommand_level(AtCommand_Broadcast) >= log_config.gm)) {
+ snprintf(message, RFIFOW(fd,2)-1, "/b %s", RFIFOP(fd,4));
+ log_atcommand(sd, message);
+ }
+ }
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
+ struct flooritem_data *fitem;
+ int map_object_id;
+ RFIFOHEAD(fd);
+
+ map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+
+ fitem = (struct flooritem_data*)map_id2bl(map_object_id);
+
+ do {
+ if (pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl, 1);
+ break;
+ }
+
+ if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
+ break;
+
+ if (clif_cant_act(sd))
+ break;
+
+ //Disable cloaking/chasewalking characters from looting [Skotlex]
+ if(pc_iscloaking(sd) || pc_ischasewalk(sd))
+ break;
+
+ if(sd->sc.count && (
+ sd->sc.data[SC_TRICKDEAD].timer != -1 ||
+ sd->sc.data[SC_BLADESTOP].timer != -1 ||
+ (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM))
+ )
+ break;
+
+ if (!pc_takeitem(sd, fitem))
+ break;
+ return;
+ } while (0);
+ // Client REQUIRES a fail packet or you can no longer pick items.
+ clif_additem(sd,0,0,6);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_DropItem(int fd, struct map_session_data *sd) {
+ int item_index, item_amount;
+ RFIFOHEAD(fd);
+
+ if (pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl, 1);
+ return;
+ }
+
+ if (clif_cant_act(sd))
+ return;
+
+ if (sd->sc.count && (
+ sd->sc.data[SC_AUTOCOUNTER].timer != -1 ||
+ sd->sc.data[SC_BLADESTOP].timer != -1 ||
+ (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM)
+ ))
+ return;
+
+ item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
+ item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ if (!pc_dropitem(sd, item_index, item_amount))
+ //Because the client does not likes being ignored.
+ clif_delitem(sd, item_index,0);
+
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_UseItem(int fd, struct map_session_data *sd) {
+ int n;
+ RFIFOHEAD(fd);
+
+ if (pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl, 1);
+ return;
+ }
+
+ if (sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT)
+ return;
+
+ //This flag enables you to use items while in an NPC. [Skotlex]
+ if (sd->npc_id) {
+ if (sd->npc_id != sd->npc_item_flag)
+ return;
+ } else
+ if (clif_trading(sd))
+ return;
+
+ if (sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+
+ //Whether the item is used or not is irrelevant, the char ain't idle. [Skotlex]
+ sd->idletime = last_tick;
+ n = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
+
+ if(n <0 || n >= MAX_INVENTORY)
+ return;
+ if (!pc_useitem(sd,n))
+ clif_useitemack(sd,n,0,0); //Send an empty ack packet or the client gets stuck.
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_EquipItem(int fd,struct map_session_data *sd)
+{
+ int index;
+ RFIFOHEAD(fd);
+
+ if(pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl,1);
+ return;
+ }
+ index = RFIFOW(fd,2)-2;
+ if (index < 0 || index >= MAX_INVENTORY)
+ return; //Out of bounds check.
+
+ if(sd->npc_id) {
+ if (sd->npc_id != sd->npc_item_flag)
+ return;
+ } else if (sd->state.storage_flag || sd->sc.opt1)
+ ; //You can equip/unequip stuff while storage is open/under status changes
+ else if (clif_cant_act(sd))
+ return;
+
+ if(sd->sc.data[SC_BLADESTOP].timer!=-1 || sd->sc.data[SC_BERSERK].timer!=-1 )
+ return;
+
+ if(!sd->status.inventory[index].identify) { // 未鑑定
+ clif_equipitemack(sd,index,0,0); // fail
+ return;
+ }
+ //ペット用装備であるかないか
+ if(sd->inventory_data[index]) {
+ if(sd->inventory_data[index]->type != IT_PETARMOR){
+ if(sd->inventory_data[index]->type == IT_AMMO)
+ pc_equipitem(sd,index,EQP_AMMO); //Client doesn't sends the position.
+ else
+ pc_equipitem(sd,index,RFIFOW(fd,4));
+ } else
+ pet_equipitem(sd,index);
+ }
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
+{
+ int index;
+ RFIFOHEAD(fd);
+
+ if(pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl,1);
+ return;
+ }
+
+ if (sd->state.storage_flag)
+ ; //You can equip/unequip stuff while storage is open.
+ else if (clif_cant_act(sd))
+ return;
+
+ index = RFIFOW(fd,2)-2;
+
+ pc_unequipitem(sd,index,1);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
+{
+ struct block_list *bl;
+ RFIFOHEAD(fd);
+
+ if(pc_isdead(sd)) {
+ clif_clearchar_area(&sd->bl,1);
+ return;
+ }
+
+ if (clif_cant_act(sd))
+ return;
+
+ bl = map_id2bl(RFIFOL(fd,2));
+ if (!bl) return;
+ switch (bl->type) {
+ case BL_MOB:
+ if (!((TBL_MOB *)bl)->nd || !mob_script_callback((TBL_MOB *)bl, &sd->bl, CALLBACK_NPCCLICK))
+ clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
+ break;
+ case BL_PC:
+ clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick());
+ break;
+ case BL_NPC:
+ npc_click(sd,(TBL_NPC*)bl);
+ break;
+ }
+ return;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->state.trading)
+ return;
+ npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
+{
+ int fail=0,n;
+ unsigned short *item_list;
+ RFIFOHEAD(fd);
+
+ n = (RFIFOW(fd,2)-4) /4;
+ item_list = (unsigned short*)RFIFOP(fd,4);
+
+ if (sd->state.trading|| !sd->npc_shopid)
+ fail = 1;
+ else
+ fail = npc_buylist(sd,n,item_list);
+
+ sd->npc_shopid = 0; //Clear shop data.
+ WFIFOHEAD(fd,packet_len_table[0xca]);
+ WFIFOW(fd,0)=0xca;
+ WFIFOB(fd,2)=fail;
+ WFIFOSET(fd,packet_len_table[0xca]);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
+{
+ int fail=0,n;
+ unsigned short *item_list;
+ RFIFOHEAD(fd);
+
+ n = (RFIFOW(fd,2)-4) /4;
+ item_list = (unsigned short*)RFIFOP(fd,4);
+
+ if (sd->state.trading || !sd->npc_shopid)
+ fail = 1;
+ else
+ fail = npc_selllist(sd,n,item_list);
+
+ sd->npc_shopid = 0; //Clear shop data.
+
+ WFIFOHEAD(fd,packet_len_table[0xcb]);
+ WFIFOW(fd,0)=0xcb;
+ WFIFOB(fd,2)=fail;
+ WFIFOSET(fd,packet_len_table[0xcb]);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_CreateChatRoom(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
+ return;
+ if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 4){
+ chat_createchat(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
+ } else
+ clif_skill_fail(sd,1,0,3);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ChatAddMember(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ chat_joinchat(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ChatRoomStatusChange(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ chat_changechatstatus(sd,RFIFOW(fd,4),RFIFOB(fd,6),(char*)RFIFOP(fd,7),(char*)RFIFOP(fd,15),RFIFOW(fd,2)-15);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ChangeChatOwner(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ chat_changechatowner(sd,(char*)RFIFOP(fd,6));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ chat_kickchat(sd,(char*)RFIFOP(fd,2));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_ChatLeave(int fd,struct map_session_data *sd)
+{
+ chat_leavechat(sd);
+}
+
+//Handles notifying asker and rejecter of what has just ocurred.
+//Type is used to determine the correct msg_txt to use:
+//0:
+static void clif_noask_sub(struct map_session_data *src, struct map_session_data *target, int type)
+{
+ char *msg, output[256];
+ // Your request has been rejected by autoreject option.
+ msg = msg_txt(392);
+ clif_disp_onlyself(src, msg, strlen(msg));
+ //Notice that a request was rejected.
+ snprintf(output, 256, msg_txt(393+type), src->status.name, 256);
+ clif_disp_onlyself(target, output, strlen(output));
+}
+
+/*==========================================
+ * 取引要請を相手に送る
+ *------------------------------------------
+ */
+void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
+{
+ struct map_session_data *t_sd;
+
+ RFIFOHEAD(fd);
+ t_sd = map_id2sd(RFIFOL(fd,2));
+
+ if(!sd->chatID && clif_cant_act(sd))
+ return; //You can trade while in a chatroom.
+
+ // @noask [LuzZza]
+ if(t_sd) {
+ if (t_sd->state.noask) {
+ clif_noask_sub(sd, t_sd, 0);
+ return;
+ }
+ if(!t_sd->chatID && clif_cant_act(t_sd))
+ return;
+ }
+
+ if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){
+ trade_traderequest(sd,t_sd);
+ } else
+ clif_skill_fail(sd,1,0,0);
+}
+
+/*==========================================
+ * 取引要請
+ *------------------------------------------
+ */
+void clif_parse_TradeAck(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ trade_tradeack(sd,RFIFOB(fd,2));
+}
+
+/*==========================================
+ * アイテム追加
+ *------------------------------------------
+ */
+void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ trade_tradeadditem(sd,RFIFOW(fd,2),RFIFOL(fd,4));
+}
+
+/*==========================================
+ * アイテム追加完了(ok押し)
+ *------------------------------------------
+ */
+void clif_parse_TradeOk(int fd,struct map_session_data *sd)
+{
+ trade_tradeok(sd);
+}
+
+/*==========================================
+ * 取引キャンセル
+ *------------------------------------------
+ */
+void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
+{
+ trade_tradecancel(sd);
+}
+
+/*==========================================
+ * 取引許諾(trade押し)
+ *------------------------------------------
+ */
+void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
+{
+ trade_tradecommit(sd);
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_StopAttack(int fd,struct map_session_data *sd)
+{
+ pc_stop_attack(sd);
+}
+
+/*==========================================
+ * カートへアイテムを移す
+ *------------------------------------------
+ */
+void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+
+ if (clif_trading(sd))
+ return;
+ pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
+}
+/*==========================================
+ * カートからアイテムを出す
+ *------------------------------------------
+ */
+void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
+}
+
+/*==========================================
+ * 付属品(鷹,ペコ,カート)をはずす
+ *------------------------------------------
+ */
+void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
+{
+ //Can only remove Cart/Riding/Falcon.
+ pc_setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON));
+}
+
+/*==========================================
+ * チェンジカート
+ *------------------------------------------
+ */
+void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ pc_setcart(sd,RFIFOW(fd,2));
+}
+
+/*==========================================
+ * ステータスアップ
+ *------------------------------------------
+ */
+void clif_parse_StatusUp(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ pc_statusup(sd,RFIFOW(fd,2));
+}
+
+/*==========================================
+ * スキルレベルアップ
+ *------------------------------------------
+ */
+void clif_parse_SkillUp(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ pc_skillup(sd,RFIFOW(fd,2));
+}
+
+static void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, int skillnum, int skilllv, int target_id)
+{
+ int lv;
+
+ if (!hd)
+ return;
+
+ if (skillnotok_hom(skillnum, hd)) //[orn]
+ return;
+
+ if (hd->bl.id != target_id &&
+ skill_get_inf(skillnum)&INF_SELF_SKILL)
+ target_id = hd->bl.id; //What good is it to mess up the target in self skills? Wished I knew... [Skotlex]
+
+ if (hd->ud.skilltimer != -1) {
+ if (skillnum != SA_CASTCANCEL)
+ return;
+ } else if (DIFF_TICK(tick, hd->ud.canact_tick) < 0)
+ return;
+
+ lv = merc_hom_checkskill(hd, skillnum);
+ if (skilllv > lv)
+ skilllv = lv;
+
+ if (skilllv)
+ unit_skilluse_id(&hd->bl, target_id, skillnum, skilllv);
+}
+
+/*==========================================
+ * スキル使用(ID指定)
+ *------------------------------------------
+ */
+void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
+ int skillnum, skilllv, tmp, target_id;
+ unsigned int tick = gettick();
+ RFIFOHEAD(fd);
+
+ if (clif_cant_act(sd))
+ return;
+ if (pc_issit(sd))
+ return;
+
+ skilllv = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ if (skilllv < 1) skilllv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex]
+ skillnum = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
+
+ //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
+ sd->idletime = last_tick;
+
+ tmp = skill_get_inf(skillnum);
+ if (tmp&INF_GROUND_SKILL)
+ return; //Using a ground skill on a target? WRONG.
+
+ if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL) {
+ clif_parse_UseSkillToId_homun(sd->hd, sd, tick, skillnum, skilllv, target_id);
+ return;
+ }
+
+ if (skillnotok(skillnum, sd))
+ return;
+
+ if (sd->bl.id != target_id && !sd->state.skill_flag && tmp&INF_SELF_SKILL)
+ target_id = sd->bl.id; //What good is it to mess up the target in self skills? Wished I knew... [Skotlex]
+
+ if (sd->ud.skilltimer != -1) {
+ if (skillnum != SA_CASTCANCEL)
+ return;
+ } else if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
+ clif_skill_fail(sd, skillnum, 4, 0);
+ return;
+ }
+
+ if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
+ return;
+
+ if (sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+
+ if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris]
+ target_id = sd->bl.id;
+
+ if (sd->skillitem == skillnum) {
+ if (skilllv != sd->skillitemlv)
+ skilllv = sd->skillitemlv;
+ unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
+ return;
+ }
+
+ sd->skillitem = sd->skillitemlv = 0;
+ if (skillnum == MO_EXTREMITYFIST) {
+ if ((sd->sc.data[SC_COMBO].timer == -1 ||
+ (sd->sc.data[SC_COMBO].val1 != MO_COMBOFINISH &&
+ sd->sc.data[SC_COMBO].val1 != CH_TIGERFIST &&
+ sd->sc.data[SC_COMBO].val1 != CH_CHAINCRUSH))) {
+ if (!sd->state.skill_flag ) {
+ sd->state.skill_flag = 1;
+ clif_skillinfo(sd, MO_EXTREMITYFIST, INF_ATTACK_SKILL, -1);
+ return;
+ } else if (sd->bl.id == target_id) {
+ clif_skillinfo(sd, MO_EXTREMITYFIST, INF_ATTACK_SKILL, -1);
+ return;
+ }
+ }
+ }
+ if (skillnum == TK_JUMPKICK) {
+ if (sd->sc.data[SC_COMBO].timer == -1 ||
+ sd->sc.data[SC_COMBO].val1 != TK_JUMPKICK) {
+ if (!sd->state.skill_flag ) {
+ sd->state.skill_flag = 1;
+ clif_skillinfo(sd, TK_JUMPKICK, INF_ATTACK_SKILL, -1);
+ return;
+ } else if (sd->bl.id == target_id) {
+ clif_skillinfo(sd, TK_JUMPKICK, INF_ATTACK_SKILL, -1);
+ return;
+ }
+ }
+ }
+
+ if (skillnum >= GD_SKILLBASE) {
+ if (sd->state.gmaster_flag)
+ skilllv = guild_checkskill(sd->state.gmaster_flag, skillnum);
+ else
+ skilllv = 0;
+ } else {
+ tmp = pc_checkskill(sd, skillnum);
+ if (skilllv > tmp)
+ skilllv = tmp;
+ }
+
+ if (skilllv)
+ unit_skilluse_id(&sd->bl, target_id, skillnum, skilllv);
+
+ if (sd->state.skill_flag)
+ sd->state.skill_flag = 0;
+}
+
+/*==========================================
+ * スキル使用(場所指定)
+ *------------------------------------------
+ */
+void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilllv, int skillnum, int x, int y, int skillmoreinfo)
+{
+ int lv;
+ unsigned int tick = gettick();
+ RFIFOHEAD(fd);
+
+ //Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
+ sd->idletime = last_tick;
+
+ if (skillnotok(skillnum, sd))
+ return;
+
+ if (!(skill_get_inf(skillnum)&INF_GROUND_SKILL))
+ return; //Using a target skill on the ground? WRONG.
+
+ if (skillmoreinfo != -1) {
+ if (pc_issit(sd)) {
+ clif_skill_fail(sd, skillnum, 0, 0);
+ return;
+ }
+ memcpy(talkie_mes, RFIFOP(fd,skillmoreinfo), MESSAGE_SIZE);
+ talkie_mes[MESSAGE_SIZE-1] = '\0'; //Overflow protection [Skotlex]
+ }
+
+ if (sd->ud.skilltimer != -1)
+ return;
+ if (DIFF_TICK(tick, sd->ud.canact_tick) < 0)
+ {
+ clif_skill_fail(sd, skillnum, 4, 0);
+ return;
+ }
+
+ if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
+ return;
+
+ if (sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+ if (sd->skillitem == skillnum) {
+ if (skilllv != sd->skillitemlv)
+ skilllv = sd->skillitemlv;
+ unit_skilluse_pos(&sd->bl, x, y, skillnum, skilllv);
+ } else {
+ sd->skillitem = sd->skillitemlv = 0;
+ if ((lv = pc_checkskill(sd, skillnum)) > 0) {
+ if (skilllv > lv)
+ skilllv = lv;
+ unit_skilluse_pos(&sd->bl, x, y, skillnum,skilllv);
+ }
+ }
+}
+
+
+void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ if (clif_cant_act(sd))
+ return;
+ if (pc_issit(sd))
+ return;
+
+ clif_parse_UseSkillToPosSub(fd, sd,
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //skill lv
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //skill num
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
+ -1 //Skill more info.
+ );
+}
+
+void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ if (clif_cant_act(sd))
+ return;
+ if (pc_issit(sd))
+ return;
+
+ clif_parse_UseSkillToPosSub(fd, sd,
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //Skill lv
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //Skill num
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
+ RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
+ packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[4] //skill more info
+ );
+}
+/*==========================================
+ * スキル使用(map指定)
+ *------------------------------------------
+ */
+void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+
+ if (clif_cant_act(sd))
+ return;
+
+ if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
+ return;
+
+ if(sd->invincible_timer != -1)
+ pc_delinvincibletimer(sd);
+
+ skill_castend_map(sd,RFIFOW(fd,2),(char*)RFIFOP(fd,4));
+}
+/*==========================================
+ * メモ要求
+ *------------------------------------------
+ */
+void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
+{
+ if (!pc_isdead(sd))
+ pc_memo(sd,-1);
+}
+/*==========================================
+ * アイテム合成
+ *------------------------------------------
+ */
+void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+
+ if (sd->menuskill_id != AM_PHARMACY)
+ return;
+
+ if (clif_trading(sd)) {
+ //Make it fail to avoid shop exploits where you sell something different than you see.
+ clif_skill_fail(sd,sd->ud.skillid,0,0);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+ return;
+ }
+ skill_produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+/*==========================================
+ * 武器修理
+ *------------------------------------------
+ */
+void clif_parse_RepairItem(int fd, struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+
+ if (sd->menuskill_id != BS_REPAIRWEAPON)
+ return;
+ if (clif_trading(sd)) {
+ //Make it fail to avoid shop exploits where you sell something different than you see.
+ clif_skill_fail(sd,sd->ud.skillid,0,0);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+ return;
+ }
+ skill_repairweapon(sd,RFIFOW(fd,2));
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) {
+ int idx;
+ RFIFOHEAD(fd);
+
+ if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit?
+ return;
+ if (clif_trading(sd)) {
+ //Make it fail to avoid shop exploits where you sell something different than you see.
+ clif_skill_fail(sd,sd->ud.skillid,0,0);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+ return;
+ }
+ idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ skill_weaponrefine(sd, idx-2);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
+{
+ unsigned char select;
+ RFIFOHEAD(fd);
+
+ select = RFIFOB(fd,6);
+ if((select > sd->max_menu && select != 0xff) || !select){
+ ShowWarning("Hack on NPC Select Menu: %s (AID: %d)!\n",sd->status.name,sd->bl.id);
+ clif_GM_kick(sd,sd,0);
+ } else {
+ sd->npc_menu=select;
+ npc_scriptcont(sd,RFIFOL(fd,2));
+ }
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+#ifdef __WIN32
+ //For some extraordinarily eerie reason that noone has figured out yet,
+ //windows native compiles NEED this nullpo_retv or the function is not found!
+ nullpo_retv(sd);
+#endif
+ npc_scriptcont(sd,RFIFOL(fd,2));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+#define RFIFOL_(fd,pos) (*(int*)(session[fd]->rdata+session[fd]->rdata_pos+(pos)))
+ //Input Value overflow Exploit FIX
+ sd->npc_amount=RFIFOL_(fd,6); //fixed by Lupus. npc_amount is (int) but was RFIFOL changing it to (unsigned int)
+#undef RFIFOL_
+
+ npc_scriptcont(sd,RFIFOL(fd,2));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcStringInput(int fd,struct map_session_data *sd)
+{
+ short message_len;
+ RFIFOHEAD(fd);
+ message_len = RFIFOW(fd,2)-7;
+
+ if(message_len < 1)
+ return; //Blank message?
+
+ if(message_len >= sizeof(sd->npc_str)){
+ ShowWarning("clif: input string too long !\n");
+ message_len = sizeof(sd->npc_str);
+ }
+
+ // Exploit prevention if crafted packets (without null) is being sent. [Lance]
+ memcpy(sd->npc_str,RFIFOP(fd,8),message_len);
+ sd->npc_str[message_len-1]=0;
+ npc_scriptcont(sd,RFIFOL(fd,4));
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
+ npc_scriptcont(sd,RFIFOL(fd,2));
+}
+
+/*==========================================
+ * アイテム鑑定
+ *------------------------------------------
+ */
+void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->menuskill_id != MC_IDENTIFY)
+ return;
+ skill_identify(sd,RFIFOW(fd,2)-2);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+/*==========================================
+ * 矢作成
+ *------------------------------------------
+ */
+void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->menuskill_id != AC_MAKINGARROW)
+ return;
+ if (clif_trading(sd)) {
+ //Make it fail to avoid shop exploits where you sell something different than you see.
+ clif_skill_fail(sd,sd->ud.skillid,0,0);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+ return;
+ }
+ skill_arrow_create(sd,RFIFOW(fd,2));
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+/*==========================================
+ * オートスペル受信
+ *------------------------------------------
+ */
+void clif_parse_AutoSpell(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->menuskill_id != SA_AUTOSPELL)
+ return;
+ skill_autospell(sd,RFIFOW(fd,2));
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+/*==========================================
+ * カード使用
+ *------------------------------------------
+ */
+void clif_parse_UseCard(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->state.trading!= 0)
+ return;
+ clif_use_card(sd,RFIFOW(fd,2)-2);
+}
+/*==========================================
+ * カード挿入装備選択
+ *------------------------------------------
+ */
+void clif_parse_InsertCard(int fd,struct map_session_data *sd)
+{
+ RFIFOHEAD(fd);
+ if (sd->state.trading!= 0)
+ return;
+ pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
+}
+
+/*==========================================
+ * 0193 キャラID名前引き
+ *------------------------------------------
+ */
+void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
+ int char_id;
+ RFIFOHEAD(fd);
+
+ char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+ clif_solved_charname(sd, char_id);
+}
+
+/*==========================================
+ * 0197 /resetskill /resetstate
+ *------------------------------------------
+ */
+void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState)) {
+ switch(RFIFOW(fd,2)){
+ case 0:
+ pc_resetstate(sd);
+ break;
+ case 1:
+ pc_resetskill(sd,1);
+ break;
+ }
+ if((log_config.gm) && (get_atcommand_level(AtCommand_ResetState) >= log_config.gm)) {
+ log_atcommand(sd, RFIFOW(fd,2) ? "/resetskill" : "/resetstate");
+ }
+ }
+}
+
+/*==========================================
+ * 019c /lb等
+ *------------------------------------------
+ */
+void clif_parse_LGMmessage(int fd, struct map_session_data *sd) {
+ unsigned char buf[512];
+ char message[MESSAGE_SIZE];
+ RFIFOHEAD(fd);
+
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_LocalBroadcast))) {
+ WBUFW(buf,0) = 0x9a;
+ WBUFW(buf,2) = RFIFOW(fd,2);
+ memcpy(WBUFP(buf,4), RFIFOP(fd,4), RFIFOW(fd,2) - 4);
+ clif_send(buf, RFIFOW(fd,2), &sd->bl, ALL_SAMEMAP);
+ if((log_config.gm) && (get_atcommand_level(AtCommand_LocalBroadcast) >= log_config.gm)) {
+ snprintf(message, RFIFOW(fd,2), "/lb %s", RFIFOP(fd,4));
+ log_atcommand(sd, message);
+ }
+ }
+}
+
+/*==========================================
+ * カプラ倉庫へ入れる
+ *------------------------------------------
+ */
+void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) {
+ int item_index, item_amount;
+ RFIFOHEAD(fd);
+
+ if (clif_trading(sd))
+ return;
+
+ item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
+ item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+ if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
+ return;
+
+ if (sd->state.storage_flag == 1)
+ storage_storageadd(sd, item_index, item_amount);
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storageadd(sd, item_index, item_amount);
+}
+
+/*==========================================
+ * カプラ倉庫から出す
+ *------------------------------------------
+ */
+void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) {
+ int item_index, item_amount;
+ RFIFOHEAD(fd);
+
+ item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1;
+ item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+
+ if (sd->state.storage_flag == 1)
+ storage_storageget(sd, item_index, item_amount);
+ else if(sd->state.storage_flag == 2)
+ storage_guild_storageget(sd, item_index, item_amount);
+}
+
+/*==========================================
+ * カプラ倉庫へカートから入れる
+ *------------------------------------------
+ */
+void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ if(sd->vender_id)
+ return;
+
+ if (sd->state.storage_flag == 1)
+ storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
+}
+
+/*==========================================
+ * カプラ倉庫から出す
+ *------------------------------------------
+ */
+void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ if (sd->vender_id)
+ return;
+ if (sd->state.storage_flag == 1)
+ storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
+}
+
+/*==========================================
+ * カプラ倉庫を閉じる
+ *------------------------------------------
+ */
+void clif_parse_CloseKafra(int fd, struct map_session_data *sd) {
+ if (sd->state.storage_flag == 1)
+ storage_storageclose(sd);
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storageclose(sd);
+}
+
+/*==========================================
+ * パーティを作る
+ *------------------------------------------
+ */
+void clif_parse_CreateParty(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.partylock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(227));
+ return;
+ }
+ if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) {
+ party_create(sd,(char*)RFIFOP(fd,2),0,0);
+ } else
+ clif_skill_fail(sd,1,0,4);
+}
+
+/*==========================================
+ * パーティを作る
+ *------------------------------------------
+ */
+void clif_parse_CreateParty2(int fd, struct map_session_data *sd) {
+ if(map[sd->bl.m].flag.partylock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(227));
+ return;
+ }
+ if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7){
+ RFIFOHEAD(fd);
+ party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27));
+ } else
+ clif_skill_fail(sd,1,0,4);
+}
+
+/*==========================================
+ * パーティに勧誘
+ *------------------------------------------
+ */
+void clif_parse_PartyInvite(int fd, struct map_session_data *sd) {
+
+ struct map_session_data *t_sd;
+
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.partylock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(227));
+ return;
+ }
+
+ t_sd = map_id2sd(RFIFOL(fd,2));
+
+ // @noask [LuzZza]
+ if(t_sd && t_sd->state.noask) {
+ clif_noask_sub(sd, t_sd, 1);
+ return;
+ }
+
+ party_invite(sd, t_sd);
+}
+
+/*==========================================
+ * パーティ勧誘返答
+ *------------------------------------------
+ */
+void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 5){
+ party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+ } else {
+ party_reply_invite(sd,RFIFOL(fd,2),-1);
+ clif_skill_fail(sd,1,0,4);
+ }
+}
+
+/*==========================================
+ * パーティ脱退要求
+ *------------------------------------------
+ */
+void clif_parse_LeaveParty(int fd, struct map_session_data *sd) {
+ if(map[sd->bl.m].flag.partylock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(227));
+ return;
+ }
+ party_leave(sd);
+}
+
+/*==========================================
+ * パーティ除名要求
+ *------------------------------------------
+ */
+void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.partylock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(227));
+ return;
+ }
+ party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
+}
+
+/*==========================================
+ * パーティ設定変更要求
+ *------------------------------------------
+ */
+void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
+ struct party_data *p;
+ RFIFOHEAD(fd);
+
+ if(!sd->status.party_id)
+ return;
+
+ p = party_search(sd->status.party_id);
+ if (!p) return;
+ //The client no longer can change the item-field, therefore it always
+ //comes as zero. Here, resend the item data as it is.
+// party_changeoption(sd, RFIFOW(fd,2), RFIFOW(fd,4));
+ party_changeoption(sd, RFIFOW(fd,2), p->party.item);
+}
+
+/*==========================================
+ * パーティメッセージ送信要求
+ *------------------------------------------
+ */
+void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4)) != CharCommand_None ||
+ is_atcommand(fd, sd, (char*)RFIFOP(fd,4)) != AtCommand_None)
+ return;
+
+ if (sd->sc.count && (
+ sd->sc.data[SC_BERSERK].timer!=-1 ||
+ (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
+ ))
+ return;
+
+ if (battle_config.min_chat_delay)
+ { //[Skotlex]
+ if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
+ return;
+ sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ }
+
+ party_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
+}
+
+/*==========================================
+ * 露店閉鎖
+ *------------------------------------------
+ */
+void clif_parse_CloseVending(int fd, struct map_session_data *sd) {
+ vending_closevending(sd);
+}
+
+/*==========================================
+ * 露店アイテムリスト要求
+ *------------------------------------------
+ */
+void clif_parse_VendingListReq(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ vending_vendinglistreq(sd,RFIFOL(fd,2));
+ if(sd->npc_id)
+ npc_event_dequeue(sd);
+}
+
+/*==========================================
+ * 露店アイテム購入
+ *------------------------------------------
+ */
+void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ vending_purchasereq(sd, RFIFOW(fd,2), RFIFOL(fd,4), RFIFOP(fd,8));
+}
+
+/*==========================================
+ * 露店開設
+ *------------------------------------------
+ */
+void clif_parse_OpenVending(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if (clif_trading(sd))
+ return;
+ if (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOROOM)
+ return;
+ vending_openvending(sd, RFIFOW(fd,2), (char*)RFIFOP(fd,4), RFIFOB(fd,84), RFIFOP(fd,85));
+}
+
+/*==========================================
+ * ギルドを作る
+ *------------------------------------------
+ */
+void clif_parse_CreateGuild(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+ guild_create(sd, (char*)RFIFOP(fd,6));
+}
+
+/*==========================================
+ * ギルドマスターかどうか確認
+ *------------------------------------------
+ */
+void clif_parse_GuildCheckMaster(int fd, struct map_session_data *sd) {
+ clif_guild_masterormember(sd);
+}
+
+/*==========================================
+ * ギルド情報要求
+ *------------------------------------------
+ */
+void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ switch(RFIFOL(fd,2)){
+ case 0: // ギルド基本情報、同盟敵対情報
+ clif_guild_basicinfo(sd);
+ clif_guild_allianceinfo(sd);
+ break;
+ case 1: // メンバーリスト、役職名リスト
+ clif_guild_positionnamelist(sd);
+ clif_guild_memberlist(sd);
+ break;
+ case 2: // 役職名リスト、役職情報リスト
+ clif_guild_positionnamelist(sd);
+ clif_guild_positioninfolist(sd);
+ break;
+ case 3: // スキルリスト
+ clif_guild_skillinfo(sd);
+ break;
+ case 4: // 追放リスト
+ clif_guild_expulsionlist(sd);
+ break;
+ default:
+ if (battle_config.error_log)
+ ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
+ break;
+ }
+}
+
+/*==========================================
+ * ギルド役職変更
+ *------------------------------------------
+ */
+void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) {
+ int i;
+ RFIFOHEAD(fd);
+
+ for(i = 4; i < RFIFOW(fd,2); i += 40 ){
+ guild_change_position(sd, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
+ }
+}
+
+/*==========================================
+ * ギルドメンバ役職変更
+ *------------------------------------------
+ */
+void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) {
+ int i;
+ RFIFOHEAD(fd);
+
+ for(i=4;i<RFIFOW(fd,2);i+=12){
+ guild_change_memberposition(sd->status.guild_id,
+ RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
+ }
+}
+
+/*==========================================
+ * ギルドエンブレム要求
+ *------------------------------------------
+ */
+void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) {
+ struct guild *g;
+ RFIFOHEAD(fd);
+ g=guild_search(RFIFOL(fd,2));
+ if(g!=NULL)
+ clif_guild_emblem(sd,g);
+}
+
+/*==========================================
+ * ギルドエンブレム変更
+ *------------------------------------------
+ */
+void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ guild_change_emblem(sd,RFIFOW(fd,2)-4,(char*)RFIFOP(fd,4));
+}
+
+/*==========================================
+ * ギルド告知変更
+ *------------------------------------------
+ */
+void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
+}
+
+/*==========================================
+ * ギルド勧誘
+ *------------------------------------------
+ */
+void clif_parse_GuildInvite(int fd,struct map_session_data *sd) {
+
+ struct map_session_data *t_sd;
+
+ RFIFOHEAD(fd);
+
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+
+ t_sd = map_id2sd(RFIFOL(fd,2));
+
+ // @noask [LuzZza]
+ if(t_sd && t_sd->state.noask) {
+ clif_noask_sub(sd, t_sd, 2);
+ return;
+ }
+
+ guild_invite(sd,t_sd);
+}
+
+/*==========================================
+ * ギルド勧誘返信
+ *------------------------------------------
+ */
+void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ guild_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
+}
+
+/*==========================================
+ * ギルド脱退
+ *------------------------------------------
+ */
+void clif_parse_GuildLeave(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+ guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
+}
+
+/*==========================================
+ * ギルド追放
+ *------------------------------------------
+ */
+void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+ guild_expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
+}
+
+/*==========================================
+ * ギルド会話
+ *------------------------------------------
+ */
+void clif_parse_GuildMessage(int fd,struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+
+ if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4)) != CharCommand_None ||
+ is_atcommand(fd, sd, (char*)RFIFOP(fd, 4)) != AtCommand_None)
+ return;
+
+ if (sd->sc.count && (
+ sd->sc.data[SC_BERSERK].timer!=-1 ||
+ (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
+ ))
+ return;
+
+ if (battle_config.min_chat_delay)
+ { //[Skotlex]
+ if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
+ return;
+ sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ }
+
+ guild_send_message(sd, (char*)RFIFOP(fd,4), RFIFOW(fd,2)-4);
+}
+
+/*==========================================
+ * ギルド同盟要求
+ *------------------------------------------
+ */
+void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) {
+
+ struct map_session_data *t_sd;
+
+ RFIFOHEAD(fd);
+
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+
+ t_sd = map_id2sd(RFIFOL(fd,2));
+
+ // @noask [LuzZza]
+ if(t_sd && t_sd->state.noask) {
+ clif_noask_sub(sd, t_sd, 3);
+ return;
+ }
+
+ guild_reqalliance(sd,t_sd);
+}
+
+/*==========================================
+ * ギルド同盟要求返信
+ *------------------------------------------
+ */
+void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+}
+
+/*==========================================
+ * ギルド関係解消
+ *------------------------------------------
+ */
+void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+ guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+}
+
+/*==========================================
+ * ギルド敵対
+ *------------------------------------------
+ */
+void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) {
+
+ struct map_session_data *t_sd;
+ RFIFOHEAD(fd);
+
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+
+ t_sd = map_id2sd(RFIFOL(fd,2));
+
+ // @noask [LuzZza]
+ if(t_sd && t_sd->state.noask) {
+ clif_noask_sub(sd, t_sd, 4);
+ return;
+ }
+
+ guild_opposition(sd,t_sd);
+}
+
+/*==========================================
+ * ギルド解散
+ *------------------------------------------
+ */
+void clif_parse_GuildBreak(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if(map[sd->bl.m].flag.guildlock)
+ { //Guild locked.
+ clif_displaymessage(fd, msg_txt(228));
+ return;
+ }
+ guild_break(sd,(char*)RFIFOP(fd,2));
+}
+
+// pet
+void clif_parse_PetMenu(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ pet_menu(sd,RFIFOB(fd,2));
+}
+
+void clif_parse_CatchPet(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ pet_catch_process2(sd,RFIFOL(fd,2));
+}
+
+void clif_parse_SelectEgg(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_lv != -1)
+ return;
+ pet_select_egg(sd,RFIFOW(fd,2)-2);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+
+void clif_parse_SendEmotion(int fd, struct map_session_data *sd) {
+ if(sd->pd) {
+ RFIFOHEAD(fd);
+ clif_pet_emotion(sd->pd,RFIFOL(fd,2));
+ }
+}
+
+void clif_parse_ChangePetName(int fd, struct map_session_data *sd) {
+ RFIFOHEAD(fd);
+ pet_change_name(sd,(char*)RFIFOP(fd,2), 0);
+}
+
+// Kick (right click menu for GM "(name) force to quit")
+void clif_parse_GMKick(int fd, struct map_session_data *sd) {
+ struct block_list *target;
+ int tid;
+ char message[MESSAGE_SIZE];
+
+ RFIFOHEAD(fd);
+ tid = RFIFOL(fd,2);
+
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_Kick))) {
+ target = map_id2bl(tid);
+ if (target) {
+ if (target->type == BL_PC) {
+ struct map_session_data *tsd = (struct map_session_data *)target;
+ if (pc_isGM(sd) > pc_isGM(tsd)) {
+ clif_GM_kick(sd, tsd, 1);
+ if((log_config.gm) && (get_atcommand_level(AtCommand_Kick) >= log_config.gm)) {
+ sprintf(message, "/kick %d", tsd->status.char_id);
+ log_atcommand(sd, message);
+ }
+ } else
+ clif_GM_kickack(sd, 0);
+ } else if (target->type == BL_MOB) {
+ status_percent_damage(&sd->bl, target, 100, 0);
+ sprintf(message, "/kick %d %d %d %d", tid, target->id, target->type, target->subtype);
+ if((log_config.gm) && (get_atcommand_level(AtCommand_Kick) >= log_config.gm)) {
+ sprintf(message, "/kick %s", ((struct mob_data*)target)->db->sprite);
+ log_atcommand(sd, message);
+ }
+ } else
+ clif_GM_kickack(sd, 0);
+ } else
+ clif_GM_kickack(sd, 0);
+ }
+}
+
+/*==========================================
+ * /shift
+ *------------------------------------------
+ */
+void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor]
+ char player_name[NAME_LENGTH];
+ char message[MESSAGE_SIZE];
+
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_JumpTo))) {
+ RFIFOHEAD(fd);
+ memcpy(player_name, RFIFOP(fd,2), NAME_LENGTH);
+ atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
+ if((log_config.gm) && (get_atcommand_level(AtCommand_JumpTo) >= log_config.gm)) {
+ sprintf(message, "/shift %s", player_name);
+ log_atcommand(sd, message);
+ }
+ }
+
+ return;
+}
+
+/*==========================================
+ * /recall
+ *------------------------------------------
+ */
+void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT
+ char player_name[NAME_LENGTH];
+ char message[MESSAGE_SIZE];
+
+ malloc_tsetdword(player_name, '\0', sizeof(player_name));
+
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) {
+ RFIFOHEAD(fd);
+ memcpy(player_name, RFIFOP(fd,2), NAME_LENGTH);
+ atcommand_recall(fd, sd, "@recall", player_name); // as @recall
+ if((log_config.gm) && (get_atcommand_level(AtCommand_Recall) >= log_config.gm)) {
+ sprintf(message, "/recall %s", player_name);
+ log_atcommand(sd, message);
+ }
+ }
+
+ return;
+}
+
+/*==========================================
+ * /monster /item rewriten by [Yor]
+ *------------------------------------------
+ */
+void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
+ char monster_item_name[NAME_LENGTH+10]; //Additional space is for logging, eg: "@monster Poring"
+ int level;
+
+ malloc_tsetdword(monster_item_name, '\0', sizeof(monster_item_name));
+
+ if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) {
+ RFIFOHEAD(fd);
+ memcpy(monster_item_name, RFIFOP(fd,2), NAME_LENGTH);
+
+ if (mobdb_searchname(monster_item_name) != 0) {
+ if (pc_isGM(sd) >= (level =get_atcommand_level(AtCommand_Spawn))) // changed from AtCommand_Monster for Skots [Reddozen]
+ {
+ atcommand_monster(fd, sd, "@spawn", monster_item_name); // as @spawn
+ if(log_config.gm && level >= log_config.gm)
+ { //Log action. [Skotlex]
+ snprintf(monster_item_name, sizeof(monster_item_name)-1, "@spawn %s", RFIFOP(fd,2));
+ log_atcommand(sd, monster_item_name);
+ }
+ }
+ } else if (itemdb_searchname(monster_item_name) != NULL) {
+ if (pc_isGM(sd) >= (level = get_atcommand_level(AtCommand_Item)))
+ {
+ atcommand_item(fd, sd, "@item", monster_item_name); // as @item
+ if(log_config.gm && level >= log_config.gm)
+ { //Log action. [Skotlex]
+ snprintf(monster_item_name, sizeof(monster_item_name)-1, "@item %s", RFIFOP(fd,2));
+ log_atcommand(sd, monster_item_name);
+ }
+ }
+ }
+ }
+}
+
+void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yor]
+ if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) &&
+ (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) {
+ if (sd->sc.option & OPTION_INVISIBLE) {
+ sd->sc.option &= ~OPTION_INVISIBLE;
+ if (sd->disguise)
+ status_set_viewdata(&sd->bl, sd->disguise);
+ else
+ status_set_viewdata(&sd->bl, sd->status.class_);
+ clif_displaymessage(fd, "Invisible: Off.");
+ } else {
+ sd->sc.option |= OPTION_INVISIBLE;
+ //Experimental hidden mode, changes your view class to invisible [Skotlex]
+ sd->vd.class_ = INVISIBLE_CLASS;
+ clif_displaymessage(fd, "Invisible: On.");
+ if((log_config.gm) && (get_atcommand_level(AtCommand_Hide) >= log_config.gm)) {
+ log_atcommand(sd, "/hide");
+ }
+ }
+ clif_changeoption(&sd->bl);
+ }
+}
+
+/*==========================================
+ * GMによるチャット禁止時間付与
+ *------------------------------------------
+ */
+void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
+{
+ int type, limit, level;
+ struct block_list *bl;
+ struct map_session_data *dstsd;
+
+ RFIFOHEAD(fd);
+ bl = map_id2bl(RFIFOL(fd,2));
+ if (!bl || bl->type != BL_PC)
+ return;
+ nullpo_retv(dstsd =(struct map_session_data *)bl);
+
+ type = RFIFOB(fd,6);
+ limit = RFIFOW(fd,7);
+ if (type == 0)
+ limit = 0 - limit;
+
+ //If type is 2 and the ids don't match, this is a crafted hacked packet!
+ //Disabled because clients keep self-muting when you give players public @ commands... [Skotlex]
+ if (type == 2/* && sd->bl.id != dstsd->bl.id*/)
+ return;
+
+ if (
+ ((level = pc_isGM(sd)) > pc_isGM(dstsd) && level >= get_atcommand_level(AtCommand_Mute))
+ || (type == 2 && !level)) {
+ clif_GM_silence(sd, dstsd, ((type == 2) ? 1 : type));
+ dstsd->status.manner -= limit;
+ if(dstsd->status.manner < 0)
+ sc_start(bl,SC_NOCHAT,100,0,0);
+ else
+ {
+ dstsd->status.manner = 0;
+ status_change_end(bl,SC_NOCHAT,-1);
+ }
+ }
+
+ return;
+}
+/*==========================================
+ * GMによるチャット禁止時間参照(?)
+ *------------------------------------------
+ */
+void clif_parse_GMReqNoChatCount(int fd, struct map_session_data *sd)
+{
+ int tid;
+ RFIFOHEAD(fd);
+ tid = RFIFOL(fd,2);
+
+ WFIFOHEAD(fd,packet_len_table[0x1e0]);
+ WFIFOW(fd,0) = 0x1e0;
+ WFIFOL(fd,2) = tid;
+ sprintf((char*)WFIFOP(fd,6),"%d",tid);
+// memcpy(WFIFOP(fd,6), "TESTNAME", 24);
+ WFIFOSET(fd, packet_len_table[0x1e0]);
+
+ return;
+}
+
+static int pstrcmp(const void *a, const void *b)
+{
+ char *name1 = (char *)a;
+ char *name2 = (char *)b;
+ if (name1[0] && name2[0])
+ return strcmp(name1, name2);
+ //Since names are sorted in ascending order, send blank entries to the bottom.
+ if (name1[0])
+ return -1;
+ if (name2[0])
+ return 1;
+ return 0;
+}
+
+void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
+ char output[512];
+ char *nick; // S 00cf <nick>.24B <type>.B: 00 (/ex nick) deny speech from nick, 01 (/in nick) allow speech from nick
+ int i;
+ WFIFOHEAD(fd,packet_len_table[0xd1]);
+ RFIFOHEAD(fd);
+
+ malloc_tsetdword(output, '\0', sizeof(output));
+
+ nick = (char*)RFIFOP(fd,2); // speed up
+ nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name have at maximum 23 characters
+
+ WFIFOW(fd,0) = 0x0d1; // R 00d1 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
+ WFIFOB(fd,2) = RFIFOB(fd,26);
+ // do nothing only if nick can not exist
+ if (strlen(nick) < 4) {
+ WFIFOB(fd,3) = 1; // fail
+ WFIFOSET(fd, packet_len_table[0x0d1]);
+ clif_wis_message(fd, wisp_server_name,
+ "This player name is not valid.",
+ strlen("This player name is not valid.")+1);
+ return;
+ }
+ // name can exist
+ // deny action (we add nick only if it's not already exist
+ if (RFIFOB(fd,26) == 0) { // Add block
+ for(i = 0; i < MAX_IGNORE_LIST &&
+ sd->ignore[i].name[0] != '\0' &&
+ strcmp(sd->ignore[i].name, nick) != 0
+ ; i++);
+
+ if (i == MAX_IGNORE_LIST) { //Full List
+ WFIFOB(fd,3) = 1; // fail
+ WFIFOSET(fd, packet_len_table[0x0d1]);
+ clif_wis_message(fd, wisp_server_name,
+ "You can not block more people.",
+ strlen("You can not block more people.") + 1);
+ if (strcmp(wisp_server_name, nick) == 0)
+ { // to found possible bot users who automaticaly ignore people.
+ sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
+ }
+ return;
+ }
+ if(sd->ignore[i].name[0] != '\0')
+ { //Name already exists.
+ WFIFOB(fd,3) = 1; // fail
+ WFIFOSET(fd, packet_len_table[0x0d1]);
+ clif_wis_message(fd, wisp_server_name,
+ "This player is already blocked.",
+ strlen("This player is already blocked.") + 1);
+ if (strcmp(wisp_server_name, nick) == 0) { // to found possible bot users who automaticaly ignore people.
+ sprintf(output, "Character '%s' (account: %d) has tried AGAIN to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
+ }
+ return;
+ }
+ //Insert in position i
+ memcpy(sd->ignore[i].name, nick, NAME_LENGTH-1);
+ WFIFOB(fd,3) = 0; // success
+ WFIFOSET(fd, packet_len_table[0x0d1]);
+ if (strcmp(wisp_server_name, nick) == 0)
+ { // to found possible bot users who automaticaly ignore people.
+ sprintf(output, "Character '%s' (account: %d) has tried to block wisps from '%s' (wisp name of the server). Bot user?", sd->status.name, sd->status.account_id, wisp_server_name);
+ intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, output);
+ // send something to be inform and force bot to ignore twice... If GM receiving block + block again, it's a bot :)
+ clif_wis_message(fd, wisp_server_name,
+ "Adding me in your ignore list will not block my wisps.",
+ strlen("Adding me in your ignore list will not block my wisps.") + 1);
+ }
+ //Sort the ignore list.
+ qsort (sd->ignore[0].name, MAX_IGNORE_LIST, sizeof(sd->ignore[0].name), pstrcmp);
+ return;
+ }
+ //Remove name
+ for(i = 0; i < MAX_IGNORE_LIST &&
+ sd->ignore[i].name[0] != '\0' &&
+ strcmp(sd->ignore[i].name, nick) != 0
+ ; i++);
+
+ if (i == MAX_IGNORE_LIST || sd->ignore[i].name[i] == '\0')
+ { //Not found
+ WFIFOB(fd,3) = 1; // fail
+ WFIFOSET(fd, packet_len_table[0x0d1]);
+ clif_wis_message(fd, wisp_server_name,
+ "This player is not blocked by you.",
+ strlen("This player is not blocked by you.") + 1);
+ return;
+ }
+ //Move everything one place down to overwrite removed entry.
+ memmove(sd->ignore[i].name, sd->ignore[i+1].name,
+ (MAX_IGNORE_LIST-i-1)*sizeof(sd->ignore[0].name));
+ malloc_tsetdword(sd->ignore[MAX_IGNORE_LIST-1].name, 0, sizeof(sd->ignore[0].name));
+ // success
+ WFIFOB(fd,3) = 0;
+ WFIFOSET(fd, packet_len_table[0x0d1]);
+
+// for debug only
+// for(i = 0; i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0'; i++) /
+// ShowDebug("Ignored player: '%s'\n", sd->ignore[i].name);
+ return;
+}
+
+void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { // Rewritten by [Yor]
+ //printf("Ignore all: state: %d\n", RFIFOB(fd,2));
+ RFIFOHEAD(fd);
+ WFIFOHEAD(fd,packet_len_table[0xd2]);
+ // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail
+ // S 00d0 <type>len.B: 00 (/exall) deny all speech, 01 (/inall) allow all speech
+ WFIFOW(fd,0) = 0x0d2;
+ WFIFOB(fd,2) = RFIFOB(fd,2);
+ if (RFIFOB(fd,2) == 0) { //Deny all
+ if (sd->state.ignoreAll) {
+ WFIFOB(fd,3) = 1; // fail
+ WFIFOSET(fd, packet_len_table[0x0d2]);
+ clif_wis_message(fd, wisp_server_name,
+ "You already block everyone.",
+ strlen("You already block everyone.") + 1);
+ return;
+ }
+ sd->state.ignoreAll = 1;
+ WFIFOB(fd,3) = 0; // success
+ WFIFOSET(fd, packet_len_table[0x0d2]);
+ return;
+ }
+ //Unblock everyone
+ if (!sd->state.ignoreAll) {
+ WFIFOB(fd,3) = 1; // fail
+ WFIFOSET(fd, packet_len_table[0x0d2]);
+ clif_wis_message(fd, wisp_server_name,
+ "You already allow everyone.",
+ strlen("You already allow everyone.") + 1);
+ return;
+ }
+ sd->state.ignoreAll = 0;
+ WFIFOB(fd,3) = 0; // success
+ WFIFOSET(fd, packet_len_table[0x0d2]);
+ return;
+}
+
+/*==========================================
+ * Wis拒否リスト
+ *------------------------------------------
+ */
+void clif_parse_PMIgnoreList(int fd,struct map_session_data *sd)
+{
+ int i;
+
+ WFIFOHEAD(fd, 4 + (NAME_LENGTH * MAX_IGNORE_LIST));
+ WFIFOW(fd,0) = 0xd4;
+
+ for(i = 0; i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0'; i++)
+ memcpy(WFIFOP(fd, 4 + i * NAME_LENGTH),sd->ignore[i].name, NAME_LENGTH);
+
+ WFIFOW(fd,2) = 4 + i * NAME_LENGTH;
+ WFIFOSET(fd, WFIFOW(fd,2));
+ return;
+}
+
+/*==========================================
+ * スパノビの/doridoriによるSPR2倍
+ *------------------------------------------
+ */
+void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) {
+ if (sd->state.doridori) return;
+
+ switch (sd->class_&MAPID_UPPERMASK)
+ {
+ case MAPID_SOUL_LINKER:
+ case MAPID_STAR_GLADIATOR:
+ case MAPID_TAEKWON:
+ if (!sd->state.rest)
+ break;
+ case MAPID_SUPER_NOVICE:
+ sd->state.doridori=1;
+ break;
+ }
+ return;
+}
+/*==========================================
+ * スパノビの爆裂波動
+ *------------------------------------------
+ */
+void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
+{
+ if(sd){
+ int nextbaseexp=pc_nextbaseexp(sd);
+ if (battle_config.etc_log){
+ if(nextbaseexp != 0)
+ ShowInfo("SuperNovice explosionspirits!! %d %d %d %d\n",sd->bl.id,sd->status.class_,sd->status.base_exp,(int)((double)1000*sd->status.base_exp/nextbaseexp));
+ else
+ ShowInfo("SuperNovice explosionspirits!! %d %d %d 000\n",sd->bl.id,sd->status.class_,sd->status.base_exp);
+ }
+ if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_exp > 0 && nextbaseexp > 0 && (int)((double)1000*sd->status.base_exp/nextbaseexp)%100==0){
+ clif_skill_nodamage(&sd->bl,&sd->bl,MO_EXPLOSIONSPIRITS,5,
+ sc_start(&sd->bl,SkillStatusChangeTable(MO_EXPLOSIONSPIRITS),100,
+ 5,skill_get_time(MO_EXPLOSIONSPIRITS,5)));
+ }
+ }
+ return;
+}
+
+// random notes:
+// 0x214: monster/player info ?
+
+/*==========================================
+ * Friends List
+ *------------------------------------------
+ */
+void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online)
+{ //Toggles a single friend online/offline [Skotlex]
+ int i, fd = sd->fd;
+
+ //Seek friend.
+ for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id &&
+ (sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
+
+ if(i == MAX_FRIENDS || sd->status.friends[i].char_id == 0)
+ return; //Not found
+
+ WFIFOHEAD(fd,packet_len_table[0x206]);
+ WFIFOW(fd, 0) = 0x206;
+ WFIFOL(fd, 2) = sd->status.friends[i].account_id;
+ WFIFOL(fd, 6) = sd->status.friends[i].char_id;
+ WFIFOB(fd,10) = !online; //Yeah, a 1 here means "logged off", go figure...
+ WFIFOSET(fd, packet_len_table[0x206]);
+}
+
+//Subfunction called from clif_foreachclient to toggle friends on/off [Skotlex]
+int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap)
+{
+ int account_id, char_id, online;
+ account_id = va_arg(ap, int);
+ char_id = va_arg(ap, int);
+ online = va_arg(ap, int);
+ clif_friendslist_toggle(sd, account_id, char_id, online);
+ return 0;
+}
+
+//For sending the whole friends list.
+void clif_friendslist_send(struct map_session_data *sd) {
+ int i = 0, n, fd = sd->fd;
+
+ // Send friends list
+ WFIFOHEAD(fd, MAX_FRIENDS * 32 + 4);
+ WFIFOW(fd, 0) = 0x201;
+ for(i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id; i++)
+ {
+ WFIFOL(fd, 4 + 32 * i + 0) = sd->status.friends[i].account_id;
+ WFIFOL(fd, 4 + 32 * i + 4) = sd->status.friends[i].char_id;
+ memcpy(WFIFOP(fd, 4 + 32 * i + 8), &sd->status.friends[i].name, NAME_LENGTH);
+ }
+
+ if (i) {
+ WFIFOW(fd,2) = 4 + 32 * i;
+ WFIFOSET(fd, WFIFOW(fd,2));
+ }
+
+ for (n = 0; n < i; n++)
+ { //Sending the online players
+ if (map_charid2sd(sd->status.friends[n].char_id))
+ clif_friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1);
+ }
+}
+
+
+// Status for adding friend - 0: successfull 1: not exist/rejected 2: over limit
+void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_data *f_sd, int type)
+{
+ int fd;
+ nullpo_retv(sd);
+
+ fd = sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x209]);
+ WFIFOW(fd,0) = 0x209;
+ WFIFOW(fd,2) = type;
+ if (f_sd)
+ {
+ WFIFOW(fd,4) = f_sd->status.account_id;
+ WFIFOW(fd,8) = f_sd->status.char_id;
+ memcpy(WFIFOP(fd, 12), f_sd->status.name,NAME_LENGTH);
+ }
+ WFIFOSET(fd, packet_len_table[0x209]);
+}
+
+void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) {
+ struct map_session_data *f_sd;
+ int i, f_fd;
+ RFIFOHEAD(fd);
+
+ f_sd = map_nick2sd((char*)RFIFOP(fd,2));
+
+ // Friend doesn't exist (no player with this name)
+ if (f_sd == NULL) {
+ clif_displaymessage(fd, msg_txt(3));
+ return;
+ }
+
+ // @noask [LuzZza]
+ if(f_sd->state.noask) {
+ clif_noask_sub(sd, f_sd, 5);
+ return;
+ }
+
+ // Friend already exists
+ for (i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id != 0; i++) {
+ if (sd->status.friends[i].char_id == f_sd->status.char_id) {
+ clif_displaymessage(fd, "Friend already exists.");
+ return;
+ }
+ }
+
+ if (i == MAX_FRIENDS) {
+ //No space, list full.
+ clif_friendslist_reqack(sd, f_sd, 2);
+ return;
+ }
+
+ f_fd = f_sd->fd;
+ WFIFOHEAD(f_fd,packet_len_table[0x207]);
+ WFIFOW(f_fd,0) = 0x207;
+ WFIFOL(f_fd,2) = sd->status.account_id;
+ WFIFOL(f_fd,6) = sd->status.char_id;
+ memcpy(WFIFOP(f_fd,10), sd->status.name, NAME_LENGTH);
+ WFIFOSET(f_fd, packet_len_table[0x207]);
+
+ return;
+}
+
+void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) {
+ //<W: id> <L: Player 1 chara ID> <L: Player 1 AID> <B: Response>
+ struct map_session_data *f_sd;
+ int char_id, account_id;
+ char reply;
+ RFIFOHEAD(fd);
+
+ account_id = RFIFOL(fd,2);
+ char_id = RFIFOL(fd,6);
+ reply = RFIFOB(fd,10);
+ //printf ("reply: %d %d %d\n", char_id, id, reply);
+
+ f_sd = map_id2sd(account_id); //The account id is the same as the bl.id of players.
+ if (f_sd == NULL)
+ return;
+
+ if (reply == 0)
+ clif_friendslist_reqack(f_sd, sd, 1);
+ else {
+ int i;
+ // Find an empty slot
+ for (i = 0; i < MAX_FRIENDS; i++)
+ if (f_sd->status.friends[i].char_id == 0)
+ break;
+ if (i == MAX_FRIENDS) {
+ clif_friendslist_reqack(f_sd, sd, 2);
+ return;
+ }
+
+ f_sd->status.friends[i].account_id = sd->status.account_id;
+ f_sd->status.friends[i].char_id = sd->status.char_id;
+ memcpy(f_sd->status.friends[i].name, sd->status.name, NAME_LENGTH);
+ clif_friendslist_reqack(f_sd, sd, 0);
+
+ if (battle_config.friend_auto_add) {
+ // Also add f_sd to sd's friendlist.
+ for (i = 0; i < MAX_FRIENDS; i++) {
+ if (sd->status.friends[i].char_id == f_sd->status.char_id)
+ return; //No need to add anything.
+ if (sd->status.friends[i].char_id == 0)
+ break;
+ }
+ if (i == MAX_FRIENDS) {
+ clif_friendslist_reqack(sd, f_sd, 2);
+ return;
+ }
+
+ sd->status.friends[i].account_id = f_sd->status.account_id;
+ sd->status.friends[i].char_id = f_sd->status.char_id;
+ memcpy(sd->status.friends[i].name, f_sd->status.name, NAME_LENGTH);
+ clif_friendslist_reqack(sd, f_sd, 0);
+ }
+ }
+
+ return;
+}
+
+void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) {
+ // 0x203 </o> <ID to be removed W 4B>
+ int account_id, char_id;
+ int i, j;
+ RFIFOHEAD(fd);
+
+ account_id = RFIFOL(fd,2);
+ char_id = RFIFOL(fd,6);
+
+ // Search friend
+ for (i = 0; i < MAX_FRIENDS &&
+ (sd->status.friends[i].char_id != char_id || sd->status.friends[i].account_id != account_id); i++);
+
+ if (i == MAX_FRIENDS) {
+ clif_displaymessage(fd, "Name not found in list.");
+ return;
+ }
+
+ // move all chars down
+ for(j = i + 1; j < MAX_FRIENDS; j++)
+ memcpy(&sd->status.friends[j-1], &sd->status.friends[j], sizeof(sd->status.friends[0]));
+
+ malloc_set(&sd->status.friends[MAX_FRIENDS-1], 0, sizeof(sd->status.friends[MAX_FRIENDS-1]));
+ clif_displaymessage(fd, "Friend removed");
+
+ WFIFOHEAD(fd,packet_len_table[0x20a]);
+ WFIFOW(fd,0) = 0x20a;
+ WFIFOL(fd,2) = account_id;
+ WFIFOL(fd,6) = char_id;
+ WFIFOSET(fd, packet_len_table[0x20a]);
+// clif_friendslist_send(sd); //This is not needed anymore.
+
+ return;
+}
+
+/*==========================================
+ * /killall
+ *------------------------------------------
+ */
+void clif_parse_GMKillAll(int fd,struct map_session_data *sd)
+{
+ char message[50];
+
+ strncpy(message,sd->status.name, NAME_LENGTH);
+ is_atcommand(fd, sd, strcat(message," : @kickall"));
+
+ return;
+}
+
+/*==========================================
+ * /pvpinfo
+ *------------------------------------------
+ */
+void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
+{
+ WFIFOHEAD(fd,packet_len_table[0x210]);
+ WFIFOW(fd,0) = 0x210;
+ //WFIFOL(fd,2) = 0; // not sure what for yet
+ //WFIFOL(fd,6) = 0;
+ WFIFOL(fd,10) = sd->pvp_won; // times won
+ WFIFOL(fd,14) = sd->pvp_lost; // times lost
+ WFIFOL(fd,18) = sd->pvp_point;
+ WFIFOSET(fd, packet_len_table[0x210]);
+
+ return;
+}
+
+/*==========================================
+ * /blacksmith
+ *------------------------------------------
+ */
+void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
+{
+ int i;
+ char *name;
+
+ WFIFOHEAD(fd,packet_len_table[0x219]);
+ WFIFOW(fd,0) = 0x219;
+ //Packet size limits this list to 10 elements. [Skotlex]
+ for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
+ if (smith_fame_list[i].id > 0) {
+ if (strcmp(smith_fame_list[i].name, "-") == 0 &&
+ (name = map_charid2nick(smith_fame_list[i].id)) != NULL)
+ {
+ strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), name, NAME_LENGTH);
+ } else
+ strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), smith_fame_list[i].name, NAME_LENGTH);
+ } else
+ strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "None", 5);
+ WFIFOL(fd, 242 + i * 4) = smith_fame_list[i].fame;
+ }
+ for(;i < 10; i++) { //In case the MAX is less than 10.
+ strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "Unavailable", 12);
+ WFIFOL(fd, 242 + i * 4) = 0;
+ }
+
+ WFIFOSET(fd, packet_len_table[0x219]);
+}
+
+int clif_fame_blacksmith(struct map_session_data *sd, int points)
+{
+ int fd = sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x21b]);
+ WFIFOW(fd,0) = 0x21b;
+ WFIFOL(fd,2) = points;
+ WFIFOL(fd,6) = sd->status.fame;
+ WFIFOSET(fd, packet_len_table[0x21b]);
+
+ return 0;
+}
+
+/*==========================================
+ * /alchemist
+ *------------------------------------------
+ */
+void clif_parse_Alchemist(int fd,struct map_session_data *sd)
+{
+ int i;
+ char *name;
+
+ WFIFOHEAD(fd,packet_len_table[0x21a]);
+ WFIFOW(fd,0) = 0x21a;
+ //Packet size limits this list to 10 elements. [Skotlex]
+ for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
+ if (chemist_fame_list[i].id > 0) {
+ if (strcmp(chemist_fame_list[i].name, "-") == 0 &&
+ (name = map_charid2nick(chemist_fame_list[i].id)) != NULL)
+ {
+ memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
+ } else
+ memcpy(WFIFOP(fd, 2 + 24 * i), chemist_fame_list[i].name, NAME_LENGTH);
+ } else
+ memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
+ WFIFOL(fd, 242 + i * 4) = chemist_fame_list[i].fame;
+ }
+ for(;i < 10; i++) { //In case the MAX is less than 10.
+ memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
+ WFIFOL(fd, 242 + i * 4) = 0;
+ }
+
+ WFIFOSET(fd, packet_len_table[0x21a]);
+}
+
+int clif_fame_alchemist(struct map_session_data *sd, int points)
+{
+ int fd = sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x21c]);
+ WFIFOW(fd,0) = 0x21c;
+ WFIFOL(fd,2) = points;
+ WFIFOL(fd,6) = sd->status.fame;
+ WFIFOSET(fd, packet_len_table[0x21c]);
+
+ return 0;
+}
+
+/*==========================================
+ * /taekwon
+ *------------------------------------------
+ */
+void clif_parse_Taekwon(int fd,struct map_session_data *sd)
+{
+ int i;
+ char *name;
+
+ WFIFOHEAD(fd,packet_len_table[0x226]);
+ WFIFOW(fd,0) = 0x226;
+ //Packet size limits this list to 10 elements. [Skotlex]
+ for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
+ if (taekwon_fame_list[i].id > 0) {
+ if (strcmp(taekwon_fame_list[i].name, "-") == 0 &&
+ (name = map_charid2nick(taekwon_fame_list[i].id)) != NULL)
+ {
+ memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
+ } else
+ memcpy(WFIFOP(fd, 2 + 24 * i), taekwon_fame_list[i].name, NAME_LENGTH);
+ } else
+ memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
+ WFIFOL(fd, 242 + i * 4) = taekwon_fame_list[i].fame;
+ }
+ for(;i < 10; i++) { //In case the MAX is less than 10.
+ memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
+ WFIFOL(fd, 242 + i * 4) = 0;
+ }
+ WFIFOSET(fd, packet_len_table[0x226]);
+}
+
+int clif_fame_taekwon(struct map_session_data *sd, int points)
+{
+ int fd = sd->fd;
+ WFIFOHEAD(fd,packet_len_table[0x224]);
+ WFIFOW(fd,0) = 0x224;
+ WFIFOL(fd,2) = points;
+ WFIFOL(fd,6) = sd->status.fame;
+ WFIFOSET(fd, packet_len_table[0x224]);
+
+ return 0;
+}
+
+/*==========================================
+ * PK Ranking table?
+ *------------------------------------------
+ */
+void clif_parse_RankingPk(int fd,struct map_session_data *sd)
+{
+ int i;
+
+ WFIFOHEAD(fd,packet_len_table[0x238]);
+ WFIFOW(fd,0) = 0x238;
+ for(i=0;i<10;i++){
+ memcpy(WFIFOP(fd,i*24+2), "Unknown", NAME_LENGTH);
+ WFIFOL(fd,i*4+242) = 0;
+ }
+ WFIFOSET(fd, packet_len_table[0x238]);
+ return;
+}
+
+/*==========================================
+ * SG Feel save OK [Komurka]
+ *------------------------------------------
+ */
+void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
+{
+ char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"};
+ int i;
+ if (sd->menuskill_id != SG_FEEL)
+ return;
+ i = sd->menuskill_lv-1;
+ if (i<0 || i > 2) return; //Bug?
+
+ sd->feel_map[i].index = map[sd->bl.m].index;
+ sd->feel_map[i].m = sd->bl.m;
+ pc_setglobalreg(sd,feel_var[i],map[sd->bl.m].index);
+
+//Are these really needed? Shouldn't they show up automatically from the feel save packet?
+// clif_misceffect2(&sd->bl, 0x1b0);
+// clif_misceffect2(&sd->bl, 0x21f);
+ clif_feel_info(sd, i, 0);
+ sd->menuskill_lv = sd->menuskill_id = 0;
+}
+
+/*==========================================
+ * Question about Star Glaldiator save map [Komurka]
+ *------------------------------------------
+ */
+void clif_parse_ReqFeel(int fd, struct map_session_data *sd, int skilllv) {
+ WFIFOHEAD(fd,packet_len_table[0x253]);
+ WFIFOW(fd,0)=0x253;
+ WFIFOSET(fd, packet_len_table[0x253]);
+ sd->menuskill_id=SG_FEEL;
+ sd->menuskill_lv=skilllv;
+}
+
+void clif_parse_AdoptRequest(int fd,struct map_session_data *sd) {
+ //TODO: add somewhere the adopt code, checks for exploits, etc, etc.
+ //Missing packets are the client's reply packets to the adopt request one.
+ //[Skotlex]
+ int account_id;
+ struct map_session_data *sd2;
+ RFIFOHEAD(fd);
+
+ account_id = RFIFOL(fd,2);
+ sd2 = map_id2sd(account_id);
+ if(sd2 && sd2->fd && sd2 != sd && sd2->status.party_id == sd->status.party_id) { //FIXME: No checks whatsoever are in place yet!
+ fd = sd2->fd;
+ WFIFOHEAD(fd,packet_len_table[0x1f9]);
+ WFIFOW(fd,0)=0x1f9;
+ WFIFOSET(fd, packet_len_table[0x1f9]);
+ }
+}
+/*==========================================
+ * パケットデバッグ
+ *------------------------------------------
+ */
+void clif_parse_debug(int fd,struct map_session_data *sd)
+{
+ int i, cmd, len;
+ RFIFOHEAD(fd);
+
+ cmd = RFIFOW(fd,0);
+ len = sd?packet_db[sd->packet_ver][cmd].len:RFIFOREST(fd); //With no session, just read the remaining in the buffer.
+ ShowDebug("packet debug 0x%4X\n",cmd);
+ printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
+ for(i=0;i<len;i++){
+ if((i&15)==0)
+ printf("\n%04X ",i);
+ printf("%02X ",RFIFOB(fd,i));
+ }
+ printf("\n");
+}
+
+/*==========================================
+ * クライアントからのパケット解析
+ * socket.cのdo_parsepacketから呼び出される
+ *------------------------------------------
+ */
+int clif_parse(int fd) {
+ int packet_len = 0, cmd, packet_ver, dump = 0;
+ struct map_session_data *sd;
+ RFIFOHEAD(fd);
+
+ if (fd <= 0)
+ { //Just in case, there are some checks for this later down below anyway which should be removed. [Skotlex]
+ ShowError("clif_parse: Received invalid session %d\n", fd);
+ return 0;
+ }
+
+ sd = (struct map_session_data*)session[fd]->session_data;
+
+ if (sd && sd->fd != fd)
+ { //FIXME: Temporal debug until a certain mysterious crash is fixed.
+ ShowError("Player's connection value is incorrect! %d != %d\n", sd->fd, fd);
+ sd->fd = fd;
+ }
+
+ if (session[fd]->eof) {
+ if (sd) {
+ if (sd->state.autotrade) {
+ //Disassociate character from the socket connection.
+ session[fd]->session_data = NULL;
+ sd->fd = 0;
+ ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n",
+ (pc_isGM(sd))?"GM ":"",sd->status.name);
+ } else
+ if (sd->state.auth) {
+ // Player logout display [Valaris]
+ ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n",
+ (pc_isGM(sd))?"GM ":"",sd->status.name);
+ clif_quitsave(fd, sd);
+ } else {
+ ShowInfo("Player AID:%d/CID:%d (not authenticated) logged off.\n",
+ sd->bl.id, sd->status.char_id);
+ map_quit(sd);
+ }
+ } else {
+ unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
+ ShowInfo("Closed connection from '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip[0],ip[1],ip[2],ip[3]);
+ }
+ do_close(fd);
+ return 0;
+ }
+
+ if (RFIFOREST(fd) < 2)
+ return 0;
+
+// printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
+
+ cmd = RFIFOW(fd,0);
+
+ // 管理用パケット処理
+ if (cmd >= 30000) {
+ switch(cmd) {
+ case 0x7530: { //Why are we letting people know which version we are running?
+ WFIFOHEAD(fd, 10);
+ WFIFOW(fd,0) = 0x7531;
+ WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
+ WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
+ WFIFOB(fd,4) = ATHENA_REVISION;
+ WFIFOB(fd,5) = ATHENA_RELEASE_FLAG;
+ WFIFOB(fd,6) = ATHENA_OFFICIAL_FLAG;
+ WFIFOB(fd,7) = ATHENA_SERVER_MAP;
+ WFIFOW(fd,8) = ATHENA_MOD_VERSION;
+ WFIFOSET(fd,10);
+ RFIFOSKIP(fd,2);
+ break;
+ }
+ case 0x7532: // 接続の切断
+ ShowWarning("clif_parse: session #%d disconnected for sending packet 0x04%x\n", fd, cmd);
+ session[fd]->eof=1;
+ break;
+ default:
+ ShowWarning("Unknown incoming packet (command: 0x%04x, session: %d), disconnecting.\n", cmd, fd);
+ session[fd]->eof=1;
+ break;
+ }
+ return 0;
+ }
+
+ // get packet version before to parse
+ packet_ver = 0;
+ if (sd) {
+ packet_ver = sd->packet_ver;
+ if (packet_ver < 0 || packet_ver > MAX_PACKET_VER) { // This should never happen unless we have some corrupted memory issues :X [Skotlex]
+ session[fd]->eof = 1;
+ return 0;
+ }
+ } else {
+ // check authentification packet to know packet version
+ packet_ver = clif_guess_PacketVer(fd, 0);
+ // check if version is accepted
+ if (packet_ver < 5 || // reject really old client versions
+ (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04
+ (packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0) ||
+ packet_ver > MAX_PACKET_VER) // no packet version support yet
+ {
+ ShowInfo("clif_parse: Disconnecting session #%d for not having latest client version (has version %d).\n", fd, packet_ver);
+ WFIFOHEAD(fd, 23);
+ WFIFOW(fd,0) = 0x6a;
+ WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version
+ WFIFOSET(fd,23);
+ packet_len = RFIFOREST(fd);
+ RFIFOSKIP(fd, packet_len);
+ clif_setwaitclose(fd);
+ if (session[fd]->func_send) //socket.c doesn't wants to send the data when left on it's own... [Skotlex]
+ session[fd]->func_send(fd);
+ return 0;
+ }
+ }
+
+ // ゲーム用以外パケットか、認証を終える前に0072以外が来たら、切断する
+ if (cmd >= MAX_PACKET_DB || packet_db[packet_ver][cmd].len == 0) { // if packet is not inside these values: session is incorrect?? or auth packet is unknown
+ ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd);
+ session[fd]->eof = 1;
+ return 0;
+ }
+
+ // パケット長を計算
+ packet_len = packet_db[packet_ver][cmd].len;
+ if (packet_len == -1) {
+ if (RFIFOREST(fd) < 4)
+ return 0; // 可変長パケットで長さの所までデータが来てない
+
+ packet_len = RFIFOW(fd,2);
+ if (packet_len < 4 || packet_len > 32768) {
+ ShowWarning("clif_parse: Packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", cmd, packet_len, fd);
+ session[fd]->eof =1;
+ return 0;
+ }
+ }
+ if ((int)RFIFOREST(fd) < packet_len)
+ return 0; // まだ1パケット分データが揃ってない
+
+#if DUMP_ALL_PACKETS
+ {
+ int i;
+ FILE *fp;
+ char packet_txt[256] = "save/packet.txt";
+ time_t now;
+ dump = 1;
+
+ if ((fp = fopen(packet_txt, "a")) == NULL) {
+ ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
+ return 1;
+ } else {
+ time(&now);
+ if (sd && sd->state.auth) {
+ if (sd->status.name != NULL)
+ fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent packet:\n",
+ asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
+ else
+ fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+ } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
+ fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+
+ fprintf(fp, "\tsession #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
+ fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
+ for(i = 0; i < packet_len; i++) {
+ if ((i & 15) == 0)
+ fprintf(fp, "\n\t%04X ", i);
+ fprintf(fp, "%02X ", RFIFOB(fd,i));
+ }
+ fprintf(fp, "\n\n");
+ fclose(fp);
+ }
+ }
+#endif
+
+ if (sd && sd->state.waitingdisconnect == 1) {
+ // 切断待ちの場合パケットを処理しない
+ } else if (packet_db[packet_ver][cmd].func) {
+ if (sd && sd->bl.prev == NULL &&
+ packet_db[packet_ver][cmd].func != clif_parse_LoadEndAck)
+ ; //Only valid packet when player is not on a map is the finish-loading packet.
+ else
+ if (sd
+ || packet_db[packet_ver][cmd].func == clif_parse_WantToConnection
+ || packet_db[packet_ver][cmd].func == clif_parse_debug
+ ) //Only execute the function when there's an sd (except for debug/wanttoconnect packets)
+ packet_db[packet_ver][cmd].func(fd, sd);
+ }
+#if DUMP_UNKNOWN_PACKET
+ else if (battle_config.error_log)
+ {
+ int i;
+ FILE *fp;
+ char packet_txt[256] = "save/packet.txt";
+ time_t now;
+ dump = 1;
+
+ if ((fp = fopen(packet_txt, "a")) == NULL) {
+ ShowError("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
+ return 1;
+ } else {
+ time(&now);
+ if (sd && sd->state.auth) {
+ fprintf(fp, "%sPlayer with account ID %d (character ID %d, player name %s) sent wrong packet:\n",
+ asctime(localtime(&now)), sd->status.account_id, sd->status.char_id, sd->status.name);
+ } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
+ fprintf(fp, "%sPlayer with account ID %d sent wrong packet:\n", asctime(localtime(&now)), sd->bl.id);
+
+ fprintf(fp, "\t---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
+ for(i = 0; i < packet_len; i++) {
+ if ((i & 15) == 0)
+ fprintf(fp, "\n\t%04X ", i);
+ fprintf(fp, "%02X ", RFIFOB(fd,i));
+ }
+ fprintf(fp, "\n\n");
+ fclose(fp);
+ }
+ }
+#endif
+
+ if (dump) {
+ int i;
+ if (fd)
+ ShowDebug("\nclif_parse: session #%d, packet 0x%04x, length %d, version %d\n", fd, cmd, packet_len, packet_ver);
+ printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
+ for(i = 0; i < packet_len; i++) {
+ if ((i & 15) == 0)
+ printf("\n%04X ",i);
+ printf("%02X ", RFIFOB(fd,i));
+ }
+ printf("\n");
+ if (sd && sd->state.auth) {
+ if (sd->status.name != NULL)
+ printf("\nAccount ID %d, character ID %d, player name %s.\n",
+ sd->status.account_id, sd->status.char_id, sd->status.name);
+ else
+ printf("\nAccount ID %d.\n", sd->bl.id);
+ } else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
+ printf("\nAccount ID %d.\n", sd->bl.id);
+ }
+
+ RFIFOSKIP(fd, packet_len);
+
+ return 0;
+}
+
+/*==========================================
+ * パケットデータベース読み込み
+ *------------------------------------------
+ */
+static int packetdb_readdb(void)
+{
+ FILE *fp;
+ char line[1024];
+ int ln=0;
+ int cmd,i,j,k,packet_ver;
+ char *str[64],*p,*str2[64],*p2,w1[64],w2[64];
+
+ struct {
+ void (*func)(int, struct map_session_data *);
+ char *name;
+ } clif_parse_func[]={
+ {clif_parse_WantToConnection,"wanttoconnection"},
+ {clif_parse_LoadEndAck,"loadendack"},
+ {clif_parse_TickSend,"ticksend"},
+ {clif_parse_WalkToXY,"walktoxy"},
+ {clif_parse_QuitGame,"quitgame"},
+ {clif_parse_GetCharNameRequest,"getcharnamerequest"},
+ {clif_parse_GlobalMessage,"globalmessage"},
+ {clif_parse_MapMove,"mapmove"},
+ {clif_parse_ChangeDir,"changedir"},
+ {clif_parse_Emotion,"emotion"},
+ {clif_parse_HowManyConnections,"howmanyconnections"},
+ {clif_parse_ActionRequest,"actionrequest"},
+ {clif_parse_Restart,"restart"},
+ {clif_parse_Wis,"wis"},
+ {clif_parse_GMmessage,"gmmessage"},
+ {clif_parse_TakeItem,"takeitem"},
+ {clif_parse_DropItem,"dropitem"},
+ {clif_parse_UseItem,"useitem"},
+ {clif_parse_EquipItem,"equipitem"},
+ {clif_parse_UnequipItem,"unequipitem"},
+ {clif_parse_NpcClicked,"npcclicked"},
+ {clif_parse_NpcBuySellSelected,"npcbuysellselected"},
+ {clif_parse_NpcBuyListSend,"npcbuylistsend"},
+ {clif_parse_NpcSellListSend,"npcselllistsend"},
+ {clif_parse_CreateChatRoom,"createchatroom"},
+ {clif_parse_ChatAddMember,"chataddmember"},
+ {clif_parse_ChatRoomStatusChange,"chatroomstatuschange"},
+ {clif_parse_ChangeChatOwner,"changechatowner"},
+ {clif_parse_KickFromChat,"kickfromchat"},
+ {clif_parse_ChatLeave,"chatleave"},
+ {clif_parse_TradeRequest,"traderequest"},
+ {clif_parse_TradeAck,"tradeack"},
+ {clif_parse_TradeAddItem,"tradeadditem"},
+ {clif_parse_TradeOk,"tradeok"},
+ {clif_parse_TradeCancel,"tradecancel"},
+ {clif_parse_TradeCommit,"tradecommit"},
+ {clif_parse_StopAttack,"stopattack"},
+ {clif_parse_PutItemToCart,"putitemtocart"},
+ {clif_parse_GetItemFromCart,"getitemfromcart"},
+ {clif_parse_RemoveOption,"removeoption"},
+ {clif_parse_ChangeCart,"changecart"},
+ {clif_parse_StatusUp,"statusup"},
+ {clif_parse_SkillUp,"skillup"},
+ {clif_parse_UseSkillToId,"useskilltoid"},
+ {clif_parse_UseSkillToPos,"useskilltopos"},
+ {clif_parse_UseSkillToPosMoreInfo,"useskilltoposinfo"},
+ {clif_parse_UseSkillMap,"useskillmap"},
+ {clif_parse_RequestMemo,"requestmemo"},
+ {clif_parse_ProduceMix,"producemix"},
+ {clif_parse_NpcSelectMenu,"npcselectmenu"},
+ {clif_parse_NpcNextClicked,"npcnextclicked"},
+ {clif_parse_NpcAmountInput,"npcamountinput"},
+ {clif_parse_NpcStringInput,"npcstringinput"},
+ {clif_parse_NpcCloseClicked,"npccloseclicked"},
+ {clif_parse_ItemIdentify,"itemidentify"},
+ {clif_parse_SelectArrow,"selectarrow"},
+ {clif_parse_AutoSpell,"autospell"},
+ {clif_parse_UseCard,"usecard"},
+ {clif_parse_InsertCard,"insertcard"},
+ {clif_parse_RepairItem,"repairitem"},
+ {clif_parse_WeaponRefine,"weaponrefine"},
+ {clif_parse_SolveCharName,"solvecharname"},
+ {clif_parse_ResetChar,"resetchar"},
+ {clif_parse_LGMmessage,"lgmmessage"},
+ {clif_parse_MoveToKafra,"movetokafra"},
+ {clif_parse_MoveFromKafra,"movefromkafra"},
+ {clif_parse_MoveToKafraFromCart,"movetokafrafromcart"},
+ {clif_parse_MoveFromKafraToCart,"movefromkafratocart"},
+ {clif_parse_CloseKafra,"closekafra"},
+ {clif_parse_CreateParty,"createparty"},
+ {clif_parse_CreateParty2,"createparty2"},
+ {clif_parse_PartyInvite,"partyinvite"},
+ {clif_parse_ReplyPartyInvite,"replypartyinvite"},
+ {clif_parse_LeaveParty,"leaveparty"},
+ {clif_parse_RemovePartyMember,"removepartymember"},
+ {clif_parse_PartyChangeOption,"partychangeoption"},
+ {clif_parse_PartyMessage,"partymessage"},
+ {clif_parse_CloseVending,"closevending"},
+ {clif_parse_VendingListReq,"vendinglistreq"},
+ {clif_parse_PurchaseReq,"purchasereq"},
+ {clif_parse_OpenVending,"openvending"},
+ {clif_parse_CreateGuild,"createguild"},
+ {clif_parse_GuildCheckMaster,"guildcheckmaster"},
+ {clif_parse_GuildRequestInfo,"guildrequestinfo"},
+ {clif_parse_GuildChangePositionInfo,"guildchangepositioninfo"},
+ {clif_parse_GuildChangeMemberPosition,"guildchangememberposition"},
+ {clif_parse_GuildRequestEmblem,"guildrequestemblem"},
+ {clif_parse_GuildChangeEmblem,"guildchangeemblem"},
+ {clif_parse_GuildChangeNotice,"guildchangenotice"},
+ {clif_parse_GuildInvite,"guildinvite"},
+ {clif_parse_GuildReplyInvite,"guildreplyinvite"},
+ {clif_parse_GuildLeave,"guildleave"},
+ {clif_parse_GuildExpulsion,"guildexplusion"},
+ {clif_parse_GuildMessage,"guildmessage"},
+ {clif_parse_GuildRequestAlliance,"guildrequestalliance"},
+ {clif_parse_GuildReplyAlliance,"guildreplyalliance"},
+ {clif_parse_GuildDelAlliance,"guilddelalliance"},
+ {clif_parse_GuildOpposition,"guildopposition"},
+ {clif_parse_GuildBreak,"guildbreak"},
+ {clif_parse_PetMenu,"petmenu"},
+ {clif_parse_CatchPet,"catchpet"},
+ {clif_parse_SelectEgg,"selectegg"},
+ {clif_parse_SendEmotion,"sendemotion"},
+ {clif_parse_ChangePetName,"changepetname"},
+ {clif_parse_GMKick,"gmkick"},
+ {clif_parse_GMHide,"gmhide"},
+ {clif_parse_GMReqNoChat,"gmreqnochat"},
+ {clif_parse_GMReqNoChatCount,"gmreqnochatcount"},
+ {clif_parse_NoviceDoriDori,"sndoridori"},
+ {clif_parse_NoviceExplosionSpirits,"snexplosionspirits"},
+ {clif_parse_PMIgnore,"wisexin"},
+ {clif_parse_PMIgnoreList,"wisexlist"},
+ {clif_parse_PMIgnoreAll,"wisall"},
+ {clif_parse_FriendsListAdd,"friendslistadd"},
+ {clif_parse_FriendsListRemove,"friendslistremove"},
+ {clif_parse_FriendsListReply,"friendslistreply"},
+ {clif_parse_GMKillAll,"killall"},
+ {clif_parse_Recall,"summon"},
+ {clif_parse_GM_Monster_Item,"itemmonster"},
+ {clif_parse_Shift,"shift"},
+ {clif_parse_Blacksmith,"blacksmith"},
+ {clif_parse_Alchemist,"alchemist"},
+ {clif_parse_Taekwon,"taekwon"},
+ {clif_parse_RankingPk,"rankingpk"},
+ {clif_parse_FeelSaveOk,"feelsaveok"},
+ {clif_parse_AdoptRequest,"adopt"},
+ {clif_parse_debug,"debug"},
+ //[blackhole89] //[orn]
+ {clif_parse_ChangeHomunculusName,"changehomunculusname"},
+ {clif_parse_HomMoveToMaster,"hommovetomaster"},
+ {clif_parse_HomMoveTo,"hommoveto"},
+ {clif_parse_HomAttack,"homattack"},
+ {clif_parse_HomMenu,"hommenu"},
+ {NULL,NULL}
+ };
+
+ sprintf(line, "%s/packet_db.txt", db_path);
+ if( (fp=fopen(line,"r"))==NULL ){
+ ShowFatalError("can't read %s\n", line);
+ exit(1);
+ }
+
+ clif_config.packet_db_ver = MAX_PACKET_VER;
+ packet_ver = MAX_PACKET_VER; // read into packet_db's version by default
+ while(fgets(line,1020,fp)){
+ if(line[0]=='/' && line[1]=='/')
+ continue;
+ if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) {
+ if(strcmpi(w1,"packet_ver")==0) {
+ int prev_ver = packet_ver;
+ packet_ver = atoi(w2);
+ if (packet_ver > MAX_PACKET_VER)
+ { //Check to avoid overflowing. [Skotlex]
+ ShowWarning("The packet_db table only has support up to version %d\n", MAX_PACKET_VER);
+ break;
+ }
+ // copy from previous version into new version and continue
+ // - indicating all following packets should be read into the newer version
+ memcpy(&packet_db[packet_ver], &packet_db[prev_ver], sizeof(packet_db[0]));
+ continue;
+ } else if(strcmpi(w1,"packet_db_ver")==0) {
+ //This is the preferred version.
+ if(strcmpi(w2,"default")==0)
+ clif_config.packet_db_ver = MAX_PACKET_VER;
+ else {
+ // to manually set the packet DB version
+ clif_config.packet_db_ver = atoi(w2);
+ // check for invalid version
+ if (clif_config.packet_db_ver > MAX_PACKET_VER ||
+ clif_config.packet_db_ver < 0)
+ clif_config.packet_db_ver = MAX_PACKET_VER;
+ }
+ continue;
+ }
+ }
+
+ malloc_tsetdword(str,0,sizeof(str));
+ for(j=0,p=line;j<4 && p;j++){
+ str[j]=p;
+ p=strchr(p,',');
+ if(p) *p++=0;
+ }
+ if(str[0]==NULL)
+ continue;
+ cmd=strtol(str[0],(char **)NULL,0);
+ if(cmd<=0 || cmd>=MAX_PACKET_DB)
+ continue;
+ if(str[1]==NULL){
+ ShowError("packet_db: packet len error\n");
+ continue;
+ }
+ k = atoi(str[1]);
+ packet_db[packet_ver][cmd].len = k;
+
+ if(str[2]==NULL){
+ packet_db[packet_ver][cmd].func = NULL;
+ ln++;
+ continue;
+ }
+ for(j=0;j<sizeof(clif_parse_func)/sizeof(clif_parse_func[0]);j++){
+ if(clif_parse_func[j].name != NULL &&
+ strcmp(str[2],clif_parse_func[j].name)==0)
+ {
+ if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func)
+ { //If we are updating a function, we need to zero up the previous one. [Skotlex]
+ for(i=0;i<MAX_PACKET_DB;i++){
+ if (packet_db[packet_ver][i].func == clif_parse_func[j].func)
+ {
+ malloc_tsetword(&packet_db[packet_ver][i], 0, sizeof(struct packet_db));
+ break;
+ }
+ }
+ }
+ packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
+ break;
+ }
+ }
+ // set the identifying cmd for the packet_db version
+ if (strcmp(str[2],"wanttoconnection")==0)
+ clif_config.connect_cmd[packet_ver] = cmd;
+
+ if(str[3]==NULL){
+ ShowError("packet_db: packet error\n");
+ exit(1);
+ }
+ for(j=0,p2=str[3];p2;j++){
+ str2[j]=p2;
+ p2=strchr(p2,':');
+ if(p2) *p2++=0;
+ k = atoi(str2[j]);
+ // if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db) // not used for now
+ packet_db[packet_ver][cmd].pos[j] = k;
+ }
+
+ ln++;
+// if(packet_db[clif_config.packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */)
+// printf("packet_db ver %d: %d 0x%x %d %s %p\n",packet_ver,ln,cmd,packet_db[packet_ver][cmd].len,str[2],packet_db[packet_ver][cmd].func);
+ }
+ fclose(fp);
+ if (!clif_config.connect_cmd[clif_config.packet_db_ver])
+ { //Locate the nearest version that we still support. [Skotlex]
+ for(j = clif_config.packet_db_ver; j >= 0 && !clif_config.connect_cmd[j]; j--);
+
+ clif_config.packet_db_ver = j?j:MAX_PACKET_VER;
+ }
+ ShowStatus("Done reading packet database from '"CL_WHITE"%s"CL_RESET"'. Using default packet version: "CL_WHITE"%d"CL_RESET".\n", "packet_db.txt", clif_config.packet_db_ver);
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+int do_init_clif(void) {
+
+ clif_config.packet_db_ver = -1; // the main packet version of the DB
+ malloc_tsetdword(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
+
+ malloc_tsetword(packet_db,0,sizeof(packet_db));
+ //Using the packet_db file is the only way to set up packets now [Skotlex]
+ packetdb_readdb();
+
+ set_defaultparse(clif_parse);
+ if (!make_listen_bind(bind_ip,map_port)) {
+ ShowFatalError("cant bind game port\n");
+ exit(1);
+ }
+
+ add_timer_func_list(clif_waitclose, "clif_waitclose");
+ add_timer_func_list(clif_clearchar_delay_sub, "clif_clearchar_delay_sub");
+ add_timer_func_list(clif_delayquit, "clif_delayquit");
+ add_timer_func_list(clif_nighttimer, "clif_nighttimer");
+ add_timer_func_list(clif_walktoxy_timer, "clif_walktoxy_timer");
+ return 0;
+}
+