summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
author(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-23 20:38:44 +0000
committer(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-01-23 20:38:44 +0000
commit2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b (patch)
tree89c47d81729687d5a69cadde99ee350306eb814f /src/map
parentc4e6857d4774b25dcd9b9137f76c14c92015d691 (diff)
downloadhercules-2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b.tar.gz
hercules-2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b.tar.bz2
hercules-2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b.tar.xz
hercules-2c5fabbc0b492cb5456e670ce9eb2352a11d5e3b.zip
update
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@968 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c164
-rw-r--r--src/map/atcommand.h10
-rw-r--r--src/map/battle.c169
-rw-r--r--src/map/battle.h7
-rw-r--r--src/map/charcommand.c4
-rw-r--r--src/map/chat.c6
-rw-r--r--src/map/clif.c388
-rw-r--r--src/map/clif.h14
-rw-r--r--src/map/guild.c36
-rw-r--r--src/map/guild.h2
-rw-r--r--src/map/intif.c10
-rw-r--r--src/map/intif.h2
-rw-r--r--src/map/itemdb.c14
-rw-r--r--src/map/mail.c56
-rw-r--r--src/map/map.c195
-rw-r--r--src/map/map.h11
-rw-r--r--src/map/mob.c636
-rw-r--r--src/map/mob.h6
-rw-r--r--src/map/npc.c226
-rw-r--r--src/map/party.c2
-rw-r--r--src/map/pc.c246
-rw-r--r--src/map/pet.c4
-rw-r--r--src/map/script.c240
-rw-r--r--src/map/skill.c536
-rw-r--r--src/map/skill.h15
-rw-r--r--src/map/storage.c12
-rw-r--r--src/map/vending.c6
27 files changed, 1743 insertions, 1274 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 4b245fd0b..c1f491910 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8,6 +8,7 @@
#include "../common/socket.h"
#include "../common/timer.h"
#include "../common/nullpo.h"
+#include "../common/mmo.h"
#include "log.h"
#include "clif.h"
@@ -465,7 +466,7 @@ static AtCommandInfo atcommand_info[] = {
{ AtCommand_Send, "@send", 60, atcommand_send },
{ AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
{ AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
- { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
+ { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
{ AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
// { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
{ AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
@@ -531,8 +532,8 @@ static AtCommandInfo atcommand_info[] = {
* This function return the name of the job (by [Yor])
*----------------------------------------------------
*/
-char * job_name(int class) {
- switch (class) {
+char * job_name(int class_) {
+ switch (class_) {
case 0: return "Novice";
case 1: return "Swordsman";
case 2: return "Mage";
@@ -833,18 +834,18 @@ static int atmobsearch_sub(struct block_list *bl,va_list ap)
static int number=0;
struct mob_data *md;
char output[128];
-
+
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(output, sizeof output, "%2d[%3d:%3d] %s",
++number,bl->x, bl->y,md->name);
@@ -894,7 +895,7 @@ void rehash( const int fd, struct map_session_data* sd )
int map_id = 0;
int LOADED_MAPS = map_num;
-
+
for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
if (map_id > LOADED_MAPS)
@@ -1023,7 +1024,7 @@ int atcommand_send(
WBUFW(buf,0)=0x18f;
case 4:
WBUFW(buf,0)=0x190;
- }
+ }
}
return 0;
}
@@ -1113,7 +1114,7 @@ int atcommand_where(
snprintf(output, sizeof output, "%s %s %d %d",
character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
clif_displaymessage(fd, output);
-
+
return 0;
}
@@ -1135,7 +1136,7 @@ int atcommand_jumpto(
clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
return -1;
}
-
+
memset(character, '\0', sizeof character);
if (sscanf(message, "%99[^\n]", character) < 1)
return -1;
@@ -1677,8 +1678,10 @@ int atcommand_whozeny(
int i, j, count,c;
char match_text[100];
char player_name[24];
- int zeny[clif_countusers()];
- int counted[clif_countusers()];
+ //int zeny[clif_countusers()];
+ //int counted[clif_countusers()];
+ int *zeny = (int *)aCallocA(clif_countusers(), sizeof(int));
+ int *counted = (int *)aCallocA(clif_countusers(), sizeof(int));
nullpo_retr(-1, sd);
@@ -1732,6 +1735,9 @@ int atcommand_whozeny(
clif_displaymessage(fd, output);
}
+ free(zeny);
+ free(counted);
+
return 0;
}
@@ -1749,7 +1755,7 @@ int atcommand_happyhappyjoyjoy(
for (i = 0; i < fd_max; i++) {
if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
e=rand()%40;
- if(e==34)
+ if(e==34)
e = 0;
clif_emotion(&pl_sd->bl,e);
}
@@ -2177,7 +2183,7 @@ int atcommand_alive(
clif_resurrection(&sd->bl, 1);
clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
return 0;
- }
+ }
return -1;
}
@@ -2296,8 +2302,8 @@ int atcommand_item(
if (pet_id >= 0) {
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(sd->status.account_id, sd->status.char_id,
- pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv,
- pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
+ (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);
// if not pet egg
} else {
@@ -2447,7 +2453,7 @@ int atcommand_baselevelup(
clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
return -1;
} // End Addition
- if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
+ if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
level = battle_config.maximum_level - sd->status.base_level;
for (i = 1; i <= level; i++)
sd->status.status_point += (sd->status.base_level + i + 14) / 5;
@@ -2464,7 +2470,7 @@ int atcommand_baselevelup(
clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
return -1;
}
- if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow
+ if (level < -(int)battle_config.maximum_level || level < (1 - (int)sd->status.base_level)) // fix negativ overflow
level = 1 - sd->status.base_level;
if (sd->status.status_point > 0) {
for (i = 0; i > level; i--)
@@ -2491,7 +2497,8 @@ int atcommand_joblevelup(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- int up_level = 50, level;
+ unsigned int up_level = 50;
+ int level;
struct pc_base_job s_class;
nullpo_retr(-1, sd);
s_class = pc_calc_base_job(sd->status.class_);
@@ -2514,7 +2521,7 @@ int atcommand_joblevelup(
clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
return -1;
}
- if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow
+ if ((unsigned int)level > up_level || (unsigned int)level > (up_level - sd->status.job_level)) // fix positiv overflow
level = up_level - sd->status.job_level;
sd->status.job_level += level;
clif_updatestatus(sd, SP_JOBLEVEL);
@@ -2529,7 +2536,7 @@ int atcommand_joblevelup(
clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
return -1;
}
- if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow
+ if (level < -(int)up_level || level < (1 - (int)sd->status.job_level)) // fix negativ overflow
level = 1 - sd->status.job_level;
sd->status.job_level += level;
clif_updatestatus(sd, SP_JOBLEVEL);
@@ -3117,7 +3124,7 @@ int atcommand_monster(
printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
count = 0;
- range = sqrt(number) / 2;
+ range = (int)sqrt(number) / 2;
range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
j = 0;
@@ -3209,7 +3216,7 @@ int atcommand_spawn(
printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
count = 0;
- range = sqrt(number) / 2;
+ range = (int)sqrt(number) / 2;
range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
j = 0;
@@ -3848,9 +3855,9 @@ int atcommand_param(
}
new_value = (int)*status[index] + value;
- if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
+ if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
new_value = battle_config.max_parameter;
- else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
+ else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
new_value = 1;
if (new_value != (int)*status[index]) {
@@ -3893,9 +3900,9 @@ int atcommand_stat_all(
for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
new_value = (int)*status[index] + value;
- if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
+ if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
new_value = battle_config.max_parameter;
- else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
+ else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
new_value = 1;
if (new_value != (int)*status[index]) {
@@ -3993,8 +4000,8 @@ int atcommand_makeegg(
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(
sd->status.account_id, sd->status.char_id,
- pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv,
- pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
+ (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_table[180]); // The monter/egg name/id doesn't exist.
@@ -4149,14 +4156,14 @@ atcommand_recall(
char character[100];
char output[200];
struct map_session_data *pl_sd = NULL;
-
+
nullpo_retr(-1, sd);
if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
return -1;
}
-
+
memset(character, '\0', sizeof character);
if(sscanf(message, "%99[^\n]", character) < 1)
return -1;
@@ -4658,7 +4665,7 @@ int atcommand_character_baselevel(
clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
return 0;
} // End Addition
- if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
+ if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
level = battle_config.maximum_level - pl_sd->status.base_level;
for (i = 1; i <= level; i++)
pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
@@ -4675,7 +4682,7 @@ int atcommand_character_baselevel(
clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
return -1;
}
- if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow
+ if (level < -(int)battle_config.maximum_level || level < (1 - (int)pl_sd->status.base_level)) // fix negativ overflow
level = 1 - pl_sd->status.base_level;
if (pl_sd->status.status_point > 0) {
for (i = 0; i > level; i--)
@@ -4712,7 +4719,8 @@ int atcommand_character_joblevel(
{
struct map_session_data *pl_sd;
char character[100];
- int max_level = 50, level = 0;
+ unsigned int max_level = 50;
+ int level = 0;
//転生や養子の場合の元の職業を算出する
struct pc_base_job pl_s_class;
nullpo_retr(-1, sd);
@@ -5195,7 +5203,7 @@ int atcommand_idsearch(
{
char item_name[100];
char output[200];
- int i, match;
+ unsigned int i, match;
struct item_data *item;
nullpo_retr(-1, sd);
@@ -5652,7 +5660,7 @@ int atcommand_reloadscript(
nullpo_retr(-1, sd);
atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
-
+
rehash( fd, sd );
atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
@@ -6090,7 +6098,7 @@ int atcommand_enablenpc(const int fd, struct map_session_data* sd,
memset(NPCname, '\0', sizeof(NPCname));
if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
- clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon <NPC_name>).");
+ clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
return -1;
}
@@ -6961,7 +6969,7 @@ atcommand_npcmove(const int fd, struct map_session_data* sd,
int x = 0, y = 0;
struct npc_data *nd = 0;
nullpo_retr(-1, sd);
-
+
if (!message || !*message)
return -1;
@@ -7010,7 +7018,7 @@ atcommand_addwarp(const int fd, struct map_session_data* sd,
ret = npc_parse_warp(w1, "warp", w3, w4);
- sprintf(output, "New warp NPC => %s",w3);
+ sprintf(output, "New warp NPC => %s",w3);
clif_displaymessage(fd, output);
@@ -7063,7 +7071,7 @@ atcommand_dropall(const int fd, struct map_session_data* sd,
}
/*==========================================
* @chardropall by [MouseJstr]
- *
+ *
* Throw all the characters possessions on the ground. Normally
* done in response to them being disrespectful of a GM
*------------------------------------------
@@ -7139,7 +7147,7 @@ atcommand_charstoreall(const int fd, struct map_session_data* sd,
if (!message || !*message)
return -1;
- if((pl_sd=map_nick2sd((char *) message)) == NULL)
+ if((pl_sd=map_nick2sd((char *) message)) == NULL)
return -1;
if (storage_storageopen(pl_sd) == 1) {
@@ -7254,7 +7262,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd,
clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
return -1;
}
- if((pl_sd=map_nick2sd(target)) == NULL)
+ if((pl_sd=map_nick2sd(target)) == NULL)
return -1;
s_class = pc_calc_base_job(pl_sd->status.class_);
@@ -7265,8 +7273,8 @@ atcommand_skilltree(const int fd, struct map_session_data* sd,
tbl = job_name(c);
- sprintf(output, "Player is using %s %s skill tree (%d basic points)",
- s_class.upper ? "upper" : "lower",
+ sprintf(output, "Player is using %s %s skill tree (%d basic points)",
+ s_class.upper ? "upper" : "lower",
tbl, pc_checkskill(pl_sd, 1));
clif_displaymessage(fd, output);
@@ -7276,7 +7284,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd,
break;
}
}
-
+
if (skillidx == -1) {
sprintf(output, "I do not believe the player can use that skill");
clif_displaymessage(fd, output);
@@ -7285,19 +7293,19 @@ atcommand_skilltree(const int fd, struct map_session_data* sd,
ent = &skill_tree[s][c][skillidx];
- for(j=0;j<5;j++)
+ for(j=0;j<5;j++)
if( ent->need[j].id &&
- pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
+ pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
{
int idx = 0;
char *desc;
- while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
+ while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
idx++;
if (skill_names[idx].id == 0)
desc = "Unknown skill";
else
desc = skill_names[idx].desc;
- sprintf(output, "player requires level %d of skill %s",
+ sprintf(output, "player requires level %d of skill %s",
ent->need[j].lv, desc);
clif_displaymessage(fd, output);
meets = 0;
@@ -7307,7 +7315,7 @@ atcommand_skilltree(const int fd, struct map_session_data* sd,
sprintf(output, "I believe the player meets all the requirements for that skill");
clif_displaymessage(fd, output);
}
-
+
return 0;
}
@@ -7392,7 +7400,7 @@ atcommand_rings(const int fd, struct map_session_data* sd,
{
struct item item_tmp;
int flag;
-
+
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = 2634;
@@ -7456,7 +7464,7 @@ atcommand_grind(const int fd, struct map_session_data* sd,
clif_displaymessage(fd, "Usage: @grind <target>");
return -1;
}
- if((pl_sd=map_nick2sd(target)) == NULL)
+ if((pl_sd=map_nick2sd(target)) == NULL)
return -1;
for (skillnum = 1; skillnum < 500; skillnum++) {
@@ -7512,7 +7520,7 @@ atcommand_rain(
} else {
map[sd->bl.m].flag.rain=1;
clif_specialeffect(&sd->bl,effno,2);
- clif_displaymessage(fd, "It is made to rain.");
+ clif_displaymessage(fd, "It is made to rain.");
}
return 0;
}
@@ -7536,7 +7544,7 @@ atcommand_snow(
clif_specialeffect(&sd->bl,effno,2);
clif_displaymessage(fd, "It is made to snow.");
}
-
+
return 0;
}
@@ -7629,7 +7637,7 @@ atcommand_clearweather(
map[sd->bl.m].flag.leaves=0;
//clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
return 0;
-}
+}
/*===============================================================
* Sound Command - plays a sound for everyone! [Codemaster]
@@ -7720,7 +7728,7 @@ atcommand_cleanmap(
}
/*==========================================
- *
+ *
*------------------------------------------
*/
int
@@ -7735,14 +7743,14 @@ atcommand_summon(
int id = 0;
struct mob_data *md;
unsigned int tick=gettick();
-
+
nullpo_retr(-1, sd);
if (!message || !*message)
return -1;
if (sscanf(message, "%99s", name) < 1)
return -1;
-
+
if ((mob_id = atoi(name)) == 0)
mob_id = mobdb_searchname(name);
if(mob_id == 0)
@@ -7823,7 +7831,7 @@ atcommand_adjgmlvl(
return -1;
}
- if((pl_sd=map_nick2sd((char *) user)) == NULL)
+ if((pl_sd=map_nick2sd((char *) user)) == NULL)
return -1;
pc_set_gm_level(pl_sd->status.account_id, newlev);
@@ -7837,7 +7845,7 @@ atcommand_adjgmlvl(
*
* Open a trade window with a remote player
*
- * If I have to jump to a remote player one more time, I am
+ * If I have to jump to a remote player one more time, I am
* gonna scream!
*------------------------------------------
*/
@@ -7876,7 +7884,7 @@ atcommand_setbattleflag(
return -1;
}
- if (battle_set_value(flag, value) == 0)
+ if (battle_set_value(flag, value) == 0)
clif_displaymessage(fd, "unknown battle_config flag");
else
clif_displaymessage(fd, "battle_config set as requested");
@@ -7901,7 +7909,7 @@ int atcommand_unmute(
if((pl_sd=map_nick2sd((char *) message)) != NULL) {
if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
pl_sd->status.manner = 0; // have to set to 0 first [celest]
- skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
+ skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
clif_displaymessage(sd->fd,"Player unmuted");
}
else
@@ -7932,7 +7940,7 @@ atcommand_uptime(
seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
minutes = seconds/minute;
seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
-
+
snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
clif_displaymessage(fd,output);
@@ -8013,7 +8021,7 @@ atcommand_petid(const int fd, struct map_session_data* sd,
char temp0[100];
char temp1[100];
int cnt = 0, i = 0;
-
+
nullpo_retr(-1, sd);
if (!message || !*message)
@@ -8066,7 +8074,7 @@ atcommand_identify(
}
}
if (num > 0) {
- clif_item_identify_list(sd);
+ clif_item_identify_list(sd);
} else {
clif_displaymessage(fd,"There are no items to appraise.");
}
@@ -8074,7 +8082,7 @@ atcommand_identify(
}
/*==========================================
- * @gmotd (Global MOTD)
+ * @gmotd (Global MOTD)
* by davidsiaw :P
*------------------------------------------
*/
@@ -8113,7 +8121,7 @@ int atcommand_misceffect(
if (sscanf(message, "%d", &effect) < 1)
return -1;
clif_misceffect(&sd->bl,effect);
-
+
return 0;
}
@@ -8128,7 +8136,7 @@ int charid2sessionid(int charid)
if (pl_sd->status.char_id==charid) { session_id = i; break; }
}
}
-
+
return session_id;
}
@@ -8143,7 +8151,7 @@ int accountid2sessionid(int accountid)
if (pl_sd->status.account_id==accountid) { session_id = i; break; }
}
}
-
+
return session_id;
}
@@ -8696,9 +8704,9 @@ atcommand_charkillableid(
{
if((pl_sd=session[session_id]->session_data) == NULL)
return -1;
-
+
pl_sd->special_state.killable = !pl_sd->special_state.killable;
-
+
if(pl_sd->special_state.killable)
clif_displaymessage(fd, "The player is now killable");
else
@@ -8737,9 +8745,9 @@ atcommand_charkillableid2(
{
if((pl_sd=session[session_id]->session_data) == NULL)
return -1;
-
+
pl_sd->special_state.killable = !pl_sd->special_state.killable;
-
+
if(pl_sd->special_state.killable)
clif_displaymessage(fd, "The player is now killable");
else
@@ -8762,7 +8770,7 @@ atcommand_charkillableid2(
int atcommand_listmail(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
-{
+{
if(!battle_config.mail_system)
return 0;
@@ -8772,7 +8780,7 @@ int atcommand_listmail(
mail_check(sd,3);
else if(strlen(command)==9)
mail_check(sd,2);
- else
+ else
mail_check(sd,1);
return 0;
}
@@ -8823,7 +8831,7 @@ int atcommand_sendmail(
if(strlen(command)==17)
mail_send(sd,name,text,1);
- else
+ else
mail_send(sd,name,text,0);
return 0;
@@ -8842,7 +8850,7 @@ int atcommand_refreshonline(
nullpo_retr(-1, sd);
char_online_check();
-
+
return 0;
}
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index f639d8c33..754a741b7 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -112,9 +112,9 @@ enum AtCommandType {
AtCommand_CharSkReset,
AtCommand_CharStReset,
//by chbrules
- AtCommand_CharModel,
+ AtCommand_CharModel,
AtCommand_CharSKPoint,
- AtCommand_CharSTPoint,
+ AtCommand_CharSTPoint,
// AtCommand_CharZeny, //now #zeny
AtCommand_RecallAll,
AtCommand_ReloadItemDB,
@@ -198,7 +198,7 @@ enum AtCommandType {
AtCommand_CleanMap,
// SQL-only commands start
-#ifndef TXT_ONLY
+#ifndef TXT_ONLY
AtCommand_CheckMail, // [Valaris]
AtCommand_ListMail, // [Valaris]
AtCommand_ListNewMail, // [Valaris]
@@ -206,7 +206,7 @@ enum AtCommandType {
AtCommand_SendMail, // [Valaris]
AtCommand_DeleteMail, // [Valaris]
AtCommand_SendPriorityMail, // [Valaris]
-// AtCommand_Sound, // [Valaris]
+// AtCommand_Sound, // [Valaris]
AtCommand_RefreshOnline, // [Valaris]
// SQL-only commands end
#endif
@@ -272,7 +272,7 @@ int msg_config_read(const char *cfgName);
char *estr_lower(char *str);
-char * job_name(int class);
+char * job_name(int class_);
int e_mail_check(unsigned char *email);
#endif
diff --git a/src/map/battle.c b/src/map/battle.c
index 3cff73a18..ce691158c 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -179,6 +179,10 @@ int battle_get_max_hp(struct block_list *bl)
if(sc_data[SC_APPLEIDUN].timer!=-1)
max_hp += ((5+sc_data[SC_APPLEIDUN].val1*2+((sc_data[SC_APPLEIDUN].val2+1)>>1)
+sc_data[SC_APPLEIDUN].val3/10) * max_hp)/100;
+ if(sc_data[SC_GOSPEL].timer!=-1 &&
+ sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ sc_data[SC_GOSPEL].val3 == 4)
+ max_hp += max_hp * 25 / 100;
}
if(max_hp < 1) max_hp = 1;
return max_hp;
@@ -429,16 +433,24 @@ int battle_get_flee(struct block_list *bl)
else
flee=battle_get_agi(bl) + battle_get_lv(bl);
- if(sc_data) {
- if(sc_data[SC_WHISTLE].timer!=-1 && bl->type != BL_PC)
+ if(bl->type != BL_PC && sc_data){
+ if(sc_data[SC_WHISTLE].timer!=-1)
flee += flee*(sc_data[SC_WHISTLE].val1+sc_data[SC_WHISTLE].val2
+(sc_data[SC_WHISTLE].val3>>16))/100;
- if(sc_data[SC_BLIND].timer!=-1 && bl->type != BL_PC)
+ if(sc_data[SC_BLIND].timer!=-1)
flee -= flee*25/100;
- if(sc_data[SC_WINDWALK].timer!=-1 && bl->type != BL_PC) // ウィンドウォーク
+ if(sc_data[SC_WINDWALK].timer!=-1) // ウィンドウォーク
flee += flee*(sc_data[SC_WINDWALK].val2)/100;
- if(sc_data[SC_SPIDERWEB].timer!=-1 && bl->type != BL_PC) //スパイダーウェブ
+ if(sc_data[SC_SPIDERWEB].timer!=-1) //スパイダーウェブ
flee -= flee*50/100;
+ if(sc_data[SC_GOSPEL].timer!=-1) {
+ if (sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ sc_data[SC_GOSPEL].val3 == 13)
+ flee += flee*5/100;
+ else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY &&
+ sc_data[SC_GOSPEL].val3 == 7)
+ flee = 0;
+ }
}
if(flee < 1) flee = 1;
return flee;
@@ -460,16 +472,20 @@ int battle_get_hit(struct block_list *bl)
else
hit=battle_get_dex(bl) + battle_get_lv(bl);
- if(sc_data) {
- if(sc_data[SC_HUMMING].timer!=-1 && bl->type != BL_PC) //
+ if(bl->type != BL_PC && sc_data) {
+ if(sc_data[SC_HUMMING].timer!=-1) //
hit += hit*(sc_data[SC_HUMMING].val1*2+sc_data[SC_HUMMING].val2
+sc_data[SC_HUMMING].val3)/100;
- if(sc_data[SC_BLIND].timer!=-1 && bl->type != BL_PC) // 呪い
+ if(sc_data[SC_BLIND].timer!=-1) // 呪い
hit -= hit*25/100;
- if(sc_data[SC_TRUESIGHT].timer!=-1 && bl->type != BL_PC) // トゥルーサイト
+ if(sc_data[SC_TRUESIGHT].timer!=-1) // トゥルーサイト
hit += 3*(sc_data[SC_TRUESIGHT].val1);
- if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション
+ if(sc_data[SC_CONCENTRATION].timer!=-1) //コンセントレーション
hit += (hit*(10*(sc_data[SC_CONCENTRATION].val1)))/100;
+ if(sc_data[SC_GOSPEL].timer!=-1 &&
+ sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ sc_data[SC_GOSPEL].val3 == 14)
+ hit += hit*5/100;
}
if(hit < 1) hit = 1;
return hit;
@@ -560,7 +576,7 @@ int battle_get_baseatk(struct block_list *bl)
if(sc_data[SC_CURSE].timer!=-1 ) //呪われていたら
batk -= batk*25/100; //base_atkが25%減少
if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション
- batk += batk*(5*sc_data[SC_CONCENTRATION].val1)/100;
+ batk += batk*(5*sc_data[SC_CONCENTRATION].val1)/100;
}
if(batk < 1) batk = 1; //base_atkは最低でも1
return batk;
@@ -584,13 +600,22 @@ int battle_get_atk(struct block_list *bl)
else if(bl->type==BL_PET && (struct pet_data *)bl)
atk = mob_db[((struct pet_data*)bl)->class_].atk1;
- if(sc_data) {
- if(sc_data[SC_PROVOKE].timer!=-1 && bl->type != BL_PC)
+ if(bl->type != BL_PC && sc_data) {
+ if(sc_data[SC_PROVOKE].timer!=-1)
atk = atk*(100+2*sc_data[SC_PROVOKE].val1)/100;
- if(sc_data[SC_CURSE].timer!=-1 )
+ if(sc_data[SC_CURSE].timer!=-1)
atk -= atk*25/100;
- if(sc_data[SC_CONCENTRATION].timer!=-1 && bl->type != BL_PC) //コンセントレーション
+ if(sc_data[SC_CONCENTRATION].timer!=-1) //コンセントレーション
atk += atk*(5*sc_data[SC_CONCENTRATION].val1)/100;
+
+ if(sc_data[SC_GOSPEL].timer!=-1) {
+ if (sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ sc_data[SC_GOSPEL].val3 == 12)
+ atk += atk*8/100;
+ else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY &&
+ sc_data[SC_GOSPEL].val3 == 6)
+ atk = 0;
+ }
}
if(atk < 0) atk = 0;
return atk;
@@ -605,9 +630,6 @@ int battle_get_atk_(struct block_list *bl)
nullpo_retr(0, bl);
if(bl->type==BL_PC && (struct map_session_data *)bl){
int atk=((struct map_session_data*)bl)->watk_;
-
- if(((struct map_session_data *)bl)->sc_data[SC_CURSE].timer!=-1 )
- atk -= atk*25/100;
return atk;
}
else
@@ -780,10 +802,19 @@ int battle_get_def(struct block_list *bl)
def = def * (100 - sc_data[SC_SIGNUMCRUCIS].val2)/100;
//永遠の混沌時はDEF0になる
if(sc_data[SC_ETERNALCHAOS].timer!=-1)
- def = 0;
+ def = 0;
//コンセントレーション時は減算
if( sc_data[SC_CONCENTRATION].timer!=-1)
def = (def*(100 - 5*sc_data[SC_CONCENTRATION].val1))/100;
+
+ if(sc_data[SC_GOSPEL].timer!=-1) {
+ if (sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ sc_data[SC_GOSPEL].val3 == 11)
+ def += def*25/100;
+ else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY &&
+ sc_data[SC_GOSPEL].val3 == 5)
+ def = 0;
+ }
}
}
//詠唱中は詠唱時減算率に基づいて減算
@@ -859,6 +890,15 @@ int battle_get_def2(struct block_list *bl)
//コンセントレーション時は減算
if( sc_data[SC_CONCENTRATION].timer!=-1)
def2 = def2*(100 - 5*sc_data[SC_CONCENTRATION].val1)/100;
+
+ if(sc_data[SC_GOSPEL].timer!=-1) {
+ if (sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ sc_data[SC_GOSPEL].val3 == 11)
+ def2 += def2*25/100;
+ else if (sc_data[SC_GOSPEL].val4 == BCT_ENEMY &&
+ sc_data[SC_GOSPEL].val3 == 5)
+ def2 = 0;
+ }
}
if(def2 < 1) def2 = 1;
return def2;
@@ -942,6 +982,10 @@ int battle_get_speed(struct block_list *bl)
speed = speed*150/100;
if(sc_data[SC_SPEEDUP0].timer!=-1)
speed -= speed*25/100;
+ if(sc_data[SC_GOSPEL].timer!=-1 &&
+ sc_data[SC_GOSPEL].val4 == BCT_ENEMY &&
+ sc_data[SC_GOSPEL].val3 == 8)
+ speed = speed*125/100;
}
if(speed < 1) speed = 1;
return speed;
@@ -1002,6 +1046,10 @@ int battle_get_adelay(struct block_list *bl)
//ディフェンダー時は加算
if(sc_data[SC_DEFENDER].timer != -1)
adelay += (1100 - sc_data[SC_DEFENDER].val1*100);
+ if(sc_data[SC_GOSPEL].timer!=-1 &&
+ sc_data[SC_GOSPEL].val4 == BCT_ENEMY &&
+ sc_data[SC_GOSPEL].val3 == 8)
+ aspd_rate = aspd_rate*125/100;
}
if(aspd_rate != 100)
adelay = adelay*aspd_rate/100;
@@ -1315,7 +1363,7 @@ int battle_delay_damage_sub(int tid,unsigned int tick,int id,int data)
struct battle_delay_damage_ *dat=(struct battle_delay_damage_ *)data;
if( dat && map_id2bl(id)==dat->src && dat->target->prev!=NULL)
battle_damage(dat->src,dat->target,dat->damage,dat->flag);
- free(dat);
+ aFree(dat);
return 0;
}
int battle_delay_damage(unsigned int tick,struct block_list *src,struct block_list *target,int damage,int flag)
@@ -1487,11 +1535,11 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i
struct mob_data *md=NULL;
struct status_change *sc_data,*sc;
short *sc_count;
- int class;
+ int class_;
nullpo_retr(0, bl);
- class = battle_get_class(bl);
+ class_ = battle_get_class(bl);
if(bl->type==BL_MOB) md=(struct mob_data *)bl;
else sd=(struct map_session_data *)bl;
@@ -1612,7 +1660,10 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i
}
// リジェクトソード
if(sc_data[SC_REJECTSWORD].timer!=-1 && damage > 0 && flag&BF_WEAPON &&
- ((src->type==BL_PC && ((struct map_session_data *)src)->status.weapon == (1 || 2 || 3)) || src->type==BL_MOB )){
+ // Fixed the condition check [Aalye]
+ (src->type==BL_MOB || (src->type==BL_PC && (((struct map_session_data *)src)->status.weapon == 1 ||
+ ((struct map_session_data *)src)->status.weapon == 2 ||
+ ((struct map_session_data *)src)->status.weapon == 3)))){
if(rand()%100 < (15*sc_data[SC_REJECTSWORD].val1)){ //反射確率は15*Lv
damage = damage*50/100;
clif_damage(bl,src,gettick(),0,0,damage,0,0,0);
@@ -1630,22 +1681,22 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i
damage<<=1;
skill_status_change_end(bl, SC_SPIDERWEB, -1);
}
-
+
if(sc_data[SC_FOGWALL].timer != -1 && flag&BF_MAGIC)
if(rand()%100 < sc_data[SC_FOGWALL].val2)
damage = 0;
}
- if(class == 1288 || class == 1287 || class == 1286 || class == 1285) {
-// if(class == 1288) {
- if(class == 1288 && flag&BF_SKILL)
+ if(class_ == 1288 || class_ == 1287 || class_ == 1286 || class_ == 1285) {
+// if(class_ == 1288) {
+ if(class_ == 1288 && flag&BF_SKILL)
damage=0;
if(src->type == BL_PC) {
struct guild *g=guild_search(((struct map_session_data *)src)->status.guild_id);
struct guild_castle *gc=guild_mapname2gc(map[bl->m].name);
if(!((struct map_session_data *)src)->status.guild_id)
damage=0;
- if(gc && agit_flag==0 && class != 1288) // guardians cannot be damaged during non-woe [Valaris]
+ if(gc && agit_flag==0 && class_ != 1288) // guardians cannot be damaged during non-woe [Valaris]
damage=0; // end woe check [Valaris]
if(g == NULL)
damage=0;//ギルド未加入ならダメージ無し
@@ -2010,7 +2061,7 @@ static struct Damage battle_calc_pet_weapon_attack(
blewcount=0;
break;
case AS_GRIMTOOTH:
- damage = damage*(100+ 20*skill_lv)/100;
+ damage = damage*(100+ 20*skill_lv)/100;
break;
case AS_POISONREACT: // celest
s_ele = 0;
@@ -2208,7 +2259,7 @@ static struct Damage battle_calc_pet_weapon_attack(
hitrate -= 50;
if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中
t_sc_data[SC_STAN].timer!=-1 || // スタンは必中
- t_sc_data[SC_FREEZE].timer!=-1 ||
+ t_sc_data[SC_FREEZE].timer!=-1 ||
(t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中
hitrate = 1000000;
}
@@ -2221,7 +2272,7 @@ static struct Damage battle_calc_pet_weapon_attack(
dmg_lv = ATK_DEF;
}
-
+
if(t_sc_data) {
int cardfix=100;
if(t_sc_data[SC_DEFENDER].timer != -1 && flag&BF_LONG)
@@ -2507,7 +2558,7 @@ static struct Damage battle_calc_mob_weapon_attack(
flag=(flag&~BF_SKILLMASK)|BF_NORMAL;
break;
case AS_GRIMTOOTH:
- damage = damage*(100+ 20*skill_lv)/100;
+ damage = damage*(100+ 20*skill_lv)/100;
break;
case AS_POISONREACT: // celest
s_ele = 0;
@@ -2710,7 +2761,7 @@ static struct Damage battle_calc_mob_weapon_attack(
hitrate -= 50;
if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中
t_sc_data[SC_STAN].timer!=-1 || // スタンは必中
- t_sc_data[SC_FREEZE].timer!=-1 ||
+ t_sc_data[SC_FREEZE].timer!=-1 ||
(t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中
hitrate = 1000000;
}
@@ -2762,8 +2813,8 @@ static struct Damage battle_calc_mob_weapon_attack(
if(damage < 0) damage = 0;
// 属 性の適用
- if (!((battle_config.mob_ghostring_fix == 1) &&
- (battle_get_elem_type(target) == 8) &&
+ if (!((battle_config.mob_ghostring_fix == 1) &&
+ (battle_get_elem_type(target) == 8) &&
(target->type==BL_PC))) // [MouseJstr]
if(skill_num != 0 || s_ele != 0 || !battle_config.mob_attack_attr_none)
damage=battle_attr_fix(damage, s_ele, battle_get_element(target) );
@@ -3506,7 +3557,7 @@ static struct Damage battle_calc_pc_weapon_attack(
/* int mdef1=battle_get_mdef(target);
int mdef2=battle_get_mdef2(target);
int imdef_flag=0;
-
+
damage = ((damage * 5) + (skill_lv * battle_get_int(src) * 5) + rand()%500 + 500) /2;
damage2 = ((damage2 * 5) + (skill_lv * battle_get_int(src) * 5) + rand()%500 + 500) /2;
damage3 = damage;
@@ -3520,7 +3571,7 @@ static struct Damage battle_calc_pc_weapon_attack(
// calculate magic part of damage
damage3 = skill_lv * battle_get_int(src) * 5;
-
+
// ignores magic defense now [Celest]
/*if(sd->ignore_mdef_ele & (1<<t_ele) || sd->ignore_mdef_race & (1<<t_race))
imdef_flag = 1;
@@ -3540,7 +3591,7 @@ static struct Damage battle_calc_pc_weapon_attack(
damage3 = (damage3*(100-mdef1))/100 - mdef2;
}
}
-
+
if(damage3<1)
damage3=1;
@@ -3688,7 +3739,7 @@ static struct Damage battle_calc_pc_weapon_attack(
hitrate -= 50;
if (t_sc_data[SC_SLEEP].timer!=-1 || // 睡眠は必中
t_sc_data[SC_STAN].timer!=-1 || // スタンは必中
- t_sc_data[SC_FREEZE].timer!=-1 ||
+ t_sc_data[SC_FREEZE].timer!=-1 ||
(t_sc_data[SC_STONE].timer!=-1 && t_sc_data[SC_STONE].val2==0)) // 凍結は必中
hitrate = 1000000;
}
@@ -3876,7 +3927,7 @@ static struct Damage battle_calc_pc_weapon_attack(
damage = damage2;
damage2 = 0;
}
-
+
// 右手、左手修練の適用
if(sd->status.weapon > 16) {// 二刀流か?
int dmg = damage, dmg2 = damage2;
@@ -4258,7 +4309,7 @@ struct Damage battle_calc_magic_attack(
} else if (target->type == BL_PC) {
damage = ((struct map_session_data *)target)->status.sp * 2;
matk_flag = 0; // don't consider matk and matk2
- }
+ }
break;
}
}
@@ -4554,6 +4605,7 @@ struct Damage battle_calc_attack( int attack_type,
default:
if(battle_config.error_log)
printf("battle_calc_attack: unknwon attack type ! %d\n",attack_type);
+ memset(&d,0,sizeof(d));
break;
}
return d;
@@ -4596,7 +4648,7 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target,
}
if(battle_check_target(src,target,BCT_ENEMY) <= 0 &&
- !battle_check_range(src,target,0))
+ !battle_check_range(src,target,0))
return 0; // 攻撃対象外
race = battle_get_race(target);
@@ -4810,8 +4862,8 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target,
--t_sc_data[SC_POISONREACT].val2;
}
if (t_sc_data[SC_POISONREACT].val2<=0)
- skill_status_change_end(target,SC_POISONREACT,-1);
- }
+ skill_status_change_end(target,SC_POISONREACT,-1);
+ }
}
if (t_sc_data && t_sc_data[SC_BLADESTOP_WAIT].timer != -1 &&
!(battle_get_mode(src)&0x20)) { // ボスには無効
@@ -4911,7 +4963,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
return -1;
if(ss->prev == NULL)
return -1;
- if(inf2&0x80 &&
+ if(inf2&0x80 &&
(map[src->m].flag.pvp || pc_iskiller((struct map_session_data *)src, (struct map_session_data *)target)) && // [MouseJstr]
!(target->type == BL_PC && pc_isinvisible((struct map_session_data *)target)))
return 0;
@@ -5037,7 +5089,7 @@ int battle_check_range(struct block_list *src,struct block_list *bl,int range)
int dx,dy;
struct walkpath_data wpd;
int arange;
-
+
nullpo_retr(0, src);
nullpo_retr(0, bl);
@@ -5182,7 +5234,7 @@ static const struct {
{ "item_slots_override_grffile", &battle_config.item_slots_override_grffile}, // [Celest]
{ "indoors_override_grffile", &battle_config.indoors_override_grffile}, // [Celest]
{ "skill_sp_override_grffile", &battle_config.skill_sp_override_grffile}, // [Celest]
- { "cardillust_read_grffile", &battle_config.cardillust_read_grffile}, // [Celest]
+ { "cardillust_read_grffile", &battle_config.cardillust_read_grffile}, // [Celest]
{ "arrow_decrement", &battle_config.arrow_decrement },
{ "max_aspd", &battle_config.max_aspd },
{ "max_hp", &battle_config.max_hp },
@@ -5329,10 +5381,10 @@ static const struct {
{ "allow_atcommand_when_mute", &battle_config.allow_atcommand_when_mute}, // [celest]
{ "finding_ore_rate", &battle_config.finding_ore_rate}, // [celest]
{ "exp_calc_type", &battle_config.exp_calc_type}, // [celest]
- { "double_login_system", &battle_config.double_login_system}, // [celest]
+ { "min_skill_delay_limit", &battle_config.min_skill_delay_limit}, // [celest]
//SQL-only options start
-#ifndef TXT_ONLY
+#ifndef TXT_ONLY
{ "mail_system", &battle_config.mail_system }, // added by [Valaris]
//SQL-only options end
#endif
@@ -5442,7 +5494,7 @@ void battle_set_defaults() {
battle_config.item_slots_override_grffile=0; // [Celest]
battle_config.indoors_override_grffile=0; // [Celest]
battle_config.skill_sp_override_grffile=0; // [Celest]
- battle_config.cardillust_read_grffile=0; // [Celest]
+ battle_config.cardillust_read_grffile=0; // [Celest]
battle_config.arrow_decrement=1;
battle_config.max_aspd = 199;
battle_config.max_hp = 32500;
@@ -5590,10 +5642,10 @@ void battle_set_defaults() {
battle_config.castrate_dex_scale = 150;
battle_config.area_size = 14;
battle_config.exp_calc_type = 1;
- battle_config.double_login_system = 0;
+ battle_config.min_skill_delay_limit = 100;
//SQL-only options start
-#ifndef TXT_ONLY
+#ifndef TXT_ONLY
battle_config.mail_system = 0;
//SQL-only options end
#endif
@@ -5710,13 +5762,13 @@ void battle_validate_conf() {
// at least 1 client must be accepted
if ((battle_config.packet_ver_flag & 127) == 0) // added by [Yor]
battle_config.packet_ver_flag = 127; // accept all clients
-
+
if (battle_config.night_darkness_level > 10) // Celest
battle_config.night_darkness_level = 10;
if (battle_config.skill_range_leniency < 0) // Celest
battle_config.skill_range_leniency = 0;
-
+
if (battle_config.motd_type < 0)
battle_config.motd_type = 0;
else if (battle_config.motd_type > 1)
@@ -5728,22 +5780,21 @@ void battle_validate_conf() {
if (battle_config.vending_max_value > 10000000 || battle_config.vending_max_value<=0) // Lupus & Kobra_k88
battle_config.vending_max_value = 10000000;
- if (battle_config.double_login_system < 0)
- battle_config.double_login_system = 0;
-
+ if (battle_config.min_skill_delay_limit < 10)
+ battle_config.min_skill_delay_limit = 10; // minimum delay of 10ms
}
/*==========================================
* 設定ファイルを読み込む
*------------------------------------------
*/
-int battle_config_read(const char *cfgName)
+int battle_config_read(const char *cfgName)
{
char line[1024], w1[1024], w2[1024];
FILE *fp;
static int count = 0;
- if ((count++) == 0)
+ if ((count++) == 0)
battle_set_defaults();
fp = fopen(cfgName,"r");
diff --git a/src/map/battle.h b/src/map/battle.h
index 29b537080..d88ea54c1 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -115,6 +115,7 @@ enum {
BCT_NOPARTY =0x50000,
BCT_ALL =0x20000,
BCT_NOONE =0x60000,
+ BCT_SELF =0x60000,
};
int battle_check_undead(int race,int element);
@@ -291,7 +292,7 @@ extern struct Battle_Config {
int prevent_logout; // Added by RoVeRT
int alchemist_summon_reward; // [Valaris]
- int maximum_level;
+ unsigned int maximum_level;
int drops_by_luk;
int monsters_ignore_gm;
int equipment_breaking;
@@ -348,7 +349,7 @@ extern struct Battle_Config {
int zeny_from_mobs; // [Valaris]
int mobs_level_up; // [Valaris]
- int pk_min_level; // [celest]
+ unsigned int pk_min_level; // [celest]
int skill_steal_type; // [celest]
int skill_steal_rate; // [celest]
int night_darkness_level; // [celest]
@@ -357,7 +358,7 @@ extern struct Battle_Config {
int allow_atcommand_when_mute; // [celest]
int finding_ore_rate; // orn
int exp_calc_type;
- int double_login_system;
+ int min_skill_delay_limit;
#ifndef TXT_ONLY /* SQL-only options */
int mail_system; // [Valaris]
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 1ced08777..5d65c8f01 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -1063,8 +1063,8 @@ int charcommand_item(
if (pet_id >= 0) {
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(sd->status.account_id, sd->status.char_id,
- pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv,
- pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
+ (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);
// if not pet egg
} else {
diff --git a/src/map/chat.c b/src/map/chat.c
index c7ec13a5f..cfd2660e0 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -49,7 +49,7 @@ int chat_createchat(struct map_session_data *sd,int limit,int pub,char* pass,cha
cd->bl.id = map_addobject(&cd->bl);
if(cd->bl.id==0){
clif_createchat(sd,1);
- free(cd);
+ aFree(cd);
return 0;
}
pc_setchatid(sd,cd->bl.id);
@@ -82,7 +82,7 @@ int chat_joinchat(struct map_session_data *sd,int chatid,char* pass)
clif_joinchatfail(sd,1);
return 0;
}
- if(chatid == sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe
+ if(chatid == (int)sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe
{
clif_joinchatfail(sd,1);
return 0;
@@ -290,7 +290,7 @@ int chat_createnpcchat(struct npc_data *nd,int limit,int pub,int trigger,char* t
cd->bl.id = map_addobject(&cd->bl);
if(cd->bl.id==0){
- free(cd);
+ aFree(cd);
return 0;
}
nd->chat_id=cd->bl.id;
diff --git a/src/map/clif.c b/src/map/clif.c
index b72192690..38aa8ab26 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -53,11 +53,15 @@
#define STATE_BLIND 0x10
-int packet_db_ver = -1; // the packet version used by packet_db
-int packet_db_connect_cmd = 0xF5; // the default packet used for connecting to the server
-
+struct Clif_Config clif_config;
struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
+#define USE_PACKET_DB(sd) \
+ clif_config.enable_packet_db && sd->packet_ver == clif_config.packet_db_ver
+
+#define IS_PACKET_DB_VER(cmd) \
+ cmd == clif_config.connect_cmd
+
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,
@@ -66,7 +70,7 @@ static const int packet_len_table[MAX_PACKET_DB] = {
//#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,
+ 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エフェクト用
@@ -155,7 +159,7 @@ char talkie_mes[80];
* map鯖のip設定
*------------------------------------------
*/
-void clif_setip(char *ip)
+void clif_setip(char *ip)
{
memcpy(map_ip_str, ip, 16);
map_ip = inet_addr(map_ip_str);
@@ -165,7 +169,7 @@ void clif_setip(char *ip)
* map鯖のport設定
*------------------------------------------
*/
-void clif_setport(int port)
+void clif_setport(int port)
{
map_port = port;
}
@@ -174,7 +178,7 @@ void clif_setport(int port)
* map鯖のip読み出し
*------------------------------------------
*/
-in_addr_t clif_getip(void)
+in_addr_t clif_getip(void)
{
return map_ip;
}
@@ -183,7 +187,7 @@ in_addr_t clif_getip(void)
* map鯖のport読み出し
*------------------------------------------
*/
-int clif_getport(void)
+int clif_getport(void)
{
return map_port;
}
@@ -192,7 +196,7 @@ int clif_getport(void)
*
*------------------------------------------
*/
-int clif_countusers(void)
+int clif_countusers(void)
{
int users = 0, i;
struct map_session_data *sd;
@@ -209,7 +213,7 @@ int clif_countusers(void)
* 全てのclientに対してfunc()実行
*------------------------------------------
*/
-int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...)
+int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...)
{
int i;
va_list ap;
@@ -228,7 +232,7 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...)
* clif_sendでAREA*指定時用
*------------------------------------------
*/
-int clif_send_sub(struct block_list *bl, va_list ap)
+int clif_send_sub(struct block_list *bl, va_list ap)
{
unsigned char *buf;
int len;
@@ -902,17 +906,17 @@ static int clif_set007b(struct map_session_data *sd,unsigned char *buf) {
* クラスチェンジ typeはMobの場合は1で他は0?
*------------------------------------------
*/
-int clif_class_change(struct block_list *bl,int class,int type)
+int clif_class_change(struct block_list *bl,int class_,int type)
{
char buf[16];
nullpo_retr(0, bl);
- if(class >= MAX_PC_CLASS) {
+ if(class_ >= MAX_PC_CLASS) {
WBUFW(buf,0)=0x1b0;
WBUFL(buf,2)=bl->id;
WBUFB(buf,6)=type;
- WBUFL(buf,7)=class;
+ WBUFL(buf,7)=class_;
clif_send(buf,packet_len_table[0x1b0],bl,AREA);
}
@@ -922,9 +926,9 @@ int clif_class_change(struct block_list *bl,int class,int type)
*
*------------------------------------------
*/
-int clif_mob_class_change(struct mob_data *md, int class) {
+int clif_mob_class_change(struct mob_data *md, int class_) {
char buf[16];
- int view = mob_get_viewclass(class);
+ int view = mob_get_viewclass(class_);
nullpo_retr(0, md);
@@ -961,7 +965,7 @@ int clif_mob_equip(struct mob_data *md, int nameid) {
* MOB表示1
*------------------------------------------
*/
-static int clif_mob0078(struct mob_data *md, unsigned char *buf)
+static int clif_mob0078(struct mob_data *md, unsigned char *buf)
{
int level;
@@ -3730,7 +3734,7 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md)
int len;
nullpo_retv(sd);
nullpo_retv(md);
-
+
if (session[sd->fd] == NULL)
return;
@@ -3749,7 +3753,7 @@ void clif_getareachar_mob(struct map_session_data* sd,struct mob_data* md)
clif_specialeffect(&md->bl,423,0);
else if(md->size==1)
clif_specialeffect(&md->bl,421,0);
-
+
}
@@ -4049,8 +4053,8 @@ int clif_moboutsight(struct block_list *bl,va_list ap)
nullpo_retr(0, ap);
nullpo_retr(0, md=va_arg(ap,struct mob_data*));
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
+ if(bl->type==BL_PC
+ && ((sd = (struct map_session_data*) bl) != NULL)
&& session[sd->fd] != NULL) {
clif_clearchar_id(md->bl.id,0,sd->fd);
}
@@ -4071,8 +4075,8 @@ int clif_mobinsight(struct block_list *bl,va_list ap)
nullpo_retr(0, ap);
md=va_arg(ap,struct mob_data*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
+ if(bl->type==BL_PC
+ && ((sd = (struct map_session_data*) bl) != NULL)
&& session[sd->fd] != NULL) {
clif_getareachar_mob(sd,md);
}
@@ -4093,8 +4097,8 @@ int clif_petoutsight(struct block_list *bl,va_list ap)
nullpo_retr(0, ap);
nullpo_retr(0, pd=va_arg(ap,struct pet_data*));
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
+ if(bl->type==BL_PC
+ && ((sd = (struct map_session_data*) bl) != NULL)
&& session[sd->fd] != NULL) {
clif_clearchar_id(pd->bl.id,0,sd->fd);
}
@@ -4112,8 +4116,8 @@ int clif_npcoutsight(struct block_list *bl,va_list ap)
nullpo_retr(0, ap);
nullpo_retr(0, nd=va_arg(ap,struct npc_data*));
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
+ if(bl->type==BL_PC
+ && ((sd = (struct map_session_data*) bl) != NULL)
&& session[sd->fd] != NULL) {
clif_clearchar_id(nd->bl.id,0,sd->fd);
}
@@ -4134,8 +4138,8 @@ int clif_petinsight(struct block_list *bl,va_list ap)
nullpo_retr(0, ap);
pd=va_arg(ap,struct pet_data*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
+ if(bl->type==BL_PC
+ && ((sd = (struct map_session_data*) bl) != NULL)
&& session[sd->fd] != NULL) {
clif_getareachar_pet(sd,pd);
}
@@ -4153,8 +4157,8 @@ int clif_npcinsight(struct block_list *bl,va_list ap)
nullpo_retr(0, ap);
nd=va_arg(ap,struct npc_data*);
- if(bl->type==BL_PC
- && ((sd = (struct map_session_data*) bl) != NULL)
+ if(bl->type==BL_PC
+ && ((sd = (struct map_session_data*) bl) != NULL)
&& session[sd->fd] != NULL) {
clif_getareachar_npc(sd,nd);
}
@@ -4701,7 +4705,7 @@ int clif_status_change(struct block_list *bl,int type,int flag)
* Send message (modified by [Yor])
*------------------------------------------
*/
-int clif_displaymessage(const int fd, char* mes)
+int clif_displaymessage(const int fd, char* mes)
{
//Console [Wizputer]
if (fd == 0)
@@ -4724,13 +4728,13 @@ int clif_displaymessage(const int fd, char* mes)
* 天の声を送信する
*------------------------------------------
*/
-int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
+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*)aCalloc(len + lp, sizeof(unsigned char));
+ buf = (unsigned char*)aCallocA(len + lp, sizeof(unsigned char));
WBUFW(buf,0) = 0x9a;
WBUFW(buf,2) = len + lp;
@@ -4743,7 +4747,7 @@ int clif_GMmessage(struct block_list *bl, char* mes, int len, int flag)
(flag == 3) ? SELF :
ALL_CLIENT);
- if(buf) free(buf);
+ if(buf) aFree(buf);
return 0;
}
@@ -4893,7 +4897,7 @@ int clif_wis_message(int fd, char *nick, char *mes, int mes_len) // R 0097 <len>
*------------------------------------------
*/
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
-{
+{
WFIFOW(fd,0) = 0x98;
WFIFOW(fd,2) = flag;
WFIFOSET(fd,packet_len_table[0x98]);
@@ -5794,7 +5798,7 @@ int clif_hpmeter(struct map_session_data *sd)
unsigned char buf[16];
unsigned char buf2[16];
int i;
-
+
nullpo_retr(0, sd);
WBUFW(buf,0)=0x107;
@@ -5809,7 +5813,7 @@ int clif_hpmeter(struct map_session_data *sd)
WFIFOSET(i,packet_len_table[0x107]);
}
}
-
+
WBUFW(buf2,0)=0x106;
WBUFL(buf2,2)=sd->status.account_id;
WBUFW(buf2,6)=(sd->status.hp > 0x7fff)? 0x7fff:sd->status.hp;
@@ -5821,7 +5825,7 @@ int clif_hpmeter(struct map_session_data *sd)
WFIFOSET(i,packet_len_table[0x106]);
}
}
-
+
return 0;
}
/*==================================================
@@ -5834,7 +5838,7 @@ int clif_update_mobhp(struct mob_data *md)
char mobhp[50];
nullpo_retr(0, md);
-
+
WBUFW(buf,0) = 0x95;
WBUFL(buf,2) = md->bl.id;
@@ -5845,7 +5849,7 @@ int clif_update_mobhp(struct mob_data *md)
WBUFL(buf,54) = 0;
WBUFL(buf,78) = 0;
clif_send(buf,packet_len_table[0x195],&md->bl,AREA);
-
+
return 0;
}
/*==========================================
@@ -6206,7 +6210,7 @@ int clif_combo_delay(struct block_list *bl,int wait)
*------------------------------------------
*/
int clif_bladestop(struct block_list *src,struct block_list *dst,
- int bool)
+ int _bool)
{
unsigned char buf[32];
@@ -6216,7 +6220,7 @@ int clif_bladestop(struct block_list *src,struct block_list *dst,
WBUFW(buf,0)=0x1d1;
WBUFL(buf,2)=src->id;
WBUFL(buf,6)=dst->id;
- WBUFL(buf,10)=bool;
+ WBUFL(buf,10)=_bool;
clif_send(buf,packet_len_table[0x1d1],src,AREA);
@@ -6837,7 +6841,7 @@ 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*)aCalloc(len + 4, sizeof(unsigned char));
+ buf = (unsigned char*)aCallocA(len + 4, sizeof(unsigned char));
WBUFW(buf, 0) = 0x17f;
WBUFW(buf, 2) = len + 4;
@@ -6846,7 +6850,7 @@ int clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
if ((sd = guild_getavailablesd(g)) != NULL)
clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD);
- if(buf) free(buf);
+ if(buf) aFree(buf);
return 0;
}
@@ -7043,7 +7047,7 @@ void clif_callpartner(struct map_session_data *sd)
* Adopt baby [Celest]
*------------------------------------------
*/
-void clif_adopt_process(struct map_session_data *sd)
+void clif_adopt_process(struct map_session_data *sd)
{
int fd;
nullpo_retv(sd);
@@ -7054,7 +7058,7 @@ void clif_adopt_process(struct map_session_data *sd)
}
/*==========================================
- *
+ *
*------------------------------------------
*/
void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
@@ -7067,7 +7071,7 @@ void clif_parse_ReqAdopt(int fd, struct map_session_data *sd) {
* 座る
*------------------------------------------
*/
-void clif_sitting(struct map_session_data *sd)
+void clif_sitting(struct map_session_data *sd)
{
unsigned char buf[64];
@@ -7083,13 +7087,13 @@ void clif_sitting(struct map_session_data *sd)
*
*------------------------------------------
*/
-int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
+int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
{
unsigned char *buf;
nullpo_retr(0, sd);
- buf = (unsigned char*)aCalloc(len + 8, sizeof(unsigned char));
+ buf = (unsigned char*)aCallocA(len + 8, sizeof(unsigned char));
WBUFW(buf, 0) = 0x17f;
WBUFW(buf, 2) = len + 8;
@@ -7097,7 +7101,7 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
clif_send(buf, WBUFW(buf,2), &sd->bl, SELF);
- if(buf) free(buf);
+ if(buf) aFree(buf);
return 0;
}
@@ -7107,7 +7111,7 @@ int clif_disp_onlyself(struct map_session_data *sd, char *mes, int len)
*------------------------------------------
*/
-int clif_GM_kickack(struct map_session_data *sd, int id)
+int clif_GM_kickack(struct map_session_data *sd, int id)
{
int fd;
@@ -7142,7 +7146,7 @@ int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int ty
*------------------------------------------
*/
-int clif_timedout(struct map_session_data *sd)
+int clif_timedout(struct map_session_data *sd)
{
nullpo_retr(0, sd);
@@ -7247,8 +7251,8 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) {
struct map_session_data *pl_sd;
int i;
for(i = 0; i < fd_max; i++) {
- if (session[i] && (pl_sd = session[i]->session_data) != NULL &&
- pl_sd->state.auth &&
+ if (session[i] && (pl_sd = session[i]->session_data) != NULL &&
+ pl_sd->state.auth &&
(pc_isGM((struct map_session_data *)&bl) > pc_isGM((struct map_session_data *)&pl_sd->bl)))
clif_specialeffect(&pl_sd->bl, type, 1);
}
@@ -7278,10 +7282,10 @@ int clif_specialeffect(struct block_list *bl, int type, int flag) {
*
*------------------------------------------
*/
-void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
+void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
{
struct map_session_data *old_sd;
- int account_id; // account_id in the packet 0x72 or 0x7E
+ int cmd, account_id; // account_id in the packet 0x72 or 0x7E
if (sd) {
if (battle_config.error_log)
@@ -7289,12 +7293,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
return;
}
+ cmd = RFIFOW(fd,0);
+
// packet DB
- if (RFIFOW(fd,0) == packet_db_connect_cmd) {
+ if (IS_PACKET_DB_VER(cmd)) {
//printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd));
- account_id = RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[0]);
+ account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[0]);
// 0x72
- } else if (RFIFOW(fd,0) == 0x72) {
+ } else if (cmd == 0x72) {
//printf("Received bytes %d with packet 0x72.\n", RFIFOREST(fd));
if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) // 00 = Female, 01 = Male
account_id = RFIFOL(fd,12);
@@ -7303,14 +7309,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
else // old packet version
account_id = RFIFOL(fd,2);
// 0x7E
- } else if (RFIFOW(fd,0) == 0x7E) {
+ } else if (cmd == 0x7E) {
//printf("Received bytes %d with packet 0x7E.\n", RFIFOREST(fd));
if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) // 00 = Female, 01 = Male
account_id = RFIFOL(fd,9);
else
account_id = RFIFOL(fd,12);
// 0xF5
- } else if (RFIFOW(fd,0) == 0xF5) {
+ } else if (cmd == 0xF5) {
//printf("Received bytes %d with packet 0xF5.\n", RFIFOREST(fd));
if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) // 00 = Female, 01 = Male
account_id = RFIFOL(fd,7);
@@ -7319,9 +7325,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
account_id = RFIFOL(fd,10);
else { // 29 28 28
- if (RFIFOW(fd,1) == 0) // testing ^^;
+ /*if (RFIFOW(fd,1) == 0) // testing ^^;
account_id = RFIFOL(fd,3);
- else
+ else*/
account_id = RFIFOL(fd,5);
}
// 0x9B
@@ -7339,14 +7345,14 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
sd = session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
sd->fd = fd;
+ if (IS_PACKET_DB_VER(cmd)) {
+ sd->packet_ver = clif_config.packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
+ pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[1]),
+ RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[2]),
+ RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[3]),
+ RFIFOL(fd,packet_db[clif_config.packet_db_ver][clif_config.connect_cmd].pos[4]), fd);
// 0x72
- if (RFIFOW(fd,0) == packet_db_connect_cmd) {
- sd->packet_ver = packet_db_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
- pc_setnewpc(sd, account_id, RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[1]),
- RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[2]),
- RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[3]),
- RFIFOL(fd,packet_db[packet_db_ver][packet_db_connect_cmd].pos[4]), fd);
- } else if (RFIFOW(fd,0) == 0x72) {
+ } else if (cmd == 0x72) {
if (RFIFOREST(fd) >= 39 && (RFIFOB(fd,38) == 0 || RFIFOB(fd,38) == 1)) { // 00 = Female, 01 = Male
sd->packet_ver = 7; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
pc_setnewpc(sd, account_id, RFIFOL(fd,22), RFIFOL(fd,30), RFIFOL(fd,34), RFIFOB(fd,38), fd);
@@ -7358,7 +7364,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
pc_setnewpc(sd, account_id, RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), fd);
}
// 0x7E
- } else if (RFIFOW(fd,0) == 0x7E) {
+ } else if (cmd == 0x7E) {
if (RFIFOREST(fd) >= 37 && (RFIFOB(fd,36) == 0 || RFIFOB(fd,36) == 1)) { // 00 = Female, 01 = Male
sd->packet_ver = 9; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
pc_setnewpc(sd, account_id, RFIFOL(fd,21), RFIFOL(fd,28), RFIFOL(fd,32), RFIFOB(fd,36), fd);
@@ -7367,7 +7373,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
pc_setnewpc(sd, account_id, RFIFOL(fd,18), RFIFOL(fd,24), RFIFOL(fd,28), RFIFOB(fd,32), fd);
}
// 0xF5
- } else if (RFIFOW(fd,0) == 0xF5) {
+ } else if (cmd == 0xF5) {
if (RFIFOREST(fd) >= 34 && (RFIFOB(fd,33) == 0 || RFIFOB(fd,33) == 1)) { // 00 = Female, 01 = Male
sd->packet_ver = 10; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
pc_setnewpc(sd, account_id, RFIFOL(fd,15), RFIFOL(fd,25), RFIFOL(fd,29), RFIFOB(fd,33), fd);
@@ -7522,7 +7528,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
(sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 ))
// オートバーサーク発動
skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0);
-
+
// if(time(&timer) < ((weddingtime=pc_readglobalreg(sd,"PC_WEDDING_TIME")) + 3600))
// skill_status_change_start(&sd->bl,SC_WEDDING,0,weddingtime,0,0,36000,0);
@@ -7568,9 +7574,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
void clif_parse_TickSend(int fd, struct map_session_data *sd) {
nullpo_retv(sd);
- if (sd->packet_ver == packet_db_ver) {
- sd->client_tick=RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
- } else {
+ if (USE_PACKET_DB(sd)) {
+ sd->client_tick=RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ } else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
sd->client_tick = RFIFOL(fd,6);
@@ -7597,7 +7603,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) {
case 16:
sd->client_tick = RFIFOL(fd,5);
break;
-
+
default: // old version by default (and version 6 + 7)
sd->client_tick = RFIFOL(fd,2);
break;
@@ -7614,7 +7620,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) {
*/
void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
int x, y;
-
+
nullpo_retv(sd);
if (pc_isdead(sd)) {
@@ -7642,6 +7648,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
sd->sc_data[SC_BLADESTOP].timer !=-1 || //白刃取り
sd->sc_data[SC_SPIDERWEB].timer !=-1 || //スパイダーウェッブ
(sd->sc_data[SC_DANCING].timer !=-1 && sd->sc_data[SC_DANCING].val4) || //合奏スキル演奏中は動けない
+ (sd->sc_data[SC_GOSPEL].timer !=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_SELF) || // cannot move while gospel is in effect
sd->sc_data[SC_CONFUSION].timer !=-1)
return;
if ((sd->status.option & 2) && pc_checkskill(sd, RG_TUNNELDRIVE) <= 0)
@@ -7652,10 +7659,12 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
pc_stopattack(sd);
- if (sd->packet_ver == packet_db_ver) {
+ if (USE_PACKET_DB(sd)) {
int cmd = RFIFOW(fd,0);
- x = RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0]) * 4 + (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0] + 1) >> 6);
- y = ((RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) + (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[0] + 2) >> 4);
+ x = RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]) * 4 +
+ (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 1) >> 6);
+ y = ((RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0]+1) & 0x3f) << 4) +
+ (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[0] + 2) >> 4);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 6:
@@ -7748,8 +7757,8 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
struct block_list *bl;
int account_id;
- if (sd->packet_ver == packet_db_ver) {
- account_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ if (USE_PACKET_DB(sd)) {
+ account_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
@@ -7785,7 +7794,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
bl = map_id2bl(account_id);
if (bl == NULL)
return;
-
+
WFIFOW(fd,0) = 0x95;
WFIFOL(fd,2) = account_id;
@@ -7881,13 +7890,13 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <
nullpo_retv(sd);
if ((is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None) ||
(is_charcommand(fd, sd, RFIFOP(fd,4),0)!= CharCommand_None) ||
- (sd->sc_data &&
+ (sd->sc_data &&
(sd->sc_data[SC_BERSERK].timer != -1 || //バーサーク時は会話も不可
sd->sc_data[SC_NOCHAT].timer != -1 ))) //チャット禁止
return;
- message = (char*)aCalloc(RFIFOW(fd,2) + 128, sizeof(char));
- buf = (char*)aCalloc(RFIFOW(fd,2) + 4, sizeof(char));
+ message = (char*)aCallocA(RFIFOW(fd,2) + 128, sizeof(char));
+ buf = (char*)aCallocA(RFIFOW(fd,2) + 4, sizeof(char));
//printf("clif_parse_GlobalMessage: message: '%s'.\n", RFIFOP(fd,4));
if (strncmp(RFIFOP(fd,4), sd->status.name, strlen(sd->status.name)) != 0) {
@@ -7912,9 +7921,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <
if (battle_config.ban_spoof_namer > 0) {
chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_spoof_namer, 0); // type: 2 - ban (year, month, day, hour, minute, second)
clif_setwaitclose(fd); // forced to disconnect because of the hack
-
- if(message) free(message);
- if(buf) free(buf);
+
+ if(message) aFree(message);
+ if(buf) aFree(buf);
return;
}
@@ -7958,8 +7967,8 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <
}
}
- if(message) free(message);
- if(buf) free(buf);
+ if(message) aFree(message);
+ if(buf) aFree(buf);
return;
}
@@ -8038,9 +8047,9 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd) {
nullpo_retv(sd);
- if (sd->packet_ver == packet_db_ver) {
- headdir = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
- dir = RFIFOB(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ if (USE_PACKET_DB(sd)) {
+ headdir = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ dir = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 7:
@@ -8152,9 +8161,9 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) {
pc_stop_walking(sd, 0);
pc_stopattack(sd);
- if (sd->packet_ver == packet_db_ver) {
- target_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
- action_type = RFIFOB(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ if (USE_PACKET_DB(sd)) {
+ target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ action_type = RFIFOB(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
@@ -8283,20 +8292,20 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni
//printf("clif_parse_Wis: message: '%s'.\n", RFIFOP(fd,28));
- gm_command = (char*)aCalloc(strlen(RFIFOP(fd,28)) + 28, sizeof(char)); // 24+3+(RFIFOW(fd,2)-28)+1 or 24+3+(strlen(RFIFOP(fd,28))+1 (size can be wrong with hacker)
+ gm_command = (char*)aCallocA(strlen(RFIFOP(fd,28)) + 28, sizeof(char)); // 24+3+(RFIFOW(fd,2)-28)+1 or 24+3+(strlen(RFIFOP(fd,28))+1 (size can be wrong with hacker)
sprintf(gm_command, "%s : %s", sd->status.name, RFIFOP(fd,28));
if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) ||
(is_atcommand(fd, sd, gm_command, 0) != AtCommand_None) ||
- (sd && sd->sc_data &&
+ (sd && sd->sc_data &&
(sd->sc_data[SC_BERSERK].timer!=-1 || //バーサーク時は会話も不可
sd->sc_data[SC_NOCHAT].timer != -1))) //チャット禁止
{
- if(gm_command) free(gm_command);
+ if(gm_command) aFree(gm_command);
return;
}
- if(gm_command) free(gm_command);
+ if(gm_command) aFree(gm_command);
// searching destination character
dstsd = map_nick2sd(RFIFOP(fd,4));
@@ -8360,8 +8369,8 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) {
nullpo_retv(sd);
- if (sd->packet_ver == packet_db_ver) {
- map_object_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ if (USE_PACKET_DB(sd)) {
+ map_object_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 7:
@@ -8436,9 +8445,9 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) {
sd->sc_data[SC_BERSERK].timer != -1)) ) //バーサーク
return;
- if (sd->packet_ver == packet_db_ver) {
- item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ if (USE_PACKET_DB(sd)) {
+ item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
+ item_amount = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
@@ -8505,8 +8514,8 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) {
if (sd->invincible_timer != -1)
pc_delinvincibletimer(sd);
- if (sd->packet_ver == packet_db_ver) {
- pc_useitem(sd,RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2);
+ if (USE_PACKET_DB(sd)) {
+ pc_useitem(sd,RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 6:
@@ -8888,10 +8897,10 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
if (sd->chatID || sd->npc_id != 0 || sd->vender_id != 0)
return;
- if (sd->packet_ver == packet_db_ver) {
- skilllv = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
- skillnum = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
- target_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[2]);
+ if (USE_PACKET_DB(sd)) {
+ skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ target_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 6:
@@ -8972,7 +8981,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
return;
}
- if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
+ if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 ||
sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22)
return;
@@ -9021,11 +9030,11 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
if(sd->chatID) return;
skillmoreinfo = -1;
- if (sd->packet_ver == packet_db_ver) {
- skilllv = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
- skillnum = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
- x = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[2]);
- y = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[3]);
+ if (USE_PACKET_DB(sd)) {
+ skilllv = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ skillnum = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ x = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[2]);
+ y = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[3]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 6:
@@ -9146,7 +9155,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) {
return;
}
- if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
+ if ((sd->sc_data[SC_TRICKDEAD].timer != -1 && skillnum != NV_TRICKDEAD) ||
sd->sc_data[SC_BERSERK].timer != -1 || sd->sc_data[SC_NOCHAT].timer != -1 ||
sd->sc_data[SC_WEDDING].timer != -1 || sd->view_class == 22)
return;
@@ -9176,7 +9185,7 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
if(sd->chatID) return;
- if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data &&
+ if (sd->npc_id!=0 || sd->vender_id != 0 || (sd->sc_data &&
(sd->sc_data[SC_TRICKDEAD].timer != -1 ||
sd->sc_data[SC_BERSERK].timer!=-1 ||
sd->sc_data[SC_NOCHAT].timer!=-1 ||
@@ -9324,8 +9333,8 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd)
void clif_parse_SolveCharName(int fd, struct map_session_data *sd) {
int char_id;
- if (sd->packet_ver == packet_db_ver) {
- char_id = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0]);
+ if (USE_PACKET_DB(sd)) {
+ char_id = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
@@ -9412,9 +9421,9 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) {
if (sd->npc_id != 0 || sd->vender_id != 0)
return;
- if (sd->packet_ver == packet_db_ver) {
- item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
- item_amount = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ if (USE_PACKET_DB(sd)) {
+ item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-2;
+ item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
@@ -9478,9 +9487,9 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) {
nullpo_retv(sd);
- if (sd->packet_ver == packet_db_ver) {
- item_index = RFIFOW(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[0])-1;
- item_amount = RFIFOL(fd,packet_db[packet_db_ver][RFIFOW(fd,0)].pos[1]);
+ if (USE_PACKET_DB(sd)) {
+ item_index = RFIFOW(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[0])-1;
+ item_amount = RFIFOL(fd,packet_db[clif_config.packet_db_ver][RFIFOW(fd,0)].pos[1]);
} else {
switch (sd->packet_ver) { // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor])
case 8:
@@ -9649,7 +9658,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
nullpo_retv(sd);
if (is_charcommand(fd, sd, RFIFOP(fd,4), 0) != CharCommand_None)
- return;
+ return;
if (is_atcommand(fd, sd, RFIFOP(fd,4), 0) != AtCommand_None)
return;
if(sd->sc_data &&
@@ -10093,7 +10102,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data *sd) { // Rewritten by
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) {
+ if (strlen(nick) < 4) {
WFIFOB(fd,3) = 1; // fail
WFIFOSET(fd, packet_len_table[0x0d1]);
if (RFIFOB(fd,26) == 0) // type
@@ -10239,7 +10248,7 @@ void clif_parse_sn_doridori(int fd, struct map_session_data *sd) {
* スパノビの爆裂波動
*------------------------------------------
*/
-void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd)
+void clif_parse_sn_explosionspirits(int fd, struct map_session_data *sd)
{
if(sd){
int nextbaseexp=pc_nextbaseexp(sd);
@@ -10369,9 +10378,6 @@ void clif_parse_debug(int fd,struct map_session_data *sd)
{
int i, cmd;
- if (packet_db_ver < 0)
- return;
-
cmd = RFIFOW(fd,0);
printf("packet debug 0x%4X\n",cmd);
@@ -10562,11 +10568,12 @@ static int clif_parse(int fd) {
packet_ver = sd->packet_ver;
// check authentification packet to know packet version
else {
- // packet DB
- if (cmd == packet_db_connect_cmd) {
- if (RFIFOREST(fd) >= packet_db[packet_db_ver][cmd].len &&
- (RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[4]) == 0 || RFIFOB(fd,packet_db[packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male
- packet_ver = packet_db_ver;
+ // packet DB
+ if (IS_PACKET_DB_VER (cmd)) {
+ if (RFIFOREST(fd) >= packet_db[clif_config.packet_db_ver][cmd].len &&
+ (RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 0 ||
+ RFIFOB(fd,packet_db[clif_config.packet_db_ver][cmd].pos[4]) == 1)) {// 00 = Female, 01 = Male
+ packet_ver = clif_config.packet_db_ver;
}
// 0x72
} else if (cmd == 0x72) {
@@ -10597,9 +10604,9 @@ static int clif_parse(int fd) {
else if (RFIFOREST(fd) >= 32 && (RFIFOB(fd,31) == 0 || RFIFOB(fd,31) == 1)) // 00 = Female, 01 = Male
packet_ver = 11; // 11: 21sept04
else if (RFIFOREST(fd) >= 29 && (RFIFOB(fd,28) == 0 || RFIFOB(fd,28) == 1)) { // 00 = Female, 01 = Male
- if (RFIFOW(fd,1) == 0) // testing ^^;
+ /*if (RFIFOW(fd,1) == 0) // testing ^^;
packet_ver = 15;
- else
+ else*/
packet_ver = 13; // 13: 25oct04 (by [Yor])
}
// -- some way to identify version 14 and 15? --
@@ -10625,7 +10632,9 @@ static int clif_parse(int fd) {
(packet_ver == 14 && (battle_config.packet_ver_flag & 16) == 0) ||
(packet_ver == 15 && (battle_config.packet_ver_flag & 32) == 0) ||
(packet_ver == 16 && (battle_config.packet_ver_flag & 64) == 0) ||
- packet_ver > MAX_PACKET_VER) { // no support yet
+ packet_ver > MAX_PACKET_VER || // no packet version support yet
+ // identified version, but unknown client?
+ (!sd && packet_db[packet_ver][cmd].func != clif_parse_WantToConnection)) {
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 5; // 05 = Game's EXE is not the latest version
WFIFOSET(fd,23);
@@ -10731,8 +10740,8 @@ static int packetdb_readdb(void)
FILE *fp;
char line[1024];
int ln=0;
- int cmd,j,packet_ver = 0;
- char *str[32],*p,*str2[32],*p2;
+ int cmd,j,k,packet_ver;
+ char *str[32],*p,*str2[32],*p2,w1[24],w2[24];
struct {
void (*func)();
@@ -10861,18 +10870,51 @@ static int packetdb_readdb(void)
return 1;
}
- packet_db_ver = MAX_PACKET_VER;
-
+ 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,"packet_ver: %d",&packet_ver) == 1) {
- memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0])); // copy into new version and continue
- // i hope this isn't the wrong way to do things ^^;
- continue;
+ if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) {
+ if(strcmpi(w1,"packet_ver")==0) {
+ packet_ver = atoi(w2);
+ // copy from previous version into new version and continue
+ // - indicating all following packets should be read into the newer version
+ // -- on 2nd thought, rereading everything isn't the best thing to do...
+ // memcpy(&packet_db[packet_ver], &packet_db[packet_ver - 1], sizeof(packet_db[0]));
+ continue;
+ } else if(strcmpi(w1,"packet_db_ver")==0) {
+ // optional: if you do not wish to read multiple versions from the packet_db,
+ // remove all "packet_ver: ##" lines, and define the packet DB version with this
+ 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;
+ } else if(strcmpi(w1,"enable_packet_db")==0) {
+ // whether we want to allow identifying clients via the packet DB
+ clif_config.enable_packet_db = battle_config_switch(w2);
+ // if we don't want to read the packet DB, and use hardcoded values only
+ if (!clif_config.enable_packet_db)
+ return 0;
+ continue;
+ } else if(strcmpi(w1,"prefer_packet_db")==0) {
+ // whether the packet DB takes higher precedence over the hardcoded one (type 1)
+ // and whether to overwrite predefined packet length and functions when reading
+ // from the DB (type 2)
+ clif_config.prefer_packet_db = battle_config_switch(w2); // not used for now
+ continue;
+ }
}
- memset(str,0,sizeof(str));
+ memset(str,0,sizeof(str));
for(j=0,p=line;j<4 && p;j++){
str[j]=p;
p=strchr(p,',');
@@ -10888,7 +10930,9 @@ static int packetdb_readdb(void)
ShowError(tmp_output);
continue;
}
- packet_db[packet_ver][cmd].len = atoi(str[1]);
+ k = atoi(str[1]);
+ // if (packet_db[packet_ver][cmd].len != k && clif_config.prefer_packet_db) // not used for now
+ packet_db[packet_ver][cmd].len = k;
if(str[2]==NULL){
ln++;
@@ -10897,13 +10941,15 @@ static int packetdb_readdb(void)
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){
- packet_db[packet_ver][cmd].func = clif_parse_func[j].func;
- break;
+ // if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func && !clif_config.prefer_packet_db)
+ // break; // not used for now
+ 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){
- packet_db_connect_cmd = cmd;
+ clif_config.connect_cmd = cmd;
}
if(str[3]==NULL){
sprintf(tmp_output, "packet_db: packet error\n");
@@ -10914,16 +10960,18 @@ static int packetdb_readdb(void)
str2[j]=p2;
p2=strchr(p2,':');
if(p2) *p2++=0;
- packet_db[packet_ver][cmd].pos[j]=atoi(str2[j]);
+ 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[packet_db_ver][cmd].len > 2 /* && packet_db[cmd].pos[0] == 0 */)
+// 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);
- sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", packet_db_ver, "db/packet_db.txt");
+ sprintf(tmp_output,"Done reading packet version '"CL_WHITE"%d"CL_RESET"' in '"CL_WHITE"%s"CL_RESET"'.\n", clif_config.packet_db_ver, "db/packet_db.txt");
ShowStatus(tmp_output);
return 0;
@@ -10936,6 +10984,11 @@ static int packetdb_readdb(void)
int do_init_clif(void) {
int i;
+ clif_config.enable_packet_db = 1; // whether to use the packet DB for client connection
+ clif_config.packet_db_ver = -1; // the main packet version of the DB
+ clif_config.prefer_packet_db = 1; // whether the packet version takes precedence
+ clif_config.connect_cmd = 0xF5; // the default packet used for connecting to the server
+
memset(packet_db,0,sizeof(packet_db));
// size of packet version 5 (old)
@@ -11163,6 +11216,7 @@ int do_init_clif(void) {
packet_db[14][0x21a].len = 282;
packet_db[14][0x21b].len = 10;
packet_db[14][0x21c].len = 10;
+// packet_db[14][0x143].len = 23; // is this required? uncomment if it is
// Init packet function calls for packet ver 15
memcpy(packet_db[15], packet_db[14], sizeof(packet_db[0]));
packet_db[15][0x072].func = clif_parse_UseSkillToId;
@@ -11200,7 +11254,7 @@ int do_init_clif(void) {
packet_db[15][0x116].len = 12;
packet_db[15][0x190].len = 15;
packet_db[15][0x193].len = 21;
- packet_db[15][0x21b].len = 6;
+ packet_db[15][0x21d].len = 6;
packet_db[15][0x222].len = 6;
packet_db[15][0x221].len = -1;
packet_db[15][0x223].len = 8;
@@ -11241,12 +11295,14 @@ int do_init_clif(void) {
packet_db[16][0x116].len = 20;
packet_db[16][0x09f].len = 17;
packet_db[16][0x0f7].len = 21;
- // Init packet function calls for packet ver 17 (packet db)
- memcpy(packet_db[17], packet_db[16], sizeof(packet_db[0]));
+ packet_db[16][0x143].len = 10;
+ // Init packet function calls for the packet_db.txt (17)
+ memcpy(packet_db[MAX_PACKET_VER], packet_db[MAX_PACKET_VER - 1], sizeof(packet_db[0]));
#endif
- packetdb_readdb();
-
+ if (clif_config.enable_packet_db)
+ packetdb_readdb();
+
set_defaultparse(clif_parse);
#ifdef __WIN32
if (!make_listen_port(map_port)) {
diff --git a/src/map/clif.h b/src/map/clif.h
index d0cd2e86e..99e0752d1 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -16,7 +16,6 @@ typedef unsigned int in_addr_t;
#define MAX_PACKET_DB 0x224
#define MAX_PACKET_VER 17
-extern int packet_db_ver;
struct packet_db {
short len;
void (*func)();
@@ -24,6 +23,13 @@ struct packet_db {
};
extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
+extern struct Clif_Config {
+ int enable_packet_db;
+ int packet_db_ver;
+ int prefer_packet_db;
+ int connect_cmd;
+} clif_config;
+
void clif_setip(char*);
void clif_setport(int);
@@ -137,8 +143,8 @@ int clif_petinsight(struct block_list *bl,va_list ap);
int clif_npcoutsight(struct block_list *bl,va_list ap);
int clif_npcinsight(struct block_list *bl,va_list ap);
-int clif_class_change(struct block_list *bl,int class,int type);
-int clif_mob_class_change(struct mob_data *md,int class);
+int clif_class_change(struct block_list *bl,int class_,int type);
+int clif_mob_class_change(struct mob_data *md,int class_);
int clif_mob_equip(struct mob_data *md,int nameid); // [Valaris]
int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range);
@@ -177,7 +183,7 @@ int clif_autospell(struct map_session_data *sd,int skilllv);
int clif_devotion(struct map_session_data *sd,int target);
int clif_spiritball(struct map_session_data *sd);
int clif_combo_delay(struct block_list *src,int wait);
-int clif_bladestop(struct block_list *src,struct block_list *dst,int bool);
+int clif_bladestop(struct block_list *src,struct block_list *dst,int bool_);
int clif_changemapcell(int m,int x,int y,int cell_type,int type);
int clif_status_change(struct block_list *bl,int type,int flag);
diff --git a/src/map/guild.c b/src/map/guild.c
index 5f9e31794..8099ac934 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -284,7 +284,7 @@ int guild_payexp_timer_sub(void *key,void *data,va_list ap)
c->exp=0;
dellist[(*delp)++]=dataid;
- free(c);
+ aFree(c);
return 0;
}
int guild_payexp_timer(int tid,unsigned int tick,int id,int data)
@@ -476,7 +476,7 @@ int guild_recv_info(struct guild *sg)
// イベントの発生
if( (ev=numdb_search(guild_infoevent_db,sg->guild_id))!=NULL ){
numdb_erase(guild_infoevent_db,sg->guild_id);
- for(;ev;ev2=ev->next,free(ev),ev=ev2){
+ for(;ev;ev2=ev->next,aFree(ev),ev=ev2){
npc_event_do(ev->name);
}
}
@@ -750,7 +750,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online)
return 0;
}
// ギルドメンバのオンライン状態/Lv更新通知
-int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class)
+int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_)
{
int i,alv,c,idx=0,om=0,oldonline=-1;
struct guild *g=guild_search(guild_id);
@@ -762,7 +762,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin
oldonline=m->online;
m->online=online;
m->lv=lv;
- m->class_=class;
+ m->class_=class_;
idx=i;
}
if(m->account_id>0){
@@ -938,7 +938,7 @@ int guild_payexp(struct map_session_data *sd,int exp)
return 0;
if( (c=numdb_search(guild_expcache_db,sd->status.char_id))==NULL ){
- c=(struct guild_expcache *)aCalloc(1,sizeof(struct guild_expcache));
+ c=(struct guild_expcache *)aCallocA(1,sizeof(struct guild_expcache));
c->guild_id=sd->status.guild_id;
c->account_id=sd->status.account_id;
c->char_id=sd->status.char_id;
@@ -960,9 +960,9 @@ int guild_getexp(struct map_session_data *sd,int exp)
if(sd->status.guild_id==0 || (g=guild_search(sd->status.guild_id))==NULL )
return 0;
-
+
if( (c=numdb_search(guild_expcache_db,sd->status.char_id))==NULL ){
- c=(struct guild_expcache *)aCalloc(1,sizeof(struct guild_expcache));
+ c=(struct guild_expcache *)aCallocA(1,sizeof(struct guild_expcache));
c->guild_id=sd->status.guild_id;
c->account_id=sd->status.account_id;
c->char_id=sd->status.char_id;
@@ -1191,7 +1191,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
const char *guild_name[2];
struct map_session_data *sd[2];
int j,i;
-
+
guild_id[0] = guild_id1;
guild_id[1] = guild_id2;
guild_name[0] = name1;
@@ -1300,7 +1300,7 @@ int guild_broken(int guild_id,int flag)
numdb_foreach(guild_db,guild_broken_sub,guild_id);
numdb_erase(guild_db,guild_id);
guild_storage_delete(guild_id);
- free(g);
+ aFree(g);
return 0;
}
@@ -1396,7 +1396,7 @@ int guild_castledataloadack(int castle_id,int index,int value)
}
if( (ev=numdb_search(guild_castleinfoevent_db,code))!=NULL ){
numdb_erase(guild_castleinfoevent_db,code);
- for(;ev;ev2=ev->next,free(ev),ev=ev2){
+ for(;ev;ev2=ev->next,aFree(ev),ev=ev2){
npc_event_do(ev->name);
}
}
@@ -1500,7 +1500,7 @@ int guild_agit_end(void)
int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data)
{ // Run One NPC_Event[OnAgitEliminate]
size_t len = strlen((const char*)data);
- char *evname=(char*)aCalloc(len + 4,sizeof(char));
+ char *evname=(char*)aCallocA(len + 4,sizeof(char));
int c=0;
if(!agit_flag) return 0; // Agit already End
@@ -1517,7 +1517,7 @@ int guild_agit_break(struct mob_data *md)
nullpo_retr(0, md);
- evname=(char *)aCalloc(strlen(md->npc_event) + 1, sizeof(char));
+ evname=(char *)aCallocA(strlen(md->npc_event) + 1, sizeof(char));
strcpy(evname,md->npc_event);
// Now By User to Run [OnAgitBreak] NPC Event...
@@ -1539,7 +1539,7 @@ int guild_checkcastles(struct guild *g) {
for(i=0;i<MAX_GUILDCASTLE;i++){
gc=guild_castle_search(i);
cas_id=gc->guild_id;
- if(g->guild_id==cas_id)
+ if(g->guild_id==cas_id)
nb_cas=nb_cas+1;
} //end for
return nb_cas;
@@ -1570,12 +1570,12 @@ int guild_isallied(struct guild *g, struct guild_castle *gc)
return 0;
}
-
+
static int guild_db_final(void *key,void *data,va_list ap)
{
struct guild *g=data;
- free(g);
+ aFree(g);
return 0;
}
@@ -1583,7 +1583,7 @@ static int castle_db_final(void *key,void *data,va_list ap)
{
struct guild_castle *gc=data;
- free(gc);
+ aFree(gc);
return 0;
}
@@ -1591,7 +1591,7 @@ static int guild_expcache_db_final(void *key,void *data,va_list ap)
{
struct guild_expcache *c=data;
- free(c);
+ aFree(c);
return 0;
}
@@ -1599,7 +1599,7 @@ static int guild_infoevent_db_final(void *key,void *data,va_list ap)
{
struct eventlist *ev=data;
- free(ev);
+ aFree(ev);
return 0;
}
diff --git a/src/map/guild.h b/src/map/guild.h
index eefdcb04e..8f5243a8c 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -56,7 +56,7 @@ int guild_delalliance(struct map_session_data *sd,int guild_id,int flag);
int guild_opposition(struct map_session_data *sd,int char_id);
int guild_send_memberinfoshort(struct map_session_data *sd,int online);
-int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class);
+int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_);
int guild_change_memberposition(int guild_id,int account_id,int char_id,int idx);
int guild_memberposition_changed(struct guild *g,int idx,int pos);
int guild_change_position(struct map_session_data *sd,int idx,
diff --git a/src/map/intif.c b/src/map/intif.c
index 9ba9b1ebb..3f1bbfe88 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -457,7 +457,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha
}
// ギルドメンバのオンライン状況/Lv更新要求
int intif_guild_memberinfoshort(int guild_id,
- int account_id,int char_id,int online,int lv,int class)
+ int account_id,int char_id,int online,int lv,int class_)
{
if (CheckForCharServer())
return 0;
@@ -467,7 +467,7 @@ int intif_guild_memberinfoshort(int guild_id,
WFIFOL(inter_fd,10) = char_id;
WFIFOB(inter_fd,14) = online;
WFIFOW(inter_fd,15) = lv;
- WFIFOW(inter_fd,17) = class;
+ WFIFOW(inter_fd,17) = class_;
WFIFOSET(inter_fd,19);
return 0;
}
@@ -640,7 +640,7 @@ int intif_parse_WisMessage(int fd) { // rewritten by [Yor]
// if(battle_config.etc_log)
// printf("intif_parse_wismessage: %d %s %s %s\n",id,RFIFOP(fd,6),RFIFOP(fd,30),RFIFOP(fd,54) );
-
+
sd=map_nick2sd(RFIFOP(fd,32)); // 送信先を探す
if(sd!=NULL && strcmp(sd->status.name, RFIFOP(fd,32)) == 0){
/*
@@ -698,7 +698,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 <packet_len>.w <wispname>.24B
struct map_session_data *pl_sd;
char Wisp_name[24];
char mbuf[255];
- char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMalloc((RFIFOW(fd,2) - 30)) : mbuf;
+ char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) aMallocA((RFIFOW(fd,2) - 30)) : mbuf;
min_gm_level = (int)RFIFOW(fd,28);
memcpy(Wisp_name, RFIFOP(fd,4), 24);
@@ -712,7 +712,7 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 <packet_len>.w <wispname>.24B
clif_wis_message(i, Wisp_name, message, strlen(message) + 1);
if (message != mbuf)
- free(message);
+ aFree(message);
return 0;
}
diff --git a/src/map/intif.h b/src/map/intif.h
index 5077dbe18..761c1ea63 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -33,7 +33,7 @@ int intif_guild_create(const char *name, const struct guild_member *master);
int intif_guild_request_info(int guild_id);
int intif_guild_addmember(int guild_id, struct guild_member *m);
int intif_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes);
-int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class);
+int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class_);
int intif_guild_break(int guild_id);
int intif_guild_message(int guild_id, int account_id, char *mes, int len);
int intif_guild_checkconflict(int guild_id, int account_id, int char_id);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index e6a997976..dd8de15d4 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -530,7 +530,7 @@ static int itemdb_read_itemnametable(void)
if(!p) break;
p++;
}
- free(buf);
+ aFree(buf);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\idnum2itemdisplaynametable.txt");
ShowStatus(tmp_output);
@@ -566,7 +566,7 @@ static int itemdb_read_cardillustnametable(void)
if(!p) break;
p++;
}
- free(buf);
+ aFree(buf);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\num2cardillustnametable.txt");
ShowStatus(tmp_output);
@@ -604,7 +604,7 @@ static int itemdb_read_itemslottable(void)
if(!p) break;
p++;
}
- free(buf);
+ aFree(buf);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\itemslottable.txt");
ShowStatus(tmp_output);
@@ -636,7 +636,7 @@ static int itemdb_read_itemslotcounttable(void)
if(!p) break;
p++;
}
- free(buf);
+ aFree(buf);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\itemslotcounttable.txt");
ShowStatus(tmp_output);
@@ -896,10 +896,10 @@ static int itemdb_final(void *key,void *data,va_list ap)
nullpo_retr(0, id=data);
if(id->use_script)
- free(id->use_script);
+ aFree(id->use_script);
if(id->equip_script)
- free(id->equip_script);
- free(id);
+ aFree(id->equip_script);
+ aFree(id);
return 0;
}
diff --git a/src/map/mail.c b/src/map/mail.c
index 5d63b6f80..74d2bf7c0 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -30,12 +30,12 @@ extern char msg_table[1000][256]; // Server messages (0-499 reserved for GM comm
int mail_check(struct map_session_data *sd,int type)
{
- int i=0,new=0,priority=0;
+ int i=0,new_=0,priority=0;
char message[50];
if(sd==NULL)
return 0;
-
+
sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`read_flag`,`priority`,`check_flag` FROM `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id`", mail_db, sd->status.account_id);
if (mysql_query(&mail_handle, tmp_msql)) {
@@ -64,7 +64,7 @@ int mail_check(struct map_session_data *sd,int type)
}
if(!atoi(mail_row[3])) {
- new++;
+ new_++;
if(atoi(mail_row[4]))
priority++;
if(type==2 || type==3) {
@@ -88,28 +88,28 @@ int mail_check(struct map_session_data *sd,int type)
sprintf(message, msg_table[513], i, mail_row[2]);
clif_displaymessage(sd->fd, jstrescape(message));
}
-
+
}
-
+
mysql_free_result(mail_res);
-
+
} else {
printf("MySQL error (storing query result for %s): %s\n", mail_db, mysql_error(&mail_handle));
return 0;
}
- if(i>0 && new>0 && type==1) {
- //sprintf(message, "You have %d new messages.", new);
- sprintf(message, msg_table[514], new);
+ if(i>0 && new_>0 && type==1) {
+ //sprintf(message, "You have %d new messages.", new_);
+ sprintf(message, msg_table[514], new_);
clif_displaymessage(sd->fd, jstrescape(message));
}
- if(i>0 && new>0 && priority>0 && type==1) {
+ if(i>0 && new_>0 && priority>0 && type==1) {
//sprintf(message, "You have %d unread priority messages.", priority);
sprintf(message, msg_table[515], priority);
clif_displaymessage(sd->fd, jstrescape(message));
}
- if(!new) {
+ if(!new_) {
//clif_displaymessage(sd->fd, "You have no new messages.");
clif_displaymessage(sd->fd, msg_table[516]);
}
@@ -124,7 +124,7 @@ int mail_read(struct map_session_data *sd, int message_id)
if(sd==NULL)
return 0;
-
+
sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`from_char_name`,`message`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1);
if (mysql_query(&mail_handle, tmp_msql)) {
@@ -162,9 +162,9 @@ int mail_read(struct map_session_data *sd, int message_id)
printf("DB server Error (update Read `%s`)- %s\n", mail_db, mysql_error(&mail_handle) );
}
}
-
+
mysql_free_result(mail_res);
-
+
} else {
printf("MySQL error (storing query result for %s): %s\n", mail_db, mysql_error(&mail_handle));
return 0;
@@ -177,7 +177,7 @@ int mail_delete(struct map_session_data *sd, int message_id)
{
if(sd==NULL)
return 0;
-
+
sprintf(tmp_msql,"SELECT `message_id`,`to_account_id`,`read_flag`,`priority`,`check_flag` from `%s` WHERE `to_account_id` = \"%d\" ORDER by `message_id` LIMIT %d, 1",mail_db,sd->status.account_id,message_id-1);
if (mysql_query(&mail_handle, tmp_msql)) {
@@ -217,9 +217,9 @@ int mail_delete(struct map_session_data *sd, int message_id)
//else clif_displaymessage(sd->fd,"Message deleted.");
else clif_displaymessage(sd->fd,msg_table[521]);
}
-
+
mysql_free_result(mail_res);
-
+
} else {
printf("MySQL error (delete query result for %s): %s\n", mail_db, mysql_error(&mail_handle));
return 0;
@@ -232,7 +232,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag)
{
if(sd==NULL)
return 0;
-
+
if(pc_isGM(sd) < 80 && sd->mail_counter > 0) {
//clif_displaymessage(sd->fd,"You must wait 10 minutes before sending another message");
clif_displaymessage(sd->fd,msg_table[522]);
@@ -254,8 +254,8 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag)
if (mysql_query(&mail_handle, tmp_msql)) {
printf("Database server error (executing query for %s): %s\n", char_db, mysql_error(&mail_handle));
return 0;
- }
-
+ }
+
mail_res = mysql_store_result(&mail_handle);
if(mail_res) {
if (mysql_num_rows(mail_res) == 0) {
@@ -268,7 +268,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag)
while ((mail_row = mysql_fetch_row(mail_res))) {
if(strcmp(name,"*")==0) {
sprintf(tmp_msql, "INSERT DELAYED INTO `%s` (`to_account_id`,`from_account_id`,`from_char_name`,`message`,`priority`)"
- " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag);
+ " VALUES ('%d', '%d', '%s', '%s', '%d')",mail_db, atoi(mail_row[0]), sd->status.account_id, sd->status.name, jstrescape(message), flag);
}
else {
sprintf(tmp_msql, "INSERT DELAYED INTO `%s` (`to_account_id`,`to_char_name`,`from_account_id`,`from_char_name`,`message`,`priority`)"
@@ -276,7 +276,7 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag)
if(pc_isGM(sd) < 80)
sd->mail_counter=5;
}
-
+
if(mysql_query(&mail_handle, tmp_msql) ) {
mysql_free_result(mail_res);
printf("DB server Error (insert `mail_db`)- %s\n", mysql_error(&mail_handle) );
@@ -295,18 +295,18 @@ int mail_send(struct map_session_data *sd, char *name, char *message, int flag)
int mail_check_timer(int tid,unsigned int tick,int id,int data)
{
struct map_session_data *sd = NULL;
- int i;
+ int i;
if(mail_timer != tid)
return 0;
sprintf(tmp_msql,"SELECT DISTINCT `to_account_id` FROM `%s` WHERE `read_flag` = '0' AND `check_flag` = '0'", mail_db);
-
+
if (mysql_query(&mail_handle, tmp_msql)) {
printf("Database server error (executing query for %s): %s\n", char_db, mysql_error(&mail_handle));
mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0);
return 0;
- }
+ }
mail_res = mysql_store_result(&mail_handle);
@@ -324,8 +324,8 @@ int mail_check_timer(int tid,unsigned int tick,int id,int data)
if(pc_isGM(sd) < 80 && sd->mail_counter > 0)
sd->mail_counter--;
if(sd->status.account_id==atoi(mail_row[0]))
- //clif_displaymessage(sd->fd, "You have new mail.");
- clif_displaymessage(sd->fd, msg_table[526]);
+ //clif_displaymessage(sd->fd, "You have new mail.");
+ clif_displaymessage(sd->fd, msg_table[526]);
}
}
}
@@ -341,7 +341,7 @@ int mail_check_timer(int tid,unsigned int tick,int id,int data)
}
int do_init_mail(void)
-{
+{
add_timer_func_list(mail_check_timer,"mail_check_timer");
mail_timer=add_timer(gettick()+MAIL_CHECK_TIME,mail_check_timer,0,0);
return 0;
diff --git a/src/map/map.c b/src/map/map.c
index a591c97a2..55d571767 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -193,7 +193,7 @@ int map_getusers(void) {
int map_freeblock( void *bl )
{
if(block_free_lock==0){
- free(bl);
+ aFree(bl);
bl = NULL;
}
else{
@@ -229,7 +229,7 @@ int map_freeblock_unlock(void) {
// printf("map_freeblock_unlock: free %d object\n",block_free_count);
// }
for(i=0;i<block_free_count;i++){
- free(block_free[i]);
+ aFree(block_free[i]);
block_free[i] = NULL;
}
block_free_count=0;
@@ -847,7 +847,7 @@ int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,struct
fitem->bl.id = map_addobject(&fitem->bl);
if(fitem->bl.id==0){
- free(fitem);
+ aFree(fitem);
return 0;
}
@@ -894,9 +894,9 @@ void map_addchariddb(int charid, char *name) {
struct charid2nick *p=NULL;
int req=0;
- p=numdb_search(charid_db,charid);
+ p = (struct charid2nick*)numdb_search(charid_db,charid);
if(p==NULL){ // デ?タベ?スにない
- p = (struct charid2nick *)aCalloc(1,sizeof(struct charid2nick));
+ p = (struct charid2nick *)aCallocA(1,sizeof(struct charid2nick));
p->req_id=0;
}else
numdb_erase(charid_db,charid);
@@ -921,7 +921,7 @@ int map_reqchariddb(struct map_session_data * sd,int charid) {
nullpo_retr(0, sd);
- p=numdb_search(charid_db,charid);
+ p = (struct charid2nick*)numdb_search(charid_db,charid);
if(p!=NULL) // デ?タベ?スにすでにある
return 0;
p = (struct charid2nick *)aCalloc(1,sizeof(struct charid2nick));
@@ -1005,7 +1005,7 @@ int map_quit(struct map_session_data *sd) {
// check if we've been authenticated [celest]
if (sd->state.auth)
skill_castcancel(&sd->bl,0); // 詠唱を中?する
-
+
skill_stop_dancing(&sd->bl,1);// ダンス/演奏中?
if(sd->sc_data && sd->sc_data[SC_BERSERK].timer!=-1) //バ?サ?ク中の終了はHPを100に
@@ -1052,7 +1052,7 @@ int map_quit(struct map_session_data *sd) {
storage_storage_save(sd);
if( sd->npc_stackbuf && sd->npc_stackbuf != NULL) {
- free( sd->npc_stackbuf );
+ aFree( sd->npc_stackbuf );
sd->npc_stackbuf = NULL;
}
@@ -1092,7 +1092,7 @@ struct map_session_data * map_id2sd(int id) {
struct map_session_data *sd=NULL;
for(i = 0; i < fd_max; i++)
- if (session[i] && (sd = session[i]->session_data) && sd->bl.id == id)
+ if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd->bl.id == id)
return sd;
return NULL;
@@ -1103,7 +1103,7 @@ struct map_session_data * map_id2sd(int id) {
*------------------------------------------
*/
char * map_charid2nick(int id) {
- struct charid2nick *p=numdb_search(charid_db,id);
+ struct charid2nick *p = (struct charid2nick*)numdb_search(charid_db,id);
if(p==NULL)
return NULL;
@@ -1130,7 +1130,7 @@ struct map_session_data * map_nick2sd(char *nick) {
nicklen = strlen(nick);
for (i = 0; i < fd_max; i++) {
- if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth)
+ if (session[i] && (pl_sd = (struct map_session_data*)session[i]->session_data) && pl_sd->state.auth)
// Without case sensitive check (increase the number of similar character names found)
if (strnicmp(pl_sd->status.name, nick, nicklen) == 0) {
// Strict comparison (if found, we finish the function immediatly with correct value)
@@ -1160,7 +1160,7 @@ struct block_list * map_id2bl(int id)
if(id<sizeof(object)/sizeof(object[0]))
bl = object[id];
else
- bl = numdb_search(id_db,id);
+ bl = (struct block_list*)numdb_search(id_db,id);
return bl;
}
@@ -1217,10 +1217,10 @@ void map_removenpc(void) {
map_delblock(&map[m].npc[i]->bl);
numdb_erase(id_db,map[m].npc[i]->bl.id);
if(map[m].npc[i]->bl.subtype==SCRIPT) {
-// free(map[m].npc[i]->u.scr.script);
-// free(map[m].npc[i]->u.scr.label_list);
+// aFree(map[m].npc[i]->u.scr.script);
+// aFree(map[m].npc[i]->u.scr.label_list);
}
- free(map[m].npc[i]);
+ aFree(map[m].npc[i]);
map[m].npc[i] = NULL;
n++;
}
@@ -1238,7 +1238,7 @@ void map_removenpc(void) {
int map_mapname2mapid(char *name) {
struct map_data *md=NULL;
- md=strdb_search(map_db,name);
+ md = (struct map_data*)strdb_search(map_db,name);
#ifdef USE_AFM
// If we can't find the .gat map try .afm instead [celest]
@@ -1246,7 +1246,7 @@ int map_mapname2mapid(char *name) {
char afm_name[16] = "";
strncpy(afm_name, name, strlen(name) - 4);
strcat(afm_name, ".afm");
- md = strdb_search(map_db,afm_name);
+ md = (struct map_data*)strdb_search(map_db,afm_name);
}
#endif
@@ -1262,7 +1262,7 @@ int map_mapname2mapid(char *name) {
int map_mapname2ipport(char *name,int *ip,int *port) {
struct map_data_other_server *mdos=NULL;
- mdos=strdb_search(map_db,name);
+ mdos = (struct map_data_other_server*)strdb_search(map_db,name);
if(mdos==NULL || mdos->gat)
return -1;
*ip=mdos->ip;
@@ -1385,7 +1385,7 @@ int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk)
case CELL_CHKTYPE:
return m->gat[j];
default: return 0;
- }
+ }
return 0;
}
@@ -1396,7 +1396,7 @@ int map_getcellp(struct map_data* m,int x,int y,CELL_CHK cellchk)
int map_setcell(int m,int x,int y,CELL_SET cellset)
{
int i,j;
-
+
if(x<0 || x>=map[m].xs || y<0 || y>=map[m].ys)
return 0;
j=x+y*map[m].xs;
@@ -1431,7 +1431,7 @@ int map_setipport(char *name,unsigned long ip,int port) {
struct map_data *md=NULL;
struct map_data_other_server *mdos=NULL;
- md=strdb_search(map_db,name);
+ md = (struct map_data*)strdb_search(map_db,name);
if(md==NULL){ // not exist -> add new data
mdos=(struct map_data_other_server *)aCalloc(1,sizeof(struct map_data_other_server));
memcpy(mdos->name,name,24);
@@ -1459,7 +1459,7 @@ int map_setipport(char *name,unsigned long ip,int port) {
* 水場高さ設定
*------------------------------------------
*/
-static struct {
+static struct waterlist_ {
char mapname[24];
int waterheight;
} *waterlist=NULL;
@@ -1487,7 +1487,7 @@ static void map_readwater(char *watertxt) {
return;
}
if(waterlist==NULL)
- waterlist=aCalloc(MAX_MAP_PER_SERVER,sizeof(*waterlist));
+ waterlist = (struct waterlist_*)aCallocA(MAX_MAP_PER_SERVER,sizeof(*waterlist));
while(fgets(line,1020,fp) && n < MAX_MAP_PER_SERVER){
int wh,count;
if(line[0] == '/' && line[1] == '/')
@@ -1554,7 +1554,7 @@ static int map_cache_open(char *fn) {
map_cache.head.filesize == ftell(map_cache.fp)
) {
// キャッシュ読み込み成功
- map_cache.map = aMalloc(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps);
+ map_cache.map = (struct MAP_CACHE_INFO*)aMallocA(sizeof(struct MAP_CACHE_INFO) * map_cache.head.nmaps);
fseek(map_cache.fp,sizeof(struct MAP_CACHE_HEAD),SEEK_SET);
fread(map_cache.map,sizeof(struct MAP_CACHE_INFO),map_cache.head.nmaps,map_cache.fp);
return 1;
@@ -1567,7 +1567,7 @@ static int map_cache_open(char *fn) {
map_cache.fp = fopen(fn,"wb");
if(map_cache.fp) {
memset(&map_cache.head,0,sizeof(struct MAP_CACHE_HEAD));
- map_cache.map = aCalloc(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX);
+ map_cache.map = (struct MAP_CACHE_INFO*)aCallocA(sizeof(struct MAP_CACHE_INFO),MAX_CAHCE_MAX);
map_cache.head.nmaps = MAX_CAHCE_MAX;
map_cache.head.sizeof_header = sizeof(struct MAP_CACHE_HEAD);
map_cache.head.sizeof_map = sizeof(struct MAP_CACHE_INFO);
@@ -1589,7 +1589,7 @@ static void map_cache_close(void) {
fwrite(map_cache.map,map_cache.head.nmaps,sizeof(struct MAP_CACHE_INFO),map_cache.fp);
}
fclose(map_cache.fp);
- free(map_cache.map);
+ aFree(map_cache.map);
map_cache.fp = NULL;
return;
}
@@ -1607,14 +1607,14 @@ int map_cache_read(struct map_data *m) {
int size = map_cache.map[i].xs * map_cache.map[i].ys;
m->xs = map_cache.map[i].xs;
m->ys = map_cache.map[i].ys;
- m->gat = (unsigned char *)aCalloc(m->xs * m->ys,sizeof(unsigned char));
+ m->gat = (unsigned char *)aCallocA(m->xs * m->ys,sizeof(unsigned char));
fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET);
if(fread(m->gat,1,size,map_cache.fp) == size) {
// 成功
return 1;
} else {
// なぜかファイル後半が欠けてるので読み直し
- m->xs = 0; m->ys = 0; m->gat = NULL; free(m->gat);
+ m->xs = 0; m->ys = 0; m->gat = NULL; aFree(m->gat);
return 0;
}
} else if(map_cache.map[i].compressed == 1) {
@@ -1624,14 +1624,14 @@ int map_cache_read(struct map_data *m) {
int size_compress = map_cache.map[i].compressed_len;
m->xs = map_cache.map[i].xs;
m->ys = map_cache.map[i].ys;
- m->gat = (unsigned char *)aMalloc(m->xs * m->ys * sizeof(unsigned char));
- buf = (unsigned char*)aMalloc(size_compress);
+ m->gat = (unsigned char *)aMallocA(m->xs * m->ys * sizeof(unsigned char));
+ buf = (unsigned char*)aMallocA(size_compress);
fseek(map_cache.fp,map_cache.map[i].pos,SEEK_SET);
if(fread(buf,1,size_compress,map_cache.fp) != size_compress) {
// なぜかファイル後半が欠けてるので読み直し
printf("fread error\n");
m->xs = 0; m->ys = 0; m->gat = NULL;
- free(m->gat); free(buf);
+ aFree(m->gat); aFree(buf);
return 0;
}
dest_len = m->xs * m->ys;
@@ -1639,10 +1639,10 @@ int map_cache_read(struct map_data *m) {
if(dest_len != map_cache.map[i].xs * map_cache.map[i].ys) {
// 正常に解凍が出来てない
m->xs = 0; m->ys = 0; m->gat = NULL;
- free(m->gat); free(buf);
+ aFree(m->gat); aFree(buf);
return 0;
}
- free(buf);
+ aFree(buf);
return 1;
}
}
@@ -1669,7 +1669,7 @@ static int map_cache_write(struct map_data *m) {
if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) {
// 圧縮保存
// さすがに2倍に膨れる事はないという事で
- write_buf = aMalloc(m->xs * m->ys * 2);
+ write_buf = (char*)aMallocA(m->xs * m->ys * 2);
len_new = m->xs * m->ys * 2;
encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys);
map_cache.map[i].compressed = 1;
@@ -1678,7 +1678,7 @@ static int map_cache_write(struct map_data *m) {
len_new = m->xs * m->ys;
write_buf = m->gat;
map_cache.map[i].compressed = 0;
- map_cache.map[i].compressed_len = 0;
+ map_cache.map[i].compressed_len = 0;
}
if(len_new <= len_old) {
// サイズが同じか小さくなったので場所は変わらない
@@ -1696,7 +1696,7 @@ static int map_cache_write(struct map_data *m) {
map_cache.map[i].water_height = map_waterheight(m->name);
map_cache.dirty = 1;
if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) {
- free(write_buf);
+ aFree(write_buf);
}
return 0;
}
@@ -1706,7 +1706,7 @@ static int map_cache_write(struct map_data *m) {
if(map_cache.map[i].fn[0] == 0) {
// 新しい場所に登録
if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) {
- write_buf = aMalloc(m->xs * m->ys * 2);
+ write_buf = (char*)aMallocA(m->xs * m->ys * 2);
len_new = m->xs * m->ys * 2;
encode_zip(write_buf,&len_new,m->gat,m->xs * m->ys);
map_cache.map[i].compressed = 1;
@@ -1727,7 +1727,7 @@ static int map_cache_write(struct map_data *m) {
map_cache.head.filesize += len_new;
map_cache.dirty = 1;
if(map_read_flag >= READ_FROM_BITMAP_COMPRESSED) {
- free(write_buf);
+ aFree(write_buf);
}
return 0;
}
@@ -1819,7 +1819,8 @@ static int map_readafm(int m,char *fn) {
map[m].m = m;
xs = map[m].xs = afm_size[0];
ys = map[m].ys = afm_size[1];
- map[m].gat = aCalloc(s = map[m].xs * map[m].ys, 1);
+ // check this, unsigned where it might not need to be
+ map[m].gat = (unsigned char*)aCallocA(s = map[m].xs * map[m].ys, 1);
if(map[m].gat==NULL){
printf("out of memory : map_readmap gat\n");
@@ -1842,14 +1843,14 @@ static int map_readafm(int m,char *fn) {
map[m].bxs=(xs+BLOCK_SIZE-1)/BLOCK_SIZE;
map[m].bys=(ys+BLOCK_SIZE-1)/BLOCK_SIZE;
size = map[m].bxs * map[m].bys * sizeof(struct block_list*);
- map[m].block = aCalloc(size, 1);
+ map[m].block = (struct block_list**)aCalloc(size, 1);
if(map[m].block == NULL){
printf("out of memory : map_readmap block\n");
exit(1);
}
- map[m].block_mob = aCalloc(size, 1);
+ map[m].block_mob = (struct block_list**)aCalloc(size, 1);
if (map[m].block_mob == NULL) {
printf("out of memory : map_readmap block_mob\n");
exit(1);
@@ -1857,14 +1858,14 @@ static int map_readafm(int m,char *fn) {
size = map[m].bxs*map[m].bys*sizeof(int);
- map[m].block_count = aCalloc(size, 1);
+ map[m].block_count = (int*)aCallocA(size, 1);
if(map[m].block_count==NULL){
printf("out of memory : map_readmap block\n");
exit(1);
}
memset(map[m].block_count,0,size);
- map[m].block_mob_count=aCalloc(size, 1);
+ map[m].block_mob_count = (int*)aCallocA(size, 1);
if(map[m].block_mob_count==NULL){
printf("out of memory : map_readmap block_mob\n");
exit(1);
@@ -1885,9 +1886,9 @@ static int map_readafm(int m,char *fn) {
* マップ1枚読み込み
* ===================================================*/
static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap) {
- unsigned char *gat="";
+ char *gat="";
size_t size;
-
+
int i = 0;
int e = 0;
char progress[21] = " ";
@@ -1925,19 +1926,20 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap)
int s;
int wh;
int x,y,xs,ys;
- struct gat_1cell {float high[4]; int type;} *p=NULL;
+ struct gat_1cell {float high[4]; int type;} *p=NULL;
// read & convert fn
- gat=grfio_read(fn);
+ // again, might not need to be unsigned char
+ gat = grfio_read(fn);
if(gat==NULL) {
return -1;
// さすがにマップが読めないのはまずいので終了する
//printf("Can't load map %s\n",fn);
//exit(1);
}
-
+
xs=map[m].xs=*(int*)(gat+6);
ys=map[m].ys=*(int*)(gat+10);
- map[m].gat = (unsigned char *)aCalloc(s = map[m].xs * map[m].ys,sizeof(unsigned char));
+ map[m].gat = (char *)aCallocA(s = map[m].xs * map[m].ys,sizeof(char));
wh=map_waterheight(map[m].name);
for(y=0;y<ys;y++){
p=(struct gat_1cell*)(gat+y*xs*20+14);
@@ -1952,7 +1954,7 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap)
}
}
map_cache_write(&map[m]);
- free(gat);
+ aFree(gat);
}
map[m].m=m;
@@ -1967,8 +1969,8 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap)
map[m].block = (struct block_list **)aCalloc(1,size);
map[m].block_mob = (struct block_list **)aCalloc(1,size);
size = map[m].bxs*map[m].bys*sizeof(int);
- map[m].block_count = (int *)aCalloc(1,size);
- map[m].block_mob_count=(int *)aCalloc(1,size);
+ map[m].block_count = (int *)aCallocA(1,size);
+ map[m].block_mob_count=(int *)aCallocA(1,size);
if (alias)
strdb_insert(map_db,alias,&map[m]);
else
@@ -1990,7 +1992,7 @@ int map_readallmap(void) {
FILE *afm_file;
#endif
int map_cache = 0;
-
+
// マップキャッシュを開く
if(map_read_flag >= READ_FROM_BITMAP) {
map_cache_open(map_bitmap_filename);
@@ -2032,7 +2034,7 @@ int map_readallmap(void) {
char buf[64];
*p++ = '\0';
sprintf(buf,"data\\%s", p);
- map[i].alias = strdup(buf);
+ map[i].alias = aStrdup(buf);
} else
map[i].alias = NULL;
@@ -2041,20 +2043,20 @@ int map_readallmap(void) {
map_delmap(map[i].name);
maps_removed++;
i--;
- }
+ }
}
}
- free(waterlist);
+ aFree(waterlist);
printf("\r");
snprintf(tmp_output,sizeof(tmp_output),"Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps.%30s\n",map_num,"");
ShowInfo(tmp_output);
-
+
map_cache_close();
if(map_read_flag == CREATE_BITMAP || map_read_flag == CREATE_BITMAP_COMPRESSED) {
--map_read_flag;
}
-
+
if (maps_removed) {
snprintf(tmp_output,sizeof(tmp_output),"Maps Removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed);
ShowNotice(tmp_output);
@@ -2119,15 +2121,15 @@ int parse_console(char *buf) {
int m, n;
struct map_session_data *sd;
- sd = aCalloc(sizeof(*sd), 1);
+ sd = (struct map_session_data*)aCalloc(sizeof(*sd), 1);
sd->fd = 0;
strcpy( sd->status.name , "console");
- type = (char *)aMalloc(64);
- command = (char *)aMalloc(64);
- map = (char *)aMalloc(64);
- buf2 = (char *)aMalloc(72);
+ type = (char *)aMallocA(64);
+ command = (char *)aMallocA(64);
+ map = (char *)aMallocA(64);
+ buf2 = (char *)aMallocA(72);
memset(type,0,64);
memset(command,0,64);
@@ -2184,12 +2186,12 @@ int parse_console(char *buf) {
}
end:
- free(buf);
- free(type);
- free(command);
- free(map);
- free(buf2);
- free(sd);
+ aFree(buf);
+ aFree(type);
+ aFree(command);
+ aFree(map);
+ aFree(buf2);
+ aFree(sd);
return 0;
}
@@ -2317,7 +2319,7 @@ int inter_config_read(char *cfgName)
if(i!=2)
continue;
if(strcmpi(w1,"stall_time")==0){
- stall_time_ = atoi(w2);
+ stall_time_ = atoi(w2);
#ifndef TXT_ONLY
} else if(strcmpi(w1,"item_db_db")==0){
strcpy(item_db_db,w2);
@@ -2484,7 +2486,7 @@ void char_online_check(void)
chrif_char_reset_offline();
for(i=0;i<fd_max;i++){
- if (session[i] && (sd = session[i]->session_data) && sd && sd->state.auth &&
+ if (session[i] && (sd = (struct map_session_data*)session[i]->session_data) && sd && sd->state.auth &&
!(battle_config.hide_GM_session && pc_isGM(sd)))
if(sd->status.char_id) {
chrif_char_online(sd);
@@ -2523,21 +2525,22 @@ int flush_timer(int tid, unsigned int tick, int id, int data){
int id_db_final(void *k,void *d,va_list ap)
{
struct mob_data *id;
- nullpo_retr(0, id=d);
+ nullpo_retr(0, id = (struct mob_data*)d);
if(id->lootitem)
- free(id->lootitem);
+ aFree(id->lootitem);
if(id)
- free(id);
+ aFree(id);
return 0;
}
+
int map_db_final(void *k,void *d,va_list ap)
{
struct map_data *id;
- nullpo_retr(0, id=d);
+ nullpo_retr(0, id = (struct map_data*)d);
if(id->gat)
- free(id->gat);
+ aFree(id->gat);
if(id)
- free(id);
+ aFree(id);
return 0;
}
int nick_db_final(void *k,void *d,va_list ap){ return 0; }
@@ -2607,14 +2610,14 @@ void do_final(void) {
do_final_guild();
/*
for(i=0;i<map_num;i++){
- if(map[i].gat) {
- free(map[i].gat);
+ if(map[i].gat) {
+ aFree(map[i].gat);
map[i].gat=NULL; //isn't it NULL already o_O?
}
- if(map[i].block) free(map[i].block);
- if(map[i].block_mob) free(map[i].block_mob);
- if(map[i].block_count) free(map[i].block_count);
- if(map[i].block_mob_count) free(map[i].block_mob_count);
+ if(map[i].block) aFree(map[i].block);
+ if(map[i].block_mob) aFree(map[i].block_mob);
+ if(map[i].block_count) aFree(map[i].block_count);
+ if(map[i].block_mob_count) aFree(map[i].block_mob_count);
}
*/
#endif
@@ -2676,15 +2679,19 @@ int do_init(int argc, char *argv[]) {
FILE *data_conf;
char line[1024], w1[1024], w2[1024];
- unsigned char *INTER_CONF_NAME="conf/inter_athena.conf";
- unsigned char *LOG_CONF_NAME="conf/log_athena.conf";
- unsigned char *MAP_CONF_NAME = "conf/map_athena.conf";
- unsigned char *BATTLE_CONF_FILENAME = "conf/battle_athena.conf";
- unsigned char *ATCOMMAND_CONF_FILENAME = "conf/atcommand_athena.conf";
- unsigned char *CHARCOMMAND_CONF_FILENAME = "conf/charcommand_athena.conf";
- unsigned char *SCRIPT_CONF_NAME = "conf/script_athena.conf";
- unsigned char *MSG_CONF_NAME = "conf/msg_athena.conf";
- unsigned char *GRF_PATH_FILENAME = "conf/grf-files.txt";
+#ifdef DGCOLLECT
+ GC_enable_incremental();
+#endif
+
+ char *INTER_CONF_NAME="conf/inter_athena.conf";
+ char *LOG_CONF_NAME="conf/log_athena.conf";
+ char *MAP_CONF_NAME = "conf/map_athena.conf";
+ char *BATTLE_CONF_FILENAME = "conf/battle_athena.conf";
+ char *ATCOMMAND_CONF_FILENAME = "conf/atcommand_athena.conf";
+ char *CHARCOMMAND_CONF_FILENAME = "conf/charcommand_athena.conf";
+ char *SCRIPT_CONF_NAME = "conf/script_athena.conf";
+ char *MSG_CONF_NAME = "conf/msg_athena.conf";
+ char *GRF_PATH_FILENAME = "conf/grf-files.txt";
chrif_connected = 0;
@@ -2711,10 +2718,10 @@ int do_init(int argc, char *argv[]) {
GRF_PATH_FILENAME = argv[i+1];
#ifndef TXT_ONLY
else if (strcmp(argv[i],"--inter_config") == 0 || strcmp(argv[i],"--inter-config") == 0)
- INTER_CONF_NAME = argv[i+1];
+ INTER_CONF_NAME = argv[i+1];
#endif /* not TXT_ONLY */
else if (strcmp(argv[i],"--log_config") == 0 || strcmp(argv[i],"--log-config") == 0)
- LOG_CONF_NAME = argv[i+1];
+ LOG_CONF_NAME = argv[i+1];
else if (strcmp(argv[i],"--run_once") == 0) // close the map-server as soon as its done.. for testing [Celest]
runflag = 0;
}
diff --git a/src/map/map.h b/src/map/map.h
index 26fc3e6c8..1b699b960 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -329,7 +329,7 @@ struct map_session_data {
unsigned short eventcount; // [celest]
int last_skillid,last_skilllv; // Added by RoVeRT
-
+
unsigned char change_level; // [celest]
#ifndef TXT_ONLY
@@ -414,6 +414,7 @@ struct mob_data {
unsigned walk_easy : 1;
unsigned special_mob_ai : 3;
unsigned soul_change_flag : 1; // Celest
+ int provoke_flag; // Celest
} state;
int timer;
short to_x,to_y;
@@ -509,7 +510,7 @@ enum {
struct map_data {
char name[24];
- unsigned char *gat; // NULLなら下のmap_data_other_serverとして扱う
+ char *gat; // NULLなら下のmap_data_other_serverとして扱う
char *alias; // [MouseJstr]
int *gat_fileused[MAX_CELL_TYPE+1+1]; //もしビットマップを使うならこちらを使う、
//上のgatはキャストされてgat_fileused[0]に指す
@@ -562,7 +563,7 @@ struct map_data {
};
struct map_data_other_server {
char name[24];
- unsigned char *gat; // NULL固定にして判断
+ char *gat; // NULL固定にして判断
unsigned long ip;
unsigned int port;
};
@@ -634,7 +635,7 @@ enum {
* CHELL_CHKTOUCH:セルはタッチ系の場合は1を返す、以外は0
* CELL_CHKTYPE: セルのタイプを知りたい場合は1を返す、以外は0
*/
-typedef enum {
+typedef enum {
CELL_CHKPASS,CELL_CHKNOPASS,CELL_CHKWATER=3,CELL_CHKHIGH=5,CELL_CHKTOUCH,CELL_CHKTYPE
} CELL_CHK;
@@ -671,7 +672,7 @@ extern int night_flag; // 0=day, 1=night [Yor]
int map_getcell(int,int,int,CELL_CHK);
int map_getcellp(struct map_data*,int,int,CELL_CHK);
extern int map_read_flag; //セル情報のソース判定フラグ、0ならgrfファイル、1ならビットマップファイル
-enum {
+enum {
READ_FROM_GAT, READ_FROM_AFM,
READ_FROM_BITMAP, CREATE_BITMAP,
READ_FROM_BITMAP_COMPRESSED, CREATE_BITMAP_COMPRESSED
diff --git a/src/map/mob.c b/src/map/mob.c
index 21ec6c585..741982041 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -31,7 +31,7 @@
#define MOB_LAZYMOVEPERC 50 // Move probability in the negligent mode MOB (rate of 1000 minute)
#define MOB_LAZYWARPPERC 20 // Warp probability in the negligent mode MOB (rate of 1000 minute)
-#define MAX_MOB_DB 2000 /* Change this to increase the table size in your mob_db to accomodate
+#define MAX_MOB_DB 2000 /* Change this to increase the table size in your mob_db to accomodate
numbers more than 2000 for mobs if you want to (and know what you're doing).
Be sure to note that 4001 to 4047 are for advanced classes. */
@@ -48,7 +48,7 @@ static int mob_makedummymobdb(int);
static int mob_timer(int,unsigned int,int,int);
int mobskill_use(struct mob_data *md,unsigned int tick,int event);
int mobskill_deltimer(struct mob_data *md );
-int mob_skillid2skillidx(int class,int skillid);
+int mob_skillid2skillidx(int class_,int skillid);
int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx);
static int mob_unlocktarget(struct mob_data *md,int tick);
@@ -73,7 +73,7 @@ int mobdb_searchname(const char *str)
* Id Mob is checked.
*------------------------------------------
*/
-int mobdb_checkid(const int id)
+int mobdb_checkid(const int id)
{
if (id <= 0 || id >= (sizeof(mob_db) / sizeof(mob_db[0])) || mob_db[id].name[0] == '\0')
return 0;
@@ -85,28 +85,28 @@ int mobdb_checkid(const int id)
* The minimum data set for MOB spawning
*------------------------------------------
*/
-int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class)
+int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class_)
{
nullpo_retr(0, md);
md->bl.prev=NULL;
md->bl.next=NULL;
if(strcmp(mobname,"--en--")==0)
- memcpy(md->name,mob_db[class].name,24);
+ memcpy(md->name,mob_db[class_].name,24);
else if(strcmp(mobname,"--ja--")==0)
- memcpy(md->name,mob_db[class].jname,24);
+ memcpy(md->name,mob_db[class_].jname,24);
else
memcpy(md->name,mobname,24);
md->n = 0;
- md->base_class = md->class_ = class;
+ md->base_class = md->class_ = class_;
md->bl.id= npc_get_new_npc_id();
memset(&md->state,0,sizeof(md->state));
md->timer = -1;
md->target_id=0;
md->attacked_id=0;
- md->speed=mob_db[class].speed;
+ md->speed=mob_db[class_].speed;
return 0;
}
@@ -117,10 +117,10 @@ int mob_spawn_dataset(struct mob_data *md,const char *mobname,int class)
*------------------------------------------
*/
int mob_once_spawn(struct map_session_data *sd,char *mapname,
- int x,int y,const char *mobname,int class,int amount,const char *event)
+ int x,int y,const char *mobname,int class_,int amount,const char *event)
{
struct mob_data *md=NULL;
- int m,count,lv=255,r=class;
+ int m,count,lv=255,r=class_;
if( sd )
lv=sd->status.base_level;
@@ -130,27 +130,27 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
else
m=map_mapname2mapid(mapname);
- if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000) // 値が異常なら召喚を止める
+ if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // 値が異常なら召喚を止める
return 0;
- if(class<0){ // ランダムに召喚
+ if(class_<0){ // ランダムに召喚
int i=0;
- int j=-class-1;
+ int j=-class_-1;
int k;
if(j>=0 && j<MAX_RANDOMMONSTER){
do{
- class=rand()%1000+1001;
+ class_=rand()%1000+1001;
k=rand()%1000000;
- }while((mob_db[class].max_hp <= 0 || mob_db[class].summonper[j] <= k ||
- (lv<mob_db[class].lv && battle_config.random_monster_checklv)) && (i++) < 2000);
+ }while((mob_db[class_].max_hp <= 0 || mob_db[class_].summonper[j] <= k ||
+ (lv<mob_db[class_].lv && battle_config.random_monster_checklv)) && (i++) < 2000);
if(i>=2000){
- class=mob_db[0].summonper[j];
+ class_=mob_db[0].summonper[j];
}
}else{
return 0;
}
// if(battle_config.etc_log)
-// printf("mobclass=%d try=%d\n",class,i);
+// printf("mobclass=%d try=%d\n",class_,i);
}
if(sd){
if(x<=0) x=sd->bl.x;
@@ -163,21 +163,21 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data));
memset(md, '\0', sizeof *md);
- if(class>4000) { // large/tiny mobs [Valaris]
+ if(class_>4000) { // large/tiny mobs [Valaris]
md->size=2;
- class-=4000;
+ class_-=4000;
}
- else if(class>MAX_MOB_DB) {
+ else if(class_>MAX_MOB_DB) {
md->size=1;
- class-=MAX_MOB_DB;
+ class_-=MAX_MOB_DB;
}
- if(mob_db[class].mode&0x02)
+ if(mob_db[class_].mode&0x02)
md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
else
md->lootitem=NULL;
- mob_spawn_dataset(md,mobname,class);
+ mob_spawn_dataset(md,mobname,class_);
md->bl.m=m;
md->bl.x=x;
md->bl.y=y;
@@ -195,15 +195,15 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
md->bl.type=BL_MOB;
map_addiddb(&md->bl);
mob_spawn(md->bl.id);
-
- if(class==1288) { // emperium hp based on defense level [Valaris]
+
+ if(class_==1288) { // emperium hp based on defense level [Valaris]
struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
if(gc) {
- mob_db[class].max_hp+=2000*gc->defense;
- md->hp=mob_db[class].max_hp;
+ mob_db[class_].max_hp+=2000*gc->defense;
+ md->hp=mob_db[class_].max_hp;
}
} // end addition [Valaris]
-
+
}
return (amount>0)?md->bl.id:0;
@@ -214,7 +214,7 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
*/
int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
int x0,int y0,int x1,int y1,
- const char *mobname,int class,int amount,const char *event)
+ const char *mobname,int class_,int amount,const char *event)
{
int x,y,i,max,lx=-1,ly=-1,id=0;
int m;
@@ -227,7 +227,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
max=(y1-y0+1)*(x1-x0+1)*3;
if(max>1000)max=1000;
- if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000) // A summon is stopped if a value is unusual
+ if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // A summon is stopped if a value is unusual
return 0;
for(i=0;i<amount;i++){
@@ -244,7 +244,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
return 0; // 最初に沸く場所の検索を失敗したのでやめる
}
if(x==0||y==0) printf("xory=0, x=%d,y=%d,x0=%d,y0=%d\n",x,y,x0,y0);
- id=mob_once_spawn(sd,mapname,x,y,mobname,class,1,event);
+ id=mob_once_spawn(sd,mapname,x,y,mobname,class_,1,event);
lx=x;
ly=y;
}
@@ -256,7 +256,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
*------------------------------------------
*/
int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
- int x,int y,const char *mobname,int class,int amount,const char *event,int guardian)
+ int x,int y,const char *mobname,int class_,int amount,const char *event,int guardian)
{
struct mob_data *md=NULL;
int m,count=1,lv=255;
@@ -269,20 +269,20 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
else
m=map_mapname2mapid(mapname);
- if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>MAX_MOB_DB) // Invalid monster classes
+ if(m<0 || amount<=0 || (class_>=0 && class_<=1000) || class_>MAX_MOB_DB) // Invalid monster classes
return 0;
- if(class<0)
+ if(class_<0)
return 0;
-
+
if(sd){
if(x<=0) x=sd->bl.x;
if(y<=0) y=sd->bl.y;
}
-
+
else if(x<=0 || y<=0)
printf("mob_spawn_guardian: ??\n");
-
+
for(count=0;count<amount;count++){
struct guild_castle *gc;
@@ -292,10 +292,10 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
exit(1);
}
memset(md, '\0', sizeof *md);
-
-
- mob_spawn_dataset(md,mobname,class);
+
+
+ mob_spawn_dataset(md,mobname,class_);
md->bl.m=m;
md->bl.x=x;
md->bl.y=y;
@@ -315,7 +315,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
gc=guild_mapname2gc(map[md->bl.m].name);
if(gc) {
- mob_db[class].max_hp+=2000*gc->defense;
+ mob_db[class_].max_hp+=2000*gc->defense;
if(guardian==0) { md->hp=gc->Ghp0; gc->GID0=md->bl.id; }
if(guardian==1) { md->hp=gc->Ghp1; gc->GID1=md->bl.id; }
if(guardian==2) { md->hp=gc->Ghp2; gc->GID2=md->bl.id; }
@@ -324,7 +324,7 @@ int mob_spawn_guardian(struct map_session_data *sd,char *mapname,
if(guardian==5) { md->hp=gc->Ghp5; gc->GID5=md->bl.id; }
if(guardian==6) { md->hp=gc->Ghp6; gc->GID6=md->bl.id; }
if(guardian==7) { md->hp=gc->Ghp7; gc->GID7=md->bl.id; }
-
+
}
}
@@ -373,49 +373,49 @@ int mob_exclusion_check(struct mob_data *md,struct map_session_data *sd)
* Appearance income of mob
*------------------------------------------
*/
-int mob_get_viewclass(int class)
+int mob_get_viewclass(int class_)
{
- return mob_db[class].view_class;
+ return mob_db[class_].view_class;
}
-int mob_get_sex(int class)
+int mob_get_sex(int class_)
{
- return mob_db[class].sex;
+ return mob_db[class_].sex;
}
-short mob_get_hair(int class)
+short mob_get_hair(int class_)
{
- return mob_db[class].hair;
+ return mob_db[class_].hair;
}
-short mob_get_hair_color(int class)
+short mob_get_hair_color(int class_)
{
- return mob_db[class].hair_color;
+ return mob_db[class_].hair_color;
}
-short mob_get_weapon(int class)
+short mob_get_weapon(int class_)
{
- return mob_db[class].weapon;
+ return mob_db[class_].weapon;
}
-short mob_get_shield(int class)
+short mob_get_shield(int class_)
{
- return mob_db[class].shield;
+ return mob_db[class_].shield;
}
-short mob_get_head_top(int class)
+short mob_get_head_top(int class_)
{
- return mob_db[class].head_top;
+ return mob_db[class_].head_top;
}
-short mob_get_head_mid(int class)
+short mob_get_head_mid(int class_)
{
- return mob_db[class].head_mid;
+ return mob_db[class_].head_mid;
}
-short mob_get_head_buttom(int class)
+short mob_get_head_buttom(int class_)
{
- return mob_db[class].head_buttom;
+ return mob_db[class_].head_buttom;
}
-short mob_get_clothes_color(int class) // Add for player monster dye - Valaris
+short mob_get_clothes_color(int class_) // Add for player monster dye - Valaris
{
- return mob_db[class].clothes_color; // End
+ return mob_db[class_].clothes_color; // End
}
-int mob_get_equip(int class) // mob equip [Valaris]
+int mob_get_equip(int class_) // mob equip [Valaris]
{
- return mob_db[class].equip;
+ return mob_db[class_].equip;
}
/*==========================================
* Is MOB in the state in which the present movement is possible or not?
@@ -432,7 +432,7 @@ int mob_can_move(struct mob_data *md)
md->sc_data[SC_AUTOCOUNTER].timer != -1 || //オートカウンター
md->sc_data[SC_BLADESTOP].timer != -1 || //白刃取り
md->sc_data[SC_SPIDERWEB].timer != -1 //スパイダーウェッブ
- )
+ )
return 0;
return 1;
@@ -536,7 +536,7 @@ static int mob_walk(struct mob_data *md,unsigned int tick,int data)
if(md->walkpath.path_pos>=md->walkpath.path_len)
clif_fixmobpos(md); // とまったときに位置の再送信
- }
+ }
return 0;
}
@@ -613,7 +613,7 @@ static int mob_attack(struct mob_data *md,unsigned int tick,int data)
if(tsd && !(mode&0x20) && (tsd->sc_data[SC_TRICKDEAD].timer != -1 || tsd->sc_data[SC_BASILICA].timer != -1 ||
((pc_ishiding(tsd) || tsd->state.gangsterparadise) && !((race == 4 || race == 6) && !tsd->perfect_hiding) ) ) ) {
md->target_id=0;
- md->state.targettype = NONE_ATTACKABLE;
+ md->state.targettype = NONE_ATTACKABLE;
return 0;
}
@@ -739,7 +739,7 @@ static int mob_timer(int tid,unsigned int tick,int id,int data)
if( (bl=map_id2bl(id)) == NULL ){ //攻撃してきた敵がもういないのは正常のようだ
return 1;
}
-
+
if(!bl || !bl->type || bl->type!=BL_MOB)
return 1;
@@ -904,7 +904,7 @@ int mob_spawn(int id)
if(!md || !md->bl.type || md->bl.type!=BL_MOB)
return -1;
-
+
md->last_spawntime=tick;
if( md->bl.prev!=NULL ){
// clif_clearchar_area(&md->bl,3);
@@ -969,7 +969,7 @@ int mob_spawn(int id)
if(gc)
md->guild_id = gc->guild_id;
}
-
+
md->deletetimer=-1;
md->skilltimer=-1;
@@ -1042,7 +1042,7 @@ int mob_stop_walking(struct mob_data *md,int type)
if(md->state.state == MS_WALK || md->state.state == MS_IDLE) {
int dx=0,dy=0;
-
+
md->walkpath.path_len=0;
if(type&4){
dx=md->to_x-md->bl.x;
@@ -1101,7 +1101,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range)
if(gc && agit_flag==0) // Guardians will not attack during non-woe time [Valaris]
return 0; // end addition [Valaris]
-
+
if(bl && bl->type == BL_PC){
nullpo_retr(0, sd=(struct map_session_data *)bl);
if(!gc)
@@ -1183,7 +1183,9 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist)
return 0;
}
// Nothing will be carried out if there is no mind of changing TAGE by TAGE ending.
- if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && ( !(mode&0x04) || rand()%100>25) )
+ if( (md->target_id > 0 && md->state.targettype == ATTACKABLE) && (!(mode&0x04) || rand()%100>25) &&
+ // if the monster was provoked ignore the above rule [celest]
+ !(md->state.provoke_flag && md->state.provoke_flag == bl->id))
return 0;
if(mode&0x20 || // Coercion is exerted if it is MVPMOB.
@@ -1197,11 +1199,13 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist)
return 0;
}
- md->target_id=bl->id; // Since there was no disturbance, it locks on to target.
+ md->target_id = bl->id; // Since there was no disturbance, it locks on to target.
if(bl->type == BL_PC || bl->type == BL_MOB)
md->state.targettype = ATTACKABLE;
else
md->state.targettype = NONE_ATTACKABLE;
+ if (md->state.provoke_flag)
+ md->state.provoke_flag = 0;
md->min_chase=dist+13;
if(md->min_chase>26)
md->min_chase=26;
@@ -1245,9 +1249,9 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
race=mob_db[smd->class_].race;
//対象がPCの場合
if(tsd &&
- !pc_isdead(tsd) &&
- tsd->bl.m == smd->bl.m &&
- tsd->invincible_timer == -1 &&
+ !pc_isdead(tsd) &&
+ tsd->bl.m == smd->bl.m &&
+ tsd->invincible_timer == -1 &&
!pc_isinvisible(tsd) &&
(dist=distance(smd->bl.x,smd->bl.y,tsd->bl.x,tsd->bl.y))<9
)
@@ -1259,7 +1263,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
rand()%1000<1000/(++(*pcc)) ){ // 範囲内PCで等確率にする
smd->target_id=tsd->bl.id;
smd->state.targettype = ATTACKABLE;
- smd->min_chase=13;
+ smd->min_chase=13;
}
}
}
@@ -1298,7 +1302,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
mode=mob_db[md->class_].mode;
else
mode=md->mode;
-
+
if( !md->target_id && mode&0x02){
if(!md->lootitem || (battle_config.monster_loot_type == 1 && md->lootitem_count >= LOOTITEM_SIZE) )
@@ -1393,7 +1397,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
}
// Although there is the master, since it is somewhat far, it approaches.
- if((!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mob_can_move(md) &&
+ if((!md->target_id || md->state.targettype == NONE_ATTACKABLE) && mob_can_move(md) &&
(md->walkpath.path_pos>=md->walkpath.path_len || md->walkpath.path_len==0) && md->master_dist<15){
int i=0,dx,dy,ret;
if(md->master_dist>4) {
@@ -1716,7 +1720,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap)
ret=mob_walktoxy(md,md->bl.x+dx,md->bl.y+dy,0);
i++;
} while(ret && i<5);
-
+
if(ret){ // 移動不可能な所からの攻撃なら2歩下る
if(dx<0) dx=2;
else if(dx>0) dx=-2;
@@ -1969,13 +1973,13 @@ static int mob_delay_item_drop(int tid,unsigned int tick,int id,int data)
clif_additem(ditem->first_sd,0,0,flag);
map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
}
- free(ditem);
+ aFree(ditem);
return 0;
}
map_addflooritem(&temp_item,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
- free(ditem);
+ aFree(ditem);
return 0;
}
@@ -1995,13 +1999,13 @@ static int mob_delay_item_drop2(int tid,unsigned int tick,int id,int data)
clif_additem(ditem->first_sd,0,0,flag);
map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
}
- free(ditem);
+ aFree(ditem);
return 0;
}
map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
- free(ditem);
+ aFree(ditem);
return 0;
}
@@ -2219,71 +2223,71 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
}
md->hp-=damage;
-
+
if(md->class_ >= 1285 && md->class_ <=1287) { // guardian hp update [Valaris]
struct guild_castle *gc=guild_mapname2gc(map[md->bl.m].name);
if(gc) {
- if(md->bl.id==gc->GID0) {
+ if(md->bl.id==gc->GID0) {
gc->Ghp0=md->hp;
if(gc->Ghp0<=0) {
guild_castledatasave(gc->castle_id,10,0);
guild_castledatasave(gc->castle_id,18,0);
}
- }
- if(md->bl.id==gc->GID1) {
+ }
+ if(md->bl.id==gc->GID1) {
gc->Ghp1=md->hp;
if(gc->Ghp1<=0) {
guild_castledatasave(gc->castle_id,11,0);
guild_castledatasave(gc->castle_id,19,0);
}
}
- if(md->bl.id==gc->GID2) {
+ if(md->bl.id==gc->GID2) {
gc->Ghp2=md->hp;
if(gc->Ghp2<=0) {
guild_castledatasave(gc->castle_id,12,0);
guild_castledatasave(gc->castle_id,20,0);
}
}
- if(md->bl.id==gc->GID3) {
+ if(md->bl.id==gc->GID3) {
gc->Ghp3=md->hp;
if(gc->Ghp3<=0) {
guild_castledatasave(gc->castle_id,13,0);
guild_castledatasave(gc->castle_id,21,0);
}
}
- if(md->bl.id==gc->GID4) {
+ if(md->bl.id==gc->GID4) {
gc->Ghp4=md->hp;
if(gc->Ghp4<=0) {
guild_castledatasave(gc->castle_id,14,0);
guild_castledatasave(gc->castle_id,22,0);
}
}
- if(md->bl.id==gc->GID5) {
+ if(md->bl.id==gc->GID5) {
gc->Ghp5=md->hp;
if(gc->Ghp5<=0) {
guild_castledatasave(gc->castle_id,15,0);
guild_castledatasave(gc->castle_id,23,0);
}
}
- if(md->bl.id==gc->GID6) {
+ if(md->bl.id==gc->GID6) {
gc->Ghp6=md->hp;
if(gc->Ghp6<=0) {
guild_castledatasave(gc->castle_id,16,0);
guild_castledatasave(gc->castle_id,24,0);
}
}
- if(md->bl.id==gc->GID7) {
+ if(md->bl.id==gc->GID7) {
gc->Ghp7=md->hp;
if(gc->Ghp7<=0) {
guild_castledatasave(gc->castle_id,17,0);
guild_castledatasave(gc->castle_id,25,0);
-
+
}
}
}
} // end addition [Valaris]
-
+
if(md->option&2 )
skill_status_change_end(&md->bl, SC_HIDING, -1);
if(md->option&4 )
@@ -2291,7 +2295,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
if(md->state.special_mob_ai == 2){//スフィアーマイン
int skillidx=0;
-
+
if((skillidx=mob_skillid2skillidx(md->class_,NPC_SELFDESTRUCTION2))>=0){
md->mode |= 0x1;
md->next_walktime=tick;
@@ -2403,10 +2407,10 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
job_exp=mob_db[md->class_].job_exp*per/256;
if(job_exp < 1) job_exp = 1;
}
-
+
if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) {
base_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris]
- }
+ }
if(sd && battle_config.pk_mode && (mob_db[md->class_].lv - sd->status.base_level >= 20)) {
job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris]
}
@@ -2415,7 +2419,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
job_exp = 0;
}
else {
- if(battle_config.zeny_from_mobs) {
+ if(battle_config.zeny_from_mobs) {
if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris]
if(mob_db[md->class_].mexp > 0)
zeny*=rand()%250;
@@ -2425,7 +2429,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
base_exp+=((md->level-mob_db[md->class_].lv)*mob_db[md->class_].base_exp*.03)*per/256;
}
}
-
+
if((pid=tmpsd[i]->status.party_id)>0){ // パーティに入っている
int j=0;
for(j=0;j<pnum;j++) // 公平パーティリストにいるかどうか
@@ -2529,7 +2533,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
int race = battle_get_race(&md->bl);
if(sd->monster_drop_itemid[i] <= 0)
continue;
- if(sd->monster_drop_race[i] & (1<<race) ||
+ if(sd->monster_drop_race[i] & (1<<race) ||
(mob_db[md->class_].mode & 0x20 && sd->monster_drop_race[i] & 1<<10) ||
(!(mob_db[md->class_].mode & 0x20) && sd->monster_drop_race[i] & 1<<11) ) {
if(sd->monster_drop_itemrate[i] <= rand()%10000)
@@ -2572,7 +2576,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
int log_mvp[2] = {0};
int j;
int mexp;
- temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar]
+ temp = ((double)mob_db[md->class_].mexp * (9.+(double)count)/10.); //[Gengar]
mexp = (temp > 2147483647.)? 0x7fffffff:(int)temp;
if(mexp < 1) mexp = 1;
clif_mvp_effect(mvp_sd); // エフェクト
@@ -2617,7 +2621,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
if(md->npc_event[0] && strcmp(((md->npc_event)+strlen(md->npc_event)-13),"::OnAgitBreak") == 0) {
printf("MOB.C: Run NPC_Event[OnAgitBreak].\n");
if (agit_flag == 1) //Call to Run NPC_Event[OnAgitBreak]
- guild_agit_break(md);
+ guild_agit_break(md);
}
// SCRIPT実行
@@ -2665,7 +2669,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
int mob_class_change(struct mob_data *md,int *value)
{
unsigned int tick = gettick();
- int i,c,hp_rate,max_hp,class,count = 0;
+ int i,c,hp_rate,max_hp,class_,count = 0;
nullpo_retr(0, md);
nullpo_retr(0, value);
@@ -2677,13 +2681,13 @@ int mob_class_change(struct mob_data *md,int *value)
while(count < 5 && value[count] > 1000 && value[count] <= MAX_MOB_DB) count++;
if(count < 1) return 0;
- class = value[rand()%count];
- if(class<=1000 || class>MAX_MOB_DB) return 0;
+ class_ = value[rand()%count];
+ if(class_<=1000 || class_>MAX_MOB_DB) return 0;
max_hp = battle_get_max_hp(&md->bl);
hp_rate = md->hp*100/max_hp;
- clif_mob_class_change(md,class);
- md->class_ = class;
+ clif_mob_class_change(md,class_);
+ md->class_ = class_;
max_hp = battle_get_max_hp(&md->bl);
if(battle_config.monster_class_change_full_recover==1) {
md->hp = max_hp;
@@ -2694,7 +2698,7 @@ int mob_class_change(struct mob_data *md,int *value)
if(md->hp > max_hp) md->hp = max_hp;
else if(md->hp < 1) md->hp = 1;
- memcpy(md->name,mob_db[class].jname,24);
+ memcpy(md->name,mob_db[class_].jname,24);
memset(&md->state,0,sizeof(md->state));
md->attacked_id = 0;
md->target_id = 0;
@@ -2710,13 +2714,13 @@ int mob_class_change(struct mob_data *md,int *value)
md->next_walktime = tick+rand()%50+5000;
md->attackabletime = tick;
md->canmove_tick = tick;
-
+
for(i=0,c=tick-1000*3600*10;i<MAX_MOBSKILL;i++)
md->skilldelay[i] = c;
md->skillid=0;
md->skilllv=0;
- if(md->lootitem == NULL && mob_db[class].mode&0x02)
+ if(md->lootitem == NULL && mob_db[class_].mode&0x02)
md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
skill_clear_unitgroup(&md->bl);
@@ -2902,7 +2906,7 @@ int mob_countslave(struct mob_data *md)
int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag)
{
struct mob_data *md;
- int bx,by,m,count = 0,class,k,a = amount;
+ int bx,by,m,count = 0,class_,k,a = amount;
nullpo_retr(0, md2);
nullpo_retr(0, value);
@@ -2918,12 +2922,12 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag)
for(k=0;k<count;k++) {
amount = a;
- class = value[k];
- if(class<=1000 || class>MAX_MOB_DB) continue;
+ class_ = value[k];
+ if(class_<=1000 || class_>MAX_MOB_DB) continue;
for(;amount>0;amount--){
int x=0,y=0,i=0;
md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data));
- if(mob_db[class].mode&0x02)
+ if(mob_db[class_].mode&0x02)
md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
else
md->lootitem=NULL;
@@ -2937,7 +2941,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int flag)
y=by;
}
- mob_spawn_dataset(md,"--ja--",class);
+ mob_spawn_dataset(md,"--ja--",class_);
md->bl.m=m;
md->bl.x=x;
md->bl.y=y;
@@ -3018,15 +3022,15 @@ int mob_counttargeted(struct mob_data *md,struct block_list *src,int target_lv)
*MOBskillから該当skillidのskillidxを返す
*------------------------------------------
*/
-int mob_skillid2skillidx(int class,int skillid)
+int mob_skillid2skillidx(int class_,int skillid)
{
int i;
- struct mob_skill *ms=mob_db[class].skill;
-
+ struct mob_skill *ms=mob_db[class_].skill;
+
if(ms==NULL)
return -1;
- for(i=0;i<mob_db[class].maxskill;i++){
+ for(i=0;i<mob_db[class_].maxskill;i++){
if(ms[i].skill_id == skillid)
return i;
}
@@ -3144,7 +3148,7 @@ int mobskill_castend_pos( int tid, unsigned int tick, int id,int data )
return 0;
nullpo_retr(0, md=(struct mob_data *)bl);
-
+
if( md->bl.type!=BL_MOB || md->bl.prev==NULL )
return 0;
@@ -3259,7 +3263,7 @@ int mobskill_use_id(struct mob_data *md,struct block_list *target,int skill_idx)
nullpo_retr(0, md);
nullpo_retr(0, ms=&mob_db[md->class_].skill[skill_idx]);
-
+
if( target==NULL && (target=map_id2bl(md->target_id))==NULL )
return 0;
@@ -3692,10 +3696,10 @@ int mobskill_event(struct mob_data *md,int flag)
int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl)
{
struct mob_data *md=NULL;
-
+
nullpo_retr(0,sd);
nullpo_retr(0,bl);
-
+
if(bl->type==BL_MOB && (md=(struct mob_data *)bl) &&
(md->class_ == 1288 || md->class_ == 1287 || md->class_ == 1286 || md->class_ == 1285))
{
@@ -3712,7 +3716,7 @@ int mob_gvmobcheck(struct map_session_data *sd, struct block_list *bl)
return 0;//正規ギルド承認がないとダメージ無し
}
-
+
return 1;
}
/*==========================================
@@ -3739,53 +3743,53 @@ int mobskill_deltimer(struct mob_data *md )
* Since un-setting [ mob ] up was used, it is an initial provisional value setup.
*------------------------------------------
*/
-static int mob_makedummymobdb(int class)
+static int mob_makedummymobdb(int class_)
{
int i;
- sprintf(mob_db[class].name,"mob%d",class);
- sprintf(mob_db[class].jname,"mob%d",class);
- mob_db[class].lv=1;
- mob_db[class].max_hp=1000;
- mob_db[class].max_sp=1;
- mob_db[class].base_exp=2;
- mob_db[class].job_exp=1;
- mob_db[class].range=1;
- mob_db[class].atk1=7;
- mob_db[class].atk2=10;
- mob_db[class].def=0;
- mob_db[class].mdef=0;
- mob_db[class].str=1;
- mob_db[class].agi=1;
- mob_db[class].vit=1;
- mob_db[class].int_=1;
- mob_db[class].dex=6;
- mob_db[class].luk=2;
- mob_db[class].range2=10;
- mob_db[class].range3=10;
- mob_db[class].size=0;
- mob_db[class].race=0;
- mob_db[class].element=0;
- mob_db[class].mode=0;
- mob_db[class].speed=300;
- mob_db[class].adelay=1000;
- mob_db[class].amotion=500;
- mob_db[class].dmotion=500;
- mob_db[class].dropitem[0].nameid=909; // Jellopy
- mob_db[class].dropitem[0].p=1000;
+ sprintf(mob_db[class_].name,"mob%d",class_);
+ sprintf(mob_db[class_].jname,"mob%d",class_);
+ mob_db[class_].lv=1;
+ mob_db[class_].max_hp=1000;
+ mob_db[class_].max_sp=1;
+ mob_db[class_].base_exp=2;
+ mob_db[class_].job_exp=1;
+ mob_db[class_].range=1;
+ mob_db[class_].atk1=7;
+ mob_db[class_].atk2=10;
+ mob_db[class_].def=0;
+ mob_db[class_].mdef=0;
+ mob_db[class_].str=1;
+ mob_db[class_].agi=1;
+ mob_db[class_].vit=1;
+ mob_db[class_].int_=1;
+ mob_db[class_].dex=6;
+ mob_db[class_].luk=2;
+ mob_db[class_].range2=10;
+ mob_db[class_].range3=10;
+ mob_db[class_].size=0;
+ mob_db[class_].race=0;
+ mob_db[class_].element=0;
+ mob_db[class_].mode=0;
+ mob_db[class_].speed=300;
+ mob_db[class_].adelay=1000;
+ mob_db[class_].amotion=500;
+ mob_db[class_].dmotion=500;
+ mob_db[class_].dropitem[0].nameid=909; // Jellopy
+ mob_db[class_].dropitem[0].p=1000;
for(i=1;i<8;i++){
- mob_db[class].dropitem[i].nameid=0;
- mob_db[class].dropitem[i].p=0;
+ mob_db[class_].dropitem[i].nameid=0;
+ mob_db[class_].dropitem[i].p=0;
}
// Item1,Item2
- mob_db[class].mexp=0;
- mob_db[class].mexpper=0;
+ mob_db[class_].mexp=0;
+ mob_db[class_].mexpper=0;
for(i=0;i<3;i++){
- mob_db[class].mvpitem[i].nameid=0;
- mob_db[class].mvpitem[i].p=0;
+ mob_db[class_].mvpitem[i].nameid=0;
+ mob_db[class_].mvpitem[i].p=0;
}
for(i=0;i<MAX_RANDOMMONSTER;i++)
- mob_db[class].summonper[i]=0;
+ mob_db[class_].summonper[i]=0;
return 0;
}
@@ -3811,7 +3815,7 @@ static int mob_readdb(void)
return -1;
}
while(fgets(line,1020,fp)){
- int class,i;
+ int class_,i;
char *str[55],*p,*np;
if(line[0] == '/' && line[1] == '/')
@@ -3826,61 +3830,61 @@ static int mob_readdb(void)
str[i]=p;
}
- class=atoi(str[0]);
- if(class<=1000 || class>MAX_MOB_DB)
+ class_=atoi(str[0]);
+ if(class_<=1000 || class_>MAX_MOB_DB)
continue;
- mob_db[class].view_class=class;
- memcpy(mob_db[class].name,str[1],24);
- memcpy(mob_db[class].jname,str[2],24);
- mob_db[class].lv=atoi(str[3]);
- mob_db[class].max_hp=atoi(str[4]);
- mob_db[class].max_sp=atoi(str[5]);
-
- mob_db[class].base_exp=atoi(str[6]);
- if(mob_db[class].base_exp < 0)
- mob_db[class].base_exp = 0;
- else if(mob_db[class].base_exp > 0 && (mob_db[class].base_exp*battle_config.base_exp_rate/100 > 1000000000 ||
- mob_db[class].base_exp*battle_config.base_exp_rate/100 < 0))
- mob_db[class].base_exp=1000000000;
- else
- mob_db[class].base_exp*= battle_config.base_exp_rate/100;
-
- mob_db[class].job_exp=atoi(str[7]);
- if(mob_db[class].job_exp < 0)
- mob_db[class].job_exp = 0;
- else if(mob_db[class].job_exp > 0 && (mob_db[class].job_exp*battle_config.job_exp_rate/100 > 1000000000 ||
- mob_db[class].job_exp*battle_config.job_exp_rate/100 < 0))
- mob_db[class].job_exp=1000000000;
- else
- mob_db[class].job_exp*=battle_config.job_exp_rate/100;
-
- mob_db[class].range=atoi(str[8]);
- mob_db[class].atk1=atoi(str[9]);
- mob_db[class].atk2=atoi(str[10]);
- mob_db[class].def=atoi(str[11]);
- mob_db[class].mdef=atoi(str[12]);
- mob_db[class].str=atoi(str[13]);
- mob_db[class].agi=atoi(str[14]);
- mob_db[class].vit=atoi(str[15]);
- mob_db[class].int_=atoi(str[16]);
- mob_db[class].dex=atoi(str[17]);
- mob_db[class].luk=atoi(str[18]);
- mob_db[class].range2=atoi(str[19]);
- mob_db[class].range3=atoi(str[20]);
- mob_db[class].size=atoi(str[21]);
- mob_db[class].race=atoi(str[22]);
- mob_db[class].element=atoi(str[23]);
- mob_db[class].mode=atoi(str[24]);
- mob_db[class].speed=atoi(str[25]);
- mob_db[class].adelay=atoi(str[26]);
- mob_db[class].amotion=atoi(str[27]);
- mob_db[class].dmotion=atoi(str[28]);
+ mob_db[class_].view_class=class_;
+ memcpy(mob_db[class_].name,str[1],24);
+ memcpy(mob_db[class_].jname,str[2],24);
+ mob_db[class_].lv=atoi(str[3]);
+ mob_db[class_].max_hp=atoi(str[4]);
+ mob_db[class_].max_sp=atoi(str[5]);
+
+ mob_db[class_].base_exp=atoi(str[6]);
+ if(mob_db[class_].base_exp < 0)
+ mob_db[class_].base_exp = 0;
+ else if(mob_db[class_].base_exp > 0 && (mob_db[class_].base_exp*battle_config.base_exp_rate/100 > 1000000000 ||
+ mob_db[class_].base_exp*battle_config.base_exp_rate/100 < 0))
+ mob_db[class_].base_exp=1000000000;
+ else
+ mob_db[class_].base_exp*= battle_config.base_exp_rate/100;
+
+ mob_db[class_].job_exp=atoi(str[7]);
+ if(mob_db[class_].job_exp < 0)
+ mob_db[class_].job_exp = 0;
+ else if(mob_db[class_].job_exp > 0 && (mob_db[class_].job_exp*battle_config.job_exp_rate/100 > 1000000000 ||
+ mob_db[class_].job_exp*battle_config.job_exp_rate/100 < 0))
+ mob_db[class_].job_exp=1000000000;
+ else
+ mob_db[class_].job_exp*=battle_config.job_exp_rate/100;
+
+ mob_db[class_].range=atoi(str[8]);
+ mob_db[class_].atk1=atoi(str[9]);
+ mob_db[class_].atk2=atoi(str[10]);
+ mob_db[class_].def=atoi(str[11]);
+ mob_db[class_].mdef=atoi(str[12]);
+ mob_db[class_].str=atoi(str[13]);
+ mob_db[class_].agi=atoi(str[14]);
+ mob_db[class_].vit=atoi(str[15]);
+ mob_db[class_].int_=atoi(str[16]);
+ mob_db[class_].dex=atoi(str[17]);
+ mob_db[class_].luk=atoi(str[18]);
+ mob_db[class_].range2=atoi(str[19]);
+ mob_db[class_].range3=atoi(str[20]);
+ mob_db[class_].size=atoi(str[21]);
+ mob_db[class_].race=atoi(str[22]);
+ mob_db[class_].element=atoi(str[23]);
+ mob_db[class_].mode=atoi(str[24]);
+ mob_db[class_].speed=atoi(str[25]);
+ mob_db[class_].adelay=atoi(str[26]);
+ mob_db[class_].amotion=atoi(str[27]);
+ mob_db[class_].dmotion=atoi(str[28]);
for(i=0;i<8;i++){
int rate = 0,type,ratemin,ratemax;
- mob_db[class].dropitem[i].nameid=atoi(str[29+i*2]);
- type = itemdb_type(mob_db[class].dropitem[i].nameid);
+ mob_db[class_].dropitem[i].nameid=atoi(str[29+i*2]);
+ type = itemdb_type(mob_db[class_].dropitem[i].nameid);
if (type == 0) { // Added [Valaris]
rate = battle_config.item_rate_heal;
ratemin = battle_config.item_drop_heal_min;
@@ -3947,28 +3951,28 @@ static int mob_readdb(void)
}
rate = rate * atoi(str[30+i*2])/100;
rate = (rate < ratemin)? ratemin: (rate > ratemax)? ratemax: rate;
- mob_db[class].dropitem[i].p = rate;
+ mob_db[class_].dropitem[i].p = rate;
}
// Item1,Item2
- mob_db[class].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100;
- mob_db[class].mexpper=atoi(str[46]);
+ mob_db[class_].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100;
+ mob_db[class_].mexpper=atoi(str[46]);
for(i=0;i<3;i++){
- mob_db[class].mvpitem[i].nameid=atoi(str[47+i*2]);
- mob_db[class].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100;
+ mob_db[class_].mvpitem[i].nameid=atoi(str[47+i*2]);
+ mob_db[class_].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100;
}
for(i=0;i<MAX_RANDOMMONSTER;i++)
- mob_db[class].summonper[i]=0;
- mob_db[class].maxskill=0;
-
- mob_db[class].sex=0;
- mob_db[class].hair=0;
- mob_db[class].hair_color=0;
- mob_db[class].weapon=0;
- mob_db[class].shield=0;
- mob_db[class].head_top=0;
- mob_db[class].head_mid=0;
- mob_db[class].head_buttom=0;
- mob_db[class].clothes_color=0; //Add for player monster dye - Valaris
+ mob_db[class_].summonper[i]=0;
+ mob_db[class_].maxskill=0;
+
+ mob_db[class_].sex=0;
+ mob_db[class_].hair=0;
+ mob_db[class_].hair_color=0;
+ mob_db[class_].weapon=0;
+ mob_db[class_].shield=0;
+ mob_db[class_].head_top=0;
+ mob_db[class_].head_mid=0;
+ mob_db[class_].head_buttom=0;
+ mob_db[class_].clothes_color=0; //Add for player monster dye - Valaris
}
fclose(fp);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",filename[i]);
@@ -3986,7 +3990,7 @@ static int mob_readdb_mobavail(void)
FILE *fp;
char line[1024];
int ln=0;
- int class,j,k;
+ int class_,j,k;
char *str[20],*p,*np;
if( (fp=fopen("db/mob_avail.txt","r"))==NULL ){
@@ -4011,28 +4015,28 @@ static int mob_readdb_mobavail(void)
if(str[0]==NULL)
continue;
- class=atoi(str[0]);
+ class_=atoi(str[0]);
- if(class<=1000 || class>MAX_MOB_DB) // 値が異常なら処理しない。
+ if(class_<=1000 || class_>MAX_MOB_DB) // 値が異常なら処理しない。
continue;
k=atoi(str[1]);
if(k >= 0)
- mob_db[class].view_class=k;
-
- if((mob_db[class].view_class < 24) || (mob_db[class].view_class > 4000)) {
- mob_db[class].sex=atoi(str[2]);
- mob_db[class].hair=atoi(str[3]);
- mob_db[class].hair_color=atoi(str[4]);
- mob_db[class].weapon=atoi(str[5]);
- mob_db[class].shield=atoi(str[6]);
- mob_db[class].head_top=atoi(str[7]);
- mob_db[class].head_mid=atoi(str[8]);
- mob_db[class].head_buttom=atoi(str[9]);
- mob_db[class].option=atoi(str[10])&~0x46;
- mob_db[class].clothes_color=atoi(str[11]); // Monster player dye option - Valaris
+ mob_db[class_].view_class=k;
+
+ if((mob_db[class_].view_class < 24) || (mob_db[class_].view_class > 4000)) {
+ mob_db[class_].sex=atoi(str[2]);
+ mob_db[class_].hair=atoi(str[3]);
+ mob_db[class_].hair_color=atoi(str[4]);
+ mob_db[class_].weapon=atoi(str[5]);
+ mob_db[class_].shield=atoi(str[6]);
+ mob_db[class_].head_top=atoi(str[7]);
+ mob_db[class_].head_mid=atoi(str[8]);
+ mob_db[class_].head_buttom=atoi(str[9]);
+ mob_db[class_].option=atoi(str[10])&~0x46;
+ mob_db[class_].clothes_color=atoi(str[11]); // Monster player dye option - Valaris
}
- else if(atoi(str[2]) > 0) mob_db[class].equip=atoi(str[2]); // mob equipment [Valaris]
+ else if(atoi(str[2]) > 0) mob_db[class_].equip=atoi(str[2]); // mob equipment [Valaris]
ln++;
}
@@ -4066,7 +4070,7 @@ static int mob_read_randommonster(void)
return -1;
}
while(fgets(line,1020,fp)){
- int class,per;
+ int class_,per;
if(line[0] == '/' && line[1] == '/')
continue;
memset(str,0,sizeof(str));
@@ -4079,10 +4083,10 @@ static int mob_read_randommonster(void)
if(str[0]==NULL || str[2]==NULL)
continue;
- class = atoi(str[0]);
+ class_ = atoi(str[0]);
per=atoi(str[2]);
- if((class>1000 && class<=MAX_MOB_DB) || class==0)
- mob_db[class].summonper[i]=per;
+ if((class_>1000 && class_<=MAX_MOB_DB) || class_==0)
+ mob_db[class_].summonper[i]=per;
}
fclose(fp);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n",mobfile[i]);
@@ -4267,12 +4271,12 @@ void mob_reload(void)
static int mob_read_sqldb(void)
{
char line[1024];
- int i,class;
+ int i,class_;
long unsigned int ln=0;
char *str[55],*p,*np;
-
+
memset(mob_db,0,sizeof(mob_db));
-
+
sprintf (tmp_sql, "SELECT * FROM `%s`",mob_db_db);
if(mysql_query(&mmysql_handle, tmp_sql) ) {
printf("DB server Error (select %s to Memory)- %s\n",mob_db_db,mysql_error(&mmysql_handle) );
@@ -4301,53 +4305,53 @@ static int mob_read_sqldb(void)
} else
str[i]=p;
}
-
- class=atoi(str[0]);
- if(class<=1000 || class>MAX_MOB_DB)
+
+ class_=atoi(str[0]);
+ if(class_<=1000 || class_>MAX_MOB_DB)
continue;
-
+
ln++;
-
- mob_db[class].view_class=class;
- memcpy(mob_db[class].name,str[1],24);
- memcpy(mob_db[class].jname,str[2],24);
- mob_db[class].lv=atoi(str[3]);
- mob_db[class].max_hp=atoi(str[4]);
- mob_db[class].max_sp=atoi(str[5]);
- mob_db[class].base_exp=atoi(str[6])*
+
+ mob_db[class_].view_class=class_;
+ memcpy(mob_db[class_].name,str[1],24);
+ memcpy(mob_db[class_].jname,str[2],24);
+ mob_db[class_].lv=atoi(str[3]);
+ mob_db[class_].max_hp=atoi(str[4]);
+ mob_db[class_].max_sp=atoi(str[5]);
+ mob_db[class_].base_exp=atoi(str[6])*
battle_config.base_exp_rate/100;
- if(mob_db[class].base_exp <= 0)
- mob_db[class].base_exp = 1;
- mob_db[class].job_exp=atoi(str[7])*
+ if(mob_db[class_].base_exp <= 0)
+ mob_db[class_].base_exp = 1;
+ mob_db[class_].job_exp=atoi(str[7])*
battle_config.job_exp_rate/100;
- if(mob_db[class].job_exp <= 0)
- mob_db[class].job_exp = 1;
- mob_db[class].range=atoi(str[8]);
- mob_db[class].atk1=atoi(str[9]);
- mob_db[class].atk2=atoi(str[10]);
- mob_db[class].def=atoi(str[11]);
- mob_db[class].mdef=atoi(str[12]);
- mob_db[class].str=atoi(str[13]);
- mob_db[class].agi=atoi(str[14]);
- mob_db[class].vit=atoi(str[15]);
- mob_db[class].int_=atoi(str[16]);
- mob_db[class].dex=atoi(str[17]);
- mob_db[class].luk=atoi(str[18]);
- mob_db[class].range2=atoi(str[19]);
- mob_db[class].range3=atoi(str[20]);
- mob_db[class].size=atoi(str[21]);
- mob_db[class].race=atoi(str[22]);
- mob_db[class].element=atoi(str[23]);
- mob_db[class].mode=atoi(str[24]);
- mob_db[class].speed=atoi(str[25]);
- mob_db[class].adelay=atoi(str[26]);
- mob_db[class].amotion=atoi(str[27]);
- mob_db[class].dmotion=atoi(str[28]);
+ if(mob_db[class_].job_exp <= 0)
+ mob_db[class_].job_exp = 1;
+ mob_db[class_].range=atoi(str[8]);
+ mob_db[class_].atk1=atoi(str[9]);
+ mob_db[class_].atk2=atoi(str[10]);
+ mob_db[class_].def=atoi(str[11]);
+ mob_db[class_].mdef=atoi(str[12]);
+ mob_db[class_].str=atoi(str[13]);
+ mob_db[class_].agi=atoi(str[14]);
+ mob_db[class_].vit=atoi(str[15]);
+ mob_db[class_].int_=atoi(str[16]);
+ mob_db[class_].dex=atoi(str[17]);
+ mob_db[class_].luk=atoi(str[18]);
+ mob_db[class_].range2=atoi(str[19]);
+ mob_db[class_].range3=atoi(str[20]);
+ mob_db[class_].size=atoi(str[21]);
+ mob_db[class_].race=atoi(str[22]);
+ mob_db[class_].element=atoi(str[23]);
+ mob_db[class_].mode=atoi(str[24]);
+ mob_db[class_].speed=atoi(str[25]);
+ mob_db[class_].adelay=atoi(str[26]);
+ mob_db[class_].amotion=atoi(str[27]);
+ mob_db[class_].dmotion=atoi(str[28]);
for(i=0;i<8;i++){
int rate = 0,type,ratemin,ratemax;
- mob_db[class].dropitem[i].nameid=atoi(str[29+i*2]);
- type = itemdb_type(mob_db[class].dropitem[i].nameid);
+ mob_db[class_].dropitem[i].nameid=atoi(str[29+i*2]);
+ type = itemdb_type(mob_db[class_].dropitem[i].nameid);
if (type == 0) { // Added by Valaris
rate = battle_config.item_rate_heal;
ratemin = battle_config.item_drop_heal_min;
@@ -4375,27 +4379,27 @@ static int mob_read_sqldb(void)
}
rate = (rate / 100) * atoi(str[30+i*2]);
rate = (rate < ratemin)? ratemin: (rate > ratemax)? ratemax: rate;
- mob_db[class].dropitem[i].p = rate;
+ mob_db[class_].dropitem[i].p = rate;
}
-
- mob_db[class].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100;
- mob_db[class].mexpper=atoi(str[46]);
+
+ mob_db[class_].mexp=atoi(str[45])*battle_config.mvp_exp_rate/100;
+ mob_db[class_].mexpper=atoi(str[46]);
for(i=0;i<3;i++){
- mob_db[class].mvpitem[i].nameid=atoi(str[47+i*2]);
- mob_db[class].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100;
+ mob_db[class_].mvpitem[i].nameid=atoi(str[47+i*2]);
+ mob_db[class_].mvpitem[i].p=atoi(str[48+i*2])*battle_config.mvp_item_rate/100;
}
for(i=0;i<MAX_RANDOMMONSTER;i++)
- mob_db[class].summonper[i]=0;
- mob_db[class].maxskill=0;
-
- mob_db[class].sex=0;
- mob_db[class].hair=0;
- mob_db[class].hair_color=0;
- mob_db[class].weapon=0;
- mob_db[class].shield=0;
- mob_db[class].head_top=0;
- mob_db[class].head_mid=0;
- mob_db[class].head_buttom=0;
+ mob_db[class_].summonper[i]=0;
+ mob_db[class_].maxskill=0;
+
+ mob_db[class_].sex=0;
+ mob_db[class_].hair=0;
+ mob_db[class_].hair_color=0;
+ mob_db[class_].weapon=0;
+ mob_db[class_].shield=0;
+ mob_db[class_].head_top=0;
+ mob_db[class_].head_mid=0;
+ mob_db[class_].head_buttom=0;
}
mysql_free_result(sql_res);
sprintf(tmp_output,"Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",ln,mob_db_db);
@@ -4414,7 +4418,7 @@ int do_init_mob(void)
#ifndef TXT_ONLY
if(db_use_sqldbs)
mob_read_sqldb();
- else
+ else
#endif /* TXT_ONLY */
mob_readdb();
diff --git a/src/map/mob.h b/src/map/mob.h
index da5725104..0f65b1404 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -83,13 +83,13 @@ enum {
int mobdb_searchname(const char *str);
int mobdb_checkid(const int id);
int mob_once_spawn(struct map_session_data *sd,char *mapname,
- int x,int y,const char *mobname,int class,int amount,const char *event);
+ int x,int y,const char *mobname,int class_,int amount,const char *event);
int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
int x0,int y0,int x1,int y1,
- const char *mobname,int class,int amount,const char *event);
+ const char *mobname,int class_,int amount,const char *event);
int mob_spawn_guardian(struct map_session_data *sd,char *mapname, // Spawning Guardians [Valaris]
- int x,int y,const char *mobname,int class,int amount,const char *event,int guardian); // Spawning Guardians [Valaris]
+ int x,int y,const char *mobname,int class_,int amount,const char *event,int guardian); // Spawning Guardians [Valaris]
int mob_walktoxy(struct mob_data *md,int x,int y,int easy);
diff --git a/src/map/npc.c b/src/map/npc.c
index 0186fe6de..6fd630fd5 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -68,7 +68,7 @@ int npc_enable_sub( struct block_list *bl, va_list ap )
{
struct map_session_data *sd;
struct npc_data *nd;
- char *name=(char *)aCalloc(50,sizeof(char));
+ char *name=(char *)aCallocA(50,sizeof(char));
nullpo_retr(0, bl);
nullpo_retr(0, ap);
@@ -84,7 +84,7 @@ int npc_enable_sub( struct block_list *bl, va_list ap )
sd->areanpc_id=nd->bl.id;
npc_event(sd,strcat(name,"::OnTouch"),0);
}
- free(name);
+ aFree(name);
return 0;
}
int npc_enable(const char *name,int flag)
@@ -92,7 +92,7 @@ int npc_enable(const char *name,int flag)
struct npc_data *nd=strdb_search(npcname_db,name);
if (nd==NULL)
return 0;
-
+
if (flag&1) { // 有効化
nd->flag&=~1;
clif_spawnnpc(nd);
@@ -132,7 +132,7 @@ int npc_event_dequeue(struct map_session_data *sd)
sd->npc_id=0;
if (sd->eventqueue[0][0]) { // キューのイベント処理
- char *name=(char *)aCalloc(50,sizeof(char));
+ char *name=(char *)aCallocA(50,sizeof(char));
int i;
memcpy(name,sd->eventqueue[0],50);
@@ -164,9 +164,9 @@ int npc_event_timer(int tid,unsigned int tick,int id,int data)
struct map_session_data *sd=map_id2sd(id);
if (sd==NULL)
return 0;
-
+
npc_event(sd,(const char *)data,0);
- free((void*)data);
+ aFree((void*)data);
return 0;
}
@@ -226,7 +226,7 @@ int npc_timer(int tid,unsigned int tick,int id,int data) // Added by RoVeRT
{
strdb_foreach(npcname_db,npc_timer_sub);
- free((void*)data);
+ aFree((void*)data);
return 0;
}*/
/*==========================================
@@ -239,14 +239,14 @@ int npc_event_export(void *key,void *data,va_list ap)
char *lname=(char *)key;
int pos=(int)data;
struct npc_data *nd=va_arg(ap,struct npc_data *);
-
+
if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) {
struct event_data *ev;
char *buf;
char *p=strchr(lname,':');
// エクスポートされる
ev=aCalloc(sizeof(struct event_data), 1);
- buf=aCalloc(50, 1);
+ buf=aCallocA(50, 1);
if (ev==NULL || buf==NULL) {
printf("npc_event_export: out of memory !\n");
exit(1);
@@ -344,17 +344,17 @@ int npc_event_doall_sub(void *key,void *data,va_list ap)
run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id);
(*c)++;
}
-
+
return 0;
}
int npc_event_doall(const char *name)
{
int c=0;
char buf[64]="::";
-
+
strncpy(buf+2,name,62);
strdb_foreach(ev_db,npc_event_doall_sub,&c,buf);
- return c;
+ return c;
}
int npc_event_do_sub(void *key,void *data,va_list ap)
@@ -380,7 +380,7 @@ int npc_event_do_sub(void *key,void *data,va_list ap)
int npc_event_do(const char *name)
{
int c=0;
-
+
if (*name==':' && name[1]==':') {
return npc_event_doall(name+2);
}
@@ -400,7 +400,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data)
char buf[64];
char *day="";
int c=0;
-
+
time(&timer);
t=localtime(&timer);
@@ -413,7 +413,7 @@ int npc_event_do_clock(int tid,unsigned int tick,int id,int data)
case 5: day = "Fri"; break;
case 6: day = "Sat"; break;
}
-
+
if (t->tm_min != ev_tm_b.tm_min ) {
sprintf(buf,"OnMinute%02d",t->tm_min);
c+=npc_event_doall(buf);
@@ -460,7 +460,7 @@ int npc_addeventtimer(struct npc_data *nd,int tick,const char *name)
if( nd->eventtimer[i]==-1 )
break;
if(i<MAX_EVENTTIMER){
- char *evname=aMalloc(24);
+ char *evname=aMallocA(24);
if(evname==NULL){
printf("npc_addeventtimer: out of memory !\n");exit(1);
}
@@ -541,12 +541,12 @@ int npc_timerevent_import(void *key,void *data,va_list ap)
int pos=(int)data;
struct npc_data *nd=va_arg(ap,struct npc_data *);
int t=0,i=0;
-
+
if(sscanf(lname,"OnTimer%d%n",&t,&i)==1 && lname[i]==':') {
// タイマーイベント
struct npc_timerevent_list *te=nd->u.scr.timer_event;
int j,i=nd->u.scr.timeramount;
- if(te==NULL) te=aMalloc(sizeof(struct npc_timerevent_list));
+ if(te==NULL) te=aMallocA(sizeof(struct npc_timerevent_list));
else te=aRealloc( te, sizeof(struct npc_timerevent_list) * (i+1) );
if(te==NULL){
printf("npc_timerevent_import: out of memory !\n");
@@ -581,7 +581,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data)
nd->u.scr.timertick=tick;
te=nd->u.scr.timer_event+ nd->u.scr.nexttimer;
nd->u.scr.timerid = -1;
-
+
t = nd->u.scr.timer+=data;
nd->u.scr.nexttimer++;
if( nd->u.scr.timeramount>nd->u.scr.nexttimer ){
@@ -605,7 +605,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid)
n=nd->u.scr.timeramount;
if( nd->u.scr.nexttimer>=0 || n==0 )
return 0;
-
+
for(j=0;j<n;j++){
if( nd->u.scr.timer_event[j].timer > nd->u.scr.timer )
break;
@@ -617,7 +617,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid)
nd->u.scr.timertick=gettick();
if (rid >= 0) nd->u.scr.rid=rid; // changed to: attaching to given rid by default [Shinomori]
// if rid is less than 0 leave it unchanged [celest]
-
+
next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer;
nd->u.scr.timerid = add_timer(gettick()+next,npc_timerevent,nd->bl.id,next);
return 0;
@@ -743,7 +743,7 @@ int npc_event(struct map_session_data *sd,const char *eventname,int mob_kill)
npc_event_dequeue(sd);
return 0;
}
-
+
sd->npc_id=nd->bl.id;
sd->npc_pos=run_script(nd->u.scr.script,ev->pos,sd->bl.id,nd->bl.id);
return 0;
@@ -764,7 +764,7 @@ int npc_command_sub(void *key,void *data,va_list ap)
if (strcmp(command,temp)==0)
run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id);
}
-
+
return 0;
}
@@ -793,7 +793,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
f=0;
continue;
}
-
+
switch(map[m].npc[i]->bl.subtype) {
case WARP:
xs=map[m].npc[i]->u.warp.xs;
@@ -824,7 +824,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
break;
case SCRIPT:
{
- char *name=(char *)aCalloc(50,sizeof(char));
+ char *name=(char *)aCallocA(50,sizeof(char));
memcpy(name,map[m].npc[i]->name,50);
if(sd->areanpc_id==map[m].npc[i]->bl.id)
@@ -832,7 +832,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
sd->areanpc_id=map[m].npc[i]->bl.id;
if(npc_event(sd,strcat(name,"::OnTouch"),0)>0)
npc_click(sd,map[m].npc[i]->bl.id);
- free(name);
+ aFree(name);
break;
}
}
@@ -855,7 +855,7 @@ int npc_checknear(struct map_session_data *sd,int id)
printf("no such npc : %d\n",id);
return 1;
}
-
+
if (nd->class_<0) // イベント系は常にOK
return 0;
@@ -968,7 +968,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
{
struct npc_data *nd;
double z;
- int i,j,w,skill,itemamount=0,new=0;
+ int i,j,w,skill,itemamount=0,new_=0;
nullpo_retr(3, sd);
nullpo_retr(3, item_list);
@@ -998,7 +998,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
case ADDITEM_EXIST:
break;
case ADDITEM_NEW:
- new++;
+ new_++;
break;
case ADDITEM_OVERAMOUNT:
return 2;
@@ -1010,7 +1010,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
return 1; // zeny不足
if (w+sd->weight > sd->max_weight)
return 2; // 重量超過
- if (pc_inventoryblank(sd)<new)
+ if (pc_inventoryblank(sd)<new_)
return 3; // 種類数超過
pc_payzeny(sd,(int)z);
@@ -1192,7 +1192,7 @@ static int npc_walk(struct npc_data *nd,unsigned int tick,int data)
if(nd->walkpath.path_pos>=nd->walkpath.path_len)
clif_fixnpcpos(nd); // When npc stops, retransmission current of a position.
-
+
}
return 0;
}
@@ -1237,7 +1237,7 @@ static int npc_walktimer(int tid,unsigned int tick,int id,int data)
if(nd->walktimer != tid){
return 0;
}
-
+
nd->walktimer=-1;
if(nd->bl.prev == NULL)
@@ -1302,7 +1302,7 @@ int npc_stop_walking(struct npc_data *nd,int type)
if(nd->state.state == MS_WALK || nd->state.state == MS_IDLE) {
int dx=0,dy=0;
-
+
nd->walkpath.path_len=0;
if(type&4){
dx=nd->to_x-nd->bl.x;
@@ -1352,7 +1352,7 @@ void npc_clearsrcfile()
while( p ) {
struct npc_src_list *p2=p;
p=p->next;
- free(p2);
+ aFree(p2);
}
npc_src_first=NULL;
npc_src_last=NULL;
@@ -1363,7 +1363,7 @@ void npc_clearsrcfile()
*/
void npc_addsrcfile(char *name)
{
- struct npc_src_list *new;
+ struct npc_src_list *new_;
size_t len;
if ( strcmpi(name,"clear")==0 ) {
@@ -1382,16 +1382,16 @@ void npc_addsrcfile(char *name)
}
}
- len = sizeof(*new) + strlen(name);
- new=(struct npc_src_list *)aCalloc(1,len);
- new->next = NULL;
- strncpy(new->name,name,strlen(name)+1);
+ len = sizeof(*new_) + strlen(name);
+ new_=(struct npc_src_list *)aCalloc(1,len);
+ new_->next = NULL;
+ strncpy(new_->name,name,strlen(name)+1);
if (npc_src_first==NULL)
- npc_src_first = new;
+ npc_src_first = new_;
if (npc_src_last)
- npc_src_last->next = new;
+ npc_src_last->next = new_;
- npc_src_last=new;
+ npc_src_last=new_;
}
/*==========================================
* 読み込むnpcファイルの削除
@@ -1411,7 +1411,7 @@ void npc_delsrcfile(char *name)
*lp=p->next;
if ( npc_src_last==p )
npc_src_last=pp;
- free(p);
+ aFree(p);
break;
}
}
@@ -1525,7 +1525,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4)
p=strchr(p,',');
}
if (pos == 0) {
- free(nd);
+ aFree(nd);
return 1;
}
nd->u.shop_item[pos++].nameid = 0;
@@ -1545,7 +1545,7 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4)
nd->opt1 = 0;
nd->opt2 = 0;
nd->opt3 = 0;
-
+
nd = (struct npc_data *)aRealloc(nd,
sizeof(struct npc_data) + sizeof(nd->u.shop_item[0]) * pos);
@@ -1572,14 +1572,14 @@ int npc_convertlabel_db(void *key,void *data,va_list ap)
struct npc_label_list *lst;
int num;
char *p=strchr(lname,':');
-
+
nullpo_retr(0, ap);
nullpo_retr(0, nd=va_arg(ap,struct npc_data *));
lst=nd->u.scr.label_list;
num=nd->u.scr.label_list_num;
if(!lst){
- lst=(struct npc_label_list *)aCalloc(1,sizeof(struct npc_label_list));
+ lst=(struct npc_label_list *)aCallocA(1,sizeof(struct npc_label_list));
num=0;
}else
lst=(struct npc_label_list *)aRealloc(lst,sizeof(struct npc_label_list)*(num+1));
@@ -1598,7 +1598,7 @@ int npc_convertlabel_db(void *key,void *data,va_list ap)
*/
static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines)
{
- int x,y,dir=0,m,xs=0,ys=0,class=0; // [Valaris] thanks to fov
+ int x,y,dir=0,m,xs=0,ys=0,class_=0; // [Valaris] thanks to fov
char mapname[24];
unsigned char *srcbuf=NULL,*script;
int srcsize=65536;
@@ -1627,7 +1627,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
if(strcmp(w2,"script")==0){
// スクリプトの解析
- srcbuf=(char *)aCalloc(srcsize,sizeof(char));
+ srcbuf=(char *)aCallocA(srcsize,sizeof(char));
if (strchr(first_line,'{')) {
strcpy(srcbuf,strchr(first_line,'{'));
startline=*lines;
@@ -1657,13 +1657,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
script=parse_script(srcbuf,startline);
if (script==NULL) {
// script parse error?
- free(srcbuf);
+ aFree(srcbuf);
return 1;
}
}else{
// duplicateする
-
+
char srcname[128];
struct npc_data *nd2;
if( sscanf(w2,"duplicate(%[^)])",srcname)!=1 ){
@@ -1678,22 +1678,22 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
label_dup=nd2->u.scr.label_list;
label_dupnum=nd2->u.scr.label_list_num;
src_id=nd2->bl.id;
-
+
}// end of スクリプト解析
nd=(struct npc_data *)aCalloc(1,sizeof(struct npc_data));
if(m==-1){
// スクリプトコピー用のダミーNPC
-
- }else if( sscanf(w4,"%d,%d,%d",&class,&xs,&ys)==3) {
+
+ }else if( sscanf(w4,"%d,%d,%d",&class_,&xs,&ys)==3) {
// 接触型NPC
int i,j;
-
+
if (xs>=0)xs=xs*2+1;
if (ys>=0)ys=ys*2+1;
-
- if (class>=0) {
+
+ if (class_>=0) {
for(i=0;i<ys;i++) {
for(j=0;j<xs;j++) {
@@ -1703,16 +1703,16 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
}
}
}
-
+
nd->u.scr.xs=xs;
nd->u.scr.ys=ys;
} else { // クリック型NPC
- class=atoi(w4);
+ class_=atoi(w4);
nd->u.scr.xs=0;
nd->u.scr.ys=0;
}
-
- if (class<0 && m>=0) { // イベント型NPC
+
+ if (class_<0 && m>=0) { // イベント型NPC
evflag=1;
}
@@ -1735,7 +1735,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
nd->bl.id=npc_get_new_npc_id();
nd->dir = dir;
nd->flag=0;
- nd->class_=class;
+ nd->class_=class_;
nd->speed=200;
nd->u.scr.script=script;
nd->u.scr.src_id=src_id;
@@ -1766,21 +1766,21 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
//-----------------------------------------
- // ラベルデータの準備
+ // ラベルデータの準備
if(srcbuf){
// script本体がある場合の処理
-
+
// ラベルデータのコンバート
label_db=script_get_label_db();
strdb_foreach(label_db,npc_convertlabel_db,nd);
-
+
// もう使わないのでバッファ解放
- free(srcbuf);
+ aFree(srcbuf);
}else{
// duplicate
-// nd->u.scr.label_list=aMalloc(sizeof(struct npc_label_list)*label_dupnum);
+// nd->u.scr.label_list=aMallocA(sizeof(struct npc_label_list)*label_dupnum);
// memcpy(nd->u.scr.label_list,label_dup,sizeof(struct npc_label_list)*label_dupnum);
nd->u.scr.label_list=label_dup; // ラベルデータ共有
@@ -1792,13 +1792,13 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
for(i=0;i<nd->u.scr.label_list_num;i++){
char *lname=nd->u.scr.label_list[i].name;
int pos=nd->u.scr.label_list[i].pos;
-
+
if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) {
struct event_data *ev;
char *buf;
// エクスポートされる
ev=(struct event_data *)aCalloc(1,sizeof(struct event_data));
- buf=(char *)aCalloc(50,sizeof(char));
+ buf=(char *)aCallocA(50,sizeof(char));
if (strlen(lname)>24) {
printf("npc_parse_script: label name error !\n");
exit(1);
@@ -1810,7 +1810,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
}
}
}
-
+
//-----------------------------------------
// ラベルデータからタイマーイベント取り込み
for(i=0;i<nd->u.scr.label_list_num;i++){
@@ -1822,7 +1822,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
struct npc_timerevent_list *te=nd->u.scr.timer_event;
int j,k=nd->u.scr.timeramount;
if(te==NULL)
- te=(struct npc_timerevent_list *)aCalloc(1,sizeof(struct npc_timerevent_list));
+ te=(struct npc_timerevent_list *)aCallocA(1,sizeof(struct npc_timerevent_list));
else
te=(struct npc_timerevent_list *)aRealloc( te, sizeof(struct npc_timerevent_list) * (k+1) );
for(j=0;j<k;j++){
@@ -1840,7 +1840,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
nd->u.scr.nexttimer=-1;
nd->u.scr.timerid=-1;
-
+
return 0;
}
@@ -1859,7 +1859,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li
char *p;
// スクリプトの解析
- srcbuf=(char *)aCalloc(srcsize,sizeof(char));
+ srcbuf=(char *)aCallocA(srcsize,sizeof(char));
if (strchr(first_line,'{')) {
strcpy(srcbuf,strchr(first_line,'{'));
startline=*lines;
@@ -1889,11 +1889,11 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li
script=parse_script(srcbuf,startline);
if (script==NULL) {
// script parse error?
- free(srcbuf);
+ aFree(srcbuf);
return 1;
}
- p=(char *)aCalloc(50,sizeof(char));
+ p=(char *)aCallocA(50,sizeof(char));
strncpy(p,w3,50);
strdb_insert(script_get_userfunc_db(),p,script);
@@ -1901,10 +1901,10 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li
// label_db=script_get_label_db();
// もう使わないのでバッファ解放
- free(srcbuf);
-
+ aFree(srcbuf);
+
// printf("function %s => %p\n",p,script);
-
+
return 0;
}
@@ -1915,7 +1915,7 @@ static int npc_parse_function(char *w1,char *w2,char *w3,char *w4,char *first_li
*/
int npc_parse_mob(char *w1,char *w2,char *w3,char *w4)
{
- int m,x,y,xs,ys,class,num,delay1,delay2,level;
+ int m,x,y,xs,ys,class_,num,delay1,delay2,level;
int i;
char mapname[24];
char mobname[24];
@@ -1926,7 +1926,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4)
delay1=delay2=0;
// 引数の個数チェック
if (sscanf(w1,"%[^,],%d,%d,%d,%d",mapname,&x,&y,&xs,&ys) < 3 ||
- sscanf(w4,"%d,%d,%d,%d,%s",&class,&num,&delay1,&delay2,eventname) < 2 ) {
+ sscanf(w4,"%d,%d,%d,%d,%s",&class_,&num,&delay1,&delay2,eventname) < 2 ) {
printf("bad monster line : %s\n",w3);
return 1;
}
@@ -1941,13 +1941,13 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4)
for(i=0;i<num;i++) {
md=(struct mob_data *)aCalloc(1,sizeof(struct mob_data));
- if(class>4000) { // large/tiny mobs [Valaris]
+ if(class_>4000) { // large/tiny mobs [Valaris]
md->size=2;
- class-=4000;
+ class_-=4000;
}
- else if(class>2000) {
+ else if(class_>2000) {
md->size=1;
- class-=2000;
+ class_-=2000;
}
md->bl.prev=NULL;
@@ -1958,9 +1958,9 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4)
if(sscanf(w3,"%[^,],%d",mobname,&level) > 1) {
if(strcmp(mobname,"--en--")==0)
- memcpy(md->name,mob_db[class].name,24);
+ memcpy(md->name,mob_db[class_].name,24);
else if(strcmp(mobname,"--ja--")==0)
- memcpy(md->name,mob_db[class].jname,24);
+ memcpy(md->name,mob_db[class_].jname,24);
md->level=level;
}
@@ -1968,7 +1968,7 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4)
memcpy(md->name,w3,24);
md->n = i;
- md->base_class = md->class_ = class;
+ md->base_class = md->class_ = class_;
md->bl.id=npc_get_new_npc_id();
md->m =m;
md->x0=x;
@@ -1982,9 +1982,9 @@ int npc_parse_mob(char *w1,char *w2,char *w3,char *w4)
md->timer = -1;
md->target_id=0;
md->attacked_id=0;
- md->speed=mob_db[class].speed;
+ md->speed=mob_db[class_].speed;
- if (mob_db[class].mode&0x02)
+ if (mob_db[class_].mode&0x02)
md->lootitem=(struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
else
md->lootitem=NULL;
@@ -2122,19 +2122,19 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4)
}
else if (strcmpi(w3,"noicewall")==0) { // noicewall [Valaris]
map[m].flag.noicewall=1;
- }
+ }
else if (strcmpi(w3,"snow")==0) { // snow [Valaris]
map[m].flag.snow=1;
- }
+ }
else if (strcmpi(w3,"fog")==0) { // fog [Valaris]
map[m].flag.fog=1;
- }
+ }
else if (strcmpi(w3,"sakura")==0) { // sakura [Valaris]
map[m].flag.sakura=1;
- }
+ }
else if (strcmpi(w3,"leaves")==0) { // leaves [Valaris]
map[m].flag.leaves=1;
- }
+ }
else if (strcmpi(w3,"rain")==0) { // rain [Valaris]
map[m].flag.rain=1;
}
@@ -2144,7 +2144,7 @@ static int npc_parse_mapflag(char *w1,char *w2,char *w3,char *w4)
else if (strcmpi(w3,"nogo")==0) { // celest
map[m].flag.nogo=1;
}
-
+
return 0;
}
@@ -2169,12 +2169,12 @@ static int npc_read_indoors(void)
if ((m = map_mapname2mapid(map_name)) >= 0)
map[m].flag.indoors=1;
}
-
+
p=strchr(p,10);
if(!p) break;
p++;
}
- free(buf);
+ aFree(buf);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\indoorrswtable.txt");
ShowStatus(tmp_output);
@@ -2183,9 +2183,9 @@ static int npc_read_indoors(void)
static int ev_db_final(void *key,void *data,va_list ap)
{
- free(data);
+ aFree(data);
if(strstr(key,"::")!=NULL)
- free(key);
+ aFree(key);
return 0;
}
static int npcname_db_final(void *key,void *data,va_list ap)
@@ -2214,49 +2214,49 @@ int do_final_npc(void)
if((bl=map_id2bl(i))){
if(bl->type == BL_NPC && (nd = (struct npc_data *)bl)){
if(nd->chat_id && (cd=(struct chat_data*)map_id2bl(nd->chat_id))){
- free(cd);
+ aFree(cd);
cd = NULL;
}
if(nd->bl.subtype == SCRIPT){
if(nd->u.scr.timer_event)
- free(nd->u.scr.timer_event);
+ aFree(nd->u.scr.timer_event);
if(nd->u.scr.src_id==0){
if(nd->u.scr.script){
- free(nd->u.scr.script);
+ aFree(nd->u.scr.script);
nd->u.scr.script=NULL;
}
if(nd->u.scr.label_list){
- free(nd->u.scr.label_list);
+ aFree(nd->u.scr.label_list);
nd->u.scr.label_list = NULL;
}
}
}
- free(nd);
+ aFree(nd);
nd = NULL;
}else if(bl->type == BL_MOB && (md = (struct mob_data *)bl)){
if(md->lootitem){
- free(md->lootitem);
+ aFree(md->lootitem);
md->lootitem = NULL;
}
- free(md);
+ aFree(md);
md = NULL;
}else if(bl->type == BL_PET && (pd = (struct pet_data *)bl)){
- free(pd);
+ aFree(pd);
pd = NULL;
}
}
}
-
+
return 0;
}
-void ev_release(struct dbn *db, int which)
+void ev_release(struct dbn *db, int which)
{
if (which & 0x1)
- free(db->key);
+ aFree(db->key);
if (which & 0x2)
- free(db->data);
+ aFree(db->data);
}
/*==========================================
@@ -2281,12 +2281,12 @@ int do_init_npc(void)
npcname_db=strdb_init(24);
ev_db->release = ev_release;
-
+
memset(&ev_tm_b,-1,sizeof(ev_tm_b));
for(nsl=npc_src_first;nsl;nsl=nsl->next) {
/*if(nsl->prev){ // [Shinomori]
- free(nsl->prev);
+ aFree(nsl->prev);
nsl->prev = NULL;
}*/
fp=fopen(nsl->name,"r");
diff --git a/src/map/party.c b/src/map/party.c
index 28f05bab9..3c3c12886 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -30,7 +30,7 @@ int party_send_xyhp_timer(int tid,unsigned int tick,int id,int data);
*/
static int party_db_final(void *key,void *data,va_list ap)
{
- free(data);
+ aFree(data);
return 0;
}
void do_final_party(void)
diff --git a/src/map/pc.c b/src/map/pc.c
index 2954dfddf..c17e8677b 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -87,11 +87,11 @@ int pc_isGM(struct map_session_data *sd) {
if (p == NULL)
return 0;
return p->level;*/
-
+
//For console [Wizputer]
if ( sd->fd == 0 )
return 99;
-
+
for(i = 0; i < GM_num; i++)
if (gm_account[i].account_id == sd->status.account_id)
return gm_account[i].level;
@@ -218,7 +218,7 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) {
sd->spiritball = 0;
if(sd->spiritball >= max) {
- if(sd->spirit_timer[0] != -1)
+ if(sd->spirit_timer[0] != -1)
delete_timer(sd->spirit_timer[0],pc_spiritball_timer);
memcpy( &sd->spirit_timer[0], &sd->spirit_timer[1], sizeof(sd->spirit_timer[0]) * (sd->spiritball - 1));
} else
@@ -554,7 +554,7 @@ int pc_isequip(struct map_session_data *sd,int n)
item = sd->inventory_data[n];
sc_data = battle_get_sc_data(&sd->bl);
- //s_class = pc_calc_base_job(sd->status.class);
+ //s_class = pc_calc_base_job(sd->status.class_);
if( battle_config.gm_allequip>0 && pc_isGM(sd)>=battle_config.gm_allequip )
return 1;
@@ -599,7 +599,7 @@ int pc_break_equip(struct map_session_data *sd, unsigned short where)
struct item_data* item;
int i;
int sc;
- char output[255];
+ char output[255];
if(sd == NULL)
return -1;
@@ -669,7 +669,7 @@ int pc_breakweapon(struct map_session_data *sd)
return 1;
}
}
-
+
return 0;
}
/*==========================================
@@ -755,7 +755,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars
sd->skillitem = -1;
sd->skillitemlv = -1;
sd->invincible_timer = -1;
-
+
sd->deal_locked = 0;
sd->trade_partner = 0;
@@ -772,7 +772,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars
sd->doridori_counter = 0;
- sd->change_level = pc_readglobalreg(sd,"jobchange_level");
+ sd->change_level = pc_readglobalreg(sd,"jobchange_level");
#ifndef TXT_ONLY // mail system [Valaris]
if(battle_config.mail_system)
@@ -790,7 +790,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars
sd->dev.val1[i] = 0;
sd->dev.val2[i] = 0;
}
-
+
// アカウント??の送信要求
intif_request_accountreg(sd);
@@ -876,7 +876,7 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, struct mmo_chars
sd->state.event_death = pc_readglobalreg(sd,"PCDieEvent");
sd->state.event_kill = pc_readglobalreg(sd,"PCKillEvent");
sd->state.event_disconnect = pc_readglobalreg(sd,"PCLogoffEvent");
-
+
if (night_flag == 1 && !map[sd->bl.m].flag.indoors) {
char tmpstr[1024];
strcpy(tmpstr, msg_txt(500)); // Actually, it's the night...
@@ -1016,7 +1016,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
for(i=0;i<MAX_SKILL;i++){
// if(skill_get_inf2(i) & 0x01)
// continue;
- if (sd->status.skill[i].flag != 13)
+ if (sd->status.skill[i].flag != 13)
sd->status.skill[i].id=0;
if (sd->status.skill[i].flag && sd->status.skill[i].flag != 13){ // cardスキルなら、
sd->status.skill[i].lv=(sd->status.skill[i].flag==1)?0:sd->status.skill[i].flag-2; // 本?のlvに
@@ -1030,13 +1030,13 @@ int pc_calc_skilltree(struct map_session_data *sd)
sd->status.skill[i].id=i;
for(i=210;i<291;i++)
sd->status.skill[i].id=i;
- for(i=304;i<337;i++){
+ for(i=304;i<338;i++){
if(i==331) continue;
sd->status.skill[i].id=i;
}
if(battle_config.enable_upper_class){ //confで無?でなければ?み?む
- for(i=355;i<MAX_SKILL;i++)
- sd->status.skill[i].id=i;
+ for(i=355;i<411;i++)
+ sd->status.skill[i].id=i;
}
}else{
do {
@@ -1052,6 +1052,8 @@ int pc_calc_skilltree(struct map_session_data *sd)
break;
}
}
+ if (id >= 2 && id <= 53 && pc_checkskill(sd, NV_BASIC) < 9)
+ f=0;
}
if(f && sd->status.skill[id].id==0 ){
sd->status.skill[id].id=id;
@@ -1073,7 +1075,7 @@ int pc_calc_skilltree_normalize_job(int c, struct map_session_data *sd) {
c = 0;
//else if((sd->status.skill_point >= sd->status.job_level && skill_point < 58) && ((c > 6 && c < 23) || (c > 4007 && c < 4023) || (c > 4029 && c < 4045))) {
//else if ((sd->status.skill_point >= sd->status.job_level && skill_point < 58) && (c > 6 && c < 23)) {
- else if ((sd->status.skill_point >= sd->status.job_level && skill_point < sd->change_level+8) && (c > 6 && c < 23)) {
+ else if (sd->status.skill_point >= sd->status.job_level && ((sd->change_level > 0 && skill_point < sd->change_level+8) || skill_point < 58) && (c > 6 && c < 23)) {
switch(c) {
case 7:
case 13:
@@ -1178,7 +1180,7 @@ int pc_checkweighticon(struct map_session_data *sd)
flag=1;
if(sd->weight*10 >= sd->max_weight*9)
flag=2;
-
+
if(flag==1){
if(sd->sc_data[SC_WEIGHT50].timer==-1)
skill_status_change_start(&sd->bl,SC_WEIGHT50,0,0,0,0,0,0);
@@ -1670,6 +1672,16 @@ int pc_calcstatus(struct map_session_data* sd,int first)
sd->paramb[5] += sd->status.luk+psd->status.luk/2 > 99 ? 99-sd->status.luk : psd->status.luk/2;
}
}
+ if(sd->sc_data[SC_GOSPEL].timer!=-1 && sd->sc_data[SC_GOSPEL].val4 == BCT_PARTY){
+ if (sd->sc_data[SC_GOSPEL].val3 == 6) {
+ sd->paramb[0]+= 2;
+ sd->paramb[1]+= 2;
+ sd->paramb[2]+= 2;
+ sd->paramb[3]+= 2;
+ sd->paramb[4]+= 2;
+ sd->paramb[5]+= 2;
+ }
+ }
}
//1度も死んでないJob70スパノビに+10
@@ -1769,7 +1781,7 @@ int pc_calcstatus(struct map_session_data* sd,int first)
else if (pc_isriding(sd)) { // ペコペコ?りによる速度?加
sd->speed -= (0.25 * DEFAULT_WALK_SPEED);
sd->max_weight += 10000;
- }
+ }
if((skill=pc_checkskill(sd,CR_TRUST))>0) { // フェイス
sd->status.max_hp += skill*200;
sd->subele[6] += skill*5;
@@ -1788,7 +1800,7 @@ int pc_calcstatus(struct map_session_data* sd,int first)
sd->status.max_hp = sd->status.max_hp * 130/100;
else if (s_class.upper==2)
sd->status.max_hp = sd->status.max_hp * 70/100;
-
+
if(sd->hprate!=100)
sd->status.max_hp = sd->status.max_hp*sd->hprate/100;
@@ -1910,6 +1922,13 @@ int pc_calcstatus(struct map_session_data* sd,int first)
}
if(sd->sc_data[SC_POISON].timer!=-1) // 毒?態
sd->def2 = sd->def2*75/100;
+ if(sd->sc_data[SC_CURSE].timer!=-1){
+ sd->base_atk = sd->base_atk*75/100;
+ sd->watk = sd->watk*75/100;
+ index = sd->equip_index[8];
+ if(index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == 4)
+ sd->watk_ = sd->watk_*75/100;
+ }
if(sd->sc_data[SC_DRUMBATTLE].timer!=-1){ // ?太鼓の響き
sd->watk += sd->sc_data[SC_DRUMBATTLE].val2;
sd->def += sd->sc_data[SC_DRUMBATTLE].val3;
@@ -2113,8 +2132,62 @@ int pc_calcstatus(struct map_session_data* sd,int first)
sd->def = 100;
if(sd->sc_data[SC_BARRIER].timer!=-1)
sd->mdef = 100;
+
+ if(sd->sc_data[SC_GOSPEL].timer!=-1) {
+ if (sd->sc_data[SC_GOSPEL].val4 == BCT_PARTY){
+ switch (sd->sc_data[SC_GOSPEL].val3)
+ {
+ case 4:
+ sd->status.max_hp += sd->status.max_hp * 25 / 100;
+ if(sd->status.max_hp > battle_config.max_hp)
+ sd->status.max_hp = battle_config.max_hp;
+ break;
+ case 5:
+ sd->status.max_sp += sd->status.max_sp * 25 / 100;
+ if(sd->status.max_sp > battle_config.max_sp)
+ sd->status.max_sp = battle_config.max_sp;
+ break;
+ case 11:
+ sd->def += sd->def * 25 / 100;
+ sd->def2 += sd->def2 * 25 / 100;
+ break;
+ case 12:
+ sd->base_atk += sd->base_atk * 8 / 100;
+ break;
+ case 13:
+ sd->flee += sd->flee * 5 / 100;
+ break;
+ case 14:
+ sd->hit += sd->hit * 5 / 100;
+ break;
+ }
+ } else if (sd->sc_data[SC_GOSPEL].val4 == BCT_ENEMY){
+ switch (sd->sc_data[SC_GOSPEL].val3)
+ {
+ case 5:
+ sd->def = 0;
+ sd->def2 = 0;
+ break;
+ case 6:
+ sd->base_atk = 0;
+ sd->watk = 0;
+ sd->watk2 = 0;
+ break;
+ case 7:
+ sd->flee = 0;
+ break;
+ case 8:
+ sd->speed_rate += 75;
+ aspd_rate += 75;
+ break;
+ }
+ }
+ }
}
+ if (sd->speed_rate <= 0)
+ sd->speed_rate = 1;
+
if(sd->speed_rate != 100)
sd->speed = sd->speed*sd->speed_rate/100;
if(sd->speed < 1) sd->speed = 1;
@@ -2216,7 +2289,7 @@ int pc_calcstatus(struct map_session_data* sd,int first)
clif_updatestatus(sd,SP_CARTINFO);*/
//if(sd->status.hp<sd->status.max_hp>>2 && pc_checkskill(sd,SM_AUTOBERSERK)>0 &&
- if(sd->status.hp<sd->status.max_hp>>2 && sd->sc_data[SC_AUTOBERSERK].timer != -1 &&
+ if(sd->status.hp<sd->status.max_hp>>2 && sd->sc_data[SC_AUTOBERSERK].timer != -1 &&
(sd->sc_data[SC_PROVOKE].timer==-1 || sd->sc_data[SC_PROVOKE].val2==0 ) && !pc_isdead(sd))
// オ?トバ?サ?ク?動
skill_status_change_start(&sd->bl,SC_PROVOKE,10,1,0,0,0,0);
@@ -2239,7 +2312,7 @@ int pc_calcspeed (struct map_session_data *sd)
b_speed = sd->speed;
sd->speed = DEFAULT_WALK_SPEED ;
-
+
if(sd->sc_count){
if(sd->sc_data[SC_INCREASEAGI].timer!=-1 && sd->sc_data[SC_QUAGMIRE].timer == -1 && sd->sc_data[SC_DONTFORGETME].timer == -1){ // 速度?加
sd->speed -= sd->speed *25/100;
@@ -2303,7 +2376,7 @@ int pc_calcspeed (struct map_session_data *sd)
if(sd->speed_rate != 100)
sd->speed = sd->speed*sd->speed_rate/100;
if(sd->speed < 1) sd->speed = 1;
-
+
if(sd->skilltimer != -1 && (skill = pc_checkskill(sd,SA_FREECAST)) > 0) {
sd->prev_speed = sd->speed;
sd->speed = sd->speed*(175 - skill*5)/100;
@@ -2932,7 +3005,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag !=2){
sd->random_attack_increase_add = type2;
sd->random_attack_increase_per += val;
- }
+ }
break;
case SP_WEAPON_ATK:
if(sd->state.lr_flag != 2)
@@ -3662,7 +3735,7 @@ int pc_item_refine(struct map_session_data *sd,int idx)
int flag = 1, i = 0, ep = 0, per;
int material[5] = { 0, 1010, 1011, 984, 984 };
struct item *item;
-
+
nullpo_retr(0, sd);
item = &sd->status.inventory[idx];
@@ -3681,7 +3754,7 @@ int pc_item_refine(struct map_session_data *sd,int idx)
per = percentrefinery [itemdb_wlv (item->nameid)][(int)item->refine];
//per += pc_checkskill(sd,BS_WEAPONRESEARCH);
per *= (75 + sd->status.job_level/2)/100;
-
+
if (per > rand() % 100) {
flag = 0;
item->refine++;
@@ -3691,7 +3764,7 @@ int pc_item_refine(struct map_session_data *sd,int idx)
pc_unequipitem(sd,idx,3);
}
clif_refine(sd->fd,sd,0,idx,item->refine);
- clif_delitem(sd,idx,1);
+ clif_delitem(sd,idx,1);
clif_additem(sd,idx,1,0);
if (ep)
pc_equipitem(sd,idx,ep);
@@ -3777,7 +3850,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl)
if(itemid > 0 && itemdb_type(itemid) != 6)
{
rate = (mob_db[md->class_].dropitem[i].p / battle_config.item_rate_common * 100 * skill)/100;
-
+
if(rand()%10000 < rate)
{
struct item tmp_item;
@@ -3882,7 +3955,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt
if(sd->sc_data[SC_DANCING].timer!=-1) // clear dance effect when warping [Valaris]
skill_stop_dancing(&sd->bl,0);
}
-
+
if(sd->status.option&2)
skill_status_change_end(&sd->bl, SC_HIDING, -1);
if(sd->status.option&4)
@@ -3894,7 +3967,7 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt
pet_stopattack(sd->pd);
pet_changestate(sd->pd,MS_IDLE,0);
}
-
+
if(sd->disguise) { // clear disguises when warping [Valaris]
clif_clearchar(&sd->bl, 9);
disguise=sd->disguise;
@@ -4000,13 +4073,13 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt
if(disguise) // disguise teleport fix [Valaris]
sd->disguise=disguise;
-
+
memcpy(sd->mapname,mapname,24);
sd->bl.m = m;
sd->to_x = x;
sd->to_y = y;
- // moved and changed dance effect stopping
+ // moved and changed dance effect stopping
sd->bl.x = x;
sd->bl.y = y;
@@ -4336,19 +4409,19 @@ int pc_walktoxy(struct map_session_data *sd,int x,int y)
if (sd->sc_data && sd->status.guild_id > 0) {
struct skill_unit *su;
struct skill_unit_group *sg;
- if (sd->state.leadership_flag && (su=(struct skill_unit *)sd->state.leadership_flag) &&
+ if (sd->state.leadership_flag && (su=(struct skill_unit *)sd->state.leadership_flag) &&
(sg=su->group) && sg->src_id == sd->bl.id) {
skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y));
}
- if (sd->state.glorywounds_flag && (su=(struct skill_unit *)sd->state.glorywounds_flag) &&
+ if (sd->state.glorywounds_flag && (su=(struct skill_unit *)sd->state.glorywounds_flag) &&
(sg=su->group) && sg->src_id == sd->bl.id) {
skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y));
}
- if (sd->state.soulcold_flag && (su=(struct skill_unit *)sd->state.soulcold_flag) &&
+ if (sd->state.soulcold_flag && (su=(struct skill_unit *)sd->state.soulcold_flag) &&
(sg=su->group) && sg->src_id == sd->bl.id) {
skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y));
}
- if (sd->state.hawkeyes_flag && (su=(struct skill_unit *)sd->state.hawkeyes_flag) &&
+ if (sd->state.hawkeyes_flag && (su=(struct skill_unit *)sd->state.hawkeyes_flag) &&
(sg=su->group) && sg->src_id == sd->bl.id) {
skill_unit_move_unit_group(sg,sd->bl.m,(x - sd->bl.x),(y - sd->bl.y));
}
@@ -4392,7 +4465,7 @@ int pc_randomwalk(struct map_session_data *sd,int tick)
{
const int retrycount = 20;
nullpo_retr(0, sd);
-
+
if(DIFF_TICK(sd->next_walktime,tick)<0){
int i,x,y,d;
d = rand()%7+5;
@@ -4608,7 +4681,7 @@ struct pc_base_job pc_calc_base_job(int b_class)
}else{
bj.type = 2;
}
-
+
return bj;
}
@@ -4624,7 +4697,7 @@ int pc_calc_base_job2 (int b_class)
return b_class - 4001;
else if(b_class == 4045)
return 23;
- return b_class - 4023;
+ return b_class - 4023;
}
int pc_calc_upper(int b_class)
@@ -4668,8 +4741,12 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data)
if(bl==NULL || bl->prev == NULL)
return 0;
- if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl))
- return 0;
+ if(bl->type == BL_PC) {
+ if (pc_isdead((struct map_session_data *)bl))
+ return 0;
+ else if (pc_ishiding((struct map_session_data *)bl))
+ return 0;
+ }
// 同じmapでないなら攻?しない
// PCが死んでても攻?しない
@@ -4685,7 +4762,7 @@ int pc_attack_timer(int tid,unsigned int tick,int id,int data)
return 0;
if(sd->sc_data[SC_BLADESTOP].timer != -1)
return 0;
- }
+ }
//if((opt = battle_get_option(bl)) != NULL && *opt&0x46)
if((opt = battle_get_option(bl)) != NULL && *opt&0x42)
@@ -4774,13 +4851,13 @@ int pc_attack(struct map_session_data *sd,int target_id,int type)
return 1;
sd->idletime = tick_;
-
+
if(bl->type==BL_NPC) { // monster npcs [Valaris]
//npc_click(sd,RFIFOL(sd->fd,2));
npc_click(sd,target_id); // submitted by leinsirk10 [Celest]
return 0;
}
-
+
if(!battle_check_target(&sd->bl,bl,BCT_ENEMY))
return 1;
if(sd->attacktimer != -1)
@@ -4972,7 +5049,7 @@ int pc_gainexp(struct map_session_data *sd,int base_exp,int job_exp)
sd->status.base_exp += base_exp;
if(sd->status.base_exp < 0)
sd->status.base_exp = 0;
-
+
while(pc_checkbaselevelup(sd)) ;
clif_updatestatus(sd,SP_BASEEXP);
@@ -4985,13 +5062,13 @@ int pc_gainexp(struct map_session_data *sd,int base_exp,int job_exp)
sd->status.job_exp += job_exp;
if(sd->status.job_exp < 0)
sd->status.job_exp = 0;
-
+
while(pc_checkjoblevelup(sd)) ;
clif_updatestatus(sd,SP_JOBEXP);
if(battle_config.disp_experience){
- sprintf(output,
+ sprintf(output,
"Experienced Gained Base:%d Job:%d",base_exp,job_exp);
clif_disp_onlyself(sd,output,strlen(output));
}
@@ -5124,7 +5201,7 @@ int pc_need_status_point(struct map_session_data *sd,int type)
int pc_statusup(struct map_session_data *sd,int type)
{
int max, need,val = 0;
-
+
nullpo_retr(0, sd);
max = (pc_calc_upper(sd->status.class_)==2) ? 80 : battle_config.max_parameter;
@@ -5326,17 +5403,21 @@ int pc_allskillup(struct map_session_data *sd)
sd->status.skill[i].lv=skill_get_max(i);
for(i=210;i<291;i++)
sd->status.skill[i].lv=skill_get_max(i);
- for(i=304;i<MAX_SKILL;i++){
+ for(i=304;i<338;i++){
if(i==331) continue;
sd->status.skill[i].lv=skill_get_max(i);
}
+ if(battle_config.enable_upper_class){ //confで無?でなければ?み?む
+ for(i=355;i<411;i++)
+ sd->status.skill[i].id=i;
+ }
}
else {
for(i=0;(id=skill_tree[s][c][i].id)>0;i++){
if(sd->status.skill[id].id==0 && (!(skill_get_inf2(id)&0x01) || battle_config.quest_skill_learn) ) {
sd->status.skill[id].id = id; // celest
// sd->status.skill[id].lv=skill_get_max(id);
- sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest
+ sd->status.skill[id].lv = skill_tree_get_max(id, sd->status.class_); // celest
}
}
}
@@ -5352,9 +5433,9 @@ int pc_allskillup(struct map_session_data *sd)
int pc_resetlvl(struct map_session_data* sd,int type)
{
int i;
-
+
nullpo_retr(0, sd);
-
+
for(i=1;i<MAX_SKILL;i++){
sd->status.skill[i].lv = 0;
}
@@ -5395,7 +5476,7 @@ int pc_resetlvl(struct map_session_data* sd,int type)
if(type == 4){
sd->status.job_level=1;
sd->status.job_exp=0;
- }
+ }
clif_updatestatus(sd,SP_STATUSPOINT);
clif_updatestatus(sd,SP_STR);
@@ -5444,7 +5525,7 @@ int pc_resetstate(struct map_session_data* sd)
sd->status.status_point = atoi (statp[sd->status.base_level - 1]);
if(sd->status.class_ >= 4001 && sd->status.class_ <= 4024)
sd->status.status_point+=52; // extra 52+48=100 stat points
-// End addition
+// End addition
// Removed by Dexity - old count
// add += sumsp(sd->status.str);
@@ -5794,7 +5875,7 @@ int pc_readparam(struct map_session_data *sd,int type)
{
int val=0;
struct pc_base_job s_class;
-
+
s_class = pc_calc_base_job(sd->status.class_);
nullpo_retr(0, sd);
@@ -6208,12 +6289,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
int b_class = 0;
//?生や養子の場合の元の職業を算出する
struct pc_base_job s_class = pc_calc_base_job(sd->status.class_);
-
+
nullpo_retr(0, sd);
if (upper < 0 || upper > 2) //現在?生かどうかを判?する
upper = s_class.upper;
-
+
b_class = job; //通常職ならjobそのまんま
if (job < 23) {
if (upper == 1)
@@ -6248,8 +6329,8 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
else
sd->change_level = 0;
- pc_setglobalreg (sd, "jobchange_level", sd->change_level);
-
+ pc_setglobalreg (sd, "jobchange_level", sd->change_level);
+
sd->status.class_ = sd->view_class = b_class;
sd->status.job_level=1;
@@ -6276,12 +6357,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
clif_equiplist(sd);
if(pc_isriding(sd)) { // remove peco status if changing into invalid class [Valaris]
- if(!(pc_checkskill(sd,KN_RIDING)))
+ if(!(pc_checkskill(sd,KN_RIDING)))
pc_setoption(sd,sd->status.option|-0x0000);
if(pc_checkskill(sd,KN_RIDING)>0)
pc_setriding(sd);
}
-
+
return 0;
}
@@ -6418,13 +6499,13 @@ int pc_setriding(struct map_session_data *sd)
if(sd->status.class_==7)
sd->status.class_=sd->view_class=13;
-
+
if(sd->status.class_==14)
sd->status.class_=sd->view_class=21;
-
+
if(sd->status.class_==4008)
sd->status.class_=sd->view_class=4014;
-
+
if(sd->status.class_==4015)
sd->status.class_=sd->view_class=4022;
}
@@ -6772,7 +6853,7 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data)
break;
}
}
- free((void *)data);
+ aFree((void *)data);
if(i==MAX_EVENTTIMER) {
if(battle_config.error_log)
printf("pc_eventtimer: no such event timer\n");
@@ -6795,7 +6876,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name)
if( sd->eventtimer[i]==-1 )
break;
if(i<MAX_EVENTTIMER){
- char *evname=(char *)aMalloc((strlen(name)+1)*sizeof(char));
+ char *evname=(char *)aMallocA((strlen(name)+1)*sizeof(char));
memcpy(evname,name,(strlen(name)+1));
sd->eventtimer[i]=add_timer(gettick()+tick,
pc_eventtimer,sd->bl.id,(int)evname);
@@ -7035,7 +7116,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
*/
int pc_unequipitem(struct map_session_data *sd,int n,int flag)
{
- nullpo_retr(0, sd);
+ nullpo_retr(0, sd);
// -- moonsoul (if player is berserk then cannot unequip)
//
@@ -7243,7 +7324,7 @@ int pc_calc_pvprank(struct map_session_data *sd)
nullpo_retr(0, sd);
nullpo_retr(0, m=&map[sd->bl.m]);
-
+
old=sd->pvp_rank;
if( !(m->flag.pvp) )
@@ -7385,8 +7466,8 @@ static int pc_spheal(struct map_session_data *sd)
if(gc) {
struct guild *g;
g=guild_search(sd->status.guild_id);
- if(g && g->guild_id == gc->guild_id)
- a += a;
+ if(g && g->guild_id == gc->guild_id)
+ a += a;
} // end addition [Valaris]
return a;
@@ -7415,8 +7496,8 @@ static int pc_hpheal(struct map_session_data *sd)
if(gc) {
struct guild *g;
g=guild_search(sd->status.guild_id);
- if(g && g->guild_id == gc->guild_id)
- a += a;
+ if(g && g->guild_id == gc->guild_id)
+ a += a;
} // end addition [Valaris]
return a;
@@ -7680,8 +7761,8 @@ static int pc_natural_heal_sub(struct map_session_data *sd,va_list ap) {
// -- moonsoul (if conditions below altered to disallow natural healing if under berserk status)
if ((battle_config.natural_heal_weight_rate > 100 || sd->weight*100/sd->max_weight < battle_config.natural_heal_weight_rate) &&
- !pc_isdead(sd) &&
- !pc_ishiding(sd) &&
+ !pc_isdead(sd) &&
+ !pc_ishiding(sd) &&
//-- cannot regen for 5 minutes after using Berserk --- [Celest]
DIFF_TICK (gettick(), sd->canregen_tick)>=0 &&
(sd->sc_data && !(sd->sc_data[SC_POISON].timer != -1 && sd->sc_data[SC_SLOWPOISON].timer == -1) &&
@@ -7746,7 +7827,7 @@ static int pc_autosave_sub(struct map_session_data *sd,va_list ap)
{
nullpo_retr(0, sd);
- Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
+ Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
if(save_flag==0 && sd->fd>last_save_fd){
struct guild_castle *gc=NULL;
@@ -7807,10 +7888,10 @@ int pc_read_gm_account(int fd)
int i = 0;
#endif
if (gm_account != NULL)
- free(gm_account);
+ aFree(gm_account);
GM_num = 0;
#ifdef TXT_ONLY
- gm_account = aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
+ gm_account = aCallocA(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
for (i = 4; i < RFIFOW(fd,2); i = i + 5) {
gm_account[GM_num].account_id = RFIFOL(fd,i);
gm_account[GM_num].level = (int)RFIFOB(fd,i+4);
@@ -7824,7 +7905,7 @@ int pc_read_gm_account(int fd)
}
lsql_res = mysql_store_result(&lmysql_handle);
if (lsql_res) {
- gm_account = aCalloc(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1);
+ gm_account = aCallocA(sizeof(struct gm_account) * mysql_num_rows(lsql_res), 1);
while ((lsql_row = mysql_fetch_row(lsql_res))) {
gm_account[GM_num].account_id = atoi(lsql_row[0]);
gm_account[GM_num].level = atoi(lsql_row[1]);
@@ -7832,7 +7913,7 @@ int pc_read_gm_account(int fd)
GM_num++;
}
}
-
+
mysql_free_result(lsql_res);
#endif /* TXT_ONLY */
return GM_num;
@@ -7926,7 +8007,7 @@ int pc_readdb(void)
char line[1024],*p;
// 必要??値?み?み
-
+ memset(exp_table,0,sizeof(exp_table));
fp=fopen("db/exp.txt","r");
if(fp==NULL){
printf("can't read db/exp.txt\n");
@@ -7997,6 +8078,7 @@ int pc_readdb(void)
ShowStatus(tmp_output);
// JOBボ?ナス
+ memset(job_bonus,0,sizeof(job_bonus));
fp=fopen("db/job_db2.txt","r");
if(fp==NULL){
printf("can't read db/job_db2.txt\n");
@@ -8076,7 +8158,7 @@ int pc_readdb(void)
for(j=0;skill_tree[u][i][j].id;j++);
skill_tree[u][i][j].id=atoi(split[1]);
skill_tree[u][i][j].max=atoi(split[2]);
-
+
//not required - Celest
//skill_tree[2][i][j].id=atoi(split[1]); //養子職は良く分からないので暫定
//skill_tree[2][i][j].max=atoi(split[2]); //養子職は良く分からないので暫定
@@ -8242,7 +8324,7 @@ static void pc_statpointdb(void)
end = ftell(stp);
rewind(stp);
- buf_stat = (char *) malloc (end + 1);
+ buf_stat = (char *) aMallocA (end + 1);
l = fread(buf_stat,1,end,stp);
fclose(stp);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/statpoint.txt");
@@ -8251,7 +8333,7 @@ static void pc_statpointdb(void)
for(i=0;i<255;i++) {
j=0;
- while (*(buf_stat+k)!='\n') {
+ while (*(buf_stat+k)!='\n') {
statp[i][j]=*(buf_stat+k);
j++;k++;
}
@@ -8259,7 +8341,7 @@ static void pc_statpointdb(void)
k++;
}
- free(buf_stat);
+ aFree(buf_stat);
}
/*==========================================
diff --git a/src/map/pet.c b/src/map/pet.c
index c198c1fb5..99f2a4d95 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -1376,7 +1376,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
clif_additem(sd,0,0,flag);
map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
}
- free(ditem);
+ aFree(ditem);
}
else
add_timer(gettick()+540+i,pet_delay_item_drop2,(int)ditem,0);
@@ -1399,7 +1399,7 @@ int pet_delay_item_drop2(int tid,unsigned int tick,int id,int data)
map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
- free(ditem);
+ aFree(ditem);
return 0;
}
diff --git a/src/map/script.c b/src/map/script.c
index a6b65e213..35645eaab 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -507,7 +507,7 @@ struct {
{buildin_npctalk,"npctalk","*"}, // [Valaris]
{buildin_hasitems,"hasitems","*"}, // [Valaris]
{buildin_mobcount,"mobcount","ss"},
- {buildin_getlook,"getlook","i"},
+ {buildin_getlook,"getlook","i"},
{buildin_getsavepoint,"getsavepoint","i"},
{buildin_npcspeed,"npcspeed","i"}, // [Valaris]
{buildin_npcwalkto,"npcwalkto","ii"}, // [Valaris]
@@ -576,14 +576,14 @@ static int add_str(const unsigned char *p)
int i;
char *lowcase;
- lowcase=strdup(p);
+ lowcase=aStrdup(p);
for(i=0;lowcase[i];i++)
lowcase[i]=tolower(lowcase[i]);
if((i=search_str(lowcase))>=0){
- free(lowcase);
+ aFree(lowcase);
return i;
}
- free(lowcase);
+ aFree(lowcase);
i=calc_hash(p);
if(str_hash[i]==0){
@@ -605,7 +605,7 @@ static int add_str(const unsigned char *p)
str_data=aRealloc(str_data,sizeof(str_data[0])*str_data_size);
memset(str_data + (str_data_size - 128), '\0', 128);
}
- while(str_pos+strlen(p)+1>=str_size){
+ while(str_pos+(int)strlen(p)+1>=str_size){
str_size+=256;
str_buf=(char *)aRealloc(str_buf,str_size);
memset(str_buf + (str_size - 256), '\0', 256);
@@ -1159,7 +1159,7 @@ unsigned char* parse_script(unsigned char *src,int line)
read_constdb();
}
first=0;
- script_buf=(unsigned char *)aCalloc(SCRIPT_BLOCK_SIZE,sizeof(unsigned char));
+ script_buf=(unsigned char *)aCallocA(SCRIPT_BLOCK_SIZE,sizeof(unsigned char));
script_pos=0;
script_size=SCRIPT_BLOCK_SIZE;
str_data[LABEL_NEXTLINE].type=C_NOP;
@@ -1395,7 +1395,7 @@ char* conv_str(struct script_state *st,struct script_data *data)
get_val(st,data);
if(data->type==C_INT){
char *buf;
- buf=(char *)aCalloc(16,sizeof(char));
+ buf=(char *)aCallocA(16,sizeof(char));
sprintf(buf,"%d",data->u.num);
data->type=C_STR;
data->u.str=buf;
@@ -1421,7 +1421,7 @@ int conv_num(struct script_state *st,struct script_data *data)
p=data->u.str;
data->u.num = atoi(p);
if(data->type==C_STR)
- free(p);
+ aFree(p);
data->type=C_INT;
}
return data->u.num;
@@ -1478,7 +1478,7 @@ void push_copy(struct script_stack *stack,int pos)
push_str(stack,C_CONSTSTR,stack->stack_data[pos].u.str);
break;
case C_STR:
- push_str(stack,C_STR,strdup(stack->stack_data[pos].u.str));
+ push_str(stack,C_STR,aStrdup(stack->stack_data[pos].u.str));
break;
default:
push_val(stack,stack->stack_data[pos].type,stack->stack_data[pos].u.num);
@@ -1495,7 +1495,7 @@ void pop_stack(struct script_stack* stack,int start,int end)
int i;
for(i=start;i<end;i++){
if(stack->stack_data[i].type==C_STR){
- free(stack->stack_data[i].u.str);
+ aFree(stack->stack_data[i].u.str);
}
}
if(stack->sp>end){
@@ -1663,7 +1663,7 @@ int buildin_menu(struct script_state *st)
char *buf;
int len,i;
struct map_session_data *sd;
-
+
sd=script_rid2sd(st);
if(sd->state.menu_or_input==0){
@@ -1673,14 +1673,14 @@ int buildin_menu(struct script_state *st)
conv_str(st,& (st->stack->stack_data[i]));
len+=strlen(st->stack->stack_data[i].u.str)+1;
}
- buf=(char *)aCalloc(len,sizeof(char));
+ buf=(char *)aCallocA(len,sizeof(char));
buf[0]=0;
for(i=st->start+2,len=0;i<st->end;i+=2){
strcat(buf,st->stack->stack_data[i].u.str);
strcat(buf,":");
}
clif_scriptmenu(script_rid2sd(st),st->oid,buf);
- free(buf);
+ aFree(buf);
} else if(sd->npc_menu==0xff){ // cansel
sd->state.menu_or_input=0;
st->state=END;
@@ -2522,7 +2522,7 @@ int buildin_delitem(struct script_state *st)
if(sd->inventory_data[i]->type==7 && sd->status.inventory[i].card[0] == (short)0xff00 && search_petDB_index(nameid, PET_EGG) >= 0 ){
intif_delete_petdata(*((long *)(&sd->status.inventory[i].card[1])));
//clear egg flag. so it won't be put in IMPORTANT items (eggs look like item with 2 cards ^_^)
- sd->status.inventory[i].card[1] = sd->status.inventory[i].card[0] = 0;
+ sd->status.inventory[i].card[1] = sd->status.inventory[i].card[0] = 0;
//now this egg'll be deleted as a common unimportant item
}
//is this item important? does it have cards? or Player's name? or Refined/Upgraded
@@ -2551,7 +2551,7 @@ int buildin_delitem(struct script_state *st)
continue;
if(sd->status.inventory[i].amount>=amount){
- pc_delitem(sd,i,amount,0);
+ pc_delitem(sd,i,amount,0);
return 0; //we deleted exact amount of items. now exit
} else {
amount-=sd->status.inventory[i].amount;
@@ -2627,7 +2627,7 @@ char *buildin_getpartyname_sub(int party_id)
if(p!=NULL){
char *buf;
- buf=(char *)aCalloc(24,sizeof(char));
+ buf=(char *)aCallocA(24,sizeof(char));
strcpy(buf,p->name);
return buf;
}
@@ -2684,7 +2684,7 @@ char *buildin_getguildname_sub(int guild_id)
if(g!=NULL){
char *buf;
- buf=(char *)aCalloc(24,sizeof(char));
+ buf=(char *)aCallocA(24,sizeof(char));
strcpy(buf,g->name);
return buf;
}
@@ -2713,7 +2713,7 @@ char *buildin_getguildmaster_sub(int guild_id)
if(g!=NULL){
char *buf;
- buf=(char *)aCalloc(24,sizeof(char));
+ buf=(char *)aCallocA(24,sizeof(char));
strncpy(buf,g->master, 23);
return buf;
}
@@ -2763,7 +2763,7 @@ int buildin_strcharinfo(struct script_state *st)
num=conv_num(st,& (st->stack->stack_data[st->start+2]));
if(num==0){
char *buf;
- buf=(char *)aCalloc(24,sizeof(char));
+ buf=(char *)aCallocA(24,sizeof(char));
strncpy(buf,sd->status.name, 23);
push_str(st->stack,C_STR,buf);
}
@@ -2830,7 +2830,7 @@ int buildin_getequipname(struct script_state *st)
struct item_data* item;
char *buf;
- buf=(char *)aCalloc(64,sizeof(char));
+ buf=(char *)aCallocA(64,sizeof(char));
sd=script_rid2sd(st);
num=conv_num(st,& (st->stack->stack_data[st->start+2]));
i=pc_checkequip(sd,equip[num-1]);
@@ -2856,9 +2856,9 @@ int buildin_getbrokenid(struct script_state *st)
{
int i,num,id=0,brokencounter=0;
struct map_session_data *sd;
-
+
sd=script_rid2sd(st);
-
+
num=conv_num(st,& (st->stack->stack_data[st->start+2]));
for(i=0; i<MAX_INVENTORY; i++) {
if(sd->status.inventory[i].attribute==1){
@@ -2869,7 +2869,7 @@ int buildin_getbrokenid(struct script_state *st)
}
}
}
-
+
push_val(st->stack,C_INT,id);
return 0;
@@ -2887,7 +2887,7 @@ int buildin_repair(struct script_state *st)
sd=script_rid2sd(st);
-
+
num=conv_num(st,& (st->stack->stack_data[st->start+2]));
for(i=0; i<MAX_INVENTORY; i++) {
if(sd->status.inventory[i].attribute==1){
@@ -2941,7 +2941,7 @@ int buildin_getequipisenableref(struct script_state *st)
i=pc_checkequip(sd,equip[num-1]);
if(i >= 0 && num<7 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine)
// replaced by Celest
- /*(num!=1
+ /*(num!=1
|| sd->inventory_data[i]->def > 1
|| (sd->inventory_data[i]->def==1 && sd->inventory_data[i]->equip_script==NULL)
|| (sd->inventory_data[i]->def<=0 && sd->inventory_data[i]->equip_script!=NULL)))*/
@@ -3245,15 +3245,15 @@ int buildin_getskilllv(struct script_state *st)
return 0;
}
/*==========================================
- * getgdskilllv(Guild_ID, Skill_ID);
- * skill_id = 10000 : GD_APPROVAL
- * 10001 : GD_KAFRACONTACT
- * 10002 : GD_GUARDIANRESEARCH
- * 10003 : GD_GUARDUP
- * 10004 : GD_EXTENSION
+ * getgdskilllv(Guild_ID, Skill_ID);
+ * skill_id = 10000 : GD_APPROVAL
+ * 10001 : GD_KAFRACONTACT
+ * 10002 : GD_GUARDIANRESEARCH
+ * 10003 : GD_GUARDUP
+ * 10004 : GD_EXTENSION
*------------------------------------------
*/
-int buildin_getgdskilllv(struct script_state *st)
+int buildin_getgdskilllv(struct script_state *st)
{
int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2]));
int skill_id=conv_num(st,& (st->stack->stack_data[st->start+3]));
@@ -3590,7 +3590,7 @@ int buildin_gettimestr(struct script_state *st)
fmtstr=conv_str(st,& (st->stack->stack_data[st->start+2]));
maxlen=conv_num(st,& (st->stack->stack_data[st->start+3]));
- tmpstr=(char *)aCalloc(maxlen+1,sizeof(char));
+ tmpstr=(char *)aCallocA(maxlen+1,sizeof(char));
strftime(tmpstr,maxlen,fmtstr,localtime(&now));
tmpstr[maxlen]='\0';
@@ -3677,8 +3677,8 @@ int buildin_makepet(struct script_state *st)
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(
sd->status.account_id, sd->status.char_id,
- pet_db[pet_id].class_, mob_db[pet_db[pet_id].class_].lv,
- pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
+ (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);
}
@@ -3727,19 +3727,19 @@ int buildin_guildgetexp(struct script_state *st)
*/
int buildin_monster(struct script_state *st)
{
- int class,amount,x,y;
+ int class_,amount,x,y;
char *str,*map,*event="";
map =conv_str(st,& (st->stack->stack_data[st->start+2]));
x =conv_num(st,& (st->stack->stack_data[st->start+3]));
y =conv_num(st,& (st->stack->stack_data[st->start+4]));
str =conv_str(st,& (st->stack->stack_data[st->start+5]));
- class=conv_num(st,& (st->stack->stack_data[st->start+6]));
+ class_=conv_num(st,& (st->stack->stack_data[st->start+6]));
amount=conv_num(st,& (st->stack->stack_data[st->start+7]));
if( st->end>st->start+8 )
event=conv_str(st,& (st->stack->stack_data[st->start+8]));
- mob_once_spawn(map_id2sd(st->rid),map,x,y,str,class,amount,event);
+ mob_once_spawn(map_id2sd(st->rid),map,x,y,str,class_,amount,event);
return 0;
}
/*==========================================
@@ -3748,7 +3748,7 @@ int buildin_monster(struct script_state *st)
*/
int buildin_areamonster(struct script_state *st)
{
- int class,amount,x0,y0,x1,y1;
+ int class_,amount,x0,y0,x1,y1;
char *str,*map,*event="";
map =conv_str(st,& (st->stack->stack_data[st->start+2]));
@@ -3757,12 +3757,12 @@ int buildin_areamonster(struct script_state *st)
x1 =conv_num(st,& (st->stack->stack_data[st->start+5]));
y1 =conv_num(st,& (st->stack->stack_data[st->start+6]));
str =conv_str(st,& (st->stack->stack_data[st->start+7]));
- class=conv_num(st,& (st->stack->stack_data[st->start+8]));
+ class_=conv_num(st,& (st->stack->stack_data[st->start+8]));
amount=conv_num(st,& (st->stack->stack_data[st->start+9]));
if( st->end>st->start+10 )
event=conv_str(st,& (st->stack->stack_data[st->start+10]));
- mob_once_spawn_area(map_id2sd(st->rid),map,x0,y0,x1,y1,str,class,amount,event);
+ mob_once_spawn_area(map_id2sd(st->rid),map,x0,y0,x1,y1,str,class_,amount,event);
return 0;
}
/*==========================================
@@ -3974,7 +3974,7 @@ int buildin_attachnpctimer(struct script_state *st)
struct map_session_data *sd;
struct npc_data *nd;
- nd=(struct npc_data *)map_id2bl(st->oid);
+ nd=(struct npc_data *)map_id2bl(st->oid);
if( st->end > st->start+2 ) {
char *name = conv_str(st,& (st->stack->stack_data[st->start+2]));
sd=map_nick2sd(name);
@@ -4270,7 +4270,7 @@ int buildin_sc_start(struct script_state *st)
bl = map_id2bl(conv_num(st,& (st->stack->stack_data[st->start+5])));
else
bl = map_id2bl(st->rid);
-
+
if (bl != 0) {
if(bl->type == BL_PC && ((struct map_session_data *)bl)->state.potionpitcher_flag)
bl = map_id2bl(((struct map_session_data *)bl)->skilltarget);
@@ -5101,7 +5101,7 @@ int buildin_getcastlename(struct script_state *st)
for(i=0;i<MAX_GUILDCASTLE;i++){
if( (gc=guild_castle_search(i)) != NULL ){
if(strcmp(mapname,gc->map_name)==0){
- buf=(char *)aCalloc(24,sizeof(char));
+ buf=(char *)aCallocA(24,sizeof(char));
strncpy(buf,gc->castle_name,24);
break;
}
@@ -5343,8 +5343,8 @@ int buildin_failedremovecards(struct script_state *st)
if( (sd->status.inventory[i].card[c-1] > 4000 &&
sd->status.inventory[i].card[c-1] < 5000) ||
itemdb_type(sd->status.inventory[i].card[c-1]) == 6){ // [Celest]
-
- cardflag = 1;
+
+ cardflag = 1;
if(typefail == 2){ // 武具のみ損失なら、カードは受け取らせる
item_tmp.id=0,item_tmp.nameid=sd->status.inventory[i].card[c-1];
@@ -5561,39 +5561,39 @@ int buildin_strmobinfo(struct script_state *st)
{
int num=conv_num(st,& (st->stack->stack_data[st->start+2]));
- int class=conv_num(st,& (st->stack->stack_data[st->start+3]));
+ int class_=conv_num(st,& (st->stack->stack_data[st->start+3]));
- if(num<=0 || num>=8 || (class>=0 && class<=1000) || class >2000)
+ if(num<=0 || num>=8 || (class_>=0 && class_<=1000) || class_ >2000)
return 0;
if(num==1) {
char *buf;
- buf=aCalloc(24, 1);
-// buf=mob_db[class].name;
+ buf=aCallocA(24, 1);
+// buf=mob_db[class_].name;
// for string assignments you would need to go for c++ [Shinomori]
- strcpy(buf,mob_db[class].name);
+ strcpy(buf,mob_db[class_].name);
push_str(st->stack,C_STR,buf);
return 0;
}
else if(num==2) {
char *buf;
- buf=aCalloc(24, 1);
-// buf=mob_db[class].jname;
+ buf=aCallocA(24, 1);
+// buf=mob_db[class_].jname;
// for string assignments you would need to go for c++ [Shinomori]
- strcpy(buf,mob_db[class].jname);
+ strcpy(buf,mob_db[class_].jname);
push_str(st->stack,C_STR,buf);
return 0;
}
else if(num==3)
- push_val(st->stack,C_INT,mob_db[class].lv);
+ push_val(st->stack,C_INT,mob_db[class_].lv);
else if(num==4)
- push_val(st->stack,C_INT,mob_db[class].max_hp);
+ push_val(st->stack,C_INT,mob_db[class_].max_hp);
else if(num==5)
- push_val(st->stack,C_INT,mob_db[class].max_sp);
+ push_val(st->stack,C_INT,mob_db[class_].max_sp);
else if(num==6)
- push_val(st->stack,C_INT,mob_db[class].base_exp);
+ push_val(st->stack,C_INT,mob_db[class_].base_exp);
else if(num==7)
- push_val(st->stack,C_INT,mob_db[class].job_exp);
+ push_val(st->stack,C_INT,mob_db[class_].job_exp);
return 0;
}
@@ -5603,20 +5603,20 @@ int buildin_strmobinfo(struct script_state *st)
*/
int buildin_guardian(struct script_state *st)
{
- int class=0,amount=1,x=0,y=0,guardian=0;
+ int class_=0,amount=1,x=0,y=0,guardian=0;
char *str,*map,*event="";
map =conv_str(st,& (st->stack->stack_data[st->start+2]));
x =conv_num(st,& (st->stack->stack_data[st->start+3]));
y =conv_num(st,& (st->stack->stack_data[st->start+4]));
str =conv_str(st,& (st->stack->stack_data[st->start+5]));
- class=conv_num(st,& (st->stack->stack_data[st->start+6]));
+ class_=conv_num(st,& (st->stack->stack_data[st->start+6]));
amount=conv_num(st,& (st->stack->stack_data[st->start+7]));
event=conv_str(st,& (st->stack->stack_data[st->start+8]));
if( st->end>st->start+9 )
guardian=conv_num(st,& (st->stack->stack_data[st->start+9]));
- mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class,amount,event,guardian);
+ mob_spawn_guardian(map_id2sd(st->rid),map,x,y,str,class_,amount,event,guardian);
return 0;
}
@@ -5657,7 +5657,7 @@ int buildin_getitemname(struct script_state *st)
i_data = NULL;
i_data = itemdb_search(item_id);
- item_name=(char *)aCalloc(24,sizeof(char));
+ item_name=(char *)aCallocA(24,sizeof(char));
strncpy(item_name,i_data->jname,23);
push_str(st->stack,C_STR,item_name);
@@ -5671,12 +5671,12 @@ int buildin_getitemname(struct script_state *st)
int buildin_petskillbonus(struct script_state *st)
{
- int type,val,duration,timer;
+ int type,val,duration,timer;
struct pet_data *pd;
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data *sd=script_rid2sd(st);
- if(sd==NULL || sd->pd==NULL)
+ if(sd==NULL || sd->pd==NULL)
return 0;
pd=sd->pd;
@@ -5691,7 +5691,7 @@ int buildin_petskillbonus(struct script_state *st)
pd->skillbonusduration=-1;
pd->skillbonustimer=-1;
-
+
pet_skill_bonus(sd,pd,type,val,duration,timer,0);
return 0;
@@ -5719,7 +5719,7 @@ int buildin_petloot(struct script_state *st)
if(!max)
return 0;
-
+
pd->loot=1;
pd->lootmax=max;
@@ -5790,14 +5790,14 @@ int buildin_clearitem(struct script_state *st)
*/
int buildin_classchange(struct script_state *st)
{
- int class,type;
+ int _class,type;
struct block_list *bl=map_id2bl(st->oid);
-
+
if(bl==NULL) return 0;
- class=conv_num(st,& (st->stack->stack_data[st->start+2]));
+ _class=conv_num(st,& (st->stack->stack_data[st->start+2]));
type=conv_num(st,& (st->stack->stack_data[st->start+3]));
- clif_class_change(bl,class,type);
+ clif_class_change(bl,_class,type);
return 0;
}
@@ -5867,9 +5867,9 @@ int buildin_petrecovery(struct script_state *st)
{
struct pet_data *pd;
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data *sd=script_rid2sd(st);
- if(sd==NULL || sd->pd==NULL)
+ if(sd==NULL || sd->pd==NULL)
return 0;
pd=sd->pd;
@@ -5893,9 +5893,9 @@ int buildin_petheal(struct script_state *st)
{
struct pet_data *pd;
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data *sd=script_rid2sd(st);
- if(sd==NULL || sd->pd==NULL)
+ if(sd==NULL || sd->pd==NULL)
return 0;
pd=sd->pd;
@@ -5911,7 +5911,7 @@ int buildin_petheal(struct script_state *st)
return 0;
}
-
+
/*==========================================
* pet magnificat [Valaris]
*------------------------------------------
@@ -5919,9 +5919,9 @@ int buildin_petheal(struct script_state *st)
int buildin_petmag(struct script_state *st)
{
struct pet_data *pd;
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data *sd=script_rid2sd(st);
- if(sd==NULL || sd->pd==NULL)
+ if(sd==NULL || sd->pd==NULL)
return 0;
pd=sd->pd;
@@ -5946,9 +5946,9 @@ int buildin_petmag(struct script_state *st)
int buildin_petskillattack(struct script_state *st)
{
struct pet_data *pd;
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data *sd=script_rid2sd(st);
- if(sd==NULL || sd->pd==NULL)
+ if(sd==NULL || sd->pd==NULL)
return 0;
pd=sd->pd;
@@ -5957,7 +5957,7 @@ int buildin_petskillattack(struct script_state *st)
return 0;
pd->skilltype=conv_num(st,& (st->stack->stack_data[st->start+2]));
- pd->skillval=conv_num(st,& (st->stack->stack_data[st->start+3]));
+ pd->skillval=conv_num(st,& (st->stack->stack_data[st->start+3]));
pd->skillduration=conv_num(st,& (st->stack->stack_data[st->start+4]));
pd->skilltimer=conv_num(st,& (st->stack->stack_data[st->start+5]));
@@ -5973,11 +5973,11 @@ int buildin_petskillattack(struct script_state *st)
int buildin_skilleffect(struct script_state *st)
{
struct map_session_data *sd;
-
+
int skillid=conv_num(st,& (st->stack->stack_data[st->start+2]));
int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3]));
sd=script_rid2sd(st);
-
+
clif_skill_nodamage(&sd->bl,&sd->bl,skillid,skilllv,1);
return 0;
@@ -5990,9 +5990,9 @@ int buildin_skilleffect(struct script_state *st)
int buildin_npcskilleffect(struct script_state *st)
{
struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid);
-
+
int skillid=conv_num(st,& (st->stack->stack_data[st->start+2]));
- int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3]));
+ int skilllv=conv_num(st,& (st->stack->stack_data[st->start+3]));
int x=conv_num(st,& (st->stack->stack_data[st->start+4]));
int y=conv_num(st,& (st->stack->stack_data[st->start+5]));
@@ -6036,13 +6036,13 @@ int buildin_specialeffect2(struct script_state *st)
int buildin_nude(struct script_state *st)
{
- struct map_session_data *sd=script_rid2sd(st);
+ struct map_session_data *sd=script_rid2sd(st);
int i;
if(sd==NULL)
return 0;
-
- for(i=0;i<11;i++)
+
+ for(i=0;i<11;i++)
if(sd->equip_index[i] >= 0)
pc_unequipitem(sd,sd->equip_index[i],2);
@@ -6118,7 +6118,7 @@ int buildin_message(struct script_state *st)
* area) [Valaris]
*------------------------------------------
*/
-
+
int buildin_npctalk(struct script_state *st)
{
char *str;
@@ -6148,16 +6148,16 @@ int buildin_hasitems(struct script_state *st)
{
int i;
struct map_session_data *sd;
-
+
sd=script_rid2sd(st);
-
+
for(i=0; i<MAX_INVENTORY; i++) {
if(sd->status.inventory[i].amount) {
push_val(st->stack,C_INT,1);
return 0;
}
}
-
+
push_val(st->stack,C_INT,0);
return 0;
@@ -6262,7 +6262,7 @@ int buildin_getsavepoint(struct script_state *st)
sd=script_rid2sd(st);
type=conv_num(st,& (st->stack->stack_data[st->start+2]));
- mapname=aCalloc(24, 1);
+ mapname=aCallocA(24, 1);
x=sd->status.save_point.x;
y=sd->status.save_point.y;
@@ -6331,7 +6331,7 @@ int buildin_getmapxy(struct script_state *st){
//??????????? >>> Possible needly check function parameters on C_STR,C_INT,C_INT <<< ???????????//
type=conv_num(st,& (st->stack->stack_data[st->start+5]));
- mapname=aCalloc(24, 1);
+ mapname=aCallocA(24, 1);
switch (type){
case 0: //Get Character Position
@@ -6363,7 +6363,7 @@ int buildin_getmapxy(struct script_state *st){
}
x=nd->bl.x;
- y=nd->bl.y;
+ y=nd->bl.y;
strncpy(mapname,map[nd->bl.m].name,24);
printf(">>>>%s %d %d\n",mapname,x,y);
break;
@@ -6385,7 +6385,7 @@ int buildin_getmapxy(struct script_state *st){
return 0;
}
x=pd->bl.x;
- y=pd->bl.y;
+ y=pd->bl.y;
strncpy(mapname,map[pd->bl.m].name,24);
printf(">>>>%s %d %d\n",mapname,x,y);
@@ -6491,7 +6491,7 @@ int buildin_logmes(struct script_state *st)
int buildin_summon(struct script_state *st)
{
- int class, id;
+ int _class, id;
char *str,*event="";
struct map_session_data *sd;
struct mob_data *md;
@@ -6500,11 +6500,11 @@ int buildin_summon(struct script_state *st)
if (sd) {
int tick = gettick();
str =conv_str(st,& (st->stack->stack_data[st->start+2]));
- class=conv_num(st,& (st->stack->stack_data[st->start+3]));
+ _class=conv_num(st,& (st->stack->stack_data[st->start+3]));
if( st->end>st->start+4 )
event=conv_str(st,& (st->stack->stack_data[st->start+4]));
- id=mob_once_spawn(sd, "this", 0, 0, str,class,1,event);
+ id=mob_once_spawn(sd, "this", 0, 0, str,_class,1,event);
if((md=(struct mob_data *)map_id2bl(id))){
md->master_id=sd->bl.id;
md->state.special_mob_ai=1;
@@ -6608,14 +6608,14 @@ void op_add(struct script_state* st)
st->stack->stack_data[st->stack->sp-1].u.num += st->stack->stack_data[st->stack->sp].u.num;
} else { // ssの予定
char *buf;
- buf=(char *)aCalloc(strlen(st->stack->stack_data[st->stack->sp-1].u.str)+
+ buf=(char *)aCallocA(strlen(st->stack->stack_data[st->stack->sp-1].u.str)+
strlen(st->stack->stack_data[st->stack->sp].u.str)+1,sizeof(char));
strcpy(buf,st->stack->stack_data[st->stack->sp-1].u.str);
strcat(buf,st->stack->stack_data[st->stack->sp].u.str);
if(st->stack->stack_data[st->stack->sp-1].type==C_STR)
- free(st->stack->stack_data[st->stack->sp-1].u.str);
+ aFree(st->stack->stack_data[st->stack->sp-1].u.str);
if(st->stack->stack_data[st->stack->sp].type==C_STR)
- free(st->stack->stack_data[st->stack->sp].u.str);
+ aFree(st->stack->stack_data[st->stack->sp].u.str);
st->stack->stack_data[st->stack->sp-1].type=C_STR;
st->stack->stack_data[st->stack->sp-1].u.str=buf;
}
@@ -6657,8 +6657,8 @@ void op_2str(struct script_state *st,int op,int sp1,int sp2)
push_val(st->stack,C_INT,a);
- if(st->stack->stack_data[sp1].type==C_STR) free(s1);
- if(st->stack->stack_data[sp2].type==C_STR) free(s2);
+ if(st->stack->stack_data[sp1].type==C_STR) aFree(s1);
+ if(st->stack->stack_data[sp2].type==C_STR) aFree(s2);
}
/*==========================================
* 二項演算子(数値)
@@ -6672,7 +6672,11 @@ void op_2num(struct script_state *st,int op,int i1,int i2)
break;
case C_MUL:
{
+ #ifndef _MSC_VER
long long res = i1 * i2;
+ #else
+ __int64 res = i1 * i2;
+ #endif
if (res > 2147483647 )
i1 = 2147483647;
else
@@ -6988,7 +6992,7 @@ int run_script_main(unsigned char *script,int pos,int rid,int oid,struct script_
struct map_session_data *sd=map_id2sd(st->rid);
if(sd/* && sd->npc_stackbuf==NULL*/){
if( sd->npc_stackbuf )
- free( sd->npc_stackbuf );
+ aFree( sd->npc_stackbuf );
sd->npc_stackbuf = (char *)aCalloc(sizeof(stack->stack_data[0])*stack->sp_max,sizeof(char));
memcpy(sd->npc_stackbuf, stack->stack_data, sizeof(stack->stack_data[0]) * stack->sp_max);
sd->npc_stack = stack->sp;
@@ -7022,7 +7026,7 @@ int run_script(unsigned char *script,int pos,int rid,int oid)
stack.sp_max=sd->npc_stackmax;
stack.stack_data=(struct script_data *)aCalloc(stack.sp_max,sizeof(stack.stack_data[0]));
memcpy(stack.stack_data,sd->npc_stackbuf,sizeof(stack.stack_data[0])*stack.sp_max);
- free(sd->npc_stackbuf);
+ aFree(sd->npc_stackbuf);
sd->npc_stackbuf=NULL;
}else{
// スタック初期化
@@ -7036,7 +7040,7 @@ int run_script(unsigned char *script,int pos,int rid,int oid)
st.oid=oid;
run_script_main(script,pos,rid,oid,&st,rootscript);
- free(stack.stack_data);
+ aFree(stack.stack_data);
stack.stack_data=NULL;
return st.pos;
}
@@ -7065,14 +7069,14 @@ int mapreg_setregstr(int num,const char *str)
char *p;
if( (p=numdb_search(mapregstr_db,num))!=NULL )
- free(p);
+ aFree(p);
if( str==NULL || *str==0 ){
numdb_erase(mapregstr_db,num);
mapreg_dirty=1;
return 0;
}
- p=(char *)aCalloc(strlen(str)+1, sizeof(char));
+ p=(char *)aCallocA(strlen(str)+1, sizeof(char));
strcpy(p,str);
numdb_insert(mapregstr_db,num,p);
mapreg_dirty=1;
@@ -7102,7 +7106,7 @@ static int script_load_mapreg()
printf("%s: %s broken data !\n",mapreg_txt,buf1);
continue;
}
- p=(char *)aCalloc(strlen(buf2) + 1,sizeof(char));
+ p=(char *)aCallocA(strlen(buf2) + 1,sizeof(char));
strcpy(p,buf2);
s=add_str(buf1);
numdb_insert(mapregstr_db,(i<<24)|s,p);
@@ -7170,7 +7174,7 @@ static int script_autosave_mapreg(int tid,unsigned int tick,int id,int data)
}
/*==========================================
- *
+ *
*------------------------------------------
*/
static int set_posword(char *p)
@@ -7256,7 +7260,7 @@ static int mapreg_db_final(void *key,void *data,va_list ap)
}
static int mapregstr_db_final(void *key,void *data,va_list ap)
{
- free(data);
+ aFree(data);
return 0;
}
static int scriptlabel_db_final(void *key,void *data,va_list ap)
@@ -7265,8 +7269,8 @@ static int scriptlabel_db_final(void *key,void *data,va_list ap)
}
static int userfunc_db_final(void *key,void *data,va_list ap)
{
- free(key);
- free(data);
+ aFree(key);
+ aFree(data);
return 0;
}
int do_final_script()
@@ -7274,7 +7278,7 @@ int do_final_script()
if(mapreg_dirty>=0)
script_save_mapreg();
if(script_buf)
- free(script_buf);
+ aFree(script_buf);
if(mapreg_db)
numdb_final(mapreg_db,mapreg_db_final);
@@ -7286,9 +7290,9 @@ int do_final_script()
strdb_final(userfunc_db,userfunc_db_final);
if (str_data)
- free(str_data);
+ aFree(str_data);
if (str_buf)
- free(str_buf);
+ aFree(str_buf);
return 0;
}
diff --git a/src/map/skill.c b/src/map/skill.c
index 8ede774e3..16cb26c06 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -730,7 +730,7 @@ const struct skill_name_db skill_names[] = {
{ WZ_STORMGUST, "STORMGUST", "Storm_Gust" } ,
{ WZ_VERMILION, "VERMILION", "Lord_of_Vermilion" } ,
{ WZ_WATERBALL, "WATERBALL", "Water_Ball" } ,
- { 0, 0, 0 }
+ { 0, 0, 0 }
};
static const int dirx[8]={0,-1,-1,-1,0,1,1,1};
@@ -890,8 +890,8 @@ int skillnotok(int skillid, struct map_session_data *sd) {
if (sd == 0)
return 0;
- if (!(skillid >= 10000 && skillid < 10015))
- if ((skillid > MAX_SKILL) || (skillid < 0))
+ if (!(skillid >= 10000 && skillid < 10015))
+ if ((skillid > MAX_SKILL) || (skillid < 0))
return 1;
if (pc_isGM(sd) >= 20)
@@ -1055,12 +1055,12 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s
//if(skilllv <= 0) return 0;
if(skillid > 0 && skilllv <= 0) return 0; // don't forget auto attacks! - celest
- if(src->type==BL_PC){
- nullpo_retr(0, sd=(struct map_session_data *)src);
- }else if(src->type==BL_MOB){
- nullpo_retr(0, md=(struct mob_data *)src); //未使用?
- }else if(src->type==BL_PET){
- nullpo_retr(0, pd=(struct pet_data *)src); // [Valaris]
+ if (src->type == BL_PC){
+ nullpo_retr(0, sd = (struct map_session_data *)src);
+ } else if (src->type == BL_MOB){
+ nullpo_retr(0, md = (struct mob_data *)src); //未使用?
+ } else if (src->type == BL_PET){
+ nullpo_retr(0, pd = (struct pet_data *)src); // [Valaris]
}
//?象の耐性
@@ -1088,6 +1088,13 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s
if(sc_def_luk<50)
sc_def_luk=50;
}
+ if (dstsd && dstsd->sc_count && dstsd->sc_data[SC_GOSPEL].timer != -1 &&
+ dstsd->sc_data[SC_GOSPEL].val4 == BCT_PARTY &&
+ dstsd->sc_data[SC_GOSPEL].val3 == 3) {
+ sc_def_mdef -= 25;
+ sc_def_vit -= 25;
+ sc_def_int -= 25;
+ }
if(sc_def_mdef<0)
sc_def_mdef=0;
if(sc_def_vit<0)
@@ -1291,18 +1298,18 @@ int skill_additional_effect( struct block_list* src, struct block_list *bl,int s
//
case WZ_METEOR:
if(rand()%100 < sc_def_vit)
- skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0);
+ skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0);
break;
case WZ_VERMILION:
if(rand()%100 < sc_def_int)
- skill_status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0);
+ skill_status_change_start(bl,SC_BLIND,skilllv,0,0,0,skill_get_time2(skillid,skilllv),0);
break;
// -- moonsoul (stun ability of new champion skill tigerfist)
//
case CH_TIGERFIST:
if( rand()%100 < (10 + skilllv*10)*sc_def_vit/100 ) {
- int sec = skill_get_time2 (skillid,skilllv) - (double)battle_get_agi(bl)*0.1;
+ int sec = skill_get_time2 (skillid,skilllv) - battle_get_agi(bl)/10;
skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,sec,0);
}
break;
@@ -1577,7 +1584,7 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds
return 0;
if(bl->type == BL_PC && pc_isdead((struct map_session_data *)bl)) //?象がPCですでに死んでいたら何もしない
return 0;
- if(bl->type == BL_PC && skillnotok(skillid, (struct map_session_data *) bl))
+ if(bl->type == BL_PC && skillnotok(skillid, (struct map_session_data *) bl))
return 0; // [MouseJstr]
if(sc_data && sc_data[SC_HIDING].timer != -1) { //ハイディング?態で
if(skill_get_pl(skillid) != 2) //スキルの?性が地?性でなければ何もしない
@@ -2297,7 +2304,7 @@ int skill_cleartimerskill(struct block_list *src)
*/
int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int skillid,int skilllv,unsigned int tick,int flag )
{
- struct map_session_data *sd=NULL;
+ struct map_session_data *sd = NULL;
struct status_change *sc_data = battle_get_sc_data(src);
int i;
@@ -2374,7 +2381,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
case LK_SPIRALPIERCE: /* スパイラルピア?ス */
case LK_HEADCRUSH: /* ヘッドクラッシュ */
case LK_JOINTBEAT: /* ジョイントビ?ト */
- case PA_PRESSURE: /* プレッシャ? */
+// case PA_PRESSURE: /* プレッシャ? */
// case PA_SACRIFICE: /* サクリファイス */
case SN_SHARPSHOOTING: /* シャ?プシュ?ティング */
case CG_ARROWVULCAN: /* アロ?バルカン */
@@ -2383,6 +2390,22 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
case ITM_TOMAHAWK:
skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag);
break;
+ case PA_PRESSURE: /* プレッシャ? */
+ skill_attack(BF_WEAPON,src,src,bl,skillid,skilllv,tick,flag);
+ if (rand()%100 < 50)
+ skill_status_change_start(bl,SC_STAN,skilllv,0,0,0,skill_get_time2(PA_PRESSURE,skilllv),0);
+ else
+ skill_status_change_start(bl,SC_BLEEDING,skilllv,0,0,0,skill_get_time2(PA_PRESSURE,skilllv),0);
+ if (bl->type == BL_PC) {
+ int sp;
+ struct map_session_data *tsd = (struct map_session_data *)bl;
+ nullpo_retb (tsd);
+ sp = tsd->status.max_sp * 10 * skilllv / 100;
+ if (sp > tsd->status.sp) sp = tsd->status.sp;
+ tsd->status.sp -= sp;
+ pc_heal(sd,0,-sp);
+ }
+ break;
case NPC_DARKBREATH:
clif_emotion(src,7);
skill_attack(BF_MISC,src,src,bl,skillid,skilllv,tick,flag);
@@ -2429,7 +2452,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
else if (bl->type == BL_MOB)
((struct mob_data *)bl)->dir=dir;
clif_changed_dir(bl);
- //skill_blown(src,bl,skill_get_blewcount(skillid,skilllv));
+ //skill_blown(src,bl,skill_get_blewcount(skillid,skilllv));
}
else if(src->type == BL_PC)
clif_skill_fail(sd,sd->skillid,0,0);
@@ -2558,7 +2581,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
if (skillid == ASC_METEORASSAULT)
clif_skill_nodamage(src,bl,skillid,skilllv,1);
-
+
skill_area_temp[1]=bl->id;
skill_area_temp[2]=x;
skill_area_temp[3]=y;
@@ -2752,7 +2775,7 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
case WZ_FROSTNOVA: /* フロストノヴァ */
skill_castend_pos2(src,bl->x,bl->y,skillid,skilllv,tick,0);
//skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,flag);
- map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY);
+ map_foreachinarea(skill_attack_area,src->m,src->x-5,bl->y-5,bl->x+5,bl->y+5,0,BF_MAGIC,src,src,skillid,skilllv,tick,flag,BCT_ENEMY);
break;
case WZ_SIGHTRASHER:
@@ -2806,8 +2829,10 @@ int skill_castend_damage_id( struct block_list* src, struct block_list *bl,int s
clif_skill_nodamage(src,bl,skillid,skilllv,1);
if (skilllv == 5)
skill_attack(BF_MAGIC,src,src,bl,skillid,skilllv,tick,0 );
- if (bl->type == BL_PC)
+ if (bl->type == BL_PC) {
((struct map_session_data *)bl)->status.sp = 0;
+ clif_updatestatus((struct map_session_data *)bl,SP_SP);
+ }
} else {
clif_skill_nodamage(src,src,skillid,skilllv,1);
if (skilllv == 5)
@@ -2961,7 +2986,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
return 1;
if (skillnotok(skillid, (struct map_session_data *)bl)) // [MouseJstr]
return 0;
-
+
map_freeblock_lock();
switch(skillid)
{
@@ -2971,7 +2996,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
int heal_get_jobexp;
int skill;
struct pc_base_job s_class;
-
+
if( dstsd && dstsd->special_state.no_magic_damage )
heal=0; /* ?金蟲カ?ド(ヒ?ル量0) */
if (sd){
@@ -2981,7 +3006,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
if(sd && dstsd && sd->status.partner_id == dstsd->status.char_id && s_class.job == 23 && sd->status.sex == 0) //自分も?象もPC、?象が自分のパ?トナ?、自分がスパノビ、自分が♀なら
heal = heal*2; //スパノビの嫁が旦那にヒ?ルすると2倍になる
}
-
+
clif_skill_nodamage(src,bl,skillid,heal,1);
heal_get_jobexp = battle_heal(NULL,bl,heal,0,0);
@@ -3192,11 +3217,11 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
struct status_change *tsc_data = battle_get_sc_data(bl);
int sc = SkillStatusChangeTable[skillid];
int sc2 = SC_MARIONETTE2;
-
+
if((dstsd->bl.type!=BL_PC)
|| (sd->bl.id == dstsd->bl.id)
|| (!sd->status.party_id)
- || (sd->status.party_id != dstsd->status.party_id)) {
+ || (sd->status.party_id != dstsd->status.party_id)) {
clif_skill_fail(sd,skillid,0,0);
map_freeblock_unlock();
return 1;
@@ -3218,7 +3243,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
}
clif_skill_nodamage(src,bl,skillid,skilllv,1);
}
- }
+ }
break;
case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris]
@@ -3303,7 +3328,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
skill_status_change_start(bl,SkillStatusChangeTable[skillid],skilllv,0,0,0,skill_get_time(skillid,skilllv),0 );
skill_status_change_start(src,SC_BLOCKSKILL,skilllv,0,skillid,0,10000,0 );
break;
-
+
case SM_AUTOBERSERK: // Celest
{
struct status_change *tsc_data = battle_get_sc_data(bl);
@@ -3317,7 +3342,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
}
}
break;
-
+
case AS_ENCHANTPOISON: // Prevent spamming [Valaris]
if(bl->type==BL_PC) {
struct map_session_data *sd2=(struct map_session_data *)bl;
@@ -3385,11 +3410,12 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
skill_status_change_end(bl,SC_SLEEP,-1);
}
- if(bl->type==BL_MOB) {
+ if(dstmd) {
int range = skill_get_range(skillid,skilllv);
if(range < 0)
range = battle_get_range(src) - (range + 1);
- mob_target((struct mob_data *)bl,src,range);
+ md->state.provoke_flag = src->id;
+ mob_target(dstmd,src,range);
}
}
break;
@@ -3506,7 +3532,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
clif_skill_produce_mix_list(sd,256);
clif_skill_nodamage(src,bl,skillid,skilllv,1);
}
- break;
+ break;
case BS_HAMMERFALL: /* ハンマ?フォ?ル */
clif_skill_nodamage(src,bl,skillid,skilllv,1);
if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_weapon_damage )
@@ -3733,6 +3759,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
skill_clear_unitgroup(src);
clif_skill_nodamage(src,bl,skillid,skilllv,1);
skill_unitsetting(src,skillid,skilllv,src->x,src->y,0);
+ skill_status_change_start(src,SkillStatusChangeTable[skillid],skilllv,0,0,BCT_SELF,skill_get_time(skillid,skilllv),0);
break;
case BD_ADAPTATION: /* アドリブ */
@@ -4402,20 +4429,20 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking)
pc_breakweapon((struct map_session_data *)bl);
break;
-
+
case NPC_BREAKARMOR:
clif_skill_nodamage(src,bl,skillid,skilllv,1);
if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking)
pc_breakarmor((struct map_session_data *)bl);
break;
-
+
case NPC_BREAKHELM:
clif_skill_nodamage(src,bl,skillid,skilllv,1);
if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking)
// since we don't have any code for helm breaking yet...
pc_breakweapon((struct map_session_data *)bl);
break;
-
+
case NPC_BREAKSHIELD:
clif_skill_nodamage(src,bl,skillid,skilllv,1);
if(bl->type == BL_PC && rand()%100 < skilllv && battle_config.equipment_breaking)
@@ -4449,7 +4476,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
if(map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto || map[dstsd->bl.m].flag.nowarp){
clif_skill_teleportmessage(sd,1);
return 0;
- }
+ }
skill_unitsetting(src,skillid,skilllv,sd->bl.x,sd->bl.y,0);
}
break;
@@ -4500,7 +4527,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
}
}
-
+
}
if(su->group->unit_id == 0x91 && su->group->val2){
struct block_list *target=map_id2bl(su->group->val2);
@@ -4595,7 +4622,9 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
sd->status.sp = sp2;
dstsd->status.sp = sp1;
clif_heal(sd->fd,SP_SP,sp2);
+ clif_updatestatus(sd,SP_SP);
clif_heal(dstsd->fd,SP_SP,sp1);
+ clif_updatestatus(dstsd,SP_SP);
} else if (dstmd) {
if (dstmd->state.soul_change_flag) {
clif_skill_fail(sd,skillid,0,0);
@@ -4607,6 +4636,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
sp2 = sd->status.max_sp - sd->status.sp;
sd->status.sp += sp2;
clif_heal(sd->fd,SP_SP,sp2);
+ clif_updatestatus(sd,SP_SP);
dstmd->state.soul_change_flag = 1;
}
}
@@ -4661,6 +4691,15 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
}
}
break;
+ case ST_PRESERVE:
+ if (sd){
+ if (sd->sc_count && sd->sc_data[SC_PRESERVE].timer != -1)
+ skill_status_change_end(src, SC_PRESERVE, -1 );
+ else
+ skill_status_change_start(src,SC_PRESERVE,skilllv,0,0,0,skill_get_time(skillid, skilllv),0 );
+ clif_skill_nodamage(src,src,skillid,skilllv,1);
+ }
+ break;
// New guild skills [Celest]
case GD_BATTLEORDER:
@@ -4713,7 +4752,7 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
}
}
break;
- case GD_RESTORE:
+ case GD_RESTORE:
{
struct guild *g = NULL;
// Only usable during WoE
@@ -4725,8 +4764,8 @@ int skill_castend_nodamage_id( struct block_list *src, struct block_list *bl,int
if(flag&1) {
if (dstsd && dstsd->status.guild_id == sd->status.guild_id) {
int hp, sp;
- hp = dstsd->status.max_hp*0.9;
- sp = dstsd->status.max_sp*0.9;
+ hp = dstsd->status.max_hp*9/10;
+ sp = dstsd->status.max_sp*9/10;
sp = dstsd->status.sp + sp <= dstsd->status.max_sp ? sp : dstsd->status.max_sp - dstsd->status.sp;
clif_skill_nodamage(src,bl,AL_HEAL,hp,1);
battle_heal(NULL,bl,hp,sp,0);
@@ -4937,8 +4976,8 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil
if(src->type==BL_PC){
nullpo_retr(0, sd=(struct map_session_data *)src);
}
- if( skillid != WZ_METEOR &&
- skillid != WZ_SIGHTRASHER &&
+ if( skillid != WZ_METEOR &&
+ skillid != WZ_SIGHTRASHER &&
skillid != AM_CANNIBALIZE &&
skillid != AM_SPHEREMINE)
clif_skill_poseffect(src,skillid,skilllv,x,y,tick);
@@ -5015,7 +5054,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil
case HT_TALKIEBOX: /* ト?キ?ボックス */
skill_unitsetting(src,skillid,skilllv,x,y,0);
break;
-
+
case RG_GRAFFITI: /* Graffiti [Valaris] */
skill_clear_unitgroup(src);
skill_unitsetting(src,skillid,skilllv,x,y,0);
@@ -5088,7 +5127,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil
mx = x;// + (rand()%10 - 5);
my = y;// + (rand()%10 - 5);
-
+
id=mob_once_spawn(sd,"this",mx,my,"--ja--", summons[skilllv-1] ,1,"");
if( (md=(struct mob_data *)map_id2bl(id)) !=NULL ){
md->master_id=sd->bl.id;
@@ -5138,7 +5177,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,int skillid,int skil
map_foreachinarea(skill_area_sub,
src->m,x-3,y-3,x+3,y+3,0,
src,skillid,skilllv,tick,flag|BCT_ALL|1,
- skill_castend_nodamage_id);
+ skill_castend_nodamage_id);
}
}
}
@@ -5175,7 +5214,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma
sd->sc_data[SC_BERSERK].timer != -1 ||
sd->sc_data[SC_MARIONETTE].timer != -1)
return 0;
-
+
if (sd->sc_data[SC_BLOCKSKILL].timer!=-1)
if (skill_num == sd->sc_data[SC_BLOCKSKILL].val3)
return 0;
@@ -5243,7 +5282,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma
return 0;
if((group=skill_unitsetting(&sd->bl,sd->skillid,sd->skilllv,sd->skillx,sd->skilly,0))==NULL)
return 0;
- group->valstr=(char *)aCalloc(24,sizeof(char));
+ group->valstr=(char *)aCallocA(24,sizeof(char));
memcpy(group->valstr,map,24);
group->val2=(x<<16)|y;
}
@@ -5287,7 +5326,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid,
else count=3;
limit=skill_get_time(skillid,skilllv);
if(sc_data) {
- if (sc_data[SC_VIOLENTGALE].timer!=-1) limit *= 1.5;
+ if (sc_data[SC_VIOLENTGALE].timer!=-1) limit = limit*3/2;
}
// check for sc_data first - Celest
// if (((struct map_session_data *)src)->sc_data[SC_VIOLENTGALE].timer!=-1)
@@ -5337,7 +5376,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid,
if(skilllv < 6)
range=1;
else
- range=2;
+ range=2;
break;
case MG_THUNDERSTORM: /* サンダ?スト?ム */
@@ -5629,7 +5668,7 @@ struct skill_unit_group *skill_unitsetting( struct block_list *src, int skillid,
group->range=range;
if(skillid==HT_TALKIEBOX ||
skillid==RG_GRAFFITI){
- group->valstr=aCalloc(80, 1);
+ group->valstr=aCallocA(80, 1);
if(group->valstr==NULL){
printf("skill_castend_map: out of memory !\n");
exit(1);
@@ -6079,13 +6118,13 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int
{
struct status_change *sc_data=battle_get_sc_data(bl);
if(sg->val2==0 && sc_data && sc_data[SC_ANKLE].timer==-1){
- int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE);
- int sec=skill_get_time2(sg->skill_id,sg->skill_lv) - (double)battle_get_agi(bl)*0.1;
+ int moveblock = ( bl->x/BLOCK_SIZE != src->bl.x/BLOCK_SIZE || bl->y/BLOCK_SIZE != src->bl.y/BLOCK_SIZE);
+ int sec = skill_get_time2(sg->skill_id,sg->skill_lv) - battle_get_agi(bl)/10;
if(battle_get_mode(bl)&0x20)
sec = sec/5;
battle_stopwalking(bl,1);
skill_status_change_start(bl,SC_ANKLE,sg->skill_lv,0,0,0,sec,0);
-
+
if(moveblock) map_delblock(bl);
bl->x = src->bl.x;
bl->y = src->bl.y;
@@ -6127,7 +6166,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int
case 0x8e: /* クァグマイア */
{
struct status_change *sc_data=battle_get_sc_data(bl);
- int type=SkillStatusChangeTable[sg->skill_id];
+ int type=SkillStatusChangeTable[sg->skill_id];
if( bl->type==BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage )
break;
if(sc_data && sc_data[type].timer==-1)
@@ -6153,7 +6192,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int
if (sc_data[type].timer==-1)
skill_status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0);
else if((unit2=(struct skill_unit *)sc_data[type].val2) && unit2 != src ){
- if( unit2->group != 0 && DIFF_TICK(sg->tick,unit2->group->tick)>0 )
+ if( unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 )
skill_status_change_start(bl,type,sg->skill_lv,(int)src,0,0,skill_get_time2(sg->skill_id,sg->skill_lv),0);
ts->tick-=sg->interval;
}
@@ -6210,7 +6249,7 @@ int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int
skill_status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff,
(int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0);
else if((unit2=(struct skill_unit *)sc_data[type].val4) && unit2 != src ){
- if( unit2->group != 0 && DIFF_TICK(sg->tick,unit2->group->tick)>0 )
+ if( unit2->group && DIFF_TICK(sg->tick,unit2->group->tick)>0 )
skill_status_change_start(bl,type,sg->skill_lv,(sg->val1)>>16,(sg->val1)&0xffff,
(int)src,skill_get_time2(sg->skill_id,sg->skill_lv),0);
ts->tick-=sg->interval;
@@ -6489,7 +6528,7 @@ int skill_unit_onout(struct skill_unit *src,struct block_list *bl,unsigned int t
{
struct map_session_data *sd;
if (bl->type == BL_PC && (sd=(struct map_session_data *)bl) && sd->state.hawkeyes_flag > 0)
- sd->state.hawkeyes_flag = 0;
+ sd->state.hawkeyes_flag = 0;
}
break;
@@ -6578,7 +6617,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick)
src->bl.x,src->bl.y,1);
if(group == NULL)
return 0;
- group->valstr=aCalloc(24, 1);
+ group->valstr=aCallocA(24, 1);
if(group->valstr==NULL){
printf("skill_unit_onlimit: out of memory !\n");
exit(1);
@@ -6619,7 +6658,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick)
struct map_session_data *sd;
if ((sd = (struct map_session_data *)(map_id2bl(sg->src_id)))!= NULL) {
sd->state.glorywounds_flag = 0;
- }
+ }
}
break;
case 0xc3: // GD_SOULCOLD
@@ -6627,7 +6666,7 @@ int skill_unit_onlimit(struct skill_unit *src,unsigned int tick)
struct map_session_data *sd;
if ((sd = (struct map_session_data *)(map_id2bl(sg->src_id)))!= NULL) {
sd->state.soulcold_flag = 0;
- }
+ }
}
break;
case 0xc4: // GD_HAWKEYES
@@ -6905,7 +6944,7 @@ static int skill_check_condition_use_sub(struct block_list *bl,va_list ap)
nullpo_retr(0, ssd=(struct map_session_data*)src);
s_class = pc_calc_base_job(sd->status.class_);
-
+
//チェックしない設定ならcにありえない大きな?字を返して終了
if(!battle_config.player_skill_partner_check){ //本?はforeachの前にやりたいけど設定適用箇所をまとめるためにここへ
(*c)=99;
@@ -7034,7 +7073,7 @@ int skill_check_condition(struct map_session_data *sd,int type)
(sd->sc_data[SC_MARIONETTE].timer != -1 && sd->skillid != CG_MARIONETTE)){
clif_skill_fail(sd,sd->skillid,0,0);
return 0; /* ?態異常や沈?など */
- }
+ }
}
skill = sd->skillid;
lv = sd->skilllv;
@@ -7192,7 +7231,7 @@ int skill_check_condition(struct map_session_data *sd,int type)
break;
case MG_FIREWALL: /* ファイア?ウォ?ル */
case WZ_QUAGMIRE:
- case WZ_FIREPILLAR: // celest
+ case WZ_FIREPILLAR: // celest
case PF_FOGWALL:
/* ?制限 */
if(battle_config.pc_land_skill_limit) {
@@ -7340,7 +7379,7 @@ int skill_check_condition(struct map_session_data *sd,int type)
if(((itemid[i] >= 715 && itemid[i] <= 717) || itemid[i] == 1065) && sd->sc_data[SC_INTOABYSS].timer != -1)
continue;
if(skill == WZ_FIREPILLAR && lv<=5)
- continue; // no gemstones for 1-5 [Celest]
+ continue; // no gemstones for 1-5 [Celest]
if(skill == AM_POTIONPITCHER && i != x)
continue;
@@ -7357,7 +7396,7 @@ int skill_check_condition(struct map_session_data *sd,int type)
if(!(type&1))
return 1;
- if(skill != AM_POTIONPITCHER &&
+ if(skill != AM_POTIONPITCHER &&
skill != CR_SLIMPITCHER &&
skill != MG_STONECURSE) {
if(skill == AL_WARP && !(type&2))
@@ -7408,7 +7447,7 @@ int skill_castfix( struct block_list *bl, int time )
nullpo_retr(0, md=(struct mob_data*)bl);
skill = md->skillid;
lv = md->skilllv;
- } else {
+ } else {
nullpo_retr(0, sd=(struct map_session_data*)bl);
skill = sd->skillid;
lv = sd->skilllv;
@@ -7451,13 +7490,13 @@ int skill_delayfix( struct block_list *bl, int time )
{
struct status_change *sc_data;
struct map_session_data *sd = NULL;
- int skill,lv = 0;
- int delayrate=100;
-
+ int skill = 0,lv = 0;
+ int delayrate = 100;
+
nullpo_retr(0, bl);
- if(bl->type==BL_PC){
- nullpo_retr(0, sd=(struct map_session_data*)bl);
+ if(bl->type == BL_PC){
+ nullpo_retr(0, sd = (struct map_session_data*)bl);
skill = sd->skillid;
lv = sd->skilllv;
}
@@ -7466,24 +7505,32 @@ int skill_delayfix( struct block_list *bl, int time )
sc_data = battle_get_sc_data(bl);
- // instant cast attack skills depend on aspd as delay [celest]
- if (time <= 0 && skill_db[skill].skill_type == BF_WEAPON)
- time = battle_get_adelay (bl)/2;
-
if(sd) {
delayrate=((struct map_session_data *)bl)->delayrate;
+ // instant cast attack skills depend on aspd as delay [celest]
+ if (time == 0) {
+ if (skill_db[skill].skill_type == BF_WEAPON)
+ time = battle_get_adelay (bl)/2;
+ else
+ time = 300; // default delay, according to official servers
+ } else if (time < 0)
+ time = abs(time) + battle_get_adelay (bl)/2; // if set to <0, the aspd delay will be added
+
if(battle_config.delay_dependon_dex && /* dexの影響を計算する */
!skill_get_delaynodex(skill, lv)) // if skill casttime is allowed to be reduced by dex
- time=time*(battle_config.castrate_dex_scale - battle_get_dex(bl))/(battle_config.castrate_dex_scale);
+ time = time * (battle_config.castrate_dex_scale - battle_get_dex(bl)) / (battle_config.castrate_dex_scale);
- time=time*delayrate*battle_config.delay_rate/10000;
+ time = time * delayrate * battle_config.delay_rate / 10000;
+
+ if (time < battle_config.min_skill_delay_limit) // check minimum skill delay
+ time = battle_config.min_skill_delay_limit;
}
/* ブラギの詩 */
- if(sc_data && sc_data[SC_POEMBRAGI].timer!=-1 )
- time=time*(100-(sc_data[SC_POEMBRAGI].val1*3+sc_data[SC_POEMBRAGI].val2
- +(sc_data[SC_POEMBRAGI].val3&0xffff)))/100;
+ if(sc_data && sc_data[SC_POEMBRAGI].timer != -1 )
+ time = time * (100 - (sc_data[SC_POEMBRAGI].val1 * 3 + sc_data[SC_POEMBRAGI].val2
+ + (sc_data[SC_POEMBRAGI].val3 & 0xffff))) / 100;
return (time>0)?time:0;
}
@@ -7512,10 +7559,10 @@ int skill_use_id( struct map_session_data *sd, int target_id,
}
if(sd->bl.m != bl->m || pc_isdead(sd))
return 0;
-
+
if(skillnotok(skill_num, sd)) // [MouseJstr]
return 0;
-
+
sc_data=sd->sc_data;
/* 沈?や異常(ただし、グリムなどの判定をする) */
@@ -7598,7 +7645,7 @@ int skill_use_id( struct map_session_data *sd, int target_id,
case ST_CHASEWALK:
return 0;
}
- }*/
+ }*/
if(skill_get_inf2(skill_num)&0x200 && sd->bl.id == target_id)
return 0;
@@ -7671,15 +7718,27 @@ int skill_use_id( struct map_session_data *sd, int target_id,
if(!skill_check_condition(sd,0)) return 0;
- /* 射程と障害物チェック */
- range = skill_get_range(skill_num,skill_lv);
- if(range < 0)
- range = battle_get_range(&sd->bl) - (range + 1);
- // be lenient if the skill was cast before we have moved to the correct position [Celest]
- if (sd->walktimer != -1)
- range += battle_config.skill_range_leniency;
- if(!battle_check_range(&sd->bl,bl,range) )
- return 0;
+ {
+ int check_range_flag = 0;
+
+ /* 射程と障害物チェック */
+ range = skill_get_range(skill_num,skill_lv);
+ if(range < 0)
+ range = battle_get_range(&sd->bl) - (range + 1);
+ // be lenient if the skill was cast before we have moved to the correct position [Celest]
+ if (sd->walktimer != -1)
+ range += battle_config.skill_range_leniency;
+ else check_range_flag = 1;
+ if(!battle_check_range(&sd->bl,bl,range)) {
+ if (check_range_flag && battle_check_range(&sd->bl,bl,range + battle_config.skill_range_leniency)) {
+ int dir, mask[8][2] = {{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
+ dir = map_calc_dir(&sd->bl,bl->x,bl->y);
+ pc_walktoxy (sd, sd->bl.x + mask[dir][0] * battle_config.skill_range_leniency,
+ sd->bl.y + mask[dir][1] * battle_config.skill_range_leniency);
+ } else
+ return 0;
+ }
+ }
if(bl->type==BL_PC) {
target_sd=(struct map_session_data*)bl;
@@ -7745,13 +7804,12 @@ int skill_use_id( struct map_session_data *sd, int target_id,
case WE_MALE:
case WE_FEMALE:
{
+ struct map_session_data *p_sd = pc_get_partner(sd);
+ nullpo_retr (0, p_sd)
if(skill_num == WE_MALE && sd->status.hp <= ((15*sd->status.max_hp)/100)) // Requires more than 15% of Max HP for WE_MALE
return 0;
if(skill_num == WE_FEMALE && sd->status.sp <= ((15*sd->status.max_sp)/100)) // Requires more than 15% of Max SP for WE_FEMALE
return 0;
- struct map_session_data *p_sd = NULL;
- if((p_sd = pc_get_partner(sd)) == NULL)
- return 0;
target_id = p_sd->bl.id;
//rangeをもう1回?査
range = skill_get_range(skill_num,skill_lv);
@@ -7905,7 +7963,7 @@ int skill_use_pos( struct map_session_data *sd,
/* if(map[sd->bl.m].flag.gvg &&
(skill_num == SM_ENDURE || skill_num == AL_TELEPORT ||
- skill_num == AL_WARP || skill_num == WZ_ICEWALL ||
+ skill_num == AL_WARP || skill_num == WZ_ICEWALL ||
skill_num == TF_BACKSLIDING))
return 0;*/
@@ -8023,7 +8081,7 @@ int skill_castcancel(struct block_list *bl,int type)
}
sd->skilltimer=-1;
clif_skillcastcancel(bl);
- }
+ }
return 0;
}else if(bl->type==BL_MOB){
@@ -8695,12 +8753,14 @@ int skill_status_change_timer_sub(struct block_list *bl, va_list ap )
break;
case SC_RUWACH: /* ルアフ */
if( (*battle_get_option(bl))&6 ){
- skill_status_change_end( bl, SC_HIDING, -1);
- skill_status_change_end( bl, SC_CLOAKING, -1);
if(battle_check_target( src,bl, BCT_ENEMY ) > 0) {
- struct status_change *sc_data = battle_get_sc_data(bl);
- if (sc_data)
+ struct status_change *sc_data = battle_get_sc_data(bl); // check whether the target is hiding/cloaking [celest]
+ if (sc_data && (sc_data[SC_HIDING].timer != -1 || // if the target is using a special hiding, i.e not using normal hiding/cloaking, don't bother
+ sc_data[SC_CLOAKING].timer != -1)) {
+ skill_status_change_end( bl, SC_HIDING, -1);
+ skill_status_change_end( bl, SC_CLOAKING, -1);
skill_attack(BF_MAGIC,src,src,bl,AL_RUWACH,sc_data[type].val1,tick,0);
+ }
}
}
break;
@@ -8712,7 +8772,7 @@ int skill_status_change_timer_sub(struct block_list *bl, va_list ap )
* ステ?タス異常終了
*------------------------------------------
*/
-int skill_status_change_end(struct block_list* bl, int type, int tid)
+int skill_status_change_end(struct block_list* bl, int type, int tid)
{
struct status_change* sc_data;
int opt_flag=0, calc_flag = 0;
@@ -8798,8 +8858,6 @@ int skill_status_change_end(struct block_list* bl, int type, int tid)
case SC_MELTDOWN: /* メルトダウン */
// Celest
case SC_EDP:
- case SC_MARIONETTE:
- case SC_MARIONETTE2:
case SC_SLOWDOWN:
case SC_SPEEDUP0:
/* case SC_LEADERSHIP:
@@ -8816,7 +8874,7 @@ int skill_status_change_end(struct block_list* bl, int type, int tid)
break;
case SC_BERSERK: /* バ?サ?ク */
calc_flag = 1;
- clif_status_change(bl,SC_INCREASEAGI,0); /* アイコン消去 */
+ clif_status_change(bl,SC_INCREASEAGI,0); /* アイコン消去 */
break;
case SC_DEVOTION: /* ディボ?ション */
{
@@ -8900,14 +8958,32 @@ int skill_status_change_end(struct block_list* bl, int type, int tid)
case SC_CONFUSION:
{
struct map_session_data *sd=NULL;
- if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){
+ if(bl->type == BL_PC && (sd=(struct map_session_data *)bl)){
sd->next_walktime = -1;
}
}
break;
- }
- if(bl->type==BL_PC && type<SC_SENDMAX)
+ case SC_MARIONETTE: /* マリオネットコントロ?ル */
+ case SC_MARIONETTE2: /// Marionette target
+ {
+ // check for partner and end their marionette status as well
+ int type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE;
+ struct block_list *pbl = map_id2bl(sc_data[type].val3);
+ if (pbl) {
+ struct status_change* sc_data;
+ if (*battle_get_sc_count(pbl) > 0 &&
+ (sc_data = battle_get_sc_data(pbl)) &&
+ sc_data[type2].timer != -1)
+ skill_status_change_end(pbl, type2, -1);
+ }
+ calc_flag = 1;
+ }
+ break;
+ }
+
+ if(bl->type==BL_PC &&
+ (type<SC_SENDMAX || type==SC_PRESERVE || type==SC_BATTLEORDERS))
clif_status_change(bl,type,0); /* アイコン消去 */
switch(type){ /* 正常に?るときなにか?理が必要 */
@@ -8922,8 +8998,8 @@ int skill_status_change_end(struct block_list* bl, int type, int tid)
case SC_POISON:
if (sc_data[SC_DPOISON].timer != -1) //
break; // DPOISON用のオプション
- *opt2 &= ~1; // が?用に用意された場合には
- opt_flag = 1; // ここは削除する
+ *opt2 &= ~1; // が?用に用意された場合には
+ opt_flag = 1; // ここは削除する
break; //
case SC_CURSE:
case SC_SILENCE:
@@ -8932,7 +9008,7 @@ int skill_status_change_end(struct block_list* bl, int type, int tid)
opt_flag = 1;
break;
case SC_DPOISON:
- if (sc_data[SC_POISON].timer != -1) // DPOISON用のオプションが
+ if (sc_data[SC_POISON].timer != -1) // DPOISON用のオプションが
break; // 用意されたら削除
*opt2 &= ~1; // 毒?態解除
opt_flag = 1;
@@ -8966,7 +9042,7 @@ int skill_status_change_end(struct block_list* bl, int type, int tid)
*option &= ~8192;
opt_flag = 1;
break;
-
+
//opt3
case SC_TWOHANDQUICKEN: /* 2HQ */
case SC_SPEARSQUICKEN: /* スピアクイッケン */
@@ -9418,7 +9494,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data)
char timer[2];
sprintf (timer, "%d", sc_data[type].val4/1000);
clif_message(bl, timer);
- }
+ }
if((sc_data[type].val4 -= 500) > 0) {
sc_data[type].timer = add_timer(
500 + tick, skill_status_change_timer,
@@ -9437,7 +9513,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data)
1000 + tick, skill_status_change_timer,
bl->id, data);
return 0;
- }
+ }
}
break;
@@ -9451,7 +9527,7 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data)
bl->id, data);
}
break;*/
-
+
// Celest
case SC_CONFUSION:
{
@@ -9475,7 +9551,159 @@ int skill_status_change_timer(int tid, unsigned int tick, int id, int data)
}
}
break;
- }
+
+ case SC_GOSPEL:
+ {
+ int calc_flag = 0;
+ if (sc_data[type].val3 > 0) {
+ sc_data[type].val3 = 0;
+ calc_flag = 1;
+ }
+ if(sd && sc_data[type].val4 == BCT_SELF){
+ int hp, sp;
+ hp = (sc_data[type].val1 > 5) ? 45 : 30;
+ sp = (sc_data[type].val1 > 5) ? 35 : 20;
+ if(sd->status.hp - hp > 0 &&
+ sd->status.sp - sp > 0){
+ sd->status.hp -= hp;
+ sd->status.sp -= sp;
+ clif_updatestatus(sd,SP_HP);
+ clif_updatestatus(sd,SP_SP);
+ if ((sc_data[type].val2 -= 10000) > 0) {
+ sc_data[type].timer = add_timer(
+ 10000+tick, skill_status_change_timer,
+ bl->id, data);
+ return 0;
+ }
+ }
+ } else if (sd && sc_data[type].val4 == BCT_PARTY) {
+ int i;
+ switch ((i = rand() % 12)) {
+ case 1: // heal between 100-1000
+ {
+ struct block_list tbl;
+ int heal = rand() % 900 + 100;
+ tbl.id = 0;
+ tbl.m = bl->m;
+ tbl.x = bl->x;
+ tbl.y = bl->y;
+ clif_skill_nodamage(&tbl,bl,AL_HEAL,heal,1);
+ battle_heal(NULL,bl,heal,0,0);
+ }
+ break;
+ case 2: // end negative status
+ {
+ int j;
+ for (j=0; j<4; j++)
+ if(sc_data[i + SC_POISON].timer!=-1) {
+ skill_status_change_end(bl,j,-1);
+ break;
+ }
+ }
+ break;
+ case 3: // +25% resistance to negative status
+ case 4: // +25% max hp
+ case 5: // +25% max sp
+ case 6: // +2 to all stats
+ case 11: // +25% armor and vit def
+ case 12: // +8% atk
+ case 13: // +5% flee
+ case 14: // +5% hit
+ sc_data[type].val3 = i;
+ if (i == 6 ||
+ (i >= 11 && i <= 14))
+ calc_flag = 1;
+ break;
+ case 7: // level 5 bless
+ {
+ struct block_list tbl;
+ tbl.id = 0;
+ tbl.m = bl->m;
+ tbl.x = bl->x;
+ tbl.y = bl->y;
+ clif_skill_nodamage(&tbl,bl,AL_BLESSING,5,1);
+ skill_status_change_start(bl,SkillStatusChangeTable[AL_BLESSING],5,0,0,0,10000,0 );
+ }
+ break;
+ case 8: // level 5 increase agility
+ {
+ struct block_list tbl;
+ tbl.id = 0;
+ tbl.m = bl->m;
+ tbl.x = bl->x;
+ tbl.y = bl->y;
+ clif_skill_nodamage(&tbl,bl,AL_INCAGI,5,1);
+ skill_status_change_start(bl,SkillStatusChangeTable[AL_INCAGI],5,0,0,0,10000,0 );
+ }
+ break;
+ case 9: // holy element to weapon
+ {
+ struct block_list tbl;
+ tbl.id = 0;
+ tbl.m = bl->m;
+ tbl.x = bl->x;
+ tbl.y = bl->y;
+ clif_skill_nodamage(&tbl,bl,PR_ASPERSIO,1,1);
+ skill_status_change_start(bl,SkillStatusChangeTable[PR_ASPERSIO],1,0,0,0,10000,0 );
+ }
+ break;
+ case 10: // holy element to armour
+ {
+ struct block_list tbl;
+ tbl.id = 0;
+ tbl.m = bl->m;
+ tbl.x = bl->x;
+ tbl.y = bl->y;
+ clif_skill_nodamage(&tbl,bl,PR_BENEDICTIO,1,1);
+ skill_status_change_start(bl,SkillStatusChangeTable[PR_BENEDICTIO],1,0,0,0,10000,0 );
+ }
+ break;
+ default:
+ break;
+ }
+ } else if (sc_data[type].val4 == BCT_ENEMY) {
+ int i;
+ switch ((i = rand() % 8)) {
+ case 1: // damage between 300-800
+ case 2: // damage between 150-550 (ignore def)
+ battle_damage(NULL, bl, rand() % 500,0); // temporary damage
+ break;
+ case 3: // random status effect
+ {
+ int effect[3] = {
+ SC_CURSE,
+ SC_BLIND,
+ SC_POISON };
+ skill_status_change_start(bl,effect[rand()%3],1,0,0,0,10000,0 );
+ }
+ break;
+ case 4: // level 10 provoke
+ {
+ struct block_list tbl;
+ tbl.id = 0;
+ tbl.m = bl->m;
+ tbl.x = bl->x;
+ tbl.y = bl->y;
+ clif_skill_nodamage(&tbl,bl,SM_PROVOKE,1,1);
+ skill_status_change_start(bl,SkillStatusChangeTable[SM_PROVOKE],10,0,0,0,10000,0 );
+ }
+ break;
+ case 5: // 0 def
+ case 6: // 0 atk
+ case 7: // 0 flee
+ case 8: // -75% move speed and aspd
+ sc_data[type].val3 = i;
+ calc_flag = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if (sd && calc_flag)
+ pc_calcstatus (sd, 0);
+ }
+ break;
+ }
return skill_status_change_end( bl,type,tid );
}
@@ -9510,7 +9738,7 @@ int skill_encchant_eremental_end(struct block_list *bl,int type)
* ステ?タス異常開始
*------------------------------------------
*/
-int skill_status_change_start(struct block_list *bl, int type, int val1, int val2, int val3, int val4, int tick, int flag)
+int skill_status_change_start(struct block_list *bl, int type, int val1, int val2, int val3, int val4, int tick, int flag)
{
struct map_session_data *sd = NULL;
struct status_change* sc_data;
@@ -9660,7 +9888,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
break;
case SC_DECREASEAGI: /* 速度減少 */
if (bl->type == BL_PC) // Celest
- tick>>=1;
+ tick>>=1;
calc_flag = 1;
if(sc_data[SC_INCREASEAGI].timer!=-1 )
skill_status_change_end(bl,SC_INCREASEAGI,-1);
@@ -9718,7 +9946,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
calc_flag = 1;
break;
case SC_POISONREACT: /* ポイズンリアクト */
- val2=val1/2 + val1%2; // [Celest]
+ val2=val1/2 + val1%2; // [Celest]
break;
case SC_IMPOSITIO: /* インポシティオマヌス */
calc_flag = 1;
@@ -9756,7 +9984,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
case SC_TRICKDEAD: /* 死んだふり */
if (bl->type == BL_PC) {
pc_stopattack((struct map_session_data *)sd);
- }
+ }
break;
case SC_QUAGMIRE: /* クァグマイア */
calc_flag = 1;
@@ -9814,7 +10042,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
case SC_STRIPSHIELD:
if (val2==0) val2=85;
break;
- case SC_STRIPARMOR:
+ case SC_STRIPARMOR:
case SC_STRIPHELM:
case SC_CP_WEAPON:
case SC_CP_SHIELD:
@@ -9970,7 +10198,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
case SC_WEDDING: //結婚用(結婚衣裳になって?くのが?いとか)
{
time_t timer;
-
+
calc_flag = 1;
tick = 10000;
if(!val2)
@@ -9983,7 +10211,7 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
if(!battle_config.muting_players)
break;
-
+
tick = 60000;
if(!val2)
val2 = time(&timer);
@@ -10243,6 +10471,30 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
case SC_BASILICA: // [celest]
break;
+ case SC_GOSPEL:
+ if (val4 == BCT_SELF) { // self effect
+ int i;
+ if (sd) {
+ sd->canact_tick += tick;
+ sd->canmove_tick += tick;
+ }
+ val2 = tick;
+ tick = 1000;
+ for (i=0; i<=26; i++) {
+ if(sc_data[i].timer!=-1)
+ skill_status_change_end(bl,i,-1);
+ }
+ for (i=58; i<=62; i++) {
+ if(sc_data[i].timer!=-1)
+ skill_status_change_end(bl,i,-1);
+ }
+ for (i=132; i<=136; i++) {
+ if(sc_data[i].timer!=-1)
+ skill_status_change_end(bl,i,-1);
+ }
+ }
+ break;
+
case SC_MARIONETTE: /* マリオネットコントロ?ル */
case SC_MARIONETTE2:
val2 = tick;
@@ -10284,6 +10536,9 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
// calc_flag = 1; // not sure of effects yet [celest]
break;
+ case SC_PRESERVE:
+ break;
+
case SC_BLOCKSKILL:
if (!tick) tick = 60000;
if (!val3) val3 = -1;
@@ -10307,7 +10562,8 @@ int skill_status_change_start(struct block_list *bl, int type, int val1, int val
return 0;
}
- if(bl->type==BL_PC && type<SC_SENDMAX)
+ if(bl->type==BL_PC &&
+ (type<SC_SENDMAX || type==SC_PRESERVE || type==SC_BATTLEORDERS))
clif_status_change(bl,type,1); /* アイコン表示 */
/* optionの?更 */
@@ -10419,14 +10675,6 @@ int skill_status_change_clear(struct block_list *bl, int type)
return 0;
for(i = 0; i < MAX_STATUSCHANGE; i++){
if(sc_data[i].timer != -1){ /* 異常があるならタイマ?を削除する */
-/*
- delete_timer(sc_data[i].timer, skill_status_change_timer);
- sc_data[i].timer = -1;
-
- if (!type && i < SC_SENDMAX)
- clif_status_change(bl, i, 0);
-*/
-
skill_status_change_end(bl, i, -1);
}
}
@@ -10447,7 +10695,7 @@ int skill_status_change_clear(struct block_list *bl, int type)
}
/* クロ?キング?査(周りに移動不可能地?があるか) */
-int skill_check_cloaking(struct block_list *bl)
+int skill_check_cloaking(struct block_list *bl)
{
static int dx[]={ 0, 1, 0, -1, -1, 1, 1, -1}; //optimized by Lupus
static int dy[]={-1, 0, 1, 0, -1, -1, 1, 1};
@@ -10804,7 +11052,7 @@ int skill_delunitgroup(struct skill_unit_group *group)
group->valstr=NULL;
}
- map_freeblock(group->unit); /* free()の替わり */
+ map_freeblock(group->unit); /* aFree()の替わり */
group->unit=NULL;
group->src_id=0;
group->group_id=0;
@@ -11243,9 +11491,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int
int i,j, *r_flag, *s_flag, *m_flag;
struct skill_unit *unit1;
struct skill_unit *unit2;
- r_flag = (int *) aMalloc(sizeof(int) * group->unit_count);
- s_flag = (int *) aMalloc(sizeof(int) * group->unit_count);
- m_flag = (int *) aMalloc(sizeof(int) * group->unit_count);
+ r_flag = (int *) aMallocA(sizeof(int) * group->unit_count);
+ s_flag = (int *) aMallocA(sizeof(int) * group->unit_count);
+ m_flag = (int *) aMallocA(sizeof(int) * group->unit_count);
memset(r_flag,0, sizeof(int) * group->unit_count);// ?承フラグ
memset(s_flag,0, sizeof(int) * group->unit_count);// ?承フラグ
memset(m_flag,0, sizeof(int) * group->unit_count);// ?承フラグ
@@ -11316,9 +11564,9 @@ int skill_unit_move_unit_group( struct skill_unit_group *group, int m,int dx,int
}
}
}
- free(r_flag);
- free(s_flag);
- free(m_flag);
+ aFree(r_flag);
+ aFree(s_flag);
+ aFree(m_flag);
}
}
return 0;
@@ -11470,7 +11718,7 @@ int skill_produce_mix( struct map_session_data *sd,
else
make_per = 1000 + sd->status.base_level*30 + sd->paramc[3]*20 + sd->paramc[4]*15 + pc_checkskill(sd,AM_LEARNINGPOTION)*100 + pc_checkskill(sd,AM_PHARMACY)*300;
} else if (skill_produce_db[idx].req_skill == ASC_CDP) {
- make_per = 2000 + 40*sd->paramc[4] + 20*sd->paramc[5];
+ make_per = 2000 + 40*sd->paramc[4] + 20*sd->paramc[5];
//make_per = 20 + (20*sd->paramc[4])/50 + (20*sd->paramc[5])/100;
} else {
if(nameid == 998)
@@ -11493,7 +11741,7 @@ int skill_produce_mix( struct map_session_data *sd,
if(make_per < 1) make_per = 1;
- if(skill_produce_db[idx].req_skill==AM_PHARMACY ||
+ if(skill_produce_db[idx].req_skill==AM_PHARMACY ||
skill_produce_db[idx].req_skill==ASC_CDP) {
if( battle_config.pp_rate!=100 )
make_per=make_per*battle_config.pp_rate/100;
@@ -12059,7 +12307,7 @@ int skill_readdb(void)
i -= 9500;
else if(i<=0 || i>MAX_SKILL_DB)
continue;
-
+
memset(split2,0,sizeof(split2));
for(j=0,p=split[1];j<MAX_SKILL_LEVEL && p;j++){
split2[j]=p;
@@ -12126,7 +12374,7 @@ static int skill_read_skillspamount(void)
char *buf,*p;
struct skill_db *skill = NULL;
int s, idx, new_flag=1, level=1, sp=0;
-
+
buf=grfio_reads("data\\leveluseskillspamount.txt",&s);
if(buf==NULL)
@@ -12135,7 +12383,7 @@ static int skill_read_skillspamount(void)
buf[s]=0;
for(p=buf;p-buf<s;){
char buf2[64];
-
+
if (sscanf(p,"%[@]",buf2) == 1) {
level = 1;
new_flag = 1;
@@ -12156,7 +12404,7 @@ static int skill_read_skillspamount(void)
if(!p) break;
p++;
}
- free(buf);
+ aFree(buf);
sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","data\\leveluseskillspamount.txt");
ShowStatus(tmp_output);
diff --git a/src/map/skill.h b/src/map/skill.h
index af6e6006a..44ea5ca22 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -186,7 +186,7 @@ enum {
enum { // struct map_session_data の status_changeの番?テ?ブル
// SC_SENDMAX未?はクライアントへの通知あり。
// 2-2次職の値はなんかめちゃくちゃっぽいので暫定。たぶん?更されます。
- SC_SENDMAX =128,
+ SC_SENDMAX = 128, // note: max is now 182, but we'll need to do alot of moving around
SC_PROVOKE = 0,
SC_ENDURE = 1,
SC_TWOHANDQUICKEN = 2,
@@ -275,8 +275,10 @@ enum { // struct map_session_data の status_changeの番?テ?ブル
SC_STONE = 128,
SC_FREEZE = 129,
+// <-- 130 = a baby skill status?
SC_STAN = 130,
SC_SLEEP = 131,
+// <-- 132 = another baby skill?
SC_POISON = 132,
SC_CURSE = 133,
SC_SILENCE = 134,
@@ -322,17 +324,15 @@ enum { // struct map_session_data の status_changeの番?テ?ブル
SC_DONTFORGETME =175,
SC_FORTUNE =176,
SC_SERVICE4U =177,
-
SC_SPIDERWEB =180, /* スパイダ?ウェッブ */
- SC_MEMORIZE =181, /* メモライズ */
- SC_DPOISON =182, /* 猛毒 */
// SC_EDP // moved
SC_SACRIFICE =184, /* サクリファイス */
SC_WEDDING =187, //結婚用(結婚衣裳になって?くのが?いとか)
SC_NOCHAT =188, //赤エモ?態
SC_SPLASHER =189, /* ベナムスプラッシャ? */
SC_SELFDESTRUCTION =190, /* 自爆 */
-
+ SC_MEMORIZE =197, /* メモライズ */ // changed from 181 to 192
+ SC_DPOISON =198, /* 猛毒 */
// Used by English Team
SC_BROKNARMOR =32,
@@ -348,6 +348,8 @@ enum { // struct map_session_data の status_changeの番?テ?ブル
SC_ENSEMBLE =159,
SC_FOGWALL =178,
SC_GOSPEL =179,
+ SC_PRESERVE =181,
+ SC_BATTLEORDERS =182,
SC_MOONLIT =183,
SC_ATKPOT =185, // [Valaris]
SC_MATKPOT =186, // [Valaris]
@@ -357,9 +359,8 @@ enum { // struct map_session_data の status_changeの番?テ?ブル
SC_BLOCKSKILL =194, // for disallowing the use of a skill for a time period
SC_ADAPTATION =195,
SC_CHASEWALK =196,
- SC_BATTLEORDERS =200,
SC_REGENERATION =201,
- SC_PRESERVE =202,
+
// [Celest]
SC_BLEEDING = 124, // Temporarily same id as headcrush
diff --git a/src/map/storage.c b/src/map/storage.c
index f0e22c71d..b78510a92 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -65,13 +65,13 @@ int do_init_storage(void) // map.c::do_init()から呼ばれる
static int guild_storage_db_final(void *key,void *data,va_list ap)
{
struct guild_storage *gstor=data;
- free(gstor);
+ aFree(gstor);
return 0;
}
static int storage_db_final(void *key,void *data,va_list ap)
{
struct storage *stor=data;
- free(stor);
+ aFree(stor);
return 0;
}
void do_final_storage(void) // by [MC Cameri]
@@ -87,7 +87,7 @@ struct storage *account2storage(int account_id)
struct storage *stor;
stor=numdb_search(storage_db,account_id);
if(stor == NULL) {
- stor = aCalloc(sizeof(struct storage), 1);
+ stor = aCallocA(sizeof(struct storage), 1);
if(stor == NULL){
printf("storage: out of memory!\n");
exit(0);
@@ -109,7 +109,7 @@ int storage_delete(int account_id)
struct storage *stor = numdb_search(storage_db,account_id);
if(stor) {
numdb_erase(storage_db,account_id);
- free(stor);
+ aFree(stor);
}
return 0;
}
@@ -381,7 +381,7 @@ struct guild_storage *guild2storage(int guild_id)
if(guild_search(guild_id) != NULL) {
gs=numdb_search(guild_storage_db,guild_id);
if(gs == NULL) {
- gs = aCalloc(sizeof(struct guild_storage), 1);
+ gs = aCallocA(sizeof(struct guild_storage), 1);
if(gs==NULL){
printf("storage: out of memory!\n");
exit(0);
@@ -398,7 +398,7 @@ int guild_storage_delete(int guild_id)
struct guild_storage *gstor = numdb_search(guild_storage_db,guild_id);
if(gstor) {
numdb_erase(guild_storage_db,guild_id);
- free(gstor);
+ aFree(gstor);
}
return 0;
}
diff --git a/src/map/vending.c b/src/map/vending.c
index 85e9b8aa9..42b9f6fea 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -48,7 +48,7 @@ void vending_vendinglistreq(struct map_session_data *sd,int id)
*/
void vending_purchasereq(struct map_session_data *sd,int len,int id,unsigned char *p)
{
- int i, j, w, z, new = 0, blank, vend_list[12];
+ int i, j, w, z, new_ = 0, blank, vend_list[12];
short amount, index;
struct map_session_data *vsd = map_id2sd(id);
@@ -99,8 +99,8 @@ void vending_purchasereq(struct map_session_data *sd,int len,int id,unsigned cha
case ADDITEM_EXIST:
break;
case ADDITEM_NEW:
- new++;
- if (new > blank)
+ new_++;
+ if (new_ > blank)
return; // 種類数超過
break;
case ADDITEM_OVERAMOUNT: