summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-09-25 09:07:33 -0300
committershennetsind <ind@henn.et>2013-09-25 09:07:33 -0300
commit13afb7e0bf35bacc9c90c7dffe34120ddd2fd099 (patch)
tree180c739ac69aceab8ce4cc6151030539a32ac8c3 /src/map/atcommand.c
parent1114eb3da58b078258a824424fef687a1ccee90c (diff)
parent66979ef89363c03e3cc02d63feb5248836daff4e (diff)
downloadhercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.gz
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.bz2
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.xz
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Conflicts: src/map/chrif.c src/map/clif.c src/map/homunculus.c src/map/pet.c src/map/script.c src/map/skill.c src/map/status.c All clear.
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c172
1 files changed, 75 insertions, 97 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 23653f803..41d93fa4d 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -60,7 +60,7 @@ static char atcmd_player_name[NAME_LENGTH];
static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
static const char* atcommand_checkalias(const char *aliasname); // @help
-static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
+static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd); // @help
// @commands (script-based)
struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
@@ -4223,8 +4223,7 @@ ACMD(nuke)
/*==========================================
* @tonpc
*------------------------------------------*/
-ACMD(tonpc)
-{
+ACMD(tonpc) {
char npcname[NAME_LENGTH+1];
struct npc_data *nd;
@@ -4238,7 +4237,7 @@ ACMD(tonpc)
}
if ((nd = npc->name2id(npcname)) != NULL) {
- if (pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
+ if (nd->bl.m != -1 && pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
clif->message(fd, msg_txt(0)); // Warped.
else
return false;
@@ -6839,27 +6838,26 @@ ACMD(showmobs)
/*==========================================
* homunculus level up [orn]
*------------------------------------------*/
-ACMD(homlevel)
-{
+ACMD(homlevel) {
TBL_HOM * hd;
int level = 0;
enum homun_type htype;
nullpo_retr(-1, sd);
- if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
+ if( !message || !*message || ( level = atoi(message) ) < 1 ) {
clif->message(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
return false;
}
- if ( !homun_alive(sd->hd) ) {
+ if( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
hd = sd->hd;
- if((htype = homun->class2type(hd->homunculus.class_)) == -1) {
+ if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) {
ShowError("atcommand_homlevel: invalid homun class %d (player %s)\n", hd->homunculus.class_,sd->status.name);
return false;
}
@@ -6921,12 +6919,12 @@ ACMD(hommutate) {
enum homun_type m_class, m_id;
nullpo_retr(-1, sd);
- if (!homun_alive(sd->hd)) {
+ if( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
- if (!message || !*message) {
+ if( !message || !*message ) {
homun_id = 6048 + (rnd() % 4);
} else {
homun_id = atoi(message);
@@ -6935,7 +6933,7 @@ ACMD(hommutate) {
m_class = homun->class2type(sd->hd->homunculus.class_);
m_id = homun->class2type(homun_id);
- if (m_class != -1 && m_id != -1 && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99) {
+ if( m_class != HT_INVALID && m_id != HT_INVALID && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99 ) {
homun->mutate(sd->hd, homun_id);
} else {
clif->emotion(&sd->hd->bl, E_SWT);
@@ -7637,7 +7635,7 @@ return true;\
clif->message(sd->fd," ");
clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
clif->message(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags.
- return 1;
+ return true;
}
for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase
@@ -7741,8 +7739,7 @@ ACMD(showdelay)
* @reject - reject invitation
* @leave - leave duel
*------------------------------------------*/
-ACMD(invite)
-{
+ACMD(invite) {
unsigned int did = sd->duel_group;
struct map_session_data *target_sd = iMap->nick2sd((char *)message);
@@ -7752,8 +7749,8 @@ ACMD(invite)
return true;
}
- if(iDuel->duel_list[did].max_players_limit > 0 &&
- iDuel->duel_list[did].members_count >= iDuel->duel_list[did].max_players_limit) {
+ 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->message(fd, msg_txt(351));
@@ -7779,18 +7776,17 @@ ACMD(invite)
return true;
}
- iDuel->invite(did, sd, target_sd);
+ duel->invite(did, sd, target_sd);
// "Duel: Invitation has been sent."
clif->message(fd, msg_txt(354));
return true;
}
-ACMD(duel)
-{
+ACMD(duel) {
unsigned int maxpl = 0;
if(sd->duel_group > 0) {
- iDuel->showinfo(sd->duel_group, sd);
+ duel->showinfo(sd->duel_group, sd);
return true;
}
@@ -7800,7 +7796,7 @@ ACMD(duel)
return true;
}
- if(!iDuel->checktime(sd)) {
+ if(!duel->checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
sprintf(output, msg_txt(356), battle_config.duel_time_interval);
@@ -7814,18 +7810,18 @@ ACMD(duel)
clif->message(fd, msg_txt(357)); // "Duel: Invalid value."
return true;
}
- iDuel->create(sd, maxpl);
+ duel->create(sd, maxpl);
} else {
struct map_session_data *target_sd;
target_sd = iMap->nick2sd((char *)message);
if(target_sd != NULL) {
unsigned int newduel;
- if((newduel = iDuel->create(sd, 2)) != -1) {
+ if((newduel = duel->create(sd, 2)) != -1) {
if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
clif->message(fd, msg_txt(353)); // "Duel: Player already in duel."
return true;
}
- iDuel->invite(newduel, sd, target_sd);
+ duel->invite(newduel, sd, target_sd);
clif->message(fd, msg_txt(354)); // "Duel: Invitation has been sent."
}
} else {
@@ -7835,28 +7831,26 @@ ACMD(duel)
}
}
} else
- iDuel->create(sd, 0);
+ duel->create(sd, 0);
return true;
}
-ACMD(leave)
-{
+ACMD(leave) {
if(sd->duel_group <= 0) {
// "Duel: @leave without @duel."
clif->message(fd, msg_txt(358));
return true;
}
- iDuel->leave(sd->duel_group, sd);
+ duel->leave(sd->duel_group, sd);
clif->message(fd, msg_txt(359)); // "Duel: You left the duel."
return true;
}
-ACMD(accept)
-{
- if(!iDuel->checktime(sd)) {
+ACMD(accept) {
+ if(!duel->checktime(sd)) {
char output[CHAT_SIZE_MAX];
// "Duel: You can take part in duel only one time per %d minutes."
sprintf(output, msg_txt(356), battle_config.duel_time_interval);
@@ -7870,28 +7864,27 @@ ACMD(accept)
return true;
}
- if( iDuel->duel_list[sd->duel_invite].max_players_limit > 0 && iDuel->duel_list[sd->duel_invite].members_count >= iDuel->duel_list[sd->duel_invite].max_players_limit )
- {
+ if( duel->list[sd->duel_invite].max_players_limit > 0
+ && duel->list[sd->duel_invite].members_count >= duel->list[sd->duel_invite].max_players_limit ) {
// "Duel: Limit of players is reached."
clif->message(fd, msg_txt(351));
return true;
}
- iDuel->accept(sd->duel_invite, sd);
+ duel->accept(sd->duel_invite, sd);
// "Duel: Invitation has been accepted."
clif->message(fd, msg_txt(361));
return true;
}
-ACMD(reject)
-{
+ACMD(reject) {
if(sd->duel_invite <= 0) {
// "Duel: @reject without invititation."
clif->message(fd, msg_txt(362));
return true;
}
- iDuel->reject(sd->duel_invite, sd);
+ duel->reject(sd->duel_invite, sd);
// "Duel: Invitation has been rejected."
clif->message(fd, msg_txt(363));
return true;
@@ -8146,28 +8139,20 @@ ACMD(itemlist)
nullpo_retr(-1, sd);
- if( strcmp(command+1, "storagelist") == 0 )
- {
+ if( strcmp(command+1, "storagelist") == 0 ) {
location = "storage";
items = sd->status.storage.items;
size = MAX_STORAGE;
- }
- else
- if( strcmp(command+1, "cartlist") == 0 )
- {
- location = "cart";
- items = sd->status.cart;
- size = MAX_CART;
- }
- else
- if( strcmp(command+1, "itemlist") == 0 )
- {
- location = "inventory";
- items = sd->status.inventory;
- size = MAX_INVENTORY;
- }
- else
- return 1;
+ } else if( strcmp(command+1, "cartlist") == 0 ) {
+ location = "cart";
+ items = sd->status.cart;
+ size = MAX_CART;
+ } else if( strcmp(command+1, "itemlist") == 0 ) {
+ location = "inventory";
+ items = sd->status.inventory;
+ size = MAX_INVENTORY;
+ } else
+ return false;
StrBuf->Init(&buf);
@@ -8196,8 +8181,7 @@ ACMD(itemlist)
else
StrBuf->Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
- if( it->equip )
- {
+ if( it->equip ) {
char equipstr[CHAT_SIZE_MAX];
strcpy(equipstr, msg_txt(1333)); // | equipped:
if( it->equip & EQP_GARMENT )
@@ -8236,52 +8220,46 @@ ACMD(itemlist)
clif->message(fd, StrBuf->Value(&buf));
StrBuf->Clear(&buf);
- if( it->card[0] == CARD0_PET )
- {// pet egg
+ if( it->card[0] == CARD0_PET ) {
+ // pet egg
if (it->card[3])
StrBuf->Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
else
StrBuf->Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
- }
- else
- if(it->card[0] == CARD0_FORGE)
- {// forged item
- StrBuf->Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
+ } else if(it->card[0] == CARD0_FORGE) {
+ // forged item
+ StrBuf->Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
+ } else if(it->card[0] == CARD0_CREATE) {
+ // created item
+ StrBuf->Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
+ } else {
+ // normal item
+ int counter2 = 0;
+
+ for( j = 0; j < itd->slot; ++j ) {
+ struct item_data* card;
+
+ if( it->card[j] == 0 || (card = itemdb->exists(it->card[j])) == NULL )
+ continue;
+
+ counter2++;
+
+ if( counter2 == 1 )
+ StrBuf->AppendStr(&buf, msg_txt(1352)); // -> (card(s):
+
+ if( counter2 != 1 )
+ StrBuf->AppendStr(&buf, ", ");
+
+ StrBuf->Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
}
- else
- if(it->card[0] == CARD0_CREATE)
- {// created item
- StrBuf->Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
- }
- else
- {// normal item
- int counter2 = 0;
-
- for( j = 0; j < itd->slot; ++j )
- {
- struct item_data* card;
-
- if( it->card[j] == 0 || (card = itemdb->exists(it->card[j])) == NULL )
- continue;
-
- counter2++;
-
- if( counter2 == 1 )
- StrBuf->AppendStr(&buf, msg_txt(1352)); // -> (card(s):
-
- if( counter2 != 1 )
- StrBuf->AppendStr(&buf, ", ");
-
- StrBuf->Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
- }
-
- if( counter2 > 0 )
- StrBuf->AppendStr(&buf, ")");
- }
+
+ if( counter2 > 0 )
+ StrBuf->AppendStr(&buf, ")");
+ }
if( StrBuf->Length(&buf) > 0 )
clif->message(fd, StrBuf->Value(&buf));
-
+
StrBuf->Clear(&buf);
}