From 53e5fbb299a72bbdab9859e948aca3b355afeb1a Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Sat, 27 Apr 2013 19:11:33 -0300 Subject: Introduced support for /guildinvite (present in 2012+ clients). Also merged both guild invite functions. Signed-off-by: Matheus Macabu --- src/map/clif.c | 47 +++++++++++++++++++++++++++++++++-------------- src/map/clif.h | 1 + src/map/packets.h | 1 + 3 files changed, 35 insertions(+), 14 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index 10c1a0d47..50ac5f06d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6698,7 +6698,8 @@ void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int if(!sd && (flag&0xf0)==0) { int i; - for(i=0;idata[i].sd;i++); + for(i=0;idata[i].sd;i++) + ; if (i < MAX_PARTY) sd = p->data[i].sd; } @@ -12432,30 +12433,47 @@ void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd) guild_change_notice(sd, guild_id, msg1, msg2); } +// Helper function for guild invite functions +int +clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_data *t_sd) { + if (t_sd == NULL) {// not online or does not exist + return 1; + } + + if (map[sd->bl.m].flag.guildlock) { //Guild locked. + clif->message(fd, msg_txt(228)); + return 1; + } + + if (t_sd && t_sd->state.noask) {// @noask [LuzZza] + clif->noask_sub(sd, t_sd, 2); + return 1; + } + + guild_invite(sd,t_sd); + return 0; +} /// Guild invite request (CZ_REQ_JOIN_GUILD). /// 0168 .L .L .L void clif_parse_GuildInvite(int fd,struct map_session_data *sd) { - struct map_session_data *t_sd; + struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,2)); - if(map[sd->bl.m].flag.guildlock) { //Guild locked. - clif->message(fd, msg_txt(228)); + if (clif_sub_guild_invite(fd, sd, t_sd)) return; - } - - t_sd = map_id2sd(RFIFOL(fd,2)); +} - // @noask [LuzZza] - if(t_sd && t_sd->state.noask) { - clif->noask_sub(sd, t_sd, 2); +/// Guild invite request (/guildinvite) (CZ_REQ_JOIN_GUILD2). +/// 0916 .24B +void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) +{ + struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, 2)); + + if (clif_sub_guild_invite(fd, sd, t_sd)) return; - } - - guild_invite(sd,t_sd); } - /// Answer to guild invitation (CZ_JOIN_GUILD). /// 016b .L .L /// answer: @@ -17707,6 +17725,7 @@ void clif_defaults(void) { clif->pCashShopBuy = clif_parse_CashShopBuy; /* */ clif->pPartyTick = clif_parse_PartyTick; + clif->pGuildInvite2 = clif_parse_GuildInvite2; /* dull */ clif->pDull = clif_parse_dull; } diff --git a/src/map/clif.h b/src/map/clif.h index ae3fb9cd4..9dfa83e00 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1079,6 +1079,7 @@ struct clif_interface { void (*pCashShopSchedule) (int fd, struct map_session_data *sd); void (*pCashShopBuy) (int fd, struct map_session_data *sd); void (*pPartyTick) (int fd, struct map_session_data *sd); + void (*pGuildInvite2) (int fd, struct map_session_data *sd); } clif_s; struct clif_interface *clif; diff --git a/src/map/packets.h b/src/map/packets.h index c91028c13..edfa40c37 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -1994,6 +1994,7 @@ packet(0x020d,-1); packet(0x0368,6,clif->pSolveCharName,2); packet(0x08E5,41,clif->pPartyBookingRegisterReq,2,4); packet(0x08d2,10); + packet(0x0916,26,clif->pGuildInvite2,2); #endif //2012-06-18aRagexeRE -- cgit v1.2.3-70-g09d2 From c347ebacd8116b49e0e839abab1be35432ce0446 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Wed, 1 May 2013 21:00:06 -0300 Subject: Implemented "item_nouse.txt" to prevent players from using items under certain flags (which are pre-determined). Fixes issue:7064. Thanks to Muad_Dib for providing the item list for this db. Signed-off-by: Matheus Macabu --- db/item_nouse.txt | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/map/itemdb.c | 26 +++++++++++ src/map/itemdb.h | 8 ++++ src/map/pc.c | 4 ++ 4 files changed, 170 insertions(+) create mode 100644 db/item_nouse.txt (limited to 'src/map') diff --git a/db/item_nouse.txt b/db/item_nouse.txt new file mode 100644 index 000000000..2615d4f50 --- /dev/null +++ b/db/item_nouse.txt @@ -0,0 +1,132 @@ +// Item Usage Restriction Configuration File +// Defines if an item cannot be used under certain circumstances +// Syntax: , , +// flag: +// 1 = Cannot use item while sitting +// X = more to come soon [TODO] +// group_id_override: group id necessary to override this setting + +619,1,100 // Unripe_Apple +620,1,100 // Orange_Juice +621,1,100 // Bitter_Herb +622,1,100 // Rainbow_Carrot +623,1,100 // Earthworm_The_Dude +624,1,100 // Rotten_Fish +625,1,100 // Lusty_Iron +626,1,100 // Monster_Juice +627,1,100 // Sweet_Milk +628,1,100 // Well_Dried_Bone +629,1,100 // Singing_Flower +630,1,100 // Dew_Laden_Moss +631,1,100 // Deadly_Noxious_Herb +632,1,100 // Fatty_Chubby_Earthworm +633,1,100 // Baked_Yam +634,1,100 // Tropical_Banana +635,1,100 // Horror_Of_Tribe +636,1,100 // No_Recipient +637,1,100 // Old_Broom +638,1,100 // Silver_Knife_Of_Chaste +639,1,100 // Armlet_Of_Obedience +640,1,100 // Shining_Stone +641,1,100 // Contracts_In_Shadow +642,1,100 // Book_Of_Devil +659,1,100 // Heart_Of_Her +660,1,100 // Prohibition_Red_Candle +661,1,100 // Sway_Apron +686,1,100 // Earth_Scroll_1_3 +687,1,100 // Earth_Scroll_1_5 +688,1,100 // Cold_Scroll_1_3 +689,1,100 // Cold_Scroll_1_5 +690,1,100 // Fire_Scroll_1_3 +691,1,100 // Fire_Scroll_1_5 +692,1,100 // Wind_Scroll_1_3 +693,1,100 // Wind_Scroll_1_5 +694,1,100 // Ghost_Scroll_1_3 +695,1,100 // Ghost_Scroll_1_5 +696,1,100 // Fire_Scroll_2_1 +697,1,100 // Fire_Scroll_2_5 +698,1,100 // Fire_Scroll_3_1 +699,1,100 // Fire_Scroll_3_5 +700,1,100 // Cold_Scroll_2_1 +11702,1,100 // Moon_Cookie +12000,1,100 // Cold_Scroll_2_5 +12001,1,100 // Holy_Scroll_1_3 +12002,1,100 // Holy_Scroll_1_5 +12027,1,100 // Giggling_Box +12028,1,100 // Box_Of_Thunder +12029,1,100 // Gloomy_Box +12030,1,100 // Box_Of_Grudge +12031,1,100 // Sleepy_Box +12032,1,100 // Box_Of_Storm +12033,1,100 // Box_Of_Sunlight +12034,1,100 // Painting_Box +12215,1,100 // Blessing_10_Scroll +12216,1,100 // Inc_Agi_10_Scroll +12217,1,100 // Aspersio_5_Scroll +12218,1,100 // Assumptio_5_Scroll +12219,1,100 // Wind_Walk_10_Scroll +12220,1,100 // Adrenaline_Scroll +12225,1,100 // Sweet_Candy_Striper +12235,1,100 // Strawberry_Choco +12236,1,100 // Choco_Tart +12237,1,100 // Choco_Lump +12290,1,100 // Mysterious_Can +12291,1,100 // Mysterious_PET_Bottle +12310,1,100 // Spray_Of_Flowers +12311,1,100 // Large_Spray_Of_Flowers +12313,1,100 // Protection_Of_Angel +12323,1,100 // N_Fly_Wing +12324,1,100 // N_Butterfly_Wing +12325,1,100 // N_Magnifier +12340,1,100 // Mysterious_Rice_Powder +12347,1,100 // Acorn_Jelly +12350,1,100 // Angeling_Potion +12358,1,100 // Fan_Of_Wind +12359,1,100 // Very_Soft_Plant +12360,1,100 // Very_Red_Juice +12361,1,100 // Delicious_Shaved_Ice +12362,1,100 // Kuloren +12363,1,100 // Fit_Pipe +12364,1,100 // Staff_Of_Leader +12365,1,100 // Charming_Lotus +12366,1,100 // Gril_Doll +12367,1,100 // Luxury_Whisky_Bottle +12368,1,100 // Splendid_Mirror +12369,1,100 // Oilpalm_Coconut +12370,1,100 // Gril's_Naivety +12371,1,100 // Magical_Lithography +12372,1,100 // Hell_Contract +12373,1,100 // Boy's_Naivety +12374,1,100 // Flaming_Ice +12376,1,100 // Mysterious_Can2 +12377,1,100 // Mysterious_PET_Bottle2 +12388,1,100 // Runstone_Crush +12389,1,100 // Runstone_Storm +12390,1,100 // Runstone_Millennium +12396,1,100 // Fools_Day_Box +12397,1,100 // Fools_Day_Box2 +12415,1,100 // Siege_Teleport_Scroll2 +12473,1,100 // RWC_Parti_Box +12474,1,100 // RWC_Final_Comp_Box +12706,1,100 // Lucky_Cookie01 +12707,1,100 // Lucky_Cookie02 +12708,1,100 // Lucky_Cookie03 +12725,1,100 // Runstone_Nosiege +12726,1,100 // Runstone_Rhydo +12727,1,100 // Runstone_Verkana +12728,1,100 // Runstone_Isia +12729,1,100 // Runstone_Asir +12730,1,100 // Runstone_Urj +12731,1,100 // Runstone_Turisus +12732,1,100 // Runstone_Pertz +12733,1,100 // Runstone_Hagalas +14521,1,100 // Repair_Scroll +14529,1,100 // Greed_Scroll +14532,1,100 // Battle_Manual25 +14587,1,100 // Repair_Scroll_ +14591,1,100 // Siege_Teleport_Scroll +14592,1,100 // Job_Manual50 +14593,1,100 // Magic_Power_Scroll +14594,1,100 // Quagmire_Scroll +14599,1,100 // Greed_Scroll_C +14606,1,100 // Job_Manual25 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 386f38c5a..0b4419e0c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -727,6 +727,31 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current) return true; } + +/******************************************* +** Item usage restriction (item_nouse.txt) +********************************************/ +static bool itemdb_read_nouse(char* fields[], int columns, int current) +{// ,, + int nameid, flag, override; + struct item_data* id; + + nameid = atoi(fields[0]); + + if( ( id = itemdb_exists(nameid) ) == NULL ) { + ShowWarning("itemdb_read_nouse: Invalid item id %d.\n", nameid); + return false; + } + + flag = atoi(fields[1]); + override = atoi(fields[2]); + + id->item_usage.flag = flag; + id->item_usage.override = override; + + return true; +} + /** * @return: amount of retrieved entries. **/ @@ -1304,6 +1329,7 @@ static void itemdb_read(void) { sv_readdb(db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); sv_readdb(db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack); sv_readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); + sv_readdb(db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); itemdb_uid_load(); } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 362b42cff..c441de26a 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -68,6 +68,10 @@ enum { ITEMID_SPECIAL_COOLER, } mecha_item_list; +enum { + NOUSE_SITTING = 0x01, +} item_nouse_list; + //The only item group required by the code to be known. See const.txt for the full list. #define IG_FINDINGORE 6 #define IG_POTION 37 @@ -136,6 +140,10 @@ struct item_data { unsigned int storage:1; unsigned int guildstorage:1; } stack; + struct {// used by item_nouse.txt + unsigned int flag; + unsigned short override; + } item_usage; short gm_lv_trade_override; //GM-level to override trade_restriction /* bugreport:309 */ struct item_combo **combos; diff --git a/src/map/pc.c b/src/map/pc.c index afc92594b..892c27e87 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4086,6 +4086,10 @@ int pc_isUseitem(struct map_session_data *sd,int n) if( !item->script ) //if it has no script, you can't really consume it! return 0; + if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) { + return 0; // You cannot use this item while sitting. + } + switch( nameid ) //@TODO, lot oh harcoded nameid here { case 605: // Anodyne -- cgit v1.2.3-70-g09d2