diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-25 20:53:56 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-25 20:53:56 +0000 |
commit | 18db3b8f930d711fab34897f7be303c430d0cf41 (patch) | |
tree | afd94ecf1991ea84e86e4ba630259e4c9ede9d4c /src/gui | |
parent | 587275709eb11a036ed474bf6a61f1fd34fc069f (diff) | |
download | mana-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')
-rw-r--r-- | src/gui/npc.cpp | 19 | ||||
-rw-r--r-- | src/gui/npc.h | 2 |
2 files changed, 11 insertions, 10 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(); diff --git a/src/gui/npc.h b/src/gui/npc.h index a0828a9a..02cc7eb1 100644 --- a/src/gui/npc.h +++ b/src/gui/npc.h @@ -27,7 +27,7 @@ struct ITEM { }; char *item_list(int index, int *list_size); -void parse_items(char *string, short len); +void parse_items(const char *string); void remove_all_items(); #endif |