* Added names to the SC_ and SI_ enums, now they can be used to properly indicate where such values are to be used (replaces usage of 'int')

* removed MIN_/MAX_PORTAL_MEMO, set MAX_MEMOPOINTS from 10 to 3
* removed support for @go-ing to your memo points
* simplified the overly verbose @memo command; now re-uses pc_memo()
* cleaned up pc_memo(), now uses semi-correct packet replies
* Minor code cleaning/formatting

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11625 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2007-10-31 13:20:48 +00:00
parent 130c4bf021
commit ac33a63e54
15 changed files with 316 additions and 359 deletions

View File

@ -4,6 +4,13 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/10/31 2007/10/31
* Added names to the SC_ and SI_ enums, now they can be used to properly
indicate where such values are to be used (replaces usage of 'int')
* removed MIN_/MAX_PORTAL_MEMO, set MAX_MEMOPOINTS from 10 to 3
* removed support for @go-ing to your memo points
* simplified the overly verbose @memo command; now re-uses pc_memo()
* cleaned up pc_memo(), now uses semi-correct packet replies
* Minor code cleaning/formatting [ultramage]
* Updated several mapflags - 'nomemo' 'noteleport' 'nosave' 'nowarpto' * Updated several mapflags - 'nomemo' 'noteleport' 'nosave' 'nowarpto'
'restricted' - due to Izlude Battle Arena release. [SinSloth] 'restricted' - due to Izlude Battle Arena release. [SinSloth]
- Updated 'item_noequip' and 'skill_nocast_db' to match with 'restricted' mapflags. - Updated 'item_noequip' and 'skill_nocast_db' to match with 'restricted' mapflags.

View File

