summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c359
-rw-r--r--src/map/clif.c4
-rw-r--r--src/map/map.h10
-rw-r--r--src/map/mob.c7
-rw-r--r--src/map/pc.c56
-rw-r--r--src/map/pc.h2
-rw-r--r--src/map/skill.c6
-rw-r--r--src/map/skill.h8
-rw-r--r--src/map/status.c170
-rw-r--r--src/map/status.h24
-rw-r--r--src/map/unit.c2
11 files changed, 301 insertions, 347 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d24884420..7ff26842a 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -409,7 +409,7 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman
*------------------------------------------*/
int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
- char map_name[MAP_NAME_LENGTH_EXT];
+ char map_name[MAP_NAME_LENGTH];
unsigned short mapindex;
int x = 0, y = 0;
int m = -1;
@@ -419,8 +419,8 @@ int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* com
memset(map_name, '\0', sizeof(map_name));
if (!message || !*message ||
- (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
- sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
+ (sscanf(message, "%11s %d %d", map_name, &x, &y) < 3 &&
+ sscanf(message, "%11[^,],%d,%d", map_name, &x, &y) < 1)) {
clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
return -1;
@@ -786,7 +786,7 @@ int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* com
int i, count, users;
int pl_GM_level, GM_level;
int map_id;
- char map_name[MAP_NAME_LENGTH_EXT];
+ char map_name[MAP_NAME_LENGTH];
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(map_name, '\0', sizeof(map_name));
@@ -794,7 +794,7 @@ int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* com
if (!message || !*message)
map_id = sd->bl.m;
else {
- sscanf(message, "%15s", map_name);
+ sscanf(message, "%11s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -839,7 +839,7 @@ int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* com
int i, count, users;
int pl_GM_level, GM_level;
int map_id = 0;
- char map_name[MAP_NAME_LENGTH_EXT];
+ char map_name[MAP_NAME_LENGTH];
nullpo_retr(-1, sd);
@@ -849,7 +849,7 @@ int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* com
if (!message || !*message)
map_id = sd->bl.m;
else {
- sscanf(message, "%15s", map_name);
+ sscanf(message, "%11s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -896,7 +896,7 @@ int atcommand_whomap(const int fd, struct map_session_data* sd, const char* comm
int i, count, users;
int pl_GM_level, GM_level;
int map_id = 0;
- char map_name[MAP_NAME_LENGTH_EXT];
+ char map_name[MAP_NAME_LENGTH];
struct guild *g;
struct party_data *p;
@@ -910,7 +910,7 @@ int atcommand_whomap(const int fd, struct map_session_data* sd, const char* comm
if (!message || !*message)
map_id = sd->bl.m;
else {
- sscanf(message, "%15s", map_name);
+ sscanf(message, "%11s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
@@ -2227,35 +2227,38 @@ int atcommand_go(const int fd, struct map_session_data* sd, const char* command,
{
int i;
int town;
- char map_name[MAP_NAME_LENGTH_EXT];
+ char map_name[MAP_NAME_LENGTH];
int m;
- const struct { char map[MAP_NAME_LENGTH_EXT]; int x, y; } data[] = {
- { MAP_PRONTERA, 156, 191 }, // 0=Prontera
- { MAP_MORROC, 156, 93 }, // 1=Morroc
- { MAP_GEFFEN, 119, 59 }, // 2=Geffen
- { MAP_PAYON, 162, 233 }, // 3=Payon
- { MAP_ALBERTA, 192, 147 }, // 4=Alberta
- { MAP_IZLUDE, 128, 114 }, // 5=Izlude
- { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
- { MAP_LUTIE, 147, 134 }, // 7=Lutie
- { MAP_COMODO, 209, 143 }, // 8=Comodo
- { MAP_YUNO, 157, 51 }, // 9=Yuno
- { MAP_AMATSU, 198, 84 }, // 10=Amatsu
- { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
- { MAP_UMBALA, 89, 157 }, // 12=Umbala
- { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
- { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
- { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
- { MAP_JAIL, 23, 61 }, // 16=Prison
- { MAP_JAWAII, 249, 127 }, // 17=Jawaii
- { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
- { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
- { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
- { MAP_EINBECH, 70, 95 }, // 21=Einbech
- { MAP_HUGEL, 96, 145 }, // 22=Hugel
- { MAP_RACHEL, 130, 110 }, // 23=Rachel
- { MAP_VEINS, 216, 123 }, // 24=Veins
+ const struct {
+ char map[MAP_NAME_LENGTH];
+ int x, y;
+ } data[] = {
+ { MAP_PRONTERA, 156, 191 }, // 0=Prontera
+ { MAP_MORROC, 156, 93 }, // 1=Morroc
+ { MAP_GEFFEN, 119, 59 }, // 2=Geffen
+ { MAP_PAYON, 162, 233 }, // 3=Payon
+ { MAP_ALBERTA, 192, 147 }, // 4=Alberta
+ { MAP_IZLUDE, 128, 114 }, // 5=Izlude
+ { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
+ { MAP_LUTIE, 147, 134 }, // 7=Lutie
+ { MAP_COMODO, 209, 143 }, // 8=Comodo
+ { MAP_YUNO, 157, 51 }, // 9=Yuno
+ { MAP_AMATSU, 198, 84 }, // 10=Amatsu
+ { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
+ { MAP_UMBALA, 89, 157 }, // 12=Umbala
+ { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
+ { MAP_LOUYANG, 217, 40 }, // 14=Louyang
+ { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
+ { MAP_JAIL, 23, 61 }, // 16=Prison
+ { MAP_JAWAII, 249, 127 }, // 17=Jawaii
+ { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
+ { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
+ { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
+ { MAP_EINBECH, 70, 95 }, // 21=Einbech
+ { MAP_HUGEL, 96, 145 }, // 22=Hugel
+ { MAP_RACHEL, 130, 110 }, // 23=Rachel
+ { MAP_VEINS, 216, 123 }, // 24=Veins
};
nullpo_retr(-1, sd);
@@ -2272,134 +2275,111 @@ int atcommand_go(const int fd, struct map_session_data* sd, const char* command,
town = atoi(message);
// if no value, display all value
- if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= ARRAYLENGTH(data)) {
+ if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
- clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
- clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
+ clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
+ clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
clif_displaymessage(fd, " 24=Veins");
return -1;
- } else {
- // get possible name of the city
- map_name[MAP_NAME_LENGTH_EXT-1] = '\0';
- for (i = 0; map_name[i]; i++)
- map_name[i] = TOLOWER(map_name[i]);
- // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
- if (strncmp(map_name, "prontera", 3) == 0) { // 3 first characters
- town = 0;
- } else if (strncmp(map_name, "morocc", 3) == 0) { // 3 first characters
- town = 1;
- } else if (strncmp(map_name, "geffen", 3) == 0) { // 3 first characters
- town = 2;
- } else if (strncmp(map_name, "payon", 3) == 0 || // 3 first characters
- strncmp(map_name, "paion", 3) == 0) { // writing error (3 first characters)
- town = 3;
- } else if (strncmp(map_name, "alberta", 3) == 0) { // 3 first characters
- town = 4;
- } else if (strncmp(map_name, "izlude", 3) == 0 || // 3 first characters
- strncmp(map_name, "islude", 3) == 0) { // writing error (3 first characters)
- town = 5;
- } else if (strncmp(map_name, "aldebaran", 3) == 0 || // 3 first characters
- strcmp(map_name, "al") == 0) { // al (de baran)
- town = 6;
- } else if (strncmp(map_name, "lutie", 3) == 0 || // name of the city, not name of the map (3 first characters)
- strcmp(map_name, "christmas") == 0 || // name of the symbol
- strncmp(map_name, "xmas", 3) == 0 || // 3 first characters
- strncmp(map_name, "x-mas", 3) == 0) { // writing error (3 first characters)
- town = 7;
- } else if (strncmp(map_name, "comodo", 3) == 0) { // 3 first characters
- town = 8;
- } else if (strncmp(map_name, "yuno", 3) == 0) { // 3 first characters
- town = 9;
- } else if (strncmp(map_name, "amatsu", 3) == 0 || // 3 first characters
- strncmp(map_name, "ammatsu", 3) == 0) { // writing error (3 first characters)
- town = 10;
- } else if (strncmp(map_name, "gonryun", 3) == 0) { // 3 first characters
- town = 11;
- } else if (strncmp(map_name, "umbala", 3) == 0) { // 3 first characters
- town = 12;
- } else if (strncmp(map_name, "niflheim", 3) == 0) { // 3 first characters
- town = 13;
- } else if (strncmp(map_name, "louyang", 3) == 0) { // 3 first characters
- town = 14;
- } else if (strncmp(map_name, "new_zone01", 3) == 0 || // 3 first characters (or "newbies")
- strncmp(map_name, "startpoint", 3) == 0 || // name of the position (3 first characters)
- strncmp(map_name, "begining", 3) == 0) { // name of the position (3 first characters)
- town = 15;
- } else if (strncmp(map_name, "sec_pri", 3) == 0 || // 3 first characters
- strncmp(map_name, "prison", 3) == 0 || // name of the position (3 first characters)
- strncmp(map_name, "jails", 3) == 0) { // name of the position
- town = 16;
- } else if (strncmp(map_name, "jawaii", 3) == 0 || // 3 first characters
- strncmp(map_name, "jawai", 3) == 0) { // writing error (3 first characters)
- town = 17;
- } else if (strncmp(map_name, "ayothaya", 2) == 0 || // 2 first characters
- strncmp(map_name, "ayotaya", 2) == 0) { // writing error (2 first characters)
- town = 18;
- } else if (strncmp(map_name, "einbroch", 5) == 0 || // 5 first characters
- strncmp(map_name, "ainbroch", 5) == 0) { // writing error (5 first characters)
- town = 19;
- } else if (strncmp(map_name, "lighthalzen", 3) == 0 || // 3 first characters
- strncmp(map_name, "reichthalzen", 3) == 0) { // 'alternative' name (3 first characters)
- town = 20;
- } else if (strncmp(map_name, "einbech", 3) == 0) { // 3 first characters
- town = 21;
- } else if (strncmp(map_name, "hugel", 3) == 0) { // 3 first characters
- town = 22;
- } else if (strncmp(map_name, "rachel", 3) == 0) { // 3 first characters
- town = 23;
- } else if (strncmp(map_name, "veins", 3) == 0) { // 3 first characters
- town = 24;
+ }
+
+ // get possible name of the city
+ map_name[MAP_NAME_LENGTH-1] = '\0';
+ for (i = 0; map_name[i]; i++)
+ map_name[i] = TOLOWER(map_name[i]);
+ // try to identify the map name
+ if (strncmp(map_name, "prontera", 3) == 0) {
+ town = 0;
+ } else if (strncmp(map_name, "morocc", 3) == 0) {
+ town = 1;
+ } else if (strncmp(map_name, "geffen", 3) == 0) {
+ town = 2;
+ } else if (strncmp(map_name, "payon", 3) == 0 ||
+ strncmp(map_name, "paion", 3) == 0) {
+ town = 3;
+ } else if (strncmp(map_name, "alberta", 3) == 0) {
+ town = 4;
+ } else if (strncmp(map_name, "izlude", 3) == 0 ||
+ strncmp(map_name, "islude", 3) == 0) {
+ town = 5;
+ } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
+ strcmp(map_name, "al") == 0) {
+ town = 6;
+ } else if (strncmp(map_name, "lutie", 3) == 0 ||
+ strcmp(map_name, "christmas") == 0 ||
+ strncmp(map_name, "xmas", 3) == 0 ||
+ strncmp(map_name, "x-mas", 3) == 0) {
+ town = 7;
+ } else if (strncmp(map_name, "comodo", 3) == 0) {
+ town = 8;
+ } else if (strncmp(map_name, "yuno", 3) == 0) {
+ town = 9;
+ } else if (strncmp(map_name, "amatsu", 3) == 0) {
+ town = 10;
+ } else if (strncmp(map_name, "gonryun", 3) == 0) {
+ town = 11;
+ } else if (strncmp(map_name, "umbala", 3) == 0) {
+ town = 12;
+ } else if (strncmp(map_name, "niflheim", 3) == 0) {
+ town = 13;
+ } else if (strncmp(map_name, "louyang", 3) == 0) {
+ town = 14;
+ } else if (strncmp(map_name, "new_zone01", 3) == 0 ||
+ strncmp(map_name, "startpoint", 3) == 0 ||
+ strncmp(map_name, "begining", 3) == 0) {
+ town = 15;
+ } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
+ strncmp(map_name, "prison", 3) == 0 ||
+ strncmp(map_name, "jails", 3) == 0) {
+ town = 16;
+ } else if (strncmp(map_name, "jawaii", 3) == 0 ||
+ strncmp(map_name, "jawai", 3) == 0) {
+ town = 17;
+ } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
+ strncmp(map_name, "ayotaya", 3) == 0) {
+ town = 18;
+ } else if (strncmp(map_name, "einbroch", 5) == 0 ||
+ strncmp(map_name, "ainbroch", 5) == 0) {
+ town = 19;
+ } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
+ town = 20;
+ } else if (strncmp(map_name, "einbech", 3) == 0) {
+ town = 21;
+ } else if (strncmp(map_name, "hugel", 3) == 0) {
+ town = 22;
+ } else if (strncmp(map_name, "rachel", 3) == 0) {
+ town = 23;
+ } else if (strncmp(map_name, "veins", 3) == 0) {
+ town = 24;
+ }
+
+ if (town >= 0 && town < ARRAYLENGTH(data))
+ {
+ m = map_mapname2mapid(data[town].map);
+ if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
}
-
- if (town >= -3 && town <= -1) {
- if (sd->status.memo_point[-town-1].map) {
- m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
- if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
- clif_displaymessage(fd, msg_txt(0)); // Warped.
- } else {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
- } else {
- sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
- clif_displaymessage(fd, atcmd_output);
- return -1;
- }
- } else if (town >= 0 && town < ARRAYLENGTH(data)) {
- m = map_mapname2mapid((char *)data[town].map);
- if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
- clif_displaymessage(fd, msg_txt(0)); // Warped.
- } else {
- clif_displaymessage(fd, msg_txt(1)); // Map not found.
- return -1;
- }
- } else { // if you arrive here, you have an error in town variable when reading of names
- clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
+ if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
+ clif_displaymessage(fd, msg_txt(248));
return -1;
}
+ if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
+ clif_displaymessage(fd, msg_txt(0)); // Warped.
+ } else {
+ clif_displaymessage(fd, msg_txt(1)); // Map not found.
+ return -1;
+ }
+ } else { // if you arrive here, you have an error in town variable when reading of names
+ clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
+ return -1;
}
return 0;
@@ -2671,13 +2651,13 @@ static int atkillmonster_sub(struct block_list *bl, va_list ap)
void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
{
int map_id;
- char map_name[MAP_NAME_LENGTH_EXT];
+ char map_name[MAP_NAME_LENGTH];
if (!sd) return;
memset(map_name, '\0', sizeof(map_name));
- if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
+ if (!message || !*message || sscanf(message, "%11s", map_name) < 1)
map_id = sd->bl.m;
else {
if ((map_id = map_mapname2mapid(map_name)) < 0)
@@ -2849,28 +2829,8 @@ int atcommand_produce(const int fd, struct map_session_data* sd, const char* com
}
/*==========================================
- * Sub-function to display actual memo points
+ *
*------------------------------------------*/
-void atcommand_memo_sub(struct map_session_data* sd)
-{
- int i;
-
- if (!sd) return;
-
- memset(atcmd_output, '\0', sizeof(atcmd_output));
-
- clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
- for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
- if (sd->status.memo_point[i].map)
- sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
- else
- sprintf(atcmd_output, msg_txt(171), i); // %d - void
- clif_displaymessage(sd->fd, atcmd_output);
- }
-
- return;
-}
-
int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
int position = 0;
@@ -2878,33 +2838,29 @@ int atcommand_memo(const int fd, struct map_session_data* sd, const char* comman
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || !*message || sscanf(message, "%d", &position) < 1)
- atcommand_memo_sub(sd);
- else {
- if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
- if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(253));
- return -1;
- }
- if (sd->status.memo_point[position].map) {
- sprintf(atcmd_output, msg_txt(172), position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
- clif_displaymessage(fd, atcmd_output);
- }
- sd->status.memo_point[position].map = map[sd->bl.m].index;
- sd->status.memo_point[position].x = sd->bl.x;
- sd->status.memo_point[position].y = sd->bl.y;
- clif_skill_memo(sd, 0);
- if (pc_checkskill(sd, AL_WARP) <= (position + 1))
- clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
- atcommand_memo_sub(sd);
- } else {
- sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
- clif_displaymessage(fd, atcmd_output);
- atcommand_memo_sub(sd);
- return -1;
- }
+ if( !message || !*message || sscanf(message, "%d", &position) < 1 )
+ {
+ int i;
+ clif_displaymessage(sd->fd, "Your actual memo positions are:");
+ for( i = 0; i < MAX_MEMOPOINTS; i++ )
+ {
+ if( sd->status.memo_point[i].map )
+ sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
+ else
+ sprintf(atcmd_output, msg_txt(171), i); // %d - void
+ clif_displaymessage(sd->fd, atcmd_output);
+ }
+ return 0;
+ }
+
+ if( position < 0 && position >= MAX_MEMOPOINTS )
+ {
+ sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
}
+ pc_memo(sd, position);
return 0;
}
@@ -4328,8 +4284,7 @@ int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* com
}
if (atcmd_player_name[0] == '\0') {
- memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH_EXT);
- atcmd_player_name[MAP_NAME_LENGTH_EXT-1] = '\0';
+ safestrncpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
m_id = map_mapindex2mapid(sd->mapindex);
} else {
m_id = map_mapname2mapid(atcmd_player_name);
@@ -4713,7 +4668,7 @@ int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* comma
}
if ((nd = npc_name2id(npcname)) != NULL) {
- if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
+ if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
clif_displaymessage(fd, msg_txt(0)); // Warped.
else
return -1;
diff --git a/src/map/clif.c b/src/map/clif.c
index 8f86ddc6b..d5eec4f56 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11184,9 +11184,9 @@ void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
i = sd->menuskill_val-1;
if (i<0 || i > 2) return; //Bug?
- sd->feel_map[i].index = map[sd->bl.m].index;
+ sd->feel_map[i].index = map_id2index(sd->bl.m);
sd->feel_map[i].m = sd->bl.m;
- pc_setglobalreg(sd,feel_var[i],map[sd->bl.m].index);
+ pc_setglobalreg(sd,feel_var[i],sd->feel_map[i].index);
//Are these really needed? Shouldn't they show up automatically from the feel save packet?
// clif_misceffect2(&sd->bl, 0x1b0);
diff --git a/src/map/map.h b/src/map/map.h
index 41856d51b..cc2b54b0c 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -33,12 +33,6 @@
#define AREA_SIZE battle_config.area_size
#define DAMAGELOG_SIZE 30
#define LOOTITEM_SIZE 10
-//Quick defines to know which are the min-max common ailments. [Skotlex]
-//Because of the way the headers are included.. these must be replaced for actual values.
-//Remember to update as needed! Min is SC_STONE and max is SC_DPOISON currently.
-#define SC_COMMON_MIN 0
-#define SC_COMMON_MAX 10
-
#define MAX_SKILL_LEVEL 100
#define MAX_SKILLUNITGROUP 25
#define MAX_SKILLUNITGROUPTICKSET 25
@@ -59,8 +53,6 @@
#define MAX_PC_BONUS 10
#define MAX_DUEL 1024
-#define map_id2index(id) map[(id)].index
-
//The following system marks a different job ID system used by the map server,
//which makes a lot more sense than the normal one. [Skotlex]
//
@@ -1333,6 +1325,8 @@ struct map_session_data* map_charid2sd(int charid);
struct map_session_data * map_id2sd(int);
struct block_list * map_id2bl(int);
+
+#define map_id2index(id) map[(id)].index
int map_mapindex2mapid(unsigned short mapindex);
int map_mapname2mapid(const char* name);
int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port);
diff --git a/src/map/mob.c b/src/map/mob.c
index 9f6b6b222..d202fd41a 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -277,8 +277,7 @@ int mob_get_random_id(int type, int flag, int lv)
}
-struct mob_data *mob_once_spawn_sub(struct block_list *bl, int m,
- short x, short y, const char *mobname, int class_, const char *event)
+struct mob_data *mob_once_spawn_sub(struct block_list *bl, int m, short x, short y, const char *mobname, int class_, const char *event)
{
struct spawn_data data;
@@ -498,8 +497,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
}
data.x = x;
data.y = y;
- strncpy(data.name, mobname, NAME_LENGTH-1);
- strncpy(data.eventname, event, 50);
+ safestrncpy(data.name, mobname, sizeof(data.name));
+ safestrncpy(data.eventname, event, sizeof(data.eventname));
if (!mob_parse_dataset(&data))
return 0;
diff --git a/src/map/pc.c b/src/map/pc.c
index 9c55f5d9b..448a82a4e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3590,50 +3590,48 @@ int pc_randomwarp(struct map_session_data *sd, int type)
}
/*==========================================
- * 現在位置のメモ
+ * Records a memo point at sd's current position
+ * pos - entry to replace, (-1: shift oldest entry out)
*------------------------------------------*/
-int pc_memo(struct map_session_data *sd, int i)
+int pc_memo(struct map_session_data* sd, int pos)
{
int skill;
- int j;
nullpo_retr(0, sd);
- skill = pc_checkskill(sd, AL_WARP);
-
- if (i >= MIN_PORTAL_MEMO)
- i -= MIN_PORTAL_MEMO;
- else if (map[sd->bl.m].flag.nomemo || (map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))) {
- clif_skill_teleportmessage(sd, 1);
+ // check mapflags
+ if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
+ clif_skill_teleportmessage(sd, 1); // "Saved point cannot be memorized."
return 0;
}
- if (skill < 1) {
- clif_skill_memo(sd,2);
- }
+ // check inputs
+ if( pos < -1 || pos >= MAX_MEMOPOINTS )
+ return 0; // invalid input
- if (skill < 2 || i < -1 || i > 2) {
- clif_skill_memo(sd, 1);
+ // check required skill level
+ skill = pc_checkskill(sd, AL_WARP);
+ if( skill < 1 ) {
+ clif_skill_memo(sd,2); // "You haven't learned Warp."
return 0;
}
-
- for(j = 0 ; j < 3; j++) {
- if (sd->status.memo_point[j].map == map[sd->bl.m].index) {
- i = j;
- break;
- }
+ if( skill < 2 || skill - 2 < pos ) {
+ clif_skill_memo(sd,1); // "Skill Level is not high enough."
+ return 0;
}
- if (i == -1) {
- for(i = skill - 3; i >= 0; i--) {
- memcpy(&sd->status.memo_point[i+1],&sd->status.memo_point[i],
- sizeof(struct point));
- }
- i = 0;
+ if( pos == -1 )
+ {
+ int i;
+ // prevent memo-ing the same map multiple times
+ ARR_FIND( 0, MAX_MEMOPOINTS, i, sd->status.memo_point[i].map == map_id2index(sd->bl.m) );
+ memmove(&sd->status.memo_point[1], &sd->status.memo_point[0], (min(i,MAX_MEMOPOINTS-1))*sizeof(struct point));
+ pos = 0;
}
- sd->status.memo_point[i].map = map[sd->bl.m].index;
- sd->status.memo_point[i].x = sd->bl.x;
- sd->status.memo_point[i].y = sd->bl.y;
+
+ sd->status.memo_point[pos].map = map_id2index(sd->bl.m);
+ sd->status.memo_point[pos].x = sd->bl.x;
+ sd->status.memo_point[pos].y = sd->bl.y;
clif_skill_memo(sd, 0);
diff --git a/src/map/pc.h b/src/map/pc.h
index dcef362fd..59bfbea53 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -148,7 +148,7 @@ int pc_clean_skilltree(struct map_session_data *sd);
int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, uint8 clrtype);
int pc_setsavepoint(struct map_session_data*,short,int,int);
int pc_randomwarp(struct map_session_data *sd,int type);
-int pc_memo(struct map_session_data *sd,int i);
+int pc_memo(struct map_session_data* sd, int pos);
int pc_remove_map(struct map_session_data *sd,int clrtype);
int pc_checkadditem(struct map_session_data*,int,int);
diff --git a/src/map/skill.c b/src/map/skill.c
index f991275a6..f24073eda 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -5612,7 +5612,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
continue;
if(map_getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH))
dx[j] = dy[j] = 0;
- pc_setpos(dstsd, map[src->m].index, src->x+dx[j], src->y+dy[j], 2);
+ pc_setpos(dstsd, map_id2index(src->m), src->x+dx[j], src->y+dy[j], 2);
}
}
if (sd)
@@ -10308,13 +10308,13 @@ int skill_unit_timer_sub (struct block_list* bl, va_list ap)
sd = map_charid2sd(group->val1);
group->val1 = 0;
if (sd && !map[sd->bl.m].flag.nowarp)
- pc_setpos(sd,map[unit->bl.m].index,unit->bl.x,unit->bl.y,3);
+ pc_setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,3);
}
if(group->val2) {
sd = map_charid2sd(group->val2);
group->val2 = 0;
if (sd && !map[sd->bl.m].flag.nowarp)
- pc_setpos(sd,map[unit->bl.m].index,unit->bl.x,unit->bl.y,3);
+ pc_setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,3);
}
skill_delunit(unit);
}
diff --git a/src/map/skill.h b/src/map/skill.h
index 7d0580945..efb6cd086 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -4,9 +4,10 @@
#ifndef _SKILL_H_
#define _SKILL_H_
+#include "../common/mmo.h" // MAX_SKILL
#include "map.h" // MAX_SKILL_LEVEL, ...
-#define MAX_SKILL_DB 1100
+#define MAX_SKILL_DB MAX_SKILL
#define MAX_SKILL_PRODUCE_DB 150
#define MAX_PRODUCE_RESOURCE 12
#define MAX_SKILL_ARROW_DB 150
@@ -86,7 +87,7 @@ extern struct s_skill_db skill_db[MAX_SKILL_DB];
struct skill_name_db {
int id; // skill id
char *name; // search strings
- char *desc; // description that shows up for search's
+ char *desc; // description that shows up for searches
};
#define MAX_SKILL_UNIT_LAYOUT 50
@@ -255,8 +256,7 @@ int skill_chastle_mob_changetarget(struct block_list *bl,va_list ap); //[orn]
// アイテム作成
int skill_can_produce_mix( struct map_session_data *sd, int nameid, int trigger, int qty);
-int skill_produce_mix( struct map_session_data *sd,
- int skill_id, int nameid, int slot1, int slot2, int slot3, int qty );
+int skill_produce_mix( struct map_session_data *sd, int skill_id, int nameid, int slot1, int slot2, int slot3, int qty );
int skill_arrow_create( struct map_session_data *sd,int nameid);
diff --git a/src/map/status.c b/src/map/status.c
index ddc3ce745..75c877140 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -34,6 +34,7 @@
//For specifying where in the SkillStatusChangeTableArray the "out of bounds" skills get stored. [Skotlex]
#define SC_HM_BASE 800
#define SC_GD_BASE 900
+
//Regen related flags.
#define RGN_HP 0x01
#define RGN_SP 0x02
@@ -4415,7 +4416,7 @@ void status_change_init(struct block_list *bl)
//Applies SC defense to a given status change.
//Returns the adjusted duration based on flag values.
//the flag values are the same as in status_change_start.
-int status_get_sc_def(struct block_list *bl, int type, int rate, int tick, int flag)
+int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int tick, int flag)
{
int sc_def, tick_def = 0;
struct status_data* status;
@@ -4579,16 +4580,16 @@ int status_get_sc_def(struct block_list *bl, int type, int rate, int tick, int f
/*==========================================
* Starts a status change.
- * type = type, val1~4 depend on the type.
- * rate = base success rate. 10000 = 100%
- * Tick is base duration
- * flag:
+ * 'type' = type, 'val1~4' depend on the type.
+ * 'rate' = base success rate. 10000 = 100%
+ * 'tick' is base duration
+ * 'flag':
* &1: Cannot be avoided (it has to start)
* &2: Tick should not be reduced (by vit, luk, lv, etc)
* &4: sc_data loaded, no value has to be altered.
* &8: rate should not be reduced
*------------------------------------------*/
-int status_change_start(struct block_list *bl,int type,int rate,int val1,int val2,int val3,int val4,int tick,int flag)
+int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val1,int val2,int val3,int val4,int tick,int flag)
{
struct map_session_data *sd = NULL;
struct status_change* sc;
@@ -4597,39 +4598,42 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
int opt_flag, calc_flag, undead_flag;
nullpo_retr(0, bl);
- sc=status_get_sc(bl);
+ sc = status_get_sc(bl);
status = status_get_status_data(bl);
- if (!sc || status_isdead(bl))
- return 0;
-
- switch (bl->type)
+ if( type < 0 || type >= SC_MAX )
{
- case BL_PC:
- sd=(struct map_session_data *)bl;
- break;
- case BL_MOB:
- if (((struct mob_data*)bl)->class_ == MOBID_EMPERIUM && type != SC_SAFETYWALL)
- return 0; //Emperium can't be afflicted by status changes.
- break;
+ if( battle_config.error_log )
+ ShowError("status_change_start: invalid status change (%d)!\n", type);
+ return 0;
}
- if(type < 0 || type >= SC_MAX) {
- if(battle_config.error_log)
- ShowError("status_change_start: invalid status change (%d)!\n", type);
+ if( !sc )
+ return 0; //Unable to receive status changes
+
+ if( status_isdead(bl) )
return 0;
+
+ if( bl->type == BL_MOB && ((TBL_MOB*)bl)->class_ == MOBID_EMPERIUM )
+ {
+ if( type != SC_SAFETYWALL )
+ return 0; //Emperium can't be afflicted by status changes
}
- //Check resistance.
- if (!(flag&(1|4))) {
+ BL_CAST(BL_PC, bl, sd);
+
+ //Adjust tick according to status resistances
+ if( !(flag&(1|4)) )
+ {
tick = status_get_sc_def(bl, type, rate, tick, flag);
- if (!tick) return 0;
+ if( !tick ) return 0;
}
- undead_flag=battle_check_undead(status->race,status->def_ele);
+ undead_flag = battle_check_undead(status->race,status->def_ele);
//Check for inmunities / sc fails
- switch (type) {
+ switch (type)
+ {
case SC_FREEZE:
case SC_STONE:
//Undead are immune to Freeze/Stone
@@ -4696,7 +4700,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
//if (sd && val1 < 3 && skill_check_cloaking(bl))
if (sd && pc_checkskill(sd, AS_CLOAKING)< 3 && skill_check_cloaking(bl,sc))
return 0;
- break;
+ break;
case SC_MODECHANGE:
{
int mode;
@@ -4716,8 +4720,8 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
return status_change_end(bl, type, -1);
return 0;
}
- break;
}
+ break;
//Strip skills, need to divest something or it fails.
case SC_STRIPWEAPON:
if (sd) {
@@ -4743,7 +4747,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
if (!opt_flag) return 0;
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
+ break;
case SC_STRIPSHIELD:
if (sd) {
int i;
@@ -4756,7 +4760,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
pc_unequipitem(sd,i,3);
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
+ break;
case SC_STRIPARMOR:
if (sd) {
int i;
@@ -4768,7 +4772,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
pc_unequipitem(sd,i,3);
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
+ break;
case SC_STRIPHELM:
if (sd) {
int i;
@@ -4780,7 +4784,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
pc_unequipitem(sd,i,3);
}
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
+ break;
}
//Check for BOSS resistances
@@ -4806,8 +4810,10 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
return 0;
}
}
+
//Before overlapping fail, one must check for status cured.
- switch (type) {
+ switch (type)
+ {
case SC_BLESSING:
if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) {
if (sc->data[SC_CURSE].timer!=-1)
@@ -4929,9 +4935,12 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
status_change_end(bl,SC_ADJUSTMENT,-1);
break;
}
+
//Check for overlapping fails
- if(sc->data[type].timer != -1){
- switch (type) {
+ if(sc->data[type].timer != -1)
+ {
+ switch (type)
+ {
case SC_ADRENALINE:
case SC_ADRENALINE2:
case SC_WEAPONPERFECTION:
@@ -4997,7 +5006,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
default:
if(sc->data[type].val1 > val1)
return 1; //Return true to not mess up skill animations. [Skotlex
- }
+ }
(sc->count)--;
delete_timer(sc->data[type].timer, status_change_timer);
sc->data[type].timer = -1;
@@ -5005,8 +5014,10 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
vd = status_get_viewdata(bl);
calc_flag = StatusChangeFlagTable[type];
- if(!(flag&4)) //Do not parse val settings when loading SCs
- switch(type){
+
+ if(!(flag&4)) //&4 - Do not parse val settings when loading SCs
+ switch(type)
+ {
case SC_DECREASEAGI:
case SC_INCREASEAGI:
val2 = 2 + val1; //Agi change
@@ -5849,9 +5860,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
//associated, and yet are not wrong/unknown. [Skotlex]
break;
default:
- if (calc_flag == SCB_NONE &&
- StatusSkillChangeTable[type]==0 &&
- StatusIconChangeTable[type]==0)
+ if( calc_flag == SCB_NONE && StatusSkillChangeTable[type] == 0 && StatusIconChangeTable[type] == 0 )
{ //Status change with no calc, no icon, and no skill associated...?
if(battle_config.error_log)
ShowError("UnknownStatusChange [%d]\n", type);
@@ -5859,7 +5868,8 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
}
}
else //Special considerations when loading SC data.
- switch (type) {
+ switch( type )
+ {
case SC_WEDDING:
case SC_XMAS:
case SC_SUMMER:
@@ -5871,8 +5881,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
case SC_KAAHI:
val4 = -1;
break;
- //In case the speed reduction comes loaded incorrectly,
- //prevent division by 0.
+ //In case the speed reduction comes loaded incorrectly, prevent division by 0.
case SC_DONTFORGETME:
case SC_CLOAKING:
case SC_LONGING:
@@ -5882,13 +5891,11 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
if (!val3)
return 0;
break;
- case SC_GUILDAURA:
- //Compatibility Upgrade due to Guild Aura code rewrite
- //(older saved SC versions would load up with huge bonuses)
- return 0;
}
+
//Those that make you stop attacking/walking....
- switch (type) {
+ switch (type)
+ {
case SC_FREEZE:
case SC_STUN:
case SC_SLEEP:
@@ -5922,7 +5929,8 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
// Set option as needed.
opt_flag = 1;
- switch(type){
+ switch(type)
+ {
//OPT1
case SC_STONE:
case SC_FREEZE:
@@ -6041,8 +6049,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
opt_flag = 0;
}
- //On Aegis, when turning on a status change, first goes the option packet,
- // then the sc packet.
+ //On Aegis, when turning on a status change, first goes the option packet, then the sc packet.
if(opt_flag)
clif_changeoption(bl);
@@ -6068,8 +6075,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
sc->data[type].val3 = val3;
sc->data[type].val4 = val4;
- sc->data[type].timer = add_timer(
- gettick() + tick, status_change_timer, bl->id, type);
+ sc->data[type].timer = add_timer(gettick() + tick, status_change_timer, bl->id, type);
if (calc_flag)
status_calc_bl(bl,calc_flag);
@@ -6095,7 +6101,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
/*==========================================
* ステータス異常全解除
*------------------------------------------*/
-int status_change_clear(struct block_list *bl,int type)
+int status_change_clear(struct block_list* bl, enum sc_type type)
{
struct status_change* sc;
int i;
@@ -6153,7 +6159,7 @@ int status_change_clear(struct block_list *bl,int type)
/*==========================================
* ステータス異常終了
*------------------------------------------*/
-int status_change_end( struct block_list* bl , int type,int tid )
+int status_change_end(struct block_list* bl, enum sc_type type, int tid)
{
struct map_session_data *sd;
struct status_change *sc;
@@ -6628,7 +6634,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, int data)
*------------------------------------------*/
int status_change_timer(int tid, unsigned int tick, int id, int data)
{
- int type = data;
+ enum sc_type type = data;
struct block_list *bl;
struct map_session_data *sd;
struct status_data *status;
@@ -6959,31 +6965,29 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
/*==========================================
* ステータス異常タイマー範囲処理
*------------------------------------------*/
-int status_change_timer_sub(struct block_list *bl, va_list ap )
+int status_change_timer_sub(struct block_list* bl, va_list ap)
{
- struct block_list *src;
- struct status_change *sc, *tsc;
- struct map_session_data* sd=NULL;
- struct map_session_data* tsd=NULL;
-
- int type;
- unsigned int tick;
-
- src=va_arg(ap,struct block_list*);
- sc=va_arg(ap,struct status_change*);
- type=va_arg(ap,int);
- tick=va_arg(ap,unsigned int);
- tsc=status_get_sc(bl);
-
+ struct map_session_data *sd, *tsd;
+ struct status_change* tsc;
+
+ struct block_list* src = va_arg(ap,struct block_list*);
+ struct status_change* sc = va_arg(ap,struct status_change*);
+ enum sc_type type = va_arg(ap,enum sc_type);
+ unsigned int tick = va_arg(ap,unsigned int);
+
if (status_isdead(bl))
return 0;
- if (src->type==BL_PC) sd= (struct map_session_data*)src;
- if (bl->type==BL_PC) tsd= (struct map_session_data*)bl;
- switch( type ){
+ tsc = status_get_sc(bl);
+
+ BL_CAST(BL_PC, src, sd);
+ BL_CAST(BL_PC, bl, tsd);
+
+ switch( type )
+ {
case SC_SIGHT: /* サイト */
case SC_CONCENTRATE:
- if (tsc && tsc->count) {
+ if (tsc) {
if (tsc->data[SC_HIDING].timer != -1)
status_change_end( bl, SC_HIDING, -1);
if (tsc->data[SC_CLOAKING].timer != -1)
@@ -6991,8 +6995,7 @@ int status_change_timer_sub(struct block_list *bl, va_list ap )
}
break;
case SC_RUWACH: /* ルアフ */
- if (tsc && tsc->count && (tsc->data[SC_HIDING].timer != -1 || // if the target is using a special hiding, i.e not using normal hiding/cloaking, don't bother
- tsc->data[SC_CLOAKING].timer != -1)) {
+ if (tsc && (tsc->data[SC_HIDING].timer != -1 || tsc->data[SC_CLOAKING].timer != -1)) {
status_change_end( bl, SC_HIDING, -1);
status_change_end( bl, SC_CLOAKING, -1);
if(battle_check_target( src, bl, BCT_ENEMY ) > 0)
@@ -7009,7 +7012,7 @@ int status_change_timer_sub(struct block_list *bl, va_list ap )
break;
case SC_CLOSECONFINE:
//Lock char has released the hold on everyone...
- if (tsc && tsc->count && tsc->data[SC_CLOSECONFINE2].timer != -1 && tsc->data[SC_CLOSECONFINE2].val2 == src->id) {
+ if (tsc && tsc->data[SC_CLOSECONFINE2].timer != -1 && tsc->data[SC_CLOSECONFINE2].val2 == src->id) {
tsc->data[SC_CLOSECONFINE2].val2 = 0;
status_change_end(bl, SC_CLOSECONFINE2, -1);
}
@@ -7022,7 +7025,7 @@ int status_change_timer_sub(struct block_list *bl, va_list ap )
* Clears buffs/debuffs of a character.
* type&1 -> buffs, type&2 -> debuffs
*------------------------------------------*/
-int status_change_clear_buffs (struct block_list *bl, int type)
+int status_change_clear_buffs (struct block_list* bl, enum sc_type type)
{
int i;
struct status_change *sc= status_get_sc(bl);
@@ -7031,13 +7034,14 @@ int status_change_clear_buffs (struct block_list *bl, int type)
return 0;
if (type&2) //Debuffs
- for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++) {
+ for( i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++ )
+ {
if(sc->data[i].timer != -1)
status_change_end(bl,i,-1);
}
- for (i = SC_COMMON_MAX+1; i < SC_MAX; i++) {
-
+ for( i = SC_COMMON_MAX+1; i < SC_MAX; i++ )
+ {
if(sc->data[i].timer == -1)
continue;
diff --git a/src/map/status.h b/src/map/status.h
index a3c03557d..074425de6 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -18,8 +18,9 @@ struct status_change;
extern unsigned long StatusChangeFlagTable[];
// Status changes listing. These code are for use by the server.
-enum {
+enum sc_type {
//First we enumerate common status ailments which are often used around.
+ SC_COMMON_MIN = 0, // begin
SC_STONE = 0,
SC_FREEZE,
SC_STUN,
@@ -31,6 +32,7 @@ enum {
SC_BLIND,
SC_BLEEDING,
SC_DPOISON, //10
+ SC_COMMON_MAX = 10, // end
//Next up, we continue on 20, to leave enough room for additional "common" ailments in the future.
SC_PROVOKE = 20,
@@ -284,7 +286,7 @@ int SkillStatusChangeTable(int skill);
extern int StatusSkillChangeTable[SC_MAX];
//Numerates the Number for the status changes (client-dependent), imported from jA
-enum {
+enum si_type {
SI_BLANK = -1,
SI_PROVOKE = 0,
SI_ENDURE = 1,
@@ -593,8 +595,10 @@ int status_heal(struct block_list *bl,int hp,int sp, int flag);
int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp);
//Define for copying a status_data structure from b to a, without overwriting current Hp and Sp, nor messing the lhw pointer.
-#define status_cpy(a, b) { memcpy(&((a)->max_hp), &((b)->max_hp), sizeof(struct status_data)-(sizeof((a)->hp)+sizeof((a)->sp)+sizeof((a)->lhw))); \
- if ((a)->lhw && (b)->lhw) { memcpy((a)->lhw, (b)->lhw, sizeof(struct weapon_atk)); }}
+#define status_cpy(a, b) { \
+ memcpy(&((a)->max_hp), &((b)->max_hp), sizeof(struct status_data)-(sizeof((a)->hp)+sizeof((a)->sp)+sizeof((a)->lhw))); \
+ if ((a)->lhw && (b)->lhw) { memcpy((a)->lhw, (b)->lhw, sizeof(struct weapon_atk)); } \
+}
struct regen_data *status_get_regen_data(struct block_list *bl);
struct status_data *status_get_status_data(struct block_list *bl);
@@ -655,19 +659,19 @@ struct status_change *status_get_sc(struct block_list *bl);
int status_isdead(struct block_list *bl);
int status_isimmune(struct block_list *bl);
-int status_get_sc_def(struct block_list *bl, int type, int rate, int tick, int flag);
+int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int tick, int flag);
//Short version, receives rate in 1->100 range, and does not uses a flag setting.
#define sc_start(bl, type, rate, val1, tick) status_change_start(bl,type,100*(rate),val1,0,0,0,tick,0)
#define sc_start2(bl, type, rate, val1, val2, tick) status_change_start(bl,type,100*(rate),val1,val2,0,0,tick,0)
#define sc_start4(bl, type, rate, val1, val2, val3, val4, tick) status_change_start(bl,type,100*(rate),val1,val2,val3,val4,tick,0)
-int status_change_start(struct block_list *bl,int type,int rate,int val1,int val2,int val3,int val4,int tick,int flag);
-int status_change_end( struct block_list* bl , int type,int tid );
+int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val1,int val2,int val3,int val4,int tick,int flag);
+int status_change_end(struct block_list* bl, enum sc_type type, int tid);
int kaahi_heal_timer(int tid, unsigned int tick, int id, int data);
int status_change_timer(int tid, unsigned int tick, int id, int data);
-int status_change_timer_sub(struct block_list *bl, va_list ap );
-int status_change_clear(struct block_list *bl,int type);
-int status_change_clear_buffs(struct block_list *bl, int type);
+int status_change_timer_sub(struct block_list* bl, va_list ap);
+int status_change_clear(struct block_list* bl, enum sc_type type);
+int status_change_clear_buffs(struct block_list* bl, enum sc_type type);
void status_calc_bl(struct block_list *bl, unsigned long flag);
int status_calc_pet(struct pet_data* pd, int first); // [Skotlex]
diff --git a/src/map/unit.c b/src/map/unit.c
index c43d1374e..3f5d1673a 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -601,7 +601,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,int type)
}
if (bl->type == BL_PC) //Use pc_setpos
- return pc_setpos((TBL_PC*)bl, map[m].index, x, y, type);
+ return pc_setpos((TBL_PC*)bl, map_id2index(m), x, y, type);
if (!unit_remove_map(bl, type))
return 3;