From e322c69d27d3db8c7141d27fa8baf0745de2eae4 Mon Sep 17 00:00:00 2001 From: Dastgir Pojee <dastgirpojee@rocketmail.com> Date: Fri, 18 Oct 2013 10:57:06 +0530 Subject: Since our neighbours added it, we too wanted this feature. Topic:http://hercules.ws/board/topic/2540-add-rathena-new-aloot-type/ --- src/map/atcommand.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/map/pc.c | 15 +++++-- src/map/pc.h | 2 + 3 files changed, 127 insertions(+), 4 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index cc29fa1bb..a3b55a6a7 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5727,6 +5727,8 @@ ACMD(autolootitem) int i; int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset + nullpo_retr(-1, sd); + if (message && *message) { if (message[0] == '+') { message++; @@ -5813,6 +5815,117 @@ ACMD(autolootitem) } return true; } + +/*========================================== + * @autoloottype + * Flags: + * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC, + * 16: IT_WEAPON, 32: IT_ARMOR, 64: IT_CARD, 128: IT_PETEGG, + * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME + * 262144: IT_CASH + *------------------------------------------ + * Credits: + * chriser + * Aleos + *------------------------------------------*/ +ACMD(autoloottype){ + uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset + enum item_types type = -1; + int ITEM_NONE = 0, ITEM_MAX = 1533; + + nullpo_retr(-1, sd); + + if (message && *message) { + if (message[0] == '+') { + message++; + action = 1; + } + else if (message[0] == '-') { + message++; + action = 2; + } + else if (!strcmp(message,"reset")) + action = 4; + } + + if (action < 3) { // add or remove + if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0)) + type = IT_HEALING; + else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2)) + type = IT_USABLE; + else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3)) + type = IT_ETC; + else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 4)) + type = IT_WEAPON; + else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 5)) + type = IT_ARMOR; + else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6)) + type = IT_CARD; + else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7)) + type = IT_PETEGG; + else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8)) + type = IT_PETARMOR; + else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10)) + type = IT_AMMO; + else { + clif->message(fd, msg_txt(1489)); // Item type not found. + + return false; + } + } + + switch (action) { + case 1: + if (sd->state.autoloottype&(1<<type)) { + clif->message(fd, msg_txt(1490)); // You're already autolooting this item type. + return false; + } + if (sd->state.autoloottype == ITEM_MAX) { + clif->message(fd, msg_txt(1491)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>. + return false; + } + sd->state.autolootingtype = 1; // Autoloot Activated + sd->state.autoloottype |= (1<<type); // Stores the type + sprintf(atcmd_output, msg_txt(1492), itemdb->typename(type), type); // Autolooting item type: '%s' {%d} + clif->message(fd, atcmd_output); + break; + case 2: + if (!(sd->state.autoloottype&(1<<type))) { + clif->message(fd, msg_txt(1493)); // You're currently not autolooting this item type. + return false; + } + sd->state.autoloottype &= ~(1<<type); + sprintf(atcmd_output, msg_txt(1494), itemdb->typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list. + clif->message(fd, atcmd_output); + if (sd->state.autoloottype == ITEM_NONE) + sd->state.autolootingtype = 0; + break; + case 3: + clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>". + clif->message(fd, msg_txt(1496)); // Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 + clif->message(fd, msg_txt(1497)); // "@aloottype reset" will clear your autoloottype list. + if (sd->state.autoloottype == ITEM_NONE) + clif->message(fd, msg_txt(1498)); // Your autoloottype list is empty. + else { + clif->message(fd, msg_txt(1499)); // Item types on your autoloottype list: + while (i < IT_MAX) { + if (sd->state.autoloottype&(1<<i)) { + sprintf(atcmd_output, " '%s' {%d}", itemdb->typename(i), i); + clif->message(fd, atcmd_output); + } + i++; + } + } + break; + case 4: + sd->state.autoloottype = ITEM_NONE; + sd->state.autolootingtype = 0; + clif->message(fd, msg_txt(1500)); // Your autoloottype list has been reset. + break; + } + return 0; +} + /** * No longer available, keeping here just in case it's back someday. [Ind] **/ @@ -9598,6 +9711,7 @@ void atcommand_basecommands(void) { ACMD_DEF(changelook), ACMD_DEF(autoloot), ACMD_DEF2("alootid", autolootitem), + ACMD_DEF(autoloottype), ACMD_DEF(mobinfo), ACMD_DEF(exp), ACMD_DEF(version), diff --git a/src/map/pc.c b/src/map/pc.c index 157d9e28a..f3f554137 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9346,11 +9346,18 @@ void pc_overheat(struct map_session_data *sd, int val) { */ bool pc_isautolooting(struct map_session_data *sd, int nameid) { - int i; - if( !sd->state.autolooting ) + uint8 i = 0; + bool j = false; + + if (!sd->state.autolooting && !sd->state.autolootingtype) return false; - ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); - return (i != AUTOLOOTITEM_SIZE); + + if (sd->state.autolooting) + ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); + if (sd->state.autolootingtype && sd->state.autoloottype&(1<<itemdb_type(nameid))) + j = true; + + return (i != AUTOLOOTITEM_SIZE || j ); } /** diff --git a/src/map/pc.h b/src/map/pc.h index f770818c2..bbea0e121 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -160,7 +160,9 @@ struct map_session_data { short pmap; // Previous map on Map Change unsigned short autoloot; unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus] + unsigned short autoloottype; unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid + unsigned int autolootingtype : 1; //performance-saver, autolooting state for @autoloottype unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish] unsigned int gmaster_flag : 1; unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not. -- cgit v1.2.3-70-g09d2 From d33d171e7bbe879af077099d201e7f9b86dd23b9 Mon Sep 17 00:00:00 2001 From: Dastgir Pojee <dastgirpojee@rocketmail.com> Date: Thu, 31 Oct 2013 00:08:56 +0530 Subject: Several Changes to autoloottype command. --- src/map/atcommand.c | 81 ++++++++++++++++++++++++----------------------------- src/map/pc.c | 14 ++++----- src/map/pc.h | 1 - 3 files changed, 43 insertions(+), 53 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a3b55a6a7..605572aad 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5727,8 +5727,6 @@ ACMD(autolootitem) int i; int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset - nullpo_retr(-1, sd); - if (message && *message) { if (message[0] == '+') { message++; @@ -5740,16 +5738,16 @@ ACMD(autolootitem) } else if (!strcmp(message,"reset")) action = 4; - } - - if (action < 3) // add or remove - { - if ((item_data = itemdb->exists(atoi(message))) == NULL) - item_data = itemdb->search_name(message); - if (!item_data) { - // No items founds in the DB with Id or Name - clif->message(fd, msg_txt(1189)); // Item not found. - return false; + + if (action < 3) // add or remove + { + if ((item_data = itemdb->exists(atoi(message))) == NULL) + item_data = itemdb->search_name(message); + if (!item_data) { + // No items founds in the DB with Id or Name + clif->message(fd, msg_txt(1189)); // Item not found. + return false; + } } } @@ -5829,11 +5827,10 @@ ACMD(autolootitem) * Aleos *------------------------------------------*/ ACMD(autoloottype){ - uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset + int i; + uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset enum item_types type = -1; int ITEM_NONE = 0, ITEM_MAX = 1533; - - nullpo_retr(-1, sd); if (message && *message) { if (message[0] == '+') { @@ -5846,31 +5843,30 @@ ACMD(autoloottype){ } else if (!strcmp(message,"reset")) action = 4; - } - if (action < 3) { // add or remove - if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0)) - type = IT_HEALING; - else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2)) - type = IT_USABLE; - else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3)) - type = IT_ETC; - else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 4)) - type = IT_WEAPON; - else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 5)) - type = IT_ARMOR; - else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6)) - type = IT_CARD; - else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7)) - type = IT_PETEGG; - else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8)) - type = IT_PETARMOR; - else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10)) - type = IT_AMMO; - else { - clif->message(fd, msg_txt(1489)); // Item type not found. - - return false; + if (action < 3) { // add or remove + if ((atoi(message) == 0) ||(strncmp(message, "healing", 3) == 0)) + type = IT_HEALING; + else if ((atoi(message) == 2) || (strncmp(message, "usable", 3) == 0)) + type = IT_USABLE; + else if ((atoi(message) == 3) || (strncmp(message, "etc", 3) == 0)) + type = IT_ETC; + else if ((atoi(message) == 4) || (strncmp(message, "weapon", 3) == 0)) + type = IT_WEAPON; + else if ((atoi(message) == 5) || (strncmp(message, "armor", 3) == 0)) + type = IT_ARMOR; + else if ((atoi(message) == 6) || (strncmp(message, "card", 3) == 0)) + type = IT_CARD; + else if ((atoi(message) == 7) || (strncmp(message, "petegg", 4) == 0)) + type = IT_PETEGG; + else if ((atoi(message) == 8) || (strncmp(message, "petarmor", 4) == 0)) + type = IT_PETARMOR; + else if ((atoi(message) == 10) || (strncmp(message, "ammo", 3) == 0)) + type = IT_AMMO; + else { + clif->message(fd, msg_txt(1489)); // Item type not found. + return false; + } } } @@ -5884,7 +5880,6 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1491)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>. return false; } - sd->state.autolootingtype = 1; // Autoloot Activated sd->state.autoloottype |= (1<<type); // Stores the type sprintf(atcmd_output, msg_txt(1492), itemdb->typename(type), type); // Autolooting item type: '%s' {%d} clif->message(fd, atcmd_output); @@ -5897,8 +5892,6 @@ ACMD(autoloottype){ sd->state.autoloottype &= ~(1<<type); sprintf(atcmd_output, msg_txt(1494), itemdb->typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list. clif->message(fd, atcmd_output); - if (sd->state.autoloottype == ITEM_NONE) - sd->state.autolootingtype = 0; break; case 3: clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>". @@ -5908,18 +5901,16 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1498)); // Your autoloottype list is empty. else { clif->message(fd, msg_txt(1499)); // Item types on your autoloottype list: - while (i < IT_MAX) { + for(i=0; i < IT_MAX; i++){ if (sd->state.autoloottype&(1<<i)) { sprintf(atcmd_output, " '%s' {%d}", itemdb->typename(i), i); clif->message(fd, atcmd_output); } - i++; } } break; case 4: sd->state.autoloottype = ITEM_NONE; - sd->state.autolootingtype = 0; clif->message(fd, msg_txt(1500)); // Your autoloottype list has been reset. break; } diff --git a/src/map/pc.c b/src/map/pc.c index f3f554137..7966e49ab 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9346,18 +9346,18 @@ void pc_overheat(struct map_session_data *sd, int val) { */ bool pc_isautolooting(struct map_session_data *sd, int nameid) { - uint8 i = 0; + int i = 0; bool j = false; - if (!sd->state.autolooting && !sd->state.autolootingtype) + if (sd->state.autoloottype && sd->state.autoloottype&(1<<itemdb_type(nameid))) + return true; + + if (!sd->state.autolooting) return false; - if (sd->state.autolooting) - ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); - if (sd->state.autolootingtype && sd->state.autoloottype&(1<<itemdb_type(nameid))) - j = true; + ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); - return (i != AUTOLOOTITEM_SIZE || j ); + return (i != AUTOLOOTITEM_SIZE); } /** diff --git a/src/map/pc.h b/src/map/pc.h index bbea0e121..bb7bff375 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -162,7 +162,6 @@ struct map_session_data { unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus] unsigned short autoloottype; unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid - unsigned int autolootingtype : 1; //performance-saver, autolooting state for @autoloottype unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish] unsigned int gmaster_flag : 1; unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not. -- cgit v1.2.3-70-g09d2 From fa54cf57ded42d7b0b45a5025a8858a9b52a0074 Mon Sep 17 00:00:00 2001 From: Dastgir Pojee <dastgirpojee@rocketmail.com> Date: Fri, 1 Nov 2013 10:27:12 +0530 Subject: Removed type_id and some unused variables from @autoloottype --- conf/messages.conf | 11 +++++------ src/map/atcommand.c | 45 +++++++++++++++++---------------------------- src/map/pc.c | 1 - 3 files changed, 22 insertions(+), 35 deletions(-) (limited to 'src/map') diff --git a/conf/messages.conf b/conf/messages.conf index ae96152f0..22ed991e2 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -1533,14 +1533,13 @@ 1488: Transforming into monster is not allowed in Guild Wars. // @autoloottype -1489: Item type not found. 1490: You're already autolooting this item type. -1491: Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>. -1492: Autolooting item type: '%s' {%d} +1491: Item type not found. +1492: Autolooting item type: '%s' 1493: You're currently not autolooting this item type. -1494: Removed item type: '%s' {%d} from your autoloottype list. -1495: To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>". -1496: Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 +1494: Removed item type: '%s' from your autoloottype list. +1495: To add an item type to the list, use "@aloottype +<type name>". To remove an item type, use "@aloottype -<type name>". +1496: Type List: healing, usable, etc, weapon, armor, card, petegg, petarmor, ammo 1497: "@aloottype reset" will clear your autoloottype list. 1498: Your autoloottype list is empty. 1499: Item types on your autoloottype list: diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 605572aad..980f61ad9 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5816,21 +5816,14 @@ ACMD(autolootitem) /*========================================== * @autoloottype - * Flags: - * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC, - * 16: IT_WEAPON, 32: IT_ARMOR, 64: IT_CARD, 128: IT_PETEGG, - * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME - * 262144: IT_CASH - *------------------------------------------ * Credits: - * chriser - * Aleos + * chriser,Aleos *------------------------------------------*/ ACMD(autoloottype){ int i; uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset enum item_types type = -1; - int ITEM_NONE = 0, ITEM_MAX = 1533; + int ITEM_NONE = 0; if (message && *message) { if (message[0] == '+') { @@ -5845,26 +5838,26 @@ ACMD(autoloottype){ action = 4; if (action < 3) { // add or remove - if ((atoi(message) == 0) ||(strncmp(message, "healing", 3) == 0)) + if (strncmp(message, "healing", 3) == 0) type = IT_HEALING; - else if ((atoi(message) == 2) || (strncmp(message, "usable", 3) == 0)) + else if (strncmp(message, "usable", 3) == 0) type = IT_USABLE; - else if ((atoi(message) == 3) || (strncmp(message, "etc", 3) == 0)) + else if (strncmp(message, "etc", 3) == 0) type = IT_ETC; - else if ((atoi(message) == 4) || (strncmp(message, "weapon", 3) == 0)) + else if (strncmp(message, "weapon", 3) == 0) type = IT_WEAPON; - else if ((atoi(message) == 5) || (strncmp(message, "armor", 3) == 0)) + else if (strncmp(message, "armor", 3) == 0) type = IT_ARMOR; - else if ((atoi(message) == 6) || (strncmp(message, "card", 3) == 0)) + else if (strncmp(message, "card", 3) == 0) type = IT_CARD; - else if ((atoi(message) == 7) || (strncmp(message, "petegg", 4) == 0)) + else if (strncmp(message, "petegg", 4) == 0) type = IT_PETEGG; - else if ((atoi(message) == 8) || (strncmp(message, "petarmor", 4) == 0)) + else if (strncmp(message, "petarmor", 4) == 0) type = IT_PETARMOR; - else if ((atoi(message) == 10) || (strncmp(message, "ammo", 3) == 0)) + else if (strncmp(message, "ammo", 3) == 0) type = IT_AMMO; else { - clif->message(fd, msg_txt(1489)); // Item type not found. + clif->message(fd, msg_txt(1491)); // Item type not found. return false; } } @@ -5876,12 +5869,8 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1490)); // You're already autolooting this item type. return false; } - if (sd->state.autoloottype == ITEM_MAX) { - clif->message(fd, msg_txt(1491)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>. - return false; - } sd->state.autoloottype |= (1<<type); // Stores the type - sprintf(atcmd_output, msg_txt(1492), itemdb->typename(type), type); // Autolooting item type: '%s' {%d} + sprintf(atcmd_output, msg_txt(1492), itemdb->typename(type)); // Autolooting item type: '%s' clif->message(fd, atcmd_output); break; case 2: @@ -5890,12 +5879,12 @@ ACMD(autoloottype){ return false; } sd->state.autoloottype &= ~(1<<type); - sprintf(atcmd_output, msg_txt(1494), itemdb->typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list. + sprintf(atcmd_output, msg_txt(1494), itemdb->typename(type)); // Removed item type: '%s' from your autoloottype list. clif->message(fd, atcmd_output); break; case 3: - clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>". - clif->message(fd, msg_txt(1496)); // Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 + clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +<type name>". To remove an item type, use "@aloottype -<type name>". + clif->message(fd, msg_txt(1496)); // Type List: healing, usable, etc, weapon, armor, card, petegg, petarmor, ammo clif->message(fd, msg_txt(1497)); // "@aloottype reset" will clear your autoloottype list. if (sd->state.autoloottype == ITEM_NONE) clif->message(fd, msg_txt(1498)); // Your autoloottype list is empty. @@ -5903,7 +5892,7 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1499)); // Item types on your autoloottype list: for(i=0; i < IT_MAX; i++){ if (sd->state.autoloottype&(1<<i)) { - sprintf(atcmd_output, " '%s' {%d}", itemdb->typename(i), i); + sprintf(atcmd_output, " '%s'", itemdb->typename(i)); clif->message(fd, atcmd_output); } } diff --git a/src/map/pc.c b/src/map/pc.c index 7966e49ab..90a3db853 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9347,7 +9347,6 @@ void pc_overheat(struct map_session_data *sd, int val) { bool pc_isautolooting(struct map_session_data *sd, int nameid) { int i = 0; - bool j = false; if (sd->state.autoloottype && sd->state.autoloottype&(1<<itemdb_type(nameid))) return true; -- cgit v1.2.3-70-g09d2 From 84e4e6ee1dcaf37d73ec6f590c675ce4b17352b9 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Sat, 2 Nov 2013 18:02:36 -0200 Subject: Fixed Shadow System Bonuses Item in shadow slots are now able to give bonuses properly, thanks to rosfus for pointing it out! Also added the missing constants for script handling. Signed-off-by: shennetsind <ind@henn.et> --- db/const.txt | 6 ++++++ doc/script_commands.txt | 7 +++++++ src/map/pc.c | 2 +- src/map/pc.h | 2 +- src/map/script.c | 2 +- src/map/script.h | 2 +- 6 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/map') diff --git a/db/const.txt b/db/const.txt index 3c20abc4a..cdb000417 100644 --- a/db/const.txt +++ b/db/const.txt @@ -610,6 +610,12 @@ EQI_COSTUME_HEAD_LOW 11 EQI_COSTUME_HEAD_MID 12 EQI_COSTUME_HEAD_TOP 13 EQI_COSTUME_GARMENT 14 +EQI_SHADOW_ARMOR 15 +EQI_SHADOW_WEAPON 16 +EQI_SHADOW_SHIELD 17 +EQI_SHADOW_SHOES 18 +EQI_SHADOW_ACC_R 19 +EQI_SHADOW_ACC_L 20 LOOK_BASE 0 LOOK_HAIR 1 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index bd0b032f1..f2ba9f6ba 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2550,6 +2550,13 @@ EQI_HEAD_LOW (10) - Lower Headgear (beards, some masks) EQI_COSTUME_HEAD_LOW (11) - Lower Costume Headgear EQI_COSTUME_HEAD_MID (12) - Middle Costume Headgear EQI_COSTUME_HEAD_TOP (13) - Upper Costume Headgear +EQI_COSTUME_GARMENT (14) - Costume Garment +EQI_SHADOW_ARMOR (15) - Shadow Armor +EQI_SHADOW_WEAPON (16) - Shadow Weapon +EQI_SHADOW_SHIELD (17) - Shadow Shield +EQI_SHADOW_SHOES (18) - Shadow Shoes +EQI_SHADOW_ACC_R (19) - Shadow Accessory 2 +EQI_SHADOW_ACC_L (20) - Shadow Accessory 1 Notice that a few items occupy several equipment slots, and if the character is wearing such an item, 'getequipid' will return it's ID number diff --git a/src/map/pc.c b/src/map/pc.c index 35d883b6f..41f4a1a96 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10257,7 +10257,7 @@ void pc_defaults(void) { { SG_MOON_ANGER, SG_MOON_BLESS, SG_MOON_COMFORT, "PC_FEEL_MOON", "PC_HATE_MOB_MOON", is_day_of_moon }, { SG_STAR_ANGER, SG_STAR_BLESS, SG_STAR_COMFORT, "PC_FEEL_STAR", "PC_HATE_MOB_STAR", is_day_of_star } }; - unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_GARMENT,EQP_AMMO}; + unsigned int equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_GARMENT,EQP_AMMO, EQP_SHADOW_ARMOR, EQP_SHADOW_WEAPON, EQP_SHADOW_SHIELD, EQP_SHADOW_SHOES, EQP_SHADOW_ACC_R, EQP_SHADOW_ACC_L }; pc = &pc_s; diff --git a/src/map/pc.h b/src/map/pc.h index fc37d0ef2..8eb7e692a 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -731,7 +731,7 @@ struct pc_interface { #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; #endif - unsigned short equip_pos[EQI_MAX]; + unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; struct fame_list smith_fame_list[MAX_FAME_LIST]; diff --git a/src/map/script.c b/src/map/script.c index d51f27ce9..944759f39 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18210,7 +18210,7 @@ void script_label_add(int key, int pos) { void script_defaults(void) { // aegis->athena slot position conversion table - unsigned int equip[SCRIPT_EQUIP_TABLE_SIZE] = {EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_GARMENT}; + unsigned int equip[SCRIPT_EQUIP_TABLE_SIZE] = {EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW,EQP_COSTUME_HEAD_LOW,EQP_COSTUME_HEAD_MID,EQP_COSTUME_HEAD_TOP,EQP_COSTUME_GARMENT,EQP_SHADOW_ARMOR, EQP_SHADOW_WEAPON, EQP_SHADOW_SHIELD, EQP_SHADOW_SHOES, EQP_SHADOW_ACC_R, EQP_SHADOW_ACC_L}; script = &script_s; diff --git a/src/map/script.h b/src/map/script.h index c6cb6070b..a4d14c777 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -35,7 +35,7 @@ struct eri; //#define SCRIPT_HASH_SDBM #define SCRIPT_HASH_ELF -#define SCRIPT_EQUIP_TABLE_SIZE 14 +#define SCRIPT_EQUIP_TABLE_SIZE 20 //#define SCRIPT_DEBUG_DISP //#define SCRIPT_DEBUG_DISASM -- cgit v1.2.3-70-g09d2 From 5e002a43399f5358b7aabd1bd653f598f35287e2 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Sat, 2 Nov 2013 18:54:56 -0200 Subject: Fixed Bug #7793 package parser will now throw an error when using a invalid random: field, also fixed another error message (was missing a double %) http://hercules.ws/board/tracker/issue-7793-item-packages-crash/ Signed-off-by: shennetsind <ind@henn.et> --- src/map/itemdb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/map') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index feb17ddc8..3fc8d526b 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1027,7 +1027,10 @@ void itemdb_read_packages(void) { if( itemdb->packages[count].random_qty ) { CREATE(itemdb->packages[count].random_groups, struct item_package_rand_group, itemdb->packages[count].random_qty); for( c = 0; c < itemdb->packages[count].random_qty; c++ ) { - CREATE(itemdb->packages[count].random_groups[c].random_list, struct item_package_rand_entry, rgroups[ i - 1 ][c]); + if( !rgroups[ i - 1 ][c] ) + ShowError("itemdb_read_packages: package '%s' missing 'Random' field %d! there must not be gaps!\n",config_setting_name(itg),c+1); + else + CREATE(itemdb->packages[count].random_groups[c].random_list, struct item_package_rand_entry, rgroups[ i - 1 ][c]); itemdb->packages[count].random_groups[c].random_qty = 0; } } @@ -1090,7 +1093,7 @@ void itemdb_read_packages(void) { itemdb->packages[count].random_groups[gidx].random_list[r].id = data ? data->nameid : 0; itemdb->packages[count].random_groups[gidx].random_list[r].qty = icount; if( (itemdb->packages[count].random_groups[gidx].random_list[r].rate = rate) == 10000 ) { - ShowWarning("itemdb_read_packages: item '%s' in '%s' has 100% drop rate!! set this item as 'Random: 0' or other items won't drop!!!\n",itname,config_setting_name(itg)); + ShowWarning("itemdb_read_packages: item '%s' in '%s' has 100%% drop rate!! set this item as 'Random: 0' or other items won't drop!!!\n",itname,config_setting_name(itg)); } itemdb->packages[count].random_groups[gidx].random_list[r].hours = expire; itemdb->packages[count].random_groups[gidx].random_list[r].announce = announce == true ? 1 : 0; -- cgit v1.2.3-70-g09d2 From 37fdcbae655c48e569398d3750d503ffe3bfae66 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Sat, 2 Nov 2013 20:25:51 -0200 Subject: Fixed Bug #7786 @speed no longer screws up on map change, modified @speed feedback so its clear whether the permanent speed flag is gone, enhanced @speed by making it capable of bypassing battle_config.max_walk_speed, made status_calc_speed rely on MIN_WALK_SPEED instead of the hardcoded 0, modified MIN_WALK_SPEED from 0 to 20 (it 1) wasnt being respected and 2) less than 20 clips). @speed is now capable of moving the character faster, prior to this commit @speed 0 was equivalent to @speed 50 of this new version, @speed 20 for example is now the new maximum (and moves much faster). http://hercules.ws/board/tracker/issue-7786-speed-bug-when-changing-maps/ Thanks to Mumbles for all the info Signed-off-by: shennetsind <ind@henn.et> --- conf/messages.conf | 2 +- src/common/mmo.h | 2 +- src/map/atcommand.c | 18 ++++++++++++------ src/map/map.c | 2 -- src/map/status.c | 28 +++++++++++++++------------- 5 files changed, 29 insertions(+), 23 deletions(-) (limited to 'src/map') diff --git a/conf/messages.conf b/conf/messages.conf index 7b7a99301..5d0fd7ba6 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -192,7 +192,7 @@ 169: The item (%d: '%s') is not equipable. 170: The item is not equipable. 171: %d - void -//172: You replace previous memo position %d - %s (%d,%d). +172: Speed returned to normal. //173: Note: you don't have the 'Warp' skill level to use it. 174: Number of status points changed. 175: Number of skill points changed. diff --git a/src/common/mmo.h b/src/common/mmo.h index 5f75f35da..349912a39 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -107,7 +107,7 @@ //Should hold the max of GLOBAL/ACCOUNT/ACCOUNT2 (needed for some arrays that hold all three) #define MAX_REG_NUM 256 #define DEFAULT_WALK_SPEED 150 -#define MIN_WALK_SPEED 0 +#define MIN_WALK_SPEED 20 /* below 20 clips animation */ #define MAX_WALK_SPEED 1000 #define MAX_STORAGE 600 #define MAX_GUILD_STORAGE 600 diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 146159c63..758ebb0db 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -766,15 +766,21 @@ ACMD(speed) return false; } - if (speed < 0) { + sd->state.permanent_speed = 0; + + if (speed < 0) sd->base_status.speed = DEFAULT_WALK_SPEED; - sd->state.permanent_speed = 0; // Remove lock when set back to default speed. - } else { + else sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED); - sd->state.permanent_speed = 1; // Set lock when set to non-default speed. - } + status_calc_bl(&sd->bl, SCB_SPEED); - clif->message(fd, msg_txt(8)); // Speed changed. + + if( sd->base_status.speed != DEFAULT_WALK_SPEED ) { + sd->state.permanent_speed = 1; // Set lock when set to non-default speed. + clif->message(fd, msg_txt(8)); // Speed changed. + } else + clif->message(fd, msg_txt(172)); //Speed returned to normal. + return true; } diff --git a/src/map/map.c b/src/map/map.c index b50297ca6..2a2f98bdc 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1722,8 +1722,6 @@ int map_quit(struct map_session_data *sd) { if( sd->state.storage_flag == 1 ) sd->state.storage_flag = 0; // No need to Double Save Storage on Quit. - if (sd->state.permanent_speed == 1) sd->state.permanent_speed = 0; // Remove lock so speed is set back to normal at login. - if( sd->ed ) { elemental->clean_effect(sd->ed); unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); diff --git a/src/map/status.c b/src/map/status.c index 9e98b2801..0ff30595d 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2389,11 +2389,17 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_CLAIRVOYANCE); memset(&sd->special_state,0,sizeof(sd->special_state)); - memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp))); - - //FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] - if (!sd->state.permanent_speed) + + if (!sd->state.permanent_speed) { + memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp))); bstatus->speed = DEFAULT_WALK_SPEED; + } else { + int pSpeed = bstatus->speed; + memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp))); + bstatus->speed = pSpeed; + } + + //FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] //Give them all modes except these (useful for clones) bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK); @@ -3670,6 +3676,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { if(flag&SCB_SPEED) { struct unit_data *ud = unit->bl2ud(bl); + st->speed = status->calc_speed(bl, sc, bst->speed); //Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER @@ -3678,13 +3685,11 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { if (ud) ud->state.change_walk_target = ud->state.speed_changed = 1; - if( bl->type&BL_PC && st->speed < battle_config.max_walk_speed ) + if( bl->type&BL_PC && !(sd && sd->state.permanent_speed) && st->speed < battle_config.max_walk_speed ) st->speed = battle_config.max_walk_speed; if( bl->type&BL_HOM && battle_config.hom_setting&0x8 && ((TBL_HOM*)bl)->master) st->speed = status->get_speed(&((TBL_HOM*)bl)->master->bl); - - } if(flag&SCB_CRI && bst->cri) { @@ -5045,11 +5050,8 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc TBL_PC* sd = BL_CAST(BL_PC, bl); int speed_rate; - if( sc == NULL ) - return cap_value(speed,10,USHRT_MAX); - - if (sd && sd->state.permanent_speed) - return (short)cap_value(speed,10,USHRT_MAX); + if( sc == NULL || ( sd && sd->state.permanent_speed ) ) + return (unsigned short)cap_value(speed,MIN_WALK_SPEED,MAX_WALK_SPEED); if( sd && sd->ud.skilltimer != INVALID_TIMER && (pc->checkskill(sd,SA_FREECAST) > 0 || sd->ud.skill_id == LG_EXEEDBREAK) ) { @@ -5222,7 +5224,7 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc } - return (short)cap_value(speed,10,USHRT_MAX); + return (unsigned short)cap_value(speed,MIN_WALK_SPEED,MAX_WALK_SPEED); } // flag&1 - fixed value [malufett] -- cgit v1.2.3-70-g09d2 From 34b5ad00e2b7a3589040946b7825ef246bfafe99 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Sat, 2 Nov 2013 20:56:10 -0200 Subject: Fixed Bug #7621 Magicmushroom poison now properly cancels skills being cast upon activating one of its own, also modified unit_skillcastcancel's error message upon timer deletion failure so that it becomes easier to debug in the future. http://hercules.ws/board/tracker/issue-7621-erro-map-server-waraitake/ Thanks to Beret Signed-off-by: shennetsind <ind@henn.et> --- src/map/status.c | 20 ++++++++++---------- src/map/unit.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/map') diff --git a/src/map/status.c b/src/map/status.c index 0ff30595d..c06de4dfe 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -10379,7 +10379,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { if (sd && !pc_issit(sd)) { //can't cast if sit int mushroom_skill_id = 0, i; unit->stop_attack(bl); - unit->skillcastcancel(bl,1); + unit->skillcastcancel(bl,0); do { i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB; mushroom_skill_id = skill->magicmushroom_db[i].skill_id; @@ -10387,15 +10387,15 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { while( mushroom_skill_id == 0 ); switch( skill->get_casttype(mushroom_skill_id) ) { // Magic Mushroom skills are buffs or area damage - case CAST_GROUND: - skill->castend_pos2(bl,bl->x,bl->y,mushroom_skill_id,1,tick,0); - break; - case CAST_NODAMAGE: - skill->castend_nodamage_id(bl,bl,mushroom_skill_id,1,tick,0); - break; - case CAST_DAMAGE: - skill->castend_damage_id(bl,bl,mushroom_skill_id,1,tick,0); - break; + case CAST_GROUND: + skill->castend_pos2(bl,bl->x,bl->y,mushroom_skill_id,1,tick,0); + break; + case CAST_NODAMAGE: + skill->castend_nodamage_id(bl,bl,mushroom_skill_id,1,tick,0); + break; + case CAST_DAMAGE: + skill->castend_damage_id(bl,bl,mushroom_skill_id,1,tick,0); + break; } } diff --git a/src/map/unit.c b/src/map/unit.c index 08e97cfee..c7ba2f6f9 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1966,7 +1966,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) else ret = timer->delete( ud->skilltimer, skill->castend_id ); if( ret < 0 ) - ShowError("delete timer error : skill_id : %d\n",ret); + ShowError("delete timer error %d : skill %d (%s)\n",ret,skill_id,skill->get_name(skill_id)); ud->skilltimer = INVALID_TIMER; -- cgit v1.2.3-70-g09d2 From 6728c0fa88b84fccb6f179ae13cf8a15c1ea23a4 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sun, 3 Nov 2013 20:19:26 +0100 Subject: Allow warp duplicates without a 'facing' value - Warps don't require a facing, so their duplicates shouldn't either. - Credits to jaBote. Signed-off-by: Haru <haru@dotalux.com> --- doc/script_commands.txt | 4 ++-- src/map/npc.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/map') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f2ba9f6ba..f0016b104 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -207,7 +207,7 @@ Ex: if your NPC is named 'Hunter#hunter1', it will be displayed as 'Hunter' ** Define a warp point -<from map name>,<fromX>,<fromY>,<facing>%TAB%warp%TAB%<warp name>%TAB%<spanx>,<spany>,<to map name>,<toX>,<toY> +<from map name>,<fromX>,<fromY>{,<facing>}%TAB%warp%TAB%<warp name>%TAB%<spanx>,<spany>,<to map name>,<toX>,<toY> This will define a warp NPC that will warp a player between maps, and while most arguments of that are obvious, some deserve special mention. @@ -299,7 +299,7 @@ items here. The layout used to define sale items still count, and ** Define an warp/shop/cashshop/NPC duplicate. -warp: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<spanx>,<spany> +warp: <map name>,<x>,<y>{,<facing>}%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<spanx>,<spany> shop/cashshop/npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id> shop/cashshop/npc: <map name>,<x>,<y>,<facing>%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id> npc: -%TAB%duplicate(<label>)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY> diff --git a/src/map/npc.c b/src/map/npc.c index f0bdd7bd0..90f588a26 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2547,8 +2547,10 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch x = y = dir = 0; m = -1; } else { - if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 )// <map name>,<x>,<y>,<facing> - { + int fields = sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir); + if( type == WARP && fields == 3 ) { // <map name>,<x>,<y> + dir = 0; + } else if( fields != 4 ) {// <map name>,<x>,<y>,<facing> ShowError("npc_parse_duplicate: Invalid placement format for duplicate in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return end;// next line, try to continue } -- cgit v1.2.3-70-g09d2 From 2ea51e2b2ac4e39d748e1ec24e34364746e43a8f Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sat, 2 Nov 2013 20:44:46 +0100 Subject: Added some packetver-related flags to the UNIX build script - The --disable-packetver-re (or --enable-packetver-re=no) flag prevents the definition of PACKETVER_RE (without editing mmo.h) - The --with-key1=, --with-key2=, --with-key3= flags override the encryption key defined by the current packetver. All three flags are required if at least one is used, or they'll be ignored. - These options are mostly useful for buildbots, developers who often use git bisect, or users who want to minimize their diffs and still want to override those settings. - (unrelated minor tweak) Silenced an unnecessarily verbose STDERR message caused by the $CC shipped with clang-5 during the MinGW check. --- configure | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- configure.in | 96 ++++++++++++++++++++++++++++++++++++++++++++++- src/common/mmo.h | 14 +++---- src/map/packets.h | 4 ++ 4 files changed, 211 insertions(+), 13 deletions(-) (limited to 'src/map') diff --git a/configure b/configure index 919d6f883..bf0a4d8ea 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in c4af60e. +# From configure.in 0219c4d. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # @@ -691,6 +691,10 @@ ac_user_opts=' enable_option_checking enable_manager enable_packetver +enable_packetver_re +with_key1 +with_key2 +with_key3 enable_debug enable_buildbot enable_rdtsc @@ -1323,8 +1327,9 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin) - --enable-packetver=ARG Sets the PACKETVER define of the map-server. (see - src/map/clif.h) + --enable-packetver=ARG Sets the PACKETVER define. (see src/common/mmo.h) + --disable-packetver-re Sets or unsets the PACKETVER_RE define - see + src/common/mmo.h (currently enabled by default) --enable-debug[=ARG] Compiles extra debug code. (disabled by default) (available options: yes, no, gdb) --enable-buildbot[=ARG] (available options: yes, no) @@ -1352,6 +1357,12 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-key1[=ARG] Set the first obfuscation key (ignored unless the + other two are also specified) + --with-key2[=ARG] Set the second obfuscation key (ignored unless the + other two are also specified) + --with-key3[=ARG] Set the third obfuscation key (ignored unless the + other two are also specified) --with-maxconn[=ARG] optionally set the maximum connections the core can handle (default: 16384) NOT USED YET - EXPERIMENTAL --with-mysql[=ARG] optionally specify the path to the mysql_config @@ -3460,6 +3471,79 @@ fi +# +# packetver-RE +# +# Check whether --enable-packetver-re was given. +if test "${enable_packetver_re+set}" = set; then : + enableval=$enable_packetver_re; + enable_packetver_re="$enableval" + case $enableval in + "no");; + "yes");; + *) as_fn_error $? "invalid argument --enable-packetver-re=$enableval... stopping" "$LINENO" 5;; + esac + +else + enable_packetver_re="yes" + +fi + + + +# +# Obfuscation keys +# + +# Check whether --with-key1 was given. +if test "${with_key1+set}" = set; then : + withval=$with_key1; + obfuscationkey1="$( expr "0x$withval" : '0*x*\(0x[A-Fa-f0-9]\{8\}\)' )" + if ! expr "x$obfuscationkey1" : 'x0x[A-Fa-f0-9]\{8\}' >/dev/null 2>&1; then + obfuscationkey1="" + fi + +else + + obfuscationkey1="" + + +fi + + +# Check whether --with-key2 was given. +if test "${with_key2+set}" = set; then : + withval=$with_key2; + obfuscationkey2="$( expr "0x$withval" : '0*x*\(0x[A-Fa-f0-9]\{8\}\)' )" + if ! expr "x$obfuscationkey2" : 'x0x[A-Fa-f0-9]\{8\}' >/dev/null 2>&1; then + obfuscationkey2="" + fi + +else + + obfuscationkey2="" + + +fi + + +# Check whether --with-key3 was given. +if test "${with_key3+set}" = set; then : + withval=$with_key3; + obfuscationkey3="$( expr "0x$withval" : '0*x*\(0x[A-Fa-f0-9]\{8\}\)' )" + if ! expr "x$obfuscationkey3" : 'x0x[A-Fa-f0-9]\{8\}' >/dev/null 2>&1; then + obfuscationkey3="" + fi + +else + + obfuscationkey3="" + + +fi + + + # # debug # @@ -5361,6 +5445,24 @@ if test -n "$enable_packetver" ; then CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver" fi +# +# Packetver-RE +# +case $enable_packetver_re in + "yes") + # default value + CFLAGS="$CFLAGS -DDISABLE_PACKETVER_RE" + ;; + "no") + ;; +esac + +# +# Obfuscation keys +# +if test -n "$obfuscationkey1" -a -n "$obfuscationkey2" -a -n "$obfuscationkey3"; then + CFLAGS="$CFLAGS -DOBFUSCATIONKEY1=$obfuscationkey1 -DOBFUSCATIONKEY2=$obfuscationkey2 -DOBFUSCATIONKEY3=$obfuscationkey3" +fi # # Debug @@ -6376,7 +6478,7 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MinGW" >&5 $as_echo_n "checking for MinGW... " >&6; } -if test -n "`$CC --version | grep -i mingw`" ; then +if test -n "`$CC --version 2>/dev/null | grep -i mingw`" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CPPFLAGS="$CPPFLAGS -DMINGW" diff --git a/configure.in b/configure.in index b79e51f6d..98c493a03 100644 --- a/configure.in +++ b/configure.in @@ -46,13 +46,87 @@ AC_ARG_ENABLE( [packetver], AC_HELP_STRING( [--enable-packetver=ARG], - [Sets the PACKETVER define of the map-server. (see src/map/clif.h)] + [Sets the PACKETVER define. (see src/common/mmo.h)] ), [enable_packetver="$enableval"], [enable_packetver=""] ) +# +# packetver-RE +# +AC_ARG_ENABLE( + [packetver-re], + AC_HELP_STRING( + [--disable-packetver-re], + [Sets or unsets the PACKETVER_RE define - see src/common/mmo.h (currently enabled by default)] + ), + [ + enable_packetver_re="$enableval" + case $enableval in + "no");; + "yes");; + *) AC_MSG_ERROR([[invalid argument --enable-packetver-re=$enableval... stopping]]);; + esac + ], + [enable_packetver_re="yes"] +) + + +# +# Obfuscation keys +# +AC_ARG_WITH( + [key1], + AC_HELP_STRING( + [--with-key1@<:@=ARG@:>@], + [Set the first obfuscation key (ignored unless the other two are also specified)] + ), + [ + obfuscationkey1="$( expr "0x$withval" : '0*x*\(0x@<:@A-Fa-f0-9@:>@\{8\}\)' )" + if ! expr "x$obfuscationkey1" : 'x0x@<:@A-Fa-f0-9@:>@\{8\}' >/dev/null 2>&1; then + obfuscationkey1="" + fi + ], + [ + obfuscationkey1="" + ] +) +AC_ARG_WITH( + [key2], + AC_HELP_STRING( + [--with-key2@<:@=ARG@:>@], + [Set the second obfuscation key (ignored unless the other two are also specified)] + ), + [ + obfuscationkey2="$( expr "0x$withval" : '0*x*\(0x@<:@A-Fa-f0-9@:>@\{8\}\)' )" + if ! expr "x$obfuscationkey2" : 'x0x@<:@A-Fa-f0-9@:>@\{8\}' >/dev/null 2>&1; then + obfuscationkey2="" + fi + ], + [ + obfuscationkey2="" + ] +) +AC_ARG_WITH( + [key3], + AC_HELP_STRING( + [--with-key3@<:@=ARG@:>@], + [Set the third obfuscation key (ignored unless the other two are also specified)] + ), + [ + obfuscationkey3="$( expr "0x$withval" : '0*x*\(0x@<:@A-Fa-f0-9@:>@\{8\}\)' )" + if ! expr "x$obfuscationkey3" : 'x0x@<:@A-Fa-f0-9@:>@\{8\}' >/dev/null 2>&1; then + obfuscationkey3="" + fi + ], + [ + obfuscationkey3="" + ] +) + + # # debug # @@ -771,6 +845,24 @@ if test -n "$enable_packetver" ; then CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver" fi +# +# Packetver-RE +# +case $enable_packetver_re in + "yes") + # default value + CFLAGS="$CFLAGS -DDISABLE_PACKETVER_RE" + ;; + "no") + ;; +esac + +# +# Obfuscation keys +# +if test -n "$obfuscationkey1" -a -n "$obfuscationkey2" -a -n "$obfuscationkey3"; then + CFLAGS="$CFLAGS -DOBFUSCATIONKEY1=$obfuscationkey1 -DOBFUSCATIONKEY2=$obfuscationkey2 -DOBFUSCATIONKEY3=$obfuscationkey3" +fi # # Debug @@ -1035,7 +1127,7 @@ esac AC_SUBST([DLLEXT]) AC_MSG_CHECKING([for MinGW]) -if test -n "`$CC --version | grep -i mingw`" ; then +if test -n "`$CC --version 2>/dev/null | grep -i mingw`" ; then AC_MSG_RESULT([yes]) CPPFLAGS="$CPPFLAGS -DMINGW" if test -z "$fd_setsize" ; then diff --git a/src/common/mmo.h b/src/common/mmo.h index 349912a39..5f4da6eb0 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -48,18 +48,18 @@ // 20120307 - 2012-03-07aRagexeRE+ - 0x970 #ifndef PACKETVER - #define PACKETVER 20120418 -#endif +#define PACKETVER 20120418 +#endif // PACKETVER +#ifndef DISABLE_PACKETVER_RE // Comment the following line if your client is NOT ragexeRE (required because of conflicting packets in ragexe vs ragexeRE). #define PACKETVER_RE +#endif // DISABLE_PACKETVER_RE // Client support for experimental RagexeRE UI present in 2012-04-10 and 2012-04-18 -#ifdef PACKETVER_RE -#if (PACKETVER == 20120410) || (PACKETVER == 20120418) - #define PARTY_RECRUIT -#endif -#endif +#if defined(PACKETVER_RE) && ( PACKETVER == 20120410 || PACKETVER == 20120418 ) +#define PARTY_RECRUIT +#endif // PACKETVER_RE && (PACKETVER == 20120410 || PACKETVER == 10120418) // Comment the following line to disable sc_data saving. [Skotlex] #define ENABLE_SC_SAVING diff --git a/src/map/packets.h b/src/map/packets.h index 918f0a10f..55a85e182 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2646,4 +2646,8 @@ packet(0x020d,-1); packetKeys(0x7E241DE0,0x5E805580,0x3D807D80); /* Thanks to Shakto */ #endif +#if defined(OBFUSCATIONKEY1) && defined(OBFUSCATIONKEY2) && defined(OBFUSCATIONKEY3) + packetKeys(OBFUSCATIONKEY1,OBFUSCATIONKEY2,OBFUSCATIONKEY3); +#endif + #endif /* _PACKETS_H_ */ -- cgit v1.2.3-70-g09d2 From 7e68906ef18a55cdffcd29730060c108ee9b9bf8 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Tue, 27 Aug 2013 18:29:13 +0200 Subject: Standardized the format of some NPC parse error messages - For better machine-parsing of such messages (i.e. in IDEs) Signed-off-by: Haru <haru@dotalux.com> --- src/map/npc.c | 74 ++++++++++++++++++++++++++++---------------------------- src/map/script.c | 4 +-- 2 files changed, 39 insertions(+), 39 deletions(-) (limited to 'src/map') diff --git a/src/map/npc.c b/src/map/npc.c index 90f588a26..d78b3f8d4 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1944,7 +1944,7 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con if( p ) { // <Display name>::<Unique name> size_t len = p-name; if( len > NAME_LENGTH ) { - ShowWarning("npc_parsename: Display name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH); + ShowWarning("npc_parsename: Display name of '%s' is too long (len=%u) in file '%s', line '%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH); safestrncpy(nd->name, name, sizeof(nd->name)); } else { memcpy(nd->name, name, len); @@ -1952,19 +1952,19 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con } len = strlen(p+2); if( len > NAME_LENGTH ) - ShowWarning("npc_parsename: Unique name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH); + ShowWarning("npc_parsename: Unique name of '%s' is too long (len=%u) in file '%s', line '%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH); safestrncpy(nd->exname, p+2, sizeof(nd->exname)); } else {// <Display name> size_t len = strlen(name); if( len > NAME_LENGTH ) - ShowWarning("npc_parsename: Name '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH); + ShowWarning("npc_parsename: Name '%s' is too long (len=%u) in file '%s', line '%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NAME_LENGTH); safestrncpy(nd->name, name, sizeof(nd->name)); safestrncpy(nd->exname, name, sizeof(nd->exname)); } if( *nd->exname == '\0' || strstr(nd->exname,"::") != NULL ) {// invalid snprintf(newname, ARRAYLENGTH(newname), "0_%d_%d_%d", nd->bl.m, nd->bl.x, nd->bl.y); - ShowWarning("npc_parsename: Invalid unique name in file '%s', line'%d'. Renaming '%s' to '%s'.\n", filepath, strline(buffer,start-buffer), nd->exname, newname); + ShowWarning("npc_parsename: Invalid unique name in file '%s', line '%d'. Renaming '%s' to '%s'.\n", filepath, strline(buffer,start-buffer), nd->exname, newname); safestrncpy(nd->exname, newname, sizeof(nd->exname)); } @@ -1981,7 +1981,7 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con strcpy(this_mapname, (nd->bl.m == -1 ? "(not on a map)" : mapindex_id2name(map_id2index(nd->bl.m)))); strcpy(other_mapname, (dnd->bl.m == -1 ? "(not on a map)" : mapindex_id2name(map_id2index(dnd->bl.m)))); - ShowWarning("npc_parsename: Duplicate unique name in file '%s', line'%d'. Renaming '%s' to '%s'.\n", filepath, strline(buffer,start-buffer), nd->exname, newname); + ShowWarning("npc_parsename: Duplicate unique name in file '%s', line '%d'. Renaming '%s' to '%s'.\n", filepath, strline(buffer,start-buffer), nd->exname, newname); ShowDebug("this npc:\n display name '%s'\n unique name '%s'\n map=%s, x=%d, y=%d\n", nd->name, nd->exname, this_mapname, nd->bl.x, nd->bl.y); ShowDebug("other npc in '%s' :\n display name '%s'\n unique name '%s'\n map=%s, x=%d, y=%d\n",dnd->path, dnd->name, dnd->exname, other_mapname, dnd->bl.x, dnd->bl.y); safestrncpy(nd->exname, newname, sizeof(nd->exname)); @@ -2240,7 +2240,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s } if( type == SHOP && value*0.75 < id->value_sell*1.24 ) {// Exploit possible: you can buy and sell back with profit - ShowWarning("npc_parse_shop: Item %s [%d] discounted buying price (%d->%d) is less than overcharged selling price (%d->%d) at file '%s', line '%d'.\n", + ShowWarning("npc_parse_shop: Item %s [%d] discounted buying price (%d->%d) is less than overcharged selling price (%d->%d) in file '%s', line '%d'.\n", id->name, nameid, value, (int)(value*0.75), id->value_sell, (int)(id->value_sell*1.24), filepath, strline(buffer,start-buffer)); } //for logs filters, atcommands and iteminfo script command @@ -2308,7 +2308,7 @@ void npc_convertlabel_db(struct npc_label_list* label_list, const char *filepath // here we check if the label fit into the buffer if( len > 23 ) { - ShowError("npc_parse_script: label name longer than 23 chars! '%s'\n (%s)", lname, filepath); + ShowError("npc_parse_script: label name longer than 23 chars! (%s) in file '%s'.\n", lname, filepath); return; } @@ -2332,7 +2332,7 @@ const char* npc_skip_script(const char* start, const char* buffer, const char* f p = strchr(start,'{'); if( p == NULL ) { - ShowError("npc_skip_script: Missing left curly in file '%s', line'%d'.", filepath, strline(buffer,start-buffer)); + ShowError("npc_skip_script: Missing left curly in file '%s', line '%d'.\n", filepath, strline(buffer,start-buffer)); return NULL;// can't continue } @@ -2368,7 +2368,7 @@ const char* npc_skip_script(const char* start, const char* buffer, const char* f } else if( *p == '\0' ) {// end of buffer - ShowError("Missing %d right curlys at file '%s', line '%d'.\n", curly_count, filepath, strline(buffer,p-buffer)); + ShowError("Missing %d right curlys in file '%s', line '%d'.\n", curly_count, filepath, strline(buffer,p-buffer)); return NULL;// can't continue } } @@ -2478,7 +2478,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* // Loop through labels to export them as necessary for (i = 0; i < nd->u.scr.label_list_num; i++) { if (npc->event_export(nd, i)) { - ShowWarning("npc_parse_script : duplicate event %s::%s (%s)\n", + ShowWarning("npc_parse_script: duplicate event %s::%s in file '%s'.\n", nd->exname, nd->u.scr.label_list[i].name, filepath); } npc->timerevent_export(nd, i); @@ -2529,14 +2529,14 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch // get the npc being duplicated if( w2[length-1] != ')' || length <= 11 || length-11 >= sizeof(srcname) ) {// does not match 'duplicate(%127s)', name is empty or too long - ShowError("npc_parse_script: bad duplicate name in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), w2); + ShowError("npc_parse_script: bad duplicate name in file '%s', line '%d': %s\n", filepath, strline(buffer,start-buffer), w2); return end;// next line, try to continue } safestrncpy(srcname, w2+10, length-10); dnd = npc->name2id(srcname); if( dnd == NULL) { - ShowError("npc_parse_script: original npc not found for duplicate in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), srcname); + ShowError("npc_parse_script: original npc not found for duplicate in file '%s', line '%d': %s\n", filepath, strline(buffer,start-buffer), srcname); return end;// next line, try to continue } src_id = dnd->bl.id; @@ -2638,7 +2638,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch // Loop through labels to export them as necessary for (i = 0; i < nd->u.scr.label_list_num; i++) { if (npc->event_export(nd, i)) { - ShowWarning("npc_parse_duplicate : duplicate event %s::%s (%s)\n", + ShowWarning("npc_parse_duplicate: duplicate event %s::%s in file '%s'.\n", nd->exname, nd->u.scr.label_list[i].name, filepath); } npc->timerevent_export(nd, i); @@ -2921,7 +2921,7 @@ const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const cha if (func_db->put(func_db, DB->str2key(w3), DB->ptr2data(scriptroot), &old_data)) { struct script_code *oldscript = (struct script_code*)DB->data2ptr(&old_data); - ShowInfo("npc_parse_function: Overwriting user function [%s] (%s:%d)\n", w3, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_function: Overwriting user function [%s] in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); script->free_vars(oldscript->script_vars); aFree(oldscript->script_buf); aFree(oldscript); @@ -2979,33 +2979,33 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st mobspawn.m = (unsigned short)m; if( x < 0 || x >= map->list[mobspawn.m].xs || y < 0 || y >= map->list[mobspawn.m].ys ) { - ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map->list[mobspawn.m].name, x, y, (map->list[mobspawn.m].xs-1), (map->list[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s in file '%s', line '%d'.\n", map->list[mobspawn.m].name, x, y, (map->list[mobspawn.m].xs-1), (map->list[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } // check monster ID if exists! if( mob->db_checkid(class_) == 0 ) { - ShowError("npc_parse_mob: Unknown mob ID %d (file '%s', line '%d').\n", class_, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mob: Unknown mob ID %d in file '%s', line '%d'.\n", class_, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } if( num < 1 || num > 1000 ) { - ShowError("npc_parse_mob: Invalid number of monsters %d, must be inside the range [1,1000] (file '%s', line '%d').\n", num, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mob: Invalid number of monsters %d, must be inside the range [1,1000] in file '%s', line '%d'.\n", num, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } if( (mobspawn.state.size < 0 || mobspawn.state.size > 2) && size != -1 ) { - ShowError("npc_parse_mob: Invalid size number %d for mob ID %d (file '%s', line '%d').\n", mobspawn.state.size, class_, filepath, strline(buffer, start - buffer)); + ShowError("npc_parse_mob: Invalid size number %d for mob ID %d in file '%s', line '%d'.\n", mobspawn.state.size, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } if( (mobspawn.state.ai < 0 || mobspawn.state.ai > 4) && ai != -1 ) { - ShowError("npc_parse_mob: Invalid ai %d for mob ID %d (file '%s', line '%d').\n", mobspawn.state.ai, class_, filepath, strline(buffer, start - buffer)); + ShowError("npc_parse_mob: Invalid ai %d for mob ID %d in file '%s', line '%d'.\n", mobspawn.state.ai, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } if( (mob_lv == 0 || mob_lv > MAX_LEVEL) && mob_lv != -1 ) { - ShowError("npc_parse_mob: Invalid level %d for mob ID %d (file '%s', line '%d').\n", mob_lv, class_, filepath, strline(buffer, start - buffer)); + ShowError("npc_parse_mob: Invalid level %d for mob ID %d in file '%s', line '%d'.\n", mob_lv, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } @@ -3035,7 +3035,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st } if(mobspawn.delay1>0xfffffff || mobspawn.delay2>0xfffffff) { - ShowError("npc_parse_mob: Invalid spawn delays %u %u (file '%s', line '%d').\n", mobspawn.delay1, mobspawn.delay2, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mob: Invalid spawn delays %u %u in file '%s', line '%d'.\n", mobspawn.delay1, mobspawn.delay2, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } @@ -3049,7 +3049,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st //Verify dataset. if( !mob->parse_dataset(&mobspawn) ) { - ShowError("npc_parse_mob: Invalid dataset for monster ID %d (file '%s', line '%d').\n", class_, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mob: Invalid dataset for monster ID %d in file '%s', line '%d'.\n", class_, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } @@ -3143,7 +3143,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char map->list[m].save.x = savex; map->list[m].save.y = savey; if (!map->list[m].save.map) { - ShowWarning("npc_parse_mapflag: Specified save point map '%s' for mapflag 'nosave' not found (file '%s', line '%d'), using 'SavePoint'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", savemap, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); + ShowWarning("npc_parse_mapflag: Specified save point map '%s' for mapflag 'nosave' not found in file '%s', line '%d', using 'SavePoint'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", savemap, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); map->list[m].save.x = -1; map->list[m].save.y = -1; } @@ -3181,11 +3181,11 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char map->list[m].flag.gvg = 0; map->list[m].flag.gvg_dungeon = 0; map->list[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } if( state && map->list[m].flag.battleground ) { map->list[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); @@ -3231,11 +3231,11 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char map->list[m].flag.gvg = state; if( state && map->list[m].flag.pvp ) { map->list[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } if( state && map->list[m].flag.battleground ) { map->list[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); @@ -3263,13 +3263,13 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char if( map->list[m].flag.battleground && map->list[m].flag.pvp ) { map->list[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } if( map->list[m].flag.battleground && (map->list[m].flag.gvg || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg_castle) ) { map->list[m].flag.gvg = 0; map->list[m].flag.gvg_dungeon = 0; map->list[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) && map->list[m].zone != zone ) { @@ -3370,11 +3370,11 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s in file '%s', line '%d'.\n",skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s in file '%s', line '%d'.\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else { int idx = map->list[m].unit_count; @@ -3424,11 +3424,11 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s in file '%s', line '%d'.\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s in file '%s', line '%d'.\n", skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s in file '%s', line '%d'.\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else { int idx = map->list[m].skill_count; @@ -3466,7 +3466,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char struct map_zone_data *zone; if( !(zone = strdb_get(map->zone_db, w4)) ) { - ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, map->list[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s in file '%s', line '%d'.\n", w4, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } @@ -3491,7 +3491,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } else if ( !strcmpi(w3,"nocashshop") ) { map->list[m].flag.nocashshop = (state) ? 1 : 0; } else - ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer)); + ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// continue } diff --git a/src/map/script.c b/src/map/script.c index 944759f39..3b0557235 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1904,9 +1904,9 @@ void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, } if( line >= 0 ) - StrBuf->Printf(buf, "script error on %s line %d\n", file, line); + StrBuf->Printf(buf, "script error in file '%s' line %d\n", file, line); else - StrBuf->Printf(buf, "script error on %s item ID %d\n", file, -line); + StrBuf->Printf(buf, "script error in file '%s' item ID %d\n", file, -line); StrBuf->Printf(buf, " %s\n", error_msg); for(j = 0; j < 5; j++ ) { -- cgit v1.2.3-70-g09d2 From 0a965aafde882e905ea71f3bcef8f4ff81c1c327 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Mon, 4 Nov 2013 21:13:19 -0200 Subject: pc_groups interfaced The last file without a interface is now no more (date.h doesn't count :P). Modified the way permissions are stored in order to enable plugins to be able to create permissions ( pcg->add_permission("name") [returns permission key] ). Special Thanks to Haruna! Closes #121 Signed-off-by: shennetsind <ind@henn.et> --- src/map/atcommand.c | 54 +++++------ src/map/map.c | 2 + src/map/pc.c | 16 ++-- src/map/pc.h | 2 +- src/map/pc_groups.c | 201 +++++++++++++++++++++++++++-------------- src/map/pc_groups.h | 66 +++++++++----- tools/HPMHookGen/HPMHookGen.pl | 3 + 7 files changed, 215 insertions(+), 129 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 758ebb0db..eda7de19a 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -574,7 +574,7 @@ ACMD(who) { case 2: { StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StrBuf->Printf(&buf, msg_txt(344), pc_group_get_name(pl_sd->group)); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) " StrBuf->Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, pc->job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s" break; @@ -584,7 +584,7 @@ ACMD(who) { StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StrBuf->Printf(&buf, msg_txt(344), pc_group_get_name(pl_sd->group)); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) " StrBuf->Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d" break; } @@ -594,7 +594,7 @@ ACMD(who) { StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StrBuf->Printf(&buf, msg_txt(344), pc_group_get_name(pl_sd->group)); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) " if (p != NULL) StrBuf->Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'" if (g != NULL) @@ -3512,7 +3512,7 @@ ACMD(reloadatcommand) { config_destroy(&run_test); atcommand->doload(); - pc_groups_reload(); + pcg->reload(); clif->message(fd, msg_txt(254)); return true; } @@ -8164,11 +8164,11 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand switch( type ) { case COMMAND_CHARCOMMAND: - if( cmd->char_groups[pc_group_get_idx(sd->group)] == 0 ) + if( cmd->char_groups[pcg->get_idx(sd->group)] == 0 ) continue; break; case COMMAND_ATCOMMAND: - if( cmd->at_groups[pc_group_get_idx(sd->group)] == 0 ) + if( cmd->at_groups[pcg->get_idx(sd->group)] == 0 ) continue; break; default: @@ -8377,7 +8377,7 @@ ACMD(reloadquestdb) { return true; } ACMD(addperm) { - int perm_size = ARRAYLENGTH(pc_g_permission_name); + int perm_size = pcg->permission_count; bool add = (strcmpi(command+1, "addperm") == 0) ? true : false; int i; @@ -8386,37 +8386,37 @@ ACMD(addperm) { clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1379)); // -- Permission List for( i = 0; i < perm_size; i++ ) { - sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name); + sprintf(atcmd_output,"- %s",pcg->permissions[i].name); clif->message(fd, atcmd_output); } return false; } - ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0); + ARR_FIND(0, perm_size, i, strcmpi(pcg->permissions[i].name, message) == 0); if( i == perm_size ) { sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission. clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1379)); // -- Permission List for( i = 0; i < perm_size; i++ ) { - sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name); + sprintf(atcmd_output,"- %s",pcg->permissions[i].name); clif->message(fd, atcmd_output); } return false; } - if( add && (sd->extra_temp_permissions&pc_g_permission_name[i].permission) ) { - sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission. + if( add && (sd->extra_temp_permissions&pcg->permissions[i].permission) ) { + sprintf(atcmd_output, msg_txt(1381),sd->status.name,pcg->permissions[i].name); // User '%s' already possesses the '%s' permission. clif->message(fd, atcmd_output); return false; - } else if ( !add && !(sd->extra_temp_permissions&pc_g_permission_name[i].permission) ) { - sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission. + } else if ( !add && !(sd->extra_temp_permissions&pcg->permissions[i].permission) ) { + sprintf(atcmd_output, msg_txt(1382),sd->status.name,pcg->permissions[i].name); // User '%s' doesn't possess the '%s' permission. clif->message(fd, atcmd_output); sprintf(atcmd_output,msg_txt(1383),sd->status.name); // -- User '%s' Permissions clif->message(fd, atcmd_output); for( i = 0; i < perm_size; i++ ) { - if( sd->extra_temp_permissions&pc_g_permission_name[i].permission ) { - sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name); + if( sd->extra_temp_permissions&pcg->permissions[i].permission ) { + sprintf(atcmd_output,"- %s",pcg->permissions[i].name); clif->message(fd, atcmd_output); } } @@ -8425,9 +8425,9 @@ ACMD(addperm) { } if( add ) - sd->extra_temp_permissions |= pc_g_permission_name[i].permission; + sd->extra_temp_permissions |= pcg->permissions[i].permission; else - sd->extra_temp_permissions &=~ pc_g_permission_name[i].permission; + sd->extra_temp_permissions &=~ pcg->permissions[i].permission; sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary. @@ -9663,7 +9663,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if( !pc->get_group_level(sd) ) { if( x >= 1 || y >= 1 ) { /* we have command */ info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); - if( !info || info->char_groups[pc_group_get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ + if( !info || info->char_groups[pcg->get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ return false; } else return false;/* display as normal message */ @@ -9743,8 +9743,8 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message // type == 1 : player invoked if (type == 1) { int i; - if ((*command == atcommand->at_symbol && info->at_groups[pc_group_get_idx(sd->group)] == 0) || - (*command == atcommand->char_symbol && info->char_groups[pc_group_get_idx(sd->group)] == 0) ) { + if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] == 0) || + (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] == 0) ) { return false; } if( pc_isdead(sd) && pc->has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) { @@ -9942,13 +9942,13 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command continue; } - idx = pc_group_get_idx(group); + idx = pcg->get_idx(group); if (idx < 0 || idx >= sz) { ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%d]\n", idx, sz - 1); continue; } - if (pc_group_has_permission(group, PC_PERM_USE_ALL_COMMANDS)) { + if (pcg->has_permission(group, PC_PERM_USE_ALL_COMMANDS)) { atcmd->at_groups[idx] = atcmd->char_groups[idx] = 1; continue; } @@ -9986,8 +9986,8 @@ bool atcommand_can_use(struct map_session_data *sd, const char *command) { if (info == NULL) return false; - if ((*command == atcommand->at_symbol && info->at_groups[pc_group_get_idx(sd->group)] != 0) || - (*command == atcommand->char_symbol && info->char_groups[pc_group_get_idx(sd->group)] != 0) ) { + if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] != 0) || + (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] != 0) ) { return true; } @@ -9999,8 +9999,8 @@ bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtComm if (info == NULL) return false; - if ((type == COMMAND_ATCOMMAND && info->at_groups[pc_group_get_idx(sd->group)] != 0) || - (type == COMMAND_CHARCOMMAND && info->char_groups[pc_group_get_idx(sd->group)] != 0) ) { + if ((type == COMMAND_ATCOMMAND && info->at_groups[pcg->get_idx(sd->group)] != 0) || + (type == COMMAND_CHARCOMMAND && info->char_groups[pcg->get_idx(sd->group)] != 0) ) { return true; } diff --git a/src/map/map.c b/src/map/map.c index 2a2f98bdc..781cc0ff9 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5342,6 +5342,7 @@ void map_hp_symbols(void) { HPM->share(skill,"skill"); HPM->share(vending,"vending"); HPM->share(pc,"pc"); + HPM->share(pcg,"pc_groups"); HPM->share(party,"party"); HPM->share(storage,"storage"); HPM->share(trade,"trade"); @@ -5396,6 +5397,7 @@ void map_load_defaults(void) { skill_defaults(); vending_defaults(); pc_defaults(); + pc_groups_defaults(); party_defaults(); storage_defaults(); trade_defaults(); diff --git a/src/map/pc.c b/src/map/pc.c index 41f4a1a96..1ed66a313 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -72,7 +72,7 @@ struct map_session_data* pc_get_dummy_sd(void) { struct map_session_data *dummy_sd; CREATE(dummy_sd, struct map_session_data, 1); - dummy_sd->group = pc_group_get_dummy_group(); // map_session_data.group is expected to be non-NULL at all times + dummy_sd->group = pcg->get_dummy_group(); // map_session_data.group is expected to be non-NULL at all times return dummy_sd; } @@ -82,7 +82,7 @@ struct map_session_data* pc_get_dummy_sd(void) */ int pc_get_group_level(struct map_session_data *sd) { - return pc_group_get_level(sd->group); + return pcg->get_level(sd->group); } /** @@ -93,7 +93,7 @@ int pc_get_group_level(struct map_session_data *sd) */ int pc_set_group(struct map_session_data *sd, int group_id) { - GroupSettings *group = pc_group_id2group(group_id); + GroupSettings *group = pcg->id2group(group_id); if (group == NULL) return 1; sd->group_id = group_id; @@ -104,9 +104,9 @@ int pc_set_group(struct map_session_data *sd, int group_id) /** * Checks if player has permission to perform action. */ -bool pc_has_permission(struct map_session_data *sd, enum e_pc_permission permission) +bool pc_has_permission(struct map_session_data *sd, unsigned int permission) { - return ((sd->extra_temp_permissions&permission) != 0 || pc_group_has_permission(sd->group, permission)); + return ((sd->extra_temp_permissions&permission) != 0 || pcg->has_permission(sd->group, permission)); } /** @@ -114,7 +114,7 @@ bool pc_has_permission(struct map_session_data *sd, enum e_pc_permission permiss */ bool pc_should_log_commands(struct map_session_data *sd) { - return pc_group_should_log_commands(sd->group); + return pcg->should_log_commands(sd->group); } int pc_invincible_timer(int tid, int64 tick, int id, intptr_t data) { @@ -10203,7 +10203,7 @@ void do_final_pc(void) { db_destroy(pc->itemcd_db); - do_final_pc_groups(); + pcg->final(); ers_destroy(pc->sc_display_ers); return; @@ -10241,7 +10241,7 @@ void do_init_pc(void) { pc->night_timer_tid = timer->add_interval(timer->gettick() + day_duration + (map->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration); } - do_init_pc_groups(); + pcg->init(); pc->sc_display_ers = ers_new(sizeof(struct sc_display_entry), "pc.c:sc_display_ers", ERS_OPT_NONE); } diff --git a/src/map/pc.h b/src/map/pc.h index 8eb7e692a..05e8ba7b4 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -751,7 +751,7 @@ struct pc_interface { bool (*can_give_items) (struct map_session_data *sd); bool (*can_use_command) (struct map_session_data *sd, const char *command); - bool (*has_permission) (struct map_session_data *sd, enum e_pc_permission permission); + bool (*has_permission) (struct map_session_data *sd, unsigned int permission); int (*set_group) (struct map_session_data *sd, int group_id); bool (*should_log_commands) (struct map_session_data *sd); diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index be02b5f15..78d111b1c 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -16,52 +16,10 @@ #include "map.h" // mapiterator #include "pc.h" // pc->set_group() -// Cached config settings for quick lookup -struct GroupSettings { - unsigned int id; // groups.[].id - int level; // groups.[].level - char *name; // copy of groups.[].name - unsigned int e_permissions; // packed groups.[].permissions - bool log_commands; // groups.[].log_commands - int index; // internal index of the group (contiguous range starting at 0) [Ind] - /// Following are used/available only during config reading - config_setting_t *commands; // groups.[].commands - config_setting_t *permissions; // groups.[].permissions - config_setting_t *inherit; // groups.[].inherit - bool inheritance_done; // have all inheritance rules been evaluated? - config_setting_t *root; // groups.[] -}; - -const struct pc_permission_name_table pc_g_permission_name[NUM_PC_PERM] = { - { "can_trade", PC_PERM_TRADE }, - { "can_party", PC_PERM_PARTY }, - { "all_skill", PC_PERM_ALL_SKILL }, - { "all_equipment", PC_PERM_USE_ALL_EQUIPMENT }, - { "skill_unconditional", PC_PERM_SKILL_UNCONDITIONAL }, - { "join_chat", PC_PERM_JOIN_ALL_CHAT }, - { "kick_chat", PC_PERM_NO_CHAT_KICK }, - { "hide_session", PC_PERM_HIDE_SESSION }, - { "who_display_aid", PC_PERM_WHO_DISPLAY_AID }, - { "hack_info", PC_PERM_RECEIVE_HACK_INFO }, - { "any_warp", PC_PERM_WARP_ANYWHERE }, - { "view_hpmeter", PC_PERM_VIEW_HPMETER }, - { "view_equipment", PC_PERM_VIEW_EQUIPMENT }, - { "use_check", PC_PERM_USE_CHECK }, - { "use_changemaptype", PC_PERM_USE_CHANGEMAPTYPE }, - { "all_commands", PC_PERM_USE_ALL_COMMANDS }, - { "receive_requests", PC_PERM_RECEIVE_REQUESTS }, - { "show_bossmobs", PC_PERM_SHOW_BOSS }, - { "disable_pvm", PC_PERM_DISABLE_PVM }, - { "disable_pvp", PC_PERM_DISABLE_PVP }, - { "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD }, - { "hchsys_admin", PC_PERM_HCHSYS_ADMIN }, -}; - -static DBMap* pc_group_db; // id -> GroupSettings -static DBMap* pc_groupname_db; // name -> GroupSettings - static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() +struct pc_groups_interface pcg_s; + /** * Returns dummy group. * Used in dummy map sessions. @@ -78,7 +36,7 @@ GroupSettings* pc_group_get_dummy_group(void) */ static inline GroupSettings* name2group(const char* group_name) { - return strdb_get(pc_groupname_db, group_name); + return strdb_get(pcg->name_db, group_name); } /** @@ -116,7 +74,7 @@ static void read_config(void) { continue; } - if (pc_group_exists(id)) { + if (pcg->exists(id)) { ShowConfigWarning(group, "pc_groups:read_config: duplicate group id %d, removing...", i); config_setting_remove_elem(groups, i); --i; @@ -162,15 +120,15 @@ static void read_config(void) { group_settings->root = group; group_settings->index = i; - strdb_put(pc_groupname_db, groupname, group_settings); - idb_put(pc_group_db, id, group_settings); + strdb_put(pcg->name_db, groupname, group_settings); + idb_put(pcg->db, id, group_settings); } group_count = config_setting_length(groups); // Save number of groups - assert(group_count == db_size(pc_group_db)); + assert(group_count == db_size(pcg->db)); // Check if all commands and permissions exist - iter = db_iterator(pc_group_db); + iter = db_iterator(pcg->db); for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions; int count = 0, i; @@ -201,8 +159,8 @@ static void read_config(void) { const char *name = config_setting_name(permission); int j; - ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), j, strcmp(pc_g_permission_name[j].name, name) == 0); - if (j == ARRAYLENGTH(pc_g_permission_name)) { + ARR_FIND(0, pcg->permission_count, j, strcmp(pcg->permissions[j].name, name) == 0); + if (j == pcg->permission_count) { ShowConfigWarning(permission, "pc_groups:read_config: non-existent permission name '%s', removing...", name); config_setting_remove(permissions, name); --i; @@ -215,7 +173,7 @@ static void read_config(void) { // Apply inheritance i = 0; // counter for processed groups while (i < group_count) { - iter = db_iterator(pc_group_db); + iter = db_iterator(pcg->db); for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { config_setting_t *inherit = NULL, *commands = group_settings->commands, @@ -280,7 +238,7 @@ static void read_config(void) { } // while(i < group_count) // Pack permissions into GroupSettings.e_permissions for faster checking - iter = db_iterator(pc_group_db); + iter = db_iterator(pcg->db); for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { config_setting_t *permissions = group_settings->permissions; int i, count = config_setting_length(permissions); @@ -293,8 +251,8 @@ static void read_config(void) { if (val == 0) // does not have this permission continue; - ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), j, strcmp(pc_g_permission_name[j].name, name) == 0); - group_settings->e_permissions |= pc_g_permission_name[j].permission; + ARR_FIND(0, pcg->permission_count, j, strcmp(pcg->permissions[j].name, name) == 0); + group_settings->e_permissions |= pcg->permissions[j].permission; } } dbi_destroy(iter); @@ -308,7 +266,7 @@ static void read_config(void) { config_setting_t **commands = NULL; CREATE(groups, GroupSettings*, group_count); CREATE(commands, config_setting_t*, group_count); - iter = db_iterator(pc_group_db); + iter = db_iterator(pcg->db); for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { groups[i] = group_settings; commands[i] = group_settings->commands; @@ -332,7 +290,7 @@ static void read_config(void) { * @param group group * @param permission permission to check */ -bool pc_group_has_permission(GroupSettings *group, enum e_pc_permission permission) +bool pc_group_has_permission(GroupSettings *group, unsigned int permission) { return ((group->e_permissions&permission) != 0); } @@ -353,7 +311,7 @@ bool pc_group_should_log_commands(GroupSettings *group) */ bool pc_group_exists(int group_id) { - return idb_exists(pc_group_db, group_id); + return idb_exists(pcg->db, group_id); } /** @@ -361,7 +319,7 @@ bool pc_group_exists(int group_id) */ GroupSettings* pc_group_id2group(int group_id) { - return idb_get(pc_group_db, group_id); + return idb_get(pcg->db, group_id); } /** @@ -397,14 +355,80 @@ int pc_group_get_idx(GroupSettings *group) return group->index; } +/** + * Insert a new permission + * @return inserted key or 0 upon failure. + **/ +unsigned int pc_groups_add_permission(const char *name) { + uint64 key = 0x1; + unsigned char i; + + for(i = 0; i < pcg->permission_count; i++) { + if( strcmpi(name,pcg->permissions[i].name) == 0 ) { + ShowError("pc_groups_add_permission(%s): failed! duplicate permission name!\n",name); + return 0; + } + } + + if( i != 0 ) + key = (uint64)pcg->permissions[i - 1].permission << 1; + + if( key >= UINT_MAX ) { + ShowError("pc_groups_add_permission(%s): failed! not enough room, too many permissions!\n",name); + return 0; + } + + i = pcg->permission_count; + RECREATE(pcg->permissions, struct pc_groups_permission_table, ++pcg->permission_count); + + pcg->permissions[i].name = aStrdup(name); + pcg->permissions[i].permission = (unsigned int)key; + + return (unsigned int)key; +} /** * Initialize PC Groups: allocate DBMaps and read config. * @public */ -void do_init_pc_groups(void) -{ - pc_group_db = idb_alloc(DB_OPT_RELEASE_DATA); - pc_groupname_db = stridb_alloc(DB_OPT_DUP_KEY, 0); +void do_init_pc_groups(void) { + const struct { + const char *name; + unsigned int permission; + } pc_g_defaults[] = { + { "can_trade", PC_PERM_TRADE }, + { "can_party", PC_PERM_PARTY }, + { "all_skill", PC_PERM_ALL_SKILL }, + { "all_equipment", PC_PERM_USE_ALL_EQUIPMENT }, + { "skill_unconditional", PC_PERM_SKILL_UNCONDITIONAL }, + { "join_chat", PC_PERM_JOIN_ALL_CHAT }, + { "kick_chat", PC_PERM_NO_CHAT_KICK }, + { "hide_session", PC_PERM_HIDE_SESSION }, + { "who_display_aid", PC_PERM_WHO_DISPLAY_AID }, + { "hack_info", PC_PERM_RECEIVE_HACK_INFO }, + { "any_warp", PC_PERM_WARP_ANYWHERE }, + { "view_hpmeter", PC_PERM_VIEW_HPMETER }, + { "view_equipment", PC_PERM_VIEW_EQUIPMENT }, + { "use_check", PC_PERM_USE_CHECK }, + { "use_changemaptype", PC_PERM_USE_CHANGEMAPTYPE }, + { "all_commands", PC_PERM_USE_ALL_COMMANDS }, + { "receive_requests", PC_PERM_RECEIVE_REQUESTS }, + { "show_bossmobs", PC_PERM_SHOW_BOSS }, + { "disable_pvm", PC_PERM_DISABLE_PVM }, + { "disable_pvp", PC_PERM_DISABLE_PVP }, + { "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD }, + { "hchsys_admin", PC_PERM_HCHSYS_ADMIN }, + }; + unsigned char i, len = ARRAYLENGTH(pc_g_defaults); + + for(i = 0; i < len; i++) { + unsigned int p; + if( ( p = pcg->add_permission(pc_g_defaults[i].name) ) != pc_g_defaults[i].permission ) + ShowError("do_init_pc_groups: %s error : %d != %d\n",pc_g_defaults[i].name,p,pc_g_defaults[i].permission); + } + + pcg->db = idb_alloc(DB_OPT_RELEASE_DATA); + pcg->name_db = stridb_alloc(DB_OPT_DUP_KEY, 0); + read_config(); } @@ -425,10 +449,19 @@ static int group_db_clear_sub(DBKey key, DBData *data, va_list args) */ void do_final_pc_groups(void) { - if (pc_group_db != NULL) - pc_group_db->destroy(pc_group_db, group_db_clear_sub); - if (pc_groupname_db != NULL) - db_destroy(pc_groupname_db); + if (pcg->db != NULL) + pcg->db->destroy(pcg->db, group_db_clear_sub); + if (pcg->name_db != NULL) + db_destroy(pcg->name_db); + + if(pcg->permissions != NULL) { + unsigned char i; + for(i = 0; i < pcg->permission_count; i++) + aFree(pcg->permissions[i].name); + aFree(pcg->permissions); + pcg->permissions = NULL; + } + pcg->permission_count = 0; } /** @@ -440,8 +473,8 @@ void pc_groups_reload(void) { struct map_session_data *sd = NULL; struct s_mapiterator *iter; - do_final_pc_groups(); - do_init_pc_groups(); + pcg->final(); + pcg->init(); /* refresh online users permissions */ iter = mapit_getallusers(); @@ -454,3 +487,31 @@ void pc_groups_reload(void) { } mapit->free(iter); } + +/** + * Connect Interface + **/ +void pc_groups_defaults(void) { + pcg = &pcg_s; + + /* */ + pcg->db = NULL; + pcg->name_db = NULL; + /* */ + pcg->permissions = NULL; + pcg->permission_count = 0; + /* */ + pcg->init = do_init_pc_groups; + pcg->final = do_final_pc_groups; + pcg->reload = pc_groups_reload; + /* */ + pcg->get_dummy_group = pc_group_get_dummy_group; + pcg->exists = pc_group_exists; + pcg->id2group = pc_group_id2group; + pcg->has_permission = pc_group_has_permission; + pcg->should_log_commands = pc_group_should_log_commands; + pcg->get_name = pc_group_get_name; + pcg->get_level = pc_group_get_level; + pcg->get_idx = pc_group_get_idx; + pcg->add_permission = pc_groups_add_permission; +} diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 8f350c2b6..28c82d619 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -32,34 +32,54 @@ enum e_pc_permission { PC_PERM_HCHSYS_ADMIN = 0x200000, }; -/// Total number of PC permissions (without PC_PERM_NONE). -/// This is manifest constant for the size of pc_g_permission_name array, -/// so it's possible to apply sizeof to it [C-FAQ 1.24] -/// Whenever adding new permission: 1. add enum entry above, 2. add entry into -/// pc_g_permission_name (in pc.c), 3. increase NUM_PC_PERM below by 1. -#define NUM_PC_PERM 22 - -struct pc_permission_name_table { - const char *name; - enum e_pc_permission permission; +// Cached config settings for quick lookup +struct GroupSettings { + unsigned int id; // groups.[].id + int level; // groups.[].level + char *name; // copy of groups.[].name + unsigned int e_permissions; // packed groups.[].permissions + bool log_commands; // groups.[].log_commands + int index; // internal index of the group (contiguous range starting at 0) [Ind] + /// Following are used/available only during config reading + config_setting_t *commands; // groups.[].commands + config_setting_t *permissions; // groups.[].permissions + config_setting_t *inherit; // groups.[].inherit + bool inheritance_done; // have all inheritance rules been evaluated? + config_setting_t *root; // groups.[] }; -/// Name <-> enum table for PC permissions -extern const struct pc_permission_name_table pc_g_permission_name[NUM_PC_PERM]; +struct pc_groups_permission_table { + char *name; + unsigned int permission; +}; typedef struct GroupSettings GroupSettings; -GroupSettings* pc_group_get_dummy_group(void); -bool pc_group_exists(int group_id); -GroupSettings* pc_group_id2group(int group_id); -bool pc_group_has_permission(GroupSettings *group, enum e_pc_permission permission); -bool pc_group_should_log_commands(GroupSettings *group); -const char* pc_group_get_name(GroupSettings *group); -int pc_group_get_level(GroupSettings *group); -int pc_group_get_idx(GroupSettings *group); +struct pc_groups_interface { + /* */ + DBMap* db; // id -> GroupSettings + DBMap* name_db; // name -> GroupSettings + /* */ + struct pc_groups_permission_table *permissions; + unsigned char permission_count; + /* */ + void (*init) (void); + void (*final) (void); + void (*reload) (void); + /* */ + GroupSettings* (*get_dummy_group) (void); + bool (*exists) (int group_id); + GroupSettings* (*id2group) (int group_id); + bool (*has_permission) (GroupSettings *group, unsigned int permission); + bool (*should_log_commands) (GroupSettings *group); + const char* (*get_name) (GroupSettings *group); + int (*get_level) (GroupSettings *group); + int (*get_idx) (GroupSettings *group); + unsigned int (*add_permission) (const char *name); +}; + +struct pc_groups_interface *pcg; -void do_init_pc_groups(void); -void do_final_pc_groups(void); -void pc_groups_reload(void); +void pc_groups_defaults(void); #endif // _PC_GROUPS_H_ diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl index cf50a9e77..eef490e29 100755 --- a/tools/HPMHookGen/HPMHookGen.pl +++ b/tools/HPMHookGen/HPMHookGen.pl @@ -265,6 +265,8 @@ foreach my $file (@files) { # Loop through the xml files $key = "ircbot"; } elsif ($key =~ /log_interface/) { $key = "logs"; + } elsif ($key =~ /pc_groups_interface/) { + $key = "pcg"; } else { $key =~ s/_interface//; } @@ -367,6 +369,7 @@ foreach my $file (@files) { # Loop through the xml files my %exportsymbols = map { $_ => &{ sub ($) { return 'battlegrounds' if $_ =~ /^bg$/; + return 'pc_groups' if $_ =~ /^pcg$/; return $_; }}($_); } @keys; -- cgit v1.2.3-70-g09d2 From 97001710c06ed7053d18c8baaac602eb563b64b3 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Tue, 27 Aug 2013 08:08:34 +0200 Subject: Introducing the Hercules Standalone Script Syntax Checker - Added a command line argument '--script-check' to check a script's syntax without running the server (and without requiring a SQL connection). Usage: ./map-server --script-check /path/to/the/script.txt - For convenience, a script-checker bash script is provided, to set the path correctly when called from a different directory. Usage: /path/to/Hercules/script-checker /path/to/the/script/to/check.txt - While the script checker will supposedly work under windows as well, no convenience scripts are currently provided for platforms other than UNIX (feel free to open a pull request with a .bat launcher or whatever you like) - Integration with IDEs or text editors is possible. In fact, I already have a fully functional plugin for vim (through vim-syntastic), and if there's enough interest, I'll publish it. - screenshot: http://d.pr/i/NOBD - If you want an online checker, http://haru.ws/scriptchecker/ is running this code, without modifications and will be kept up to date (without any warranty though.) - Special thanks to Ind, Yommy, Streusel, who helped making this possible, in a way or another. --- script-checker | 18 ++++++ src/common/core.c | 14 ++++- src/common/mapindex.c | 17 +++-- src/common/mapindex.h | 3 +- src/map/atcommand.c | 5 +- src/map/atcommand.h | 2 +- src/map/battle.c | 5 +- src/map/battle.h | 2 +- src/map/battleground.c | 5 +- src/map/battleground.h | 2 +- src/map/chrif.c | 6 +- src/map/chrif.h | 2 +- src/map/clif.c | 5 +- src/map/clif.h | 2 +- src/map/duel.c | 5 +- src/map/duel.h | 2 +- src/map/elemental.c | 5 +- src/map/elemental.h | 2 +- src/map/guild.c | 15 +++-- src/map/guild.h | 2 +- src/map/homunculus.c | 6 +- src/map/homunculus.h | 2 +- src/map/instance.c | 5 +- src/map/instance.h | 2 +- src/map/irc-bot.c | 5 +- src/map/irc-bot.h | 2 +- src/map/itemdb.c | 15 +++-- src/map/itemdb.h | 4 +- src/map/map.c | 168 +++++++++++++++++++++++++++++-------------------- src/map/map.h | 2 +- src/map/mercenary.c | 5 +- src/map/mercenary.h | 2 +- src/map/mob.c | 20 ++++-- src/map/mob.h | 4 +- src/map/npc.c | 69 ++++++++++---------- src/map/npc.h | 4 +- src/map/party.c | 5 +- src/map/party.h | 2 +- src/map/pc.c | 4 +- src/map/pc.h | 2 +- src/map/pet.c | 6 +- src/map/pet.h | 2 +- src/map/quest.c | 5 +- src/map/quest.h | 2 +- src/map/script.c | 72 +++++++++++++++------ src/map/script.h | 2 +- src/map/skill.c | 15 +++-- src/map/skill.h | 4 +- src/map/status.c | 5 +- src/map/status.h | 2 +- src/map/storage.c | 4 +- src/map/storage.h | 2 +- src/map/unit.c | 5 +- src/map/unit.h | 2 +- src/map/vending.c | 2 +- src/map/vending.h | 2 +- 56 files changed, 382 insertions(+), 197 deletions(-) create mode 100755 script-checker (limited to 'src/map') diff --git a/script-checker b/script-checker new file mode 100755 index 000000000..ec79fcc61 --- /dev/null +++ b/script-checker @@ -0,0 +1,18 @@ +#!/bin/bash + +ORIG_CWD="$(pwd)" +BASEDIR="$(dirname "$0")" +EXECUTABLE="./map-server" + +cd "${BASEDIR}" +if [ -z "$1" ]; then + exit -1 +elif [[ "$1" =~ ^\/ ]]; then + FILE="$1" +else + FILE="${ORIG_CWD}/$1" +fi +if [ ! -x "$EXECUTABLE" ]; then + exit -1 +fi +"$EXECUTABLE" --script-check "${FILE}" 2>&1 diff --git a/src/common/core.c b/src/common/core.c index 6a73d2d39..f57cc4c79 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -302,10 +302,20 @@ int main (int argc, char **argv) { arg_v = argv; } core_defaults(); + + { + int i; + for(i = 0; i < argc; i++) { + if( strcmp(argv[i], "--script-check") == 0 ) { + msg_silent = 0x7; // silence information and status messages + } + } + } iMalloc->init();// needed for Show* in display_title() [FlavioJS] - - console->display_title(); + + if (!(msg_silent&0x1)) + console->display_title(); #ifdef MINICORE // minimalist Core usercheck(); diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 83de21b2b..a95e143c3 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -21,7 +21,12 @@ int max_index = 0; char mapindex_cfgfile[80] = "db/map_index.txt"; -#define mapindex_exists(id) (indexes[id].name[0] != '\0') +#define mapindex_exists_sub(id) (indexes[id].name[0] != '\0') + +bool mapindex_exists(int id) { + return mapindex_exists_sub(id); +} + /// Retrieves the map name from 'string' (removing .gat extension if present). /// Result gets placed either into 'buf' or in a static local buffer. const char* mapindex_getmapname(const char* string, char* output) { @@ -102,7 +107,7 @@ int mapindex_addmap(int index, const char* name) { return 0; } - if (mapindex_exists(index)) { + if (mapindex_exists_sub(index)) { ShowWarning("(mapindex_add) Overriding index %d: map \"%s\" -> \"%s\"\n", index, indexes[index].name, map_name); strdb_remove(mapindex_db, indexes[index].name); } @@ -129,18 +134,18 @@ unsigned short mapindex_name2id(const char* name) { } const char* mapindex_id2name_sub(unsigned short id,const char *file, int line, const char *func) { - if (id > MAX_MAPINDEX || !mapindex_exists(id)) { + if (id > MAX_MAPINDEX || !mapindex_exists_sub(id)) { ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line); return indexes[0].name; // dummy empty string so that the callee doesn't crash } return indexes[id].name; } -void mapindex_init(void) { +int mapindex_init(void) { FILE *fp; char line[1024]; int last_index = -1; - int index; + int index, total = 0; char map_name[12]; if( ( fp = fopen(mapindex_cfgfile,"r") ) == NULL ){ @@ -158,6 +163,7 @@ void mapindex_init(void) { index = last_index+1; case 2: //Map with ID given mapindex_addmap(index,map_name); + total++; break; default: continue; @@ -169,6 +175,7 @@ void mapindex_init(void) { if( !strdb_iget(mapindex_db, MAP_DEFAULT) ) { ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n",MAP_DEFAULT); } + return total; } int mapindex_removemap(int index){ diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 43953a8e0..646f73f18 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -56,12 +56,13 @@ extern char mapindex_cfgfile[80]; #define MAP_MALAYA "malaya" #define MAP_ECLAGE "eclage" +bool mapindex_exists(int id); const char* mapindex_getmapname(const char* string, char* output); const char* mapindex_getmapname_ext(const char* string, char* output); unsigned short mapindex_name2id(const char*); #define mapindex_id2name(n) mapindex_id2name_sub(n,__FILE__, __LINE__, __func__) const char* mapindex_id2name_sub(unsigned short,const char *file, int line, const char *func); -void mapindex_init(void); +int mapindex_init(void); void mapindex_final(void); int mapindex_addmap(int index, const char* name); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0ba977ff4..b11a4f4c0 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -10149,7 +10149,10 @@ void atcommand_doload(void) { atcommand->config_read(map->ATCOMMAND_CONF_FILENAME); } -void do_init_atcommand(void) { +void do_init_atcommand(bool minimal) { + if (minimal) + return; + atcommand->at_symbol = '@'; atcommand->char_symbol = '#'; atcommand->binding_count = 0; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 63c38e4d1..74ab30bed 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -77,7 +77,7 @@ struct atcommand_interface { /* */ char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ bool (*parse) (const int fd, struct map_session_data* sd, const char* message, int type); diff --git a/src/map/battle.c b/src/map/battle.c index 94222f663..c090c5623 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6759,7 +6759,10 @@ int battle_config_read(const char* cfgName) return 0; } -void do_init_battle(void) { +void do_init_battle(bool minimal) { + if (minimal) + return; + battle->delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); timer->add_func_list(battle->delay_damage_sub, "battle_delay_damage_sub"); diff --git a/src/map/battle.h b/src/map/battle.h index bf08ab8d6..0f3a22c4b 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -506,7 +506,7 @@ struct battle_interface { int attr_fix_table[4][ELE_MAX][ELE_MAX]; struct eri *delay_damage_ers; //For battle delay damage structures. /* init */ - void (*init) (void); + void (*init) (bool minimal); /* final */ void (*final) (void); /* damage calculation */ diff --git a/src/map/battleground.c b/src/map/battleground.c index 62688659e..76cf22471 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -757,7 +757,10 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ return BGQA_SUCCESS; } -void do_init_battleground(void) { +void do_init_battleground(bool minimal) { + if (minimal) + return; + bg->team_db = idb_alloc(DB_OPT_RELEASE_DATA); timer->add_func_list(bg->send_xy_timer, "bg_send_xy_timer"); timer->add_interval(timer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); diff --git a/src/map/battleground.h b/src/map/battleground.h index a5e540924..fab614d08 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -75,7 +75,7 @@ struct battleground_interface { DBMap *team_db; // int bg_id -> struct battleground_data* unsigned int team_counter; // Next bg_id /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ struct bg_arena *(*name2arena) (char *name); diff --git a/src/map/chrif.c b/src/map/chrif.c index a13217060..87ec71ec5 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1611,8 +1611,10 @@ int do_final_chrif(void) { /*========================================== * *------------------------------------------*/ -int do_init_chrif(void) { - +int do_init_chrif(bool minimal) { + if (minimal) + return 0; + chrif->auth_db = idb_alloc(DB_OPT_BASE); chrif->auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE); diff --git a/src/map/chrif.h b/src/map/chrif.h index 9df4b9931..56aa569a3 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -63,7 +63,7 @@ struct chrif_interface { int state; /* */ int (*final) (void); - int (*init) (void); + int (*init) (bool minimal); /* funcs */ void (*setuserid) (char* id); void (*setpasswd) (char* pwd); diff --git a/src/map/clif.c b/src/map/clif.c index c1e7cb1c9..5f88557fd 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18046,10 +18046,13 @@ void clif_bc_ready(void) { /*========================================== * *------------------------------------------*/ -int do_init_clif(void) { +int do_init_clif(bool minimal) { const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" }; int i; + if (minimal) + return 0; + /** * Setup Color Table (saves unnecessary load of strtoul on every call) **/ diff --git a/src/map/clif.h b/src/map/clif.h index cbe3fa857..1710cfc88 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -526,7 +526,7 @@ struct clif_interface { /* */ bool ally_only; /* core */ - int (*init) (void); + int (*init) (bool minimal); void (*final) (void); int (*setip) (const char* ip); void (*setbindip) (const char* ip); diff --git a/src/map/duel.c b/src/map/duel.c index 4e41865d4..5e305244a 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -166,7 +166,10 @@ void duel_reject(const unsigned int did, struct map_session_data* sd) { void do_final_duel(void) { } -void do_init_duel(void) { +void do_init_duel(bool minimal) { + if (minimal) + return; + memset(&duel->list[0], 0, sizeof(duel->list)); } diff --git a/src/map/duel.h b/src/map/duel.h index d1ec58415..d60c9531a 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -34,7 +34,7 @@ struct duel_interface { void (*showinfo) (const unsigned int did, struct map_session_data* sd); int (*checktime) (struct map_session_data* sd); - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); } duel_s; diff --git a/src/map/elemental.c b/src/map/elemental.c index f15b735b2..2581d1839 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -931,7 +931,10 @@ void reload_elemental_skilldb(void) { elemental->read_skilldb(); } -int do_init_elemental(void) { +int do_init_elemental(bool minimal) { + if (minimal) + return 0; + elemental->read_db(); elemental->read_skilldb(); diff --git a/src/map/elemental.h b/src/map/elemental.h index 3cd819d53..8ffffa5e3 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -73,7 +73,7 @@ struct elemental_interface { struct s_elemental_db db[MAX_ELEMENTAL_CLASS]; // Elemental Database /* */ - int (*init) (void); + int (*init) (bool minimal); void (*final) (void); /* funcs */ bool (*class) (int class_); diff --git a/src/map/guild.c b/src/map/guild.c index 0ae45bede..908c38341 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2172,12 +2172,15 @@ void guild_flags_clear(void) { guild->flags_count = 0; } -void do_init_guild(void) { - guild->db = idb_alloc(DB_OPT_RELEASE_DATA); - guild->castle_db = idb_alloc(DB_OPT_BASE); - guild->expcache_db = idb_alloc(DB_OPT_BASE); - guild->infoevent_db = idb_alloc(DB_OPT_BASE); - guild->expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE); +void do_init_guild(bool minimal) { + if (minimal) + return; + + guild->db = idb_alloc(DB_OPT_RELEASE_DATA); + guild->castle_db = idb_alloc(DB_OPT_BASE); + guild->expcache_db = idb_alloc(DB_OPT_BASE); + guild->infoevent_db = idb_alloc(DB_OPT_BASE); + guild->expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.c::expcache_ers",ERS_OPT_NONE); sv->readdb(map->db_path, "castle_db.txt", ',', 4, 5, -1, guild->read_castledb); diff --git a/src/map/guild.h b/src/map/guild.h index 348a6c7e4..8da9036e6 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -56,7 +56,7 @@ struct s_guild_skill_tree { struct guild_interface { - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ DBMap* db; // int guild_id -> struct guild* diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 52f0572c0..cb54d2d8b 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1229,8 +1229,12 @@ void homunculus_skill_reload(void) { homun->skill_db_read(); } -void do_init_homunculus(void) { +void do_init_homunculus(bool minimal) { int class_; + + if (minimal) + return; + homun->read_db(); homun->exp_db_read(); homun->skill_db_read(); diff --git a/src/map/homunculus.h b/src/map/homunculus.h index e3ec38f7b..bf1de6171 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -91,7 +91,7 @@ struct homunculus_interface { struct s_homunculus_db db[MAX_HOMUNCULUS_CLASS]; struct homun_skill_tree_entry skill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE]; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); void (*reload) (void); void (*reload_skill) (void); diff --git a/src/map/instance.c b/src/map/instance.c index 6b96c3112..ab68c9e22 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -691,7 +691,10 @@ void do_final_instance(void) { instance->instances = 0; } -void do_init_instance(void) { +void do_init_instance(bool minimal) { + if (minimal) + return; + timer->add_func_list(instance->destroy_timer, "instance_destroy_timer"); } diff --git a/src/map/instance.h b/src/map/instance.h index 27a9401b4..4f65d7db0 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -47,7 +47,7 @@ struct instance_data { }; struct instance_interface { - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); void (*reload) (void); /* start point */ diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index f67446629..0f487d8f7 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -386,7 +386,7 @@ void irc_relay(char *name, const char *msg) { /** * IRC bot initializer */ -void irc_bot_init(void) { +void irc_bot_init(bool minimal) { /// Command handlers const struct irc_func irc_func_base[] = { { "PING" , ircbot->pong }, @@ -399,6 +399,9 @@ void irc_bot_init(void) { struct irc_func* function; int i; + if (minimal) + return; + if( !hChSys.irc ) return; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 52ff0c9be..305cdfd91 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -34,7 +34,7 @@ struct irc_bot_interface { unsigned int size; } funcs; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ int (*parse) (int fd); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3fc8d526b..e29b74cd4 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1927,7 +1927,7 @@ int itemdb_uid_load() { /*==================================== * read all item-related databases *------------------------------------*/ -void itemdb_read(void) { +void itemdb_read(bool minimal) { int i; DBData prev; @@ -1945,6 +1945,9 @@ void itemdb_read(void) { } } + if (minimal) + return; + itemdb->read_combos(); itemdb->read_groups(); itemdb->read_chains(); @@ -2065,7 +2068,7 @@ void itemdb_reload(void) { db_clear(itemdb->names); // read new data - itemdb->read(); + itemdb->read(false); //Epoque's awesome @reloaditemdb fix - thanks! [Ind] //- Fixes the need of a @reloadmobdb after a @reloaditemdb to re-link monster drop data @@ -2174,12 +2177,16 @@ void do_final_itemdb(void) { db_destroy(itemdb->names); } -void do_init_itemdb(void) { +void do_init_itemdb(bool minimal) { memset(itemdb->array, 0, sizeof(itemdb->array)); itemdb->other = idb_alloc(DB_OPT_BASE); itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH); itemdb->create_dummy_data(); //Dummy data item. - itemdb->read(); + itemdb->read(minimal); + + if (minimal) + return; + clif->cashshop_load(); } void itemdb_defaults(void) { diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 2579d84ca..80d2fd0ce 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -266,7 +266,7 @@ struct item_package { #define itemdb_canauction(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canauction_sub) struct itemdb_interface { - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); void (*reload) (void); void (*name_constants) (void); @@ -343,7 +343,7 @@ struct itemdb_interface { int (*read_sqldb) (void); uint64 (*unique_id) (int8 flag, int64 value); int (*uid_load) (); - void (*read) (void); + void (*read) (bool minimal); void (*destroy_item_data) (struct item_data *self, int free_self); int (*final_sub) (DBKey key, DBData *data, va_list ap); }; diff --git a/src/map/map.c b/src/map/map.c index 781cc0ff9..cd192b7d4 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2905,7 +2905,7 @@ int map_readfromcache(struct map_data *m, char *buffer) { } -int map_addmap(char* mapname) { +int map_addmap(const char* mapname) { map->list[map->count].instance_id = -1; mapindex_getmapname(mapname, map->list[map->count++].name); return 0; @@ -5419,6 +5419,8 @@ void map_load_defaults(void) { } int do_init(int argc, char *argv[]) { + bool minimal = false; + char *scriptcheck = NULL; int i; #ifdef GCOLLECT @@ -5468,6 +5470,11 @@ int do_init(int argc, char *argv[]) map->LOG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "run-once") == 0 ) { // close the map-server as soon as its done.. for testing [Celest] runflag = CORE_ST_STOP; + } else if( strcmp(arg, "script-check") == 0 ) { + minimal = true; + runflag = CORE_ST_STOP; + if( map->arg_next_value(arg, i, argc) ) + scriptcheck = argv[++i]; } else { ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); @@ -5489,39 +5496,42 @@ int do_init(int argc, char *argv[]) } map_load_defaults(); - map->config_read(map->MAP_CONF_NAME); - CREATE(map->list,struct map_data,map->count); - map->count = 0; - map->config_read_sub(map->MAP_CONF_NAME); - // loads npcs - map->reloadnpc(false); + if (!minimal) { + map->config_read(map->MAP_CONF_NAME); + CREATE(map->list,struct map_data,map->count); + map->count = 0; + map->config_read_sub(map->MAP_CONF_NAME); - chrif->checkdefaultlogin(); + // loads npcs + map->reloadnpc(false); - if (!map->ip_set || !map->char_ip_set) { - char ip_str[16]; - ip2str(addr_[0], ip_str); + chrif->checkdefaultlogin(); - ShowWarning("Not all IP addresses in /conf/map-server.conf configured, autodetecting...\n"); + if (!map->ip_set || !map->char_ip_set) { + char ip_str[16]; + ip2str(addr_[0], ip_str); - if (naddr_ == 0) - ShowError("Unable to determine your IP address...\n"); - else if (naddr_ > 1) - ShowNotice("Multiple interfaces detected...\n"); + ShowWarning("Not all IP addresses in /conf/map-server.conf configured, autodetecting...\n"); - ShowInfo("Defaulting to %s as our IP address\n", ip_str); + if (naddr_ == 0) + ShowError("Unable to determine your IP address...\n"); + else if (naddr_ > 1) + ShowNotice("Multiple interfaces detected...\n"); - if (!map->ip_set) - clif->setip(ip_str); - if (!map->char_ip_set) - chrif->setip(ip_str); - } + ShowInfo("Defaulting to %s as our IP address\n", ip_str); - battle->config_read(map->BATTLE_CONF_FILENAME); - atcommand->msg_read(map->MSG_CONF_NAME); + if (!map->ip_set) + clif->setip(ip_str); + if (!map->char_ip_set) + chrif->setip(ip_str); + } + + battle->config_read(map->BATTLE_CONF_FILENAME); + atcommand->msg_read(map->MSG_CONF_NAME); + map->inter_config_read(map->INTER_CONF_NAME); + logs->config_read(map->LOG_CONF_NAME); + } script->config_read(map->SCRIPT_CONF_NAME); - map->inter_config_read(map->INTER_CONF_NAME); - logs->config_read(map->LOG_CONF_NAME); map->id_db = idb_alloc(DB_OPT_BASE); map->pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] @@ -5538,53 +5548,77 @@ int do_init(int argc, char *argv[]) map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE); ers_chunk_size(map->flooritem_ers, 100); - - map->sql_init(); - if (logs->config.sql_logs) - logs->sql_init(); - mapindex_init(); + if (!minimal) { + map->sql_init(); + if (logs->config.sql_logs) + logs->sql_init(); + } + + i = mapindex_init(); + + if (minimal) { + // Pretend all maps from the mapindex are on this mapserver + CREATE(map->list,struct map_data,i); + + for( i = 0; i < MAX_MAPINDEX; i++ ) { + if (mapindex_exists(i)) { + map->addmap(mapindex_id2name(i)); + } + } + } + if(map->enable_grf) grfio_init(map->GRF_PATH_FILENAME); map->readallmaps(); - timer->add_func_list(map->freeblock_timer, "map_freeblock_timer"); - timer->add_func_list(map->clearflooritem_timer, "map_clearflooritem_timer"); - timer->add_func_list(map->removemobs_timer, "map_removemobs_timer"); - timer->add_interval(timer->gettick()+1000, map->freeblock_timer, 0, 0, 60*1000); - - HPM->load_sub = HPM_map_plugin_load_sub; - HPM->symbol_defaults_sub = map_hp_symbols; - HPM->config_read(); - HPM->event(HPET_INIT); - - atcommand->init(); - battle->init(); - instance->init(); - chrif->init(); - clif->init(); - ircbot->init(); - script->init(); - itemdb->init(); - skill->init(); - map->read_zone_db();/* read after item and skill initalization */ - mob->init(); - pc->init(); - status->init(); - party->init(); - guild->init(); - gstorage->init(); - pet->init(); - homun->init(); - mercenary->init(); - elemental->init(); - quest->init(); - npc->init(); - unit->init(); - bg->init(); - duel->init(); - vending->init(); + + if (!minimal) { + timer->add_func_list(map->freeblock_timer, "map_freeblock_timer"); + timer->add_func_list(map->clearflooritem_timer, "map_clearflooritem_timer"); + timer->add_func_list(map->removemobs_timer, "map_removemobs_timer"); + timer->add_interval(timer->gettick()+1000, map->freeblock_timer, 0, 0, 60*1000); + + HPM->load_sub = HPM_map_plugin_load_sub; + HPM->symbol_defaults_sub = map_hp_symbols; + HPM->config_read(); + HPM->event(HPET_INIT); + } + + atcommand->init(minimal); + battle->init(minimal); + instance->init(minimal); + chrif->init(minimal); + clif->init(minimal); + ircbot->init(minimal); + script->init(minimal); + itemdb->init(minimal); + skill->init(minimal); + if (!minimal) + map->read_zone_db();/* read after item and skill initalization */ + mob->init(minimal); + pc->init(minimal); + status->init(minimal); + party->init(minimal); + guild->init(minimal); + gstorage->init(minimal); + pet->init(minimal); + homun->init(minimal); + mercenary->init(minimal); + elemental->init(minimal); + quest->init(minimal); + npc->init(minimal); + unit->init(minimal); + bg->init(minimal); + duel->init(minimal); + vending->init(minimal); + + if (minimal) { + if (npc->parsesrcfile(scriptcheck, false) == 0) + exit(EXIT_SUCCESS); + exit(EXIT_FAILURE); + } npc->event_do_oninit(); // Init npcs (OnInit) diff --git a/src/map/map.h b/src/map/map.h index 6b7d2a630..31ee0ef60 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1020,7 +1020,7 @@ struct map_interface { int (*eraseallipport_sub) (DBKey key, DBData *data, va_list va); char* (*init_mapcache) (FILE *fp); int (*readfromcache) (struct map_data *m, char *buffer); - int (*addmap) (char *mapname); + int (*addmap) (const char *mapname); void (*delmapid) (int id); void (*zone_db_clear) (void); void (*list_final) (void); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 8c74a5e1e..a38b37b1e 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -490,7 +490,10 @@ int read_mercenary_skilldb(void) { return 0; } -void do_init_mercenary(void) { +void do_init_mercenary(bool minimal) { + if (minimal) + return; + mercenary->read_db(); mercenary->read_skilldb(); diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 3245606cf..3f2214b65 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -59,7 +59,7 @@ struct mercenary_interface { /* funcs */ - void (*init) (void); + void (*init) (bool minimal); bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); diff --git a/src/map/mob.c b/src/map/mob.c index 97f8ea6c1..c5a79dffe 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4534,7 +4534,12 @@ bool mob_readdb_itemratio(char* str[], int columns, int current) /** * read all mob-related databases */ -void mob_load(void) { +void mob_load(bool minimal) { + if (minimal) { + // Only read the mob db in minimal mode + mob->readdb(); + return; + } sv->readdb(map->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb mob->readchatdb(); if (map->db_use_sql_mob_db) { @@ -4569,7 +4574,7 @@ void mob_reload(void) { } } - mob->load(); + mob->load(false); } void mob_clear_spawninfo() @@ -4583,15 +4588,18 @@ void mob_clear_spawninfo() /*========================================== * Circumference initialization of mob *------------------------------------------*/ -int do_init_mob(void) -{ //Initialize the mob database +int do_init_mob(bool minimal) { + // Initialize the mob database memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array - mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns + mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE); item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE); - mob->load(); + mob->load(minimal); + + if (minimal) + return 0; timer->add_func_list(mob->delayspawn,"mob_delayspawn"); timer->add_func_list(mob->delay_item_drop,"mob_delay_item_drop"); diff --git a/src/map/mob.h b/src/map/mob.h index 2f425e285..31a8666a2 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -259,7 +259,7 @@ struct mob_interface { int manuk[8]; int splendide[5]; /* */ - int (*init) (void); + int (*init) (bool mimimal); int (*final) (void); void (*reload) (void); /* */ @@ -354,7 +354,7 @@ struct mob_interface { int (*read_sqlskilldb) (void); bool (*readdb_race2) (char *fields[], int columns, int current); bool (*readdb_itemratio) (char *str[], int columns, int current); - void (*load) (void); + void (*load) (bool minimal); void (*clear_spawninfo) (); }; diff --git a/src/map/npc.c b/src/map/npc.c index d78b3f8d4..9330d59d3 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1253,6 +1253,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) { } return 0; } + /*========================================== * Cash Shop Buy List *------------------------------------------*/ @@ -3498,8 +3499,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char //Read file and create npc/func/mapflag/monster... accordingly. //@runOnInit should we exec OnInit when it's done ? -void npc_parsesrcfile(const char* filepath, bool runOnInit) -{ +int npc_parsesrcfile(const char* filepath, bool runOnInit) { int16 m, x, y; int lines = 0; FILE* fp; @@ -3512,7 +3512,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) if( fp == NULL ) { ShowError("npc_parsesrcfile: File not found '%s'.\n", filepath); - return; + return -1; } fseek(fp, 0, SEEK_END); len = ftell(fp); @@ -3525,7 +3525,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) ShowError("npc_parsesrcfile: Failed to read file '%s' - %s\n", filepath, strerror(errno)); aFree(buffer); fclose(fp); - return; + return -1; } fclose(fp); @@ -3660,7 +3660,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) } aFree(buffer); - return; + return 0; } int npc_script_event(struct map_session_data* sd, enum npce_event type) @@ -3937,8 +3937,7 @@ static void npc_debug_warps(void) { /*========================================== * npc initialization *------------------------------------------*/ -int do_init_npc(void) -{ +int do_init_npc(bool minimal) { struct npc_src_list *file; int i; @@ -3965,43 +3964,47 @@ int do_init_npc(void) npc->name_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH); npc->path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0); - npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); - npc_last_npd = NULL; npc_last_path = NULL; npc_last_ref = NULL; - // process all npc files - ShowStatus("Loading NPCs...\r"); - for( file = npc->src_files; file != NULL; file = file->next ) { - ShowStatus("Loading NPC file: %s"CL_CLL"\r", file->name); - npc->parsesrcfile(file->name,false); + if (!minimal) { + npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); + + // process all npc files + ShowStatus("Loading NPCs...\r"); + for( file = npc->src_files; file != NULL; file = file->next ) { + ShowStatus("Loading NPC file: %s"CL_CLL"\r", file->name); + npc->parsesrcfile(file->name,false); + } + ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Warps\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Shops\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Scripts\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Spawn sets\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" + "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", + npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); } - ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Warps\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Shops\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Scripts\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Spawn sets\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" - "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", - npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); itemdb->name_constants(); + + if (!minimal) { + map->zone_init(); - map->zone_init(); - - npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ + npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ - // set up the events cache - memset(script_event, 0, sizeof(script_event)); - npc->read_event_script(); + // set up the events cache + memset(script_event, 0, sizeof(script_event)); + npc->read_event_script(); - //Debug function to locate all endless loop warps. - if (battle_config.warp_point_debug) - npc->debug_warps(); + //Debug function to locate all endless loop warps. + if (battle_config.warp_point_debug) + npc->debug_warps(); - timer->add_func_list(npc->event_do_clock,"npc_event_do_clock"); - timer->add_func_list(npc->timerevent,"npc_timerevent"); + timer->add_func_list(npc->event_do_clock,"npc_event_do_clock"); + timer->add_func_list(npc->timerevent,"npc_timerevent"); + } // Init dummy NPC npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data)); diff --git a/src/map/npc.h b/src/map/npc.h index 5ec201e55..10f3406b4 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -140,7 +140,7 @@ struct npc_interface { struct npc_src_list *src_files; struct unit_data base_ud; /* */ - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); /* */ int (*get_new_npc_id) (void); @@ -218,7 +218,7 @@ struct npc_interface { void (*parse_mob2) (struct spawn_data *mobspawn); const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); - void (*parsesrcfile) (const char *filepath, bool runOnInit); + int (*parsesrcfile) (const char *filepath, bool runOnInit); int (*script_event) (struct map_session_data *sd, enum npce_event type); void (*read_event_script) (void); int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args); diff --git a/src/map/party.c b/src/map/party.c index ab05c23f7..2801d0466 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -1306,7 +1306,10 @@ void do_final_party(void) { db_destroy(party->booking_db); // Party Booking [Spiria] } // Constructor, init vars -void do_init_party(void) { +void do_init_party(bool minimal) { + if (minimal) + return; + party->db = idb_alloc(DB_OPT_RELEASE_DATA); party->booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria] timer->add_func_list(party->send_xy_timer, "party_send_xy_timer"); diff --git a/src/map/party.h b/src/map/party.h index ab14d1a31..91f4c1b7d 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -73,7 +73,7 @@ struct party_interface { DBMap* booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] unsigned long booking_nextid; /* funcs */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ struct party_data* (*search) (int party_id); diff --git a/src/map/pc.c b/src/map/pc.c index d1d76fd4c..89b094043 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10215,7 +10215,9 @@ void do_final_pc(void) { return; } -void do_init_pc(void) { +void do_init_pc(bool minimal) { + if (minimal) + return; pc->itemcd_db = idb_alloc(DB_OPT_RELEASE_DATA); diff --git a/src/map/pc.h b/src/map/pc.h index 7ae92c9a5..af03aa2f3 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -742,7 +742,7 @@ struct pc_interface { /* */ struct eri *sc_display_ers; /* funcs */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); struct map_session_data* (*get_dummy_sd) (void); diff --git a/src/map/pet.c b/src/map/pet.c index 7dcf06c02..612ddfada 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1328,8 +1328,10 @@ int read_petdb() /*========================================== * Initialization process relationship skills *------------------------------------------*/ -int do_init_pet(void) -{ +int do_init_pet(bool minimal) { + if (minimal) + return 0; + pet->read_db(); pet->item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE); diff --git a/src/map/pet.h b/src/map/pet.h index f95e860a2..f9a756de2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -106,7 +106,7 @@ struct pet_interface { struct eri *item_drop_ers; //For loot drops delay structures. struct eri *item_drop_list_ers; /* */ - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); /* */ int (*hungry_val) (struct pet_data *pd); diff --git a/src/map/quest.c b/src/map/quest.c index f40b60c3d..0719b8dbb 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -351,7 +351,10 @@ int quest_read_db(void) { return 0; } -void do_init_quest(void) { +void do_init_quest(bool minimal) { + if (minimal) + return; + quest->read_db(); } diff --git a/src/map/quest.h b/src/map/quest.h index 340bc8608..0725a8c46 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -19,7 +19,7 @@ typedef enum quest_check_type { HAVEQUEST, PLAYTIME, HUNTING } quest_check_type; struct quest_interface { struct s_quest_db db[MAX_QUEST_DB]; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*reload) (void); /* */ int (*search_db) (int quest_id); diff --git a/src/map/script.c b/src/map/script.c index 3b0557235..ea3867083 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1863,66 +1863,98 @@ void read_constdb(void) { fclose(fp); } +// Standard UNIX tab size is 8 +#define TAB_SIZE 8 +#define update_tabstop(tabstop,chars) \ + do { \ + (tabstop) -= (chars); \ + while ((tabstop) <= 0) (tabstop) += TAB_SIZE; \ + } while (false) + /*========================================== * Display emplacement line of script *------------------------------------------*/ const char* script_print_line(StringBuf* buf, const char* p, const char* mark, int line) { - int i; + int i, mark_pos = 0, tabstop = TAB_SIZE; if( p == NULL || !p[0] ) return NULL; if( line < 0 ) - StrBuf->Printf(buf, "*% 5d : ", -line); + StrBuf->Printf(buf, "*%5d: ", -line); // len = 8 else - StrBuf->Printf(buf, " % 5d : ", line); - for(i=0;p[i] && p[i] != '\n';i++){ - if(p + i != mark) - StrBuf->Printf(buf, "%c", p[i]); + StrBuf->Printf(buf, " %5d: ", line); // len = 8 + update_tabstop(tabstop,8); // len = 8 + for( i=0; p[i] && p[i] != '\n'; i++ ) { + char c = p[i]; + int w = 1; + // Like Clang does, let's print the code with tabs expanded to spaces to ensure that the marker will be under the right character + if( c == '\t' ) { + c = ' '; + w = tabstop; + } + update_tabstop(tabstop, w); + if( p + i < mark) + mark_pos += w; + if( p + i != mark) + StrBuf->Printf(buf, "%*c", w, c); else - StrBuf->Printf(buf, "\'%c\'", p[i]); + StrBuf->Printf(buf, CL_BT_RED"%*c"CL_RESET, w, c); } StrBuf->AppendStr(buf, "\n"); + if( mark ) { + StrBuf->AppendStr(buf, " "CL_BT_CYAN); // len = 8 + for( ; mark_pos > 0; mark_pos-- ) { + StrBuf->AppendStr(buf, "~"); + } + StrBuf->AppendStr(buf, CL_RESET CL_BT_GREEN"^"CL_RESET"\n"); + } return p+i+(p[i] == '\n' ? 1 : 0); } +#undef TAB_SIZE +#undef update_tabstop +#define CONTEXTLINES 3 void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { // Find the line where the error occurred int j; int line = start_line; - const char *p; - const char *linestart[5] = { NULL, NULL, NULL, NULL, NULL }; + const char *p, *error_linepos; + const char *linestart[CONTEXTLINES]; + memset(linestart, '\0', sizeof(linestart)); for(p=src;p && *p;line++){ const char *lineend=strchr(p,'\n'); if(lineend==NULL || error_pos<lineend){ break; } - for( j = 0; j < 4; j++ ) { + for( j = 0; j < CONTEXTLINES-1; j++ ) { linestart[j] = linestart[j+1]; } - linestart[4] = p; - p=lineend+1; + linestart[CONTEXTLINES-1] = p; + p = lineend+1; } + error_linepos = p; if( line >= 0 ) - StrBuf->Printf(buf, "script error in file '%s' line %d\n", file, line); + StrBuf->Printf(buf, "script error in file '%s' line %d column %d\n", file, line, error_pos-error_linepos+1); else StrBuf->Printf(buf, "script error in file '%s' item ID %d\n", file, -line); StrBuf->Printf(buf, " %s\n", error_msg); - for(j = 0; j < 5; j++ ) { - script->print_line(buf, linestart[j], NULL, line + j - 5); + for(j = 0; j < CONTEXTLINES; j++ ) { + script->print_line(buf, linestart[j], NULL, line + j - CONTEXTLINES); } p = script->print_line(buf, p, error_pos, -line); - for(j = 0; j < 5; j++) { + for(j = 0; j < CONTEXTLINES; j++) { p = script->print_line(buf, p, NULL, line + j + 1 ); } } +#undef CONTEXTLINES void script_error(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { StringBuf buf; StrBuf->Init(&buf); - StrBuf->AppendStr(&buf, "\a\n"); + StrBuf->AppendStr(&buf, "\a"); script->errorwarning_sub(&buf, src, file, start_line, error_msg, error_pos); @@ -3694,7 +3726,7 @@ void do_final_script(void) { /*========================================== * Initialization *------------------------------------------*/ -void do_init_script(void) { +void do_init_script(bool minimal) { script->st_db = idb_alloc(DB_OPT_BASE); script->userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0); script->autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0); @@ -3707,6 +3739,10 @@ void do_init_script(void) { script->parse_builtin(); script->read_constdb(); + + if (minimal) + return; + mapreg->init(); } diff --git a/src/map/script.h b/src/map/script.h index a4d14c777..6aebc8a30 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -507,7 +507,7 @@ struct script_interface { int potion_hp, potion_per_hp, potion_sp, potion_per_sp; int potion_target; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); int (*reload) (void); /* parse */ diff --git a/src/map/skill.c b/src/map/skill.c index b70e58c46..c16ab832c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -18027,7 +18027,7 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { * create_arrow_db.txt * abra_db.txt *------------------------------*/ -void skill_readdb(void) { +void skill_readdb(bool minimal) { // init skill db structures db_clear(skill->name2id_db); @@ -18050,6 +18050,10 @@ void skill_readdb(void) { safestrncpy(skill->db[0].desc, "Unknown Skill", sizeof(skill->db[0].desc)); sv->readdb(map->db_path, DBPATH"skill_db.txt", ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); + + if (minimal) + return; + sv->readdb(map->db_path, DBPATH"skill_require_db.txt", ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); #ifdef RENEWAL_CAST sv->readdb(map->db_path, "re/skill_cast_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); @@ -18077,7 +18081,7 @@ void skill_reload (void) { struct map_session_data *sd; int i,c,k; - skill->read_db(); + skill->read_db(false); //[Ind/Hercules] refresh index cache for(c = 0; c < CLASS_COUNT; c++) { @@ -18103,9 +18107,12 @@ void skill_reload (void) { /*========================================== * *------------------------------------------*/ -int do_init_skill (void) { +int do_init_skill(bool minimal) { skill->name2id_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAX_SKILL_NAME_LENGTH); - skill->read_db(); + skill->read_db(minimal); + + if (minimal) + return 0; skill->group_db = idb_alloc(DB_OPT_BASE); skill->unit_db = idb_alloc(DB_OPT_BASE); diff --git a/src/map/skill.h b/src/map/skill.h index fca4952ef..918216e8a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1797,10 +1797,10 @@ typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint * Skill.c Interface **/ struct skill_interface { - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); void (*reload) (void); - void (*read_db) (void); + void (*read_db) (bool minimal); /* */ DBMap* cd_db; // char_id -> struct skill_cd DBMap* name2id_db; diff --git a/src/map/status.c b/src/map/status.c index c06de4dfe..17fa4dd38 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -11536,7 +11536,10 @@ int status_readdb(void) /*========================================== * Status db init and destroy. *------------------------------------------*/ -int do_init_status(void) { +int do_init_status(bool minimal) { + if (minimal) + return 0; + timer->add_func_list(status->change_timer,"status_change_timer"); timer->add_func_list(status->kaahi_heal_timer,"status_kaahi_heal_timer"); timer->add_func_list(status->natural_heal_timer,"status_natural_heal_timer"); diff --git a/src/map/status.h b/src/map/status.h index 254f3bfab..7d48e5684 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1864,7 +1864,7 @@ struct status_interface { int64 natural_heal_prev_tick; unsigned int natural_heal_diff_tick; /* */ - int (*init) (void); + int (*init) (bool minimal); void (*final) (void); /* funcs */ int (*get_refine_chance) (enum refine_type wlv, int refine); diff --git a/src/map/storage.c b/src/map/storage.c index cc1100d28..45a80867d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -717,7 +717,9 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) { return 0; } -void do_init_gstorage(void) { +void do_init_gstorage(bool minimal) { + if (minimal) + return; gstorage->db = idb_alloc(DB_OPT_RELEASE_DATA); } void do_final_gstorage(void) { diff --git a/src/map/storage.h b/src/map/storage.h index 9258e0265..8a10c9f3b 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -36,7 +36,7 @@ struct guild_storage_interface { struct guild_storage *(*id2storage) (int guild_id); struct guild_storage *(*id2storage2) (int guild_id); /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ int (*delete) (int guild_id); diff --git a/src/map/unit.c b/src/map/unit.c index c7ba2f6f9..b1240def2 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2573,7 +2573,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) { return 0; } -int do_init_unit(void) { +int do_init_unit(bool minimal) { + if (minimal) + return 0; + timer->add_func_list(unit->attack_timer, "unit_attack_timer"); timer->add_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); timer->add_func_list(unit->walktobl_sub, "unit_walktobl_sub"); diff --git a/src/map/unit.h b/src/map/unit.h index 0567688a1..8220b7e8f 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -72,7 +72,7 @@ extern const short dirx[8]; extern const short diry[8]; struct unit_interface { - int (*init) (void); + int (*init) (bool minimal); int (*final) (void); /* */ struct unit_data* (*bl2ud) (struct block_list *bl); diff --git a/src/map/vending.c b/src/map/vending.c index 7d6d02cfb..c7a2dfa68 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -360,7 +360,7 @@ void final(void) { db_destroy(vending->db); } -void init(void) { +void init(bool minimal) { vending->db = idb_alloc(DB_OPT_BASE); vending->next_id = 0; } diff --git a/src/map/vending.h b/src/map/vending.h index 968811ecd..b760bf064 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -20,7 +20,7 @@ struct vending_interface { unsigned int next_id;/* next vender id */ DBMap *db; /* */ - void (*init) (void); + void (*init) (bool minimal); void (*final) (void); /* */ void (*close) (struct map_session_data* sd); -- cgit v1.2.3-70-g09d2 From 778facb21f822cea549939c8dbee886e1cd342aa Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Wed, 6 Nov 2013 15:06:00 -0200 Subject: Modified @command loading So that HPM plugins are able to override default commands, thanks to Akkarin for bringing it up. Signed-off-by: shennetsind <ind@henn.et> --- src/map/HPMmap.c | 5 +---- src/map/atcommand.c | 19 ++++++++++--------- src/map/atcommand.h | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src/map') diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index ca4a7a2e8..8a69cba97 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -142,10 +142,7 @@ void HPM_map_atcommands(void) { unsigned int i; for(i = 0; i < atcommand_list_items; i++) { - if( !atcommand->add(atcommand_list[i].name,atcommand_list[i].func) ) { - ShowDebug("HPM_map_atcommands: duplicate command '%s', skipping...\n", atcommand_list[i].name); - continue; - } + atcommand->add(atcommand_list[i].name,atcommand_list[i].func,true); } } diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0ba977ff4..2abdb5925 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9564,7 +9564,7 @@ void atcommand_basecommands(void) { int i; for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) { - if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func)) { // Should not happen if atcommand_base[] array is OK + if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func,false)) { // Should not happen if atcommand_base[] array is OK ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command); continue; } @@ -9576,21 +9576,22 @@ void atcommand_basecommands(void) { return; } -bool atcommand_add(char *name,AtCommandFunc func) { +bool atcommand_add(char *name,AtCommandFunc func, bool replace) { AtCommandInfo* cmd; - if(atcommand->exists(name)) //caller will handle/display on false - return false; - - CREATE(cmd, AtCommandInfo, 1); + if( (cmd = atcommand->exists(name)) ) { //caller will handle/display on false + if( !replace ) + return false; + } else { + CREATE(cmd, AtCommandInfo, 1); + strdb_put(atcommand->db, name, cmd); + } safestrncpy(cmd->command, name, sizeof(cmd->command)); cmd->func = func; cmd->help = NULL; cmd->log = true; - - strdb_put(atcommand->db, cmd->command, cmd); - + return true; } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 63c38e4d1..e4c66df40 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -110,7 +110,7 @@ struct atcommand_interface { int (*cmd_db_clear_sub) (DBKey key, DBData *data, va_list args); void (*doload) (void); void (*base_commands) (void); - bool (*add) (char *name, AtCommandFunc func); + bool (*add) (char *name, AtCommandFunc func, bool replace); }; struct atcommand_interface *atcommand; -- cgit v1.2.3-70-g09d2 From 6f77d070b98c73962a4f45f274a0f5c58a2448e3 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Wed, 6 Nov 2013 15:10:35 -0200 Subject: Modified status_calc_ Replaces the previous 'first' flag with a multi-option flag capable of selectively determining calls where the recalculation must not be hold by delayed damage, and therefore must take place immediately. This fixes issues caused by actions that require immediate recalculation e.g. on-level-up max_hp update, also modified @baselevel where status_calc was being called after the heal and not before, causing it not to be fully healed. Special Thanks to Haruna! <3 Signed-off-by: shennetsind <ind@henn.et> --- src/map/atcommand.c | 11 ++++---- src/map/battle.c | 4 +-- src/map/clif.c | 2 +- src/map/elemental.c | 2 +- src/map/guild.c | 2 +- src/map/homunculus.c | 12 ++++----- src/map/itemdb.c | 2 +- src/map/mercenary.c | 2 +- src/map/mob.c | 6 ++--- src/map/pc.c | 64 ++++++++++++++++++++++---------------------- src/map/pet.c | 16 +++++------ src/map/script.c | 18 ++++++------- src/map/status.c | 75 +++++++++++++++++++++++++++------------------------- src/map/status.h | 38 +++++++++++++++----------- 14 files changed, 132 insertions(+), 122 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2abdb5925..7e5d42e69 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1258,6 +1258,7 @@ ACMD(baselevelup) sd->status.status_point += status_point; sd->status.base_level += (unsigned int)level; + status_calc_pc(sd, SCO_FORCE); status_percent_heal(&sd->bl, 100, 100); clif->misceffect(&sd->bl, 0); clif->message(fd, msg_txt(21)); // Base level raised. @@ -1279,13 +1280,13 @@ ACMD(baselevelup) sd->status.status_point -= status_point; sd->status.base_level -= (unsigned int)level; clif->message(fd, msg_txt(22)); // Base level lowered. + status_calc_pc(sd, SCO_FORCE); } sd->status.base_exp = 0; clif->updatestatus(sd, SP_STATUSPOINT); clif->updatestatus(sd, SP_BASELEVEL); clif->updatestatus(sd, SP_BASEEXP); clif->updatestatus(sd, SP_NEXTBASEEXP); - status_calc_pc(sd, 0); pc->baselevelchanged(sd); if(sd->status.party_id) party->send_levelup(sd); @@ -1338,7 +1339,7 @@ ACMD(joblevelup) clif->updatestatus(sd, SP_JOBEXP); clif->updatestatus(sd, SP_NEXTJOBEXP); clif->updatestatus(sd, SP_SKILLPOINT); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); return true; } @@ -2352,7 +2353,7 @@ ACMD(param) { *stats[i] = new_value; clif->updatestatus(sd, SP_STR + i); clif->updatestatus(sd, SP_USTR + i); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); clif->message(fd, msg_txt(42)); // Stat changed. } else { if (value < 0) @@ -2409,7 +2410,7 @@ ACMD(stat_all) { } if (count > 0) { // if at least 1 stat modified - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); clif->message(fd, msg_txt(84)); // All stats changed! } else { if (value < 0) @@ -6725,7 +6726,7 @@ ACMD(homlevel) { hd->homunculus.exp += hd->exp_next; } while( hd->homunculus.level < level && homun->levelup(hd) ); - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); clif->specialeffect(&hd->bl,568,AREA); return true; diff --git a/src/map/battle.c b/src/map/battle.c index 94222f663..499b7e3a0 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -206,7 +206,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { if( !target || status->isdead(target) ) {/* nothing we can do */ if( dat->src_type == BL_PC && ( src = map->id2bl(dat->src_id) ) && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { ((TBL_PC*)src)->state.hold_recalc = 0; - status_calc_pc(((TBL_PC*)src),0); + status_calc_pc(((TBL_PC*)src),SCO_FORCE); } ers_free(battle->delay_damage_ers, dat); return 0; @@ -237,7 +237,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { if( src && src->type == BL_PC && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { ((TBL_PC*)src)->state.hold_recalc = 0; - status_calc_pc(((TBL_PC*)src),0); + status_calc_pc(((TBL_PC*)src),SCO_FORCE); } } ers_free(battle->delay_damage_ers, dat); diff --git a/src/map/clif.c b/src/map/clif.c index c1e7cb1c9..913a94058 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9473,7 +9473,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } map->iwall_get(sd); // Updates Walls Info on this Map to Client - status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ + status_calc_pc(sd, SCO_NONE);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; if( hChSys.local && hChSys.local_autojoin && !map->list[sd->bl.m].flag.chsysnolocalaj ) { diff --git a/src/map/elemental.c b/src/map/elemental.c index f15b735b2..d280f5b81 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -258,7 +258,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { ed->bl.y = ed->ud.to_y; map->addiddb(&ed->bl); - status_calc_elemental(ed,1); + status_calc_elemental(ed,SCO_FIRST); ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; elemental->summon_init(ed); diff --git a/src/map/guild.c b/src/map/guild.c index 0ae45bede..4dcdb6c46 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1923,7 +1923,7 @@ int guild_castledatasave(int castle_id, int index, int value) gc->defense = value; for (i = 0; i < MAX_GUARDIANS; i++) if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL) - status_calc_mob(gd, 0); + status_calc_mob(gd, SCO_NONE); break; } case 4: diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 52f0572c0..a7a409011 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -272,7 +272,7 @@ void homunculus_skillup(struct homun_data *hd,uint16 skill_id) { { hd->homunculus.hskill[i].lv++; hd->homunculus.skillpts-- ; - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); if (hd->master) { clif->homskillup(hd->master, skill_id); clif->hominfo(hd->master,hd,0); @@ -413,7 +413,7 @@ bool homunculus_evolve(struct homun_data *hd) { //status_Calc flag&1 will make current HP/SP be reloaded from hom structure hom->hp = hd->battle_status.hp; hom->sp = hd->battle_status.sp; - status_calc_homunculus(hd,1); + status_calc_homunculus(hd,SCO_FIRST); if (!(battle_config.hom_setting&0x2)) skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately @@ -460,7 +460,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { hom->hp = hd->battle_status.hp; hom->sp = hd->battle_status.sp; hom->prev_class = prev_class; - status_calc_homunculus(hd,1); + status_calc_homunculus(hd,SCO_FIRST); if (!(battle_config.hom_setting&0x2)) skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately @@ -505,7 +505,7 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) { hd->homunculus.exp = 0; clif->specialeffect(&hd->bl,568,AREA); - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); return 0; } @@ -757,7 +757,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { hd->bl.y = hd->ud.to_y; map->addiddb(&hd->bl); - status_calc_homunculus(hd,1); + status_calc_homunculus(hd,SCO_FIRST); hd->hungry_timer = INVALID_TIMER; return true; @@ -1003,7 +1003,7 @@ bool homunculus_shuffle(struct homun_data *hd) { memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill)); hd->homunculus.skillpts = skillpts; clif->homskillinfoblock(sd); - status_calc_homunculus(hd,0); + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); clif->specialeffect(&hd->bl,568,AREA); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3fc8d526b..8dd6e9d9d 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2108,7 +2108,7 @@ void itemdb_reload(void) { sd->combos.id = NULL; sd->combos.count = 0; if( pc->load_combo(sd) > 0 ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); } } diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 8c74a5e1e..5ea10dc66 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -317,7 +317,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) { md->bl.y = md->ud.to_y; map->addiddb(&md->bl); - status_calc_mercenary(md,1); + status_calc_mercenary(md,SCO_FIRST); md->contract_timer = INVALID_TIMER; merc_contract_init(md); } diff --git a/src/map/mob.c b/src/map/mob.c index 97f8ea6c1..3f2ae2a55 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -601,7 +601,7 @@ int mob_spawn_guardian_sub(int tid, int64 tick, int id, intptr_t data) { memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH); md->guardian_data->guardup_lv = guardup_lv; if( guardup_lv ) - status_calc_mob(md, 0); //Give bonuses. + status_calc_mob(md, SCO_NONE); //Give bonuses. return 0; } @@ -919,7 +919,7 @@ int mob_spawn (struct mob_data *md) } memset(&md->state, 0, sizeof(md->state)); - status_calc_mob(md, 1); + status_calc_mob(md, SCO_FIRST); md->attacked_id = 0; md->target_id = 0; md->move_fail_count = 0; @@ -2725,7 +2725,7 @@ int mob_class_change (struct mob_data *md, int class_) unit->skillcastcancel(&md->bl, 0); status->set_viewdata(&md->bl, class_); clif->class_change(&md->bl, md->vd->class_, 1); - status_calc_mob(md, 1); + status_calc_mob(md, SCO_FIRST); md->ud.state.speed_changed = 1; //Speed change update. if (battle_config.monster_class_change_recover) { diff --git a/src/map/pc.c b/src/map/pc.c index d1d76fd4c..f5e20b32b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1320,7 +1320,7 @@ int pc_reg_received(struct map_session_data *sd) pc->load_combo(sd); - status_calc_pc(sd,1); + status_calc_pc(sd,SCO_FIRST|SCO_FORCE); chrif->scdata_request(sd->status.account_id, sd->status.char_id); intif->Mail_requestinbox(sd->status.char_id, 0); // MAIL SYSTEM - Request Mail Inbox @@ -2028,7 +2028,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) autobonus->active = timer->add(timer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); sd->state.autobonus |= autobonus->pos; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return 0; } @@ -2042,7 +2042,7 @@ int pc_endautobonus(int tid, int64 tick, int id, intptr_t data) { autobonus->active = INVALID_TIMER; sd->state.autobonus &= ~autobonus->pos; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return 0; } @@ -3549,7 +3549,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { } else clif->addskill(sd,id); if( !skill->db[index].inf ) //Only recalculate for passive skills. - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); break; case 1: //Item bonus skill. if( sd->status.skill[index].id == id ) { @@ -3583,7 +3583,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) { } else clif->addskill(sd,id); if( !skill->db[index].inf ) //Only recalculate for passive skills. - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); break; default: //Unknown flag? return 0; @@ -5789,13 +5789,13 @@ int pc_checkbaselevelup(struct map_session_data *sd) { } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level - status_calc_pet(sd->pd,0); + status_calc_pet(sd->pd,SCO_NONE); clif->updatestatus(sd,SP_STATUSPOINT); clif->updatestatus(sd,SP_BASELEVEL); clif->updatestatus(sd,SP_BASEEXP); clif->updatestatus(sd,SP_NEXTBASEEXP); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); status_percent_heal(&sd->bl,100,100); if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) { @@ -5855,7 +5855,7 @@ int pc_checkjoblevelup(struct map_session_data *sd) clif->updatestatus(sd,SP_JOBEXP); clif->updatestatus(sd,SP_NEXTJOBEXP); clif->updatestatus(sd,SP_SKILLPOINT); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); clif->misceffect(&sd->bl,1); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL. @@ -6143,7 +6143,7 @@ int pc_statusup(struct map_session_data* sd, int type) val = pc->setstat(sd, type, pc->getstat(sd,type) + 1); sd->status.status_point -= need; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); // update increase cost indicator if( need != pc->need_status_point(sd,type,1) ) @@ -6183,7 +6183,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val) max = pc_maxparameter(sd); val = pc->setstat(sd, type, cap_value(pc->getstat(sd,type) + val, 1, max)); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); // update increase cost indicator if( need != pc->need_status_point(sd,type,1) ) @@ -6226,7 +6226,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { sd->status.skill[index].lv++; sd->status.skill_point--; if( !skill->db[index].inf ) - status_calc_pc(sd,0); // Only recalculate for passive skills. + status_calc_pc(sd,SCO_NONE); // Only recalculate for passive skills. else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) pc->calc_skilltree(sd); // Required to grant all TK Ranger skills. else @@ -6299,7 +6299,7 @@ int pc_allskillup(struct map_session_data *sd) sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class_); // celest } } - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); //Required because if you could level up all skills previously, //the update will not be sent as only the lv variable changes. clif->skillinfoblock(sd); @@ -6389,7 +6389,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) if ((type == 1 || type == 2 || type == 3) && sd->status.party_id) party->send_levelup(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); clif->skillinfoblock(sd); return 0; @@ -6454,7 +6454,7 @@ int pc_resetstate(struct map_session_data* sd) pc_setglobalreg(sd,"TK_MISSION_ID", 0); } - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return 1; } @@ -6565,7 +6565,7 @@ int pc_resetskill(struct map_session_data* sd, int flag) if( flag&1 ) { clif->updatestatus(sd,SP_SKILLPOINT); clif->skillinfoblock(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); } return skill_point; @@ -6819,7 +6819,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { ) { // monster level up [Valaris] clif->misceffect(&md->bl,0); md->level++; - status_calc_mob(md, 0); + status_calc_mob(md, SCO_NONE); status_percent_heal(src,10,0); if( battle_config.show_mob_info&4 ) @@ -7235,7 +7235,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) clif->updatestatus(sd, SP_NEXTBASEEXP); clif->updatestatus(sd, SP_STATUSPOINT); clif->updatestatus(sd, SP_BASEEXP); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); if(sd->status.party_id) { party->send_levelup(sd); @@ -7252,7 +7252,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) // clif->updatestatus(sd, SP_JOBLEVEL); // Gets updated at the bottom clif->updatestatus(sd, SP_NEXTJOBEXP); clif->updatestatus(sd, SP_JOBEXP); - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_FORCE); break; case SP_SKILLPOINT: sd->status.skill_point = val; @@ -7662,7 +7662,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if(sd->status.manner < 0) clif->changestatus(sd,SP_MANNER,sd->status.manner); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_FORCE); pc->checkallowskill(sd); pc->equiplookall(sd); @@ -7785,11 +7785,11 @@ int pc_setoption(struct map_session_data *sd,int type) if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc->checkskill(sd,RK_DRAGONTRAINING) > 0) ) { // Mounting clif->sc_load(&sd->bl,sd->bl.id,AREA,SI_RIDING, 0, 0, 0); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } else if( (!(type&OPTION_RIDING) && p_type&OPTION_RIDING) || (!(type&OPTION_DRAGON) && p_type&OPTION_DRAGON) ) { // Dismount clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_RIDING); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } #ifndef NEW_CARTS @@ -7797,11 +7797,11 @@ int pc_setoption(struct map_session_data *sd,int type) clif->cartlist(sd); clif->updatestatus(sd, SP_CARTINFO); if(pc->checkskill(sd, MC_PUSHCART) < 10) - status_calc_pc(sd,0); //Apply speed penalty. + status_calc_pc(sd,SCO_NONE); //Apply speed penalty. } else if( !( type&OPTION_CART ) && p_type&OPTION_CART ){ //Cart Off clif->clearcart(sd->fd); if(pc->checkskill(sd, MC_PUSHCART) < 10) - status_calc_pc(sd,0); //Remove speed penalty. + status_calc_pc(sd,SCO_NONE); //Remove speed penalty. } #endif @@ -7813,18 +7813,18 @@ int pc_setoption(struct map_session_data *sd,int type) if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER ) { if( type&OPTION_WUGRIDER && !(p_type&OPTION_WUGRIDER) ) { // Mounting clif->sc_load(&sd->bl,sd->bl.id,AREA,SI_WUGRIDER, 0, 0, 0); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } else if( !(type&OPTION_WUGRIDER) && p_type&OPTION_WUGRIDER ) { // Dismount clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_WUGRIDER); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } } if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) { int i; if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) ) - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR ) - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); for( i = 0; i < SC_MAX; i++ ){ if ( !sd->sc.data[i] || !status->get_sc_type(i) ) continue; @@ -7903,7 +7903,7 @@ int pc_setcart(struct map_session_data *sd,int type) { } if(pc->checkskill(sd, MC_PUSHCART) < 10) - status_calc_pc(sd,0); //Recalc speed penalty. + status_calc_pc(sd,SCO_NONE); //Recalc speed penalty. #else // Update option option = sd->sc.option; @@ -8155,7 +8155,7 @@ int pc_setregistry(struct map_session_data *sd,const char *reg,int val,int type) i = (!sd->die_counter && (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE); sd->die_counter = val; if( i ) - status_calc_pc(sd,0); // Lost the bonus. + status_calc_pc(sd,SCO_NONE); // Lost the bonus. } else if( !strcmp(reg,"COOK_MASTERY") && sd->cook_mastery != val ) { @@ -8759,7 +8759,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) } } - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); if (flag) //Update skill data clif->skillinfoblock(sd); @@ -8924,7 +8924,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) { if(flag&1 || status_cacl) { pc->checkallowskill(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } if(sd->sc.data[SC_CRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele)) @@ -9029,7 +9029,7 @@ int pc_checkitem(struct map_session_data *sd) if( calc_flag && sd->state.active ) { pc->checkallowskill(sd); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } return 0; diff --git a/src/map/pet.c b/src/map/pet.c index 7dcf06c02..b75cc5a44 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -65,7 +65,7 @@ void pet_set_intimate(struct pet_data *pd, int value) pd->pet.intimate = value; if( (intimate >= battle_config.pet_equip_min_friendly && pd->pet.intimate < battle_config.pet_equip_min_friendly) || (intimate < battle_config.pet_equip_min_friendly && pd->pet.intimate >= battle_config.pet_equip_min_friendly) ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } int pet_create_egg(struct map_session_data *sd, int item_id) @@ -219,7 +219,7 @@ int pet_hungry(int tid, int64 tick, int id, intptr_t data) { pd->pet.intimate = 0; pd->status.speed = pd->db->status.speed; } - status_calc_pet(pd, 0); + status_calc_pet(pd, SCO_NONE); clif->send_petdata(sd,pd,1,pd->pet.intimate); } clif->send_petdata(sd,pd,2,pd->pet.hungry); @@ -304,7 +304,7 @@ int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) pd->pet.incuvate = 1; unit->free(&pd->bl,CLR_OUTSIGHT); - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); sd->status.pet_id = 0; return 1; @@ -360,14 +360,14 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) pd->bl.y = pd->ud.to_y; map->addiddb(&pd->bl); - status_calc_pet(pd,1); + status_calc_pet(pd,SCO_FIRST); pd->last_thinktime = timer->gettick(); pd->state.skillbonus = 0; if( battle_config.pet_status_support ) script->run(pet->db[i].pet_script,0,sd->bl.id,0); if( pd->petDB && pd->petDB->equip_script ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); if( battle_config.pet_hungry_delay_rate != 100 ) interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100; @@ -703,7 +703,7 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { if( pd->state.skillbonus ) { pd->state.skillbonus = 0; - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); } if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER ) { @@ -759,7 +759,7 @@ int pet_food(struct map_session_data *sd, struct pet_data *pd) } else if( pd->pet.intimate > 1000 ) pd->pet.intimate = 1000; - status_calc_pet(pd, 0); + status_calc_pet(pd, SCO_NONE); pd->pet.hungry += pd->petDB->fullness; if( pd->pet.hungry > 100 ) pd->pet.hungry = 100; @@ -1062,7 +1062,7 @@ int pet_skill_bonus_timer(int tid, int64 tick, int id, intptr_t data) { if (pd->state.skillbonus != bonus) { pd->state.skillbonus = bonus; - status_calc_pc(sd, 0); + status_calc_pc(sd, SCO_NONE); } // wait for the next timer pd->bonus->timer=timer->add(tick+duration,pet->skill_bonus_timer,sd->bl.id,0); diff --git a/src/map/script.c b/src/map/script.c index 3b0557235..8fd7f425c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12099,7 +12099,7 @@ BUILDIN(nude) } if( calcflag ) - status_calc_pc(sd,0); + status_calc_pc(sd,SCO_NONE); return true; } @@ -12425,9 +12425,9 @@ BUILDIN(npcwalkto) { if( nd ) { unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit if (!nd->status.hp) { - status_calc_npc(nd, true); + status_calc_npc(nd, SCO_FIRST); } else { - status_calc_npc(nd, false); + status_calc_npc(nd, SCO_NONE); } unit->walktoxy(&nd->bl,x,y,0); } @@ -14967,9 +14967,9 @@ BUILDIN(unitskilluseid) { if( bl != NULL ) { if( bl->type == BL_NPC ) { if (!((TBL_NPC*)bl)->status.hp) { - status_calc_npc(((TBL_NPC*)bl), true); + status_calc_npc(((TBL_NPC*)bl), SCO_FIRST); } else { - status_calc_npc(((TBL_NPC*)bl), false); + status_calc_npc(((TBL_NPC*)bl), SCO_NONE); } } unit->skilluse_id(bl, target_id, skill_id, skill_lv); @@ -15001,9 +15001,9 @@ BUILDIN(unitskillusepos) { if( bl != NULL ) { if( bl->type == BL_NPC ) { if (!((TBL_NPC*)bl)->status.hp) { - status_calc_npc(((TBL_NPC*)bl), true); + status_calc_npc(((TBL_NPC*)bl), SCO_FIRST); } else { - status_calc_npc(((TBL_NPC*)bl), false); + status_calc_npc(((TBL_NPC*)bl), SCO_NONE); } } unit->skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv); @@ -17013,9 +17013,9 @@ BUILDIN(npcskill) { nd->stat_point = stat_point; if (!nd->status.hp) { - status_calc_npc(nd, true); + status_calc_npc(nd, SCO_FIRST); } else { - status_calc_npc(nd, false); + status_calc_npc(nd, SCO_NONE); } if (skill->get_inf(skill_id)&INF_GROUND_SKILL) { diff --git a/src/map/status.c b/src/map/status.c index c06de4dfe..1df98a957 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1999,13 +1999,12 @@ void status_calc_misc(struct block_list *bl, struct status_data *st, int level) //Skotlex: Calculates the initial status for the given mob //first will only be false when the mob leveled up or got a GuardUp level. -int status_calc_mob_(struct mob_data* md, bool first) { +int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) { struct status_data *mstatus; struct block_list *mbl = NULL; int flag=0; - if(first) - { //Set basic level on respawn. + if(opt&SCO_FIRST) { //Set basic level on respawn. if (md->level > 0 && md->level <= MAX_LEVEL && md->level != md->db->lv) ; else @@ -2036,7 +2035,7 @@ int status_calc_mob_(struct mob_data* md, bool first) { aFree(md->base_status); md->base_status = NULL; } - if(first) + if(opt&SCO_FIRST) memcpy(&md->status, &md->db->status, sizeof(struct status_data)); return 0; } @@ -2160,18 +2159,18 @@ int status_calc_mob_(struct mob_data* md, bool first) { } } - if( first ) //Initial battle status + if( opt&SCO_FIRST ) //Initial battle status memcpy(&md->status, mstatus, sizeof(struct status_data)); return 1; } //Skotlex: Calculates the stats of the given pet. -int status_calc_pet_(struct pet_data *pd, bool first) +int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt) { nullpo_ret(pd); - if (first) { + if (opt&SCO_FIRST) { memcpy(&pd->status, &pd->db->status, sizeof(struct status_data)); pd->status.mode = MD_CANMOVE; // pets discard all modes, except walking pd->status.speed = pd->petDB->speed; @@ -2189,10 +2188,10 @@ int status_calc_pet_(struct pet_data *pd, bool first) lv =sd->status.base_level*battle_config.pet_lv_rate/100; if (lv < 0) lv = 1; - if (lv != pd->pet.level || first) { + if (lv != pd->pet.level || opt&SCO_FIRST) { struct status_data *bstat = &pd->db->status, *pstatus = &pd->status; pd->pet.level = lv; - if (!first) //Lv Up animation + if (! (opt&SCO_FIRST) ) //Lv Up animation clif->misceffect(&pd->bl, 0); pstatus->rhw.atk = (bstat->rhw.atk*lv)/pd->db->lv; pstatus->rhw.atk2 = (bstat->rhw.atk2*lv)/pd->db->lv; @@ -2214,10 +2213,10 @@ int status_calc_pet_(struct pet_data *pd, bool first) status->calc_misc(&pd->bl, &pd->status, lv); - if (!first) //Not done the first time because the pet is not visible yet + if (! (opt&SCO_FIRST) ) //Not done the first time because the pet is not visible yet clif->send_petstatus(sd); } - } else if (first) { + } else if ( opt&SCO_FIRST ) { status->calc_misc(&pd->bl, &pd->status, pd->db->lv); if (!battle_config.pet_lv_rate && pd->pet.level != pd->db->lv) pd->pet.level = pd->db->lv; @@ -2295,7 +2294,7 @@ unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct status_dat //Calculates player data from scratch without counting SC adjustments. //Should be invoked whenever players raise stats, learn passive skills or change equipment. -int status_calc_pc_(struct map_session_data* sd, bool first) { +int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { static int calculating = 0; //Check for recursive call preemption. [Skotlex] struct status_data *bstatus; // pointer to the player's base status const struct status_change *sc = &sd->sc; @@ -2317,7 +2316,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { sd->max_weight = status->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300; - if(first) { + if(opt&SCO_FIRST) { //Load Hp/SP from char-received data. sd->battle_status.hp = sd->status.hp; sd->battle_status.sp = sd->status.sp; @@ -2482,7 +2481,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { bstatus->def += sd->inventory_data[index]->def; - if(first && sd->inventory_data[index]->equip_script) + if(opt&SCO_FIRST && sd->inventory_data[index]->equip_script) { //Execute equip-script on login script->run(sd->inventory_data[index]->equip_script,0,sd->bl.id,0); if (!calculating) @@ -2625,7 +2624,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if( k < map->list[sd->bl.m].zone->disabled_items_count ) continue; - if(first && data->equip_script) {//Execute equip-script on login + if(opt&SCO_FIRST && data->equip_script) {//Execute equip-script on login script->run(data->equip_script,0,sd->bl.id,0); if (!calculating) return 1; @@ -3135,11 +3134,11 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { return 0; } -int status_calc_mercenary_(struct mercenary_data *md, bool first) { +int status_calc_mercenary_(struct mercenary_data *md, enum e_status_calc_opt opt) { struct status_data *mstatus = &md->base_status; struct s_mercenary *merc = &md->mercenary; - if( first ) { + if( opt&SCO_FIRST ) { memcpy(mstatus, &md->db->status, sizeof(struct status_data)); mstatus->mode = MD_CANMOVE|MD_CANATTACK; mstatus->hp = mstatus->max_hp; @@ -3154,7 +3153,7 @@ int status_calc_mercenary_(struct mercenary_data *md, bool first) { return 0; } -int status_calc_homunculus_(struct homun_data *hd, bool first) { +int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) { struct status_data *hstatus = &hd->base_status; struct s_homunculus *hom = &hd->homunculus; int skill_lv; @@ -3167,7 +3166,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { hstatus->int_ = hom->int_ / 10; hstatus->luk = hom->luk / 10; - if (first) { //[orn] + if ( opt&SCO_FIRST ) { //[orn] const struct s_homunculus_db *db = hd->homunculusDB; hstatus->def_ele = db->element; hstatus->ele_lv = 1; @@ -3207,7 +3206,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { if((skill_lv = homun->checkskill(hd,HLIF_BRAIN)) > 0) hstatus->max_sp += (1 +skill_lv/2 -skill_lv/4 +skill_lv/5) * hstatus->max_sp / 100; - if (first) { + if ( opt&SCO_FIRST ) { hd->battle_status.hp = hom->hp; hd->battle_status.sp = hom->sp; } @@ -3231,7 +3230,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) { return 1; } -int status_calc_elemental_(struct elemental_data *ed, bool first) { +int status_calc_elemental_(struct elemental_data *ed, enum e_status_calc_opt opt) { struct status_data *estatus = &ed->base_status; struct s_elemental *ele = &ed->elemental; struct map_session_data *sd = ed->master; @@ -3239,7 +3238,7 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { if( !sd ) return 0; - if( first ) { + if( opt&SCO_FIRST ) { memcpy(estatus, &ed->db->status, sizeof(struct status_data)); if( !ele->mode ) estatus->mode = EL_MODE_PASSIVE; @@ -3270,13 +3269,13 @@ int status_calc_elemental_(struct elemental_data *ed, bool first) { return 0; } -int status_calc_npc_(struct npc_data *nd, bool first) { +int status_calc_npc_(struct npc_data *nd, enum e_status_calc_opt opt) { struct status_data *nstatus = &nd->status; if (!nd) return 0; - if (first) { + if ( opt&SCO_FIRST ) { nstatus->hp = 1; nstatus->sp = 1; nstatus->max_hp = 1; @@ -3863,13 +3862,17 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { /// Also sends updates to the client wherever applicable. /// @param flag bitfield of values from enum scb_flag /// @param first if true, will cause status_calc_* functions to run their base status initialization code -void status_calc_bl_(struct block_list *bl, enum scb_flag flag, bool first) { +void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_calc_opt opt) { struct status_data bst; // previous battle status struct status_data *st; // pointer to current battle status if( bl->type == BL_PC && ((TBL_PC*)bl)->delayed_damage != 0 ) { - ((TBL_PC*)bl)->state.hold_recalc = 1; - return; + if( opt&SCO_FORCE ) + ((TBL_PC*)bl)->state.hold_recalc = 0;/* clear and move on */ + else { + ((TBL_PC*)bl)->state.hold_recalc = 1;/* flag and stop */ + return; + } } // remember previous values @@ -3878,25 +3881,25 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, bool first) { if( flag&SCB_BASE ) {// calculate the object's base status too switch( bl->type ) { - case BL_PC: status->calc_pc_(BL_CAST(BL_PC,bl), first); break; - case BL_MOB: status->calc_mob_(BL_CAST(BL_MOB,bl), first); break; - case BL_PET: status->calc_pet_(BL_CAST(BL_PET,bl), first); break; - case BL_HOM: status->calc_homunculus_(BL_CAST(BL_HOM,bl), first); break; - case BL_MER: status->calc_mercenary_(BL_CAST(BL_MER,bl), first); break; - case BL_ELEM: status->calc_elemental_(BL_CAST(BL_ELEM,bl), first); break; - case BL_NPC: status->calc_npc_(BL_CAST(BL_NPC,bl), first); break; + case BL_PC: status->calc_pc_(BL_CAST(BL_PC,bl), opt); break; + case BL_MOB: status->calc_mob_(BL_CAST(BL_MOB,bl), opt); break; + case BL_PET: status->calc_pet_(BL_CAST(BL_PET,bl), opt); break; + case BL_HOM: status->calc_homunculus_(BL_CAST(BL_HOM,bl), opt); break; + case BL_MER: status->calc_mercenary_(BL_CAST(BL_MER,bl), opt); break; + case BL_ELEM: status->calc_elemental_(BL_CAST(BL_ELEM,bl), opt); break; + case BL_NPC: status->calc_npc_(BL_CAST(BL_NPC,bl), opt); break; } } if( bl->type == BL_PET ) return; // pets are not affected by statuses - if( first && bl->type == BL_MOB ) + if( opt&SCO_FIRST && bl->type == BL_MOB ) return; // assume there will be no statuses active status->calc_bl_main(bl, flag); - if( first && bl->type == BL_HOM ) + if( opt&SCO_FIRST && bl->type == BL_HOM ) return; // client update handled by caller // compare against new values and send client updates diff --git a/src/map/status.h b/src/map/status.h index 254f3bfab..e588fbb3f 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1627,6 +1627,12 @@ enum e_regen { RGN_SSP = 0x08, }; +enum e_status_calc_opt { + SCO_NONE = 0x0, + SCO_FIRST = 0x1, /* trigger the calculations that should take place only onspawn/once */ + SCO_FORCE = 0x2, /* only relevant to BL_PC types, ensures call bypasses the queue caused by delayed damage */ +}; + //Define to determine who gets HP/SP consumed on doing skills/etc. [Skotlex] #define BL_CONSUME (BL_PC|BL_HOM|BL_MER|BL_ELEM) //Define to determine who has regen @@ -1810,14 +1816,14 @@ struct status_change { #define status_change_end(bl,type,tid) status->change_end_(bl,type,tid,__FILE__,__LINE__) -#define status_calc_bl(bl, flag) status->calc_bl_(bl, (enum scb_flag)(flag), false) -#define status_calc_mob(md, first) status->calc_bl_(&(md)->bl, SCB_ALL, first) -#define status_calc_pet(pd, first) status->calc_bl_(&(pd)->bl, SCB_ALL, first) -#define status_calc_pc(sd, first) status->calc_bl_(&(sd)->bl, SCB_ALL, first) -#define status_calc_homunculus(hd, first) status->calc_bl_(&(hd)->bl, SCB_ALL, first) -#define status_calc_mercenary(md, first) status->calc_bl_(&(md)->bl, SCB_ALL, first) -#define status_calc_elemental(ed, first) status->calc_bl_(&(ed)->bl, SCB_ALL, first) -#define status_calc_npc(nd, first) status->calc_bl_(&(nd)->bl, SCB_ALL, first) +#define status_calc_bl(bl, flag) status->calc_bl_(bl, (enum scb_flag)(flag), SCO_NONE) +#define status_calc_mob(md, opt) status->calc_bl_(&(md)->bl, SCB_ALL, opt) +#define status_calc_pet(pd, opt) status->calc_bl_(&(pd)->bl, SCB_ALL, opt) +#define status_calc_pc(sd, opt) status->calc_bl_(&(sd)->bl, SCB_ALL, opt) +#define status_calc_homunculus(hd, opt) status->calc_bl_(&(hd)->bl, SCB_ALL, opt) +#define status_calc_mercenary(md, opt) status->calc_bl_(&(md)->bl, SCB_ALL, opt) +#define status_calc_elemental(ed, opt) status->calc_bl_(&(ed)->bl, SCB_ALL, opt) +#define status_calc_npc(nd, opt) status->calc_bl_(&(nd)->bl, SCB_ALL, opt) // bonus values and upgrade chances for refining equipment struct s_refine_info { @@ -1911,13 +1917,13 @@ struct status_interface { int (*change_timer_sub) (struct block_list* bl, va_list ap); int (*change_clear) (struct block_list* bl, int type); int (*change_clear_buffs) (struct block_list* bl, int type); - void (*calc_bl_) (struct block_list *bl, enum scb_flag flag, bool first); - int (*calc_mob_) (struct mob_data* md, bool first); - int (*calc_pet_) (struct pet_data* pd, bool first); - int (*calc_pc_) (struct map_session_data* sd, bool first); - int (*calc_homunculus_) (struct homun_data *hd, bool first); - int (*calc_mercenary_) (struct mercenary_data *md, bool first); - int (*calc_elemental_) (struct elemental_data *ed, bool first); + void (*calc_bl_) (struct block_list *bl, enum scb_flag flag, enum e_status_calc_opt opt); + int (*calc_mob_) (struct mob_data* md, enum e_status_calc_opt opt); + int (*calc_pet_) (struct pet_data* pd, enum e_status_calc_opt opt); + int (*calc_pc_) (struct map_session_data* sd, enum e_status_calc_opt opt); + int (*calc_homunculus_) (struct homun_data *hd, enum e_status_calc_opt opt); + int (*calc_mercenary_) (struct mercenary_data *md, enum e_status_calc_opt opt); + int (*calc_elemental_) (struct elemental_data *ed, enum e_status_calc_opt opt); void (*calc_misc) (struct block_list *bl, struct status_data *status, int level); void (*calc_regen) (struct block_list *bl, struct status_data *st, struct regen_data *regen); void (*calc_regen_rate) (struct block_list *bl, struct regen_data *regen, struct status_change *sc); @@ -1943,7 +1949,7 @@ struct status_interface { void (*calc_sigma) (void); unsigned int (*base_pc_maxhp) (struct map_session_data *sd, struct status_data *st); unsigned int (*base_pc_maxsp) (struct map_session_data *sd, struct status_data *st); - int (*calc_npc_) (struct npc_data *nd, bool first); + int (*calc_npc_) (struct npc_data *nd, enum e_status_calc_opt opt); unsigned short (*calc_str) (struct block_list *bl, struct status_change *sc, int str); unsigned short (*calc_agi) (struct block_list *bl, struct status_change *sc, int agi); unsigned short (*calc_vit) (struct block_list *bl, struct status_change *sc, int vit); -- cgit v1.2.3-70-g09d2 From 665f1306a130d4b8c359972bf4e58ef9d3bd9cd8 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Wed, 6 Nov 2013 20:28:45 -0200 Subject: Fixed Bug 7799 SC_MOONSTAR, SC_SUPER_STAR are no longer removeable by sc_end all, and sc clear. Modified sc_config.txt, added a new flag (0x80/128) for such cases. http://hercules.ws/board/tracker/issue-7799-sc-moonstar/ Special Thanks to kyeme. Signed-off-by: shennetsind <ind@henn.et> --- db/const.txt | 2 ++ db/sc_config.txt | 18 +++++++++++------- src/map/script.c | 11 ++--------- src/map/status.c | 13 ++----------- src/map/status.h | 15 ++++++++------- 5 files changed, 25 insertions(+), 34 deletions(-) (limited to 'src/map') diff --git a/db/const.txt b/db/const.txt index cdb000417..ddc4a188a 100644 --- a/db/const.txt +++ b/db/const.txt @@ -1242,6 +1242,8 @@ SC_KINGS_GRACE 557 SC_TELEKINESIS_INTENSE 558 SC_OFFERTORIUM 559 SC_FRIGG_SONG 560 +SC_ALL_RIDING 561 +SC_HANBOK 562 SC_MONSTER_TRANSFORM 563 SC_ANGEL_PROTECT 564 SC_ILLUSIONDOPING 565 diff --git a/db/sc_config.txt b/db/sc_config.txt index 9e0b8b268..38e10e4c2 100644 --- a/db/sc_config.txt +++ b/db/sc_config.txt @@ -10,6 +10,7 @@ // 16 - SC considered as buff and be removed by Hermode and etc. // 32 - SC considered as debuff and be removed by Gospel and etc. // 64 - SC cannot be reset when MADO Gear is taken off. +// 128 - SC cannot be reset by sc_end and change clear. //Example: //SC_ENDURE, 21 //SC_ENDURE: cannot be removed by death and dispell and cosidered as buff. (16 + 4 + 1 = 21) @@ -395,12 +396,12 @@ SC_SOULCOLD,78 SC_HAWKEYES,78 // Unremovable -SC_WEIGHTOVER50, 79 -SC_WEIGHTOVER90, 79 +SC_WEIGHTOVER50, 207 +SC_WEIGHTOVER90, 207 SC_WEDDING, 77 SC_XMAS, 77 SC_SUMMER, 77 -SC_NOCHAT, 77 +SC_NOCHAT, 205 SC_FUSION, 77 SC_EARTHSCROLL, 77 SC_STORMKICK_READY, 77 @@ -408,7 +409,7 @@ SC_DOWNKICK_READY, 77 SC_COUNTERKICK_READY, 77 SC_TURNKICK_READY, 77 SC_DODGE_READY, 77 -SC_JAILED, 77 +SC_JAILED, 205 SC_AUTOTRADE, 77 SC_WHISTLE, 79 SC_ASSNCROS, 79 @@ -419,6 +420,9 @@ SC_DONTFORGETME, 79 SC_FORTUNE, 79 SC_SERVICEFORYOU, 79 SC_INCHIT, 77 -SC_PUSH_CART, 0x4D -SC_MOONSTAR, 79 -SC_SUPER_STAR, 79 +SC_PUSH_CART, 205 +SC_MOONSTAR, 207 +SC_SUPER_STAR, 207 + +//Cant Clear +SC_ALL_RIDING, 128 \ No newline at end of file diff --git a/src/map/script.c b/src/map/script.c index 8fd7f425c..a944447e2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9425,15 +9425,8 @@ BUILDIN(sc_end) { if (!sce) return true; - switch (type) { - case SC_WEIGHTOVER50: - case SC_WEIGHTOVER90: - case SC_NOCHAT: - case SC_PUSH_CART: - return true; - default: - break; - } + if( status->get_sc_type(type)&SC_NO_CLEAR ) + return true; //This should help status_change_end force disabling the SC in case it has no limit. sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0; diff --git a/src/map/status.c b/src/map/status.c index 1df98a957..e2cc39a70 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -9223,17 +9223,8 @@ int status_change_clear(struct block_list* bl, int type) { } } } - if( type == 3 ) { - switch (i) {// TODO: This list may be incomplete - case SC_WEIGHTOVER50: - case SC_WEIGHTOVER90: - case SC_NOCHAT: - case SC_PUSH_CART: - case SC_JAILED: - case SC_ALL_RIDING: - continue; - } - } + if( type == 3 && status->get_sc_type(i)&SC_NO_CLEAR ) + continue; status_change_end(bl, (sc_type)i, INVALID_TIMER); diff --git a/src/map/status.h b/src/map/status.h index e588fbb3f..784c8ca5f 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -34,13 +34,14 @@ enum refine_type { }; typedef enum sc_conf_type { - SC_NO_REM_DEATH = 0x1, - SC_NO_SAVE = 0x2, - SC_NO_DISPELL = 0x4, - SC_NO_CLEARANCE = 0x8, - SC_BUFF = 0x10, - SC_DEBUFF = 0x20, - SC_MADO_NO_RESET = 0x40 + SC_NO_REM_DEATH = 0x01, + SC_NO_SAVE = 0x02, + SC_NO_DISPELL = 0x04, + SC_NO_CLEARANCE = 0x08, + SC_BUFF = 0x10, + SC_DEBUFF = 0x20, + SC_MADO_NO_RESET = 0x40, + SC_NO_CLEAR = 0x80, } sc_conf_type; // Status changes listing. These code are for use by the server. -- cgit v1.2.3-70-g09d2 From eaf04b9a2f0b399027df251c5d19d58d74e24e6a Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Wed, 6 Nov 2013 21:10:05 -0200 Subject: BG Queue Update Enabled Party/Guild joining methods, Implements first attempt at the splitting algorithm (Thanks to jaBote!) Checks item 1 on issue #69 Help us test! -- http://hercules.ws/board/topic/1302-bg-queue-debug/ Signed-off-by: shennetsind <ind@henn.et> --- npc/custom/bgqueue/flavius.txt | 90 ++++++++++++++++++++++++++++++++++++------ src/map/battleground.c | 39 ++++++++++++++---- src/map/battleground.h | 9 +++-- src/map/clif.c | 6 +-- src/map/party.c | 2 +- 5 files changed, 120 insertions(+), 26 deletions(-) (limited to 'src/map') diff --git a/npc/custom/bgqueue/flavius.txt b/npc/custom/bgqueue/flavius.txt index b3db9f81d..45b261175 100644 --- a/npc/custom/bgqueue/flavius.txt +++ b/npc/custom/bgqueue/flavius.txt @@ -3,7 +3,7 @@ //===== By: ================================================== //= L0ne_W0lf //===== Current Version: ===================================== -//= 1.4 +//= 1.5 //===== Description: ========================================= //= [AEGIS Conversion] //= Flavius Battleground. @@ -15,6 +15,7 @@ //= 1.2 Updated 'waitingroom' to support required zeny/lvl. [Kisuka] //= 1.3 Removed MaxLvl check in waitingrooms. Replaced setwall with setcell. //= 1.4 Attempt at implementing BG Queue [Ind/Hercules] +//= 1.5 Attempt at implementing BG Queue team-algorithm [jaBote] //============================================================ @@ -36,20 +37,87 @@ OnPlayerListReady: queueopt($@Guill_QueueBG1,HQO_OnLogout,"start#bat_b01::OnGuillaumeQuit"); queueopt($@Croix_QueueBG1,HQO_OnLogout,"start#bat_b01::OnCroixQuit"); - set .@it,queueiterator($@bg_queue_id); set .@i, 0; - for( set .@member, qiget(.@it); qicheck(.@it); set .@member,qiget(.@it) ) { - if( .@i % 2 == 0 ) { - bg_join_team($@FlaviusBG1_id1,.@member); - queueadd($@Guill_QueueBG1,.@member); - } else { - bg_join_team($@FlaviusBG1_id2,.@member); - queueadd($@Croix_QueueBG1,.@member); + copyarray .@bg_member[0],$@bg_member[0],$@bg_member_size; + copyarray .@bg_member_group[0],$@bg_member_group[0],$@bg_member_size; + copyarray .@bg_member_type[0],$@bg_member_type[0],$@bg_member_size; + + freeloop(1); + // Counting all participants and determining sizes, condensing .@bg_member_group + set .@nogroupcount, 0; + for (set .@i, 0; .@i < getarraysize(.@bg_member); set .@i, .@i + 1) { + // check if .@bg_member_group and .@bg_member_type already exists on these groups. + for (set .@j, 0; .@j <= getarraysize(.@bg_groups); set .@j, .@j + 1) { // <= since it has to start working even if the array is still blank + if (.@bg_member_group[.@i] == 0) { // Just count them + set .@nogroupcount, .@nogroupcount + 1; + break; + } + else if ( (.@bg_member_group[.@i] == .@bg_groups[.@j]) && (.@bg_member_type[.@i] == .@bg_types[.@j]) ) { + set .@bg_count[.@j], .@bg_count[.@j] + 1; + break; + } + else if (.@j == (getarraysize(.@bg_groups)) ) { // It isn't there, insert a new entry at j+1 since j is the last known member + set .@bg_groups[.@j], .@bg_member_group[.@i]; + set .@bg_types[.@j], .@bg_member_type[.@i]; + set .@bg_count[.@j], 1; + break; + } + // Else keep running the loop until we find there's a group already made or make a new one + } + } + + // Now, sorting the group arrays from amount of population descending! Bubble sort powers, I call upon thee! + // Type doesn't matter here for precedence checks, but also needs to be sorted the same way along with groups + for (set .@i, 0; .@i < getarraysize(.@bg_groups); set .@i, .@i + 1) { + for (set .@j, 0; .@j < (getarraysize(.@bg_groups) - .@i); set .@j, .@j + 1) { + if (.@bg_count[.@j] < .@bg_count[.@j+1]){ + set .@temp1, .@bg_groups[.@j]; + set .@temp2, .@bg_types[.@j]; + set .@temp3, .@bg_count[.@j]; + set .@bg_groups[.@j], .@bg_groups[.@j+1]; + set .@bg_types[.@j], .@bg_types[.@j+1]; + set .@bg_count[.@j], .@bg_count[.@j+1]; + set .@bg_groups[.@j+1], .@temp1; + set .@bg_types[.@j+1], .@temp2; + set .@bg_count[.@j+1], .@temp3; + } + } + } + + // Add the groups to the queues! :D + for (set .@i, 0; .@i < getarraysize(.@bg_groups); set .@i, .@i + 1){ + if (queuesize($@Croix_QueueBG1) <= queuesize($@Guill_QueueBG1)){ // Catch'em all and add to the queue! + for (set .@j, 0; .@j < getarraysize(.@bg_member); set .@j, .@j + 1) { + if ( (.@bg_groups[.@i] == .@bg_member_group[.@j]) && (.@bg_types[.@i] == .@bg_member_type[.@j]) ) { + bg_join_team($@FlaviusBG1_id1,.@bg_member[.@j]); + queueadd($@Croix_QueueBG1, .@bg_member[.@j]); + } + } + } + else { + for (set .@j, 0; .@j < getarraysize(.@bg_member); set .@j, .@j + 1) { + if ( (.@bg_groups[.@i] == .@bg_member_group[.@j]) && (.@bg_types[.@i] == .@bg_member_type[.@j]) ) { + bg_join_team($@FlaviusBG1_id2,.@bg_member[.@j]); + queueadd($@Guill_QueueBG1, .@bg_member[.@j]); + } + } + } + } + // Don't forget the people that go on their own! + for (set .@i, 0; .@i <= getarraysize(.@bg_member); set .@i, .@i+1) { + if (.@bg_member_group[.@i] == 0) { // Get alone people only + if (queuesize($@Croix_QueueBG1) <= queuesize($@Guill_QueueBG1)) { + bg_join_team($@FlaviusBG1_id1,.@bg_member[.@i]); + queueadd($@Croix_QueueBG1, .@bg_member[.@i]); + } + else { + bg_join_team($@FlaviusBG1_id2,.@bg_member[.@i]); + queueadd($@Guill_QueueBG1, .@bg_member[.@i]); + } } - set .@i,.@i + 1; } - qiclear(.@it); + freeloop(0); set $@FlaviusBG1, 1; set $@FlaviusBG1_Victory, 0; diff --git a/src/map/battleground.c b/src/map/battleground.c index 62688659e..84b41af29 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -520,13 +520,43 @@ void bg_begin(struct bg_arena *arena) { bg->queue_pc_cleanup(sd); } } + /* TODO/FIXME? I *think* it should check what kind of queue the player used, then check if his party/guild + * (his team) still meet the join criteria (sort of what bg->can_queue does) + */ if( count < arena->min_players ) { bg->match_over(arena,true); } else { arena->ongoing = true; - mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */ + /* TODO: make this a arena-independant var? or just .@? */ + mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id); mapreg->setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var); + + count = 0; + for( i = 0; i < queue->size; i++ ) { + struct map_session_data * sd = NULL; + + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { + if( sd->bg_queue.ready == 1 ) { + + mapreg->setreg(reference_uid(script->add_str("$@bg_member"), count), sd->status.account_id); + + mapreg->setreg(reference_uid(script->add_str("$@bg_member_group"), count), + sd->bg_queue.type == BGQT_GUILD ? sd->status.guild_id : + sd->bg_queue.type == BGQT_PARTY ? sd->status.party_id : + 0 + ); + mapreg->setreg(reference_uid(script->add_str("$@bg_member_type"), count), + sd->bg_queue.type == BGQT_GUILD ? 1 : + sd->bg_queue.type == BGQT_PARTY ? 2 : + 0 + ); + count++; + } + } + } + mapreg->setreg(script->add_str("$@bg_member_size"),count); + npc->event_do(arena->npc_event); /* we split evenly? */ /* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */ @@ -685,12 +715,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ if( sd->bg_queue.arena != NULL ) return BGQA_DUPLICATE_REQUEST; - - if( type != BGQT_INDIVIDUAL ) {/* until we get the damn balancing correct */ - clif->colormes(sd->fd,COLOR_RED,"Queueing is only currently enabled only for Solo Mode"); - return BGQA_FAIL_TEAM_COUNT; - } - + switch(type) { case BGQT_GUILD: if( !sd->guild || !sd->state.gmaster_flag ) diff --git a/src/map/battleground.h b/src/map/battleground.h index a5e540924..4150de8be 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -19,10 +19,11 @@ * Enumerations **/ enum bg_queue_types { - BGQT_INVALID, - BGQT_INDIVIDUAL, - BGQT_PARTY, - BGQT_GUILD + BGQT_INVALID = 0x0, + BGQT_INDIVIDUAL = 0x1, + BGQT_PARTY = 0x2, + /* yup no 0x3 */ + BGQT_GUILD = 0x4, }; struct battleground_member_data { diff --git a/src/map/clif.c b/src/map/clif.c index 913a94058..f309a53a9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9213,7 +9213,9 @@ void clif_hercules_chsys_mjoin(struct map_session_data *sd) { /// Notification from the client, that it has finished map loading and is about to display player's character (CZ_NOTIFY_ACTORINIT). /// 007d void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { +#if PACKETVER >= 20090218 int i; +#endif if(sd->bl.prev != NULL) return; @@ -17572,9 +17574,7 @@ void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) { clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID,0); return; } - //debug - safestrncpy(arena->name, p->bg_name, sizeof(arena->name)); - + switch( (enum bg_queue_types)p->type ) { case BGQT_INDIVIDUAL: case BGQT_PARTY: diff --git a/src/map/party.c b/src/map/party.c index ab05c23f7..1f82028a8 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -849,7 +849,7 @@ int party_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { for( i = 0; i < MAX_PARTY; i++ ) { struct map_session_data* sd = p->data[i].sd; - if( !sd ) continue; + if( !sd || sd->bg_id ) continue; if( p->data[i].x != sd->bl.x || p->data[i].y != sd->bl.y ) {// perform position update -- cgit v1.2.3-70-g09d2