viewing paste ra_startingitem | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <malloc.h>
 
+#define MAX_STARTITEM 32
 #define CHAR_MAX_MSG 300
 static char* msg_table[CHAR_MAX_MSG]; // Login Server messages_conf
 
@@ -143,12 +144,16 @@
    unsigned int char_moves[MAX_CHARS]; // character moves left
 };
 
+struct startitem {
+   int nameid;
+   int amout;
+   int autoequip;
+} start_items[MAX_STARTITEM+1];
+
 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 guild_exp_rate = 100;
 
 // Pincode system
@@ -1531,7 +1536,7 @@
 
    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);
@@ -1606,14 +1611,10 @@
    //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) )
+   for (k = 0; k <= MAX_STARTITEM && start_items[k].nameid != 0; k ++) {
+       if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`char_id`,`nameid`, `amount`, `equip`, `identify`) VALUES ('%d', '%d', '%d', '%d')", inventory_db, char_id, start_items[k].nameid, start_items[k].amout, start_items[k].autoequip, 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);
-   }
 
    ShowInfo("Created char: account: %d, char: %d, slot: %d, name: %s\n", sd->account_id, char_id, slot, name);
    return char_id;
@@ -4986,14 +4987,31 @@
            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, "start_items") == 0) {
+           int i=0, n=0;
+           char *split, **fields;
+           int fields_length = 3+1;
+           fields = (char**)aMalloc(fields_length*sizeof(char*));
+
+           split = strtok(w2, ";");
+           while (split != NULL) {
+               n = sv_split(split, strlen(split), 0, ',', fields, fields_length, SV_NOESCAPE_NOTERMINATE);
+               if(i > MAX_STARTITEM){
+                   ShowDebug("start_items overbound, only %d items are allowed ignoring parameter %s\n",MAX_STARTITEM,split);
+                   break;
+               }
+               else if(n+1 < fields_length){
+                   ShowDebug("start_items not enough argument for %s; YOU STUPID BASTARD\n",split);
+               }
+               else {
+                   start_items[i].nameid = max(0,atoi(fields[1]));
+                   start_items[i].amout = max(0,atoi(fields[2]));
+                   start_items[i].autoequip = max(0,atoi(fields[3]));
+               }
+               split = strtok(NULL, ";"); //next item
+               i++;
+           }
+           aFree(fields);
        } else if(strcmpi(w1,"log_char")==0) {      //log char or not [devil]
            log_char = atoi(w2);
        } else if (strcmpi(w1, "unknown_char_name") == 0) {
Viewed 1033 times, submitted by lighta.