@ -1569,7 +1569,6 @@ int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *da
switch(type) switch(type)
{ {
case GBI_GUILDLV: case GBI_GUILDLV:
ShowDebug("GBI_GUILDLV\n");
if(dw>0 && g->guild_lv+dw<=50) if(dw>0 && g->guild_lv+dw<=50)
{ {
g->guild_lv+=dw; g->guild_lv+=dw;

View File

@ -65,9 +65,6 @@
#define MIN_STAR 0 #define MIN_STAR 0
#define MAX_STAR 3 #define MAX_STAR 3
#define MIN_PORTAL_MEMO 0
#define MAX_PORTAL_MEMO 2
#define MAX_STATUS_TYPE 5 #define MAX_STATUS_TYPE 5
#define WEDDING_RING_M 2634 #define WEDDING_RING_M 2634
@ -83,7 +80,7 @@
#define MAP_NAME_LENGTH_EXT (MAP_NAME_LENGTH + 4) #define MAP_NAME_LENGTH_EXT (MAP_NAME_LENGTH + 4)
#define MAX_FRIENDS 40 #define MAX_FRIENDS 40
#define MAX_MEMOPOINTS 10 #define MAX_MEMOPOINTS 3
//Size of the fame list arrays. //Size of the fame list arrays.
#define MAX_FAME_LIST 10 #define MAX_FAME_LIST 10

View File

@ -171,7 +171,7 @@ int recv_to_fifo(int fd)
if( len == SOCKET_ERROR ) if( len == SOCKET_ERROR )
{//An exception has occured {//An exception has occured
if( s_errno != S_EWOULDBLOCK ) { if( s_errno != S_EWOULDBLOCK ) {
ShowDebug("recv_to_fifo: code %d, closing connection #%d\n", s_errno, fd); //ShowDebug("recv_to_fifo: code %d, closing connection #%d\n", s_errno, fd);
set_eof(fd); set_eof(fd);
} }
return 0; return 0;
@ -201,9 +201,9 @@ int send_from_fifo(int fd)
len = send(fd, (const char *) session[fd]->wdata, (int)session[fd]->wdata_size, 0); len = send(fd, (const char *) session[fd]->wdata, (int)session[fd]->wdata_size, 0);
if( len == SOCKET_ERROR ) if( len == SOCKET_ERROR )
{ {//An exception has occured
if( s_errno != S_EWOULDBLOCK ) { if( s_errno != S_EWOULDBLOCK ) {
ShowDebug("send_from_fifo: error %d, ending connection #%d\n", s_errno, fd); //ShowDebug("send_from_fifo: error %d, ending connection #%d\n", s_errno, fd);
session[fd]->wdata_size = 0; //Clear the send queue as we can't send anymore. [Skotlex] session[fd]->wdata_size = 0; //Clear the send queue as we can't send anymore. [Skotlex]
set_eof(fd); set_eof(fd);
} }

View File

@ -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) 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; unsigned short mapindex;
int x = 0, y = 0; int x = 0, y = 0;
int m = -1; 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)); memset(map_name, '\0', sizeof(map_name));
if (!message || !*message || if (!message || !*message ||
(sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 && (sscanf(message, "%11s %d %d", map_name, &x, &y) < 3 &&
sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) { sscanf(message, "%11[^,],%d,%d", map_name, &x, &y) < 1)) {
clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>)."); clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
return -1; 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 i, count, users;
int pl_GM_level, GM_level; int pl_GM_level, GM_level;
int map_id; int map_id;
char map_name[MAP_NAME_LENGTH_EXT]; char map_name[MAP_NAME_LENGTH];
memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(map_name, '\0', sizeof(map_name)); 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) if (!message || !*message)
map_id = sd->bl.m; map_id = sd->bl.m;
else { else {
sscanf(message, "%15s", map_name); sscanf(message, "%11s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0) if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m; 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 i, count, users;
int pl_GM_level, GM_level; int pl_GM_level, GM_level;
int map_id = 0; int map_id = 0;
char map_name[MAP_NAME_LENGTH_EXT]; char map_name[MAP_NAME_LENGTH];
nullpo_retr(-1, sd); 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) if (!message || !*message)
map_id = sd->bl.m; map_id = sd->bl.m;
else { else {
sscanf(message, "%15s", map_name); sscanf(message, "%11s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0) if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m; 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 i, count, users;
int pl_GM_level, GM_level; int pl_GM_level, GM_level;
int map_id = 0; int map_id = 0;
char map_name[MAP_NAME_LENGTH_EXT]; char map_name[MAP_NAME_LENGTH];
struct guild *g; struct guild *g;
struct party_data *p; 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) if (!message || !*message)
map_id = sd->bl.m; map_id = sd->bl.m;
else { else {
sscanf(message, "%15s", map_name); sscanf(message, "%11s", map_name);
if ((map_id = map_mapname2mapid(map_name)) < 0) if ((map_id = map_mapname2mapid(map_name)) < 0)
map_id = sd->bl.m; 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 i;
int town; int town;
char map_name[MAP_NAME_LENGTH_EXT]; char map_name[MAP_NAME_LENGTH];
int m; int m;
const struct { char map[MAP_NAME_LENGTH_EXT]; int x, y; } data[] = { const struct {
{ MAP_PRONTERA, 156, 191 }, // 0=Prontera char map[MAP_NAME_LENGTH];
{ MAP_MORROC, 156, 93 }, // 1=Morroc int x, y;
{ MAP_GEFFEN, 119, 59 }, // 2=Geffen } data[] = {
{ MAP_PAYON, 162, 233 }, // 3=Payon { MAP_PRONTERA, 156, 191 }, // 0=Prontera
{ MAP_ALBERTA, 192, 147 }, // 4=Alberta { MAP_MORROC, 156, 93 }, // 1=Morroc
{ MAP_IZLUDE, 128, 114 }, // 5=Izlude { MAP_GEFFEN, 119, 59 }, // 2=Geffen
{ MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran { MAP_PAYON, 162, 233 }, // 3=Payon
{ MAP_LUTIE, 147, 134 }, // 7=Lutie { MAP_ALBERTA, 192, 147 }, // 4=Alberta
{ MAP_COMODO, 209, 143 }, // 8=Comodo { MAP_IZLUDE, 128, 114 }, // 5=Izlude
{ MAP_YUNO, 157, 51 }, // 9=Yuno { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
{ MAP_AMATSU, 198, 84 }, // 10=Amatsu { MAP_LUTIE, 147, 134 }, // 7=Lutie
{ MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun { MAP_COMODO, 209, 143 }, // 8=Comodo
{ MAP_UMBALA, 89, 157 }, // 12=Umbala { MAP_YUNO, 157, 51 }, // 9=Yuno
{ MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim { MAP_AMATSU, 198, 84 }, // 10=Amatsu
{ MAP_LOUYANG, 217, 40 }, // 14=Lou Yang { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
{ MAP_NOVICE, 53, 111 }, // 15=Training Grounds { MAP_UMBALA, 89, 157 }, // 12=Umbala
{ MAP_JAIL, 23, 61 }, // 16=Prison { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
{ MAP_JAWAII, 249, 127 }, // 17=Jawaii { MAP_LOUYANG, 217, 40 }, // 14=Louyang
{ MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
{ MAP_EINBROCH, 64, 200 }, // 19=Einbroch { MAP_JAIL, 23, 61 }, // 16=Prison
{ MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen { MAP_JAWAII, 249, 127 }, // 17=Jawaii
{ MAP_EINBECH, 70, 95 }, // 21=Einbech { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
{ MAP_HUGEL, 96, 145 }, // 22=Hugel { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
{ MAP_RACHEL, 130, 110 }, // 23=Rachel { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
{ MAP_VEINS, 216, 123 }, // 24=Veins { 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); 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); town = atoi(message);
// if no value, display all value // 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(38)); // Invalid location number or name.
clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/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, " 0=Prontera 1=Morroc 2=Geffen");
clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude"); clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo"); clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun"); clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang"); clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii"); clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen"); clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel"); clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
clif_displaymessage(fd, " 24=Veins"); clif_displaymessage(fd, " 24=Veins");
return -1; return -1;
} else { }
// get possible name of the city
map_name[MAP_NAME_LENGTH_EXT-1] = '\0'; // get possible name of the city
for (i = 0; map_name[i]; i++) map_name[MAP_NAME_LENGTH-1] = '\0';
map_name[i] = TOLOWER(map_name[i]); for (i = 0; map_name[i]; i++)
// try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too) map_name[i] = TOLOWER(map_name[i]);
if (strncmp(map_name, "prontera", 3) == 0) { // 3 first characters // try to identify the map name
town = 0; if (strncmp(map_name, "prontera", 3) == 0) {
} else if (strncmp(map_name, "morocc", 3) == 0) { // 3 first characters town = 0;
town = 1; } else if (strncmp(map_name, "morocc", 3) == 0) {
} else if (strncmp(map_name, "geffen", 3) == 0) { // 3 first characters town = 1;
town = 2; } else if (strncmp(map_name, "geffen", 3) == 0) {
} else if (strncmp(map_name, "payon", 3) == 0 || // 3 first characters town = 2;
strncmp(map_name, "paion", 3) == 0) { // writing error (3 first characters) } else if (strncmp(map_name, "payon", 3) == 0 ||
town = 3; strncmp(map_name, "paion", 3) == 0) {
} else if (strncmp(map_name, "alberta", 3) == 0) { // 3 first characters town = 3;
town = 4; } else if (strncmp(map_name, "alberta", 3) == 0) {
} else if (strncmp(map_name, "izlude", 3) == 0 || // 3 first characters town = 4;
strncmp(map_name, "islude", 3) == 0) { // writing error (3 first characters) } else if (strncmp(map_name, "izlude", 3) == 0 ||
town = 5; strncmp(map_name, "islude", 3) == 0) {
} else if (strncmp(map_name, "aldebaran", 3) == 0 || // 3 first characters town = 5;
strcmp(map_name, "al") == 0) { // al (de baran) } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
town = 6; strcmp(map_name, "al") == 0) {
} else if (strncmp(map_name, "lutie", 3) == 0 || // name of the city, not name of the map (3 first characters) town = 6;
strcmp(map_name, "christmas") == 0 || // name of the symbol } else if (strncmp(map_name, "lutie", 3) == 0 ||
strncmp(map_name, "xmas", 3) == 0 || // 3 first characters strcmp(map_name, "christmas") == 0 ||
strncmp(map_name, "x-mas", 3) == 0) { // writing error (3 first characters) strncmp(map_name, "xmas", 3) == 0 ||
town = 7; strncmp(map_name, "x-mas", 3) == 0) {
} else if (strncmp(map_name, "comodo", 3) == 0) { // 3 first characters town = 7;
town = 8; } else if (strncmp(map_name, "comodo", 3) == 0) {
} else if (strncmp(map_name, "yuno", 3) == 0) { // 3 first characters town = 8;
town = 9; } else if (strncmp(map_name, "yuno", 3) == 0) {
} else if (strncmp(map_name, "amatsu", 3) == 0 || // 3 first characters town = 9;
strncmp(map_name, "ammatsu", 3) == 0) { // writing error (3 first characters) } else if (strncmp(map_name, "amatsu", 3) == 0) {
town = 10; town = 10;
} else if (strncmp(map_name, "gonryun", 3) == 0) { // 3 first characters } else if (strncmp(map_name, "gonryun", 3) == 0) {
town = 11; town = 11;
} else if (strncmp(map_name, "umbala", 3) == 0) { // 3 first characters } else if (strncmp(map_name, "umbala", 3) == 0) {
town = 12; town = 12;
} else if (strncmp(map_name, "niflheim", 3) == 0) { // 3 first characters } else if (strncmp(map_name, "niflheim", 3) == 0) {
town = 13; town = 13;
} else if (strncmp(map_name, "louyang", 3) == 0) { // 3 first characters } else if (strncmp(map_name, "louyang", 3) == 0) {
town = 14; town = 14;
} else if (strncmp(map_name, "new_zone01", 3) == 0 || // 3 first characters (or "newbies") } else if (strncmp(map_name, "new_zone01", 3) == 0 ||
strncmp(map_name, "startpoint", 3) == 0 || // name of the position (3 first characters) strncmp(map_name, "startpoint", 3) == 0 ||
strncmp(map_name, "begining", 3) == 0) { // name of the position (3 first characters) strncmp(map_name, "begining", 3) == 0) {
town = 15; town = 15;
} else if (strncmp(map_name, "sec_pri", 3) == 0 || // 3 first characters } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
strncmp(map_name, "prison", 3) == 0 || // name of the position (3 first characters) strncmp(map_name, "prison", 3) == 0 ||
strncmp(map_name, "jails", 3) == 0) { // name of the position strncmp(map_name, "jails", 3) == 0) {
town = 16; town = 16;
} else if (strncmp(map_name, "jawaii", 3) == 0 || // 3 first characters } else if (strncmp(map_name, "jawaii", 3) == 0 ||
strncmp(map_name, "jawai", 3) == 0) { // writing error (3 first characters) strncmp(map_name, "jawai", 3) == 0) {
town = 17; town = 17;
} else if (strncmp(map_name, "ayothaya", 2) == 0 || // 2 first characters } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
strncmp(map_name, "ayotaya", 2) == 0) { // writing error (2 first characters) strncmp(map_name, "ayotaya", 3) == 0) {
town = 18; town = 18;
} else if (strncmp(map_name, "einbroch", 5) == 0 || // 5 first characters } else if (strncmp(map_name, "einbroch", 5) == 0 ||
strncmp(map_name, "ainbroch", 5) == 0) { // writing error (5 first characters) strncmp(map_name, "ainbroch", 5) == 0) {
town = 19; town = 19;
} else if (strncmp(map_name, "lighthalzen", 3) == 0 || // 3 first characters } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
strncmp(map_name, "reichthalzen", 3) == 0) { // 'alternative' name (3 first characters) town = 20;
town = 20; } else if (strncmp(map_name, "einbech", 3) == 0) {
} else if (strncmp(map_name, "einbech", 3) == 0) { // 3 first characters town = 21;
town = 21; } else if (strncmp(map_name, "hugel", 3) == 0) {
} else if (strncmp(map_name, "hugel", 3) == 0) { // 3 first characters town = 22;
town = 22; } else if (strncmp(map_name, "rachel", 3) == 0) {
} else if (strncmp(map_name, "rachel", 3) == 0) { // 3 first characters town = 23;
town = 23; } else if (strncmp(map_name, "veins", 3) == 0) {
} else if (strncmp(map_name, "veins", 3) == 0) { // 3 first characters town = 24;
town = 24; }
}
if (town >= 0 && town < ARRAYLENGTH(data))
if (town >= -3 && town <= -1) { {
if (sd->status.memo_point[-town-1].map) { m = map_mapname2mapid(data[town].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)) {
if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) { clif_displaymessage(fd, msg_txt(247));
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.
return -1; 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(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; 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) void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
{ {
int map_id; int map_id;
char map_name[MAP_NAME_LENGTH_EXT]; char map_name[MAP_NAME_LENGTH];
if (!sd) return; if (!sd) return;
memset(map_name, '\0', sizeof(map_name)); 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; map_id = sd->bl.m;
else { else {
if ((map_id = map_mapname2mapid(map_name)) < 0) 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 atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
{ {
int position = 0; 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)); memset(atcmd_output, '\0', sizeof(atcmd_output));
if (!message || !*message || sscanf(message, "%d", &position) < 1) if( !message || !*message || sscanf(message, "%d", &position) < 1 )
atcommand_memo_sub(sd); {
else { int i;
if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) { clif_displaymessage(sd->fd, "Your actual memo positions are:");
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)) { for( i = 0; i < MAX_MEMOPOINTS; i++ )
clif_displaymessage(fd, msg_txt(253)); {
return -1; 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);
if (sd->status.memo_point[position].map) { else
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). sprintf(atcmd_output, msg_txt(171), i); // %d - void
clif_displaymessage(fd, atcmd_output); clif_displaymessage(sd->fd, atcmd_output);
} }
sd->status.memo_point[position].map = map[sd->bl.m].index; return 0;
sd->status.memo_point[position].x = sd->bl.x; }
sd->status.memo_point[position].y = sd->bl.y;
clif_skill_memo(sd, 0); if( position < 0 && position >= MAX_MEMOPOINTS )
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. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
atcommand_memo_sub(sd); clif_displaymessage(fd, atcmd_output);
} else { return -1;
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;
}
} }
pc_memo(sd, position);
return 0; 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') { if (atcmd_player_name[0] == '\0') {
memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH_EXT); safestrncpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
atcmd_player_name[MAP_NAME_LENGTH_EXT-1] = '\0';
m_id = map_mapindex2mapid(sd->mapindex); m_id = map_mapindex2mapid(sd->mapindex);
} else { } else {
m_id = map_mapname2mapid(atcmd_player_name); 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 ((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. clif_displaymessage(fd, msg_txt(0)); // Warped.
else else
return -1; return -1;

View File

@ -11184,9 +11184,9 @@ void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd)
i = sd->menuskill_val-1; i = sd->menuskill_val-1;
if (i<0 || i > 2) return; //Bug? 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; 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? //Are these really needed? Shouldn't they show up automatically from the feel save packet?
// clif_misceffect2(&sd->bl, 0x1b0); // clif_misceffect2(&sd->bl, 0x1b0);

View File

@ -33,12 +33,6 @@
#define AREA_SIZE battle_config.area_size #define AREA_SIZE battle_config.area_size
#define DAMAGELOG_SIZE 30 #define DAMAGELOG_SIZE 30
#define LOOTITEM_SIZE 10 #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_SKILL_LEVEL 100
#define MAX_SKILLUNITGROUP 25 #define MAX_SKILLUNITGROUP 25
#define MAX_SKILLUNITGROUPTICKSET 25 #define MAX_SKILLUNITGROUPTICKSET 25
@ -59,8 +53,6 @@
#define MAX_PC_BONUS 10 #define MAX_PC_BONUS 10
#define MAX_DUEL 1024 #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, //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] //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 map_session_data * map_id2sd(int);
struct block_list * map_id2bl(int); struct block_list * map_id2bl(int);
#define map_id2index(id) map[(id)].index
int map_mapindex2mapid(unsigned short mapindex); int map_mapindex2mapid(unsigned short mapindex);
int map_mapname2mapid(const char* name); int map_mapname2mapid(const char* name);
int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port); int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port);

View File

@ -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, 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)
short x, short y, const char *mobname, int class_, const char *event)
{ {
struct spawn_data data; 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.x = x;
data.y = y; data.y = y;
strncpy(data.name, mobname, NAME_LENGTH-1); safestrncpy(data.name, mobname, sizeof(data.name));
strncpy(data.eventname, event, 50); safestrncpy(data.eventname, event, sizeof(data.eventname));
if (!mob_parse_dataset(&data)) if (!mob_parse_dataset(&data))
return 0; return 0;

View File

@ -3590,50 +3590,48 @@ int pc_randomwarp(struct map_session_data *sd, int type)
} }
/*========================================== /*==========================================
* Œ»<EFBFBD>݈Êũ<EFBFBD>ƒ * 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 skill;
int j;
nullpo_retr(0, sd); nullpo_retr(0, sd);
// 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;
}
// check inputs
if( pos < -1 || pos >= MAX_MEMOPOINTS )
return 0; // invalid input
// check required skill level
skill = pc_checkskill(sd, AL_WARP); skill = pc_checkskill(sd, AL_WARP);
if( skill < 1 ) {
if (i >= MIN_PORTAL_MEMO) clif_skill_memo(sd,2); // "You haven't learned Warp."
i -= MIN_PORTAL_MEMO; return 0;
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); if( skill < 2 || skill - 2 < pos ) {
clif_skill_memo(sd,1); // "Skill Level is not high enough."
return 0; return 0;
} }
if (skill < 1) { if( pos == -1 )
clif_skill_memo(sd,2); {
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;
} }
if (skill < 2 || i < -1 || i > 2) { sd->status.memo_point[pos].map = map_id2index(sd->bl.m);
clif_skill_memo(sd, 1); sd->status.memo_point[pos].x = sd->bl.x;
return 0; sd->status.memo_point[pos].y = sd->bl.y;
}
for(j = 0 ; j < 3; j++) {
if (sd->status.memo_point[j].map == map[sd->bl.m].index) {
i = j;
break;
}
}
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;
}
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;
clif_skill_memo(sd, 0); clif_skill_memo(sd, 0);

View File

@ -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_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_setsavepoint(struct map_session_data*,short,int,int);
int pc_randomwarp(struct map_session_data *sd,int type); 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_remove_map(struct map_session_data *sd,int clrtype);
int pc_checkadditem(struct map_session_data*,int,int); int pc_checkadditem(struct map_session_data*,int,int);

View File

@ -5612,7 +5612,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
continue; continue;
if(map_getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) if(map_getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH))
dx[j] = dy[j] = 0; 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) if (sd)
@ -10308,13 +10308,13 @@ int skill_unit_timer_sub (struct block_list* bl, va_list ap)
sd = map_charid2sd(group->val1); sd = map_charid2sd(group->val1);
group->val1 = 0; group->val1 = 0;
if (sd && !map[sd->bl.m].flag.nowarp) 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) { if(group->val2) {
sd = map_charid2sd(group->val2); sd = map_charid2sd(group->val2);
group->val2 = 0; group->val2 = 0;
if (sd && !map[sd->bl.m].flag.nowarp) 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); skill_delunit(unit);
} }

View File

@ -4,9 +4,10 @@
#ifndef _SKILL_H_ #ifndef _SKILL_H_
#define _SKILL_H_ #define _SKILL_H_
#include "../common/mmo.h" // MAX_SKILL
#include "map.h" // MAX_SKILL_LEVEL, ... #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_SKILL_PRODUCE_DB 150
#define MAX_PRODUCE_RESOURCE 12 #define MAX_PRODUCE_RESOURCE 12
#define MAX_SKILL_ARROW_DB 150 #define MAX_SKILL_ARROW_DB 150
@ -86,7 +87,7 @@ extern struct s_skill_db skill_db[MAX_SKILL_DB];
struct skill_name_db { struct skill_name_db {
int id; // skill id int id; // skill id
char *name; // search strings 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 #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_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_produce_mix( struct map_session_data *sd, int skill_id, int nameid, int slot1, int slot2, int slot3, int qty );
int skill_id, int nameid, int slot1, int slot2, int slot3, int qty );
int skill_arrow_create( struct map_session_data *sd,int nameid); int skill_arrow_create( struct map_session_data *sd,int nameid);

View File

@ -34,6 +34,7 @@
//For specifying where in the SkillStatusChangeTableArray the "out of bounds" skills get stored. [Skotlex] //For specifying where in the SkillStatusChangeTableArray the "out of bounds" skills get stored. [Skotlex]
#define SC_HM_BASE 800 #define SC_HM_BASE 800
#define SC_GD_BASE 900 #define SC_GD_BASE 900
//Regen related flags. //Regen related flags.
#define RGN_HP 0x01 #define RGN_HP 0x01
#define RGN_SP 0x02 #define RGN_SP 0x02
@ -4415,7 +4416,7 @@ void status_change_init(struct block_list *bl)
//Applies SC defense to a given status change. //Applies SC defense to a given status change.
//Returns the adjusted duration based on flag values. //Returns the adjusted duration based on flag values.
//the flag values are the same as in status_change_start. //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; int sc_def, tick_def = 0;
struct status_data* status; 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. * Starts a status change.
* type = type, val1~4 depend on the type. * 'type' = type, 'val1~4' depend on the type.
* rate = base success rate. 10000 = 100% * 'rate' = base success rate. 10000 = 100%
* Tick is base duration * 'tick' is base duration
* flag: * 'flag':
* &1: Cannot be avoided (it has to start) * &1: Cannot be avoided (it has to start)
* &2: Tick should not be reduced (by vit, luk, lv, etc) * &2: Tick should not be reduced (by vit, luk, lv, etc)
* &4: sc_data loaded, no value has to be altered. * &4: sc_data loaded, no value has to be altered.
* &8: rate should not be reduced * &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 map_session_data *sd = NULL;
struct status_change* sc; 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; int opt_flag, calc_flag, undead_flag;
nullpo_retr(0, bl); nullpo_retr(0, bl);
sc=status_get_sc(bl); sc = status_get_sc(bl);
status = status_get_status_data(bl); status = status_get_status_data(bl);
if (!sc || status_isdead(bl)) if( type < 0 || type >= SC_MAX )
return 0;
switch (bl->type)
{ {
case BL_PC: if( battle_config.error_log )
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(type < 0 || type >= SC_MAX) {
if(battle_config.error_log)
ShowError("status_change_start: invalid status change (%d)!\n", type); ShowError("status_change_start: invalid status change (%d)!\n", type);
return 0; return 0;
} }
//Check resistance. if( !sc )
if (!(flag&(1|4))) { return 0; //Unable to receive status changes
tick = status_get_sc_def(bl, type, rate, tick, flag);
if (!tick) return 0; 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
} }
undead_flag=battle_check_undead(status->race,status->def_ele); 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;
}
undead_flag = battle_check_undead(status->race,status->def_ele);
//Check for inmunities / sc fails //Check for inmunities / sc fails
switch (type) { switch (type)
{
case SC_FREEZE: case SC_FREEZE:
case SC_STONE: case SC_STONE:
//Undead are immune to Freeze/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 && val1 < 3 && skill_check_cloaking(bl))
if (sd && pc_checkskill(sd, AS_CLOAKING)< 3 && skill_check_cloaking(bl,sc)) if (sd && pc_checkskill(sd, AS_CLOAKING)< 3 && skill_check_cloaking(bl,sc))
return 0; return 0;
break; break;
case SC_MODECHANGE: case SC_MODECHANGE:
{ {
int mode; 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 status_change_end(bl, type, -1);
return 0; return 0;
} }
break;
} }
break;
//Strip skills, need to divest something or it fails. //Strip skills, need to divest something or it fails.
case SC_STRIPWEAPON: case SC_STRIPWEAPON:
if (sd) { 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 (!opt_flag) return 0;
} }
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break; break;
case SC_STRIPSHIELD: case SC_STRIPSHIELD:
if (sd) { if (sd) {
int i; 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); pc_unequipitem(sd,i,3);
} }
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break; break;
case SC_STRIPARMOR: case SC_STRIPARMOR:
if (sd) { if (sd) {
int i; 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); pc_unequipitem(sd,i,3);
} }
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break; break;
case SC_STRIPHELM: case SC_STRIPHELM:
if (sd) { if (sd) {
int i; 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); pc_unequipitem(sd,i,3);
} }
if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
break; break;
} }
//Check for BOSS resistances //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; return 0;
} }
} }
//Before overlapping fail, one must check for status cured. //Before overlapping fail, one must check for status cured.
switch (type) { switch (type)
{
case SC_BLESSING: case SC_BLESSING:
if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) { if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) {
if (sc->data[SC_CURSE].timer!=-1) 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); status_change_end(bl,SC_ADJUSTMENT,-1);
break; break;
} }
//Check for overlapping fails //Check for overlapping fails
if(sc->data[type].timer != -1){ if(sc->data[type].timer != -1)
switch (type) { {
switch (type)
{
case SC_ADRENALINE: case SC_ADRENALINE:
case SC_ADRENALINE2: case SC_ADRENALINE2:
case SC_WEAPONPERFECTION: case SC_WEAPONPERFECTION:
@ -4997,7 +5006,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val
default: default:
if(sc->data[type].val1 > val1) if(sc->data[type].val1 > val1)
return 1; //Return true to not mess up skill animations. [Skotlex return 1; //Return true to not mess up skill animations. [Skotlex
} }
(sc->count)--; (sc->count)--;
delete_timer(sc->data[type].timer, status_change_timer); delete_timer(sc->data[type].timer, status_change_timer);
sc->data[type].timer = -1; 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); vd = status_get_viewdata(bl);
calc_flag = StatusChangeFlagTable[type]; 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_DECREASEAGI:
case SC_INCREASEAGI: case SC_INCREASEAGI:
val2 = 2 + val1; //Agi change 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] //associated, and yet are not wrong/unknown. [Skotlex]
break; break;
default: default:
if (calc_flag == SCB_NONE && if( calc_flag == SCB_NONE && StatusSkillChangeTable[type] == 0 && StatusIconChangeTable[type] == 0 )
StatusSkillChangeTable[type]==0 &&
StatusIconChangeTable[type]==0)
{ //Status change with no calc, no icon, and no skill associated...? { //Status change with no calc, no icon, and no skill associated...?
if(battle_config.error_log) if(battle_config.error_log)
ShowError("UnknownStatusChange [%d]\n", type); 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. else //Special considerations when loading SC data.
switch (type) { switch( type )
{
case SC_WEDDING: case SC_WEDDING:
case SC_XMAS: case SC_XMAS:
case SC_SUMMER: 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: case SC_KAAHI:
val4 = -1; val4 = -1;
break; break;
//In case the speed reduction comes loaded incorrectly, //In case the speed reduction comes loaded incorrectly, prevent division by 0.
//prevent division by 0.
case SC_DONTFORGETME: case SC_DONTFORGETME:
case SC_CLOAKING: case SC_CLOAKING:
case SC_LONGING: 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) if (!val3)
return 0; return 0;
break; 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.... //Those that make you stop attacking/walking....
switch (type) { switch (type)
{
case SC_FREEZE: case SC_FREEZE:
case SC_STUN: case SC_STUN:
case SC_SLEEP: 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. // Set option as needed.
opt_flag = 1; opt_flag = 1;
switch(type){ switch(type)
{
//OPT1 //OPT1
case SC_STONE: case SC_STONE:
case SC_FREEZE: 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; opt_flag = 0;
} }
//On Aegis, when turning on a status change, first goes the option packet, //On Aegis, when turning on a status change, first goes the option packet, then the sc packet.
// then the sc packet.
if(opt_flag) if(opt_flag)
clif_changeoption(bl); 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].val3 = val3;
sc->data[type].val4 = val4; sc->data[type].val4 = val4;
sc->data[type].timer = add_timer( sc->data[type].timer = add_timer(gettick() + tick, status_change_timer, bl->id, type);
gettick() + tick, status_change_timer, bl->id, type);
if (calc_flag) if (calc_flag)
status_calc_bl(bl,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; struct status_change* sc;
int i; 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 map_session_data *sd;
struct status_change *sc; 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 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 block_list *bl;
struct map_session_data *sd; struct map_session_data *sd;
struct status_data *status; 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 map_session_data *sd, *tsd;
struct status_change *sc, *tsc; struct status_change* tsc;
struct map_session_data* sd=NULL;
struct map_session_data* tsd=NULL;
int type; struct block_list* src = va_arg(ap,struct block_list*);
unsigned int tick; 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);
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);
if (status_isdead(bl)) if (status_isdead(bl))
return 0; 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_SIGHT: /* サイト */
case SC_CONCENTRATE: case SC_CONCENTRATE:
if (tsc && tsc->count) { if (tsc) {
if (tsc->data[SC_HIDING].timer != -1) if (tsc->data[SC_HIDING].timer != -1)
status_change_end( bl, SC_HIDING, -1); status_change_end( bl, SC_HIDING, -1);
if (tsc->data[SC_CLOAKING].timer != -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; break;
case SC_RUWACH: /* ルアフ */ 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 if (tsc && (tsc->data[SC_HIDING].timer != -1 || tsc->data[SC_CLOAKING].timer != -1)) {
tsc->data[SC_CLOAKING].timer != -1)) {
status_change_end( bl, SC_HIDING, -1); status_change_end( bl, SC_HIDING, -1);
status_change_end( bl, SC_CLOAKING, -1); status_change_end( bl, SC_CLOAKING, -1);
if(battle_check_target( src, bl, BCT_ENEMY ) > 0) 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; break;
case SC_CLOSECONFINE: case SC_CLOSECONFINE:
//Lock char has released the hold on everyone... //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; tsc->data[SC_CLOSECONFINE2].val2 = 0;
status_change_end(bl, SC_CLOSECONFINE2, -1); 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. * Clears buffs/debuffs of a character.
* type&1 -> buffs, type&2 -> debuffs * 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; int i;
struct status_change *sc= status_get_sc(bl); 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; return 0;
if (type&2) //Debuffs 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) if(sc->data[i].timer != -1)
status_change_end(bl,i,-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) if(sc->data[i].timer == -1)
continue; continue;

View File

@ -18,8 +18,9 @@ struct status_change;
extern unsigned long StatusChangeFlagTable[]; extern unsigned long StatusChangeFlagTable[];
// Status changes listing. These code are for use by the server. // 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. //First we enumerate common status ailments which are often used around.
SC_COMMON_MIN = 0, // begin
SC_STONE = 0, SC_STONE = 0,
SC_FREEZE, SC_FREEZE,
SC_STUN, SC_STUN,
@ -31,6 +32,7 @@ enum {
SC_BLIND, SC_BLIND,
SC_BLEEDING, SC_BLEEDING,
SC_DPOISON, //10 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. //Next up, we continue on 20, to leave enough room for additional "common" ailments in the future.
SC_PROVOKE = 20, SC_PROVOKE = 20,
@ -284,7 +286,7 @@ int SkillStatusChangeTable(int skill);
extern int StatusSkillChangeTable[SC_MAX]; extern int StatusSkillChangeTable[SC_MAX];
//Numerates the Number for the status changes (client-dependent), imported from jA //Numerates the Number for the status changes (client-dependent), imported from jA
enum { enum si_type {
SI_BLANK = -1, SI_BLANK = -1,
SI_PROVOKE = 0, SI_PROVOKE = 0,
SI_ENDURE = 1, 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); 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 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))); \ #define status_cpy(a, b) { \
if ((a)->lhw && (b)->lhw) { memcpy((a)->lhw, (b)->lhw, sizeof(struct weapon_atk)); }} 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 regen_data *status_get_regen_data(struct block_list *bl);
struct status_data *status_get_status_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_isdead(struct block_list *bl);
int status_isimmune(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. //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_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_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) #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_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 , int type,int tid ); 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 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(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);
int status_change_clear(struct block_list *bl,int type); int status_change_clear(struct block_list* bl, enum sc_type type);
int status_change_clear_buffs(struct block_list *bl, int 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); void status_calc_bl(struct block_list *bl, unsigned long flag);
int status_calc_pet(struct pet_data* pd, int first); // [Skotlex] int status_calc_pet(struct pet_data* pd, int first); // [Skotlex]

View File

@ -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 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)) if (!unit_remove_map(bl, type))
return 3; return 3;