本文整理汇总了C++中chrif_save函数的典型用法代码示例。如果您正苦于以下问题:C++ chrif_save函数的具体用法?C++ chrif_save怎么用?C++ chrif_save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chrif_save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: storage_storage_quit
/*==========================================
* When quitting the game.
*------------------------------------------*/
void storage_storage_quit(struct map_session_data* sd, int flag)
{
nullpo_retv(sd);
if (save_settings&4)
chrif_save(sd, flag); //Invokes the storage saving as well.
sd->state.storage_flag = 0;
}
开发者ID:Boooo,项目名称:i-aint-quitting,代码行数:12,代码来源:storage.c
示例2: storage_storageclose
/**
* Make player close his storage
* @author : [massdriller] / modified by [Valaris]
* @param sd : player
*/
void storage_storageclose(struct map_session_data *sd)
{
nullpo_retv(sd);
clif_storageclose(sd);
if (save_settings&4)
chrif_save(sd, 0); //Invokes the storage saving as well
sd->state.storage_flag = 0;
}
开发者ID:MStr3am,项目名称:idathena,代码行数:16,代码来源:storage.c
示例3: quest_change
int quest_change(TBL_PC * sd, int qid1, int qid2)
{
int i, j;
if( quest_check(sd, qid2, HAVEQUEST) >= 0 )
{
ShowError("quest_change: Character %d already has quest %d.\n", sd->status.char_id, qid2);
return -1;
}
if( quest_check(sd, qid1, HAVEQUEST) < 0 )
{
ShowError("quest_change: Character %d doesn't have quest %d.\n", sd->status.char_id, qid1);
return -1;
}
if( (j = quest_search_db(qid2)) < 0 )
{
ShowError("quest_change: quest %d not found in DB.\n",qid2);
return -1;
}
ARR_FIND(0, sd->avail_quests, i, sd->quest_log[i].quest_id == qid1);
if(i == sd->avail_quests)
{
ShowError("quest_change: Character %d has completed quests %d.\n", sd->status.char_id, qid1);
return -1;
}
memset(&sd->quest_log[i], 0, sizeof(struct quest));
sd->quest_log[i].quest_id = quest_db[j].id;
if( quest_db[j].time )
sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
sd->quest_log[i].state = Q_ACTIVE;
sd->quest_index[i] = j;
sd->save_quest = true;
clif_quest_delete(sd, qid1);
clif_quest_add(sd, &sd->quest_log[i], sd->quest_index[i]);
if( save_settings&64 )
chrif_save(sd,0);
return 0;
}
开发者ID:Boooo,项目名称:i-aint-quitting,代码行数:47,代码来源:quest.c
示例4: gstorage_storageclose
/**
* Close storage for player then save it
* @param sd : player
*/
void gstorage_storageclose(struct map_session_data *sd)
{
struct guild_storage *stor;
nullpo_retv(sd);
nullpo_retv(stor = gstorage_get_storage(sd->status.guild_id));
clif_storageclose(sd);
if (stor->opened) {
if (save_settings&4)
chrif_save(sd, 0); //This one also saves the storage [Skotlex]
else
gstorage_storagesave(sd->status.account_id, sd->status.guild_id, 0);
stor->opened = 0;
}
sd->state.storage_flag = 0;
}
开发者ID:MStr3am,项目名称:idathena,代码行数:21,代码来源:storage.c
示例5: quest_add
int quest_add(TBL_PC * sd, int quest_id)
{
int i, j;
if( sd->num_quests >= MAX_QUEST_DB )
{
ShowError("quest_add: Character %d has got all the quests.(max quests: %d)\n", sd->status.char_id, MAX_QUEST_DB);
return 1;
}
if( quest_check(sd, quest_id, HAVEQUEST) >= 0 )
{
ShowError("quest_add: Character %d already has quest %d.\n", sd->status.char_id, quest_id);
return -1;
}
if( (j = quest_search_db(quest_id)) < 0 )
{
ShowError("quest_add: quest %d not found in DB.\n", quest_id);
return -1;
}
i = sd->avail_quests;
memmove(&sd->quest_log[i+1], &sd->quest_log[i], sizeof(struct quest)*(sd->num_quests-sd->avail_quests));
memmove(sd->quest_index+i+1, sd->quest_index+i, sizeof(int)*(sd->num_quests-sd->avail_quests));
memset(&sd->quest_log[i], 0, sizeof(struct quest));
sd->quest_log[i].quest_id = quest_db[j].id;
if( quest_db[j].time )
sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
sd->quest_log[i].state = Q_ACTIVE;
sd->quest_index[i] = j;
sd->num_quests++;
sd->avail_quests++;
sd->save_quest = true;
clif_quest_add(sd, &sd->quest_log[i], sd->quest_index[i]);
if( save_settings&64 )
chrif_save(sd,0);
return 0;
}
开发者ID:Boooo,项目名称:i-aint-quitting,代码行数:45,代码来源:quest.c
示例6: storage_storage_quit
/*==========================================
* When quitting the game.
*------------------------------------------
*/
int storage_storage_quit(struct map_session_data *sd, int flag)
{
struct storage *stor;
nullpo_retr(0, sd);
nullpo_retr(0, stor=account2storage2(sd->status.account_id));
if (stor->storage_status)
{
if (save_settings&4)
chrif_save(sd, flag); //Invokes the storage saving as well.
else
storage_storage_save(sd->status.account_id, flag);
}
stor->storage_status = 0;
sd->state.storage_flag = 0;
return 0;
}
开发者ID:AxlSckay,项目名称:Ragnarok-OldTimes,代码行数:22,代码来源:storage.c
示例7: storage_guild_storageclose
/**
* Close storage for player then save it
* @param sd : player
*/
void storage_guild_storageclose(struct map_session_data* sd)
{
struct s_storage *stor;
nullpo_retv(sd);
nullpo_retv(stor = guild2storage2(sd->status.guild_id));
clif_storageclose(sd);
if (stor->status) {
if (save_settings&CHARSAVE_STORAGE)
chrif_save(sd, 0); //This one also saves the storage. [Skotlex]
else
storage_guild_storagesave(sd->status.account_id, sd->status.guild_id,0);
stor->status = false;
}
sd->state.storage_flag = 0;
}
开发者ID:AtlantisRO,项目名称:rathena,代码行数:23,代码来源:storage.c
示例8: pet_birth_process
/**
* Begin hatching a pet.
* @param sd : player requesting
* @param pet : pet requesting
*/
int pet_birth_process(struct map_session_data *sd, struct s_pet *pet)
{
nullpo_retr(1, sd);
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->master == sd);
if(sd->status.pet_id && pet->incubate == 1) {
sd->status.pet_id = 0;
return 1;
}
pet->incubate = 0;
pet->account_id = sd->status.account_id;
pet->char_id = sd->status.char_id;
sd->status.pet_id = pet->pet_id;
if(pet_data_init(sd, pet)) {
sd->status.pet_id = 0;
return 1;
}
intif_save_petdata(sd->status.account_id,pet);
if (save_settings&8)
chrif_save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex]
if(sd->bl.prev != NULL) {
if(map_addblock(&sd->pd->bl))
return 1;
clif_spawn(&sd->pd->bl);
clif_send_petdata(sd,sd->pd, 0,0);
clif_send_petdata(sd,sd->pd, 5,battle_config.pet_hair_style);
clif_pet_equip_area(sd->pd);
clif_send_petstatus(sd);
}
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->master == sd);
return 0;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:48,代码来源:pet.c
示例9: quest_add
/**
* Adds a quest to the player's list.
* New quest will be added as Q_ACTIVE.
* @param sd : Player's data
* @param quest_id : ID of the quest to add.
* @return 0 in case of success, nonzero otherwise
*/
int quest_add(TBL_PC *sd, int quest_id)
{
int n;
struct quest_db *qi = quest_db(quest_id);
if( qi == &quest_dummy ) {
ShowError("quest_add: quest %d not found in DB.\n", quest_id);
return -1;
}
if( quest_check(sd, quest_id, HAVEQUEST) >= 0 ) {
ShowError("quest_add: Character %d already has quest %d.\n", sd->status.char_id, quest_id);
return -1;
}
n = sd->avail_quests; //Insertion point
sd->num_quests++;
sd->avail_quests++;
RECREATE(sd->quest_log, struct quest, sd->num_quests);
//The character has some completed quests, make room before them so that they will stay at the end of the array
if( sd->avail_quests != sd->num_quests )
memmove(&sd->quest_log[n + 1], &sd->quest_log[n], sizeof(struct quest) * (sd->num_quests-sd->avail_quests));
memset(&sd->quest_log[n], 0, sizeof(struct quest));
sd->quest_log[n].quest_id = qi->id;
if( qi->time )
sd->quest_log[n].time = (unsigned int)(time(NULL) + qi->time);
sd->quest_log[n].state = Q_ACTIVE;
sd->save_quest = true;
clif_quest_add(sd, &sd->quest_log[n]);
clif_quest_update_objective(sd, &sd->quest_log[n]);
if( save_settings&CHARSAVE_QUEST )
chrif_save(sd,0);
return 0;
}
开发者ID:Oranji-Aka,项目名称:rathena,代码行数:49,代码来源:quest.c
示例10: chrif_changedsex
/*==========================================
* 性別変化終了 (modified by Yor)
*------------------------------------------
*/
static
void chrif_changedsex(Session *, const Packet_Fixed<0x2b0d>& fixed)
{
dumb_ptr<map_session_data> sd;
AccountId acc = fixed.account_id;
SEX sex = fixed.sex;
if (battle_config.etc_log)
PRINTF("chrif_changedsex %d.\n"_fmt, acc);
sd = map_id2sd(account_to_block(acc));
if (acc)
{
if (sd != nullptr && sd->status.sex != sex)
{
if (sd->status.sex == SEX::MALE)
sd->sex = sd->status.sex = SEX::FEMALE;
else if (sd->status.sex == SEX::FEMALE)
sd->sex = sd->status.sex = SEX::MALE;
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for (IOff0 i : IOff0::iter())
{
if (sd->status.inventory[i].nameid
&& bool(sd->status.inventory[i].equip))
pc_unequipitem(sd, i, CalcStatus::NOW);
}
// save character
chrif_save(sd);
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it)
clif_displaymessage(sd->sess,
"Your sex has been changed (need disconexion by the server)..."_s);
clif_setwaitclose(sd->sess); // forced to disconnect for the change
}
}
else
{
if (sd != nullptr)
{
PRINTF("chrif_changedsex failed.\n"_fmt);
}
}
}
开发者ID:Rosalila,项目名称:tswa,代码行数:46,代码来源:chrif.cpp
示例11: pet_birth_process
int pet_birth_process(struct map_session_data *sd, struct s_pet *pet)
{
char pet_output[1024]; // Declaracion de char para Invocacion Pet's [Tab]
nullpo_retr(1, sd);
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
if(sd->status.pet_id && pet->incuvate == 1) {
sd->status.pet_id = 0;
return 1;
}
pet->incuvate = 0;
pet->account_id = sd->status.account_id;
pet->char_id = sd->status.char_id;
sd->status.pet_id = pet->pet_id;
if(pet_data_init(sd, pet)) {
sd->status.pet_id = 0;
return 1;
}
intif_save_petdata(sd->status.account_id,pet);
if (save_settings&8)
chrif_save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex]
if(sd->bl.prev != NULL) {
map_addblock(&sd->pd->bl);
clif_spawn(&sd->pd->bl);
clif_send_petdata(sd,sd->pd, 0,0);
clif_send_petdata(sd,sd->pd, 5,battle_config.pet_hair_style);
clif_pet_equip_area(sd->pd);
clif_send_petstatus(sd);
}
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
clif_misceffect(&sd->pd->bl, 0); // Efecto 1 de nacimiento [Tab]
clif_misceffect(&sd->pd->bl, 344); // Efecto 2 de nacimiento [Tab]
sprintf(pet_output,"Get Out %s... NOW!",pet->name); // Cuidado aca con el nombre del pet
clif_displaymessage(sd->fd, pet_output); // Frase nacimiento [Tab]
return 0;
}
开发者ID:philg666,项目名称:Latest_eAmod,代码行数:42,代码来源:pet.c
示例12: storage_guild_storageclose
//Close storage for sd and save it
int storage_guild_storageclose(struct map_session_data* sd)
{
struct guild_storage *stor;
nullpo_ret(sd);
nullpo_ret(stor=guild2storage2(sd->status.guild_id));
clif_storageclose(sd);
if (stor->storage_status)
{
if (save_settings&4)
chrif_save(sd, 0); //This one also saves the storage. [Skotlex]
else
storage_guild_storagesave(sd->status.account_id, sd->status.guild_id,0);
stor->storage_status=0;
}
sd->state.storage_flag = 0;
return 0;
}
开发者ID:gigaguzel,项目名称:rAthena-1,代码行数:21,代码来源:storage.c
示例13: storage_storageclose
/*==========================================
* カプラ倉庫を閉じて保存
*------------------------------------------
*/
void storage_storageclose(struct map_session_data *sd)
{
struct storage *stor;
nullpo_retv(sd);
nullpo_retv(stor = (struct storage *)numdb_search(storage_db,sd->status.account_id));
if(stor->dirty) {
storage_sortitem(stor->store_item, MAX_STORAGE, &stor->sortkey, battle_config.personal_storage_sort);
intif_send_storage(stor);
if(battle_config.save_player_when_storage_closed) {
chrif_save(sd,0);
}
stor->dirty = 0;
}
stor->storage_status = 0;
sd->state.storage_flag = 0;
clif_storageclose(sd);
return;
}
开发者ID:Lilystar,项目名称:Auriga,代码行数:25,代码来源:storage.c
示例14: auth_db_cleanup_sub
/**
* This can still happen (client times out while waiting for char to confirm auth data)
* @see DBApply
*/
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
const char* states[] = { "Login", "Logout", "Map change" };
if(DIFF_TICK(gettick(),node->node_created)>60000) {
switch (node->state) {
case ST_LOGOUT:
//Re-save attempt (->sd should never be null here).
node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
chrif_save(node->sd, 1);
break;
default:
//Clear data. any connected players should have timed out by now.
ShowInfo("auth_db: Node (state %s) timed out for %d:%d\n", states[node->state], node->account_id, node->char_id);
chrif_char_offline_nsd(node->account_id, node->char_id);
chrif_auth_delete(node->account_id, node->char_id, node->state);
break;
}
return 1;
}
return 0;
}
开发者ID:Shaktoh,项目名称:Hercules,代码行数:26,代码来源:chrif.c
示例15: chrif_changedsex
/*==========================================
* 性別変化終了 (modified by Yor)
*------------------------------------------
*/
static
void chrif_changedsex(Session *, const Packet_Fixed<0x2b0d>& fixed)
{
dumb_ptr<map_session_data> sd;
AccountId acc = fixed.account_id;
SEX sex = fixed.sex;
if (battle_config.etc_log)
PRINTF("chrif_changedsex %d.\n"_fmt, acc);
sd = map_id2sd(account_to_block(acc));
if (acc)
{
if (sd != nullptr && sd->status.sex != sex)
{
sd->sex = sd->status.sex = sex;
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for (IOff0 i : IOff0::iter())
{
if (sd->status.inventory[i].nameid
&& bool(sd->status.inventory[i].equip))
pc_unequipitem(sd, i, CalcStatus::LATER);
}
pc_calcstatus(sd, 0);
// save character
chrif_save(sd);
sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it)
clif_fixpcpos(sd); // use clif_set0078_main_1d8 to send new sex to the client
}
}
else
{
if (sd != nullptr)
{
PRINTF("chrif_changedsex failed.\n"_fmt);
}
}
}
开发者ID:MadCamel,项目名称:tmwa,代码行数:42,代码来源:chrif.cpp
示例16: quest_update_status
int quest_update_status(TBL_PC * sd, int quest_id, quest_state status)
{
int i;
//Only status of active and inactive quests can be updated. Completed quests can't (for now). [Inkfish]
ARR_FIND(0, sd->avail_quests, i, sd->quest_log[i].quest_id == quest_id);
if(i == sd->avail_quests)
{
ShowError("quest_update_status: Character %d doesn't have quest %d.\n", sd->status.char_id, quest_id);
return -1;
}
sd->quest_log[i].state = status;
sd->save_quest = true;
if( status < Q_COMPLETE )
{
clif_quest_update_status(sd, quest_id, (bool)status);
return 0;
}
achievement_validate_quest(sd,quest_id);
if( i != (--sd->avail_quests) )
{
struct quest tmp_quest;
memcpy(&tmp_quest, &sd->quest_log[i],sizeof(struct quest));
memcpy(&sd->quest_log[i], &sd->quest_log[sd->avail_quests],sizeof(struct quest));
memcpy(&sd->quest_log[sd->avail_quests], &tmp_quest,sizeof(struct quest));
}
clif_quest_delete(sd, quest_id);
if( save_settings&64 )
chrif_save(sd,0);
return 0;
}
开发者ID:philg666,项目名称:Latest_eAmod,代码行数:38,代码来源:quest.c
示例17: auth_db_cleanup_sub
//This can still happen (client times out while waiting for char to confirm auth data)
int auth_db_cleanup_sub(DBKey key,void *data,va_list ap)
{
struct auth_node *node=(struct auth_node*)data;
const char* states[] = { "Iniciar Sessao", "Encerrar Sessao", "Mudanca de Mapa" };
if(DIFF_TICK(gettick(),node->node_created)>60000) {
switch (node->state)
{
case ST_LOGOUT:
//Re-save attempt (->sd should never be null here).
node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
chrif_save(node->sd, 1);
break;
default:
//Clear data. any connected players should have timed out by now.
ShowInfo("auth_db: No (estado %s) tempo esgotado para %d:%d\n", states[node->state], node->account_id, node->char_id);
chrif_char_offline_nsd(node->account_id, node->char_id);
chrif_auth_delete(node->account_id, node->char_id, node->state);
break;
}
return 1;
}
return 0;
}
开发者ID:JulioCF,项目名称:cronus-txt,代码行数:24,代码来源:chrif.c
示例18: quest_update_status
/**
* Updates a quest's state.
* Only status of active and inactive quests can be updated. Completed quests can't (for now).
* @param sd : Character's data
* @param quest_id : Quest ID to update
* @param qs : New quest state
* @return 0 in case of success, nonzero otherwise
* @author [Inkfish]
*/
int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state status)
{
int i;
ARR_FIND(0, sd->avail_quests, i, sd->quest_log[i].quest_id == quest_id);
if( i == sd->avail_quests ) {
ShowError("quest_update_status: Character %d doesn't have quest %d.\n", sd->status.char_id, quest_id);
return -1;
}
sd->quest_log[i].state = status;
sd->save_quest = true;
if( status < Q_COMPLETE ) {
clif_quest_update_status(sd, quest_id, status == Q_ACTIVE ? true : false);
return 0;
}
achievement_validate_quest(sd,quest_id);
// The quest is complete, so it needs to be moved to the completed quests block at the end of the array.
if( i < (--sd->avail_quests) ) {
struct quest tmp_quest;
memcpy(&tmp_quest, &sd->quest_log[i], sizeof(struct quest));
memcpy(&sd->quest_log[i], &sd->quest_log[sd->avail_quests], sizeof(struct quest));
memcpy(&sd->quest_log[sd->avail_quests], &tmp_quest, sizeof(struct quest));
}
clif_quest_delete(sd, quest_id);
if( save_settings&64 )
chrif_save(sd,0);
return 0;
}
开发者ID:LKJeronimo,项目名称:eamod,代码行数:45,代码来源:quest.c
示例19: buyingstore_trade
//.........这里部分代码省略.........
}
if( sd->status.inventory[index].expire_time || !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;
}
if( pc->checkadditem(pl_sd, nameid, amount) == ADDITEM_OVERAMOUNT )
{// buyer does not have enough space for this item
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
if( amount*(unsigned int)sd->inventory_data[index]->weight > pl_sd->max_weight-weight )
{// normally this is not supposed to happen, as the total weight is
// checked upon creation, but the buyer could have gained items
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
weight+= amount*sd->inventory_data[index]->weight;
if( amount*pl_sd->buyingstore.items[listidx].price > pl_sd->buyingstore.zenylimit-zeny )
{// buyer does not have enough zeny
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_ZENY, nameid);
return;
}
zeny+= amount*pl_sd->buyingstore.items[listidx].price;
}
// process 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);
ARR_FIND( 0, pl_sd->buyingstore.slots, listidx, pl_sd->buyingstore.items[listidx].nameid == nameid );
zeny = amount*pl_sd->buyingstore.items[listidx].price;
// move item
pc->additem(pl_sd, &sd->status.inventory[index], amount, LOG_TYPE_BUYING_STORE);
pc->delitem(sd, index, amount, 1, 0, LOG_TYPE_BUYING_STORE);
pl_sd->buyingstore.items[listidx].amount-= amount;
// pay up
pc->payzeny(pl_sd, zeny, LOG_TYPE_BUYING_STORE, sd);
pc->getzeny(sd, zeny, LOG_TYPE_BUYING_STORE, pl_sd);
pl_sd->buyingstore.zenylimit-= zeny;
// notify clients
clif->buyingstore_delete_item(sd, index, amount, pl_sd->buyingstore.items[listidx].price);
clif->buyingstore_update_item(pl_sd, nameid, amount);
}
if( iMap->save_settings&128 ) {
chrif_save(sd, 0);
chrif_save(pl_sd, 0);
}
// check whether or not there is still something to buy
ARR_FIND( 0, pl_sd->buyingstore.slots, i, pl_sd->buyingstore.items[i].amount != 0 );
if( i == pl_sd->buyingstore.slots )
{// everything was bought
clif->buyingstore_trade_failed_buyer(pl_sd, BUYINGSTORE_TRADE_BUYER_NO_ITEMS);
}
else if( pl_sd->buyingstore.zenylimit == 0 )
{// zeny limit reached
clif->buyingstore_trade_failed_buyer(pl_sd, BUYINGSTORE_TRADE_BUYER_ZENY);
}
else
{// continue buying
return;
}
// cannot continue buying
buyingstore_close(pl_sd);
// remove auto-trader
if( pl_sd->state.autotrade )
{
iMap->quit(pl_sd);
}
}
开发者ID:i-nan,项目名称:Hercules,代码行数:101,代码来源:buyingstore.c
示例20: 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
注:本文中的chrif_save函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论