本文整理汇总了C++中ShowWarning函数的典型用法代码示例。如果您正苦于以下问题:C++ ShowWarning函数的具体用法?C++ ShowWarning怎么用?C++ ShowWarning使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ShowWarning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: map_config_read
//.........这里部分代码省略.........
else if (strcmp(w1, "CoP_Battle_cap") == 0)
{
map_config.CoP_Battle_cap = atoi(w2);
}
else if (strcmp(w1, "max_merit_points") == 0)
{
map_config.max_merit_points = atoi(w2);
}
else if (strcmp(w1, "yell_cooldown") == 0)
{
map_config.yell_cooldown = atoi(w2);
}
else if (strcmp(w1, "audit_chat") == 0)
{
map_config.audit_chat = atoi(w2);
}
else if (strcmp(w1, "audit_say") == 0)
{
map_config.audit_say = atoi(w2);
}
else if (strcmp(w1, "audit_shout") == 0)
{
map_config.audit_shout = atoi(w2);
}
else if (strcmp(w1, "audit_tell") == 0)
{
map_config.audit_tell = atoi(w2);
}
else if (strcmp(w1, "audit_yell") == 0)
{
map_config.audit_yell = atoi(w2);
}
else if (strcmp(w1, "audit_linkshell") == 0)
{
map_config.audit_linkshell = atoi(w2);
}
else if (strcmp(w1, "audit_party") == 0)
{
map_config.audit_party = atoi(w2);
}
else if (strcmp(w1, "msg_server_port") == 0)
{
map_config.msg_server_port = atoi(w2);
}
else if (strcmp(w1, "msg_server_ip") == 0)
{
map_config.msg_server_ip = aStrdup(w2);
}
else
{
ShowWarning(CL_YELLOW"Unknown setting '%s' in file %s\n" CL_RESET, w1, cfgName);
}
}
fclose(fp);
// Load the English server message..
fp = fopen("./conf/server_message.conf", "rb");
if (fp == nullptr)
{
ShowError("Could not read English server message from: ./conf/server_message.conf\n");
return 1;
}
while (fgets(line, sizeof(line), fp))
{
string_t sline(line);
map_config.server_message += sline;
}
fclose(fp);
// Load the French server message..
fp = fopen("./conf/server_message_fr.conf", "rb");
if (fp == nullptr)
{
ShowError("Could not read English server message from: ./conf/server_message_fr.conf\n");
return 1;
}
while (fgets(line, sizeof(line), fp))
{
string_t sline(line);
map_config.server_message_fr += sline;
}
fclose(fp);
// Ensure both messages have nullptr terminates..
if (map_config.server_message.at(map_config.server_message.length() - 1) != 0x00)
{
map_config.server_message += (char)0x00;
}
if (map_config.server_message_fr.at(map_config.server_message_fr.length() - 1) != 0x00)
{
map_config.server_message_fr += (char)0x00;
}
return 0;
}
示例2: buyingstore_trade
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;
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->message(sd->fd, msg_txt(246));
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
if( ( pl_sd = iMap->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 || !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
//.........这里部分代码省略.........
示例3: searchstore_query
void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned int min_price, unsigned int max_price, const unsigned short* itemlist, unsigned int item_count, const unsigned short* cardlist, unsigned int card_count)
{
unsigned int i;
struct map_session_data* pl_sd;
struct DBIterator *iter;
struct s_search_store_search s;
searchstore_searchall_t store_searchall;
time_t querytime;
if( !battle_config.feature_search_stores ) {
return;
}
if( !sd->searchstore.open ) {
return;
}
if( ( store_searchall = searchstore_getsearchallfunc(type) ) == NULL ) {
ShowError("searchstore_query: Tipo de procura desconhecida %u (account_id=%d).\n", (unsigned int)type, sd->bl.id);
return;
}
time(&querytime);
if( sd->searchstore.nextquerytime > querytime ) {
clif->search_store_info_failed(sd, SSI_FAILED_LIMIT_SEARCH_TIME);
return;
}
if( !sd->searchstore.uses ) {
clif->search_store_info_failed(sd, SSI_FAILED_SEARCH_CNT);
return;
}
// validate lists
for( i = 0; i < item_count; i++ ) {
if( !itemdb->exists(itemlist[i]) ) {
ShowWarning("searchstore_query: Item do Client determinado %hu nao se sabe.\n", itemlist[i]);
clif->search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
for( i = 0; i < card_count; i++ ) {
if( !itemdb->exists(cardlist[i]) ) {
ShowWarning("searchstore_query: Carta do Client determinado %hu nao se sabe.\n", cardlist[i]);
clif->search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
if( max_price < min_price ) {
swap(min_price, max_price);
}
sd->searchstore.uses--;
sd->searchstore.type = type;
sd->searchstore.nextquerytime = querytime+battle_config.searchstore_querydelay;
// drop previous results
searchstore->clear(sd);
// allocate max. amount of results
sd->searchstore.items = (struct s_search_store_info_item*)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);
// search
s.search_sd = sd;
s.itemlist = itemlist;
s.cardlist = cardlist;
s.item_count = item_count;
s.card_count = card_count;
s.min_price = min_price;
s.max_price = max_price;
iter = db_iterator(vending->db);
for( pl_sd = dbi_first(iter); dbi_exists(iter); pl_sd = dbi_next(iter) ) {
if( sd == pl_sd ) {// skip own shop, if any
continue;
}
if( !store_searchall(pl_sd, &s) ) {// exceeded result size
clif->search_store_info_failed(sd, SSI_FAILED_OVER_MAXCOUNT);
break;
}
}
dbi_destroy(iter);
if( sd->searchstore.count ) {
// reclaim unused memory
sd->searchstore.items = (struct s_search_store_info_item*)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);
// present results
clif->search_store_info_ack(sd);
// one page displayed
sd->searchstore.pages++;
} else {
// cleanup
searchstore->clear(sd);
//.........这里部分代码省略.........
示例4: itemdb_parse_dbrow
/*==========================================
* processes one itemdb entry
*------------------------------------------*/
static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
{
/*
+----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+
| 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
+----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+
| id | name_english | name_japanese | type | price_buy | price_sell | weight | attack | defence | range | slots | equip_jobs | equip_upper | equip_genders | equip_locations | weapon_level | equip_level | refineable | view | script | equip_script | unequip_script |
+----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+
*/
int nameid;
struct item_data* id;
nameid = atoi(str[0]);
if( nameid <= 0 )
{
ShowWarning("itemdb_parse_dbrow: Invalid id %d in line %d of \"%s\", skipping.\n", nameid, line, source);
return false;
}
//ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View
id = itemdb_load(nameid);
safestrncpy(id->name, str[1], sizeof(id->name));
safestrncpy(id->jname, str[2], sizeof(id->jname));
id->type = atoi(str[3]);
if( id->type < 0 || id->type == IT_UNKNOWN || id->type == IT_UNKNOWN2 || ( id->type > IT_DELAYCONSUME && id->type < IT_THROWWEAPON ) || id->type >= IT_MAX )
{// catch invalid item types
ShowWarning("itemdb_parse_dbrow: Invalid item type %d for item %d. IT_ETC will be used.\n", id->type, nameid);
id->type = IT_ETC;
}
if (id->type == IT_DELAYCONSUME)
{ //Items that are consumed only after target confirmation
id->type = IT_USABLE;
id->flag.delay_consume = 1;
} else //In case of an itemdb reload and the item type changed.
id->flag.delay_consume = 0;
//When a particular price is not given, we should base it off the other one
//(it is important to make a distinction between 'no price' and 0z)
if ( str[4][0] )
id->value_buy = atoi(str[4]);
else
id->value_buy = atoi(str[5]) * 2;
if ( str[5][0] )
id->value_sell = atoi(str[5]);
else
id->value_sell = id->value_buy / 2;
/*
if ( !str[4][0] && !str[5][0])
{
ShowWarning("itemdb_parse_dbrow: No buying/selling price defined for item %d (%s), using 20/10z\n", nameid, id->jname);
id->value_buy = 20;
id->value_sell = 10;
} else
*/
if (id->value_buy/124. < id->value_sell/75.)
ShowWarning("itemdb_parse_dbrow: Buying/Selling [%d/%d] price of item %d (%s) allows Zeny making exploit through buying/selling at discounted/overcharged prices!\n",
id->value_buy, id->value_sell, nameid, id->jname);
id->weight = atoi(str[6]);
#if REMODE
itemdb_re_split_atoi(str[7],&id->atk,&id->matk);
#else
id->atk = atoi(str[7]);
#endif
id->def = atoi(str[8]);
id->range = atoi(str[9]);
id->slot = atoi(str[10]);
if (id->slot > MAX_SLOTS)
{
ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d. Using %d slots.\n", nameid, id->jname, id->slot, MAX_SLOTS, MAX_SLOTS);
id->slot = MAX_SLOTS;
}
itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11],NULL,0));
id->class_upper = atoi(str[12]);
id->sex = atoi(str[13]);
id->equip = atoi(str[14]);
if (!id->equip && itemdb_isequip2(id))
{
ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname);
id->type = IT_ETC;
}
id->wlv = atoi(str[15]);
id->elv = atoi(str[16]);
id->flag.no_refine = atoi(str[17]) ? 0 : 1; //FIXME: verify this
id->look = atoi(str[18]);
id->flag.available = 1;
id->view_id = 0;
id->sex = itemdb_gendercheck(id); //Apply gender filtering.
//.........这里部分代码省略.........
示例5: netbuffer_init
void netbuffer_init()
{
char localsection[32];
raconf conf;
sysint i;
// Initialize Statistic counters:
l_nEmergencyAllocations = 0;
// Set localsection name according to running serverype.
switch(SERVER_TYPE) {
case SERVER_TYPE_LOGIN:
strcpy(localsection, "login-netbuffer");
break;
case SERVER_TYPE_CHAR:
strcpy(localsection, "char-netbuffer");
break;
//case ATHENA_SERVER_INTER: strcpy(localsection, "inter-netbuffer"); break;
case SERVER_TYPE_MAP:
strcpy(localsection, "map-netbuffer");
break;
default:
strcpy(localsection, "unsupported_type");
break;
}
conf = raconf_parse("conf/network.conf");
if(conf == NULL) {
ShowFatalError(read_message("Source.common.net_buffer_init"));
exit(EXIT_FAILURE);
}
// Get Values from config file
l_nPools = (sysint)raconf_getintEx(conf, localsection, "netbuffer", "num", 0);
if(l_nPools == 0) {
ShowFatalError(read_message("Source.common.net_buffer_init2"));
exit(EXIT_FAILURE);
}
// Allocate arrays.
l_poolElemSize = (sysint *)aCalloc(l_nPools, sizeof(sysint));
l_pool = (mempool *)aCalloc(l_nPools, sizeof(mempool));
for(i = 0; i < l_nPools; i++) {
int64 num_prealloc, num_realloc;
char key[32];
sprintf(key, "pool_%u_size", (uint32)i+1);
l_poolElemSize[i] = (sysint)raconf_getintEx(conf, localsection, "netbuffer", key, 4096);
if(l_poolElemSize[i] < 32) {
ShowWarning(read_message("Source.common.net_buffer_init3"));
l_poolElemSize[i] = 32;
}
sprintf(key, "pool_%u_prealloc", (uint32)i+1);
num_prealloc = raconf_getintEx(conf, localsection, "netbuffer", key, 150);
sprintf(key, "pool_%u_realloc_step", (uint32)i+1);
num_realloc = raconf_getintEx(conf, localsection, "netbuffer", key, 100);
// Create Pool!
sprintf(key, "Netbuffer %u", (uint32)l_poolElemSize[i]); // name.
// Info
ShowInfo(read_message("Source.net_buffer_init4"), l_poolElemSize[i], num_prealloc, num_realloc, (float)((sizeof(struct netbuf) + l_poolElemSize[i] - 32)* num_prealloc)/1024.0f/1024.0f);
//
// Size Calculation:
// struct netbuf + requested buffer size - 32 (because the struct already contains 32 byte buffer space at the end of struct)
l_pool[i] = mempool_create(key, (sizeof(struct netbuf) + l_poolElemSize[i] - 32), num_prealloc, num_realloc, NULL, NULL);
if(l_pool[i] == NULL) {
ShowFatalError(read_message("Source.net_buffer_init5"), l_poolElemSize[i]);
// @leak: clean everything :D
exit(EXIT_FAILURE);
}
}//
raconf_destroy(conf);
}//end: netbuffer_init()
示例6: plugin_open
Plugin* plugin_open(const char* filename)
{
Plugin* plugin;
Plugin_Info* info;
Plugin_Event_Table* events;
void** procs;
int init_flag = 1;
//ShowDebug("plugin_open(%s)\n", filename);
// Check if the plugin has been loaded before
plugin = plugin_head;
while (plugin) {
// returns handle to the already loaded plugin
if( plugin->state && strcmpi(plugin->filename, filename) == 0 ){
ShowWarning("plugin_open: not loaded (duplicate) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
return plugin;
}
plugin = plugin->next;
}
CREATE(plugin, Plugin, 1);
plugin->state = -1; // not loaded
plugin->dll = DLL_OPEN(filename);
if( !plugin->dll ){
ShowWarning("plugin_open: not loaded (invalid file) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
plugin_unload(plugin);
return NULL;
}
// Retrieve plugin information
plugin->state = 0; // initialising
info = (Plugin_Info*)DLL_SYM(plugin->dll, "plugin_info");
// For high priority plugins (those that are explicitly loaded from the conf file)
// we'll ignore them even (could be a 3rd party dll file)
if( !info )
{// foreign plugin
//ShowDebug("plugin_open: plugin_info not found\n");
if( load_priority == 0 )
{// not requested
//ShowDebug("plugin_open: not loaded (not requested) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
plugin_unload(plugin);
return NULL;
}
} else if( !plugin_iscompatible(info->req_version) )
{// incompatible version
ShowWarning("plugin_open: not loaded (incompatible version '%s' -> '%s') : '"CL_WHITE"%s"CL_RESET"'\n", info->req_version, PLUGIN_VERSION, filename);
plugin_unload(plugin);
return NULL;
} else if( (info->type != PLUGIN_ALL && info->type != PLUGIN_CORE && info->type != SERVER_TYPE) ||
(info->type == PLUGIN_CORE && SERVER_TYPE != PLUGIN_LOGIN && SERVER_TYPE != PLUGIN_CHAR && SERVER_TYPE != PLUGIN_MAP) )
{// not for this server
//ShowDebug("plugin_open: not loaded (incompatible) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
plugin_unload(plugin);
return NULL;
}
plugin->info = ( info != NULL ? info : &default_info );
plugin->filename = aStrdup(filename);
// Initialise plugin call table (For exporting procedures)
procs = (void**)DLL_SYM(plugin->dll, "plugin_call_table");
if( procs )
*procs = plugin_call_table;
//else ShowDebug("plugin_open: plugin_call_table not found\n");
// Register plugin events
events = (Plugin_Event_Table*)DLL_SYM(plugin->dll, "plugin_event_table");
if( events ){
int i = 0;
//ShowDebug("plugin_open: parsing plugin_event_table\n");
while( events[i].func_name ){
if( strcmpi(events[i].event_name, EVENT_PLUGIN_TEST) == 0 ){
Plugin_Test_Func* test_func;
test_func = (Plugin_Test_Func*)DLL_SYM(plugin->dll, events[i].func_name);
//ShowDebug("plugin_open: invoking "EVENT_PLUGIN_TEST" with %s()\n", events[i].func_name);
if( test_func && test_func() == 0 ){
// plugin has failed test, disabling
//ShowDebug("plugin_open: disabled (failed test) : %s\n", filename);
init_flag = 0;
}
} else {
Plugin_Event_Func* func;
func = (Plugin_Event_Func*)DLL_SYM(plugin->dll, events[i].func_name);
if (func)
register_plugin_event(func, events[i].event_name);
}
i++;
}
}
//else ShowDebug("plugin_open: plugin_event_table not found\n");
plugin->next = plugin_head;
plugin_head = plugin;
plugin->state = init_flag; // fully loaded
ShowStatus("Done loading plugin '"CL_WHITE"%s"CL_RESET"'\n", (info) ? plugin->info->name : filename);
return plugin;
//.........这里部分代码省略.........
示例7: account_db_txt_init
/// opens accounts file, loads it, and starts a periodic saving timer
static bool account_db_txt_init(AccountDB* self)
{
AccountDB_TXT* db = (AccountDB_TXT*)self;
DBMap* accounts;
FILE* fp;
char line[2048];
unsigned int version = 0;
// create accounts database
db->accounts = idb_alloc(DB_OPT_RELEASE_DATA);
accounts = db->accounts;
// open data file
fp = fopen(db->account_db, "r");
if( fp == NULL )
{
// no account file -> no account -> no login, including char-server (ERROR)
ShowError(CL_RED"account_db_txt_init: Accounts file [%s] not found."CL_RESET"\n", db->account_db);
return false;
}
// load data file
while( fgets(line, sizeof(line), fp) != NULL )
{
int account_id, n;
unsigned int v;
struct mmo_account acc;
struct mmo_account* tmp;
struct DBIterator* iter;
int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp;
if( line[0] == '/' && line[1] == '/' )
continue;
n = 0;
if( sscanf(line, "%d%n", &v, &n) == 1 && (line[n] == '\n' || line[n] == '\r') )
{// format version definition
version = v;
continue;
}
n = 0;
if( sscanf(line, "%d\t%%newid%%%n", &account_id, &n) == 1 && (line[n] == '\n' || line[n] == '\r') )
{// auto-increment
if( account_id > db->next_account_id )
db->next_account_id = account_id;
continue;
}
if( !mmo_auth_fromstr(&acc, line, version) )
{
ShowError("account_db_txt_init: skipping invalid data: %s", line);
continue;
}
// apply constraints & checks here
if( acc.sex != 'S' && (acc.account_id < START_ACCOUNT_NUM || acc.account_id > END_ACCOUNT_NUM) )
ShowWarning("account_db_txt_init: account %d:'%s' has ID outside of the defined range for accounts (min:%d max:%d)!\n", acc.account_id, acc.userid, START_ACCOUNT_NUM, END_ACCOUNT_NUM);
iter = accounts->iterator(accounts);
for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) )
if( compare(acc.userid, tmp->userid) == 0 )
break;
iter->destroy(iter);
if( tmp != NULL )
{// entry with identical username
ShowWarning("account_db_txt_init: account %d:'%s' has same username as account %d. The account will be inaccessible!\n", acc.account_id, acc.userid, tmp->account_id);
}
if( idb_get(accounts, acc.account_id) != NULL )
{// account id already occupied
ShowError("account_db_txt_init: ID collision for account id %d! Discarding data for account '%s'...\n", acc.account_id, acc.userid);
continue;
}
// record entry in db
tmp = (struct mmo_account*)aMalloc(sizeof(struct mmo_account));
memcpy(tmp, &acc, sizeof(struct mmo_account));
idb_put(accounts, acc.account_id, tmp);
if( acc.account_id >= db->next_account_id )
db->next_account_id = acc.account_id + 1;
}
// close data file
fclose(fp);
// initialize data saving timer
add_timer_func_list(mmo_auth_sync_timer, "mmo_auth_sync_timer");
db->save_timer = add_timer_interval(gettick() + AUTH_SAVING_INTERVAL, mmo_auth_sync_timer, 0, (intptr)db, AUTH_SAVING_INTERVAL);
return true;
}
示例8: chrif_parse
/*==========================================
*
*------------------------------------------*/
int chrif_parse(int fd) {
int packet_len, cmd;
// only process data from the char-server
if ( fd != char_fd ) {
ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd);
do_close(fd);
return 0;
}
if ( session[fd]->flag.eof ) {
do_close(fd);
char_fd = -1;
chrif_on_disconnect();
return 0;
} else if ( session[fd]->flag.ping ) {/* we've reached stall time */
if( DIFF_TICK(last_tick, session[fd]->rdata_tick) > (stall_time * 2) ) {/* we can't wait any longer */
set_eof(fd);
return 0;
} else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
chrif_keepalive(fd);
session[fd]->flag.ping = 2;
}
}
while ( RFIFOREST(fd) >= 2 ) {
cmd = RFIFOW(fd,0);
if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(packet_len_table) || packet_len_table[cmd-0x2af8] == 0) {
int r = intif_parse(fd); // Passed on to the intif
if (r == 1) continue; // Treated in intif
if (r == 2) return 0; // Didn't have enough data (len==-1)
ShowWarning("chrif_parse: session #%d, intif_parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
set_eof(fd);
return 0;
}
if ( ( packet_len = packet_len_table[cmd-0x2af8] ) == -1) { // dynamic-length packet, second WORD holds the length
if (RFIFOREST(fd) < 4)
return 0;
packet_len = RFIFOW(fd,2);
}
if ((int)RFIFOREST(fd) < packet_len)
return 0;
//ShowDebug("Received packet 0x%4x (%d bytes) from char-server (connection %d)\n", RFIFOW(fd,0), packet_len, fd);
switch(cmd) {
case 0x2af9: chrif_connectack(fd); break;
case 0x2afb: chrif_sendmapack(fd); break;
case 0x2afd: chrif_authok(fd); break;
case 0x2b00: map_setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break;
case 0x2b03: clif->charselectok(RFIFOL(fd,2), RFIFOB(fd,6)); break;
case 0x2b04: chrif_recvmap(fd); break;
case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break;
case 0x2b09: map_addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break;
case 0x2b0a: socket_datasync(fd, false); break;
case 0x2b0d: chrif_changedsex(fd); break;
case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break;
case 0x2b12: chrif_divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break;
case 0x2b14: chrif_accountban(fd); break;
case 0x2b1b: chrif_recvfamelist(fd); break;
case 0x2b1d: chrif_load_scdata(fd); break;
case 0x2b1e: chrif_update_ip(fd); break;
case 0x2b1f: chrif_disconnectplayer(fd); break;
case 0x2b20: chrif_removemap(fd); break;
case 0x2b21: chrif_save_ack(fd); break;
case 0x2b22: chrif_updatefamelist_ack(fd); break;
case 0x2b24: chrif_keepalive_ack(fd); break;
case 0x2b25: chrif_deadopt(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
case 0x2b27: chrif_authfail(fd); break;
default:
ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd);
set_eof(fd);
return 0;
}
if ( fd == char_fd ) //There's the slight chance we lost the connection during parse, in which case this would segfault if not checked [Skotlex]
RFIFOSKIP(fd, packet_len);
}
return 0;
}
示例9: mapif_parse_WisRequest
// Wisp/page request to send
int mapif_parse_WisRequest(int fd) {
struct WisData* wd;
static int wisid = 0;
char name[NAME_LENGTH], t_name[NAME_LENGTH*2]; //Needs space to allocate names with escaped chars [Skotlex]
if ( fd <= 0 ) {return 0;} // check if we have a valid fd
if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) {
ShowWarning("inter: Wis message size too long.\n");
return 0;
} else if (RFIFOW(fd,2)-52 <= 0) { // normaly, impossible, but who knows...
ShowError("inter: Wis message doesn't exist.\n");
return 0;
}
memcpy(name, RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]
name[NAME_LENGTH-1]= '\0';
sprintf (tmp_sql, "SELECT `name` FROM `%s` WHERE `name`='%s'",
char_db, jstrescapecpy(t_name, name));
if(mysql_query(&mysql_handle, tmp_sql) ) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
sql_res = mysql_store_result(&mysql_handle);
// search if character exists before to ask all map-servers
if (!(sql_row = mysql_fetch_row(sql_res))) {
unsigned char buf[27];
WBUFW(buf, 0) = 0x3802;
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
mapif_send(fd, buf, 27);
// Character exists. So, ask all map-servers
} else {
// to be sure of the correct name, rewrite it
memset(name, 0, NAME_LENGTH);
strncpy(name, sql_row[0], NAME_LENGTH);
// if source is destination, don't ask other servers.
if (strcmp((char*)RFIFOP(fd,4),name) == 0) {
unsigned char buf[27];
WBUFW(buf, 0) = 0x3802;
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
mapif_send(fd, buf, 27);
} else {
CREATE(wd, struct WisData, 1);
// Whether the failure of previous wisp/page transmission (timeout)
check_ttl_wisdata();
wd->id = ++wisid;
wd->fd = fd;
wd->len= RFIFOW(fd,2)-52;
memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH);
memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH);
memcpy(wd->msg, RFIFOP(fd,52), wd->len);
wd->tick = gettick();
numdb_insert(wis_db, wd->id, wd);
mapif_wis_message(wd);
}
}
//Freeing ... O.o
if(sql_res){
mysql_free_result(sql_res);
}
return 0;
}
示例10: mercenary_readdb_sub
/**
* Read each line of Mercenary's database
**/
static bool mercenary_readdb_sub(char* str[], int columns, int current)
{
int ele;
uint16 i, class_ = atoi(str[0]);
struct s_mercenary_db *db;
struct status_data *status;
//Find the ID, already exist or not in mercenary_db
ARR_FIND(0,mercenary_count,i,mercenary_db[i].class_ == class_);
if (i >= mercenary_count)
db = &mercenary_db[mercenary_count];
else
db = &mercenary_db[i];
db->class_ = class_;
safestrncpy(db->sprite, str[1], NAME_LENGTH);
safestrncpy(db->name, str[2], NAME_LENGTH);
db->lv = atoi(str[3]);
status = &db->status;
db->vd.class_ = db->class_;
status->max_hp = atoi(str[4]);
status->max_sp = atoi(str[5]);
status->rhw.range = atoi(str[6]);
status->rhw.atk = atoi(str[7]);
status->rhw.atk2 = status->rhw.atk + atoi(str[8]);
status->def = atoi(str[9]);
status->mdef = atoi(str[10]);
status->str = atoi(str[11]);
status->agi = atoi(str[12]);
status->vit = atoi(str[13]);
status->int_ = atoi(str[14]);
status->dex = atoi(str[15]);
status->luk = atoi(str[16]);
db->range2 = atoi(str[17]);
db->range3 = atoi(str[18]);
status->size = atoi(str[19]);
status->race = atoi(str[20]);
ele = atoi(str[21]);
status->def_ele = ele%20;
status->ele_lv = (unsigned char)floor(ele/20.);
if( !CHK_ELEMENT(status->def_ele) )
{
ShowWarning("Mercenary %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_ALL - 1);
status->def_ele = ELE_NEUTRAL;
}
if( !CHK_ELEMENT_LEVEL(status->ele_lv) )
{
ShowWarning("Mercenary %d has invalid element level %d (max is %d)\n", db->class_, status->ele_lv, MAX_ELE_LEVEL);
status->ele_lv = 1;
}
status->aspd_rate = 1000;
status->speed = atoi(str[22]);
status->adelay = atoi(str[23]);
status->amotion = atoi(str[24]);
status->dmotion = atoi(str[25]);
if (i >= mercenary_count)
mercenary_count++;
return true;
}
示例11: yaml_invalid_warning
void yaml_invalid_warning(const char* fmt, YAML::Node &node, std::string &file) {
YAML::Emitter out;
out << node;
ShowWarning(fmt, file.c_str());
ShowMessage("%s\n", out.c_str());
}
示例12: DSP_DEBUG_BREAK_IF
void CZone::DecreaseZoneCounter(CCharEntity* PChar)
{
DSP_DEBUG_BREAK_IF(PChar == NULL);
DSP_DEBUG_BREAK_IF(PChar->loc.zone != this);
//remove pets
if(PChar->PPet != NULL)
{
charutils::BuildingCharPetAbilityTable(PChar,(CPetEntity*)PChar->PPet,0);//blank the pet commands
if(PChar->PPet->isCharmed) {
petutils::DespawnPet(PChar);
}
else {
PChar->PPet->status = STATUS_DISAPPEAR;
if( ((CPetEntity*)(PChar->PPet))->getPetType() == PETTYPE_AVATAR )
PChar->setModifier(MOD_AVATAR_PERPETUATION, 0);
}
// It may have been nulled by DespawnPet
if(PChar->PPet != NULL) {
PChar->PPet->PBattleAI->SetCurrentAction(ACTION_NONE);
DeletePET(PChar->PPet);//remove the TID for this pet
for (EntityList_t::const_iterator it = m_charList.begin() ; it != m_charList.end() ; ++it)
{
//inform other players of the pets removal
CCharEntity* PCurrentChar = (CCharEntity*)it->second;
SpawnIDList_t::iterator PET = PCurrentChar->SpawnPETList.find(PChar->PPet->id);
if( PET != PCurrentChar->SpawnPETList.end() )
{
PCurrentChar->SpawnPETList.erase(PET);
PCurrentChar->pushPacket(new CEntityUpdatePacket(PChar->PPet, ENTITY_DESPAWN));
}
}
PChar->PPet = NULL;
}
}
//remove bcnm status
if(m_InstanceHandler != NULL && PChar->StatusEffectContainer->HasStatusEffect(EFFECT_BATTLEFIELD))
{
if(m_InstanceHandler->disconnectFromBcnm(PChar)){
ShowDebug("Removed %s from the BCNM they were in as they have left the zone.\n",PChar->GetName());
}
if(PChar->loc.destination==0){ //this player is disconnecting/logged out, so move them to the entrance
//move depending on zone
int pos[4] = {0,0,0,0};
instanceutils::getStartPosition(m_zoneID,pos);
if(pos!=NULL){
PChar->loc.p.x = pos[0];
PChar->loc.p.y = pos[1];
PChar->loc.p.z = pos[2];
PChar->loc.p.rotation = pos[3];
charutils::SaveCharPosition(PChar);
}
else{
ShowWarning("%s has disconnected from the BCNM but cannot move them to the lobby as the lobby position is unknown!\n",PChar->GetName());
}
}
}
else if(m_InstanceHandler != NULL && PChar->StatusEffectContainer->HasStatusEffect(EFFECT_DYNAMIS, 0))
{
if(m_InstanceHandler->disconnectFromDynamis(PChar)){
ShowDebug("Removed %s from the BCNM they were in as they have left the zone.\n",PChar->GetName());
}
if(PChar->loc.destination==0){ //this player is disconnecting/logged out, so move them to the entrance
//move depending on zone
int pos[4] = {0,0,0,0};
instanceutils::getStartPosition(m_zoneID,pos);
if(pos!=NULL){
PChar->loc.p.x = pos[0];
PChar->loc.p.y = pos[1];
PChar->loc.p.z = pos[2];
PChar->loc.p.rotation = pos[3];
charutils::SaveCharPosition(PChar);
}
else{
ShowWarning("%s has disconnected from the BCNM but cannot move them to the lobby as the lobby position is unknown!\n",PChar->GetName());
}
}
}
for (EntityList_t::const_iterator it = m_mobList.begin() ; it != m_mobList.end() ; ++it)
{
CMobEntity* PCurrentMob = (CMobEntity*)it->second;
PCurrentMob->PEnmityContainer->Clear(PChar->id);
if(PCurrentMob->m_OwnerID.id == PChar->id){
PCurrentMob->m_OwnerID.clean();
}
}
// TODO: могут возникать проблемы с переходом между одной и той же зоной (zone == prevzone)
m_charList.erase(PChar->targid);
ShowDebug(CL_CYAN"CZone:: %s DecreaseZoneCounter <%u> %s\n" CL_RESET, GetName(), m_charList.size(),PChar->GetName());
if (ZoneTimer && m_charList.empty())
//.........这里部分代码省略.........
示例13: read_elemental_skilldb
int read_elemental_skilldb(void)
{
FILE *fp;
char line[1024], *p;
char *str[4];
struct s_elemental_db *db;
int i, j = 0, k = 0, class_;
int skillid, skilllv, skillmode;
sprintf(line, "%s/%s", db_path, "elemental_skill_db.txt");
fp = fopen(line, "r");
if( !fp )
{
ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n");
return -1;
}
while( fgets(line, sizeof(line), fp) )
{
k++;
if( line[0] == '/' && line[1] == '/' )
continue;
i = 0;
p = strtok(line, ",");
while( p != NULL && i < 4 )
{
str[i++] = p;
p = strtok(NULL, ",");
}
if( i < 4 )
{
ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k);
continue;
}
class_ = atoi(str[0]);
ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental_db[i].class_);
if( i == MAX_ELEMENTAL_CLASS )
{
ShowError("read_elemental_skilldb : Class not found in elemental_db for skill entry, line %d.\n", k);
continue;
}
skillid = atoi(str[1]);
if( skillid < EL_SKILLBASE || skillid >= EL_SKILLBASE + MAX_ELEMENTALSKILL )
{
ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k);
continue;
}
db = &elemental_db[i];
skilllv = atoi(str[2]);
skillmode = atoi(str[3]);
if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE )
{
ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k);
skillmode = EL_SKILLMODE_PASIVE;
continue;
}
ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skillid );
if( i == MAX_ELESKILLTREE )
{
ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skillid, class_);
continue;
}
db->skill[i].id = skillid;
db->skill[i].lv = skilllv;
db->skill[i].mode = skillmode;
j++;
}
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j);
return 0;
}
示例14: read_elementaldb
int read_elementaldb(void)
{
FILE *fp;
char line[1024], *p;
char *str[26];
int i, j = 0, k = 0, ele;
struct s_elemental_db *db;
struct status_data *status;
sprintf(line, "%s/%s", db_path, "elemental_db.txt");
memset(elemental_db,0,sizeof(elemental_db));
fp = fopen(line, "r");
if( !fp )
{
ShowError("read_elementaldb : can't read elemental_db.txt\n");
return -1;
}
while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS )
{
k++;
if( line[0] == '/' && line[1] == '/' )
continue;
i = 0;
p = strtok(line, ",");
while( p != NULL && i < 26 )
{
str[i++] = p;
p = strtok(NULL, ",");
}
if( i < 26 )
{
ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k);
continue;
}
db = &elemental_db[j];
db->class_ = atoi(str[0]);
strncpy(db->sprite, str[1], NAME_LENGTH);
strncpy(db->name, str[2], NAME_LENGTH);
db->lv = atoi(str[3]);
status = &db->status;
db->vd.class_ = db->class_;
status->max_hp = atoi(str[4]);
status->max_sp = atoi(str[5]);
status->rhw.range = atoi(str[6]);
status->rhw.atk = atoi(str[7]);
status->rhw.atk2 = status->rhw.atk + atoi(str[8]);
status->def = atoi(str[9]);
status->mdef = atoi(str[10]);
status->str = atoi(str[11]);
status->agi = atoi(str[12]);
status->vit = atoi(str[13]);
status->int_ = atoi(str[14]);
status->dex = atoi(str[15]);
status->luk = atoi(str[16]);
db->range2 = atoi(str[17]);
db->range3 = atoi(str[18]);
status->size = atoi(str[19]);
status->race = atoi(str[20]);
ele = atoi(str[21]);
status->def_ele = ele%10;
status->ele_lv = ele/20;
if( status->def_ele >= ELE_MAX )
{
ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1);
status->def_ele = ELE_NEUTRAL;
}
if( status->ele_lv < 1 || status->ele_lv > 4 )
{
ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv);
status->ele_lv = 1;
}
status->aspd_rate = 1000;
status->speed = atoi(str[22]);
status->adelay = atoi(str[23]);
status->amotion = atoi(str[24]);
status->dmotion = atoi(str[25]);
j++;
}
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j);
return 0;
}
示例15: 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;
//.........这里部分代码省略.........