diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2004-11-12 15:11:47 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2004-11-12 15:11:47 +0000 |
commit | 526f9a301caa29d1922561104de9aea8bc213b65 (patch) | |
tree | bc2852547d0b41843375dcf406c00e1ee54117d9 /src/gui/npc.cpp | |
parent | 628ac878c21c5150528b969ac151cd2450e2549d (diff) | |
download | mana-client-526f9a301caa29d1922561104de9aea8bc213b65.tar.gz mana-client-526f9a301caa29d1922561104de9aea8bc213b65.tar.bz2 mana-client-526f9a301caa29d1922561104de9aea8bc213b65.tar.xz mana-client-526f9a301caa29d1922561104de9aea8bc213b65.zip |
NPC lists
Diffstat (limited to 'src/gui/npc.cpp')
-rw-r--r-- | src/gui/npc.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 0b7a7102..37fc4eb2 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -50,7 +50,7 @@ char *item_list(int index, int *list_size) { void add_item(char *name) { ITEM *item = item_head; ITEM *temp = (ITEM *)malloc(sizeof(ITEM)); - temp->name = NULL; + //temp->name = NULL; temp->name = name; temp->next = NULL; if(!item_head) @@ -63,16 +63,29 @@ void add_item(char *name) { item_number++; } +void remove_tail() { + int iterator = 0; + ITEM *temp = item_head; + while(iterator<item_number-2) { + temp = temp->next; + iterator++; + } + free(temp->next); + temp->next = NULL; + item_number--; +} + void parse_items(char *string, short len) { char *token = strtok(string, ":"); while(token!=NULL) { - if(strcmp(token, "you prefer?")!=0) { // temp fix for the barber script + //if(strcmp(token, "you prefer?")!=0) { // temp fix for the barber script char *temp = (char *)malloc(strlen(token)); strcpy(temp, token); add_item(temp); - } + //} token = strtok(NULL, ":"); - } + } + remove_tail(); } void remove_all_items() { @@ -87,6 +100,5 @@ void remove_all_items() { } item_head = NULL; item_number = 0; -} - +} |