summaryrefslogtreecommitdiff
path: root/src/gui/npc.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-25 20:53:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-25 20:53:56 +0000
commit18db3b8f930d711fab34897f7be303c430d0cf41 (patch)
treeafd94ecf1991ea84e86e4ba630259e4c9ede9d4c /src/gui/npc.cpp
parent587275709eb11a036ed474bf6a61f1fd34fc069f (diff)
downloadmana-18db3b8f930d711fab34897f7be303c430d0cf41.tar.gz
mana-18db3b8f930d711fab34897f7be303c430d0cf41.tar.bz2
mana-18db3b8f930d711fab34897f7be303c430d0cf41.tar.xz
mana-18db3b8f930d711fab34897f7be303c430d0cf41.zip
Some corrections made to parse_items. Something still seems to go wrong at the
server side though.
Diffstat (limited to 'src/gui/npc.cpp')
-rw-r--r--src/gui/npc.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp
index a5089123..29dc12d2 100644
--- a/src/gui/npc.cpp
+++ b/src/gui/npc.cpp
@@ -45,29 +45,30 @@ void add_item(char *name) {
}
void remove_tail() {
- //free(items.back()->name);
+ free(items.back()->name);
free(items.back());
items.pop_back();
}
-void parse_items(char *string, short len) {
- char *token = strtok(string, ":");
+void parse_items(const char *string) {
+ char *copy = new char[strlen(string) + 1];
+ strcpy(copy, string);
+
+ char *token = strtok(copy, ":");
while (token != NULL) {
- // temp fix for the barber script
- //if (strcmp(token, "you prefer?") != 0) {
- char *temp = (char*)malloc(strlen(token));
+ char *temp = (char*)malloc(strlen(token) + 1);
strcpy(temp, token);
add_item(temp);
- //}
token = strtok(NULL, ":");
}
- remove_tail();
+
+ delete[] copy;
}
void remove_all_items() {
int i;
for (i = 0; i < items.size(); i++) {
- //free(items[i]->name);
+ free(items[i]->name);
free(items[i]);
}
items.clear();