diff options
-rw-r--r-- | conf/char-server.conf | 8 | ||||
-rw-r--r-- | src/char/char.c | 43 |
2 files changed, 28 insertions, 23 deletions
diff --git a/conf/char-server.conf b/conf/char-server.conf index da0b8d45b..b2120471c 100644 --- a/conf/char-server.conf +++ b/conf/char-server.conf @@ -94,11 +94,9 @@ save_log: yes // Start point, Map name followed by coordinates (x,y) start_point: new_1-1,53,111 -// Starting weapon for new characters -start_weapon: 1201 - -// Starting armor for new characters -start_armor: 2301 +// Starting items for new characters +// Format is: id1,qt1,idn,qtn +start_items: 1201,1,2301,1 // Starting zeny for new characters start_zeny: 0 diff --git a/src/char/char.c b/src/char/char.c index ce0d067a7..782036647 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -125,8 +125,7 @@ int max_connect_user = -1; int gm_allow_group = -1; int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; int start_zeny = 0; -int start_weapon = 1201; -int start_armor = 2301; +int start_items[64]; //32 starting items allowed [mkbu95] int guild_exp_rate = 100; //Custom limits for the fame lists. [Skotlex] @@ -1530,7 +1529,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; + int char_id, flag, k; safestrncpy(name, name_, NAME_LENGTH); normalize_name(name,TRIM_CHARS); @@ -1594,13 +1593,10 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag //Retrieve the newly auto-generated char id char_id = (int)Sql_LastInsertId(sql_handle); //Give the char the default items - if (start_weapon > 0) { //add Start Weapon (Knife?) - 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_weapon, 1, 1) ) - Sql_ShowDebug(sql_handle); - } - if (start_armor > 0) { //Add default armor (cotton shirt?) - 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_armor, 1, 1) ) - Sql_ShowDebug(sql_handle); + + 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); } ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, char_id, slot, name); @@ -4812,18 +4808,29 @@ int char_config_read(const char* cfgName) ShowError("Specified start_point %s not found in map-index cache.\n", map); start_point.x = x; start_point.y = y; + } else if (strcmpi(w1, "start_items") == 0) { + int i; + char *split, *split2; + + i = 0; + split = strtok(w2, ","); + while (split != NULL) { + 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; + } } else if (strcmpi(w1, "start_zeny") == 0) { start_zeny = atoi(w2); if (start_zeny < 0) start_zeny = 0; - } else if (strcmpi(w1, "start_weapon") == 0) { - start_weapon = atoi(w2); - if (start_weapon < 0) - start_weapon = 0; - } else if (strcmpi(w1, "start_armor") == 0) { - start_armor = atoi(w2); - if (start_armor < 0) - start_armor = 0; } else if(strcmpi(w1,"log_char")==0) { //log char or not [devil] log_char = atoi(w2); } else if (strcmpi(w1, "unknown_char_name") == 0) { |