diff options
author | panikon <panikon@zoho.com> | 2014-02-13 16:33:10 -0200 |
---|---|---|
committer | panikon <panikon@zoho.com> | 2014-02-13 16:33:10 -0200 |
commit | 94b80cf63ba464e956941459903af6df128951e0 (patch) | |
tree | 7c19c33c96e5e4c308c2641c155b1871a0889a23 | |
parent | ba123df3939ff378ca6499ebd9508a7e79abd37d (diff) | |
download | hercules-94b80cf63ba464e956941459903af6df128951e0.tar.gz hercules-94b80cf63ba464e956941459903af6df128951e0.tar.bz2 hercules-94b80cf63ba464e956941459903af6df128951e0.tar.xz hercules-94b80cf63ba464e956941459903af6df128951e0.zip |
Fixed bug 7279
http://hercules.ws/board/tracker/issue-7279-starting-items/
-rw-r--r-- | conf/char-server.conf | 7 | ||||
-rw-r--r-- | src/char/char.c | 45 |
2 files changed, 40 insertions, 12 deletions
diff --git a/conf/char-server.conf b/conf/char-server.conf index 4ff2a3398..b1172e654 100644 --- a/conf/char-server.conf +++ b/conf/char-server.conf @@ -98,8 +98,11 @@ save_log: yes start_point: new_1-1,53,111 // Starting items for new characters -// Format is: id1,qt1,idn,qtn -start_items: 1201,1,2301,1 +// Format is: id1,quantity1,stackable1,idN,quantityN,stackableN +// stackable: +// 0 - Not stackable (weapon, armor, egg, pet armor) +// 1 - Stackable +start_items: 1201,1,0,2301,1,0 // Starting zeny for new characters start_zeny: 0 diff --git a/src/char/char.c b/src/char/char.c index 4ea1f8451..1ee3cfd1d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -137,7 +137,7 @@ int max_connect_user = -1; int gm_allow_group = -1; int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; int start_zeny = 0; -int start_items[MAX_START_ITEMS*2]; +int start_items[MAX_START_ITEMS*3]; int guild_exp_rate = 100; //Custom limits for the fame lists. [Skotlex] @@ -1579,7 +1579,7 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; - int char_id, flag, k; + int char_id, flag, k, l; safestrncpy(name, name_, NAME_LENGTH); normalize_name(name,TRIM_CHARS); @@ -1642,11 +1642,29 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag #endif //Retrieve the newly auto-generated char id char_id = (int)SQL->LastInsertId(sql_handle); + //Give the char the default items - - for (k = 0; k < ARRAYLENGTH(start_items) && start_items[k] != 0; k += 2) { - if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", inventory_db, char_id, start_items[k], start_items[k + 1], 1) ) - Sql_ShowDebug(sql_handle); + for (k = 0; k < ARRAYLENGTH(start_items) && start_items[k] != 0; k += 3) { + // FIXME: How to define if an item is stackable without having to lookup itemdb? [panikon] + if( start_items[k+2] == 1 ) + { + if( SQL_ERROR == SQL->Query(sql_handle, + "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", + inventory_db, char_id, start_items[k], start_items[k + 1], 1) ) + Sql_ShowDebug(sql_handle); + } + else if( start_items[k+2] == 0 ) + { + // Non-stackable items should have their own entries (issue: 7279) + for( l = 0; l < start_items[k+1]; l++ ) + { + if( SQL_ERROR == SQL->Query(sql_handle, + "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `identify`) VALUES ('%d', '%d', '%d', '%d')", + inventory_db, char_id, start_items[k], 1, 1) + ) + Sql_ShowDebug(sql_handle); + } + } } ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, char_id, slot, name); @@ -5195,18 +5213,25 @@ int char_config_read(const char* cfgName) i = 0; split = strtok(w2, ","); - while (split != NULL && i < MAX_START_ITEMS*2) { + while (split != NULL && i < MAX_START_ITEMS*3) { split2 = split; split = strtok(NULL, ","); start_items[i] = atoi(split2); + if (start_items[i] < 0) start_items[i] = 0; + ++i; } - if (i%2) { //we know it must be a even number - ShowError("Specified 'start_items' is missing a parameter. Removing '%d'.\n", start_items[i - 1]); - start_items[i - 1] = 0; + // Format is: id1,quantity1,stackable1,idN,quantityN,stackableN + if( i%3 ) + { + ShowWarning("char_config_read: There are not enough parameters in start_items, ignoring last item...\n"); + if( i%3 == 1 ) + start_items[i-1] = 0; + else + start_items[i-2] = 0; } } else if (strcmpi(w1, "start_zeny") == 0) { start_zeny = atoi(w2); |