本文整理汇总了C++中pc_get_group_level函数的典型用法代码示例。如果您正苦于以下问题:C++ pc_get_group_level函数的具体用法?C++ pc_get_group_level怎么用?C++ pc_get_group_level使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pc_get_group_level函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mail_setitem
/**
* Attempt to set item or zeny to a mail
* @param sd : player attaching the content
* @param idx 0 - Zeny; >= 2 - Inventory item
* @param amount : amout of zeny or number of item
* @return True if item/zeny can be set, False if failed
*/
bool mail_setitem(struct map_session_data *sd, short idx, uint32 amount) {
if( pc_istrading(sd) )
return false;
if( idx == 0 ) { // Zeny Transfer
if( !pc_can_give_items(sd) )
return false;
if( amount > sd->status.zeny )
amount = sd->status.zeny;
sd->mail.zeny = amount;
// clif_updatestatus(sd, SP_ZENY);
return true;
} else { // Item Transfer
idx -= 2;
mail_removeitem(sd, 0);
if( idx < 0 || idx >= MAX_INVENTORY )
return false;
if( amount > sd->status.inventory[idx].amount )
return false;
if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time
|| !itemdb_available(sd->status.inventory[idx].nameid)
|| !itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd))
|| (sd->status.inventory[idx].bound && !pc_can_give_bounded_items(sd)) )
return false;
sd->mail.index = idx;
sd->mail.nameid = sd->status.inventory[idx].nameid;
sd->mail.amount = amount;
return true;
}
}
开发者ID:544a,项目名称:rathena,代码行数:42,代码来源:mail.c
示例2: mail_setitem
unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) {
if( pc_istrading(sd) )
return 1;
if( idx == 0 ) { // Zeny Transfer
if( amount < 0 || !pc_can_give_items(sd) )
return 1;
if( amount > sd->status.zeny )
amount = sd->status.zeny;
sd->mail.zeny = amount;
// clif->updatestatus(sd, SP_ZENY);
return 0;
} else { // Item Transfer
idx -= 2;
mail->removeitem(sd, 0);
if( idx < 0 || idx >= MAX_INVENTORY )
return 1;
if( amount < 0 || amount > sd->status.inventory[idx].amount )
return 1;
if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
!itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd)) ||
(sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) )
return 1;
sd->mail.index = idx;
sd->mail.nameid = sd->status.inventory[idx].nameid;
sd->mail.amount = amount;
return 0;
}
}
开发者ID:AbbottWC,项目名称:Hercules,代码行数:35,代码来源:mail.c
示例3: guild_storage_additem
/**
* Attempt to add an item in guild storage, then refresh it
* @param sd : player attempting to open the guild_storage
* @param stor : guild_storage
* @param item_data : item to add
* @param amount : number of item to add
* @return 0 : success, 1 : fail
*/
char guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount)
{
struct item_data *data;
int i;
nullpo_retr(1, sd);
nullpo_retr(1, stor);
nullpo_retr(1, item_data);
if(item_data->nameid == 0 || amount <= 0)
return 1;
data = itemdb_search(item_data->nameid);
if( data->stack.guildstorage && amount > data->stack.amount )
{// item stack limitation
return 1;
}
if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time )
{ //Check if item is storable. [Skotlex]
clif_displaymessage (sd->fd, msg_txt(sd,264));
return 1;
}
if( (item_data->bound == BOUND_ACCOUNT || item_data->bound > BOUND_GUILD) && !pc_can_give_bounded_items(sd) ) {
clif_displaymessage(sd->fd, msg_txt(sd,294));
return 1;
}
if(itemdb_isstackable2(data)){ //Stackable
for(i=0;i<MAX_GUILD_STORAGE;i++){
if(compare_item(&stor->items[i], item_data)) {
if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.guildstorage && amount > data->stack.amount - stor->items[i].amount ) )
return 1;
stor->items[i].amount+=amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
stor->dirty = 1;
return 0;
}
}
}
//Add item
for(i=0;i<MAX_GUILD_STORAGE && stor->items[i].nameid;i++);
if(i>=MAX_GUILD_STORAGE)
return 1;
memcpy(&stor->items[i],item_data,sizeof(stor->items[0]));
stor->items[i].amount=amount;
stor->storage_amount++;
clif_storageitemadded(sd,&stor->items[i],i,amount);
clif_updatestorageamount(sd, stor->storage_amount, MAX_GUILD_STORAGE);
stor->dirty = 1;
return 0;
}
开发者ID:Escada28,项目名称:rathena,代码行数:64,代码来源:storage.c
示例4: storage_additem
/**
* Make a player add an item to his storage
* @param sd : player
* @param item_data : item to add
* @param amount : quantity of items
* @return 0:success, 1:failed
*/
static int storage_additem(struct map_session_data* sd, struct item* item_data, int amount)
{
struct storage_data* stor = &sd->status.storage;
struct item_data *data;
int i;
if( item_data->nameid == 0 || amount <= 0 )
return 1;
data = itemdb_search(item_data->nameid);
if( data->stack.storage && amount > data->stack.amount )
{// item stack limitation
return 1;
}
if( !itemdb_canstore(item_data, pc_get_group_level(sd)) )
{ //Check if item is storable. [Skotlex]
clif_displaymessage (sd->fd, msg_txt(sd,264));
return 1;
}
if( (item_data->bound > BOUND_ACCOUNT) && !pc_can_give_bounded_items(sd) ) {
clif_displaymessage(sd->fd, msg_txt(sd,294));
return 1;
}
if( itemdb_isstackable2(data) )
{//Stackable
for( i = 0; i < sd->storage_size; i++ )
{
if( compare_item(&stor->items[i], item_data) )
{// existing items found, stack them
if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.storage && amount > data->stack.amount - stor->items[i].amount ) )
return 1;
stor->items[i].amount += amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
return 0;
}
}
}
// find free slot
ARR_FIND( 0, sd->storage_size, i, stor->items[i].nameid == 0 );
if( i >= sd->storage_size )
return 1;
// add item to slot
memcpy(&stor->items[i],item_data,sizeof(stor->items[0]));
stor->storage_amount++;
stor->items[i].amount = amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
clif_updatestorageamount(sd, stor->storage_amount, sd->storage_size);
return 0;
}
开发者ID:Escada28,项目名称:rathena,代码行数:63,代码来源:storage.c
示例5: mail_setitem
/**
* Attempt to set item or zeny
* @param sd
* @param idx 0 - Zeny; >= 2 - Inventory item
* @param amount
* @return True if item/zeny can be set, False if failed
*/
bool mail_setitem(struct map_session_data *sd, short idx, int amount) {
if( sd->state.secure_items )
{
clif_displaymessage(sd->fd, "You can't attach. Blocked with @security");
return 1;
}
if( pc_istrading(sd) )
return false;
if( battle_config.super_woe_enable )
{
clif_displaymessage(sd->fd, "Super WoE don't allow send items/zeny with attachments");
return 1;
}
if( idx == 0 )
{ // Zeny Transfer
if( !pc_can_give_items(sd) )
return false;
if( amount > sd->status.zeny )
amount = sd->status.zeny;
sd->mail.zeny = amount;
// clif_updatestatus(sd, SP_ZENY);
return true;
} else { // Item Transfer
idx -= 2;
mail_removeitem(sd, 0);
if( idx < 0 || idx >= MAX_INVENTORY )
return false;
if( amount > sd->status.inventory[idx].amount )
return false;
if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time
|| !itemdb_available(sd->status.inventory[idx].nameid)
|| !itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd))
|| (sd->status.inventory[idx].bound && !pc_can_give_bounded_items(sd)) )
return false;
sd->mail.index = idx;
sd->mail.nameid = sd->status.inventory[idx].nameid;
sd->mail.amount = amount;
return true;
}
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:54,代码来源:mail.c
示例6: storage_additem
/*==========================================
* Internal add-item function.
*------------------------------------------*/
static int storage_additem(struct map_session_data* sd, struct item* item_data, int amount)
{
struct storage_data* stor = &sd->status.storage;
struct item_data *data;
int i;
if( item_data->nameid <= 0 || amount <= 0 )
return 1;
data = itemdb_search(item_data->nameid);
if( !itemdb_canstore(item_data, pc_get_group_level(sd)) )
{ //Check if item is storable. [Skotlex]
clif_displaymessage (sd->fd, msg_txt(264));
return 1;
}
if( itemdb_isstackable2(data) )
{//Stackable
for( i = 0; i < MAX_STORAGE; i++ )
{
if( compare_item(&stor->items[i], item_data) )
{// existing items found, stack them
if( amount > MAX_AMOUNT - stor->items[i].amount )
return 1;
stor->items[i].amount += amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
return 0;
}
}
}
// find free slot
ARR_FIND( 0, MAX_STORAGE, i, stor->items[i].nameid == 0 );
if( i >= MAX_STORAGE )
return 1;
// add item to slot
memcpy(&stor->items[i],item_data,sizeof(stor->items[0]));
stor->storage_amount++;
stor->items[i].amount = amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
clif_updatestorageamount(sd, stor->storage_amount, MAX_STORAGE);
return 0;
}
开发者ID:greenboxal,项目名称:Cronus-Emulator,代码行数:49,代码来源:storage.c
示例7: vending_openvending
/*==========================================
* Abrir loja
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count) {
int i, j;
int vending_skill_lvl;
nullpo_retv(sd);
if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd))
return; // nao pode abrir vendas deitado morto || não usou via habilidade (wpe/hack) || não pode ter 2 lojas ao mesmo tempo
vending_skill_lvl = pc->checkskill(sd, MC_VENDING);
// check de nivel de habilidade e carrinho
if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// checka numero de itens na loja
if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl ) {
// contagem de item invalida
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// filtrar itens invalidos
i = 0;
for( j = 0; j < count; j++ ) {
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
index -= 2; // ajuste de equilibrio (cliente diz que a posição do primeiro carrinho é 2)
if( index < 0 || index >= MAX_CART // posição inválida
|| pc->cartitem_amount(sd, index, amount) < 0 // item invalido ou quantidade insuficiente
//NOT: servidores oficiais não fazem nenhum dos checks abaixo!
|| !sd->status.cart[index].identify // item não-identficado
|| sd->status.cart[index].attribute == 1 // item quebrado
|| sd->status.cart[index].expire_time // Isso não deveria estar no carrinho mas apenas no caso de estar
|| (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // não pode trocar itens de recompensa, permissão w/o
|| !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // Itens não-trocaveis
continue;
sd->vending[i].index = index;
sd->vending[i].amount = amount;
sd->vending[i].value = cap_value(value, 0, (unsigned int)battle_config.vending_max_value);
i++; // item adicionado com sucesso
}
if( i != j )
clif->message (sd->fd, msg_txt(266)); //"Alguns dos seus itens não pode ser vendido e foram removidos da loja."
if( i == 0 ) { // nenhum item válido encontrado
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // packet de resposta personalizada
return;
}
sd->state.prevend = sd->state.workinprogress = 0;
sd->state.vending = true;
sd->vender_id = getid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
clif->openvending(sd,sd->bl.id,sd->vending);
clif->showvendingboard(&sd->bl,message,0);
idb_put(vending->db, sd->status.char_id, sd);
}
开发者ID:Cronus-Emulator,项目名称:Cronus,代码行数:70,代码来源:vending.c
示例8: buyingstore_trade
/**
* Start transaction
* @param sd Player/Seller
* @param account_id Buyer account ID
* @param *itemlist List of sold items { <index>.W, <nameid>.W, <amount>.W }*
* @param count Number of item on the itemlist
*/
void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count)
{
int zeny = 0;
unsigned int i, weight, listidx, k;
struct map_session_data* pl_sd;
nullpo_retv(sd);
if( count == 0 )
{// nothing to do
return;
}
if( !battle_config.feature_buying_store || pc_istrading(sd) )
{// not allowed to sell
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
if( !pc_can_give_items(sd) )
{// custom: GM is not allowed to sell
clif_displaymessage(sd->fd, msg_txt(sd,246));
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
if( ( pl_sd = map_id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id )
{// not online, not buying or not same store
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
if( !searchstore_queryremote(sd, account_id) && ( sd->bl.m != pl_sd->bl.m || !check_distance_bl(&sd->bl, &pl_sd->bl, AREA_SIZE) ) )
{// out of view range
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
searchstore_clearremote(sd);
if( pl_sd->status.zeny < pl_sd->buyingstore.zenylimit )
{// buyer lost zeny in the mean time? fix the limit
pl_sd->buyingstore.zenylimit = pl_sd->status.zeny;
}
weight = pl_sd->weight;
// check item list
for( i = 0; i < count; i++ )
{// itemlist: <index>.W <name id>.W <amount>.W
unsigned short nameid, amount;
int index;
index = RBUFW(itemlist,i*6+0)-2;
nameid = RBUFW(itemlist,i*6+2);
amount = RBUFW(itemlist,i*6+4);
if( i )
{// duplicate check. as the client does this too, only malicious intent should be caught here
ARR_FIND( 0, i, k, RBUFW(itemlist,k*6+0)-2 == index );
if( k != i )
{// duplicate
ShowWarning("buyingstore_trade: Found duplicate item on selling list (prevnameid=%hu, prevamount=%hu, nameid=%hu, amount=%hu, account_id=%d, char_id=%d).\n",
RBUFW(itemlist,k*6+2), RBUFW(itemlist,k*6+4), nameid, amount, sd->status.account_id, sd->status.char_id);
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
}
if( index < 0 || index >= ARRAYLENGTH(sd->status.inventory) || sd->inventory_data[index] == NULL || sd->status.inventory[index].nameid != nameid || sd->status.inventory[index].amount < amount )
{// invalid input
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
if( sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc_can_give_bounded_items(sd)) || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore_blankslots, sizeof(buyingstore_blankslots)) )
{// non-tradable item
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
ARR_FIND( 0, pl_sd->buyingstore.slots, listidx, pl_sd->buyingstore.items[listidx].nameid == nameid );
if( listidx == pl_sd->buyingstore.slots || pl_sd->buyingstore.items[listidx].amount == 0 )
{// there is no such item or the buyer has already bought all of them
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
if( pl_sd->buyingstore.items[listidx].amount < amount )
{// buyer does not need that much of the item
clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_COUNT, nameid);
return;
}
//.........这里部分代码省略.........
开发者ID:AsaK,项目名称:rathena,代码行数:101,代码来源:buyingstore.c
示例9: buyingstore_create
/**
* Attempt to create new buying store
* @param sd
* @param zenylimit
* @param result
* @param storename
* @param *itemlist { <nameid>.W, <amount>.W, <price>.L }*
* @param count Number of item on the itemlist
* @return 0 If success, 1 - Cannot open, 2 - Manner penalty, 3 - Mapflag restiction, 4 - Cell restriction, 5 - Invalid count/result, 6 - Cannot give item, 7 - Will be overweight
*/
char buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count)
{
unsigned int i, weight, listidx;
char message_sql[MESSAGE_SIZE*2];
nullpo_retr(1, sd);
if( !result || count == 0 )
{// canceled, or no items
return 5;
}
if( !battle_config.feature_buying_store || pc_istrading(sd) || sd->buyingstore.slots == 0 || count > sd->buyingstore.slots || zenylimit <= 0 || zenylimit > sd->status.zeny || !storename[0] )
{// disabled or invalid input
sd->buyingstore.slots = 0;
clif_buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0);
return 1;
}
if( !pc_can_give_items(sd) )
{// custom: GM is not allowed to buy (give zeny)
sd->buyingstore.slots = 0;
clif_displaymessage(sd->fd, msg_txt(sd,246));
clif_buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0);
return 6;
}
if( sd->sc.data[SC_NOCHAT] && (sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM) )
{// custom: mute limitation
return 2;
}
if( map[sd->bl.m].flag.novending )
{// custom: no vending maps
clif_displaymessage(sd->fd, msg_txt(sd,276)); // "You can't open a shop on this map"
return 3;
}
if( map_getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) )
{// custom: no vending cells
clif_displaymessage(sd->fd, msg_txt(sd,204)); // "You can't open a shop on this cell."
return 4;
}
weight = sd->weight;
// check item list
for( i = 0; i < count; i++ )
{// itemlist: <name id>.W <amount>.W <price>.L
unsigned short nameid, amount;
int price, idx;
struct item_data* id;
nameid = RBUFW(itemlist,i*8+0);
amount = RBUFW(itemlist,i*8+2);
price = RBUFL(itemlist,i*8+4);
if( ( id = itemdb_exists(nameid) ) == NULL || amount == 0 )
{// invalid input
break;
}
if( price <= 0 || price > BUYINGSTORE_MAX_PRICE )
{// invalid price: unlike vending, items cannot be bought at 0 Zeny
break;
}
if( !id->flag.buyingstore || !itemdb_cantrade_sub(id, pc_get_group_level(sd), pc_get_group_level(sd)) || ( idx = pc_search_inventory(sd, nameid) ) == -1 )
{// restrictions: allowed, no character-bound items and at least one must be owned
break;
}
if( sd->status.inventory[idx].amount+amount > BUYINGSTORE_MAX_AMOUNT )
{// too many items of same kind
break;
}
if( i )
{// duplicate check. as the client does this too, only malicious intent should be caught here
ARR_FIND( 0, i, listidx, sd->buyingstore.items[listidx].nameid == nameid );
if( listidx != i )
{// duplicate
ShowWarning("buyingstore_create: Found duplicate item on buying list (nameid=%hu, amount=%hu, account_id=%d, char_id=%d).\n", nameid, amount, sd->status.account_id, sd->status.char_id);
break;
}
}
weight+= id->weight*amount;
sd->buyingstore.items[i].nameid = nameid;
sd->buyingstore.items[i].amount = amount;
//.........这里部分代码省略.........
开发者ID:AsaK,项目名称:rathena,代码行数:101,代码来源:buyingstore.c
示例10: vending_openvending
/*==========================================
* Open shop
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
void vending_openvending(struct map_session_data *sd, const char *message, const uint8 *data, int count)
{
int i, j;
int vending_skill_lvl;
nullpo_retv(sd);
if(pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd))
return; // can't open vendings lying dead || didn't use via the skill (wpe/hack) || can't have 2 shops at once
vending_skill_lvl = pc_checkskill(sd, MC_VENDING);
// skill level and cart check
if(!vending_skill_lvl || !pc_iscarton(sd)) {
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// check number of items in shop
if(count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl) {
// invalid item count
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return;
}
// filter out invalid items
i = 0;
for(j = 0; j < count; j++) {
short index = *(uint16 *)(data + 8*j + 0);
short amount = *(uint16 *)(data + 8*j + 2);
unsigned int value = *(uint32 *)(data + 8*j + 4);
index -= 2; // offset adjustment (client says that the first cart position is 2)
if(index < 0 || index >= MAX_CART // invalid position
|| pc_cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
|| !sd->status.cart[index].identify // unidentified item
|| sd->status.cart[index].attribute == 1 // broken item
|| sd->status.cart[index].expire_time // It should not be in the cart but just in case
|| (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission
|| !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd))) // untradeable item
continue;
sd->vending[i].index = index;
sd->vending[i].amount = amount;
#if VERSION == -1
sd->vending[i].value = cap_value(value, 0, (unsigned int)battle_config.vending_max_value_ot);
#else
sd->vending[i].value = cap_value(value, 0, (unsigned int)battle_config.vending_max_value);
#endif
i++; // item successfully added
}
if(i != j)
clif_displaymessage(sd->fd, msg_txt(266)); //"Some of your items cannot be vended and were removed from the shop."
if(i == 0) {
// no valid item found
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // custom reply packet
return;
}
sd->state.prevend = sd->state.workinprogress = 0;
sd->state.vending = true;
sd->vender_id = getid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
clif_openvending(sd,sd->bl.id,sd->vending);
clif_showvendingboard(&sd->bl,message,0);
idb_put(vending->db, sd->status.char_id, sd);
}
开发者ID:Mateuus,项目名称:brathena-1,代码行数:76,代码来源:vending.c
示例11: rodex_add_item
/// Attaches an item to a message being written
/// @param sd : The player who's writting
/// @param idx : the inventory idx of the item
/// @param amount : Amount of the item to be attached
void rodex_add_item(struct map_session_data *sd, int16 idx, int16 amount)
{
int i;
bool is_stack = false;
nullpo_retv(sd);
if (idx < 0 || idx >= MAX_INVENTORY) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_FATAL_ERROR);
return;
}
if (amount < 0 || amount > sd->status.inventory[idx].amount) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_FATAL_ERROR);
return;
}
if (!pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
!itemdb_canmail(&sd->status.inventory[idx], pc_get_group_level(sd)) ||
(sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd))) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_NOT_TRADEABLE);
return;
}
if (itemdb->isstackable(sd->status.inventory[idx].nameid) == 1) {
for (i = 0; i < RODEX_MAX_ITEM; ++i) {
if (sd->rodex.tmp.items[i].idx == idx) {
if (sd->status.inventory[idx].nameid == sd->rodex.tmp.items[i].item.nameid &&
sd->status.inventory[idx].unique_id == sd->rodex.tmp.items[i].item.unique_id) {
is_stack = true;
break;
}
}
}
if (i == RODEX_MAX_ITEM && sd->rodex.tmp.items_count < RODEX_MAX_ITEM) {
ARR_FIND(0, RODEX_MAX_ITEM, i, sd->rodex.tmp.items[i].idx == 0);
}
} else if (sd->rodex.tmp.items_count < RODEX_MAX_ITEM) {
ARR_FIND(0, RODEX_MAX_ITEM, i, sd->rodex.tmp.items[i].idx == 0);
} else {
i = RODEX_MAX_ITEM;
}
if (i == RODEX_MAX_ITEM) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_NO_SPACE);
return;
}
if (sd->rodex.tmp.items[i].item.amount + amount > sd->status.inventory[idx].amount) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_FATAL_ERROR);
return;
}
if (sd->rodex.tmp.weight + sd->inventory_data[idx]->weight * amount > RODEX_WEIGHT_LIMIT) {
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_FATAL_ERROR);
return;
}
sd->rodex.tmp.items[i].idx = idx;
sd->rodex.tmp.weight += sd->inventory_data[idx]->weight * amount;
if (is_stack == false) {
sd->rodex.tmp.items[i].item = sd->status.inventory[idx];
sd->rodex.tmp.items[i].item.amount = amount;
sd->rodex.tmp.items_count++;
} else {
sd->rodex.tmp.items[i].item.amount += amount;
}
sd->rodex.tmp.type |= MAIL_TYPE_ITEM;
clif->rodex_add_item_result(sd, idx, amount, RODEX_ADD_ITEM_SUCCESS);
}
开发者ID:Asheraf,项目名称:Hercules,代码行数:76,代码来源:rodex.c
示例12: buyingstore_create
void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count)
{
unsigned int i, weight, listidx;
nullpo_retv(sd);
if (!result || count == 0) {
// canceled, or no items
return;
}
if( !battle_config.feature_buying_store || pc_istrading(sd) || sd->buyingstore.slots == 0 || count > sd->buyingstore.slots || zenylimit <= 0 || zenylimit > sd->status.zeny || !storename[0] )
{// disabled or invalid input
sd->buyingstore.slots = 0;
clif->buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0);
return;
}
if( !pc_can_give_items(sd) )
{// custom: GM is not allowed to buy (give zeny)
sd->buyingstore.slots = 0;
clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action.
clif->buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0);
return;
}
if(pc_ismuted(&sd->sc, MANNER_NOROOM))
{// custom: mute limitation
return;
}
if( map->list[sd->bl.m].flag.novending ) {
// custom: no vending maps
clif->message(sd->fd, msg_sd(sd,276)); // "You can't open a shop on this map"
return;
}
if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING)) {
// custom: no vending cells
clif->message(sd->fd, msg_sd(sd,204)); // "You can't open a shop on this cell."
return;
}
weight = sd->weight;
// check item list
for (i = 0; i < count; i++) {
// itemlist: <name id>.W <amount>.W <price>.L
unsigned short nameid, amount;
int price, idx;
struct item_data* id;
nameid = RBUFW(itemlist,i*8+0);
amount = RBUFW(itemlist,i*8+2);
price = RBUFL(itemlist,i*8+4);
if( ( id = itemdb->exists(nameid) ) == NULL || amount == 0 )
{// invalid input
break;
}
if( price <= 0 || price > BUYINGSTORE_MAX_PRICE )
{// invalid price: unlike vending, items cannot be bought at 0 Zeny
break;
}
if (!id->flag.buyingstore || !itemdb->cantrade_sub(id, pc_get_group_level(sd), pc_get_group_level(sd))
|| (idx = pc->search_inventory(sd, nameid)) == INDEX_NOT_FOUND
) { // restrictions: allowed, no character-bound items and at least one must be owned
break;
}
if( sd->status.inventory[idx].amount+amount > BUYINGSTORE_MAX_AMOUNT )
{// too many items of same kind
break;
}
if( i )
{// duplicate check. as the client does this too, only malicious intent should be caught here
ARR_FIND( 0, i, listidx, sd->buyingstore.items[listidx].nameid == nameid );
if( listidx != i )
{// duplicate
ShowWarning("buyingstore_create: Found duplicate item on buying list (nameid=%hu, amount=%hu, account_id=%d, char_id=%d).\n", nameid, amount, sd->status.account_id, sd->status.char_id);
break;
}
}
weight+= id->weight*amount;
sd->buyingstore.items[i].nameid = nameid;
sd->buyingstore.items[i].amount = amount;
sd->buyingstore.items[i].price = price;
}
if( i != count )
{// invalid item/amount/price
sd->buyingstore.slots = 0;
clif->buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0);
return;
}
if( (sd->max_weight*90)/100 < weight )
//.........这里部分代码省略.........
开发者ID:DeepBugs,项目名称:Hercules,代码行数:101,代码来源:buyingstore.c
示例13: vending_openvending
/**
* Player setup a new shop
* @param sd : player opening the shop
* @param message : shop title
* @param data : itemlist data
* data := {<index>.w <amount>.w <value>.l}[count]
* @param count : number of different items
* @param at Autotrader info, or NULL if requetsed not from autotrade persistance
* @return 0 If success, 1 - Cannot open (die, not state.prevend, trading), 2 - No cart, 3 - Count issue, 4 - Cart data isn't saved yet, 5 - No valid item found
*/
int8 vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count, struct s_autotrader *at)
{
int i, j, k, n;
int vending_skill_lvl;
char message_sql[MESSAGE_SIZE*2];
int item_bad_price[MAX_VENDING];
StringBuf buf;
struct item_data *item;
nullpo_retr(false,sd);
if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd)) {
return 1; // can't open vendings lying dead || didn't use via the skill (wpe/hack) || can't have 2 shops at once
}
vending_skill_lvl = pc_checkskill(sd, MC_VENDING);
// skill level and cart check
if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return 2;
}
// check number of items in shop
if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl ) { // invalid item count
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return 3;
}
if (save_settings&CHARSAVE_VENDING) // Avoid invalid data from saving
chrif_save(sd, 0);
// filter out invalid items
i = k = 0;
for( j = 0; j < count; j++ ) {
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
index -= 2; // offset adjustment (client says that the first cart position is 2)
if( index < 0 || index >= MAX_CART // invalid position
|| pc_cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
|| !sd->status.cart[index].identify // unidentified item
|| sd->status.cart[index].attribute == 1 // broken item
|| sd->status.cart[index].expire_time // It should not be in the cart but just in case
|| (sd->status.cart[index].bound && !pc_can_give_bounded_items(sd)) // can't trade account bound items and has no permission
|| !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item
continue;
item = itemdb_search(sd->status.cart[index].nameid);
if (item->value_buy_min > 0 && value > item->value_buy_min)
{
if (battle_config.vending_price_min_overflow > 0 )
{
if (value > item->value_buy_min + (item->value_buy_min * (battle_config.vending_price_min_overflow / 10000.)))
{
item_bad_price[k++] = sd->status.cart[index].nameid;
continue;
}
}
else
{
item_bad_price[k++] = sd->status.cart[index].nameid;
continue;
}
}
sd->vending[i].index = index;
sd->vending[i].amount = amount;
sd->vending[i].value = min(value, (unsigned int)battle_config.vending_max_value);
// Player just moved item to cart and we don't have the correct cart ID yet.
if (sd->status.cart[sd->vending[i].index].id == 0) {
char msg[256];
snprintf(msg, 256, "äÍà·çÁ %s ÂѧäÁèä´éºÑ¹·Ö¡. ¡ÃسÒÍÍ¡à¢éÒãËÁè à¾×èÍãËéäÍà·çÁ·Ó¡ÒÃ૿ŧÃéÒ¹¤éÒ", item->jname);
clif_displaymessage(sd->fd, msg);
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return 4;
}
i++; // item successfully added
}
//if( i != j )
//clif_displaymessage (sd->fd, msg_txt(sd,266)); //"Some of your items cannot be vended and were removed from the shop."
//.........这里部分代码省略.........
开发者ID:bossemoja,项目名称:5.0,代码行数:101,代码来源:vending.c
示例14: mail_setitem
/**
* Attempt to set item or zeny to a mail
* @param sd : player attaching the content
* @param idx 0 - Zeny; >= 2 - Inventory item
* @param amount : amout of zeny or number of item
* @return see enum mail_attach_result in mail.h
*/
enum mail_attach_result mail_setitem(struct map_session_data *sd, short idx, uint32 amount) {
if( pc_istrading(sd) )
return MAIL_ATTACH_ERROR;
if( idx == 0 ) { // Zeny Transfer
if( !pc_can_give_items(sd) )
return MAIL_ATTACH_UNTRADEABLE;
#if PACKETVER < 20150513
if( amount > sd->status.zeny )
amount = sd->status.zeny; // TODO: confirm this behavior for old mail system
#else
if( ( amount + battle_config.mail_zeny_fee / 100 * amount ) > sd->status.zeny )
return MAIL_ATTACH_ERROR;
#endif
sd->mail.zeny = amount;
// clif_updatestatus(sd, SP_ZENY);
return MAIL_ATTACH_SUCCESS;
} else { // Item Transfer
int i, j, total = 0;
idx -= 2;
if( idx < 0 || idx >= MAX_INVENTORY )
return MAIL_ATTACH_ERROR;
#if PACKETVER < 20150513
i = 0;
// Remove existing item
mail_removeitem(sd, 0, sd->mail.item[i].index + 2, sd->mail.item[i].amount);
#else
ARR_FIND(0, MAIL_MAX_ITEM, i, sd->mail.item[i].index == idx && sd->mail.item[i].nameid > 0 );
// The same item had already been added to the mail
if( i < MAIL_MAX_ITEM ){
// Check if it is stackable
if( !itemdb_isstackable(sd->mail.item[i].nameid) ){
return MAIL_ATTACH_ERROR;
}
// Check if it exceeds the total amount
if( ( amount + sd->mail.item[i].amount ) > sd->inventory.u.items_inventory[idx].amount ){
return MAIL_ATTACH_ERROR;
}
// Check if it exceeds the total weight
if( battle_config.mail_attachment_weight ){
for( j = 0; j < i; j++ ){
total += sd->mail.item[j].amount * ( sd->inventory_data[sd->mail.item[j].index]->weight / 10 );
}
total += amount * sd->inventory_data[idx]->weight / 10;
if( total > battle_config.mail_attachment_weight ){
return MAIL_ATTACH_WEIGHT;
}
}
sd->mail.item[i].amount += amount;
return MAIL_ATTACH_SUCCESS;
}else{
ARR_FIND(0, MAIL_MAX_ITEM, i, sd->mail.item[i].nameid == 0);
if( i == MAIL_MAX_ITEM ){
return MAIL_ATTACH_SPACE;
}
// Check if it exceeds the total weight
if( battle_config.mail_attachment_weight ){
for( j = 0; j < i; j++ ){
total += sd->mail.item[j].amount * ( sd->inventory_data[sd->mail.item[j].index]->weight / 10 );
}
total += amount * sd->inventory_data[idx]->weight / 10;
if( total > battle_config.mail_attachment_weight ){
return MAIL_ATTACH_WEIGHT;
}
}
}
#endif
if( amount > sd->inventory.u.items_inventory[idx].amount )
return MAIL_ATTACH_ERROR;
if( !pc_can_give_items(sd) || sd->inventory.u.items_inventory[idx].expire_time
|| !itemdb_available(sd->inventory.u.items_inventory[idx].nameid)
|| !itemdb_canmail(&sd->inventory.u.items_inventory[idx],pc_get_group_level(sd))
|| (sd->inventory.u.items_inventory[idx].bound && !pc_can_give_bounded_items(sd)) )
return MAIL_ATTACH_UNTRADEABLE;
sd->mail.item[i].index = idx;
//.........这里部分代码省略.........
开发者ID:Vincentore,项目名称:rathena,代码行数:101,代码来源:mail.c
示例15: vending_openvending
/**
* Player setup a new shop
* @param sd : player opening the shop
* @param message : shop title
* @param data : itemlist data \n
* data := {<index>.w <amount>.w <value>.l}[count]
* @param count : number of different items
* @return 0 If success, 1 - Cannot open (die, not state.prevend, trading), 2 - No cart, 3 - Count issue, 4 - Cart data isn't saved yet, 5 - No valid item found
*/
char vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count) {
int i, j;
int vending_skill_lvl;
char message_sql[MESSAGE_SIZE*2];
nullpo_retr(false,sd);
if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd)) {
return 1; // can't open vendings lying dead || didn't use via the skill (wpe/hack) || can't have 2 shops at once
}
vending_skill_lvl = pc_checkskill(sd, MC_VENDING);
// skill level and cart check
if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return 2;
}
// check number of items in shop
if( count < 1 || count > MAX_VENDING || count > 2 + vending_skill_lvl )
{ // invalid item count
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return 3;
}
if (save_settings&2) // Avoid invalid data from saving
chrif_save(sd, 0);
// filter out invalid items
i = 0;
for( j = 0; j < count; j++ ) {
short index = *(uint16*)(data + 8*j + 0);
short amount = *(uint16*)(data + 8*j + 2);
unsigned int value = *(uint32*)(data + 8*j + 4);
index -= 2; // offset adjustment (client says that the first cart position is 2)
if( index < 0 || index >= MAX_CART // invalid position
|| pc_cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
|| !sd->status.cart[index].identify // unidentified item
|| sd->status.cart[index].attribute == 1 // broken item
|| sd->status.cart[index].expire_time // It should not be in the cart but just in case
|| (sd->status.cart[index].bound && !pc_can_give_bounded_items(sd)) // can't trade account bound items and has no permission
|| !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item
continue;
sd->vending[i].index = index;
sd->vending[i].amount = amount;
sd->vending[i].value = min(value, (unsigned int)battle_config.vending_max_value);
// Player just moved item to cart and we don't have the correct cart ID yet.
if (sd->status.cart[sd->vending[i].index].id == 0) {
struct item_data *idb = itemdb_search(sd->status.cart[index].nameid);
char msg[256];
sprintf(msg, msg_txt(sd, 733), idb->jname);
clif_displaymessage(sd->fd, msg);
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return 4;
}
i++; // item successfully added
}
if( i != j )
clif_displaymessage (sd->fd, msg_txt(sd,266)); //"Some of your items cannot be vended and were removed from the shop."
if( i == 0 ) { // no valid item found
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // custom reply packet
return 5;
}
sd->state.prevend = 0;
sd->state.vending = true;
sd->vender_id = vending_getuid();
sd->vend_num = i;
safestrncpy(sd->message, message, MESSAGE_SIZE);
Sql_EscapeString( mmysql_handle, message_sql, sd->message );
if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`id`,`account_id`,`char_id`,`sex`,`map`,`x`,`y`,`title`,`autotrade`, `body_direction`, `head_direction`, `sit`) "
"VALUES( %d, %d, %d, '%c', '%s', %d, %d, '%s', %d, '%d', '%d', '%d' );",
vendings_db, sd->vender_id, sd->status.account_id, sd->status.char_id, sd->status.sex == 0 ? 'F' : 'M', map[sd->bl.m].name, sd->bl.x, sd->bl.y, message_sql, sd->state.autotrade, sd->ud.dir, sd->head_dir, pc_issit(sd) ) != SQL_SUCCESS ){
Sql_ShowDebug(mmysql_handle);
}
for( i = 0; i < count; i++ ) {
if( Sql_Query( mmysql_handle, "INSERT INTO `%s`(`vending_id`,`index`,`cartinventory_id`,`amount`,`price`) VALUES( %d, %d, %d, %d, %d );", vending_items_db, sd->vender_id, i, sd->status.cart[sd->vending[i].index].id, sd->vending[i].amount, sd->vending[i].value ) != SQL_SUCCESS ){
Sql_ShowDebug(mmysql_handle);
}
//.........这里部分代码省略.........
开发者ID:Escada28,项目名称:rathena,代码行数:101,代码来源:vending.c
示例16: trade_tradeadditem
/*==========================================
* Adds an item/qty to the trade window
*------------------------------------------*/
void trade_tradeadditem (struct map_session_data *sd, short index, short amount)
{
struct map_session_data *target_sd;
struct item *item;
int trade_i, trade_weight;
int src_lv, dst_lv;
nullpo_retv (sd);
if (!sd->state.trading || sd->state.deal_locked > 0)
return; //Can't add stuff.
if ( (target_sd = map_id2sd (sd->trade_partner)) == NULL) {
trade_tradecancel (sd);
return;
}
if (amount == 0) {
//Why do this.. ~.~ just send an ack, the item won't display on the trade window.
clif_tradeitemok (sd, index, 0);
return;
}
index -= 2; // 0 is for zeny, 1 is unknown. Gravity, go figure...
//Item checks...
if (index < 0 || index >= MAX_INVENTORY)
return;
if (amount < 0 || amount > sd->status.inventory[index].amount)
return;
item = &sd->status.inventory[index];
src_lv = pc_get_group_level (sd);
dst_lv = pc_get_group_level (target_sd);
if (!itemdb_cantrade (item, src_lv, dst_lv) && //Can't trade
(pc_get_partner (sd) != target_sd || !itemdb_canpartnertrade (item, src_lv, dst_lv))) { //Can't partner-trade
clif_displaymessage (sd->fd, msg_txt (260));
clif_tradeitemok (sd, index + 2, 1);
return;
}
if (item->expire_time) {
// Rental System
clif_displaymessage (sd->fd, msg_txt (260));
clif_tradeitemok (sd, index + 2, 1);
return;
}
//Locate a trade position
ARR_FIND (0, 10, trade_i, sd->deal.item[trade_i].index == index || sd->deal.item[trade_i].amount == 0);
if (trade_i == 10) { //No space left
clif_tradeitemok (sd, index + 2, 1);
return;
}
trade_weight = sd->inventory_data[index]->weight * amount;
if (target_sd->weight + sd->deal.weight + trade_weight > target_sd->max_weight) {
//fail to add item -- the player was over weighted.
clif_tradeitemok (sd, index + 2, 1);
return;
}
if (sd->deal.item[trade_i].index == index) {
//The same item as before is being readjusted.
if (sd->deal.item[trade_i].amount + amount > sd->status.inventory[index].amount) {
//packet deal exploit check
amount = sd->sta
|
请发表评论